From: Zhi Wang <[email protected]> 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 <[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 | 11 +++++++++++ drivers/gpu/nova-core/vgpu/fw/commands.rs | 22 ++++++++++++++++++++++ drivers/gpu/nova-core/vgpu/instance.rs | 2 ++ 3 files changed, 35 insertions(+) diff --git a/drivers/gpu/nova-core/vgpu/commands.rs b/drivers/gpu/nova-core/vgpu/commands.rs index 968942273b9e..7f26d2dabca4 100644 --- a/drivers/gpu/nova-core/vgpu/commands.rs +++ b/drivers/gpu/nova-core/vgpu/commands.rs @@ -26,6 +26,7 @@ use super::{ fw::{ commands::{ + encode_plugin_set_bme, VgpuPropertiesSchema, // }, RpcMessage, // @@ -179,3 +180,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<device::Bound>, + 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 3f94435e7a59..9356b4fb643a 100644 --- a/drivers/gpu/nova-core/vgpu/fw/commands.rs +++ b/drivers/gpu/nova-core/vgpu/fw/commands.rs @@ -36,6 +36,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, } bitfield! { @@ -397,3 +398,24 @@ pub(crate) fn encode_plugin_config_params( request.encode(&mut encoder)?; Ok(encoder.finish()) } + +nvkv_encode! { + struct PluginSetBmeRequest { + bme_enable: Key<bool, { Self::BME_ENABLE_KEY }, u32>, + } +} + +impl PluginSetBmeRequest { + const BME_ENABLE_KEY: KeyId = 0x0100; +} + +/// Encodes a plugin BME state update using the typed NVKV schema. +pub(crate) fn encode_plugin_set_bme(enable: bool) -> Result<KVVec<u64>> { + let request = PluginSetBmeRequest { + bme_enable: enable.into(), + }; + + let mut encoder = Encoder::new(); + request.encode(&mut encoder)?; + Ok(encoder.finish()) +} diff --git a/drivers/gpu/nova-core/vgpu/instance.rs b/drivers/gpu/nova-core/vgpu/instance.rs index 247e88bdc82f..23c2b791aa25 100644 --- a/drivers/gpu/nova-core/vgpu/instance.rs +++ b/drivers/gpu/nova-core/vgpu/instance.rs @@ -36,6 +36,7 @@ send_cleanup, send_plugin_config, send_shutdown, + set_plugin_bme, Dbdf, // }, fw::commands::{ @@ -162,6 +163,7 @@ fn activate(&mut self, vgpu: &VgpuManager<'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
