drm/nouveau/core: prepare printk for NULL engine pointer on device object tree
authorBen Skeggs <bskeggs@redhat.com>
Fri, 5 Dec 2014 01:03:18 +0000 (11:03 +1000)
committerBen Skeggs <bskeggs@redhat.com>
Thu, 22 Jan 2015 02:14:47 +0000 (12:14 +1000)
The [  SUBDEV] specified in log output will be a bit different for
children of a subdev now.  Previously this reports whatever subdev
is specified by object.engine, now it reports the subdev that owns
the object (so, up object.parent somewhere).

Later patches will append object and class identifiers to messages,
which will help clarify where it's coming from.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
drivers/gpu/drm/nouveau/core/core/printk.c

index d6c4d9072a36bbb9ae14f70e565edd2214f4af92..1060e3a173fe8ba304b79dc926212258fcef935b 100644 (file)
@@ -60,21 +60,26 @@ nv_printk_(struct nouveau_object *object, int level, const char *fmt, ...)
        }
 
        if (object && !nv_iclass(object, NV_CLIENT_CLASS)) {
-               struct nouveau_object *device = object;
-               struct nouveau_object *subdev = object;
+               struct nouveau_object *device;
+               struct nouveau_object *subdev;
                char obuf[64], *ofmt = "";
 
-               if (object->engine) {
+               subdev = object;
+               while (subdev && !nv_iclass(subdev, NV_SUBDEV_CLASS))
+                       subdev = subdev->parent;
+               if (!subdev)
+                       subdev = object->engine;
+
+               device = subdev;
+               if (device->parent)
+                       device = device->parent;
+
+               if (object != subdev) {
                        snprintf(obuf, sizeof(obuf), "[0x%08x]",
                                 nv_hclass(object));
                        ofmt = obuf;
-                       subdev = object->engine;
-                       device = object->engine;
                }
 
-               if (subdev->parent)
-                       device = subdev->parent;
-
                if (level > nv_subdev(subdev)->debug)
                        return;