<div dir="ltr">+ dri-devel<br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Sep 3, 2019 at 5:41 PM Jiang, Sonny <<a href="mailto:Sonny.Jiang@amd.com">Sonny.Jiang@amd.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Add DRM device name and use DRM_IOCTL_VERSION ioctl drmVersion::desc passing it to user space<br>
instead of unused DRM driver name descriptor.<br>
<br>
Change-Id: I809f6d3e057111417efbe8fa7cab8f0113ba4b21<br>
Signed-off-by: Sonny Jiang <<a href="mailto:sonny.jiang@amd.com" target="_blank">sonny.jiang@amd.com</a>><br>
---<br>
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c |  2 ++<br>
 drivers/gpu/drm/drm_drv.c                  | 17 +++++++++++++++++<br>
 drivers/gpu/drm/drm_ioctl.c                |  2 +-<br>
 include/drm/drm_device.h                   |  3 +++<br>
 include/drm/drm_drv.h                      |  1 +<br>
 5 files changed, 24 insertions(+), 1 deletion(-)<br>
<br>
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c<br>
index 67b09cb2a9e2..8f0971cea363 100644<br>
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c<br>
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c<br>
@@ -2809,6 +2809,8 @@ int amdgpu_device_init(struct amdgpu_device *adev,<br>
        /* init the mode config */<br>
        drm_mode_config_init(adev->ddev);<br>
<br>
+       drm_dev_set_name(adev->ddev, amdgpu_asic_name[adev->asic_type]);<br>
+<br>
        r = amdgpu_device_ip_init(adev);<br>
        if (r) {<br>
                /* failed in exclusive mode due to timeout */<br>
diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c<br>
index 862621494a93..6c33879bb538 100644<br>
--- a/drivers/gpu/drm/drm_drv.c<br>
+++ b/drivers/gpu/drm/drm_drv.c<br>
@@ -802,6 +802,7 @@ void drm_dev_fini(struct drm_device *dev)<br>
        mutex_destroy(&dev->struct_mutex);<br>
        drm_legacy_destroy_members(dev);<br>
        kfree(dev->unique);<br>
+       kfree(dev->name);<br>
 }<br>
 EXPORT_SYMBOL(drm_dev_fini);<br>
<br>
@@ -1078,6 +1079,22 @@ int drm_dev_set_unique(struct drm_device *dev, const char *name)<br>
 }<br>
 EXPORT_SYMBOL(drm_dev_set_unique);<br>
<br>
+/**<br>
+ * drm_dev_set_name - Set the name of a DRM device<br>
+ * @dev: device of which to set the name<br>
+ * @name: name to be set<br>
+ *<br>
+ * Return: 0 on success or a negative error code on failure.<br>
+ */<br>
+int drm_dev_set_name(struct drm_device *dev, const char *name)<br>
+{<br>
+       kfree(dev->name);<br>
+       dev->name = kstrdup(name, GFP_KERNEL);<br>
+<br>
+       return dev->name ? 0 : -ENOMEM;<br>
+}<br>
+EXPORT_SYMBOL(drm_dev_set_name);<br>
+<br>
 /*<br>
  * DRM Core<br>
  * The DRM core module initializes all global DRM objects and makes them<br>
diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c<br>
index 2263e3ddd822..61f02965106b 100644<br>
--- a/drivers/gpu/drm/drm_ioctl.c<br>
+++ b/drivers/gpu/drm/drm_ioctl.c<br>
@@ -506,7 +506,7 @@ int drm_version(struct drm_device *dev, void *data,<br>
                                dev->driver->date);<br>
        if (!err)<br>
                err = drm_copy_field(version->desc, &version->desc_len,<br>
-                               dev->driver->desc);<br>
+                               dev->name);<br>
<br>
        return err;<br>
 }<br>
diff --git a/include/drm/drm_device.h b/include/drm/drm_device.h<br>
index 7f9ef709b2b6..e29912c484e4 100644<br>
--- a/include/drm/drm_device.h<br>
+++ b/include/drm/drm_device.h<br>
@@ -123,6 +123,9 @@ struct drm_device {<br>
        /** @unique: Unique name of the device */<br>
        char *unique;<br>
<br>
+       /** @name: device name */<br>
+       char *name;<br>
+<br>
        /**<br>
         * @struct_mutex:<br>
         *<br>
diff --git a/include/drm/drm_drv.h b/include/drm/drm_drv.h<br>
index 68ca736c548d..f742e2bde467 100644<br>
--- a/include/drm/drm_drv.h<br>
+++ b/include/drm/drm_drv.h<br>
@@ -798,6 +798,7 @@ static inline bool drm_drv_uses_atomic_modeset(struct drm_device *dev)<br>
<br>
<br>
 int drm_dev_set_unique(struct drm_device *dev, const char *name);<br>
+int drm_dev_set_name(struct drm_device *dev, const char *name);<br>
<br>
<br>
 #endif<br>
-- <br>
2.17.1<br>
<br>
_______________________________________________<br>
amd-gfx mailing list<br>
<a href="mailto:amd-gfx@lists.freedesktop.org" target="_blank">amd-gfx@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/amd-gfx" rel="noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/amd-gfx</a></blockquote></div>