OF-device: Don't overwrite numa_node in device registration
authorJeremy Kerr <jk@ozlabs.org>
Sun, 26 Oct 2008 21:51:25 +0000 (21:51 +0000)
committerPaul Mackerras <paulus@samba.org>
Fri, 31 Oct 2008 05:12:01 +0000 (16:12 +1100)
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>
arch/powerpc/kernel/of_device.c
drivers/of/device.c

index 93ae5b169f418b59e9fd7dadc1f5b89890a9d6fc..f3c9cae01dd5d76389b1c2ce8779c14cb8e6f086 100644 (file)
@@ -78,7 +78,6 @@ struct of_device *of_device_alloc(struct device_node *np,
        dev->dev.parent = parent;
        dev->dev.release = of_release_dev;
        dev->dev.archdata.of_node = np;
-       set_dev_node(&dev->dev, of_node_to_nid(np));
 
        if (bus_id)
                strlcpy(dev->dev.bus_id, bus_id, BUS_ID_SIZE);
index 51e5214071da9f32b370c48622d70f9a62f55e5b..224ae6bc67b6bb7b5b893192b7170cc6be8ef29c 100644 (file)
@@ -105,7 +105,16 @@ EXPORT_SYMBOL(of_release_dev);
 int of_device_register(struct of_device *ofdev)
 {
        BUG_ON(ofdev->node == NULL);
-       return device_register(&ofdev->dev);
+
+       device_initialize(&ofdev->dev);
+
+       /* device_add will assume that this device is on the same node as
+        * the parent. If there is no parent defined, set the node
+        * explicitly */
+       if (!ofdev->dev.parent)
+               set_dev_node(&ofdev->dev, of_node_to_nid(ofdev->node));
+
+       return device_add(&ofdev->dev);
 }
 EXPORT_SYMBOL(of_device_register);