Skip to content

Commit 6098e2e

Browse files
jk-ozlabspaulusmack
authored andcommitted
OF-device: Don't overwrite numa_node in device registration
Currently, the numa_node of OF-devices will be overwritten during device_register, which simply sets the node to -1. On cell machines, this means that devices can't find their IOMMU, which is referenced through the device's numa node. Set the numa node for OF devices with no parent, and use the lower-level device_initialize and device_add functions, so that the node is preserved. We can remove the call to set_dev_node in of_device_alloc, as it will be overwritten during register. Signed-off-by: Jeremy Kerr <jk@ozlabs.org> Signed-off-by: Paul Mackerras <paulus@samba.org>
1 parent 16c29d1 commit 6098e2e

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

‎arch/powerpc/kernel/of_device.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ struct of_device *of_device_alloc(struct device_node *np,
7878
dev->dev.parent = parent;
7979
dev->dev.release = of_release_dev;
8080
dev->dev.archdata.of_node = np;
81-
set_dev_node(&dev->dev, of_node_to_nid(np));
8281

8382
if (bus_id)
8483
strlcpy(dev->dev.bus_id, bus_id, BUS_ID_SIZE);

‎drivers/of/device.c‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,16 @@ EXPORT_SYMBOL(of_release_dev);
105105
int of_device_register(struct of_device *ofdev)
106106
{
107107
BUG_ON(ofdev->node == NULL);
108-
return device_register(&ofdev->dev);
108+
109+
device_initialize(&ofdev->dev);
110+
111+
/* device_add will assume that this device is on the same node as
112+
* the parent. If there is no parent defined, set the node
113+
* explicitly */
114+
if (!ofdev->dev.parent)
115+
set_dev_node(&ofdev->dev, of_node_to_nid(ofdev->node));
116+
117+
return device_add(&ofdev->dev);
109118
}
110119
EXPORT_SYMBOL(of_device_register);
111120

0 commit comments

Comments
 (0)