@@ -149,9 +149,12 @@ static int setup_mgmt_heap(struct nvidia_vgpu *vgpu)
*/
int nvidia_vgpu_mgr_destroy_vgpu(struct nvidia_vgpu *vgpu)
{
+ struct nvidia_vgpu_mgr *vgpu_mgr = vgpu->vgpu_mgr;
+
if (!atomic_cmpxchg(&vgpu->status, 1, 0))
return -ENODEV;
+ nvidia_vgpu_mgr_free_gsp_client(vgpu_mgr, &vgpu->gsp_client);
clean_mgmt_heap(vgpu);
clean_chids(vgpu);
clean_fbmem_heap(vgpu);
@@ -171,6 +174,7 @@ EXPORT_SYMBOL(nvidia_vgpu_mgr_destroy_vgpu);
*/
int nvidia_vgpu_mgr_create_vgpu(struct nvidia_vgpu *vgpu, u8 *vgpu_type)
{
+ struct nvidia_vgpu_mgr *vgpu_mgr = vgpu->vgpu_mgr;
int ret;
if (WARN_ON(vgpu->info.id >= NVIDIA_MAX_VGPUS))
@@ -198,10 +202,17 @@ int nvidia_vgpu_mgr_create_vgpu(struct nvidia_vgpu *vgpu, u8 *vgpu_type)
if (ret)
goto err_setup_mgmt_heap;
+ ret = nvidia_vgpu_mgr_alloc_gsp_client(vgpu_mgr,
+ &vgpu->gsp_client);
+ if (ret)
+ goto err_alloc_gsp_client;
+
atomic_set(&vgpu->status, 1);
return 0;
+err_alloc_gsp_client:
+ clean_mgmt_heap(vgpu);
err_setup_mgmt_heap:
clean_chids(vgpu);
err_setup_chids:
@@ -36,6 +36,7 @@ struct nvidia_vgpu {
u8 *vgpu_type;
struct nvidia_vgpu_info info;
struct nvidia_vgpu_mgr *vgpu_mgr;
+ struct nvidia_vgpu_gsp_client gsp_client;
struct nvidia_vgpu_mem *fbmem_heap;
struct nvidia_vgpu_chid chid;
A GSP RM client is required when talking to the GSP firmware via GSP RM controls. So far, all the vGPU GSP RPCs are sent via the GSP RM client allocated for vGPU manager and some vGPU GSP RPCs needs a per-vGPU GSP RM client. Allocate a dedicated GSP RM client for each vGPU. Signed-off-by: Zhi Wang <zhiw@nvidia.com> --- drivers/vfio/pci/nvidia-vgpu/vgpu.c | 11 +++++++++++ drivers/vfio/pci/nvidia-vgpu/vgpu_mgr.h | 1 + 2 files changed, 12 insertions(+)