gpiolib: Show IRQ line in debugfs
v2 cover gpiolib: Show IRQ line in debugfs
Couple of patches to show IRQ only (when it's not requested as GPIO) lines in the debugfs.
In v2:
- joined two separate patches
- rebased on top of latest GPIO for-next (Bart)
Andy Shevchenko (2):
gpiolib: Return label, if set, for IRQ only line
gpiolib: Show more info for interrupt only lines in debugfs
drivers/gpio/gpiolib.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
Signature · 1 line
2.43.0.rc1.1336.g36b5255a03ac
PATCH v2 1/2 gpiolib: Return label, if set, for IRQ only line
If line has been locked as IRQ without requesting, still check its label and return it, if not NULL.
--- drivers/gpio/gpiolib.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/gpio/gpiolib.c +6 -6
@@ -107,16 +107,16 @@ const char *gpiod_get_label(struct gpio_desc *desc)unsigned long flags; flags =READ_ONCE (desc->flags); -if (test_bit (FLAG_USED_AS_IRQ , &flags) && - !test_bit (FLAG_REQUESTED , &flags)) -return "interrupt" ; - -if (!test_bit (FLAG_REQUESTED , &flags)) -return NULL ; label =srcu_dereference_check (desc->label, &desc->gdev->desc_srcu,srcu_read_lock_held (&desc->gdev->desc_srcu)); +if (test_bit (FLAG_USED_AS_IRQ , &flags)) +return label->str ?:"interrupt" ; + +if (!test_bit (FLAG_REQUESTED , &flags)) +return NULL ; +return label->str; }
Signature · 1 line
2.43.0.rc1.1336.g36b5255a03ac
Re: [PATCH v2 1/2] gpiolib: Return label, if set, for IRQ only line
Quoted 4 lines · Andy Shevchenko
If line has been locked as IRQ without requesting, still check its label and return it, if not NULL.
Signed-off-by Andy Shevchenko <[email protected]>
I'm OK with it personally, the perfect solution would be to catenate "interrupt" to the line name so we don't miss the information that the line is used for interrupts in case of proper labels, but it's not a big problem.
Yours,
Linus Walleij
PATCH v2 2/2 gpiolib: Show more info for interrupt only lines in debugfs
In reply to Andy ShevchenkoShow more info for interrupt only lines in debugfs. It's useful to monitor the lines that have been never requested as GPIOs, but IRQs.
--- drivers/gpio/gpiolib.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpio/gpiolib.c +2 -2
@@ -4888,11 +4888,11 @@ static void gpiolib_dbg_show(struct seq_file *s, struct gpio_device *gdev)for_each_gpio_desc (gc, desc) {guard (srcu)(&desc->gdev->desc_srcu); -if (test_bit (FLAG_REQUESTED , &desc->flags)) { + is_irq =test_bit (FLAG_USED_AS_IRQ , &desc->flags); +if (is_irq ||test_bit (FLAG_REQUESTED , &desc->flags)) {gpiod_get_direction (desc); is_out =test_bit (FLAG_IS_OUT , &desc->flags); value =gpio_chip_get_value (gc, desc); - is_irq =test_bit (FLAG_USED_AS_IRQ , &desc->flags); active_low =test_bit (FLAG_ACTIVE_LOW , &desc->flags); seq_printf(s, " gpio-%-3u (%-20.20s|%-20.20s) %s %s %s%s\n", gpio, desc->name ?: "", gpiod_get_label(desc),
Signature · 1 line
2.43.0.rc1.1336.g36b5255a03ac
Re: [PATCH v2 2/2] gpiolib: Show more info for interrupt only lines in debugfs
Hi,
Am Donnerstag, 30. Mai 2024, 21:12:30 CEST schrieb Andy Shevchenko:
Quoted 3 lines
Show more info for interrupt only lines in debugfs. It's useful to monitor the lines that have been never requested as GPIOs, but IRQs.
I was trying to test this on TQMa8MPQL (i.MX8MP) using gpio-mxc.c. But apparently this series only has an effect when gpiochip_lock_as_irq() is called eventually. I'm wondering what needs to be done so IRQ only GPIOs are listed in debugfs. Using irq_request_resources/irq_release_resources similar to what pinctrl-at91.c is doing?
Best regards,
Alexander
Quoted 25 lines
Reviewed-by Linus Walleij <[email protected]>Signed-off-by Andy Shevchenko <[email protected]>--- drivers/gpio/gpiolib.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/gpio/gpiolib.c +2
-2@@ -4888,11 +4888,11 @@ static void gpiolib_dbg_show(struct seq_file *s, struct gpio_device *gdev)for_each_gpio_desc (gc, desc) {guard (srcu)(&desc->gdev->desc_srcu); -if (test_bit (FLAG_REQUESTED , &desc->flags)) { + is_irq =test_bit (FLAG_USED_AS_IRQ , &desc->flags); +if (is_irq ||test_bit (FLAG_REQUESTED , &desc->flags)) {gpiod_get_direction (desc); is_out =test_bit (FLAG_IS_OUT , &desc->flags); value =gpio_chip_get_value (gc, desc); - is_irq =test_bit (FLAG_USED_AS_IRQ , &desc->flags); active_low =test_bit (FLAG_ACTIVE_LOW , &desc->flags); seq_printf(s, " gpio-%-3u (%-20.20s|%-20.20s) %s %s %s%s\n", gpio, desc->name ?: "", gpiod_get_label(desc),
Signature · 4 lines
TQ-Systems GmbH | Mühlstraße 2, Gut Delling | 82229 Seefeld, Germany Amtsgericht München, HRB 105018 Geschäftsführer: Detlef Schneider, Rüdiger Stahl, Stefan Schneider http://www.tq-group.com/
Re: [PATCH v2 2/2] gpiolib: Show more info for interrupt only lines in debugfs
Quoted 6 lines · Alexander Stein
Am Donnerstag, 30. Mai 2024, 21:12:30 CEST schrieb Andy Shevchenko:
Quoted 3 lines
Show more info for interrupt only lines in debugfs. It's useful to monitor the lines that have been never requested as GPIOs, but IRQs.
I was trying to test this on TQMa8MPQL (i.MX8MP) using
gpio-mxc.c.
Thank you for trying!
Quoted 4 lines
But apparently this series only has an effect when
gpiochip_lock_as_irq()is called eventually. I'm wondering what needs to be done so IRQ only GPIOs are listed in debugfs. Using irq_request_resources/irq_release_resources similar to whatpinctrl-at91.cis doing?
I haven't looked deeply into this and I don't know if it's relevant, but...
The idea is that GPIO driver has an IRQ chip that announces handle_bad_irq() as a handler and IRQ_TYPE_NONE as default type at probe stage. It also needs to implement ->set_irq_type() callback where actual handler is going to be locked.
That's what I do not see implemented in the driver. Moreover, I do see it implements its own ->to_irq() callback which shouldn't be there.
Taking all above into consideration _I think_ the drivers need a bit of refreshments.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v2 2/2] gpiolib: Show more info for interrupt only lines in debugfs
Hi,
Am Freitag, 31. Mai 2024, 15:30:58 CEST schrieb Andy Shevchenko:
Quoted 22 lines · Alexander Stein
Quoted 6 lines
Am Donnerstag, 30. Mai 2024, 21:12:30 CEST schrieb Andy Shevchenko:
Quoted 3 lines
Show more info for interrupt only lines in debugfs. It's useful to monitor the lines that have been never requested as GPIOs, but IRQs.
I was trying to test this on TQMa8MPQL (i.MX8MP) using
gpio-mxc.c.Thank you for trying!
Quoted 4 lines
But apparently this series only has an effect when
gpiochip_lock_as_irq()is called eventually. I'm wondering what needs to be done so IRQ only GPIOs are listed in debugfs. Using irq_request_resources/irq_release_resources similar to whatpinctrl-at91.cis doing?I haven't looked deeply into this and I don't know if it's relevant, but...
The idea is that GPIO driver has an IRQ chip that announces
handle_bad_irq()as a handler andIRQ_TYPE_NONEas default type at probe stage. It also needs to implement ->set_irq_type() callback where actual handler is going to be locked.
Quoted 5 lines
That's what I do not see implemented in the driver. Moreover, I do see it implements its own ->to_irq() callback which shouldn't be there.
Taking all above into consideration _I
think_the drivers need a bit of refreshments.
I noticed this driver is using irq_chip_generic and a dedicated irq domain. I'm not sure if this is superseded meanwhile using the integrated IRQ chip inside that GPIO chip.
Thanks for looking into this.
Best regards,
Alexander
Signature · 4 lines
TQ-Systems GmbH | Mühlstraße 2, Gut Delling | 82229 Seefeld, Germany Amtsgericht München, HRB 105018 Geschäftsführer: Detlef Schneider, Rüdiger Stahl, Stefan Schneider http://www.tq-group.com/
Re: [PATCH v2 2/2] gpiolib: Show more info for interrupt only lines in debugfs
In reply to Alexander SteinQuoted 7 lines · Alexander Stein
Hi,
Am Donnerstag, 30. Mai 2024, 21:12:30 CEST schrieb Andy Shevchenko:
Quoted 3 lines
Show more info for interrupt only lines in debugfs. It's useful to monitor the lines that have been never requested as GPIOs, but IRQs.
Quoted 5 lines
I was trying to test this on TQMa8MPQL (i.MX8MP) using
gpio-mxc.c. But apparently this series only has an effect whengpiochip_lock_as_irq()is called eventually. I'm wondering what needs to be done so IRQ only GPIOs are listed in debugfs. Using irq_request_resources/irq_release_resources similar to whatpinctrl-at91.cis doing?
For the record on Intel Galileo Gen2 I see this difference
Before:
gpiochip4: GPIOs 8-15, parent: platform/gpio-dwapb.1, gpio-dwapb.1:
gpio-10 ( |spi169 CS0 ) out hi
After:
gpiochip4: GPIOs 8-15, parent: platform/gpio-dwapb.1, gpio-dwapb.1:
gpio-9 ( |irq ) in hi IRQ ACTIVE LOW gpio-10 ( |spi169 CS0 ) out hi
but it's handled via gpiolib-acpi.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Bartosz Golaszewski
AppliedFrom: Bartosz Golaszewski <[email protected]>
Quoted 8 lines · Andy Shevchenko
Couple of patches to show IRQ only (when it's not requested as GPIO) lines in the debugfs.
In v2:
- joined two separate patches
- rebased on top of latest GPIO for-next (Bart)[...]
Applied, thanks!
[1/2] gpiolib: Return label, if set, for IRQ only line
commit: 5a646e03e956f45e74c0a606f51e1ebc13880309
[2/2] gpiolib: Show more info for interrupt only lines in debugfs
commit: 54a687cd49e3625819f24e17655346c85f498cbcBest regards,
Signature · 1 line
Bartosz Golaszewski <[email protected]>