Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/nouveau/mmu/tu102: Add support for compressed kinds

Allow compressed PTE kinds to be written into PTEs when GSP-RM is
present, rather than reverting to their non-compressed versions.

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
Signed-off-by: Mohamed Ahmed <mohamedahmedegypt2001@gmail.com>
Signed-off-by: Mary Guillemard <mary@mary.zone>
Reviewed-by: Lyude Paul <lyude@redhat.com>
Reviewed-by: James Jones <jajones@nvidia.com>
Signed-off-by: Lyude Paul <lyude@redhat.com>
Link: https://patch.msgid.link/20251110-nouveau-compv6-v6-4-83b05475f57c@mary.zone

authored by

Ben Skeggs and committed by
Lyude Paul
0ee6a72b a79d3845

+44 -2
+44 -2
drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmmgp100.c
··· 109 109 nvkm_done(pt->memory); 110 110 } 111 111 112 + static inline u64 113 + gp100_vmm_comptag_nr(u64 size) 114 + { 115 + return size >> 16; /* One comptag per 64KiB VRAM. */ 116 + } 117 + 118 + static inline u64 119 + gp100_vmm_pte_comptagline_base(u64 addr) 120 + { 121 + /* RM allocates enough comptags for all of VRAM, so use a 1:1 mapping. */ 122 + return (1 + gp100_vmm_comptag_nr(addr)) << 36; /* NV_MMU_VER2_PTE_COMPTAGLINE */ 123 + } 124 + 125 + static inline u64 126 + gp100_vmm_pte_comptagline_incr(u32 page_size) 127 + { 128 + return gp100_vmm_comptag_nr(page_size) << 36; /* NV_MMU_VER2_PTE_COMPTAGLINE */ 129 + } 130 + 112 131 static inline void 113 132 gp100_vmm_pgt_pte(struct nvkm_vmm *vmm, struct nvkm_mmu_pt *pt, 114 133 u32 ptei, u32 ptes, struct nvkm_vmm_map *map, u64 addr) 115 134 { 116 135 u64 data = (addr >> 4) | map->type; 136 + 137 + if (map->ctag) 138 + data |= gp100_vmm_pte_comptagline_base(addr); 117 139 118 140 while (ptes--) { 119 141 VMM_WO064(pt, vmm, ptei++ * 8, data); ··· 216 194 u32 ptei, u32 ptes, struct nvkm_vmm_map *map, u64 addr) 217 195 { 218 196 u64 data = (addr >> 4) | map->type; 197 + 198 + if (map->ctag) 199 + data |= gp100_vmm_pte_comptagline_base(addr); 219 200 220 201 while (ptes--) { 221 202 VMM_WO128(pt, vmm, ptei++ * 0x10, data, 0ULL); ··· 465 440 return -EINVAL; 466 441 } 467 442 443 + /* Handle compression. */ 468 444 if (kindm[kind] != kind) { 469 - /* Revert to non-compressed kind. */ 470 - kind = kindm[kind]; 445 + struct nvkm_device *device = vmm->mmu->subdev.device; 446 + 447 + /* Compression is only supported when using GSP-RM, as 448 + * PMU firmware is required in order to initialise the 449 + * compbit backing store. 450 + */ 451 + if (nvkm_gsp_rm(device->gsp)) { 452 + /* Turing GPUs require PTE_COMPTAGLINE to be filled, 453 + * in addition to specifying a compressed kind. 454 + */ 455 + if (device->card_type < GA100) { 456 + map->ctag = gp100_vmm_pte_comptagline_incr(1 << map->page->shift); 457 + map->next |= map->ctag; 458 + } 459 + } else { 460 + /* Revert to non-compressed kind. */ 461 + kind = kindm[kind]; 462 + } 471 463 } 472 464 473 465 map->type |= BIT(0);