summaryrefslogtreecommitdiffstats
path: root/kernel/gsp_rm_emulation.c
diff options
context:
space:
mode:
authorArthur Hanson Rasmusson <arthur@vgpu.io>2026-11-11 21:55:47 -0500
committerArthur Hanson Rasmusson <arthur@vgpu.io>2026-11-11 21:55:47 -0500
commit8c7bf2959c62743899dfdc6097dabfaebf227158 (patch)
tree444714ec225532e02d78b3e49e6f297b004c96df /kernel/gsp_rm_emulation.c
parent889ccc0f3992022762d4a4d6a3641b64699d5bd3 (diff)
downloadopen-iov-8c7bf2959c62743899dfdc6097dabfaebf227158.tar.gz
open-iov-8c7bf2959c62743899dfdc6097dabfaebf227158.zip
vgsp: report FB info sizes in KB and use 0 for unsupported context buffers
The FB info ABI documents RAM_SIZE/TOTAL_RAM_SIZE/USABLE_RAM_SIZE/HEAP_SIZE/ MAPPABLE_HEAP_SIZE/HEAP_FREE/BAR1_SIZE/BAR1_AVAIL_SIZE in kilobytes; the emulation returned bytes, over-reporting the emulated framebuffer by 1024x to the X DDX. COMPRESSION_SIZE and L2CACHE_SIZE remain in bytes. KGR_GET_CONTEXT_BUFFERS_INFO reported NV_U32_MAX for buffer kinds Turing does not support. kgraphics treats size==0 as unsupported (skip); an NV_U32_MAX byte length rounds up to exactly 4 GiB in the page-count computation, which is the shape of the transient guest sysmem allocations. Report 0/0 instead. Evidence: handoff-meta-plan.md CONT.435 (c15-c21 allocation traces, the guest nvidia.ko disassembly of osAllocPagesInternal), kernel 570.144 ctrl2080fb.h units and kernel_graphics.c:1775-1800.
Diffstat (limited to 'kernel/gsp_rm_emulation.c')
-rw-r--r--kernel/gsp_rm_emulation.c32
1 files changed, 23 insertions, 9 deletions
diff --git a/kernel/gsp_rm_emulation.c b/kernel/gsp_rm_emulation.c
index 9d9f351..581ed19 100644
--- a/kernel/gsp_rm_emulation.c
+++ b/kernel/gsp_rm_emulation.c
@@ -2892,11 +2892,16 @@ static void gsp_rm_handle_kgr_get_context_buffers_info(
for (e = 0; e < TU104_CTX_GPU_MAX_ENGINES; e++) {
for (i = 0; i < TU104_CTX_ENGINE_ID_COUNT; i++) {
- /* engine IDs the chip does not support report
- * NV_U32_MAX (the client skips those entries) */
+ /* r1781/CONT.435: use 0 (not NV_U32_MAX) for buffer
+ * kinds this chip does not support. kgraphics treats
+ * size==0 as "not supported" and skips the buffer
+ * (kernel_graphics.c:1785); an NV_U32_MAX byte length
+ * would instead round up to exactly 4 GiB in the
+ * page-count computation. The reserve-size sum also
+ * guards on NV_U32_MAX, so 0 is both safe and honest. */
if (sizes[i].size == 0) {
- info->engineContextBuffersInfo[e].engine[i].size = 0xFFFFFFFF;
- info->engineContextBuffersInfo[e].engine[i].alignment = 0xFFFFFFFF;
+ info->engineContextBuffersInfo[e].engine[i].size = 0;
+ info->engineContextBuffersInfo[e].engine[i].alignment = 0;
continue;
}
info->engineContextBuffersInfo[e].engine[i].size = sizes[i].size;
@@ -2948,15 +2953,24 @@ static u32 tu104_fb_info_data(struct gsp_emu_context *ctx, u32 index)
return gsp_rm_fb_compr_mb << 20;
case TU104_FB_INFO_IDX_PARTITION_COUNT:
return 1;
+ /*
+ * r1781/CONT.435: every size index below is documented in KB
+ * (ctrl2080fb.h: RAM_SIZE/TOTAL_RAM_SIZE/USABLE_RAM_SIZE/HEAP_SIZE/
+ * MAPPABLE_HEAP_SIZE/HEAP_FREE/BAR1_SIZE/BAR1_AVAIL_SIZE are all
+ * "in kilobytes"). Returning the byte count over-reported the
+ * emulated FB size by 1024x to the X DDX (FbTotalSizeKb =
+ * 0x20000000 = 512 GB). COMPRESSION_SIZE and L2CACHE_SIZE stay
+ * in bytes per the same header.
+ */
case TU104_FB_INFO_IDX_BAR1_SIZE:
- return (u32)fb;
+ return (u32)(fb >> 10);
case TU104_FB_INFO_IDX_RAM_SIZE:
case TU104_FB_INFO_IDX_TOTAL_RAM_SIZE:
case TU104_FB_INFO_IDX_USABLE_RAM_SIZE:
- return (u32)fb;
+ return (u32)(fb >> 10);
case TU104_FB_INFO_IDX_HEAP_SIZE:
case TU104_FB_INFO_IDX_MAPPABLE_HEAP_SIZE:
- return (u32)fb;
+ return (u32)(fb >> 10);
case TU104_FB_INFO_IDX_BUS_WIDTH:
return 256;
case TU104_FB_INFO_IDX_RAM_TYPE:
@@ -2969,7 +2983,7 @@ static u32 tu104_fb_info_data(struct gsp_emu_context *ctx, u32 index)
case TU104_FB_INFO_IDX_PARTITION_MASK:
return 1;
case TU104_FB_INFO_IDX_HEAP_FREE:
- return (u32)fb;
+ return (u32)(fb >> 10);
case TU104_FB_INFO_IDX_RAM_LOCATION:
return TU104_RAM_LOCATION_GPU_DEDICATED;
case TU104_FB_INFO_IDX_FBP_COUNT:
@@ -2982,7 +2996,7 @@ static u32 tu104_fb_info_data(struct gsp_emu_context *ctx, u32 index)
return TU104_MEMORYINFO_VENDOR_ID_SAMSUNG;
case TU104_FB_INFO_IDX_BAR1_AVAIL_SIZE:
case TU104_FB_INFO_IDX_BAR1_MAX_CONTIG_AVAIL_SIZE:
- return (u32)fb;
+ return (u32)(fb >> 10);
case TU104_FB_INFO_IDX_LTC_COUNT:
return TU104_LTC_COUNT;
case TU104_FB_INFO_IDX_LTS_COUNT: