From: Zhi Wang The vGPU manager reports the enabled bus-mastering state to the GSP plugin after its initial configuration. The guest can then use the vGPU from now on. Add the BME state request and NVKV encoder, and send the enabled state after configuration succeeds. Co-developed-by: Eliot Courtney Signed-off-by: Eliot Courtney Signed-off-by: Zhi Wang Signed-off-by: Alok Kumar --- drivers/gpu/nova-core/vgpu/commands.rs | 11 +++++++++++ drivers/gpu/nova-core/vgpu/fw/commands.rs | 18 ++++++++++++++++++ drivers/gpu/nova-core/vgpu/instance.rs | 4 +++- 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/nova-core/vgpu/commands.rs b/drivers/gpu/nova-core/vgpu/commands.rs index 70fd35566822..d11f9af27ee0 100644 --- a/drivers/gpu/nova-core/vgpu/commands.rs +++ b/drivers/gpu/nova-core/vgpu/commands.rs @@ -40,6 +40,7 @@ vgpu::{ fw::{ commands::{ + encode_plugin_set_bme, AssignedVfVgpuType, VgpuProperties, VgpuPropertiesSchema, // @@ -244,3 +245,13 @@ pub(super) fn send_plugin_config( ) -> Result { rpc.rpc_call_nvkv(dev, RpcMessage::SetupConfigParamsAndInit, config) } + +/// Update the bus-mastering state reported to the GSP plugin. +pub(super) fn set_plugin_bme( + dev: &device::Device, + rpc: &mut PluginRpc<'_, '_>, + enable: bool, +) -> Result { + let bme = encode_plugin_set_bme(enable)?; + rpc.rpc_call_nvkv(dev, RpcMessage::UpdateBmeState, &bme) +} diff --git a/drivers/gpu/nova-core/vgpu/fw/commands.rs b/drivers/gpu/nova-core/vgpu/fw/commands.rs index c7ff27fcf6d7..10f1427bf355 100644 --- a/drivers/gpu/nova-core/vgpu/fw/commands.rs +++ b/drivers/gpu/nova-core/vgpu/fw/commands.rs @@ -37,6 +37,7 @@ pub(crate) enum RpcMessage { VersionNegotiation = bindings::MESSAGE_NV_VGPU_CPU_RPC_MSG_VERSION_NEGOTIATION, SetupConfigParamsAndInit = bindings::MESSAGE_NV_VGPU_CPU_RPC_MSG_SETUP_CONFIG_PARAMS_AND_INIT, + UpdateBmeState = bindings::MESSAGE_NV_VGPU_CPU_RPC_MSG_UPDATE_BME_STATE, } #[derive(Clone, Copy)] @@ -329,6 +330,23 @@ pub(crate) fn encode_plugin_config_params( Ok(encoder.finish()) } +nvkv_encode! { + struct PluginSetBmeRequest { + bme_enable: Key, + } +} + +/// Encodes a plugin BME state update using the typed NVKV schema. +pub(crate) fn encode_plugin_set_bme(enable: bool) -> Result> { + let request = PluginSetBmeRequest { + bme_enable: enable.into(), + }; + + let mut encoder = Encoder::new(); + request.encode(&mut encoder)?; + Ok(encoder.finish()) +} + // TODO: extract from bindings #[repr(C)] #[derive(FromBytes, IntoBytes)] diff --git a/drivers/gpu/nova-core/vgpu/instance.rs b/drivers/gpu/nova-core/vgpu/instance.rs index af1b43533a77..59d7014d7f69 100644 --- a/drivers/gpu/nova-core/vgpu/instance.rs +++ b/drivers/gpu/nova-core/vgpu/instance.rs @@ -35,7 +35,8 @@ send_bootload, send_cleanup, send_plugin_config, - send_shutdown, // + send_shutdown, + set_plugin_bme, // }, fw::commands::{ encode_plugin_config_params, @@ -167,6 +168,7 @@ fn activate(&mut self, vgpu: &VgpuManagerInner<'gpu>) -> Result { self.plugin_rpc.init_rpc()?; negotiate_plugin_version(dev, &mut self.plugin_rpc)?; self.configure_plugin(dev)?; + set_plugin_bme(dev, &mut self.plugin_rpc, true)?; Ok(()) } -- 2.53.0