[PATCH] gpu: host1x: Support sub-devices recursively

Thierry Reding thierry.reding at gmail.com
Tue Aug 15 13:46:22 UTC 2017


From: Thierry Reding <treding at nvidia.com>

The display architecture in Tegra186 changes slightly compared to
earlier Tegra generations, which requires that we recursively scan
host1x sub-devices from device tree.

Signed-off-by: Thierry Reding <treding at nvidia.com>
---
 drivers/gpu/host1x/bus.c | 26 +++++++++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/host1x/bus.c b/drivers/gpu/host1x/bus.c
index 7ece0e9058c6..998139c964f4 100644
--- a/drivers/gpu/host1x/bus.c
+++ b/drivers/gpu/host1x/bus.c
@@ -44,9 +44,14 @@ struct host1x_subdev {
  * @np: device node
  */
 static int host1x_subdev_add(struct host1x_device *device,
+			     struct host1x_driver *driver,
 			     struct device_node *np)
 {
 	struct host1x_subdev *subdev;
+	struct device_node *child;
+	int err;
+
+	dev_info(&device->dev, "adding subdevice %s\n", np->full_name);
 
 	subdev = kzalloc(sizeof(*subdev), GFP_KERNEL);
 	if (!subdev)
@@ -59,6 +64,19 @@ static int host1x_subdev_add(struct host1x_device *device,
 	list_add_tail(&subdev->list, &device->subdevs);
 	mutex_unlock(&device->subdevs_lock);
 
+	/* recursively add children */
+	for_each_child_of_node(np, child) {
+		if (of_match_node(driver->subdevs, child) &&
+		    of_device_is_available(child)) {
+			err = host1x_subdev_add(device, driver, child);
+			if (err < 0) {
+				/* XXX cleanup? */
+				of_node_put(child);
+				return err;
+			}
+		}
+	}
+
 	return 0;
 }
 
@@ -87,7 +105,7 @@ static int host1x_device_parse_dt(struct host1x_device *device,
 	for_each_child_of_node(device->dev.parent->of_node, np) {
 		if (of_match_node(driver->subdevs, np) &&
 		    of_device_is_available(np)) {
-			err = host1x_subdev_add(device, np);
+			err = host1x_subdev_add(device, driver, np);
 			if (err < 0) {
 				of_node_put(np);
 				return err;
@@ -104,6 +122,8 @@ static void host1x_subdev_register(struct host1x_device *device,
 {
 	int err;
 
+	dev_info(&device->dev, "registering subdevice %s\n", subdev->np->full_name);
+
 	/*
 	 * Move the subdevice to the list of active (registered) subdevices
 	 * and associate it with a client. At the same time, associate the
@@ -124,6 +144,10 @@ static void host1x_subdev_register(struct host1x_device *device,
 			dev_err(&device->dev, "failed to add: %d\n", err);
 		else
 			device->registered = true;
+	} else {
+		dev_info(&device->dev, "remaining subdevices:\n");
+		list_for_each_entry(subdev, &device->subdevs, list)
+			dev_info(&device->dev, "  %s\n", subdev->np->full_name);
 	}
 }
 
-- 
2.13.3



More information about the dri-devel mailing list