From: Zhi Wang <[email protected]> The host must negotiate the RPC protocol with the booted GSP plugin before sending instance configuration.
After observing the plugin's ready marker, initialize the shared RPC buffers and submit the existing typed version-negotiation request through the instance's PluginRpc channel. Co-developed-by: Eliot Courtney <[email protected]> Signed-off-by: Eliot Courtney <[email protected]> Signed-off-by: Zhi Wang <[email protected]> Signed-off-by: Alok Kumar <[email protected]> --- drivers/gpu/nova-core/vgpu/commands.rs | 20 ++++++++++++++++---- drivers/gpu/nova-core/vgpu/fw/commands.rs | 1 - drivers/gpu/nova-core/vgpu/gsp_plugin_rpc.rs | 2 -- drivers/gpu/nova-core/vgpu/instance.rs | 3 +++ 4 files changed, 19 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/nova-core/vgpu/commands.rs b/drivers/gpu/nova-core/vgpu/commands.rs index d0fd7ab2593b..660df399330e 100644 --- a/drivers/gpu/nova-core/vgpu/commands.rs +++ b/drivers/gpu/nova-core/vgpu/commands.rs @@ -38,11 +38,15 @@ }, sbuffer::SBufferIter, vgpu::{ - fw::commands::{ - AssignedVfVgpuType, - VgpuProperties, - VgpuPropertiesSchema, // + fw::{ + commands::{ + AssignedVfVgpuType, + VgpuProperties, + VgpuPropertiesSchema, // + }, + RpcMessage, }, + gsp_plugin_rpc::PluginRpc, instance::Gfid, Dbdf, }, @@ -223,3 +227,11 @@ pub(super) fn send_cleanup(dev: &device::Device, cmdq: &Cmdq<'_>, gfid: Gfid) -> dev_dbg!(dev, "cleanup: gfid={} done\n", gfid.get()); Ok(()) } + +/// Negotiate the host protocol with a bootloaded GSP plugin. +pub(super) fn negotiate_plugin_version( + dev: &device::Device, + rpc: &mut PluginRpc<'_, '_, '_>, +) -> Result { + rpc.rpc_call(dev, RpcMessage::VersionNegotiation, &[]) +} diff --git a/drivers/gpu/nova-core/vgpu/fw/commands.rs b/drivers/gpu/nova-core/vgpu/fw/commands.rs index d900075a96b0..e912c8255702 100644 --- a/drivers/gpu/nova-core/vgpu/fw/commands.rs +++ b/drivers/gpu/nova-core/vgpu/fw/commands.rs @@ -31,7 +31,6 @@ use super::bindings; /// Message types supported by the nova-core plugin RPC channel. -#[expect(dead_code)] #[derive(Clone, Copy)] #[repr(u32)] pub(crate) enum RpcMessage { diff --git a/drivers/gpu/nova-core/vgpu/gsp_plugin_rpc.rs b/drivers/gpu/nova-core/vgpu/gsp_plugin_rpc.rs index e63f4c660c0a..c22f35b43f0c 100644 --- a/drivers/gpu/nova-core/vgpu/gsp_plugin_rpc.rs +++ b/drivers/gpu/nova-core/vgpu/gsp_plugin_rpc.rs @@ -69,7 +69,6 @@ pub(super) fn comm(&self) -> &CommBufferRegion<'pool, 'map, 'gpu> { } /// Initialize the control and response buffers for the first RPC. - #[expect(dead_code)] pub(super) fn init_rpc(&mut self) -> Result { self.comm.initialize()?; self.message_sequence = 0; @@ -86,7 +85,6 @@ fn next_sequence(&self) -> u32 { } /// Write one RPC message, ring the VF doorbell, and wait for its response. - #[expect(dead_code)] pub(super) fn rpc_call( &mut self, dev: &device::Device, diff --git a/drivers/gpu/nova-core/vgpu/instance.rs b/drivers/gpu/nova-core/vgpu/instance.rs index 062cf963e7f7..18aa4d4c7e90 100644 --- a/drivers/gpu/nova-core/vgpu/instance.rs +++ b/drivers/gpu/nova-core/vgpu/instance.rs @@ -31,6 +31,7 @@ use super::{ commands::{ + negotiate_plugin_version, send_bootload, send_cleanup, send_shutdown, // @@ -161,6 +162,8 @@ impl<'gpu> VgpuInstance<'_, 'gpu> { fn activate(&mut self, vgpu: &VgpuManagerInner<'gpu>) -> Result { let dev = vgpu.dev; self.bootload(dev, vgpu.cmdq, &vgpu.fifo_engine_list)?; + self.plugin_rpc.init_rpc()?; + negotiate_plugin_version(dev, &mut self.plugin_rpc)?; Ok(()) }
