@@ -779,6 +779,14 @@ int drm_dev_register(struct drm_device *dev, unsigned long flags)
if (drm_core_check_feature(dev, DRIVER_MODESET))
drm_modeset_register_all(dev);
+ if (drm_core_check_feature(dev, DRIVER_RENDER)) {
+ ret = sysfs_create_link(&dev->render->kdev->kobj,
+ &dev->primary->kdev->kobj,
+ "card");
+ if (ret)
+ goto err_minors;
+ }
+
ret = 0;
DRM_INFO("Initialized %s %d.%d.%d %s for %s on minor %d\n",
@@ -835,6 +843,9 @@ void drm_dev_unregister(struct drm_device *dev)
list_for_each_entry_safe(r_list, list_temp, &dev->maplist, head)
drm_legacy_rmmap(dev, r_list->map);
+ if (drm_core_check_feature(dev, DRIVER_RENDER))
+ sysfs_remove_link(&dev->render->kdev->kobj, "card");
+
remove_compat_control_link(dev);
drm_minor_unregister(dev, DRM_MINOR_PRIMARY);
drm_minor_unregister(dev, DRM_MINOR_RENDER);
In i915 we would like to expose information about the GPU topology which would be useful mostly to applications making use of the device computational capability (not so much the display part). At the moment we already store information like frequency, etc... into the card directory (/sys/class/drm/card0). It seems natural to add the additional data there too. Unfortunately it's not obvious how to go from the render node back to the sysfs card directory. From the major/minor number it's possible to figure out what device associated with the render node. For example with this render node : $ ls -l /dev/dri/renderD128 crw-rw----+ 1 root video 226, 128 Oct 24 16:17 /dev/dri/renderD128 You can rebuild a part to access the associated drm device in : $ ls -l /sys/dev/char/226\:128/device/drm/ total 0 drwxr-xr-x 9 root root 0 Nov 27 16:52 card0 lrwxrwxrwx 1 root root 0 Nov 27 16:52 controlD64 -> card0 drwxr-xr-x 3 root root 0 Nov 27 16:50 renderD128 Right now, most devices have usually only one card. But in order to be future proof, we would like to associate the render node with the card so that you can get access to the card with the following path : /sys/dev/char/226\:128/card/ Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Cc: dri-devel@lists.freedesktop.org --- drivers/gpu/drm/drm_drv.c | 11 +++++++++++ 1 file changed, 11 insertions(+)