Re: [PATCH v9 21/31] gpu: nova-core: Hopper/Blackwell: add FSP send/receive messaging

From: Alexandre Courbot

Date: Tue Apr 07 2026 - 21:54:01 EST


On Thu Mar 26, 2026 at 10:38 AM JST, John Hubbard wrote:
<snip>
> diff --git a/drivers/gpu/nova-core/fsp.rs b/drivers/gpu/nova-core/fsp.rs
> index bbf89c70a425..931d806c3db8 100644
> --- a/drivers/gpu/nova-core/fsp.rs
> +++ b/drivers/gpu/nova-core/fsp.rs
> @@ -19,6 +19,15 @@
>
> use crate::regs;
>
> +use crate::mctp::{
> + MctpHeader,
> + NvdmHeader,
> + NvdmType, //
> +};
> +
> +/// FSP message timeout in milliseconds.
> +const FSP_MSG_TIMEOUT_MS: i64 = 2000;
> +
> /// FSP secure boot completion timeout in milliseconds.
> ///
> /// GB20x requires a longer timeout than Hopper/GB10x.
> @@ -124,6 +133,37 @@ pub(crate) struct FmcSignatures {
> public_key: [u8; FSP_PKEY_SIZE],
> signature: [u8; FSP_SIG_SIZE],
> }
> +
> +/// FSP Command Response payload structure.
> +/// NVDM_PAYLOAD_COMMAND_RESPONSE structure.
> +#[repr(C, packed)]
> +#[derive(Clone, Copy)]
> +struct NvdmPayloadCommandResponse {
> + task_id: u32,
> + command_nvdm_type: u32,
> + error_code: u32,
> +}
> +
> +/// Complete FSP response structure with MCTP and NVDM headers.
> +#[repr(C, packed)]
> +#[derive(Clone, Copy)]
> +struct FspResponse {
> + mctp_header: u32,
> + nvdm_header: u32,
> + response: NvdmPayloadCommandResponse,
> +}
> +
> +// SAFETY: FspResponse is a packed C struct with only integral fields.
> +unsafe impl FromBytes for FspResponse {}
> +
> +/// Trait implemented by types representing a message to send to FSP.
> +///
> +/// This provides [`Fsp::send_sync_fsp`] with the information it needs to send
> +/// a given message, following the same pattern as GSP's `CommandToGsp`.
> +pub(crate) trait MessageToFsp: AsBytes {
> + /// NVDM type identifying this message to FSP.
> + const NVDM_TYPE: u32;
> +}

A trait is useful to provide some kind of polymorphism. This trait is
only ever implemented by `FspMessage` (which strangely is added in a
different patch), so it seems pretty pointless (unless we have plans to
implement it on other types, but this series doesn't do it).

> /// FSP interface for Hopper/Blackwell GPUs.
> pub(crate) struct Fsp;
>
> @@ -224,4 +264,87 @@ pub(crate) fn extract_fmc_signatures(
>
> Ok(signatures)
> }
> +
> + /// Send message to FSP and wait for response.
> + #[expect(dead_code)]
> + fn send_sync_fsp<M>(
> + dev: &device::Device<device::Bound>,
> + bar: &crate::driver::Bar0,
> + fsp_falcon: &crate::falcon::Falcon<crate::falcon::fsp::Fsp>,

Please import relevant items, this is very heavy to read (applies to
other patches in the series as well).