summaryrefslogtreecommitdiff
path: root/drivers/gpu/nova-core
diff options
context:
space:
mode:
authorEliot Courtney <ecourtney@nvidia.com>2026-03-06 16:22:04 +0900
committerAlexandre Courbot <acourbot@nvidia.com>2026-03-10 16:07:33 +0900
commitadcb40c5fcf085b16327ab1eef11ec157c9f603b (patch)
tree23c548d6b139f5b9e3639c496e94b18eb0150831 /drivers/gpu/nova-core
parentdcf1fdafe04095947f08db5a45d1994aa1d948fa (diff)
downloadlinux-next-adcb40c5fcf085b16327ab1eef11ec157c9f603b.tar.gz
linux-next-adcb40c5fcf085b16327ab1eef11ec157c9f603b.zip
gpu: nova-core: gsp: add `size` helper to `CommandToGsp`
Add a default method to `CommandToGsp` which computes the size of a command. Tested-by: Zhi Wang <zhiw@nvidia.com> Signed-off-by: Eliot Courtney <ecourtney@nvidia.com> Link: https://patch.msgid.link/20260306-cmdq-continuation-v6-7-cc7b629200ee@nvidia.com Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
Diffstat (limited to 'drivers/gpu/nova-core')
-rw-r--r--drivers/gpu/nova-core/gsp/cmdq.rs12
1 files changed, 9 insertions, 3 deletions
diff --git a/drivers/gpu/nova-core/gsp/cmdq.rs b/drivers/gpu/nova-core/gsp/cmdq.rs
index b41a866e24da..861f5666fe7f 100644
--- a/drivers/gpu/nova-core/gsp/cmdq.rs
+++ b/drivers/gpu/nova-core/gsp/cmdq.rs
@@ -94,6 +94,12 @@ pub(crate) trait CommandToGsp {
) -> Result {
Ok(())
}
+
+ /// Total size of the command (including its variable-length payload) without the
+ /// [`GspMsgElement`] header.
+ fn size(&self) -> usize {
+ size_of::<Self::Command>() + self.variable_payload_len()
+ }
}
/// Trait representing messages received from the GSP.
@@ -529,10 +535,10 @@ impl Cmdq {
// This allows all error types, including `Infallible`, to be used for `M::InitError`.
Error: From<M::InitError>,
{
- let command_size = size_of::<M::Command>() + command.variable_payload_len();
+ let size_in_bytes = command.size();
let dst = self
.gsp_mem
- .allocate_command(command_size, Self::ALLOCATE_TIMEOUT)?;
+ .allocate_command(size_in_bytes, Self::ALLOCATE_TIMEOUT)?;
// Extract area for the command itself. The GSP message header and the command header
// together are guaranteed to fit entirely into a single page, so it's ok to only look
@@ -540,7 +546,7 @@ impl Cmdq {
let (cmd, payload_1) = M::Command::from_bytes_mut_prefix(dst.contents.0).ok_or(EIO)?;
// Fill the header and command in-place.
- let msg_element = GspMsgElement::init(self.seq, command_size, M::FUNCTION);
+ let msg_element = GspMsgElement::init(self.seq, size_in_bytes, M::FUNCTION);
// SAFETY: `msg_header` and `cmd` are valid references, and not touched if the initializer
// fails.
unsafe {