* [PATCH] gpio: ml-ioh: Add devm_free_irq() call to remove flow
@ 2022-05-12 11:21 Zheyu Ma
2022-05-12 12:02 ` Andy Shevchenko
0 siblings, 1 reply; 6+ messages in thread
From: Zheyu Ma @ 2022-05-12 11:21 UTC (permalink / raw)
To: andy, linus.walleij, brgl; +Cc: linux-gpio, linux-kernel, Zheyu Ma
When removing the module, we will get the following flaw:
[ 14.204955] remove_proc_entry: removing non-empty directory 'irq/21', leaking at least 'gpio_ml_ioh'
[ 14.205827] WARNING: CPU: 0 PID: 305 at fs/proc/generic.c:717 remove_proc_entry+0x389/0x3f0
[ 14.209994] RIP: 0010:remove_proc_entry+0x389/0x3f0
[ 14.217820] Call Trace:
[ 14.218057] <TASK>
[ 14.218264] unregister_irq_proc+0x14c/0x170
[ 14.218674] irq_free_descs+0x94/0xe0
[ 14.219019] mp_unmap_irq+0xb6/0x100
[ 14.219357] acpi_unregister_gsi_ioapic+0x27/0x40
[ 14.219796] acpi_pci_irq_disable+0x1d3/0x320
[ 14.220206] pci_disable_device+0x1ad/0x380
[ 14.220613] ioh_gpio_remove+0xc5/0xe0 [gpio_ml_ioh]
[ 14.221075] pci_device_remove+0x92/0x240
Fix this bug by adding devm_free_irq() call to remove flow.
Signed-off-by: Zheyu Ma <zheyuma97@gmail.com>
---
drivers/gpio/gpio-ml-ioh.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/gpio/gpio-ml-ioh.c b/drivers/gpio/gpio-ml-ioh.c
index b060c4773698..09bf317876b0 100644
--- a/drivers/gpio/gpio-ml-ioh.c
+++ b/drivers/gpio/gpio-ml-ioh.c
@@ -508,6 +508,8 @@ static void ioh_gpio_remove(struct pci_dev *pdev)
struct ioh_gpio *chip = pci_get_drvdata(pdev);
void *chip_save;
+ devm_free_irq(&pdev->dev, pdev->irq, chip);
+
chip_save = chip;
for (i = 0; i < 8; i++, chip++)
--
2.25.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] gpio: ml-ioh: Add devm_free_irq() call to remove flow
2022-05-12 11:21 [PATCH] gpio: ml-ioh: Add devm_free_irq() call to remove flow Zheyu Ma
@ 2022-05-12 12:02 ` Andy Shevchenko
2022-05-12 12:47 ` [PATCH v2] " Zheyu Ma
2022-05-12 12:50 ` [PATCH] " Zheyu Ma
0 siblings, 2 replies; 6+ messages in thread
From: Andy Shevchenko @ 2022-05-12 12:02 UTC (permalink / raw)
To: Zheyu Ma
Cc: Andy Shevchenko, Linus Walleij, Bartosz Golaszewski,
open list:GPIO SUBSYSTEM, Linux Kernel Mailing List
On Thu, May 12, 2022 at 1:21 PM Zheyu Ma <zheyuma97@gmail.com> wrote:
>
> When removing the module, we will get the following flaw:
Thanks for the report and patch! My comments below.
> [ 14.204955] remove_proc_entry: removing non-empty directory 'irq/21', leaking at least 'gpio_ml_ioh'
> [ 14.205827] WARNING: CPU: 0 PID: 305 at fs/proc/generic.c:717 remove_proc_entry+0x389/0x3f0
> [ 14.209994] RIP: 0010:remove_proc_entry+0x389/0x3f0
> [ 14.217820] Call Trace:
> [ 14.218057] <TASK>
> [ 14.218264] unregister_irq_proc+0x14c/0x170
> [ 14.218674] irq_free_descs+0x94/0xe0
> [ 14.219019] mp_unmap_irq+0xb6/0x100
> [ 14.219357] acpi_unregister_gsi_ioapic+0x27/0x40
> [ 14.219796] acpi_pci_irq_disable+0x1d3/0x320
> [ 14.220206] pci_disable_device+0x1ad/0x380
> [ 14.220613] ioh_gpio_remove+0xc5/0xe0 [gpio_ml_ioh]
> [ 14.221075] pci_device_remove+0x92/0x240
Can we remove not so important lines from the above? I guess ~3-4
selected ones would be enough.
> Fix this bug by adding devm_free_irq() call to remove flow.
Fixes tag?
> Signed-off-by: Zheyu Ma <zheyuma97@gmail.com>
The code looks okay on the first glance.
P.S. Do you have such hardware?
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2] gpio: ml-ioh: Add devm_free_irq() call to remove flow
2022-05-12 12:02 ` Andy Shevchenko
@ 2022-05-12 12:47 ` Zheyu Ma
2022-05-14 12:50 ` Bartosz Golaszewski
2022-05-14 13:04 ` Andy Shevchenko
2022-05-12 12:50 ` [PATCH] " Zheyu Ma
1 sibling, 2 replies; 6+ messages in thread
From: Zheyu Ma @ 2022-05-12 12:47 UTC (permalink / raw)
To: andy, linus.walleij, brgl; +Cc: linux-gpio, linux-kernel, Zheyu Ma
When removing the module, we will get the following flaw:
[ 14.204955] remove_proc_entry: removing non-empty directory 'irq/21', leaking at least 'gpio_ml_ioh'
[ 14.205827] WARNING: CPU: 0 PID: 305 at fs/proc/generic.c:717 remove_proc_entry+0x389/0x3f0
[ 14.209994] RIP: 0010:remove_proc_entry+0x389/0x3f0
[ 14.217820] Call Trace:
[ 14.218264] unregister_irq_proc+0x14c/0x170
[ 14.220206] pci_disable_device+0x1ad/0x380
[ 14.220613] ioh_gpio_remove+0xc5/0xe0 [gpio_ml_ioh]
Fix this bug by adding devm_free_irq() call to remove flow.
Fixes: e971ac9a564a ("gpio: ml-ioh: use resource management for irqs")
Signed-off-by: Zheyu Ma <zheyuma97@gmail.com>
---
Changes in v2:
- Remove unimportant lines from the call trace.
- Add the fixes tag.
---
drivers/gpio/gpio-ml-ioh.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/gpio/gpio-ml-ioh.c b/drivers/gpio/gpio-ml-ioh.c
index b060c4773698..09bf317876b0 100644
--- a/drivers/gpio/gpio-ml-ioh.c
+++ b/drivers/gpio/gpio-ml-ioh.c
@@ -508,6 +508,8 @@ static void ioh_gpio_remove(struct pci_dev *pdev)
struct ioh_gpio *chip = pci_get_drvdata(pdev);
void *chip_save;
+ devm_free_irq(&pdev->dev, pdev->irq, chip);
+
chip_save = chip;
for (i = 0; i < 8; i++, chip++)
--
2.25.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] gpio: ml-ioh: Add devm_free_irq() call to remove flow
2022-05-12 12:02 ` Andy Shevchenko
2022-05-12 12:47 ` [PATCH v2] " Zheyu Ma
@ 2022-05-12 12:50 ` Zheyu Ma
1 sibling, 0 replies; 6+ messages in thread
From: Zheyu Ma @ 2022-05-12 12:50 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Andy Shevchenko, Linus Walleij, Bartosz Golaszewski,
open list:GPIO SUBSYSTEM, Linux Kernel Mailing List
On Thu, May 12, 2022 at 8:03 PM Andy Shevchenko
<andy.shevchenko@gmail.com> wrote:
>
> On Thu, May 12, 2022 at 1:21 PM Zheyu Ma <zheyuma97@gmail.com> wrote:
> >
> > When removing the module, we will get the following flaw:
>
> Thanks for the report and patch! My comments below.
>
> > [ 14.204955] remove_proc_entry: removing non-empty directory 'irq/21', leaking at least 'gpio_ml_ioh'
> > [ 14.205827] WARNING: CPU: 0 PID: 305 at fs/proc/generic.c:717 remove_proc_entry+0x389/0x3f0
> > [ 14.209994] RIP: 0010:remove_proc_entry+0x389/0x3f0
> > [ 14.217820] Call Trace:
> > [ 14.218057] <TASK>
> > [ 14.218264] unregister_irq_proc+0x14c/0x170
> > [ 14.218674] irq_free_descs+0x94/0xe0
> > [ 14.219019] mp_unmap_irq+0xb6/0x100
> > [ 14.219357] acpi_unregister_gsi_ioapic+0x27/0x40
> > [ 14.219796] acpi_pci_irq_disable+0x1d3/0x320
> > [ 14.220206] pci_disable_device+0x1ad/0x380
> > [ 14.220613] ioh_gpio_remove+0xc5/0xe0 [gpio_ml_ioh]
> > [ 14.221075] pci_device_remove+0x92/0x240
>
> Can we remove not so important lines from the above? I guess ~3-4
> selected ones would be enough.
>
> > Fix this bug by adding devm_free_irq() call to remove flow.
>
> Fixes tag?
>
> > Signed-off-by: Zheyu Ma <zheyuma97@gmail.com>
>
> The code looks okay on the first glance.
>
> P.S. Do you have such hardware?
Thanks for your comments, I've resend the patch.
Actually, I do not have the hardware. I test the driver with a virtual
device instead.
Zheyu Ma
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] gpio: ml-ioh: Add devm_free_irq() call to remove flow
2022-05-12 12:47 ` [PATCH v2] " Zheyu Ma
@ 2022-05-14 12:50 ` Bartosz Golaszewski
2022-05-14 13:04 ` Andy Shevchenko
1 sibling, 0 replies; 6+ messages in thread
From: Bartosz Golaszewski @ 2022-05-14 12:50 UTC (permalink / raw)
To: Zheyu Ma
Cc: Andy Shevchenko, Linus Walleij, open list:GPIO SUBSYSTEM,
Linux Kernel Mailing List
On Thu, May 12, 2022 at 2:48 PM Zheyu Ma <zheyuma97@gmail.com> wrote:
>
> When removing the module, we will get the following flaw:
>
> [ 14.204955] remove_proc_entry: removing non-empty directory 'irq/21', leaking at least 'gpio_ml_ioh'
> [ 14.205827] WARNING: CPU: 0 PID: 305 at fs/proc/generic.c:717 remove_proc_entry+0x389/0x3f0
> [ 14.209994] RIP: 0010:remove_proc_entry+0x389/0x3f0
> [ 14.217820] Call Trace:
> [ 14.218264] unregister_irq_proc+0x14c/0x170
> [ 14.220206] pci_disable_device+0x1ad/0x380
> [ 14.220613] ioh_gpio_remove+0xc5/0xe0 [gpio_ml_ioh]
>
> Fix this bug by adding devm_free_irq() call to remove flow.
>
> Fixes: e971ac9a564a ("gpio: ml-ioh: use resource management for irqs")
> Signed-off-by: Zheyu Ma <zheyuma97@gmail.com>
> ---
> Changes in v2:
> - Remove unimportant lines from the call trace.
> - Add the fixes tag.
> ---
> drivers/gpio/gpio-ml-ioh.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/gpio/gpio-ml-ioh.c b/drivers/gpio/gpio-ml-ioh.c
> index b060c4773698..09bf317876b0 100644
> --- a/drivers/gpio/gpio-ml-ioh.c
> +++ b/drivers/gpio/gpio-ml-ioh.c
> @@ -508,6 +508,8 @@ static void ioh_gpio_remove(struct pci_dev *pdev)
> struct ioh_gpio *chip = pci_get_drvdata(pdev);
> void *chip_save;
>
> + devm_free_irq(&pdev->dev, pdev->irq, chip);
> +
If you need to use devm_free_anything() in the remove callback then
something is simply wrong in the resource handling. Can you instead
use devm_gpiochip_add_data() in probe? This most likely would fix this
problem because it would correctly order the freeing of resources.
Bart
> chip_save = chip;
>
> for (i = 0; i < 8; i++, chip++)
> --
> 2.25.1
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] gpio: ml-ioh: Add devm_free_irq() call to remove flow
2022-05-12 12:47 ` [PATCH v2] " Zheyu Ma
2022-05-14 12:50 ` Bartosz Golaszewski
@ 2022-05-14 13:04 ` Andy Shevchenko
1 sibling, 0 replies; 6+ messages in thread
From: Andy Shevchenko @ 2022-05-14 13:04 UTC (permalink / raw)
To: Zheyu Ma; +Cc: andy, linus.walleij, brgl, linux-gpio, linux-kernel
On Thu, May 12, 2022 at 08:47:55PM +0800, Zheyu Ma wrote:
> When removing the module, we will get the following flaw:
>
> [ 14.204955] remove_proc_entry: removing non-empty directory 'irq/21', leaking at least 'gpio_ml_ioh'
> [ 14.205827] WARNING: CPU: 0 PID: 305 at fs/proc/generic.c:717 remove_proc_entry+0x389/0x3f0
> [ 14.209994] RIP: 0010:remove_proc_entry+0x389/0x3f0
> [ 14.217820] Call Trace:
> [ 14.218264] unregister_irq_proc+0x14c/0x170
> [ 14.220206] pci_disable_device+0x1ad/0x380
> [ 14.220613] ioh_gpio_remove+0xc5/0xe0 [gpio_ml_ioh]
I would expect something like:
[ 14.204955] remove_proc_entry: removing non-empty directory 'irq/21', leaking at least 'gpio_ml_ioh'
[ 14.205827] WARNING: CPU: 0 PID: 305 at fs/proc/generic.c:717 remove_proc_entry+0x389/0x3f0
...
[ 14.220613] ioh_gpio_remove+0xc5/0xe0 [gpio_ml_ioh]
[ 14.221075] pci_device_remove+0x92/0x240
It pretty much explains the case.
> Fix this bug by adding devm_free_irq() call to remove flow.
P.S. When sending a new version do not attach it to previous thread, always
start a new one. It will be simpler to handle by tools.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2022-05-14 13:05 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-12 11:21 [PATCH] gpio: ml-ioh: Add devm_free_irq() call to remove flow Zheyu Ma
2022-05-12 12:02 ` Andy Shevchenko
2022-05-12 12:47 ` [PATCH v2] " Zheyu Ma
2022-05-14 12:50 ` Bartosz Golaszewski
2022-05-14 13:04 ` Andy Shevchenko
2022-05-12 12:50 ` [PATCH] " Zheyu Ma
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.