drivers/acpi/acpi_platform.c | 4 +--- drivers/base/platform.c | 4 ++++ 2 files changed, 5 insertions(+), 3 deletions(-)
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
Hi guojinhui.liam,
kernel test robot noticed the following build errors:
[auto build test ERROR on linus/master]
[also build test ERROR on v6.6-rc1 next-20230913]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/guojinhui-liam/driver-core-platform-set-numa_node-before-platform_add_device/20230912-151119
base: linus/master
patch link: https://lore.kernel.org/r/20230912070900.1862-1-guojinhui.liam%40bytedance.com
patch subject: [PATCH] driver core: platform: set numa_node before platform_add_device()
config: um-allyesconfig (https://download.01.org/0day-ci/archive/20230913/202309131848.CgiiHpZu-lkp@intel.com/config)
compiler: clang version 14.0.6 (https://github.com/llvm/llvm-project.git f28c006a5895fc0e329fe15fead81e37457cb1d1)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20230913/202309131848.CgiiHpZu-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202309131848.CgiiHpZu-lkp@intel.com/
All errors (new ones prefixed by >>):
In file included from drivers/base/platform.c:15:
In file included from include/linux/of_irq.h:7:
In file included from include/linux/irq.h:20:
In file included from include/linux/io.h:13:
In file included from arch/um/include/asm/io.h:24:
include/asm-generic/io.h:547:31: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
val = __raw_readb(PCI_IOBASE + addr);
~~~~~~~~~~ ^
include/asm-generic/io.h:560:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
val = __le16_to_cpu((__le16 __force)__raw_readw(PCI_IOBASE + addr));
~~~~~~~~~~ ^
include/uapi/linux/byteorder/little_endian.h:37:51: note: expanded from macro '__le16_to_cpu'
#define __le16_to_cpu(x) ((__force __u16)(__le16)(x))
^
In file included from drivers/base/platform.c:15:
In file included from include/linux/of_irq.h:7:
In file included from include/linux/irq.h:20:
In file included from include/linux/io.h:13:
In file included from arch/um/include/asm/io.h:24:
include/asm-generic/io.h:573:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
val = __le32_to_cpu((__le32 __force)__raw_readl(PCI_IOBASE + addr));
~~~~~~~~~~ ^
include/uapi/linux/byteorder/little_endian.h:35:51: note: expanded from macro '__le32_to_cpu'
#define __le32_to_cpu(x) ((__force __u32)(__le32)(x))
^
In file included from drivers/base/platform.c:15:
In file included from include/linux/of_irq.h:7:
In file included from include/linux/irq.h:20:
In file included from include/linux/io.h:13:
In file included from arch/um/include/asm/io.h:24:
include/asm-generic/io.h:584:33: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
__raw_writeb(value, PCI_IOBASE + addr);
~~~~~~~~~~ ^
include/asm-generic/io.h:594:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
__raw_writew((u16 __force)cpu_to_le16(value), PCI_IOBASE + addr);
~~~~~~~~~~ ^
include/asm-generic/io.h:604:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
__raw_writel((u32 __force)cpu_to_le32(value), PCI_IOBASE + addr);
~~~~~~~~~~ ^
include/asm-generic/io.h:692:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
readsb(PCI_IOBASE + addr, buffer, count);
~~~~~~~~~~ ^
include/asm-generic/io.h:700:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
readsw(PCI_IOBASE + addr, buffer, count);
~~~~~~~~~~ ^
include/asm-generic/io.h:708:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
readsl(PCI_IOBASE + addr, buffer, count);
~~~~~~~~~~ ^
include/asm-generic/io.h:717:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
writesb(PCI_IOBASE + addr, buffer, count);
~~~~~~~~~~ ^
include/asm-generic/io.h:726:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
writesw(PCI_IOBASE + addr, buffer, count);
~~~~~~~~~~ ^
include/asm-generic/io.h:735:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
writesl(PCI_IOBASE + addr, buffer, count);
~~~~~~~~~~ ^
>> drivers/base/platform.c:846:28: error: implicit declaration of function 'acpi_get_node' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
set_dev_node(&pdev->dev, acpi_get_node(adev->handle));
^
drivers/base/platform.c:846:28: note: did you mean 'acpi_get_name'?
include/acpi/acpixf.h:525:9: note: 'acpi_get_name' declared here
acpi_get_name(acpi_handle object, u32 name_type,
^
include/acpi/platform/aclinux.h:93:21: note: expanded from macro 'ACPI_EXTERNAL_RETURN_STATUS'
static ACPI_INLINE prototype {return(AE_NOT_CONFIGURED);}
^
drivers/base/platform.c:846:46: error: incomplete definition of type 'struct acpi_device'
set_dev_node(&pdev->dev, acpi_get_node(adev->handle));
~~~~^
include/linux/acpi.h:788:8: note: forward declaration of 'struct acpi_device'
struct acpi_device;
^
12 warnings and 2 errors generated.
vim +/acpi_get_node +846 drivers/base/platform.c
797
798 /**
799 * platform_device_register_full - add a platform-level device with
800 * resources and platform-specific data
801 *
802 * @pdevinfo: data used to create device
803 *
804 * Returns &struct platform_device pointer on success, or ERR_PTR() on error.
805 */
806 struct platform_device *platform_device_register_full(
807 const struct platform_device_info *pdevinfo)
808 {
809 int ret;
810 struct platform_device *pdev;
811 struct acpi_device *adev = to_acpi_device_node(pdevinfo->fwnode);
812
813 pdev = platform_device_alloc(pdevinfo->name, pdevinfo->id);
814 if (!pdev)
815 return ERR_PTR(-ENOMEM);
816
817 pdev->dev.parent = pdevinfo->parent;
818 pdev->dev.fwnode = pdevinfo->fwnode;
819 pdev->dev.of_node = of_node_get(to_of_node(pdev->dev.fwnode));
820 pdev->dev.of_node_reused = pdevinfo->of_node_reused;
821
822 if (pdevinfo->dma_mask) {
823 pdev->platform_dma_mask = pdevinfo->dma_mask;
824 pdev->dev.dma_mask = &pdev->platform_dma_mask;
825 pdev->dev.coherent_dma_mask = pdevinfo->dma_mask;
826 }
827
828 ret = platform_device_add_resources(pdev,
829 pdevinfo->res, pdevinfo->num_res);
830 if (ret)
831 goto err;
832
833 ret = platform_device_add_data(pdev,
834 pdevinfo->data, pdevinfo->size_data);
835 if (ret)
836 goto err;
837
838 if (pdevinfo->properties) {
839 ret = device_create_managed_software_node(&pdev->dev,
840 pdevinfo->properties, NULL);
841 if (ret)
842 goto err;
843 }
844
845 if (adev)
> 846 set_dev_node(&pdev->dev, acpi_get_node(adev->handle));
847
848 ret = platform_device_add(pdev);
849 if (ret) {
850 err:
851 ACPI_COMPANION_SET(&pdev->dev, NULL);
852 platform_device_put(pdev);
853 return ERR_PTR(ret);
854 }
855
856 return pdev;
857 }
858 EXPORT_SYMBOL_GPL(platform_device_register_full);
859
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
> Hi guojinhui.liam, > > kernel test robot noticed the following build errors: > > [auto build test ERROR on linus/master] > [also build test ERROR on v6.6-rc1 next-20230913] > [If your patch is applied to the wrong git tree, kindly drop us a note. > And when submitting patch, we suggest to use '--base' as documented in > https://git-scm.com/docs/git-format-patch#_base_tree_information] > > url: https://github.com/intel-lab-lkp/linux/commits/guojinhui-liam/driver-core-platform-set-numa_node-before-platform_add_device/20230912-151119 > base: linus/master > patch link: https://lore.kernel.org/r/20230912070900.1862-1-guojinhui.liam%40bytedance.com > patch subject: [PATCH] driver core: platform: set numa_node before platform_add_device() > config: um-allyesconfig (https://download.01.org/0day-ci/archive/20230913/202309131848.CgiiHpZu-lkp@intel.com/config) > compiler: clang version 14.0.6 (https://github.com/llvm/llvm-project.git f28c006a5895fc0e329fe15fead81e37457cb1d1) > reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20230913/202309131848.CgiiHpZu-lkp@intel.com/reproduce) > > If you fix the issue in a separate patch/commit (i.e. not just a new version of > the same patch/commit), kindly add following tags > | Reported-by: kernel test robot <lkp@intel.com> > | Closes: https://lore.kernel.org/oe-kbuild-all/202309131848.CgiiHpZu-lkp@intel.com/ > ... Is there anyone known how to stop this test for my first patch? I have sent a new one to review, which fixes the compile bug. thanks, Jinhui Guo
On Wed, Sep 13, 2023 at 4:46 AM Jinhui Guo <guojinhui.liam@bytedance.com> wrote: > > > Hi guojinhui.liam, > > > > kernel test robot noticed the following build errors: > > > > [auto build test ERROR on linus/master] > > [also build test ERROR on v6.6-rc1 next-20230913] > > [If your patch is applied to the wrong git tree, kindly drop us a note. > > And when submitting patch, we suggest to use '--base' as documented in > > https://git-scm.com/docs/git-format-patch#_base_tree_information] > > > > url: https://github.com/intel-lab-lkp/linux/commits/guojinhui-liam/driver-core-platform-set-numa_node-before-platform_add_device/20230912-151119 > > base: linus/master > > patch link: https://lore.kernel.org/r/20230912070900.1862-1-guojinhui.liam%40bytedance.com > > patch subject: [PATCH] driver core: platform: set numa_node before platform_add_device() > > config: um-allyesconfig (https://download.01.org/0day-ci/archive/20230913/202309131848.CgiiHpZu-lkp@intel.com/config) > > compiler: clang version 14.0.6 (https://github.com/llvm/llvm-project.git f28c006a5895fc0e329fe15fead81e37457cb1d1) > > reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20230913/202309131848.CgiiHpZu-lkp@intel.com/reproduce) > > > > If you fix the issue in a separate patch/commit (i.e. not just a new version of > > the same patch/commit), kindly add following tags > > | Reported-by: kernel test robot <lkp@intel.com> > > | Closes: https://lore.kernel.org/oe-kbuild-all/202309131848.CgiiHpZu-lkp@intel.com/ > > ... > > Is there anyone known how to stop this test for my first patch? I have sent a new one to review, which fixes the compile bug. Then it's ok to either ignore the report, or do as you did and say "I sent a V+1." Doesn't hurt to have a link to the next revision on lore if you are to reply. kbuild test robot will test each patch sent to LKML; it might not stop ongoing tests if a V+1 is sent. > > thanks, > > Jinhui Guo > -- Thanks, ~Nick Desaulniers
Hi guojinhui.liam,
kernel test robot noticed the following build errors:
[auto build test ERROR on linus/master]
[also build test ERROR on v6.6-rc1 next-20230912]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/guojinhui-liam/driver-core-platform-set-numa_node-before-platform_add_device/20230912-151119
base: linus/master
patch link: https://lore.kernel.org/r/20230912070900.1862-1-guojinhui.liam%40bytedance.com
patch subject: [PATCH] driver core: platform: set numa_node before platform_add_device()
config: powerpc-allnoconfig (https://download.01.org/0day-ci/archive/20230912/202309122309.mbxAnAIe-lkp@intel.com/config)
compiler: powerpc-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20230912/202309122309.mbxAnAIe-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202309122309.mbxAnAIe-lkp@intel.com/
All errors (new ones prefixed by >>):
drivers/base/platform.c: In function 'platform_device_register_full':
>> drivers/base/platform.c:846:42: error: implicit declaration of function 'acpi_get_node'; did you mean 'acpi_get_name'? [-Werror=implicit-function-declaration]
846 | set_dev_node(&pdev->dev, acpi_get_node(adev->handle));
| ^~~~~~~~~~~~~
| acpi_get_name
>> drivers/base/platform.c:846:60: error: invalid use of undefined type 'struct acpi_device'
846 | set_dev_node(&pdev->dev, acpi_get_node(adev->handle));
| ^~
cc1: some warnings being treated as errors
vim +846 drivers/base/platform.c
797
798 /**
799 * platform_device_register_full - add a platform-level device with
800 * resources and platform-specific data
801 *
802 * @pdevinfo: data used to create device
803 *
804 * Returns &struct platform_device pointer on success, or ERR_PTR() on error.
805 */
806 struct platform_device *platform_device_register_full(
807 const struct platform_device_info *pdevinfo)
808 {
809 int ret;
810 struct platform_device *pdev;
811 struct acpi_device *adev = to_acpi_device_node(pdevinfo->fwnode);
812
813 pdev = platform_device_alloc(pdevinfo->name, pdevinfo->id);
814 if (!pdev)
815 return ERR_PTR(-ENOMEM);
816
817 pdev->dev.parent = pdevinfo->parent;
818 pdev->dev.fwnode = pdevinfo->fwnode;
819 pdev->dev.of_node = of_node_get(to_of_node(pdev->dev.fwnode));
820 pdev->dev.of_node_reused = pdevinfo->of_node_reused;
821
822 if (pdevinfo->dma_mask) {
823 pdev->platform_dma_mask = pdevinfo->dma_mask;
824 pdev->dev.dma_mask = &pdev->platform_dma_mask;
825 pdev->dev.coherent_dma_mask = pdevinfo->dma_mask;
826 }
827
828 ret = platform_device_add_resources(pdev,
829 pdevinfo->res, pdevinfo->num_res);
830 if (ret)
831 goto err;
832
833 ret = platform_device_add_data(pdev,
834 pdevinfo->data, pdevinfo->size_data);
835 if (ret)
836 goto err;
837
838 if (pdevinfo->properties) {
839 ret = device_create_managed_software_node(&pdev->dev,
840 pdevinfo->properties, NULL);
841 if (ret)
842 goto err;
843 }
844
845 if (adev)
> 846 set_dev_node(&pdev->dev, acpi_get_node(adev->handle));
847
848 ret = platform_device_add(pdev);
849 if (ret) {
850 err:
851 ACPI_COMPANION_SET(&pdev->dev, NULL);
852 platform_device_put(pdev);
853 return ERR_PTR(ret);
854 }
855
856 return pdev;
857 }
858 EXPORT_SYMBOL_GPL(platform_device_register_full);
859
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
On Tue, Sep 12, 2023 at 03:09:00PM +0800, guojinhui.liam wrote:
> 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.
Why? What will this allow to happen differently? What is broken with
the current code?
> Fixes: 4a60406d3592 ("driver core: platform: expose numa_node to users in sysfs")
> Signed-off-by: guojinhui.liam <guojinhui.liam@bytedance.com>
Please use your name here, and not your email alias, as the first part
of the signed-off-by line.
And also, please fix up your email client to have the correct name as
well.
> ---
> 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));
Are you sure that this platform code can always call acpi functions?
thanks,
greg k-h
> On Tue, Sep 12, 2023 at 03:09:00PM +0800, guojinhui.liam wrote:
> > 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.
>
> Why? What will this allow to happen differently? What is broken with
> the current code?
Commit 4a60406d3592 can run well with dtb, because of_device_add() set the numa_node before device_add().
I think it didn't test acpi before submitting.
> > Fixes: 4a60406d3592 ("driver core: platform: expose numa_node to users in sysfs")
> > Signed-off-by: guojinhui.liam <guojinhui.liam@bytedance.com>
>
> Please use your name here, and not your email alias, as the first part
> of the signed-off-by line.
>
> And also, please fix up your email client to have the correct name as
> well.
I will fix them with a new patch v2.
> > ---
> > 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));
>
> Are you sure that this platform code can always call acpi functions?
Thanks for your review, there are something wrong without enabling CONFIG_ACPI.
I will fix it with patch v2 soon.
thanks,
guojinhui
© 2016 - 2025 Red Hat, Inc.