Skip to content

Commit 4f59d71

Browse files
Zhen Leirobherring
authored andcommitted
of: to support binding numa node to specified device in devicetree
For now, in function device_add, the new device will be forced to inherit the numa node of its parent. But this will override the device's numa node which configured in devicetree. Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com> Signed-off-by: Rob Herring <robh@kernel.org>
1 parent 6ff33f3 commit 4f59d71

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

drivers/base/core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1066,7 +1066,7 @@ int device_add(struct device *dev)
10661066
dev->kobj.parent = kobj;
10671067

10681068
/* use parent numa_node */
1069-
if (parent)
1069+
if (parent && (dev_to_node(dev) == NUMA_NO_NODE))
10701070
set_dev_node(dev, dev_to_node(parent));
10711071

10721072
/* first, register with generic layer. */

drivers/of/device.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,12 @@ int of_device_add(struct platform_device *ofdev)
6060
ofdev->name = dev_name(&ofdev->dev);
6161
ofdev->id = -1;
6262

63-
/* device_add will assume that this device is on the same node as
64-
* the parent. If there is no parent defined, set the node
65-
* explicitly */
66-
if (!ofdev->dev.parent)
67-
set_dev_node(&ofdev->dev, of_node_to_nid(ofdev->dev.of_node));
63+
/*
64+
* If this device has not binding numa node in devicetree, that is
65+
* of_node_to_nid returns NUMA_NO_NODE. device_add will assume that this
66+
* device is on the same node as the parent.
67+
*/
68+
set_dev_node(&ofdev->dev, of_node_to_nid(ofdev->dev.of_node));
6869

6970
return device_add(&ofdev->dev);
7071
}

0 commit comments

Comments
 (0)