On Tue, Aug 4, 2026 at 9:08 PM Wysocki, Rafael J
<[email protected]> wrote:
>
> Hi,
>
> On 8/2/2026 2:54 PM, Julien wrote:
> > Hello,
> >
> > Please keep in mind this is my first time reporting a Linux kernel
> > regression.
> >
> > Since commit 48fe2cddc85c ("tpm_crb: Convert ACPI driver to a platform
> > one"), my TPM device is no longer available. Both /dev/tpm0 and
> > /dev/tpmrm0 are missing.
> >
> > Log messages:
> > platform MSFT0101:00: failed to claim resource 1: [mem
> > 0xfed40000-0xfed40fff]
> > acpi MSFT0101:00: platform device creation failed: -16
> >
> So there's no platform device for the driver to bind to.
>
> I think that these messages have been present in the kernel logs for
> quite some time, but previously they were not connected to any
> functional issues.
>
>
> > I added some debug logging:
> > ACPI resourcet[0] = [mem 0xfed40040-0xfed4103f flags 0x200]
> > ACPI resourcet[1] = [mem 0xfed40000-0xfed40fff flags 0x200]
> >
> > I think the failure happens in kernel/resource.c: __insert_resource()
> > because of the two memory regions overlapping.
> >
> This is quite plausible, but if that's the case, it should be fixable.
>
> Let me figure out something.

Please try the attached patch and let me know how it goes.

It applies on top of the current mainline, but it may be adjusted to
older kernels, so please let me know if you need that.
---
 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 resource %pR to %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 via email to