mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Adrian Ambrozewicz <aambrozewicz@nvidia.com>
Cc: Bartosz Golaszewski <brgl@kernel.org>,
	Linus Walleij <linusw@kernel.org>,
	Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>,
	Kent Gibson <warthog618@gmail.com>,
	Mika Westerberg <westeri@kernel.org>,
	Herve Codina <herve.codina@bootlin.com>,
	linux-gpio@vger.kernel.org, linux-acpi@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 2/3] gpiolib: release the chip's own lines before numbing it on removal
Date: Fri, 27 Nov 2026 17:42:50 +0200	[thread overview]
Message-ID: <awmk-lfmMw8GG21o@ashevche-desk.local> (raw)
In-Reply-To: <20261127124429.3423977-2-aambrozewicz@nvidia.com>

On Fri, Nov 27, 2026 at 02:44:30PM +0200, Adrian Ambrozewicz wrote:
> On Fri, Nov 27, 2026 at 01:46:29PM +0200, Andy Shevchenko wrote:
> > On Fri, Nov 27, 2026 at 09:49:26AM +0200, Adrian Ambrozewicz wrote:

...

> > >  	gpiochip_irqchip_remove(gc);
> > > -	acpi_gpiochip_remove(gc);
> > >  	of_gpiochip_remove(gc);
> >
> > I need to look closer for ACPI bits, but above doesn't sound right. Why
> > of_gpiochip_remove() is not associated with ACPI counterpart? Wouldn't it bring
> > a completely different experience on the same platform depending on the
> > firmware in use (DT or ACPI)?
> 
> Thanks for the review. acpi_gpiochip_remove() releases the OpRegion
> connections with gpiochip_free_own_desc(), which skips ->free() once
> the chip is numbed. of_gpiochip_remove() releases no lines; the DT hogs
> are freed by gpiochip_free_hogs(), which commit 5018ada69a04 ("gpio:
> Move freeing of GPIO hogs before numbing of the device") already moved
> ahead of the numbing. So both now free their lines before it.
> 
> To keep the two calls paired, for v3 I plan to split the OpRegion
> release out of acpi_gpiochip_remove() and move only that ahead of the
> numbing. Would that work for you?

At least it sounds like a better idea.

> > > - * This is called only from gpiochip_remove()
> > > + * acpi_gpiochip_free_interrupts() below finds nothing once
> > > + * gpiochip_free_own_lines() has run; it is for the error paths before that.
> >
> > This doesn't sound right either. Why the common method of freeing ACPI event
> > interrupts can't be shut down here and this one called when we need to remove
> > the IRQ chip altogether?
> 
> The event IRQs cannot wait for the irqchip removal: the numbing ends
> with gpiochip_free_remaining_irqs(), which frees them, and
> acpi_gpiochip_free_interrupts() then frees them again ("Trying to free
> already-free IRQ"). The irqchip cannot go before the numbing either:
> the character device frees its IRQs only after it.

This sounds like something is wrong in the cleanup flow. Why double free
appears in the first place? Is the acpi_gpiochip_free_interrupts() call
placed at incorrect function in the tear down flow?

> So for v3 I plan to drop acpi_gpiochip_free_interrupts() and this
> comment from gpiochip_irqchip_remove(), and call it from
> gpiochip_remove() and the error paths instead. Is that what you had in
> mind?

Perhaps. I can't see it clearly in my mind, maybe when v3 is out it will
be more obvious.

-- 
With Best Regards,
Andy Shevchenko



  reply	other threads:[~2026-11-27 15:42 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-27  7:49 [PATCH v2 0/3] gpiolib: free the lines a chip owns before numbing it Adrian Ambrozewicz
2026-11-27  7:49 ` [PATCH v2 1/3] gpiolib: shared: remove the proxies before releasing the shared line Adrian Ambrozewicz
2026-11-27  7:49 ` [PATCH v2 2/3] gpiolib: release the chip's own lines before numbing it on removal Adrian Ambrozewicz
2026-11-27 11:46   ` Andy Shevchenko
2026-11-27 12:44     ` Adrian Ambrozewicz
2026-11-27 15:42       ` Andy Shevchenko [this message]
2026-11-27  7:49 ` [PATCH v2 3/3] gpiolib: release user space's lines when adding the chip fails late Adrian Ambrozewicz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=awmk-lfmMw8GG21o@ashevche-desk.local \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=aambrozewicz@nvidia.com \
    --cc=bartosz.golaszewski@oss.qualcomm.com \
    --cc=brgl@kernel.org \
    --cc=herve.codina@bootlin.com \
    --cc=linusw@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=warthog618@gmail.com \
    --cc=westeri@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®