ACPI / platform: Update platform device NUMA node based on _PXM method
authorShanker Donthineni <shankerd@codeaurora.org>
Wed, 29 Mar 2017 11:39:19 +0000 (06:39 -0500)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Tue, 18 Apr 2017 14:56:39 +0000 (16:56 +0200)
The optional _PXM method evaluates to an integer that identifies the
proximity domain of a device object. On ACPI based kernel boot, the
field numa_node in 'struct device' is always set to -1 irrespective
of _PXM value that is specified in the ACPI device object. But in
case of device-tree based kernel boot the numa_node field is populated
and reflects to a DT property that is specified in DTS according to
the below document.

https://www.kernel.org/doc/Documentation/devicetree/bindings/numa.txt
http://lxr.free-electrons.com/source/drivers/of/device.c#L54

Without this patch dev_to_node() always returns -1 for all platform
devices. This patch adds support for the ACPI _PXM method and updates
the platform device NUMA node id using acpi_get_node() which provides
the PXM-to-NUMA mapping information.

The individual platform device drivers should be able to use the
NUMA-aware memory allocation functions kmalloc_node() and
alloc_pages_node() to improve performance.

Signed-off-by: Shanker Donthineni <shankerd@codeaurora.org>
Reviewed-by: Hanjun Guo <hanjun.guo@linaro.org>
Tested-by: Jiandi An <anjiandi@codeaurora.org>
[ rjw: Subject / changelog ]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/acpi/acpi_platform.c

index 03250e1..88cd949 100644 (file)
@@ -121,11 +121,14 @@ 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
+       else {
+               set_dev_node(&pdev->dev, acpi_get_node(adev->handle));
                dev_dbg(&adev->dev, "created platform device %s\n",
                        dev_name(&pdev->dev));
+       }
 
        kfree(resources);
+
        return pdev;
 }
 EXPORT_SYMBOL_GPL(acpi_create_platform_device);