[PATCH 3/3] drm/nouveau/instmem: map only the part of BAR2 that is used
From: Mohamed Ahmed
Date: Tue Nov 17 2026 - 16:44:48 EST
The io_mapping covers the whole BAR2 resource. With GSP-RM and with
NvBar2Halve the BAR2 address space covers only its lower half. The
driver maps nothing in the upper half, and a mapping that already
exists there would give the io_mapping its type.
Size the io_mapping to the BAR2 address space. The range does not
change where BAR2 is not halved.
Fixes: 34e27b90552a ("nouveau/instmem: use iomapping interface for instmem handling")
Signed-off-by: Mohamed Ahmed <mohamedahmedegypt2001@xxxxxxxxx>
Tested-by: Thomas Andersen <phomes@xxxxxxxxx>
---
drivers/gpu/drm/nouveau/nvkm/subdev/instmem/nv50.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/instmem/nv50.c b/drivers/gpu/drm/nouveau/nvkm/subdev/instmem/nv50.c
index 1b4be4b1f0bb..1e7d439c2d59 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/instmem/nv50.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/instmem/nv50.c
@@ -191,16 +191,17 @@ nv50_instobj_map(struct nvkm_memory *memory, u64 offset, struct nvkm_vmm *vmm,
}
static bool
-check_io_mapping(struct nv50_instmem *imem)
+check_io_mapping(struct nv50_instmem *imem, struct nvkm_vmm *vmm)
{
struct nvkm_device *device = imem->base.subdev.device;
if (imem->iomap.size)
return true;
+ /* Map the part of BAR2 that its address space covers. */
return io_mapping_init_wc(&imem->iomap,
device->func->resource_addr(device, NVKM_BAR2_INST),
- device->func->resource_size(device, NVKM_BAR2_INST)) != NULL;
+ vmm->limit - vmm->start) != NULL;
}
static void
@@ -293,10 +294,10 @@ nv50_instobj_boot(struct nvkm_memory *memory, struct nvkm_vmm *vmm)
}
/*
- * boot is only called on BAR2, if we can't remap the complete
- * BAR it's unlikely things are functioning well.
+ * boot is only called on BAR2. If we can't map it, it's unlikely
+ * things are functioning well.
*/
- if (check_io_mapping(iobj->imem))
+ if (check_io_mapping(iobj->imem, vmm))
nv50_instobj_kmap(iobj, vmm);
nvkm_instmem_boot(imem);
mutex_unlock(&imem->mutex);
--
2.56.1