summaryrefslogtreecommitdiffstats
path: root/kernel/bar_init.c
diff options
context:
space:
mode:
authorArthur Hanson Rasmusson <arthur@vgpu.io>2026-10-07 21:21:50 -0400
committerArthur Hanson Rasmusson <arthur@vgpu.io>2026-10-07 21:21:50 -0400
commitd5bc16983832c6fe4949f28b9f3a6760e3db8f71 (patch)
treed75ec9faa3ffb830c457935b78cbc0518cd8a6ee /kernel/bar_init.c
parentcc784674988a9401a430fd346fc2ffedeb36b524 (diff)
downloadopen-iov-d5bc16983832c6fe4949f28b9f3a6760e3db8f71.tar.gz
open-iov-d5bc16983832c6fe4949f28b9f3a6760e3db8f71.zip
vgsp: m143 (1.0 P1) - 2GiB turing type, BAR1 size = fb_emul_size, script accepts -1g/-2g
Diffstat (limited to 'kernel/bar_init.c')
-rw-r--r--kernel/bar_init.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/kernel/bar_init.c b/kernel/bar_init.c
index f4c982a..b5703d8 100644
--- a/kernel/bar_init.c
+++ b/kernel/bar_init.c
@@ -56,20 +56,31 @@ int nv_vgpu_bar_init(struct nv_vgpu_device *vgpu)
bar_size = pci_resource_len(pdev, 1);
if (bar_addr && bar_size) {
vgpu->bars[1].gpa = bar_addr;
- vgpu->bars[1].size = bar_size;
+ /*
+ * m143 (1.0 VRAM sizes): expose the EMULATED framebuffer size as
+ * BAR1's size, not the physical aperture. The guest derives its
+ * BAR1 from the VFIO region info (config-space BAR writes are
+ * ignored) and every GSCI/PFB report already carries
+ * fb_emul_size; leaving the physical 256 MB here made 1G/2G types
+ * tell the guest one size and expose another (the shadow is
+ * fb_emul_size, so vidmem bounds and mmap math must match it).
+ */
+ vgpu->bars[1].size = nv_vgpu_fb_emul_size(vgpu);
/* Emulated vidmem: a dedicated host-RAM buffer backing the guest's
* VRAM aperture. Do NOT map the host GPU's real BAR1 - guest VRAM
* accesses must hit our own clean buffer, not the (broken) host
* GPU's VRAM. Allocated lazily on first use to keep mdev create
- * cheap; 256MB to match the GSCI fb size. */
+ * cheap; sized by the mdev type (512M/1G/2G). */
vgpu->bars[1].vaddr = vzalloc(nv_vgpu_fb_emul_size(vgpu));
if (!vgpu->bars[1].vaddr) {
nv_vgpu_err(vgpu, "Failed to allocate emulated vidmem (%llu MiB)",
(unsigned long long)(nv_vgpu_fb_emul_size(vgpu) >> 20));
return -ENOMEM;
}
- nv_vgpu_info(vgpu, "BAR1: gpa=0x%llx, size=0x%llx, emulated vidmem=%p",
- bar_addr, bar_size, vgpu->bars[1].vaddr);
+ nv_vgpu_info(vgpu, "BAR1: gpa=0x%llx, size=0x%llx (emulated, %llu MiB), emulated vidmem=%p",
+ bar_addr, vgpu->bars[1].size,
+ (unsigned long long)(nv_vgpu_fb_emul_size(vgpu) >> 20),
+ vgpu->bars[1].vaddr);
}
bar_addr = pci_resource_start(pdev, 2);