Skip to contentSkip to conversation

rtc: Pass the IRQF_ONESHOT flag

PATCH In review Fabio Estevam 3 participants 5 messages Aug 14, 2015 – Oct 16, 2015

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rtc: Pass the IRQF_ONESHOT flag

From: Fabio Estevam <[email protected]>

Since commit 1c6c69525b40eb76de8adf039409722015927dc3 ("genirq: Reject bogus threaded irq requests") threaded IRQs without a primary handler need to be requested with IRQF_ONESHOT, otherwise the request will fail.

So pass the IRQF_ONESHOT flag in this case.

The semantic patch that makes this change is available in scripts/coccinelle/misc/irqf_oneshot.cocci

---
 drivers/rtc/rtc-isl1208.c  | 2 +-
 drivers/rtc/rtc-lp8788.c   | 2 +-
 drivers/rtc/rtc-max77686.c | 3 ++-
 drivers/rtc/rtc-max77802.c | 3 ++-
 drivers/rtc/rtc-max8997.c  | 2 +-
 drivers/rtc/rtc-max8998.c  | 3 ++-
 drivers/rtc/rtc-rc5t583.c  | 2 +-
 drivers/rtc/rtc-rk808.c    | 2 +-
 drivers/rtc/rtc-s5m.c      | 3 ++-
 drivers/rtc/rtc-tps65910.c | 3 ++-
 drivers/rtc/rtc-wm831x.c   | 3 ++-
 11 files changed, 17 insertions(+), 11 deletions(-)
drivers/rtc/rtc-isl1208.c +1 -1
index aa3b8f1..b57a304 100644
@@ -638,7 +638,7 @@ isl1208_probe(struct i2c_client *client, const struct i2c_device_id *id)
 	if (client->irq > 0) {
 		rc = devm_request_threaded_irq(&client->dev, client->irq, NULL,
 					       isl1208_rtc_interrupt,
-					       IRQF_SHARED,
+					       IRQF_SHARED | IRQF_ONESHOT,
 					       isl1208_driver.driver.name,
 					       client);
 		if (!rc) {
drivers/rtc/rtc-lp8788.c +1 -1
index e20e7bd..e0de665 100644
@@ -280,7 +280,7 @@ static int lp8788_alarm_irq_register(struct platform_device *pdev,
 
 	return devm_request_threaded_irq(&pdev->dev, rtc->irq, NULL,
 				lp8788_alarm_irq_handler,
-				0, LP8788_ALM_IRQ, rtc);
+				IRQF_ONESHOT, LP8788_ALM_IRQ, rtc);
 }
 
 static int lp8788_rtc_probe(struct platform_device *pdev)
drivers/rtc/rtc-max77686.c +2 -1
index 7184a0e..06d1354 100644
@@ -471,7 +471,8 @@ static int max77686_rtc_probe(struct platform_device *pdev)
 	}
 
 	ret = devm_request_threaded_irq(&pdev->dev, info->virq, NULL,
-				max77686_rtc_alarm_irq, 0, "rtc-alarm1", info);
+				max77686_rtc_alarm_irq, IRQF_ONESHOT,
+				"rtc-alarm1", info);
 	if (ret < 0)
 		dev_err(&pdev->dev, "Failed to request alarm IRQ: %d: %d\n",
 			info->virq, ret);
drivers/rtc/rtc-max77802.c +2 -1
index 82ffcc5..e275d9b 100644
@@ -444,7 +444,8 @@ static int max77802_rtc_probe(struct platform_device *pdev)
 	}
 
 	ret = devm_request_threaded_irq(&pdev->dev, info->virq, NULL,
-					max77802_rtc_alarm_irq, 0, "rtc-alarm1",
+					max77802_rtc_alarm_irq, IRQF_ONESHOT,
+					"rtc-alarm1",
 					info);
 	if (ret < 0)
 		dev_err(&pdev->dev, "Failed to request alarm IRQ: %d: %d\n",
drivers/rtc/rtc-max8997.c +1 -1
index 9e02bcd..48e8ae4 100644
@@ -499,7 +499,7 @@ static int max8997_rtc_probe(struct platform_device *pdev)
 	info->virq = virq;
 
 	ret = devm_request_threaded_irq(&pdev->dev, virq, NULL,
-				max8997_rtc_alarm_irq, 0,
+				max8997_rtc_alarm_irq, IRQF_ONESHOT,
 				"rtc-alarm0", info);
 	if (ret < 0)
 		dev_err(&pdev->dev, "Failed to request alarm IRQ: %d: %d\n",
drivers/rtc/rtc-max8998.c +2 -1
index 30804b0..bcd4956 100644
@@ -287,7 +287,8 @@ static int max8998_rtc_probe(struct platform_device *pdev)
 	}
 
 	ret = devm_request_threaded_irq(&pdev->dev, info->irq, NULL,
-				max8998_rtc_alarm_irq, 0, "rtc-alarm0", info);
+				max8998_rtc_alarm_irq, IRQF_ONESHOT,
+				"rtc-alarm0", info);
 
 	if (ret < 0)
 		dev_err(&pdev->dev, "Failed to request alarm IRQ: %d: %d\n",
drivers/rtc/rtc-rc5t583.c +1 -1
index f28d577..a9b02af 100644
@@ -248,7 +248,7 @@ static int rc5t583_rtc_probe(struct platform_device *pdev)
 
 	irq += RC5T583_IRQ_YALE;
 	ret = devm_request_threaded_irq(&pdev->dev, irq, NULL,
-		rc5t583_rtc_interrupt, IRQF_TRIGGER_LOW,
+		rc5t583_rtc_interrupt, IRQF_TRIGGER_LOW | IRQF_ONESHOT,
 		"rtc-rc5t583", &pdev->dev);
 	if (ret < 0) {
 		dev_err(&pdev->dev, "IRQ is not free.\n");
drivers/rtc/rtc-rk808.c +1 -1
index 91ca0bc..bf118da 100644
@@ -393,7 +393,7 @@ static int rk808_rtc_probe(struct platform_device *pdev)
 
 	/* request alarm irq of rk808 */
 	ret = devm_request_threaded_irq(&pdev->dev, rk808_rtc->irq, NULL,
-					rk808_alarm_irq, 0,
+					rk808_alarm_irq, IRQF_ONESHOT,
 					"RTC alarm", rk808_rtc);
 	if (ret) {
 		dev_err(&pdev->dev, "Failed to request alarm IRQ %d: %d\n",
drivers/rtc/rtc-s5m.c +2 -1
index 8c70d78..dab0c34 100644
@@ -740,7 +740,8 @@ static int s5m_rtc_probe(struct platform_device *pdev)
 	}
 
 	ret = devm_request_threaded_irq(&pdev->dev, info->irq, NULL,
-					s5m_rtc_alarm_irq, 0, "rtc-alarm0",
+					s5m_rtc_alarm_irq, IRQF_ONESHOT,
+					"rtc-alarm0",
 					info);
 	if (ret < 0) {
 		dev_err(&pdev->dev, "Failed to request alarm IRQ: %d: %d\n",
drivers/rtc/rtc-tps65910.c +2 -1
index f42aa2b..9afafde 100644
@@ -268,7 +268,8 @@ static int tps65910_rtc_probe(struct platform_device *pdev)
 	}
 
 	ret = devm_request_threaded_irq(&pdev->dev, irq, NULL,
-		tps65910_rtc_interrupt, IRQF_TRIGGER_LOW | IRQF_EARLY_RESUME,
+		tps65910_rtc_interrupt,
+		IRQF_TRIGGER_LOW | IRQF_EARLY_RESUME | IRQF_ONESHOT,
 		dev_name(&pdev->dev), &pdev->dev);
 	if (ret < 0) {
 		dev_err(&pdev->dev, "IRQ is not free.\n");
drivers/rtc/rtc-wm831x.c +2 -1
index 75aea4c..54504d5 100644
@@ -445,7 +445,8 @@ static int wm831x_rtc_probe(struct platform_device *pdev)
 
 	ret = devm_request_threaded_irq(&pdev->dev, alm_irq, NULL,
 				wm831x_alm_irq,
-				IRQF_TRIGGER_RISING, "RTC alarm",
+				IRQF_TRIGGER_RISING | IRQF_ONESHOT,
+				"RTC alarm",
 				wm831x_rtc);
 	if (ret != 0) {
 		dev_err(&pdev->dev, "Failed to request alarm IRQ %d: %d\n",
Signature · 12 lines
1.9.1

-- 
-- 
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
--- 
You received this message because you are subscribed to the Google Groups "rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
For more options, visit https://groups.google.com/d/optout.
#1 lore raw

W dniu 14.08.2015 o 11:13, Fabio Estevam pisze:

Quoted 5 lines

From: Fabio Estevam <[email protected]>

Since commit 1c6c69525b40eb76de8adf039409722015927dc3 ("genirq: Reject bogus threaded irq requests") threaded IRQs without a primary handler need to be requested with IRQF_ONESHOT, otherwise the request will fail.

That statement is not entirely correct... because the request does not fail. It works. At least for max77686 and rtc-s5m.

After looking at __setup_irq, your change does nothing because the flag will be cleared:

	if (desc->irq_data.chip->flags & IRQCHIP_ONESHOT_SAFE)
		new->flags &= ~IRQF_ONESHOT;

Best regards,
Krzysztof

Quoted 171 lines

So pass the IRQF_ONESHOT flag in this case.

The semantic patch that makes this change is available in scripts/coccinelle/misc/irqf_oneshot.cocci

---
 drivers/rtc/rtc-isl1208.c  | 2 +-
 drivers/rtc/rtc-lp8788.c   | 2 +-
 drivers/rtc/rtc-max77686.c | 3 ++-
 drivers/rtc/rtc-max77802.c | 3 ++-
 drivers/rtc/rtc-max8997.c  | 2 +-
 drivers/rtc/rtc-max8998.c  | 3 ++-
 drivers/rtc/rtc-rc5t583.c  | 2 +-
 drivers/rtc/rtc-rk808.c    | 2 +-
 drivers/rtc/rtc-s5m.c      | 3 ++-
 drivers/rtc/rtc-tps65910.c | 3 ++-
 drivers/rtc/rtc-wm831x.c   | 3 ++-
 11 files changed, 17 insertions(+), 11 deletions(-)
drivers/rtc/rtc-isl1208.c +1 -1
index aa3b8f1..b57a304 100644
@@ -638,7 +638,7 @@ isl1208_probe(struct i2c_client *client, const struct i2c_device_id *id)
 	if (client->irq > 0) {
 		rc = devm_request_threaded_irq(&client->dev, client->irq, NULL,
 					       isl1208_rtc_interrupt,
-					       IRQF_SHARED,
+					       IRQF_SHARED | IRQF_ONESHOT,
 					       isl1208_driver.driver.name,
 					       client);
 		if (!rc) {
drivers/rtc/rtc-lp8788.c +1 -1
index e20e7bd..e0de665 100644
@@ -280,7 +280,7 @@ static int lp8788_alarm_irq_register(struct platform_device *pdev,
 
 	return devm_request_threaded_irq(&pdev->dev, rtc->irq, NULL,
 				lp8788_alarm_irq_handler,
-				0, LP8788_ALM_IRQ, rtc);
+				IRQF_ONESHOT, LP8788_ALM_IRQ, rtc);
 }
 
 static int lp8788_rtc_probe(struct platform_device *pdev)
drivers/rtc/rtc-max77686.c +2 -1
index 7184a0e..06d1354 100644
@@ -471,7 +471,8 @@ static int max77686_rtc_probe(struct platform_device *pdev)
 	}
 
 	ret = devm_request_threaded_irq(&pdev->dev, info->virq, NULL,
-				max77686_rtc_alarm_irq, 0, "rtc-alarm1", info);
+				max77686_rtc_alarm_irq, IRQF_ONESHOT,
+				"rtc-alarm1", info);
 	if (ret < 0)
 		dev_err(&pdev->dev, "Failed to request alarm IRQ: %d: %d\n",
 			info->virq, ret);
drivers/rtc/rtc-max77802.c +2 -1
index 82ffcc5..e275d9b 100644
@@ -444,7 +444,8 @@ static int max77802_rtc_probe(struct platform_device *pdev)
 	}
 
 	ret = devm_request_threaded_irq(&pdev->dev, info->virq, NULL,
-					max77802_rtc_alarm_irq, 0, "rtc-alarm1",
+					max77802_rtc_alarm_irq, IRQF_ONESHOT,
+					"rtc-alarm1",
 					info);
 	if (ret < 0)
 		dev_err(&pdev->dev, "Failed to request alarm IRQ: %d: %d\n",
drivers/rtc/rtc-max8997.c +1 -1
index 9e02bcd..48e8ae4 100644
@@ -499,7 +499,7 @@ static int max8997_rtc_probe(struct platform_device *pdev)
 	info->virq = virq;
 
 	ret = devm_request_threaded_irq(&pdev->dev, virq, NULL,
-				max8997_rtc_alarm_irq, 0,
+				max8997_rtc_alarm_irq, IRQF_ONESHOT,
 				"rtc-alarm0", info);
 	if (ret < 0)
 		dev_err(&pdev->dev, "Failed to request alarm IRQ: %d: %d\n",
drivers/rtc/rtc-max8998.c +2 -1
index 30804b0..bcd4956 100644
@@ -287,7 +287,8 @@ static int max8998_rtc_probe(struct platform_device *pdev)
 	}
 
 	ret = devm_request_threaded_irq(&pdev->dev, info->irq, NULL,
-				max8998_rtc_alarm_irq, 0, "rtc-alarm0", info);
+				max8998_rtc_alarm_irq, IRQF_ONESHOT,
+				"rtc-alarm0", info);
 
 	if (ret < 0)
 		dev_err(&pdev->dev, "Failed to request alarm IRQ: %d: %d\n",
drivers/rtc/rtc-rc5t583.c +1 -1
index f28d577..a9b02af 100644
@@ -248,7 +248,7 @@ static int rc5t583_rtc_probe(struct platform_device *pdev)
 
 	irq += RC5T583_IRQ_YALE;
 	ret = devm_request_threaded_irq(&pdev->dev, irq, NULL,
-		rc5t583_rtc_interrupt, IRQF_TRIGGER_LOW,
+		rc5t583_rtc_interrupt, IRQF_TRIGGER_LOW | IRQF_ONESHOT,
 		"rtc-rc5t583", &pdev->dev);
 	if (ret < 0) {
 		dev_err(&pdev->dev, "IRQ is not free.\n");
drivers/rtc/rtc-rk808.c +1 -1
index 91ca0bc..bf118da 100644
@@ -393,7 +393,7 @@ static int rk808_rtc_probe(struct platform_device *pdev)
 
 	/* request alarm irq of rk808 */
 	ret = devm_request_threaded_irq(&pdev->dev, rk808_rtc->irq, NULL,
-					rk808_alarm_irq, 0,
+					rk808_alarm_irq, IRQF_ONESHOT,
 					"RTC alarm", rk808_rtc);
 	if (ret) {
 		dev_err(&pdev->dev, "Failed to request alarm IRQ %d: %d\n",
drivers/rtc/rtc-s5m.c +2 -1
index 8c70d78..dab0c34 100644
@@ -740,7 +740,8 @@ static int s5m_rtc_probe(struct platform_device *pdev)
 	}
 
 	ret = devm_request_threaded_irq(&pdev->dev, info->irq, NULL,
-					s5m_rtc_alarm_irq, 0, "rtc-alarm0",
+					s5m_rtc_alarm_irq, IRQF_ONESHOT,
+					"rtc-alarm0",
 					info);
 	if (ret < 0) {
 		dev_err(&pdev->dev, "Failed to request alarm IRQ: %d: %d\n",
drivers/rtc/rtc-tps65910.c +2 -1
index f42aa2b..9afafde 100644
@@ -268,7 +268,8 @@ static int tps65910_rtc_probe(struct platform_device *pdev)
 	}
 
 	ret = devm_request_threaded_irq(&pdev->dev, irq, NULL,
-		tps65910_rtc_interrupt, IRQF_TRIGGER_LOW | IRQF_EARLY_RESUME,
+		tps65910_rtc_interrupt,
+		IRQF_TRIGGER_LOW | IRQF_EARLY_RESUME | IRQF_ONESHOT,
 		dev_name(&pdev->dev), &pdev->dev);
 	if (ret < 0) {
 		dev_err(&pdev->dev, "IRQ is not free.\n");
drivers/rtc/rtc-wm831x.c +2 -1
index 75aea4c..54504d5 100644
@@ -445,7 +445,8 @@ static int wm831x_rtc_probe(struct platform_device *pdev)
 
 	ret = devm_request_threaded_irq(&pdev->dev, alm_irq, NULL,
 				wm831x_alm_irq,
-				IRQF_TRIGGER_RISING, "RTC alarm",
+				IRQF_TRIGGER_RISING | IRQF_ONESHOT,
+				"RTC alarm",
 				wm831x_rtc);
 	if (ret != 0) {
 		dev_err(&pdev->dev, "Failed to request alarm IRQ %d: %d\n",
Signature · 9 lines
-- 
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
--- 
You received this message because you are subscribed to the Google Groups "rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
For more options, visit https://groups.google.com/d/optout.
#2 lore raw

W dniu 16.08.2015 o 19:13, Krzysztof Kozlowski pisze:

Quoted 7 lines

W dniu 14.08.2015 o 11:13, Fabio Estevam pisze:

Quoted 5 lines

From: Fabio Estevam <[email protected]>

Since commit 1c6c69525b40eb76de8adf039409722015927dc3 ("genirq: Reject bogus threaded irq requests") threaded IRQs without a primary handler need to be requested with IRQF_ONESHOT, otherwise the request will fail.

Quoted 7 lines

That statement is not entirely correct... because the request does not fail. It works. At least for max77686 and rtc-s5m.

After looking at __setup_irq, your change does nothing because the flag will be cleared:

	if (desc->irq_data.chip->flags & IRQCHIP_ONESHOT_SAFE)
		new->flags &= ~IRQF_ONESHOT;

Heh, which is also not correct. The chip does not have IRQCHIP_ONESHOT_SAFE set.

However interrupts in these drivers are nested so the handler is "irq_nested_primary_handler". The parent device (sec-irq, max77686) has properly set IRQF_ONESHOT.

Overall the patch is not needed, description is misleading (small difference between "works" and "will fail") and cocci script generates false positive (at least for max77686, max77802 and rtc-s5m).

Quoted 1 line

From another point of view, have you tested the patch on these devices?

This introduces small functional change - the irq becomes oneshot...

Best regards,
Krzystof

BTW Please Cc the maintainers for drivers. If the patch is marked as request-for-tests, then they could provide it.

Quoted 177 lines

Best regards,
Krzysztof

Quoted 171 lines

So pass the IRQF_ONESHOT flag in this case.

The semantic patch that makes this change is available in scripts/coccinelle/misc/irqf_oneshot.cocci

---
 drivers/rtc/rtc-isl1208.c  | 2 +-
 drivers/rtc/rtc-lp8788.c   | 2 +-
 drivers/rtc/rtc-max77686.c | 3 ++-
 drivers/rtc/rtc-max77802.c | 3 ++-
 drivers/rtc/rtc-max8997.c  | 2 +-
 drivers/rtc/rtc-max8998.c  | 3 ++-
 drivers/rtc/rtc-rc5t583.c  | 2 +-
 drivers/rtc/rtc-rk808.c    | 2 +-
 drivers/rtc/rtc-s5m.c      | 3 ++-
 drivers/rtc/rtc-tps65910.c | 3 ++-
 drivers/rtc/rtc-wm831x.c   | 3 ++-
 11 files changed, 17 insertions(+), 11 deletions(-)
drivers/rtc/rtc-isl1208.c +1 -1
index aa3b8f1..b57a304 100644
@@ -638,7 +638,7 @@ isl1208_probe(struct i2c_client *client, const struct i2c_device_id *id)
 	if (client->irq > 0) {
 		rc = devm_request_threaded_irq(&client->dev, client->irq, NULL,
 					       isl1208_rtc_interrupt,
-					       IRQF_SHARED,
+					       IRQF_SHARED | IRQF_ONESHOT,
 					       isl1208_driver.driver.name,
 					       client);
 		if (!rc) {
drivers/rtc/rtc-lp8788.c +1 -1
index e20e7bd..e0de665 100644
@@ -280,7 +280,7 @@ static int lp8788_alarm_irq_register(struct platform_device *pdev,
 
 	return devm_request_threaded_irq(&pdev->dev, rtc->irq, NULL,
 				lp8788_alarm_irq_handler,
-				0, LP8788_ALM_IRQ, rtc);
+				IRQF_ONESHOT, LP8788_ALM_IRQ, rtc);
 }
 
 static int lp8788_rtc_probe(struct platform_device *pdev)
drivers/rtc/rtc-max77686.c +2 -1
index 7184a0e..06d1354 100644
@@ -471,7 +471,8 @@ static int max77686_rtc_probe(struct platform_device *pdev)
 	}
 
 	ret = devm_request_threaded_irq(&pdev->dev, info->virq, NULL,
-				max77686_rtc_alarm_irq, 0, "rtc-alarm1", info);
+				max77686_rtc_alarm_irq, IRQF_ONESHOT,
+				"rtc-alarm1", info);
 	if (ret < 0)
 		dev_err(&pdev->dev, "Failed to request alarm IRQ: %d: %d\n",
 			info->virq, ret);
drivers/rtc/rtc-max77802.c +2 -1
index 82ffcc5..e275d9b 100644
@@ -444,7 +444,8 @@ static int max77802_rtc_probe(struct platform_device *pdev)
 	}
 
 	ret = devm_request_threaded_irq(&pdev->dev, info->virq, NULL,
-					max77802_rtc_alarm_irq, 0, "rtc-alarm1",
+					max77802_rtc_alarm_irq, IRQF_ONESHOT,
+					"rtc-alarm1",
 					info);
 	if (ret < 0)
 		dev_err(&pdev->dev, "Failed to request alarm IRQ: %d: %d\n",
drivers/rtc/rtc-max8997.c +1 -1
index 9e02bcd..48e8ae4 100644
@@ -499,7 +499,7 @@ static int max8997_rtc_probe(struct platform_device *pdev)
 	info->virq = virq;
 
 	ret = devm_request_threaded_irq(&pdev->dev, virq, NULL,
-				max8997_rtc_alarm_irq, 0,
+				max8997_rtc_alarm_irq, IRQF_ONESHOT,
 				"rtc-alarm0", info);
 	if (ret < 0)
 		dev_err(&pdev->dev, "Failed to request alarm IRQ: %d: %d\n",
drivers/rtc/rtc-max8998.c +2 -1
index 30804b0..bcd4956 100644
@@ -287,7 +287,8 @@ static int max8998_rtc_probe(struct platform_device *pdev)
 	}
 
 	ret = devm_request_threaded_irq(&pdev->dev, info->irq, NULL,
-				max8998_rtc_alarm_irq, 0, "rtc-alarm0", info);
+				max8998_rtc_alarm_irq, IRQF_ONESHOT,
+				"rtc-alarm0", info);
 
 	if (ret < 0)
 		dev_err(&pdev->dev, "Failed to request alarm IRQ: %d: %d\n",
drivers/rtc/rtc-rc5t583.c +1 -1
index f28d577..a9b02af 100644
@@ -248,7 +248,7 @@ static int rc5t583_rtc_probe(struct platform_device *pdev)
 
 	irq += RC5T583_IRQ_YALE;
 	ret = devm_request_threaded_irq(&pdev->dev, irq, NULL,
-		rc5t583_rtc_interrupt, IRQF_TRIGGER_LOW,
+		rc5t583_rtc_interrupt, IRQF_TRIGGER_LOW | IRQF_ONESHOT,
 		"rtc-rc5t583", &pdev->dev);
 	if (ret < 0) {
 		dev_err(&pdev->dev, "IRQ is not free.\n");
drivers/rtc/rtc-rk808.c +1 -1
index 91ca0bc..bf118da 100644
@@ -393,7 +393,7 @@ static int rk808_rtc_probe(struct platform_device *pdev)
 
 	/* request alarm irq of rk808 */
 	ret = devm_request_threaded_irq(&pdev->dev, rk808_rtc->irq, NULL,
-					rk808_alarm_irq, 0,
+					rk808_alarm_irq, IRQF_ONESHOT,
 					"RTC alarm", rk808_rtc);
 	if (ret) {
 		dev_err(&pdev->dev, "Failed to request alarm IRQ %d: %d\n",
drivers/rtc/rtc-s5m.c +2 -1
index 8c70d78..dab0c34 100644
@@ -740,7 +740,8 @@ static int s5m_rtc_probe(struct platform_device *pdev)
 	}
 
 	ret = devm_request_threaded_irq(&pdev->dev, info->irq, NULL,
-					s5m_rtc_alarm_irq, 0, "rtc-alarm0",
+					s5m_rtc_alarm_irq, IRQF_ONESHOT,
+					"rtc-alarm0",
 					info);
 	if (ret < 0) {
 		dev_err(&pdev->dev, "Failed to request alarm IRQ: %d: %d\n",
drivers/rtc/rtc-tps65910.c +2 -1
index f42aa2b..9afafde 100644
@@ -268,7 +268,8 @@ static int tps65910_rtc_probe(struct platform_device *pdev)
 	}
 
 	ret = devm_request_threaded_irq(&pdev->dev, irq, NULL,
-		tps65910_rtc_interrupt, IRQF_TRIGGER_LOW | IRQF_EARLY_RESUME,
+		tps65910_rtc_interrupt,
+		IRQF_TRIGGER_LOW | IRQF_EARLY_RESUME | IRQF_ONESHOT,
 		dev_name(&pdev->dev), &pdev->dev);
 	if (ret < 0) {
 		dev_err(&pdev->dev, "IRQ is not free.\n");
drivers/rtc/rtc-wm831x.c +2 -1
index 75aea4c..54504d5 100644
@@ -445,7 +445,8 @@ static int wm831x_rtc_probe(struct platform_device *pdev)
 
 	ret = devm_request_threaded_irq(&pdev->dev, alm_irq, NULL,
 				wm831x_alm_irq,
-				IRQF_TRIGGER_RISING, "RTC alarm",
+				IRQF_TRIGGER_RISING | IRQF_ONESHOT,
+				"RTC alarm",
 				wm831x_rtc);
 	if (ret != 0) {
 		dev_err(&pdev->dev, "Failed to request alarm IRQ %d: %d\n",
Signature · 9 lines
-- 
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
--- 
You received this message because you are subscribed to the Google Groups "rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
For more options, visit https://groups.google.com/d/optout.
#3 lore raw

+CC Fabio's gmail address (disappeared from previous reply).

2015-08-16 19:51 GMT+09:00 Krzysztof Kozlowski <[email protected]>:

Quoted 15 lines

W dniu 16.08.2015 o 19:13, Krzysztof Kozlowski pisze:

Quoted 14 lines

W dniu 14.08.2015 o 11:13, Fabio Estevam pisze:

Quoted 5 lines

From: Fabio Estevam <[email protected]>

Since commit 1c6c69525b40eb76de8adf039409722015927dc3 ("genirq: Reject bogus threaded irq requests") threaded IRQs without a primary handler need to be requested with IRQF_ONESHOT, otherwise the request will fail.

That statement is not entirely correct... because the request does not fail. It works. At least for max77686 and rtc-s5m.

After looking at __setup_irq, your change does nothing because the flag will be cleared:

      if (desc->irq_data.chip->flags & IRQCHIP_ONESHOT_SAFE)
              new->flags &= ~IRQF_ONESHOT;

Heh, which is also not correct. The chip does not have IRQCHIP_ONESHOT_SAFE set.

However interrupts in these drivers are nested so the handler is "irq_nested_primary_handler". The parent device (sec-irq, max77686) has properly set IRQF_ONESHOT.

Overall the patch is not needed, description is misleading (small difference between "works" and "will fail") and cocci script generates false positive (at least for max77686, max77802 and rtc-s5m).

Quoted 1 line

From another point of view, have you tested the patch on these devices?

This introduces small functional change - the irq becomes oneshot...

Best regards,
Krzystof

BTW Please Cc the maintainers for drivers. If the patch is marked as request-for-tests, then they could provide it.

Quoted 178 lines
Quoted 177 lines

Best regards,
Krzysztof

Quoted 171 lines

So pass the IRQF_ONESHOT flag in this case.

The semantic patch that makes this change is available in scripts/coccinelle/misc/irqf_oneshot.cocci

---
 drivers/rtc/rtc-isl1208.c  | 2 +-
 drivers/rtc/rtc-lp8788.c   | 2 +-
 drivers/rtc/rtc-max77686.c | 3 ++-
 drivers/rtc/rtc-max77802.c | 3 ++-
 drivers/rtc/rtc-max8997.c  | 2 +-
 drivers/rtc/rtc-max8998.c  | 3 ++-
 drivers/rtc/rtc-rc5t583.c  | 2 +-
 drivers/rtc/rtc-rk808.c    | 2 +-
 drivers/rtc/rtc-s5m.c      | 3 ++-
 drivers/rtc/rtc-tps65910.c | 3 ++-
 drivers/rtc/rtc-wm831x.c   | 3 ++-
 11 files changed, 17 insertions(+), 11 deletions(-)
drivers/rtc/rtc-isl1208.c +1 -1
index aa3b8f1..b57a304 100644
@@ -638,7 +638,7 @@ isl1208_probe(struct i2c_client *client, const struct i2c_device_id *id)
     if (client->irq > 0) {
             rc = devm_request_threaded_irq(&client->dev, client->irq, NULL,
                                            isl1208_rtc_interrupt,
-                                           IRQF_SHARED,
+                                           IRQF_SHARED | IRQF_ONESHOT,
                                            isl1208_driver.driver.name,
                                            client);
             if (!rc) {
drivers/rtc/rtc-lp8788.c +1 -1
index e20e7bd..e0de665 100644
@@ -280,7 +280,7 @@ static int lp8788_alarm_irq_register(struct platform_device *pdev,
 
     return devm_request_threaded_irq(&pdev->dev, rtc->irq, NULL,
                             lp8788_alarm_irq_handler,
-                            0, LP8788_ALM_IRQ, rtc);
+                            IRQF_ONESHOT, LP8788_ALM_IRQ, rtc);
 }
 
 static int lp8788_rtc_probe(struct platform_device *pdev)
drivers/rtc/rtc-max77686.c +2 -1
index 7184a0e..06d1354 100644
@@ -471,7 +471,8 @@ static int max77686_rtc_probe(struct platform_device *pdev)
     }
 
     ret = devm_request_threaded_irq(&pdev->dev, info->virq, NULL,
-                            max77686_rtc_alarm_irq, 0, "rtc-alarm1", info);
+                            max77686_rtc_alarm_irq, IRQF_ONESHOT,
+                            "rtc-alarm1", info);
     if (ret < 0)
             dev_err(&pdev->dev, "Failed to request alarm IRQ: %d: %d\n",
                     info->virq, ret);
drivers/rtc/rtc-max77802.c +2 -1
index 82ffcc5..e275d9b 100644
@@ -444,7 +444,8 @@ static int max77802_rtc_probe(struct platform_device *pdev)
     }
 
     ret = devm_request_threaded_irq(&pdev->dev, info->virq, NULL,
-                                    max77802_rtc_alarm_irq, 0, "rtc-alarm1",
+                                    max77802_rtc_alarm_irq, IRQF_ONESHOT,
+                                    "rtc-alarm1",
                                     info);
     if (ret < 0)
             dev_err(&pdev->dev, "Failed to request alarm IRQ: %d: %d\n",
drivers/rtc/rtc-max8997.c +1 -1
index 9e02bcd..48e8ae4 100644
@@ -499,7 +499,7 @@ static int max8997_rtc_probe(struct platform_device *pdev)
     info->virq = virq;
 
     ret = devm_request_threaded_irq(&pdev->dev, virq, NULL,
-                            max8997_rtc_alarm_irq, 0,
+                            max8997_rtc_alarm_irq, IRQF_ONESHOT,
                             "rtc-alarm0", info);
     if (ret < 0)
             dev_err(&pdev->dev, "Failed to request alarm IRQ: %d: %d\n",
drivers/rtc/rtc-max8998.c +2 -1
index 30804b0..bcd4956 100644
@@ -287,7 +287,8 @@ static int max8998_rtc_probe(struct platform_device *pdev)
     }
 
     ret = devm_request_threaded_irq(&pdev->dev, info->irq, NULL,
-                            max8998_rtc_alarm_irq, 0, "rtc-alarm0", info);
+                            max8998_rtc_alarm_irq, IRQF_ONESHOT,
+                            "rtc-alarm0", info);
 
     if (ret < 0)
             dev_err(&pdev->dev, "Failed to request alarm IRQ: %d: %d\n",
drivers/rtc/rtc-rc5t583.c +1 -1
index f28d577..a9b02af 100644
@@ -248,7 +248,7 @@ static int rc5t583_rtc_probe(struct platform_device *pdev)
 
     irq += RC5T583_IRQ_YALE;
     ret = devm_request_threaded_irq(&pdev->dev, irq, NULL,
-            rc5t583_rtc_interrupt, IRQF_TRIGGER_LOW,
+            rc5t583_rtc_interrupt, IRQF_TRIGGER_LOW | IRQF_ONESHOT,
             "rtc-rc5t583", &pdev->dev);
     if (ret < 0) {
             dev_err(&pdev->dev, "IRQ is not free.\n");
drivers/rtc/rtc-rk808.c +1 -1
index 91ca0bc..bf118da 100644
@@ -393,7 +393,7 @@ static int rk808_rtc_probe(struct platform_device *pdev)
 
     /* request alarm irq of rk808 */
     ret = devm_request_threaded_irq(&pdev->dev, rk808_rtc->irq, NULL,
-                                    rk808_alarm_irq, 0,
+                                    rk808_alarm_irq, IRQF_ONESHOT,
                                     "RTC alarm", rk808_rtc);
     if (ret) {
             dev_err(&pdev->dev, "Failed to request alarm IRQ %d: %d\n",
drivers/rtc/rtc-s5m.c +2 -1
index 8c70d78..dab0c34 100644
@@ -740,7 +740,8 @@ static int s5m_rtc_probe(struct platform_device *pdev)
     }
 
     ret = devm_request_threaded_irq(&pdev->dev, info->irq, NULL,
-                                    s5m_rtc_alarm_irq, 0, "rtc-alarm0",
+                                    s5m_rtc_alarm_irq, IRQF_ONESHOT,
+                                    "rtc-alarm0",
                                     info);
     if (ret < 0) {
             dev_err(&pdev->dev, "Failed to request alarm IRQ: %d: %d\n",
drivers/rtc/rtc-tps65910.c +2 -1
index f42aa2b..9afafde 100644
@@ -268,7 +268,8 @@ static int tps65910_rtc_probe(struct platform_device *pdev)
     }
 
     ret = devm_request_threaded_irq(&pdev->dev, irq, NULL,
-            tps65910_rtc_interrupt, IRQF_TRIGGER_LOW | IRQF_EARLY_RESUME,
+            tps65910_rtc_interrupt,
+            IRQF_TRIGGER_LOW | IRQF_EARLY_RESUME | IRQF_ONESHOT,
             dev_name(&pdev->dev), &pdev->dev);
     if (ret < 0) {
             dev_err(&pdev->dev, "IRQ is not free.\n");
drivers/rtc/rtc-wm831x.c +2 -1
index 75aea4c..54504d5 100644
@@ -445,7 +445,8 @@ static int wm831x_rtc_probe(struct platform_device *pdev)
 
     ret = devm_request_threaded_irq(&pdev->dev, alm_irq, NULL,
                             wm831x_alm_irq,
-                            IRQF_TRIGGER_RISING, "RTC alarm",
+                            IRQF_TRIGGER_RISING | IRQF_ONESHOT,
+                            "RTC alarm",
                             wm831x_rtc);
     if (ret != 0) {
             dev_err(&pdev->dev, "Failed to request alarm IRQ %d: %d\n",
Signature · 9 lines
-- 
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
--- 
You received this message because you are subscribed to the Google Groups "rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
For more options, visit https://groups.google.com/d/optout.
#4 lore raw

Hi,

Quoted 7 lines · Krzysztof Kozlowski

Overall the patch is not needed, description is misleading (small difference between "works" and "will fail") and cocci script generates false positive (at least for max77686, max77802 and rtc-s5m).

From another point of view, have you tested the patch on these devices? This introduces small functional change - the irq becomes oneshot...

I had a good look and they are actually all false positive apart from isl1208 (they are all MFDs). Fabio, do you mind reworking?

Signature · 14 lines
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

-- 
-- 
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
--- 
You received this message because you are subscribed to the Google Groups "rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
For more options, visit https://groups.google.com/d/optout.