From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=113.46.200.216 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796182536; b=suQQHGHZc2wlOFCDU65+m4W4Pz9IYQz1YIhUCjlrDP6l7rlmWZfe6+bUk6lhM5/2/mQ4 E9hOSEYkp32JhafzRzqHVB8XkhVV7p4OW9llVCqsQ0zn5HD5FBPAwkw2Rn+uCf6RtFVpr XkGPD0grNERKBqiJIvEEemBXfDjbKMSSueVfUGEly+v1W4Yn6PcXXYxNZWxfYLELiVJL4 h/s+DK8YpQmoH4Wk0zTVpptCFIYSI/WIHJWxTU5fiTdZCPIvyX9Fx7IbYApiQ9zyglX2q uQkU4hjXkN0cGJlYZfcMf3z/c3BXblwTOizZ8ac7CAZbyTVajw6BaKhZQWt9s0f0Kjw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796182536; h=DMARC-Filter:dkim-signature:Received:Received:Received:Message-ID: Date:MIME-Version:User-Agent:Subject:To:CC:References:From: In-Reply-To:Content-Type:Content-Transfer-Encoding:X-Originating-IP: X-ClientProxiedBy; bh=smLebVQ1MitWp2zFD8eC/4Z7mvPA9wdeS/1Xgr9Yf8Q=; b=OL2mMWCRZUpYLXsDsfzczJzepwnXz6hhHSwxi0UK5vNQVbPYG1dW6fuzp97Rcs27g6PN GsqxOzAakZ0i5aOFuVeUwMjZyGNHNG7QCvajPu8hopC+i78DtOwaA5EN+5FHa/lAjc5aO skCDxFbXKdUh5oX9qeyLccMyJxlYuRAeefWBrPWunlTKuhCQhEqtAUaQ6NhRjQNwIGkam k2uQgwiOf7pRByUlN2T+yG3QNavBUe2xnhGLrLJBwpkngHZ5VkfExCo0tO/QHyjbW1O7K 9ws4dV4aCKyiOZnyOnXxDPK3Jg/nSDE2fJYpntCC4DmbW3S6ZSMf+5SCRzVCzMdZ4Hg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; dkim=pass header.d=huawei.com header.i=@huawei.com header.a=rsa-sha256 header.s=dkim header.b="K5/Rb8s6"; arc=none smtp.remote-ip=113.46.200.216 Received: from canpmsgout01.his.huawei.com (canpmsgout01.his.huawei.com [113.46.200.216]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 610A5606A323; Wed, 2 Dec 2026 03:35:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 610A5606A323 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=huawei.com header.i=@huawei.com header.a=rsa-sha256 header.s=dkim header.b=K5/Rb8s6 dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=smLebVQ1MitWp2zFD8eC/4Z7mvPA9wdeS/1Xgr9Yf8Q=; b=K5/Rb8s62/vzLb/lOLKYnW7Yy21e53peGJN5F8IeuHYqkw2vDANWp4UIATiqjYtXbrGavhZkf sCkvzRrdy5QlrS201Cyd86Nr9hq0pPQyh0wwSgkFNH636nvYCBBvWtMeB8Px47/lZaA9C02oMu/ lPpbvV5CCjlc4zTJ66BM8eE= Received: from mail.maildlp.com (unknown [172.19.162.223]) by canpmsgout01.his.huawei.com (SkyGuard) with ESMTPS id 4jfNfV2y8wz1T4GK; Wed, 2 Dec 2026 11:34:26 +0800 (CST) Received: from kwepemo100017.china.huawei.com (unknown [7.202.195.215]) by mail.maildlp.com (Postfix) with ESMTPS id C702340577; Wed, 2 Dec 2026 11:35:25 +0800 (CST) Received: from [10.67.120.228] (10.67.120.228) by kwepemo100017.china.huawei.com (7.202.195.215) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.56; Wed, 2 Dec 2026 11:35:25 +0800 Message-ID: <733904f1-d3ad-4dec-a2c0-9ab01fb42bf0@huawei.com> Date: Wed, 2 Dec 2026 11:35:24 +0800 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] ACPI: platform: Assign names to MEM resources from _DSD "reg-names" To: "Rafael J. Wysocki (Intel)" CC: , , , , , , , , , , , , References: <20261105030450.1946871-1-yubowen8@huawei.com> From: "yubowen (H)" In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-ClientProxiedBy: kwepems100001.china.huawei.com (7.221.188.238) To kwepemo100017.china.huawei.com (7.202.195.215) 在 2026/11/20 20:56, Rafael J. Wysocki (Intel) 写道: > On Thu, Nov 5, 2026 at 4:05 AM Bowen Yu 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 > 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