Re: [PATCH v3] ACPI: scan: Avoid registering platform devices with resource overlaps
"Rafael J. Wysocki (Intel)" <[email protected]> Mon, 10 Aug 2026 12:41:05 +0200
| Newsgroups | gmane.linux.acpi.devel,gmane.linux.kernel |
|---|---|
| Message-ID | <CAJZ5v0itYEMDyzkYdPApQXMVu06-jVpZs4qWrw2SnYLLHzthpw@mail.gmail.com> |
On Sat, Aug 8, 2026 at 10:04 PM Andy Shevchenko <[email protected]> wrote: > > On Fri, Aug 07, 2026 at 12:22:37PM +0200, Rafael J. Wysocki wrote: > > > If acpi_dev_get_resources() returns overlapping I/O or memory resources, > > the subsequent registration of a platform device will fail with -EBUSY > > due to a resource conflict. This is reported to happen on Acer Aspire > > ES1-572 [1]. > > > > Avoid that by adjusting resources returned by acpi_dev_get_resources() > > to eliminate partial overlaps between them. > > > > This has not been regarded as necessary before because putting > > overlapping resources into the _CRS of one device is really pointless, > > but now that the issue has been reported to actually happen in the > > field, it needs to be done. > > ... > > > * Use resource_union() and adjust code and comment (Andy) > > Thanks, LGTM now, > Reviewed-by: Andy Shevchenko <[email protected]> Thanks! > > +static unsigned int acpi_platform_adjust_resources(struct acpi_device *adev, > > + struct resource *new_res, > > + struct resource *resources, > > + unsigned int count) > > +{ > > + unsigned int i; > > + > > + if (!(new_res->flags & (IORESOURCE_IO | IORESOURCE_MEM))) > > Can also be > > if (!(resource_type(new_res) & (IORESOURCE_IO | IORESOURCE_MEM))) It could, but it would add a redundant "bitwise and" with the type mask. I guess the compiler can be expected to optimize it away, but if it doesn't get optimized away, it's just pure useless overhead. > > + return count; > > + > > + for (i = 0; i < count; ) { > > + struct resource *res = &resources[i]; > > > + if (resource_type(new_res) != resource_type(res) || > > + !resource_union(new_res, res, new_res)) { > > Wondering why we don't have the resource type checks in resource_overlaps(), Yeah, it looks like a missing piece. > but we have in resource_contains(). Ilpo, do you know?