From 549d1e8126f96b3515d37037ae22e0dce430c20b Mon Sep 17 00:00:00 2001 From: Arthur Hanson Rasmusson Date: Mon, 5 Oct 2026 12:25:05 -0400 Subject: vgsp: per-mdev emulated VRAM size (1.0 multiple mediate sizes) - nv_vgpu_type_info/ioctl gain vram_mb; nv_vgpu_device gains fb_emul_size bound from the mdev type at create (default 512 MiB). - New nvidia-vgpu-turing-1g type (1024 MiB); turing max_instances 1 -> 2; show_description reports the per-type framebuffer and max_instance. - Thread fb_emul_size through GSCI fb_length/region/frtsOffset, WPR2, NV_PFB_PRI_MMU_LOCAL_MEMORY_RANGE, the vidmem allocator bound and the BAR1 shadow; bar_info callback uses the per-device size. - UNTESTED at commit time: builds clean; validation blocked by the Xid 140 incident (reboot pending). See Handoff-vGPU-IO.md ADDENDUM 48. --- kernel/gsp_rm_emulation.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'kernel/gsp_rm_emulation.c') diff --git a/kernel/gsp_rm_emulation.c b/kernel/gsp_rm_emulation.c index f123792..f2656bb 100644 --- a/kernel/gsp_rm_emulation.c +++ b/kernel/gsp_rm_emulation.c @@ -1025,7 +1025,7 @@ static void gsp_rm_handle_set_guest_system_info(struct gsp_emu_context *ctx, * Builds the 1656-byte GspStaticConfigInfo for TU104. * ============================================================ */ -static void gsp_rm_build_static_info(u8 *buf) +static void gsp_rm_build_static_info(u8 *buf, u64 fb_size) { u64 val64; u32 val32; @@ -1058,7 +1058,7 @@ static void gsp_rm_build_static_info(u8 *buf) { struct tu104_fb_region *region = (void *)(p + 8); /* 8-aligned */ val64 = 0; memcpy(®ion->base, &val64, 8); - val64 = (NV_VGPU_EMUL_FB_SIZE - 1); + val64 = (fb_size - 1); memcpy(®ion->limit, &val64, 8); val64 = 0; memcpy(®ion->reserved, &val64, 8); val32 = 0; memcpy(®ion->performance, &val32, 4); @@ -1097,9 +1097,10 @@ static void gsp_rm_build_static_info(u8 *buf) /* poisonFuseEnabled (offset 1216, 1 byte) */ buf[TU104_GSCI_OFF_poisonFuseEnabled] = 0; - /* fb_length (offset 1224, 8 bytes) - 512MB. Kept in lockstep with - * NV_PFB_PRI_MMU_LOCAL_MEMORY_RANGE and wpr2_addr_lo. */ - val64 = NV_VGPU_EMUL_FB_SIZE; + /* fb_length (offset 1224, 8 bytes) - this mdev's emulated FB size. + * Kept in lockstep with NV_PFB_PRI_MMU_LOCAL_MEMORY_RANGE and + * wpr2_addr_lo (all derive from nv_vgpu_fb_emul_size). */ + val64 = fb_size; memcpy(buf + TU104_GSCI_OFF_fb_length, &val64, 8); /* fbio_mask (offset 1232, 8 bytes) - 8 FBIOs for 256-bit bus */ @@ -1167,7 +1168,7 @@ static void gsp_rm_build_static_info(u8 *buf) /* fwWprLayoutOffset (offset 1640, 16 bytes): nonWprHeapOffset, frtsOffset */ val64 = 0; memcpy(buf + TU104_GSCI_OFF_fwWprLayoutOffset, &val64, 8); - val64 = NV_VGPU_EMUL_FB_SIZE - 0x200000; /* frtsOffset = fbSize - 2MB */ + val64 = fb_size - 0x200000; /* frtsOffset = fbSize - 2MB */ memcpy(buf + TU104_GSCI_OFF_fwWprLayoutOffset + 8, &val64, 8); } @@ -1241,12 +1242,13 @@ static void gsp_rm_handle_get_static_info(struct gsp_emu_context *ctx, return; } - gsp_rm_build_static_info(reply); + gsp_rm_build_static_info(reply, nv_vgpu_fb_emul_size(ctx->vgpu)); gsp_rm_apply_static_overlay(ctx, reply); nv_vgpu_info(ctx->vgpu, "vgsp-rm: GET_GSP_STATIC_INFO seq=%u -> %u bytes (fb=%lluMB, engines=0x%x/0x%x)", sequence, TU104_GSCI_SIZE, - (unsigned long long)(NV_VGPU_EMUL_FB_SIZE >> 20), 0x60003E02, 0x362020); + (unsigned long long)(nv_vgpu_fb_emul_size(ctx->vgpu) >> 20), + 0x60003E02, 0x362020); if (gsp_rm_send(ctx, GSPRM_RPC_FUNC_GET_GSP_STATIC_INFO, sequence, 0, reply, TU104_GSCI_SIZE)) @@ -1993,7 +1995,7 @@ static void gsp_rm_handle_kgr_get_context_buffers_info( */ static u32 tu104_fb_info_data(struct gsp_emu_context *ctx, u32 index) { - u64 fb = NV_VGPU_EMUL_FB_SIZE; + u64 fb = nv_vgpu_fb_emul_size(ctx->vgpu); switch (index) { case TU104_FB_INFO_IDX_TILE_REGION_COUNT: -- cgit v1.2.3