Add the short 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    | 7 +++++++
 drivers/gpu/nova-core/gsp/fw/commands.rs | 5 +++++
 include/uapi/drm/nova_drm.h              | 5 +++++
 5 files changed, 23 insertions(+)

diff --git a/drivers/gpu/drm/nova/file.rs b/drivers/gpu/drm/nova/file.rs
index ab04a10d3353..64d9f68c7cf0 100644
--- a/drivers/gpu/drm/nova/file.rs
+++ b/drivers/gpu/drm/nova/file.rs
@@ -37,6 +37,7 @@ fn new(reg_data: &DrmRegData<'_>) -> Self {
             implementation: reg_data.api.implementation(),
             vram_size: reg_data.api.vram_size(),
             gpu_name: reg_data.api.gpu_name(),
+            gpu_short_name: reg_data.api.gpu_short_name(),
         })
     }
 }
diff --git a/drivers/gpu/nova-core/api.rs b/drivers/gpu/nova-core/api.rs
index e6789f1485d1..c18fa1766892 100644
--- a/drivers/gpu/nova-core/api.rs
+++ b/drivers/gpu/nova-core/api.rs
@@ -29,6 +29,11 @@ impl NovaCoreApi<'_> {
         *self.gpu.gsp_static_info.gpu_name_bytes()
     }
 
+    /// Returns the NUL-terminated short GPU name supplied by GSP-RM.
+    pub fn gpu_short_name(&self) -> [u8; 64] {
+        *self.gpu.gsp_static_info.gpu_short_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 b8dc64808620..b9f19be9b29c 100644
--- a/drivers/gpu/nova-core/gsp/commands.rs
+++ b/drivers/gpu/nova-core/gsp/commands.rs
@@ -214,6 +214,7 @@ fn init(&self) -> impl Init<Self::Command, Self::InitError> 
{
 /// The reply from the GSP to the [`GetGspStaticInfo`] command.
 pub(crate) struct GetGspStaticInfoReply {
     gpu_name: [u8; 64],
+    gpu_short_name: [u8; 64],
     /// Usable FB (VRAM) regions for driver memory allocation.
     pub(crate) usable_fb_regions: KVec<Range<u64>>,
 }
@@ -234,6 +235,7 @@ fn read(
 
         Ok(GetGspStaticInfoReply {
             gpu_name: msg.gpu_name_str(),
+            gpu_short_name: msg.gpu_short_name_str(),
             usable_fb_regions,
         })
     }
@@ -256,6 +258,11 @@ impl GetGspStaticInfoReply {
         &self.gpu_name
     }
 
+    /// Returns the short GPU name as a NUL-terminated byte string.
+    pub(crate) fn gpu_short_name_bytes(&self) -> &[u8; 64] {
+        &self.gpu_short_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/drivers/gpu/nova-core/gsp/fw/commands.rs 
b/drivers/gpu/nova-core/gsp/fw/commands.rs
index 6dc31d1bf5ae..8dddd0876145 100644
--- a/drivers/gpu/nova-core/gsp/fw/commands.rs
+++ b/drivers/gpu/nova-core/gsp/fw/commands.rs
@@ -131,6 +131,11 @@ impl GspStaticConfigInfo {
         self.0.gpuNameString
     }
 
+    /// Returns a bytes array containing the NUL-terminated short name of this 
GPU.
+    pub(crate) fn gpu_short_name_str(&self) -> [u8; 64] {
+        self.0.gpuShortNameString
+    }
+
     /// Returns an iterator over valid FB regions from GSP firmware data.
     fn fb_regions(
         &self,
diff --git a/include/uapi/drm/nova_drm.h b/include/uapi/drm/nova_drm.h
index 7e11d1bfeb6b..f912c5bf3b4f 100644
--- a/include/uapi/drm/nova_drm.h
+++ b/include/uapi/drm/nova_drm.h
@@ -147,6 +147,11 @@ struct drm_nova_gpu_info {
         * @gpu_name: NUL-terminated full GPU name.
         */
        __u8 gpu_name[64];
+
+       /**
+        * @gpu_short_name: NUL-terminated short GPU name.
+        */
+       __u8 gpu_short_name[64];
 };
 
 #define DRM_NOVA_GETPARAM              0x00
-- 
2.54.0

Reply via email to