From: "yubowen (H)" <yubowen8@huawei.com>
To: "Rafael J. Wysocki (Intel)" <rafael@kernel.org>
Cc: <linuxarm@huawei.com>, <linux-acpi@vger.kernel.org>,
<lenb@kernel.org>, <linux-kernel@vger.kernel.org>,
<zhanjie9@hisilicon.com>, <prime.zeng@hisilicon.com>,
<wanghuiqiang@huawei.com>, <xuwei5@huawei.com>,
<ouyiyong1@huawei.com>, <dengtao44@huawei.com>,
<tangbin55@huawei.com>, <mojunjun4@huawei.com>,
<wuzhanlong@h-partners.com>
Subject: Re: [PATCH] ACPI: platform: Assign names to MEM resources from _DSD "reg-names"
Date: Wed, 2 Dec 2026 11:35:24 +0800 [thread overview]
Message-ID: <733904f1-d3ad-4dec-a2c0-9ab01fb42bf0@huawei.com> (raw)
In-Reply-To: <CAJZ5v0hJh+DiWhFOUTGqK20FEP-n1uW7n0RbJqyEZqyH-wBUjg@mail.gmail.com>
在 2026/11/20 20:56, Rafael J. Wysocki (Intel) 写道:
> On Thu, Nov 5, 2026 at 4:05 AM Bowen Yu <yubowen8@huawei.com> wrote:
>> ACPI _CRS resources carry no names, so platform_get_resource_byname()
>> always fails for ACPI-created platform devices -- it skips any resource
>> whose name is NULL. This prevents drivers shared between Device Tree
>> and ACPI (via PRP0001) from using byname resource lookup.
>>
>> Add a new helper, acpi_platform_set_resource_names(), that reads the
>> "reg-names" string array from _DSD and assigns names to MEM resources
>> in the order they appear in _CRS. This mirrors the Device Tree
>> "reg-names" property semantics. This property is optional, if absent
>> the behavior will be unchanged.
>>
>> Tested on arm64 by injecting an SSDT through the initrd table upgrade
>> mechanism that describes a PRP0001 test device with three MMIO
>> resources and a matching "reg-names" package: a test driver using
>> platform_get_resource_byname() resolved all three regions, and
>> /proc/iomem shows the assigned names:
>>
>> f0000000-f0000fff : reg0
>> f0001000-f0001fff : reg1
>> f0002000-f0002fff : reg2
>>
>> Signed-off-by: Bowen Yu <yubowen8@huawei.com>
> This is essentially an ACPI specification extension that would be
> Linux-specific and introduced without asking the ACPI Specification
> Working Group for feedback. Let alone documenting it properly.
>
> I'm not going to apply this, sorry.
>
>> ---
>> drivers/acpi/acpi_platform.c | 37 ++++++++++++++++++++++++++++++++++++
>> 1 file changed, 37 insertions(+)
>>
>> diff --git a/drivers/acpi/acpi_platform.c b/drivers/acpi/acpi_platform.c
>> index 80ea7121744d..61f04eacc2f0 100644
>> --- a/drivers/acpi/acpi_platform.c
>> +++ b/drivers/acpi/acpi_platform.c
>> @@ -108,6 +108,39 @@ static unsigned int acpi_platform_adjust_resources(struct acpi_device *adev,
>> return count;
>> }
>>
>> +static void acpi_platform_set_resource_names(struct acpi_device *adev,
>> + struct resource *resources,
>> + int count)
>> +{
>> + const char **names;
>> + int mem_count = 0, mem_idx = 0;
>> + int i, num;
>> +
>> + /* reg-names is optional; skip entirely if not present in _DSD */
>> + if (!fwnode_property_present(acpi_fwnode_handle(adev), "reg-names"))
>> + return;
>> +
>> + for (i = 0; i < count; i++)
>> + if (resource_type(&resources[i]) == IORESOURCE_MEM)
>> + mem_count++;
>> + if (mem_count == 0)
>> + return;
>> +
>> + names = kcalloc(mem_count, sizeof(*names), GFP_KERNEL);
>> + if (!names)
>> + return;
>> +
>> + num = fwnode_property_read_string_array(acpi_fwnode_handle(adev),
>> + "reg-names", names, mem_count);
>> + if (num == mem_count) {
>> + for (i = 0; i < count; i++) {
>> + if (resource_type(&resources[i]) == IORESOURCE_MEM)
>> + resources[i].name = names[mem_idx++];
>> + }
>> + }
>> + kfree(names);
>> +}
>> +
>> static void acpi_platform_fill_resource(struct device *parent,
>> const struct resource *src,
>> struct resource *dest)
>> @@ -194,6 +227,10 @@ struct platform_device *acpi_create_platform_device(struct acpi_device *adev,
>> acpi_platform_fill_resource(parent, rentry->res,
>> &resources[count++]);
>> }
>> +
>> + acpi_platform_set_resource_names(adev, resources,
>> + count);
>> +
>> acpi_dev_free_resource_list(&resource_list);
>> }
>> }
>> --
>> 2.33.0
>>
>>
Hi Rafael,
Thank you for taking a look. The ACPI core was the wrong place for
this. Let me restate the problem.
PRP0001 lets a device be described by its Device Tree binding, with
the binding properties carried in _DSD (see
Documentation/firmware-guide/acpi/enumeration.rst, "Device Tree
namespace link device ID"). Drivers written against such bindings
use by-name lookups, but ACPI has no native notion of named
resources. For IRQs this has already been adapted:
platform_get_irq_byname() resolves "interrupt-names" from _DSD into
the Interrupt() resources of _CRS via fwnode_irq_get_byname()
(ca0acb511c21, d4ad017d6345). platform_get_resource_byname() has no
counterpart yet: drivers like m_can whose bindings require reg-names
cannot be supported at all.
I see two ways out:
1. rework v1 to only affect PRP0001 devices, filling resource names
at device creation time only for devices described by a DT
binding;
2. keep the ACPI core out of this and resolve the name at lookup
time, in platform_get_resource_byname() itself -- this may not be
as clean as the IRQ update since the resource concept is
different in ACPI and DT, so it would be guarded by
is_acpi_device_node() and nothing would change for OF.
Either way this would be documented next to "Named Interrupts" in
enumeration.rst.
Would one of these approaches be acceptable?
Thanks,
Bowen
prev parent reply other threads:[~2026-12-02 3:35 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-05 3:04 Bowen Yu
2026-11-20 12:56 ` Rafael J. Wysocki (Intel)
2026-12-02 3:35 ` yubowen (H) [this message]
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=733904f1-d3ad-4dec-a2c0-9ab01fb42bf0@huawei.com \
--to=yubowen8@huawei.com \
--cc=dengtao44@huawei.com \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxarm@huawei.com \
--cc=mojunjun4@huawei.com \
--cc=ouyiyong1@huawei.com \
--cc=prime.zeng@hisilicon.com \
--cc=rafael@kernel.org \
--cc=tangbin55@huawei.com \
--cc=wanghuiqiang@huawei.com \
--cc=wuzhanlong@h-partners.com \
--cc=xuwei5@huawei.com \
--cc=zhanjie9@hisilicon.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
all inboxes | Powered by JetHome®