Skip to content

Commit 87bfb48

Browse files
mibrunnerlag-linaro
authored andcommitted
mfd: kempld-core: Don't replace resources provided by ACPI
The current implementation to retrieve ACPI resources is faulty and may cause issues that even can lead to non-booting systems. When adding data from an ACPI device, the resources are already assigned to the platform device. Therefore there is no need to retrieve the resource list from ACPI and manually assign it to the platform device. Also there shouldn't be any BIOS in the wild anymore, that does not have resources added to the KEMPLD ACPI data. In particular this fixes an issue where the retrieval of the resource list using /proc/ioports is disturbed and does not list the assigned resource for the kempld device or even no resources at all. On some distributions this also leads to problems during system initialization (e.g. with udev) and causes the system to not boot at all. I have reproduced the issue with the following kernel versions: 5.10.209 5.15.148 6.1.25 6.6.17 6.7.5 6.8-rc5 The patch applies to all of those versions and seems to resolve the issue. Signed-off-by: Michael Brunner <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Lee Jones <[email protected]>
1 parent 8f49b62 commit 87bfb48

File tree

1 file changed

+0
-37
lines changed

1 file changed

+0
-37
lines changed

drivers/mfd/kempld-core.c

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -428,50 +428,13 @@ static int kempld_detect_device(struct kempld_device_data *pld)
428428
#ifdef CONFIG_ACPI
429429
static int kempld_get_acpi_data(struct platform_device *pdev)
430430
{
431-
struct list_head resource_list;
432-
struct resource *resources;
433-
struct resource_entry *rentry;
434431
struct device *dev = &pdev->dev;
435-
struct acpi_device *acpi_dev = ACPI_COMPANION(dev);
436432
const struct kempld_platform_data *pdata;
437433
int ret;
438-
int count;
439434

440435
pdata = acpi_device_get_match_data(dev);
441436
ret = platform_device_add_data(pdev, pdata,
442437
sizeof(struct kempld_platform_data));
443-
if (ret)
444-
return ret;
445-
446-
INIT_LIST_HEAD(&resource_list);
447-
ret = acpi_dev_get_resources(acpi_dev, &resource_list, NULL, NULL);
448-
if (ret < 0)
449-
goto out;
450-
451-
count = ret;
452-
453-
if (count == 0) {
454-
ret = platform_device_add_resources(pdev, pdata->ioresource, 1);
455-
goto out;
456-
}
457-
458-
resources = devm_kcalloc(&acpi_dev->dev, count, sizeof(*resources),
459-
GFP_KERNEL);
460-
if (!resources) {
461-
ret = -ENOMEM;
462-
goto out;
463-
}
464-
465-
count = 0;
466-
list_for_each_entry(rentry, &resource_list, node) {
467-
memcpy(&resources[count], rentry->res,
468-
sizeof(*resources));
469-
count++;
470-
}
471-
ret = platform_device_add_resources(pdev, resources, count);
472-
473-
out:
474-
acpi_dev_free_resource_list(&resource_list);
475438

476439
return ret;
477440
}

0 commit comments

Comments
 (0)