Skip to content

Commit 708d81a

Browse files
Ben Skeggsairlied
authored andcommitted
drm/nouveau/gsp: fetch level shift and PDE from BAR2 VMM
When mirroring BAR2 page tables to RM, we need to know the level shift for the root page table (which is currently hardcoded), as well as the raw PDE value (which is currently hardcoded in GP1xx-AD1xx format). In order to support GH100/GBxxx, modify the code to determine the page shift from per-GPU info in nvkm_vmm_page, as well as read the relevant PDE back from the root page table rather than recalculating it. Signed-off-by: Ben Skeggs <[email protected]> Reviewed-by: Dave Airlie <[email protected]> Reviewed-by: Timur Tabi <[email protected]> Tested-by: Timur Tabi <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
1 parent 82df73d commit 708d81a

File tree

1 file changed

+17
-6
lines changed
  • drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/r535

1 file changed

+17
-6
lines changed

drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/r535/bar.c

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ r535_bar_bar2_wait(struct nvkm_bar *base)
5050
}
5151

5252
static int
53-
r535_bar_bar2_update_pde(struct nvkm_gsp *gsp, u64 addr)
53+
r535_bar_bar2_update_pde(struct nvkm_gsp *gsp, u8 page_shift, u64 pdbe)
5454
{
5555
rpc_update_bar_pde_v15_00 *rpc;
5656

@@ -59,21 +59,22 @@ r535_bar_bar2_update_pde(struct nvkm_gsp *gsp, u64 addr)
5959
return -EIO;
6060

6161
rpc->info.barType = NV_RPC_UPDATE_PDE_BAR_2;
62-
rpc->info.entryValue = addr ? ((addr >> 4) | 2) : 0; /* PD3 entry format! */
63-
rpc->info.entryLevelShift = 47; //XXX: probably fetch this from mmu!
62+
rpc->info.entryValue = pdbe;
63+
rpc->info.entryLevelShift = page_shift;
6464

6565
return nvkm_gsp_rpc_wr(gsp, rpc, NVKM_GSP_RPC_REPLY_RECV);
6666
}
6767

6868
static void
6969
r535_bar_bar2_fini(struct nvkm_bar *bar)
7070
{
71+
struct nvkm_vmm *vmm = gf100_bar(bar)->bar[0].vmm;
7172
struct nvkm_gsp *gsp = bar->subdev.device->gsp;
7273

7374
bar->flushBAR2 = bar->flushBAR2PhysMode;
7475
nvkm_done(bar->flushFBZero);
7576

76-
WARN_ON(r535_bar_bar2_update_pde(gsp, 0));
77+
WARN_ON(r535_bar_bar2_update_pde(gsp, vmm->func->page[0].shift, 0));
7778
}
7879

7980
static void
@@ -82,8 +83,18 @@ r535_bar_bar2_init(struct nvkm_bar *bar)
8283
struct nvkm_device *device = bar->subdev.device;
8384
struct nvkm_vmm *vmm = gf100_bar(bar)->bar[0].vmm;
8485
struct nvkm_gsp *gsp = device->gsp;
85-
86-
WARN_ON(r535_bar_bar2_update_pde(gsp, vmm->pd->pde[0]->pt[0]->addr));
86+
struct nvkm_memory *pdb = vmm->pd->pt[0]->memory;
87+
u32 pdb_offset = vmm->pd->pt[0]->base;
88+
u32 pdbe_lo, pdbe_hi;
89+
u64 pdbe;
90+
91+
nvkm_kmap(pdb);
92+
pdbe_lo = nvkm_ro32(pdb, pdb_offset + 0);
93+
pdbe_hi = nvkm_ro32(pdb, pdb_offset + 4);
94+
pdbe = ((u64)pdbe_hi << 32) | pdbe_lo;
95+
nvkm_done(pdb);
96+
97+
WARN_ON(r535_bar_bar2_update_pde(gsp, vmm->func->page[0].shift, pdbe));
8798
vmm->rm.bar2_pdb = gsp->bar.rm_bar2_pdb;
8899

89100
if (!bar->flushFBZero) {

0 commit comments

Comments
 (0)