public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH RESEND v2] gpio: omap: Add omap_gpio_disable/enable_irq calls
@ 2024-10-31 14:56 Judith Mendez
  2024-11-01 14:29 ` Kevin Hilman
  2024-11-06  0:07 ` Kevin Hilman
  0 siblings, 2 replies; 8+ messages in thread
From: Judith Mendez @ 2024-10-31 14:56 UTC (permalink / raw)
  To: Santosh Shilimkar, Kevin Hilman
  Cc: Linus Walleij, Bartosz Golaszewski, linux-omap, linux-gpio,
	linux-kernel, Bin Liu, Judith Mendez

From: Bin Liu <b-liu@ti.com>

Add omap_gpio_disable_irq and omap_gpio_enable_irq
calls in gpio-omap.

Currently, kernel cannot disable gpio interrupts in
case of a irq storm, so add omap_gpio_disable/enable_irq
so that interrupts can be disabled/enabled.

Signed-off-by: Bin Liu <b-liu@ti.com>
[Judith: Add commit message]
Signed-off-by: Judith Mendez <jm@ti.com>
---
Changes since v2:
- Fix email header and commit message
Changes since v1 RESEND:
- split patch from series [0]
- Add disable/enable calls without wrapper functions
[0] https://lore.kernel.org/linux-omap/20241011173356.870883-1-jm@ti.com/

Tested on am335x BeagleBone Black
---
 drivers/gpio/gpio-omap.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
index 76d5d87e9681e..137aabada26f9 100644
--- a/drivers/gpio/gpio-omap.c
+++ b/drivers/gpio/gpio-omap.c
@@ -711,6 +711,28 @@ static void omap_gpio_unmask_irq(struct irq_data *d)
 	raw_spin_unlock_irqrestore(&bank->lock, flags);
 }
 
+static void omap_gpio_disable_irq(struct irq_data *d)
+{
+	struct gpio_bank *bank = omap_irq_data_get_bank(d);
+	unsigned int offset = d->hwirq;
+	unsigned long flags;
+
+	raw_spin_lock_irqsave(&bank->lock, flags);
+	omap_set_gpio_irqenable(bank, offset, 0);
+	raw_spin_unlock_irqrestore(&bank->lock, flags);
+}
+
+static void omap_gpio_enable_irq(struct irq_data *d)
+{
+	struct gpio_bank *bank = omap_irq_data_get_bank(d);
+	unsigned int offset = d->hwirq;
+	unsigned long flags;
+
+	raw_spin_lock_irqsave(&bank->lock, flags);
+	omap_set_gpio_irqenable(bank, offset, 1);
+	raw_spin_unlock_irqrestore(&bank->lock, flags);
+}
+
 static void omap_gpio_irq_print_chip(struct irq_data *d, struct seq_file *p)
 {
 	struct gpio_bank *bank = omap_irq_data_get_bank(d);
@@ -723,6 +745,8 @@ static const struct irq_chip omap_gpio_irq_chip = {
 	.irq_shutdown = omap_gpio_irq_shutdown,
 	.irq_mask = omap_gpio_mask_irq,
 	.irq_unmask = omap_gpio_unmask_irq,
+	.irq_disable = omap_gpio_disable_irq,
+	.irq_enable = omap_gpio_enable_irq,
 	.irq_set_type = omap_gpio_irq_type,
 	.irq_set_wake = omap_gpio_wake_enable,
 	.irq_bus_lock = omap_gpio_irq_bus_lock,
@@ -737,6 +761,8 @@ static const struct irq_chip omap_gpio_irq_chip_nowake = {
 	.irq_shutdown = omap_gpio_irq_shutdown,
 	.irq_mask = omap_gpio_mask_irq,
 	.irq_unmask = omap_gpio_unmask_irq,
+	.irq_disable = omap_gpio_disable_irq,
+	.irq_enable = omap_gpio_enable_irq,
 	.irq_set_type = omap_gpio_irq_type,
 	.irq_bus_lock = omap_gpio_irq_bus_lock,
 	.irq_bus_sync_unlock = gpio_irq_bus_sync_unlock,
-- 
2.47.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH RESEND v2] gpio: omap: Add omap_gpio_disable/enable_irq calls
  2024-10-31 14:56 [PATCH RESEND v2] gpio: omap: Add omap_gpio_disable/enable_irq calls Judith Mendez
@ 2024-11-01 14:29 ` Kevin Hilman
  2024-11-05 18:47   ` Judith Mendez
  2024-11-06  0:07 ` Kevin Hilman
  1 sibling, 1 reply; 8+ messages in thread
From: Kevin Hilman @ 2024-11-01 14:29 UTC (permalink / raw)
  To: Judith Mendez, Santosh Shilimkar
  Cc: Linus Walleij, Bartosz Golaszewski, linux-omap, linux-gpio,
	linux-kernel, Bin Liu, Judith Mendez

Hi Judith,

Judith Mendez <jm@ti.com> writes:

> From: Bin Liu <b-liu@ti.com>
>
> Add omap_gpio_disable_irq and omap_gpio_enable_irq
> calls in gpio-omap.
>
> Currently, kernel cannot disable gpio interrupts in
> case of a irq storm, so add omap_gpio_disable/enable_irq
> so that interrupts can be disabled/enabled.
>
> Signed-off-by: Bin Liu <b-liu@ti.com>
> [Judith: Add commit message]
> Signed-off-by: Judith Mendez <jm@ti.com>

Thanks for this patch.  Can you give a bit more context on the
problem(s) this solves and on which SoCs/platforms it was
developed/validated?

Thanks,

Kevin

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH RESEND v2] gpio: omap: Add omap_gpio_disable/enable_irq calls
  2024-11-01 14:29 ` Kevin Hilman
@ 2024-11-05 18:47   ` Judith Mendez
  2024-11-05 19:00     ` Bin Liu
  0 siblings, 1 reply; 8+ messages in thread
From: Judith Mendez @ 2024-11-05 18:47 UTC (permalink / raw)
  To: Kevin Hilman, Santosh Shilimkar
  Cc: Linus Walleij, Bartosz Golaszewski, linux-omap, linux-gpio,
	linux-kernel, Bin Liu

Hi Kevin,

On 11/1/24 9:29 AM, Kevin Hilman wrote:
> Hi Judith,
> 
> Judith Mendez <jm@ti.com> writes:
> 
>> From: Bin Liu <b-liu@ti.com>
>>
>> Add omap_gpio_disable_irq and omap_gpio_enable_irq
>> calls in gpio-omap.
>>
>> Currently, kernel cannot disable gpio interrupts in
>> case of a irq storm, so add omap_gpio_disable/enable_irq
>> so that interrupts can be disabled/enabled.
>>
>> Signed-off-by: Bin Liu <b-liu@ti.com>
>> [Judith: Add commit message]
>> Signed-off-by: Judith Mendez <jm@ti.com>
> 
> Thanks for this patch.  Can you give a bit more context on the
> problem(s) this solves and on which SoCs/platforms it was
> developed/validated?

Sorry for the late response. Patch was tested/developed on am335x
device BBB, If you feed a PWM signal at 200KHz frequency to
GPIO, and execute gpiomon 0 12 &, Linux will be unresponsive
even after CTRL+C without these 2 functions in this patch. Once
this patch is applied, you can get console back after hitting
CTRL+C and then proceed to kill gpiomon.

~ Judith



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH RESEND v2] gpio: omap: Add omap_gpio_disable/enable_irq calls
  2024-11-05 18:47   ` Judith Mendez
@ 2024-11-05 19:00     ` Bin Liu
  2024-11-06  0:06       ` Kevin Hilman
  2024-11-06 13:42       ` Bartosz Golaszewski
  0 siblings, 2 replies; 8+ messages in thread
From: Bin Liu @ 2024-11-05 19:00 UTC (permalink / raw)
  To: Judith Mendez
  Cc: Kevin Hilman, Santosh Shilimkar, Linus Walleij,
	Bartosz Golaszewski, linux-omap, linux-gpio, linux-kernel

On Tue, Nov 05, 2024 at 12:47:58PM -0600, Judith Mendez wrote:
> Hi Kevin,
> 
> On 11/1/24 9:29 AM, Kevin Hilman wrote:
> > Hi Judith,
> > 
> > Judith Mendez <jm@ti.com> writes:
> > 
> > > From: Bin Liu <b-liu@ti.com>
> > > 
> > > Add omap_gpio_disable_irq and omap_gpio_enable_irq
> > > calls in gpio-omap.
> > > 
> > > Currently, kernel cannot disable gpio interrupts in
> > > case of a irq storm, so add omap_gpio_disable/enable_irq
> > > so that interrupts can be disabled/enabled.
> > > 
> > > Signed-off-by: Bin Liu <b-liu@ti.com>
> > > [Judith: Add commit message]
> > > Signed-off-by: Judith Mendez <jm@ti.com>
> > 
> > Thanks for this patch.  Can you give a bit more context on the
> > problem(s) this solves and on which SoCs/platforms it was
> > developed/validated?
> 
> Sorry for the late response. Patch was tested/developed on am335x
> device BBB, If you feed a PWM signal at 200KHz frequency to
> GPIO, and execute gpiomon 0 12 &, Linux will be unresponsive
> even after CTRL+C without these 2 functions in this patch. Once
> this patch is applied, you can get console back after hitting
> CTRL+C and then proceed to kill gpiomon.

In addtion to Judith's explanation, when the PWM is applied to a GPIO
pin, kernel detects the interrupt storm and disables the irq, however,
without these callbacks, this gpio platform driver doesn't really
disable the interrupt in the gpio controller, so the interrupt storm is
still happening and handled by this gpio controller driver then causes
Linux unresponsive.

-Bin.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH RESEND v2] gpio: omap: Add omap_gpio_disable/enable_irq calls
  2024-11-05 19:00     ` Bin Liu
@ 2024-11-06  0:06       ` Kevin Hilman
  2024-11-06 13:42       ` Bartosz Golaszewski
  1 sibling, 0 replies; 8+ messages in thread
From: Kevin Hilman @ 2024-11-06  0:06 UTC (permalink / raw)
  To: Bin Liu, Judith Mendez
  Cc: Santosh Shilimkar, Linus Walleij, Bartosz Golaszewski, linux-omap,
	linux-gpio, linux-kernel

Bin Liu <b-liu@ti.com> writes:

> On Tue, Nov 05, 2024 at 12:47:58PM -0600, Judith Mendez wrote:
>> Hi Kevin,
>> 
>> On 11/1/24 9:29 AM, Kevin Hilman wrote:
>> > Hi Judith,
>> > 
>> > Judith Mendez <jm@ti.com> writes:
>> > 
>> > > From: Bin Liu <b-liu@ti.com>
>> > > 
>> > > Add omap_gpio_disable_irq and omap_gpio_enable_irq
>> > > calls in gpio-omap.
>> > > 
>> > > Currently, kernel cannot disable gpio interrupts in
>> > > case of a irq storm, so add omap_gpio_disable/enable_irq
>> > > so that interrupts can be disabled/enabled.
>> > > 
>> > > Signed-off-by: Bin Liu <b-liu@ti.com>
>> > > [Judith: Add commit message]
>> > > Signed-off-by: Judith Mendez <jm@ti.com>
>> > 
>> > Thanks for this patch.  Can you give a bit more context on the
>> > problem(s) this solves and on which SoCs/platforms it was
>> > developed/validated?
>> 
>> Sorry for the late response. Patch was tested/developed on am335x
>> device BBB, If you feed a PWM signal at 200KHz frequency to
>> GPIO, and execute gpiomon 0 12 &, Linux will be unresponsive
>> even after CTRL+C without these 2 functions in this patch. Once
>> this patch is applied, you can get console back after hitting
>> CTRL+C and then proceed to kill gpiomon.
>
> In addtion to Judith's explanation, when the PWM is applied to a GPIO
> pin, kernel detects the interrupt storm and disables the irq, however,
> without these callbacks, this gpio platform driver doesn't really
> disable the interrupt in the gpio controller, so the interrupt storm is
> still happening and handled by this gpio controller driver then causes
> Linux unresponsive.

Excellent! Thank you both for the detailed explanations.

Kevin

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH RESEND v2] gpio: omap: Add omap_gpio_disable/enable_irq calls
  2024-10-31 14:56 [PATCH RESEND v2] gpio: omap: Add omap_gpio_disable/enable_irq calls Judith Mendez
  2024-11-01 14:29 ` Kevin Hilman
@ 2024-11-06  0:07 ` Kevin Hilman
  1 sibling, 0 replies; 8+ messages in thread
From: Kevin Hilman @ 2024-11-06  0:07 UTC (permalink / raw)
  To: Judith Mendez, Santosh Shilimkar
  Cc: Linus Walleij, Bartosz Golaszewski, linux-omap, linux-gpio,
	linux-kernel, Bin Liu, Judith Mendez

Judith Mendez <jm@ti.com> writes:

> From: Bin Liu <b-liu@ti.com>
>
> Add omap_gpio_disable_irq and omap_gpio_enable_irq
> calls in gpio-omap.
>
> Currently, kernel cannot disable gpio interrupts in
> case of a irq storm, so add omap_gpio_disable/enable_irq
> so that interrupts can be disabled/enabled.
>
> Signed-off-by: Bin Liu <b-liu@ti.com>
> [Judith: Add commit message]
> Signed-off-by: Judith Mendez <jm@ti.com>

Reviewed-by: Kevin Hilman <khilman@baylibre.com>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH RESEND v2] gpio: omap: Add omap_gpio_disable/enable_irq calls
  2024-11-05 19:00     ` Bin Liu
  2024-11-06  0:06       ` Kevin Hilman
@ 2024-11-06 13:42       ` Bartosz Golaszewski
  2024-11-08 15:43         ` Judith Mendez
  1 sibling, 1 reply; 8+ messages in thread
From: Bartosz Golaszewski @ 2024-11-06 13:42 UTC (permalink / raw)
  To: Bin Liu, Judith Mendez, Kevin Hilman, Santosh Shilimkar,
	Linus Walleij, Bartosz Golaszewski, linux-omap, linux-gpio,
	linux-kernel

On Tue, Nov 5, 2024 at 8:00 PM Bin Liu <b-liu@ti.com> wrote:
>
> On Tue, Nov 05, 2024 at 12:47:58PM -0600, Judith Mendez wrote:
> > Hi Kevin,
> >
> > On 11/1/24 9:29 AM, Kevin Hilman wrote:
> > > Hi Judith,
> > >
> > > Judith Mendez <jm@ti.com> writes:
> > >
> > > > From: Bin Liu <b-liu@ti.com>
> > > >
> > > > Add omap_gpio_disable_irq and omap_gpio_enable_irq
> > > > calls in gpio-omap.
> > > >
> > > > Currently, kernel cannot disable gpio interrupts in
> > > > case of a irq storm, so add omap_gpio_disable/enable_irq
> > > > so that interrupts can be disabled/enabled.
> > > >
> > > > Signed-off-by: Bin Liu <b-liu@ti.com>
> > > > [Judith: Add commit message]
> > > > Signed-off-by: Judith Mendez <jm@ti.com>
> > >
> > > Thanks for this patch.  Can you give a bit more context on the
> > > problem(s) this solves and on which SoCs/platforms it was
> > > developed/validated?
> >
> > Sorry for the late response. Patch was tested/developed on am335x
> > device BBB, If you feed a PWM signal at 200KHz frequency to
> > GPIO, and execute gpiomon 0 12 &, Linux will be unresponsive
> > even after CTRL+C without these 2 functions in this patch. Once
> > this patch is applied, you can get console back after hitting
> > CTRL+C and then proceed to kill gpiomon.
>
> In addtion to Judith's explanation, when the PWM is applied to a GPIO
> pin, kernel detects the interrupt storm and disables the irq, however,
> without these callbacks, this gpio platform driver doesn't really
> disable the interrupt in the gpio controller, so the interrupt storm is
> still happening and handled by this gpio controller driver then causes
> Linux unresponsive.
>
> -Bin.

I take it that this is a fix then and should have relevant Fixes and Cc tags?

Bart

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH RESEND v2] gpio: omap: Add omap_gpio_disable/enable_irq calls
  2024-11-06 13:42       ` Bartosz Golaszewski
@ 2024-11-08 15:43         ` Judith Mendez
  0 siblings, 0 replies; 8+ messages in thread
From: Judith Mendez @ 2024-11-08 15:43 UTC (permalink / raw)
  To: Bartosz Golaszewski, linux-gpio
  Cc: Linus Walleij, Santosh Shilimkar, linux-kernel, Kevin Hilman,
	Bin Liu, linux-omap

Hi Bartosz,

On 11/6/24 7:42 AM, Bartosz Golaszewski wrote:
> On Tue, Nov 5, 2024 at 8:00 PM Bin Liu <b-liu@ti.com> wrote:
>>
>> On Tue, Nov 05, 2024 at 12:47:58PM -0600, Judith Mendez wrote:
>>> Hi Kevin,
>>>
>>> On 11/1/24 9:29 AM, Kevin Hilman wrote:
>>>> Hi Judith,
>>>>
>>>> Judith Mendez <jm@ti.com> writes:
>>>>
>>>>> From: Bin Liu <b-liu@ti.com>
>>>>>
>>>>> Add omap_gpio_disable_irq and omap_gpio_enable_irq
>>>>> calls in gpio-omap.
>>>>>
>>>>> Currently, kernel cannot disable gpio interrupts in
>>>>> case of a irq storm, so add omap_gpio_disable/enable_irq
>>>>> so that interrupts can be disabled/enabled.
>>>>>
>>>>> Signed-off-by: Bin Liu <b-liu@ti.com>
>>>>> [Judith: Add commit message]
>>>>> Signed-off-by: Judith Mendez <jm@ti.com>
>>>>
>>>> Thanks for this patch.  Can you give a bit more context on the
>>>> problem(s) this solves and on which SoCs/platforms it was
>>>> developed/validated?
>>>
>>> Sorry for the late response. Patch was tested/developed on am335x
>>> device BBB, If you feed a PWM signal at 200KHz frequency to
>>> GPIO, and execute gpiomon 0 12 &, Linux will be unresponsive
>>> even after CTRL+C without these 2 functions in this patch. Once
>>> this patch is applied, you can get console back after hitting
>>> CTRL+C and then proceed to kill gpiomon.
>>
>> In addtion to Judith's explanation, when the PWM is applied to a GPIO
>> pin, kernel detects the interrupt storm and disables the irq, however,
>> without these callbacks, this gpio platform driver doesn't really
>> disable the interrupt in the gpio controller, so the interrupt storm is
>> still happening and handled by this gpio controller driver then causes
>> Linux unresponsive.
>>
>> -Bin.
> 
> I take it that this is a fix then and should have relevant Fixes and Cc tags?

ok, will send v3 with fixes tag.

~ Judith


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2024-11-08 15:43 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-31 14:56 [PATCH RESEND v2] gpio: omap: Add omap_gpio_disable/enable_irq calls Judith Mendez
2024-11-01 14:29 ` Kevin Hilman
2024-11-05 18:47   ` Judith Mendez
2024-11-05 19:00     ` Bin Liu
2024-11-06  0:06       ` Kevin Hilman
2024-11-06 13:42       ` Bartosz Golaszewski
2024-11-08 15:43         ` Judith Mendez
2024-11-06  0:07 ` Kevin Hilman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox