Change send_sync_fsp() to return the raw response buffer after
validating the common MCTP/NVDM headers and error code. This allows
callers to perform protocol-specific parsing on the response payload,
which is needed for the upcoming PRC protocol support.

For the existing COT caller, the response buffer is unused.

Signed-off-by: Zhi Wang <[email protected]>
---
 drivers/gpu/nova-core/fsp.rs | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/nova-core/fsp.rs b/drivers/gpu/nova-core/fsp.rs
index 477ed719b757..69e48b655879 100644
--- a/drivers/gpu/nova-core/fsp.rs
+++ b/drivers/gpu/nova-core/fsp.rs
@@ -454,12 +454,13 @@ pub(crate) fn boot_fmc(
     }
 
     /// Send message to FSP and wait for response.
+    /// Returns the raw response buffer for protocol-specific parsing.
     fn send_sync_fsp<M>(
         dev: &device::Device<device::Bound>,
         bar: &crate::driver::Bar0,
         fsp_falcon: &crate::falcon::Falcon<crate::falcon::fsp::Fsp>,
         msg: &M,
-    ) -> Result
+    ) -> Result<KVec<u8>>
     where
         M: MessageToFsp,
     {
@@ -482,12 +483,13 @@ fn send_sync_fsp<M>(
         response_buf.resize(packet_size, 0, GFP_KERNEL)?;
         fsp_falcon.recv_msg(bar, &mut response_buf, packet_size)?;
 
-        if response_buf.len() < core::mem::size_of::<FspResponse>() {
+        let min_size = core::mem::size_of::<FspResponse>();
+        if response_buf.len() < min_size {
             dev_err!(dev, "FSP response too small: {}\n", response_buf.len());
             return Err(EIO);
         }
 
-        let response = FspResponse::from_bytes(&response_buf[..]).ok_or(EIO)?;
+        let response = 
FspResponse::from_bytes(&response_buf[..min_size]).ok_or(EIO)?;
 
         let mctp_header: MctpHeader = response.header.mctp_header.into();
         let nvdm_header: NvdmHeader = response.header.nvdm_header.into();
@@ -532,6 +534,6 @@ fn send_sync_fsp<M>(
             return Err(EIO);
         }
 
-        Ok(())
+        Ok(response_buf)
     }
 }
-- 
2.51.0

Reply via email to