Re: [PATCH v1 06/17] ACPI: HED: Switch over to devres-based resource management

From: Andy Shevchenko

Date: Wed Jun 03 2026 - 07:21:02 EST


On Wed, Jun 03, 2026 at 12:51:20PM +0200, Rafael J. Wysocki wrote:
> On Wed, Jun 3, 2026 at 12:10 AM Andy Shevchenko
> <andriy.shevchenko@xxxxxxxxxxxxxxx> wrote:
> > On Thu, May 21, 2026 at 04:04:03PM +0200, Rafael J. Wysocki wrote:

...

> > > static void acpi_hed_remove(struct platform_device *pdev)
> > > {
> > > - struct acpi_device *device = ACPI_COMPANION(&pdev->dev);
> > > -
> > > hed_present = false;
> > > - acpi_dev_remove_notify_handler(device, ACPI_DEVICE_NOTIFY,
> > > - acpi_hed_notify);
> > > }
> >
> > devm will be cleaned after this, right?
>
> Yes.
>
> > So, here is a window that if one tries
> > to unbind device from the driver in one thread and do the opposite in another
> > they will see the flag false while resources are still allocated for the old
> > one. It seems that hed_present should be also devm:ed?
>
> If this is the same device, both binding and unbinding (including
> devm) take place under its device lock which will serialize all of
> that.
>
> If they are different devices with different ACPI companions, there's
> no resource conflict. If they are both valid HEDs (which would be a
> stretch already) and they both trigger a notification exactly at the
> "wrong" time (more stretch), worst-case stuff will be called twice in
> a row via blocking_notifier_call_chain().

Thanks for elaborating. We are good then.

--
With Best Regards,
Andy Shevchenko