From: Jinhui Guo <guojinhui.liam@bytedance.com>
To: rafael@kernel.org, lenb@kernel.org, gregkh@linuxfoundation.org
Cc: lizefan.x@bytedance.com, linux-acpi@vger.kernel.org,
linux-kernel@vger.kernel.org,
Jinhui Guo <guojinhui.liam@bytedance.com>,
stable@vger.kernel.org, kernel test robot <lkp@intel.com>
Subject: [PATCH v6] driver core: platform: set numa_node before platform_device_add()
Date: Mon, 18 Sep 2023 21:45:27 +0800 [thread overview]
Message-ID: <20230918134527.252-1-guojinhui.liam@bytedance.com> (raw)
Setting the devices' numa_node needs to be done in
platform_device_register_full(), because that's where the
platform device object is allocated.
Fixes: 4a60406d3592 ("driver core: platform: expose numa_node to users in sysfs")
Cc: stable@vger.kernel.org
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202309122309.mbxAnAIe-lkp@intel.com/
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Rafael J. Wysocki <rafael@kernel.org>
Signed-off-by: Jinhui Guo <guojinhui.liam@bytedance.com>
---
V5 -> V6:
1. Update subject to correct function name platform_device_add().
2. Provide a more clear and accurate description of the changes
made in commit (suggested by Rafael J. Wysocki).
3. Add reviewer name.
V4 -> V5:
Add Cc: stable line and changes from the previous submited patches.
V3 -> V4:
Refactor code to be an ACPI function call.
V2 -> V3:
Fix Signed-off name.
V1 -> V2:
Fix compile error without enabling CONFIG_ACPI.
---
drivers/acpi/acpi_platform.c | 4 +---
drivers/base/platform.c | 1 +
include/linux/acpi.h | 5 +++++
3 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/drivers/acpi/acpi_platform.c b/drivers/acpi/acpi_platform.c
index 48d15dd785f6..adcbfbdc343f 100644
--- a/drivers/acpi/acpi_platform.c
+++ b/drivers/acpi/acpi_platform.c
@@ -178,11 +178,9 @@ struct platform_device *acpi_create_platform_device(struct acpi_device *adev,
if (IS_ERR(pdev))
dev_err(&adev->dev, "platform device creation failed: %ld\n",
PTR_ERR(pdev));
- else {
- set_dev_node(&pdev->dev, acpi_get_node(adev->handle));
+ else
dev_dbg(&adev->dev, "created platform device %s\n",
dev_name(&pdev->dev));
- }
kfree(resources);
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index 76bfcba25003..35c891075d95 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -841,6 +841,7 @@ struct platform_device *platform_device_register_full(
goto err;
}
+ set_dev_node(&pdev->dev, ACPI_NODE_GET(ACPI_COMPANION(&pdev->dev)));
ret = platform_device_add(pdev);
if (ret) {
err:
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index a73246c3c35e..6a349d53f19e 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -477,6 +477,10 @@ static inline int acpi_get_node(acpi_handle handle)
return 0;
}
#endif
+
+#define ACPI_NODE_GET(adev) ((adev) && (adev)->handle ? \
+ acpi_get_node((adev)->handle) : NUMA_NO_NODE)
+
extern int pnpacpi_disabled;
#define PXM_INVAL (-1)
@@ -770,6 +774,7 @@ const char *acpi_get_subsystem_id(acpi_handle handle);
#define ACPI_COMPANION_SET(dev, adev) do { } while (0)
#define ACPI_HANDLE(dev) (NULL)
#define ACPI_HANDLE_FWNODE(fwnode) (NULL)
+#define ACPI_NODE_GET(adev) NUMA_NO_NODE
#include <acpi/acpi_numa.h>
--
2.20.1
next reply other threads:[~2023-09-18 15:20 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-18 13:45 Jinhui Guo [this message]
2023-09-18 14:34 ` Rafael J. Wysocki
2023-09-18 15:17 ` Greg KH
2023-09-18 15:25 ` Jinhui Guo
2023-09-18 15:29 ` Jinhui Guo
2023-09-18 15:44 ` Jinhui Guo
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=20230918134527.252-1-guojinhui.liam@bytedance.com \
--to=guojinhui.liam@bytedance.com \
--cc=gregkh@linuxfoundation.org \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lizefan.x@bytedance.com \
--cc=lkp@intel.com \
--cc=rafael@kernel.org \
--cc=stable@vger.kernel.org \
/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®