[PATCH v5 09/11] drm: nova: Report GPU name in GPU info

Alistair Popple <[email protected]>
Newsgroups dev.linux.lists.nova-gpu,org.freedesktop.lists.dri-devel,org.kernel.vger.linux-kernel,org.kernel.vger.rust-for-linux
Message-ID <[email protected]>
Add the full GPU name to the GPU info structure.

Signed-off-by: Alistair Popple <[email protected]>

---

Changes since v4:

 - New for v5
---
 drivers/gpu/drm/nova/file.rs          | 1 +
 drivers/gpu/nova-core/api.rs          | 5 +++++
 drivers/gpu/nova-core/gsp/commands.rs | 5 +++++
 include/uapi/drm/nova_drm.h           | 5 +++++
 4 files changed, 16 insertions(+)

diff --git a/drivers/gpu/drm/nova/file.rs b/drivers/gpu/drm/nova/file.rs
index 6fc169c66d02..ab04a10d3353 100644
--- a/drivers/gpu/drm/nova/file.rs
+++ b/drivers/gpu/drm/nova/file.rs
@@ -36,6 +36,7 @@ fn new(reg_data: &DrmRegData<'_>) -> Self {
             architecture: reg_data.api.architecture(),
             implementation: reg_data.api.implementation(),
             vram_size: reg_data.api.vram_size(),
+            gpu_name: reg_data.api.gpu_name(),
         })
     }
 }
diff --git a/drivers/gpu/nova-core/api.rs b/drivers/gpu/nova-core/api.rs
index f4fd78f9c321..e6789f1485d1 100644
--- a/drivers/gpu/nova-core/api.rs
+++ b/drivers/gpu/nova-core/api.rs
@@ -24,6 +24,11 @@ pub struct NovaCoreApi<'bound> {
 }
 
 impl NovaCoreApi<'_> {
+    /// Returns the NUL-terminated full GPU name supplied by GSP-RM.
+    pub fn gpu_name(&self) -> [u8; 64] {
+        *self.gpu.gsp_static_info.gpu_name_bytes()
+    }
+
     /// Obtain a [`NovaCoreApi`] handle from an auxiliary device registered
     /// by nova-core.
     pub fn of(adev: &auxiliary::Device<Bound>) -> Result<Pin<&NovaCoreApi<'_>>> {
diff --git a/drivers/gpu/nova-core/gsp/commands.rs b/drivers/gpu/nova-core/gsp/commands.rs
index 6453184af55b..b8dc64808620 100644
--- a/drivers/gpu/nova-core/gsp/commands.rs
+++ b/drivers/gpu/nova-core/gsp/commands.rs
@@ -251,6 +251,11 @@ pub(crate) enum GpuNameError {
 }
 
 impl GetGspStaticInfoReply {
+    /// Returns the full GPU name as a NUL-terminated byte string.
+    pub(crate) fn gpu_name_bytes(&self) -> &[u8; 64] {
+        &self.gpu_name
+    }
+
     /// Returns the name of the GPU as a string.
     ///
     /// Returns an error if the string given by the GSP does not contain a null terminator or
diff --git a/include/uapi/drm/nova_drm.h b/include/uapi/drm/nova_drm.h
index b80bb50acaa1..7e11d1bfeb6b 100644
--- a/include/uapi/drm/nova_drm.h
+++ b/include/uapi/drm/nova_drm.h
@@ -142,6 +142,11 @@ struct drm_nova_gpu_info {
 	 * regions.
 	 */
 	__u64 vram_size;
+
+	/**
+	 * @gpu_name: NUL-terminated full GPU name.
+	 */
+	__u8 gpu_name[64];
 };
 
 #define DRM_NOVA_GETPARAM		0x00
-- 
2.54.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.