Re: [PATCH 7/9] gpu: nova-core: gsp: add RM control command infrastructure
From: Danilo Krummrich
Date: Fri Mar 13 2026 - 11:45:18 EST
On Fri Feb 27, 2026 at 1:32 PM CET, Eliot Courtney wrote:
> +/// Command for sending an RM control message to the GSP.
> +struct RmControl<'a> {
> + h_client: u32,
> + h_object: u32,
> + cmd: RmControlMsgFunction,
> + params: &'a [u8],
> +}
Please expand the documentation, especially the fields.
> +impl<'a> RmControl<'a> {
> + /// Creates a new RM control command.
> + fn new(h_client: u32, h_object: u32, cmd: RmControlMsgFunction, params: &'a [u8]) -> Self {
> + Self {
> + h_client,
> + h_object,
> + cmd,
> + params,
> + }
> + }
> +}
> +
> +impl CommandToGsp for RmControl<'_> {
> + const FUNCTION: MsgFunction = MsgFunction::GspRmControl;
> + type Command = GspRmControl;
> + type Reply = RmControlReply;
> + type InitError = Infallible;
> +
> + fn init(&self) -> impl Init<Self::Command, Self::InitError> {
> + GspRmControl::new(
> + self.h_client,
> + self.h_object,
> + self.cmd,
> + self.params.len() as u32,
> + )
> + }
> +
> + fn variable_payload_len(&self) -> usize {
> + self.params.len()
> + }
> +
> + fn init_variable_payload(
> + &self,
> + dst: &mut SBufferIter<array::IntoIter<&mut [u8], 2>>,
> + ) -> Result {
> + dst.write_all(self.params)
> + }
> +}
> +
> +/// Response from an RM control message.
> +pub(crate) struct RmControlReply {
> + status: NvStatus,
> + params: KVVec<u8>,
> +}
> +
> +impl MessageFromGsp for RmControlReply {
> + const FUNCTION: MsgFunction = MsgFunction::GspRmControl;
> + type Message = GspRmControl;
> + type InitError = Error;
> +
> + fn read(
> + msg: &Self::Message,
> + sbuffer: &mut SBufferIter<array::IntoIter<&[u8], 2>>,
> + ) -> Result<Self, Self::InitError> {
> + Ok(RmControlReply {
> + status: msg.status(),
> + params: sbuffer.flush_into_kvvec(GFP_KERNEL)?,
> + })
> + }
> +}
> +
> +/// Sends an RM control command, checks the reply status, and returns the raw parameter bytes.
> +#[expect(dead_code)]
> +fn send_rm_control(
Why isn't this a method of Cmdq?
> + cmdq: &Cmdq,
> + bar: &Bar0,
> + h_client: u32,
> + h_object: u32,
> + cmd: RmControlMsgFunction,
> + params: &[u8],
> +) -> Result<KVVec<u8>> {
> + let reply = cmdq.send_sync_command(bar, RmControl::new(h_client, h_object, cmd, params))?;
Why not let the caller construct RmControl?
> +
> + Result::from(reply.status)?;
> +
> + Ok(reply.params)
> +}
>
> --
> 2.53.0