[PATCH v5 11/11] drm: nova: Report GPU GID 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 GPU GID to the reported GPU info. 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 | 7 +++++++ include/uapi/drm/nova_drm.h | 5 +++++ 5 files changed, 25 insertions(+) diff --git a/drivers/gpu/drm/nova/file.rs b/drivers/gpu/drm/nova/file.rs index 64d9f68c7cf0..e1223a29f8b1 100644 --- a/drivers/gpu/drm/nova/file.rs +++ b/drivers/gpu/drm/nova/file.rs @@ -38,6 +38,7 @@ fn new(reg_data: &DrmRegData<'_>) -> Self { vram_size: reg_data.api.vram_size(), gpu_name: reg_data.api.gpu_name(), gpu_short_name: reg_data.api.gpu_short_name(), + gpu_gid: reg_data.api.gpu_gid(), }) } } diff --git a/drivers/gpu/nova-core/api.rs b/drivers/gpu/nova-core/api.rs index c18fa1766892..ad4b62db1e5f 100644 --- a/drivers/gpu/nova-core/api.rs +++ b/drivers/gpu/nova-core/api.rs @@ -34,6 +34,11 @@ impl NovaCoreApi<'_> { *self.gpu.gsp_static_info.gpu_short_name_bytes() } + /// Returns the 16-byte SHA-1 GPU identifier supplied by GSP-RM. + pub fn gpu_gid(&self) -> [u8; 16] { + *self.gpu.gsp_static_info.gpu_gid() + } + /// 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 b9f19be9b29c..c01b978f46d2 100644 --- a/drivers/gpu/nova-core/gsp/commands.rs +++ b/drivers/gpu/nova-core/gsp/commands.rs @@ -215,6 +215,7 @@ fn init(&self) -> impl Init<Self::Command, Self::InitError> { pub(crate) struct GetGspStaticInfoReply { gpu_name: [u8; 64], gpu_short_name: [u8; 64], + gpu_gid: [u8; 16], /// Usable FB (VRAM) regions for driver memory allocation. pub(crate) usable_fb_regions: KVec<Range<u64>>, } @@ -236,6 +237,7 @@ fn read( Ok(GetGspStaticInfoReply { gpu_name: msg.gpu_name_str(), gpu_short_name: msg.gpu_short_name_str(), + gpu_gid: msg.gpu_gid(), usable_fb_regions, }) } @@ -263,6 +265,11 @@ impl GetGspStaticInfoReply { &self.gpu_short_name } + /// Returns the 16-byte SHA-1 GPU identifier. + pub(crate) fn gpu_gid(&self) -> &[u8; 16] { + &self.gpu_gid + } + /// 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 8dddd0876145..1020de51a83c 100644 --- a/drivers/gpu/nova-core/gsp/fw/commands.rs +++ b/drivers/gpu/nova-core/gsp/fw/commands.rs @@ -136,6 +136,13 @@ impl GspStaticConfigInfo { self.0.gpuShortNameString } + /// Returns the 16-byte SHA-1 GPU identifier. + pub(crate) fn gpu_gid(&self) -> [u8; 16] { + let mut gid = [0; 16]; + gid.copy_from_slice(&self.0.gidInfo.data[..16]); + gid + } + /// 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 f912c5bf3b4f..3bd9db27c665 100644 --- a/include/uapi/drm/nova_drm.h +++ b/include/uapi/drm/nova_drm.h @@ -152,6 +152,11 @@ struct drm_nova_gpu_info { * @gpu_short_name: NUL-terminated short GPU name. */ __u8 gpu_short_name[64]; + + /** + * @gpu_gid: 16-byte SHA-1 GPU identifier supplied by GSP-RM. + */ + __u8 gpu_gid[16]; }; #define DRM_NOVA_GETPARAM 0x00 -- 2.54.0