@@ -3,6 +3,7 @@
#include <core/device.h>
#include <engine/chid.h>
#include <engine/fifo.h>
+#include <engine/fifo/runl.h>
#include <subdev/bar.h>
#include <subdev/fb.h>
#include <subdev/gsp.h>
@@ -248,6 +249,19 @@ static int bar1_map_mem(struct nvidia_vgpu_mem *base)
return 0;
}
+static void get_engine_bitmap(void *handle, unsigned long *bitmap)
+{
+ struct nvkm_device *nvkm_dev = handle;
+ struct nvkm_runl *runl;
+ struct nvkm_engn *engn;
+
+ nvkm_runl_foreach(runl, nvkm_dev->fifo) {
+ nvkm_runl_foreach_engn(engn, runl) {
+ __set_bit(engn->id, bitmap);
+ }
+ }
+}
+
struct nvkm_vgpu_mgr_vfio_ops nvkm_vgpu_mgr_vfio_ops = {
.vgpu_mgr_is_enabled = vgpu_mgr_is_enabled,
.get_handle = get_handle,
@@ -266,6 +280,7 @@ struct nvkm_vgpu_mgr_vfio_ops nvkm_vgpu_mgr_vfio_ops = {
.free_fbmem = free_fbmem,
.bar1_map_mem = bar1_map_mem,
.bar1_unmap_mem = bar1_unmap_mem,
+ .get_engine_bitmap = get_engine_bitmap,
};
/**
@@ -48,6 +48,7 @@ struct nvkm_vgpu_mgr_vfio_ops {
void (*free_fbmem)(struct nvidia_vgpu_mem *mem);
int (*bar1_map_mem)(struct nvidia_vgpu_mem *mem);
void (*bar1_unmap_mem)(struct nvidia_vgpu_mem *mem);
+ void (*get_engine_bitmap)(void *handle, unsigned long *bitmap);
};
struct nvkm_vgpu_mgr_vfio_ops *nvkm_vgpu_mgr_get_vfio_ops(void *handle);
Activating a new vGPU needs to configure the allocated CHIDs of engines. Thus, an engine bitmap is required. Expose the engine bitmap to NVIDIA vGPU VFIO module to activate the new vGPU. Signed-off-by: Zhi Wang <zhiw@nvidia.com> --- drivers/gpu/drm/nouveau/nvkm/vgpu_mgr/vfio.c | 15 +++++++++++++++ include/drm/nvkm_vgpu_mgr_vfio.h | 1 + 2 files changed, 16 insertions(+)