Skip to content

gpio-cdev: Release IRQ used by gpio-cdev on gpio chip removal

Herve Codina linux-gpio lkml 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest2 patches 10 repliesIn review
  2. v12 patches 14 repliesSuperseded

Changes in v2 from the cover letter

- Patch 1

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2gpiolib: call gcdev_unregister() sooner in the removal operationsdrivers/gpio/gpiolib.c+5 -10 replies
2/2gpiolib: cdev: release IRQs when the gpio chip device is removeddrivers/gpio/gpiolib-cdev.c+22 -110 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [PATCH v2 0/2] gpio-cdev: Release IRQ used by gpio-cdev on gpio chip removal

Hi,

When a gpio chip device is removed while some related gpio are used by the user-space (gpiomon for instance), the following warning can appear:
remove_proc_entry: removing non-empty directory 'irq/233', leaking at least 'gpiomon'

  WARNING: CPU: 2 PID: 72 at fs/proc/generic.c:717 remove_proc_entry+0x190/0x19c
  ...
  Call trace:
    remove_proc_entry+0x190/0x19c
    unregister_irq_proc+0xd0/0x104
    free_desc+0x4c/0xc4
    irq_free_descs+0x6c/0x90
    irq_dispose_mapping+0x104/0x14c
    gpiochip_irqchip_remove+0xcc/0x1a4
    gpiochip_remove+0x48/0x100
  ...

Indeed, even if the gpio removal is notified to the gpio-cdev, the IRQ used is not released when it should be.

This series calls the gpio removal notifier sooner in the removal process in order to give a chance to a notifier function to release the IRQ before releasing the IRQ mapping and adds the needed operations to release the IRQ in the gpio cdev notifier function.

Compared to the previous iteration:
https://lore.kernel.org/linux-kernel/[email protected]/
this v2 series set gdev->chip to NULL before calling gcdev_unregister().

Also, this v2 series was rebased on top of for-next branch of the GPIO tree.

Best regards,
Hervé Codina

Changes v1 -> v2:
- Patch 1

    Set gdev->chip to NULL before calling gcdev_unregister()

- Patch 2
No changes

Herve Codina (2):
gpiolib: call gcdev_unregister() sooner in the removal operations
gpiolib: cdev: release IRQs when the gpio chip device is removed

 drivers/gpio/gpiolib-cdev.c | 33 ++++++++++++++++++++++-----------
 drivers/gpio/gpiolib.c      |  6 +++++-
 2 files changed, 27 insertions(+), 12 deletions(-)
Signature · 1 line
2.43.0