Linux Integrity Measurement development
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rafael@kernel.org>
To: Linux ACPI <linux-acpi@vger.kernel.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	Mika Westerberg <mika.westerberg@linux.intel.com>,
	Julien <julien82453@gmail.com>,
	jarkko@kernel.org, linux-integrity@vger.kernel.org
Subject: [PATCH v1] ACPI: scan: Avoid registering platform devices with resource overlaps
Date: Thu, 06 Aug 2026 16:45:13 +0200	[thread overview]
Message-ID: <6299389.lOV4Wx5bFT@rafael.j.wysocki> (raw)

From: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>

If acpi_dev_get_resources() returns overlapping I/O or memory resources,
the subsequent registration of a platform devices 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.

Fixes: 8e345c991c8c ("ACPI: Centralized processing of ACPI device resources")
Fixes: 48fe2cddc85c ("tpm_crb: Convert ACPI driver to a platform one")
Reported-by: Julien <julien82453@gmail.com>
Tested-by: Julien <julien82453@gmail.com>
Closes: https://lore.kernel.org/linux-integrity/CAJOGg3z6LJPDsdPNBxajgy8_wQxfhYBRxe4EiurZf3kPU5A5Bw@mail.gmail.com/ [1]
Cc: All applicable <stable@vger.kernel.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 drivers/acpi/acpi_platform.c |   39 +++++++++++++++++++++++++++++++++++++--
 1 file changed, 37 insertions(+), 2 deletions(-)

--- a/drivers/acpi/acpi_platform.c
+++ b/drivers/acpi/acpi_platform.c
@@ -71,6 +71,39 @@ static struct notifier_block acpi_platfo
 	.notifier_call = acpi_platform_device_remove_notify,
 };
 
+static void acpi_platform_adjust_resource(struct acpi_device *adev,
+					  struct resource *new_res,
+					  const struct resource *resources,
+					  unsigned int count)
+{
+	unsigned int i;
+
+	if (!(new_res->flags & (IORESOURCE_IO | IORESOURCE_MEM)))
+		return;
+
+	for (i = 0; i < count; i++) {
+		const struct resource *res = &resources[i];
+
+		if (resource_type(new_res) != resource_type(res))
+			continue;
+
+		if (!resource_overlaps(new_res, res))
+			continue;
+
+		dev_info(&adev->dev, "Adjusting %pR for %pR\n", new_res, res);
+		/*
+		 * Extend the new resource to include the one that has been
+		 * processed already to avoid resource insertion failures during
+		 * platform device registration.
+		 */
+		if (res->start < new_res->start)
+			new_res->start = res->start;
+
+		if (res->end > new_res->end)
+			new_res->end = res->end;
+	}
+}
+
 static void acpi_platform_fill_resource(struct acpi_device *adev,
 	const struct resource *src, struct resource *dest)
 {
@@ -151,10 +184,12 @@ struct platform_device *acpi_create_plat
 				return ERR_PTR(-ENOMEM);
 			}
 			count = 0;
-			list_for_each_entry(rentry, &resource_list, node)
+			list_for_each_entry(rentry, &resource_list, node) {
+				acpi_platform_adjust_resource(adev, rentry->res,
+							      resources, count);
 				acpi_platform_fill_resource(adev, rentry->res,
 							    &resources[count++]);
-
+			}
 			acpi_dev_free_resource_list(&resource_list);
 		}
 	}




                 reply	other threads:[~2026-08-06 14:45 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=6299389.lOV4Wx5bFT@rafael.j.wysocki \
    --to=rafael@kernel.org \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=jarkko@kernel.org \
    --cc=julien82453@gmail.com \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-integrity@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mika.westerberg@linux.intel.com \
    /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