public inbox for linux-acpi@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] driver core: platform: set numa_node before platform_add_device()
@ 2023-09-12  7:09 guojinhui.liam
  2023-09-12  8:11 ` Greg KH
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: guojinhui.liam @ 2023-09-12  7:09 UTC (permalink / raw)
  To: rafael, lenb, gregkh; +Cc: lizefan.x, linux-acpi, linux-kernel, guojinhui.liam

platform_add_device creates numa_node attribute of sysfs according to
whether dev_to_node(dev) is equal to NUMA_NO_NODE. So set the numa node
of the device before creating numa_node attribute of sysfs.

Fixes: 4a60406d3592 ("driver core: platform: expose numa_node to users in sysfs")
Signed-off-by: guojinhui.liam <guojinhui.liam@bytedance.com>
---
 drivers/acpi/acpi_platform.c | 4 +---
 drivers/base/platform.c      | 4 ++++
 2 files changed, 5 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..355abf91930a 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -808,6 +808,7 @@ struct platform_device *platform_device_register_full(
 {
 	int ret;
 	struct platform_device *pdev;
+	struct acpi_device *adev = to_acpi_device_node(pdevinfo->fwnode);
 
 	pdev = platform_device_alloc(pdevinfo->name, pdevinfo->id);
 	if (!pdev)
@@ -841,6 +842,9 @@ struct platform_device *platform_device_register_full(
 			goto err;
 	}
 
+	if (adev)
+		set_dev_node(&pdev->dev, acpi_get_node(adev->handle));
+
 	ret = platform_device_add(pdev);
 	if (ret) {
 err:
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread
* Re: [PATCH v5] driver core: platform: set numa_node before platform_add_device()
@ 2023-09-18 10:30 Rafael J. Wysocki
  2023-09-18 12:41 ` [PATCH] " Jinhui Guo
  0 siblings, 1 reply; 9+ messages in thread
From: Rafael J. Wysocki @ 2023-09-18 10:30 UTC (permalink / raw)
  To: Jinhui Guo
  Cc: rafael, lenb, gregkh, lizefan.x, linux-acpi, linux-kernel, stable,
	kernel test robot

On Thu, Sep 14, 2023 at 11:32 PM Jinhui Guo
<guojinhui.liam@bytedance.com> wrote:
>
> platform_add_device()

According to "git grep" this function is not present in 6.6-rc2.

If you mean platform_device_add(), please update the patch subject and
changelog accordingly.

> creates the numa_node attribute of sysfs according
> to whether dev_to_node(dev) is equal to NUMA_NO_NODE. So set the numa node
> of device before creating numa_node attribute of sysfs.

It would be good to also say that this needs to be done in
platform_device_register_full(), because that's where the platform
device object is allocated.

However, what about adding the NUMA node information to pdevinfo?  It
would be more straightforward to handle it then AFAICS.

> 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/
> Signed-off-by: Jinhui Guo <guojinhui.liam@bytedance.com>
> ---
> 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
>

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2023-09-18 15:39 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-12  7:09 [PATCH] driver core: platform: set numa_node before platform_add_device() guojinhui.liam
2023-09-12  8:11 ` Greg KH
2023-09-13  3:02   ` guojinhui
2023-09-12 16:11 ` kernel test robot
2023-09-13 10:52 ` kernel test robot
2023-09-13 11:46   ` Jinhui Guo
2023-09-13 15:14     ` Nick Desaulniers
  -- strict thread matches above, loose matches on Subject: below --
2023-09-18 10:30 [PATCH v5] " Rafael J. Wysocki
2023-09-18 12:41 ` [PATCH] " Jinhui Guo
2023-09-18 15:09   ` Rafael J. Wysocki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox