GspStaticInfo holds the static GPU configuration which GSP returns in
reply to GSP_INIT, such as the GPU names, the GID and the FB regions.

GSP reports these as keys of the GMCAPI static config, so add them
to the GSP_INIT response schema and to GspStaticInfo. A subsequent patch
allows nova-drm to report them to userspace.

None of the keys are required. Firmware which predates a key does not
send it, in which case the value decodes as None. GSP also reports zero
for a clock it cannot determine, so zero means unknown for all of these.

Signed-off-by: Alistair Popple <[email protected]>
---
 drivers/gpu/nova-core/gsp/commands.rs     | 14 +++++++++++
 drivers/gpu/nova-core/gsp/commands/gmc.rs |  5 ++++
 drivers/gpu/nova-core/gsp/fw/commands.rs  | 42 +++++++++++++++++++++++++++++++
 3 files changed, 61 insertions(+)

diff --git a/drivers/gpu/nova-core/gsp/commands.rs 
b/drivers/gpu/nova-core/gsp/commands.rs
index 985cfc2a958e..e7281fb8997e 100644
--- a/drivers/gpu/nova-core/gsp/commands.rs
+++ b/drivers/gpu/nova-core/gsp/commands.rs
@@ -23,6 +23,20 @@ pub struct GspStaticInfo {
     pub(crate) usable_fb_regions: KVec<Range<u64>>,
     /// Exclusive end of the FB physical address space.
     pub(crate) total_fb_end: u64,
+    /// Number of streaming multiprocessors (SMs), or `None` if GSP does not 
report it.
+    pub sm_count: Option<u32>,
+    /// Width of the FB memory bus in bits, or `None` if GSP does not report 
it.
+    pub fb_bus_width: Option<u32>,
+    /// Size of the GPU L2 cache in bytes, or `None` if GSP does not report it.
+    pub l2_cache_size: Option<u32>,
+    /// Maximum frequency of the graphics clock in Hz, or `None` if GSP does 
not report it.
+    ///
+    /// GSP reports zero if it cannot determine the frequency.
+    pub max_gpc_clk_hz: Option<u64>,
+    /// Maximum frequency of the memory clock in Hz, or `None` if GSP does not 
report it.
+    ///
+    /// GSP reports zero if it cannot determine the frequency.
+    pub max_mem_clk_hz: Option<u64>,
 }
 
 /// Error type for [`GspStaticInfo::gpu_name`].
diff --git a/drivers/gpu/nova-core/gsp/commands/gmc.rs 
b/drivers/gpu/nova-core/gsp/commands/gmc.rs
index a6cc5759c2a2..0b19acbdbed7 100644
--- a/drivers/gpu/nova-core/gsp/commands/gmc.rs
+++ b/drivers/gpu/nova-core/gsp/commands/gmc.rs
@@ -190,6 +190,11 @@ fn read(payload: &mut 
SBufferIter<core::array::IntoIter<&[u8], 2>>) -> Result<Se
             bar1_pde_base: reply.bar1_pde_base(),
             usable_fb_regions,
             total_fb_end: reply.total_fb_end().ok_or(EINVAL)?,
+            sm_count: reply.sm_count(),
+            fb_bus_width: reply.fb_bus_width(),
+            l2_cache_size: reply.l2_cache_size(),
+            max_gpc_clk_hz: reply.max_gpc_clk_hz(),
+            max_mem_clk_hz: reply.max_mem_clk_hz(),
         })
     }
 }
diff --git a/drivers/gpu/nova-core/gsp/fw/commands.rs 
b/drivers/gpu/nova-core/gsp/fw/commands.rs
index 9083175ee6e5..48a327082358 100644
--- a/drivers/gpu/nova-core/gsp/fw/commands.rs
+++ b/drivers/gpu/nova-core/gsp/fw/commands.rs
@@ -26,6 +26,7 @@
             Encodable,
             Encoder,
             Key,
+            Optional,
             Required,
             TruncatingArray, //
         },
@@ -334,6 +335,11 @@ pub(crate) struct GspInitResponseSchema => GspInitResponse 
{
         fb_regions: Accumulated<FbRegionSchema>,
         bar1_pde_base: Required<Key<u64, 0x1020>>,
         vmmu_segment_size: Key<u64, 0x1050>,
+        sm_count: Optional<Key<u32, 0x0400>>,
+        fb_bus_width: Optional<Key<u32, 0x0401>>,
+        l2_cache_size: Optional<Key<u32, 0x0402>>,
+        max_gpc_clk_hz: Optional<Key<u64, 0x1060>>,
+        max_mem_clk_hz: Optional<Key<u64, 0x1061>>,
     }
 }
 
@@ -345,6 +351,11 @@ pub(crate) struct GspInitResponse {
     fb_regions: KVVec<FbRegion>,
     bar1_pde_base: u64,
     vmmu_segment_size: u64,
+    sm_count: Option<u32>,
+    fb_bus_width: Option<u32>,
+    l2_cache_size: Option<u32>,
+    max_gpc_clk_hz: Option<u64>,
+    max_mem_clk_hz: Option<u64>,
 }
 
 impl GspInitResponse {
@@ -402,6 +413,37 @@ pub(crate) fn total_fb_end(&self) -> Option<u64> {
     pub(crate) fn bar1_pde_base(&self) -> u64 {
         self.bar1_pde_base
     }
+
+    /// Returns the number of streaming multiprocessors (SMs), or `None` if 
GSP did not send it.
+    pub(crate) fn sm_count(&self) -> Option<u32> {
+        self.sm_count
+    }
+
+    /// Returns the width of the FB memory bus in bits, or `None` if GSP did 
not send it.
+    pub(crate) fn fb_bus_width(&self) -> Option<u32> {
+        self.fb_bus_width
+    }
+
+    /// Returns the size of the GPU L2 cache in bytes, or `None` if GSP did 
not send it.
+    pub(crate) fn l2_cache_size(&self) -> Option<u32> {
+        self.l2_cache_size
+    }
+
+    /// Returns the maximum frequency of the graphics clock in Hz, or `None` 
if GSP did not
+    /// send it.
+    ///
+    /// GSP sends zero if it could not determine the frequency.
+    pub(crate) fn max_gpc_clk_hz(&self) -> Option<u64> {
+        self.max_gpc_clk_hz
+    }
+
+    /// Returns the maximum frequency of the memory clock in Hz, or `None` if 
GSP did not send
+    /// it.
+    ///
+    /// GSP sends zero if it could not determine the frequency.
+    pub(crate) fn max_mem_clk_hz(&self) -> Option<u64> {
+        self.max_mem_clk_hz
+    }
 }
 
 nvkv_decode! {

-- 
2.54.0

Reply via email to