[PATCH RESEND 1/2] gpio: omap: Add omap_gpio_disable/enable_irq calls

Judith Mendez posted 2 patches 1 month, 2 weeks ago
[PATCH RESEND 1/2] gpio: omap: Add omap_gpio_disable/enable_irq calls
Posted by Judith Mendez 1 month, 2 weeks ago
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_irq
so that interrupts can be disabled/enabled.

Signed-off-by: Bin Liu <b-liu@ti.com>
Signed-off-by: Judith Mendez <jm@ti.com>
---
 drivers/gpio/gpio-omap.c | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
index 76d5d87e9681..913e6ece1238 100644
--- a/drivers/gpio/gpio-omap.c
+++ b/drivers/gpio/gpio-omap.c
@@ -711,6 +711,31 @@ static void omap_gpio_unmask_irq(struct irq_data *d)
 	raw_spin_unlock_irqrestore(&bank->lock, flags);
 }
 
+static void omap_gpio_set_irq(struct irq_data *d, bool enable)
+{
+	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, enable);
+	raw_spin_unlock_irqrestore(&bank->lock, flags);
+}
+
+static void omap_gpio_disable_irq(struct irq_data *d)
+{
+	bool enable = 1;
+
+	omap_gpio_set_irq(d, !enable);
+}
+
+static void omap_gpio_enable_irq(struct irq_data *d)
+{
+	bool enable = 1;
+
+	omap_gpio_set_irq(d, enable);
+}
+
 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 +748,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 +764,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
Re: [PATCH RESEND 1/2] gpio: omap: Add omap_gpio_disable/enable_irq calls
Posted by Andrew Davis 1 month, 2 weeks ago
On 10/11/24 12:33 PM, Judith Mendez wrote:
> 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_irq
> so that interrupts can be disabled/enabled.
> 
> Signed-off-by: Bin Liu <b-liu@ti.com>
> Signed-off-by: Judith Mendez <jm@ti.com>
> ---
>   drivers/gpio/gpio-omap.c | 29 +++++++++++++++++++++++++++++
>   1 file changed, 29 insertions(+)
> 
> diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
> index 76d5d87e9681..913e6ece1238 100644
> --- a/drivers/gpio/gpio-omap.c
> +++ b/drivers/gpio/gpio-omap.c
> @@ -711,6 +711,31 @@ static void omap_gpio_unmask_irq(struct irq_data *d)
>   	raw_spin_unlock_irqrestore(&bank->lock, flags);
>   }
>   
> +static void omap_gpio_set_irq(struct irq_data *d, bool enable)
> +{
> +	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, enable);
> +	raw_spin_unlock_irqrestore(&bank->lock, flags);
> +}
> +
> +static void omap_gpio_disable_irq(struct irq_data *d)
> +{
> +	bool enable = 1;
> +
> +	omap_gpio_set_irq(d, !enable);

Seems like an odd way to make "false", why not:

omap_gpio_set_irq(d, false);

Andrew

> +}
> +
> +static void omap_gpio_enable_irq(struct irq_data *d)
> +{
> +	bool enable = 1;
> +
> +	omap_gpio_set_irq(d, enable);
> +}
> +
>   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 +748,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 +764,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,
Re: [PATCH RESEND 1/2] gpio: omap: Add omap_gpio_disable/enable_irq calls
Posted by Judith Mendez 1 month, 1 week ago
Hi Andrew,

On 10/11/24 2:07 PM, Andrew Davis wrote:
> On 10/11/24 12:33 PM, Judith Mendez wrote:
>> 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_irq
>> so that interrupts can be disabled/enabled.
>>
>> Signed-off-by: Bin Liu <b-liu@ti.com>
>> Signed-off-by: Judith Mendez <jm@ti.com>
>> ---
>>   drivers/gpio/gpio-omap.c | 29 +++++++++++++++++++++++++++++
>>   1 file changed, 29 insertions(+)
>>
>> diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
>> index 76d5d87e9681..913e6ece1238 100644
>> --- a/drivers/gpio/gpio-omap.c
>> +++ b/drivers/gpio/gpio-omap.c
>> @@ -711,6 +711,31 @@ static void omap_gpio_unmask_irq(struct irq_data *d)
>>       raw_spin_unlock_irqrestore(&bank->lock, flags);
>>   }
>> +static void omap_gpio_set_irq(struct irq_data *d, bool enable)
>> +{
>> +    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, enable);
>> +    raw_spin_unlock_irqrestore(&bank->lock, flags);
>> +}
>> +
>> +static void omap_gpio_disable_irq(struct irq_data *d)
>> +{
>> +    bool enable = 1;
>> +
>> +    omap_gpio_set_irq(d, !enable);
> 
> Seems like an odd way to make "false", why not:
> 
> omap_gpio_set_irq(d, false);

Thanks for your review, you are right, but I will
be reverting to the original patch format. Where we do
not used wrappers function around omap_gpio_set_irq().

~ Judith

> 
> Andrew
> 
>> +}
>> +
>> +static void omap_gpio_enable_irq(struct irq_data *d)
>> +{
>> +    bool enable = 1;
>> +
>> +    omap_gpio_set_irq(d, enable);
>> +}
>> +
>>   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 +748,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 +764,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,