Skip to contentSkip to conversation

gpio: aspeed: Lock GPIO pin used as IRQ

PATCH In review Troy Lee 3 participants 3 messages Dec 10, 2020 – Dec 13, 2020

Subsystems (2)
lore
Share & tools
lore

Troy Lee

author
#0 lore raw

PATCH 1/1 gpio: aspeed: Lock GPIO pin used as IRQ

GPIO pins can be used as IRQ indicators. When they do, those pins should be flaged with locks to avoid kernel warning message.

---
 drivers/gpio/gpio-aspeed.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/gpio/gpio-aspeed.c +7 -0
index b966f5e28ebf..f5b3e1d89fbf 100644
@@ -651,6 +651,13 @@ static int aspeed_gpio_set_type(struct irq_data *d, unsigned int type)
 		aspeed_gpio_copro_release(gpio, offset);
 	spin_unlock_irqrestore(&gpio->lock, flags);
 
+	rc = gpiochip_lock_as_irq(&gpio->chip, d->hwirq);
+	if (rc) {
+		dev_err(gpio->chip.parent, "unable to lock GPIO %lu as IRQ\n",
+			d->hwirq);
+		return rc;
+	}
+
 	irq_set_handler_locked(d, handler);
 
 	return 0;
Signature · 1 line
2.17.1
#1 lore raw
Quoted 3 lines · Troy Lee

GPIO pins can be used as IRQ indicators. When they do, those pins should be flaged with locks to avoid kernel

flagged

Quoted 1 line

warning message.

...

drivers/gpio/gpio-aspeed.c static int aspeed_gpio_set_type(struct irq_data *d, unsigned int type) · line 657

Quoted 8 lines
drivers/gpio/gpio-aspeed.c +6 -0
@@ -651,6 +651,13 @@ static int aspeed_gpio_set_type(struct irq_data *d, unsigned int type)
 
+       rc = gpiochip_lock_as_irq(&gpio->chip, d->hwirq);
+       if (rc) {
+               dev_err(gpio->chip.parent, "unable to lock GPIO %lu as IRQ\n",
+                       d->hwirq);
+               return rc;
+       }

It's a copy'n'paste of generic code. Why do you need it in an unusual place, i.e. ->irq_set_type() IIUC?
Can you elaborate about an issue, because this seems to be a hack?

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#2 lore raw
Quoted 20 lines · Andy Shevchenko
Quoted 3 lines · Troy Lee

GPIO pins can be used as IRQ indicators. When they do, those pins should be flaged with locks to avoid kernel

flagged

Quoted 1 line

warning message.

...

drivers/gpio/gpio-aspeed.c static int aspeed_gpio_set_type(struct irq_data *d, unsigned int type) · line 657

Quoted 8 lines
drivers/gpio/gpio-aspeed.c +6 -0
@@ -651,6 +651,13 @@ static int aspeed_gpio_set_type(struct irq_data *d, unsigned int type)
 
+       rc = gpiochip_lock_as_irq(&gpio->chip, d->hwirq);
+       if (rc) {
+               dev_err(gpio->chip.parent, "unable to lock GPIO %lu as IRQ\n",
+                       d->hwirq);
+               return rc;
+       }
Quoted 3 lines

It's a copy'n'paste of generic code. Why do you need it in an unusual place, i.e. ->irq_set_type() IIUC?
Can you elaborate about an issue, because this seems to be a hack?

Yep - Troy please provide more information. What was the warning you saw? How were the GPIOs allocated on the system that triggered the warning? What did you do to trigger the warning?

Andrew