Skip to content

Commit 0ee6a72

Browse files
Ben SkeggsLyude
authored andcommitted
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
1 parent a79d384 commit 0ee6a72

1 file changed

Lines changed: 44 additions & 2 deletions

File tree

drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmmgp100.c

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,34 @@ gp100_vmm_pgt_pfn(struct nvkm_vmm *vmm, struct nvkm_mmu_pt *pt,
109109
nvkm_done(pt->memory);
110110
}
111111

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+
112131
static inline void
113132
gp100_vmm_pgt_pte(struct nvkm_vmm *vmm, struct nvkm_mmu_pt *pt,
114133
u32 ptei, u32 ptes, struct nvkm_vmm_map *map, u64 addr)
115134
{
116135
u64 data = (addr >> 4) | map->type;
117136

137+
if (map->ctag)
138+
data |= gp100_vmm_pte_comptagline_base(addr);
139+
118140
while (ptes--) {
119141
VMM_WO064(pt, vmm, ptei++ * 8, data);
120142
data += map->next;
@@ -195,6 +217,9 @@ gp100_vmm_pd0_pte(struct nvkm_vmm *vmm, struct nvkm_mmu_pt *pt,
195217
{
196218
u64 data = (addr >> 4) | map->type;
197219

220+
if (map->ctag)
221+
data |= gp100_vmm_pte_comptagline_base(addr);
222+
198223
while (ptes--) {
199224
VMM_WO128(pt, vmm, ptei++ * 0x10, data, 0ULL);
200225
data += map->next;
@@ -440,9 +465,26 @@ gp100_vmm_valid(struct nvkm_vmm *vmm, void *argv, u32 argc,
440465
return -EINVAL;
441466
}
442467

468+
/* Handle compression. */
443469
if (kindm[kind] != kind) {
444-
/* Revert to non-compressed kind. */
445-
kind = kindm[kind];
470+
struct nvkm_device *device = vmm->mmu->subdev.device;
471+
472+
/* Compression is only supported when using GSP-RM, as
473+
* PMU firmware is required in order to initialise the
474+
* compbit backing store.
475+
*/
476+
if (nvkm_gsp_rm(device->gsp)) {
477+
/* Turing GPUs require PTE_COMPTAGLINE to be filled,
478+
* in addition to specifying a compressed kind.
479+
*/
480+
if (device->card_type < GA100) {
481+
map->ctag = gp100_vmm_pte_comptagline_incr(1 << map->page->shift);
482+
map->next |= map->ctag;
483+
}
484+
} else {
485+
/* Revert to non-compressed kind. */
486+
kind = kindm[kind];
487+
}
446488
}
447489

448490
map->type |= BIT(0);

0 commit comments

Comments
 (0)