From: Barry Song <hidden> Date: 2021-01-28 22:42:28
Many drivers don't want interrupts enabled automatically due to
request_irq(). So they are handling this issue by either way of
the below two:
(1)
irq_set_status_flags(irq, IRQ_NOAUTOEN);
request_irq(dev, irq...);
(2)
request_irq(dev, irq...);
disable_irq(irq);
The code in the second way is silly and unsafe. In the small time
gap between request_irq() and disable_irq(), interrupts can still
come.
The code in the first way is safe though we might be able to do it
in the generic irq code.
With this patch, drivers can request_irq with IRQF_NO_AUTOEN flag.
They will need neither irq_set_status_flags() nor disable_irq().
Hundreds of drivers with this problem will be handled afterwards.
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Barry Song <redacted>
---
-v4: remove the irq_settings magic for NOAUTOEN
include/linux/interrupt.h | 3 +++
kernel/irq/manage.c | 8 +++++++-
2 files changed, 10 insertions(+), 1 deletion(-)
@@ -2086,10 +2087,15 @@ int request_threaded_irq(unsigned int irq, irq_handler_t handler,*whichinterruptiswhich(messesuptheinterruptfreeing*logicetc).*+*Alsosharedinterruptsdonotgowellwithdisablingautoenable.+*Thesharinginterruptmightrequestitwhileit'sstilldisabled+*andthenwaitforinterruptsforever.+**AlsoIRQF_COND_SUSPENDonlymakessenseforsharedinterruptsand*itcannotbesetalongwithIRQF_NO_SUSPEND.*/if(((irqflags&IRQF_SHARED)&&!dev_id)||+((irqflags&IRQF_SHARED)&&(irqflags&IRQF_NO_AUTOEN))||(!(irqflags&IRQF_SHARED)&&(irqflags&IRQF_COND_SUSPEND))||((irqflags&IRQF_NO_SUSPEND)&&(irqflags&IRQF_COND_SUSPEND)))return-EINVAL;
From: Barry Song <hidden> Date: 2021-01-28 22:43:00
disable_irq() after request_irq() still has a time gap in which
interrupts can come. request_irq() with IRQF_NO_AUTOEN flag will
disable IRQ auto-enable because of requesting.
Signed-off-by: Barry Song <redacted>
---
drivers/input/touchscreen/ar1021_i2c.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
@@ -125,7 +125,7 @@ static int ar1021_i2c_probe(struct i2c_client *client,error=devm_request_threaded_irq(&client->dev,client->irq,NULL,ar1021_i2c_irq,-IRQF_ONESHOT,+IRQF_ONESHOT|IRQF_NO_AUTOEN,"ar1021_i2c",ar1021);if(error){dev_err(&client->dev,
@@ -133,9 +133,6 @@ static int ar1021_i2c_probe(struct i2c_client *client,returnerror;}-/* Disable the IRQ, we'll enable it in ar1021_i2c_open() */-disable_irq(client->irq);-error=input_register_device(ar1021->input);if(error){dev_err(&client->dev,
From: Barry Song <hidden> Date: 2021-01-28 22:43:00
Right now, irq core supports requesting irq with IRQF_NO_AUTOEN, this means
the driver doesn't need to call irq_set_status_flags any more.
Signed-off-by: Barry Song <redacted>
---
drivers/input/touchscreen/bu21029_ts.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
From: Barry Song <hidden> Date: 2021-01-28 22:43:28
Right now, irq core supports requesting irq with IRQF_NO_AUTOEN, this means
the driver doesn't need to call irq_set_status_flags any more.
Signed-off-by: Barry Song <redacted>
---
drivers/input/touchscreen/zinitix.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
From: Barry Song <hidden> Date: 2021-01-28 22:43:56
Right now, irq core supports requesting irq with IRQF_NO_AUTOEN, this means
the driver doesn't need to call irq_set_status_flags any more.
Signed-off-by: Barry Song <redacted>
---
drivers/input/touchscreen/stmfts.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
From: Barry Song <hidden> Date: 2021-01-28 22:44:02
disable_irq() after request_irq() still has a time gap in which
interrupts can come. request_irq() with IRQF_NO_AUTOEN flag will
disable IRQ auto-enable because of requesting.
Signed-off-by: Barry Song <redacted>
---
drivers/input/keyboard/tegra-kbc.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
From: Barry Song <hidden> Date: 2021-01-28 22:44:28
disable_irq() after request_irq() still has a time gap in which
interrupts can come. request_irq() with IRQF_NO_AUTOEN flag will
disable IRQ auto-enable because of requesting.
Signed-off-by: Barry Song <redacted>
---
drivers/input/touchscreen/cyttsp_core.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
From: Barry Song <hidden> Date: 2021-01-28 22:45:11
disable_irq() after request_irq() still has a time gap in which
interrupts can come. request_irq() with IRQF_NO_AUTOEN flag will
disable IRQ auto-enable because of requesting.
Signed-off-by: Barry Song <redacted>
---
drivers/input/touchscreen/mms114.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
From: Barry Song <hidden> Date: 2021-01-28 22:45:21
disable_irq() after request_irq() still has a time gap in which
interrupts can come. request_irq() with IRQF_NO_AUTOEN flag will
disable IRQ auto-enable because of requesting.
Signed-off-by: Barry Song <redacted>
---
drivers/input/touchscreen/wm831x-ts.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
From: Barry Song <hidden> Date: 2021-01-28 22:45:21
disable_irq() after request_irq() still has a time gap in which
interrupts can come. request_irq() with IRQF_NO_AUTOEN flag will
disable IRQ auto-enable because of requesting.
Signed-off-by: Barry Song <redacted>
---
drivers/input/keyboard/tca6416-keypad.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
From: Barry Song <hidden> Date: 2021-01-28 22:46:18
disable_irq() after request_irq() still has a time gap in which
interrupts can come. request_irq() with IRQF_NO_AUTOEN flag will
disable IRQ auto-enable because of requesting.
Signed-off-by: Barry Song <redacted>
---
drivers/input/touchscreen/melfas_mip4.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
From: Barry Song <hidden> Date: 2021-01-28 22:47:27
disable_irq() after request_irq() still has a time gap in which
interrupts can come. request_irq() with IRQF_NO_AUTOEN flag will
disable IRQ auto-enable because of requesting.
Signed-off-by: Barry Song <redacted>
---
drivers/input/touchscreen/atmel_mxt_ts.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
From: Song Bao Hua (Barry Song) <hidden> Date: 2021-02-10 01:15:17
-----Original Message-----
From: Song Bao Hua (Barry Song)
Sent: Friday, January 29, 2021 11:35 AM
To: tglx@linutronix.de; dmitry.torokhov@gmail.com; maz@kernel.org;
gregkh@linuxfoundation.org; linux-input@vger.kernel.org;
linux-kernel@vger.kernel.org
Cc: linuxarm@openeuler.org; Song Bao Hua (Barry Song)
[off-list ref]
Subject: [PATCH v4 01/12] genirq: add IRQF_NO_AUTOEN for request_irq
Many drivers don't want interrupts enabled automatically due to
request_irq(). So they are handling this issue by either way of
the below two:
(1)
irq_set_status_flags(irq, IRQ_NOAUTOEN);
request_irq(dev, irq...);
(2)
request_irq(dev, irq...);
disable_irq(irq);
The code in the second way is silly and unsafe. In the small time
gap between request_irq() and disable_irq(), interrupts can still
come.
The code in the first way is safe though we might be able to do it
in the generic irq code.
With this patch, drivers can request_irq with IRQF_NO_AUTOEN flag.
They will need neither irq_set_status_flags() nor disable_irq().
Hundreds of drivers with this problem will be handled afterwards.
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Barry Song <redacted>
---
-v4: remove the irq_settings magic for NOAUTOEN
Hi Thomas,
Any further comment on this? Does it get any opportunity to hit
5.12 so that we can begin to handle those drivers in 5.12?
Thanks
Barry
@@ -2086,10 +2087,15 @@ int request_threaded_irq(unsigned int irq,
irq_handler_t handler,
* which interrupt is which (messes up the interrupt freeing
* logic etc).
*
+ * Also shared interrupts do not go well with disabling auto enable.
+ * The sharing interrupt might request it while it's still disabled
+ * and then wait for interrupts forever.
+ *
* Also IRQF_COND_SUSPEND only makes sense for shared interrupts and
* it cannot be set along with IRQF_NO_SUSPEND.
*/
if (((irqflags & IRQF_SHARED) && !dev_id) ||
+ ((irqflags & IRQF_SHARED) && (irqflags & IRQF_NO_AUTOEN)) ||
(!(irqflags & IRQF_SHARED) && (irqflags & IRQF_COND_SUSPEND)) ||
((irqflags & IRQF_NO_SUSPEND) && (irqflags & IRQF_COND_SUSPEND)))
return -EINVAL;
--
2.25.1