Commit 2c0c15a2 authored by Ben Skeggs's avatar Ben Skeggs Committed by Karol Herbst

drm/nouveau/fb/gp102-ga100: switch to simpler vram size detection method

Also exposes this for use by upcoming GSP-RM initialisation code.

v2: add SPDX header
Signed-off-by: default avatarBen Skeggs <bskeggs@redhat.com>
Reviewed-by: default avatarLyude Paul <lyude@redhat.com>
Signed-off-by: default avatarKarol Herbst <kherbst@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20230525003106.3853741-3-skeggsb@gmail.com
parent ba1efd8e
...@@ -59,6 +59,7 @@ struct nvkm_fb { ...@@ -59,6 +59,7 @@ struct nvkm_fb {
struct nvkm_memory *mmu_wr; struct nvkm_memory *mmu_wr;
}; };
u64 nvkm_fb_vidmem_size(struct nvkm_device *);
int nvkm_fb_mem_unlock(struct nvkm_fb *); int nvkm_fb_mem_unlock(struct nvkm_fb *);
void nvkm_fb_tile_init(struct nvkm_fb *, int region, u32 addr, u32 size, void nvkm_fb_tile_init(struct nvkm_fb *, int region, u32 addr, u32 size,
......
...@@ -55,6 +55,7 @@ nvkm-y += nvkm/subdev/fb/ramgk104.o ...@@ -55,6 +55,7 @@ nvkm-y += nvkm/subdev/fb/ramgk104.o
nvkm-y += nvkm/subdev/fb/ramgm107.o nvkm-y += nvkm/subdev/fb/ramgm107.o
nvkm-y += nvkm/subdev/fb/ramgm200.o nvkm-y += nvkm/subdev/fb/ramgm200.o
nvkm-y += nvkm/subdev/fb/ramgp100.o nvkm-y += nvkm/subdev/fb/ramgp100.o
nvkm-y += nvkm/subdev/fb/ramgp102.o
nvkm-y += nvkm/subdev/fb/ramga102.o nvkm-y += nvkm/subdev/fb/ramga102.o
nvkm-y += nvkm/subdev/fb/sddr2.o nvkm-y += nvkm/subdev/fb/sddr2.o
nvkm-y += nvkm/subdev/fb/sddr3.o nvkm-y += nvkm/subdev/fb/sddr3.o
......
...@@ -174,6 +174,18 @@ nvkm_fb_mem_unlock(struct nvkm_fb *fb) ...@@ -174,6 +174,18 @@ nvkm_fb_mem_unlock(struct nvkm_fb *fb)
return 0; return 0;
} }
u64
nvkm_fb_vidmem_size(struct nvkm_device *device)
{
struct nvkm_fb *fb = device->fb;
if (fb && fb->func->vidmem.size)
return fb->func->vidmem.size(fb);
WARN_ON(1);
return 0;
}
static int static int
nvkm_fb_init(struct nvkm_subdev *subdev) nvkm_fb_init(struct nvkm_subdev *subdev)
{ {
......
...@@ -30,7 +30,8 @@ ga100_fb = { ...@@ -30,7 +30,8 @@ ga100_fb = {
.init_page = gv100_fb_init_page, .init_page = gv100_fb_init_page,
.init_unkn = gp100_fb_init_unkn, .init_unkn = gp100_fb_init_unkn,
.sysmem.flush_page_init = gf100_fb_sysmem_flush_page_init, .sysmem.flush_page_init = gf100_fb_sysmem_flush_page_init,
.ram_new = gp100_ram_new, .vidmem.size = gp102_fb_vidmem_size,
.ram_new = gp102_ram_new,
.default_bigpage = 16, .default_bigpage = 16,
}; };
......
...@@ -40,6 +40,20 @@ gp102_fb_vpr_scrub_required(struct nvkm_fb *fb) ...@@ -40,6 +40,20 @@ gp102_fb_vpr_scrub_required(struct nvkm_fb *fb)
return (nvkm_rd32(device, 0x100cd0) & 0x00000010) != 0; return (nvkm_rd32(device, 0x100cd0) & 0x00000010) != 0;
} }
u64
gp102_fb_vidmem_size(struct nvkm_fb *fb)
{
const u32 data = nvkm_rd32(fb->subdev.device, 0x100ce0);
const u32 lmag = (data & 0x000003f0) >> 4;
const u32 lsca = (data & 0x0000000f);
const u64 size = (u64)lmag << (lsca + 20);
if (data & 0x40000000)
return size / 16 * 15;
return size;
}
int int
gp102_fb_oneinit(struct nvkm_fb *fb) gp102_fb_oneinit(struct nvkm_fb *fb)
{ {
...@@ -59,9 +73,10 @@ gp102_fb = { ...@@ -59,9 +73,10 @@ gp102_fb = {
.init_remapper = gp100_fb_init_remapper, .init_remapper = gp100_fb_init_remapper,
.init_page = gm200_fb_init_page, .init_page = gm200_fb_init_page,
.sysmem.flush_page_init = gf100_fb_sysmem_flush_page_init, .sysmem.flush_page_init = gf100_fb_sysmem_flush_page_init,
.vidmem.size = gp102_fb_vidmem_size,
.vpr.scrub_required = gp102_fb_vpr_scrub_required, .vpr.scrub_required = gp102_fb_vpr_scrub_required,
.vpr.scrub = gp102_fb_vpr_scrub, .vpr.scrub = gp102_fb_vpr_scrub,
.ram_new = gp100_ram_new, .ram_new = gp102_ram_new,
}; };
int int
......
...@@ -36,9 +36,10 @@ gv100_fb = { ...@@ -36,9 +36,10 @@ gv100_fb = {
.init_page = gv100_fb_init_page, .init_page = gv100_fb_init_page,
.init_unkn = gp100_fb_init_unkn, .init_unkn = gp100_fb_init_unkn,
.sysmem.flush_page_init = gf100_fb_sysmem_flush_page_init, .sysmem.flush_page_init = gf100_fb_sysmem_flush_page_init,
.vidmem.size = gp102_fb_vidmem_size,
.vpr.scrub_required = gp102_fb_vpr_scrub_required, .vpr.scrub_required = gp102_fb_vpr_scrub_required,
.vpr.scrub = gp102_fb_vpr_scrub, .vpr.scrub = gp102_fb_vpr_scrub,
.ram_new = gp100_ram_new, .ram_new = gp102_ram_new,
.default_bigpage = 16, .default_bigpage = 16,
}; };
......
...@@ -20,6 +20,10 @@ struct nvkm_fb_func { ...@@ -20,6 +20,10 @@ struct nvkm_fb_func {
void (*flush_page_init)(struct nvkm_fb *); void (*flush_page_init)(struct nvkm_fb *);
} sysmem; } sysmem;
struct nvkm_fb_func_vidmem {
u64 (*size)(struct nvkm_fb *);
} vidmem;
struct { struct {
bool (*scrub_required)(struct nvkm_fb *); bool (*scrub_required)(struct nvkm_fb *);
int (*scrub)(struct nvkm_fb *); int (*scrub)(struct nvkm_fb *);
...@@ -84,6 +88,7 @@ void gp100_fb_init_remapper(struct nvkm_fb *); ...@@ -84,6 +88,7 @@ void gp100_fb_init_remapper(struct nvkm_fb *);
void gp100_fb_init_unkn(struct nvkm_fb *); void gp100_fb_init_unkn(struct nvkm_fb *);
int gp102_fb_oneinit(struct nvkm_fb *); int gp102_fb_oneinit(struct nvkm_fb *);
u64 gp102_fb_vidmem_size(struct nvkm_fb *);
bool gp102_fb_vpr_scrub_required(struct nvkm_fb *); bool gp102_fb_vpr_scrub_required(struct nvkm_fb *);
int gp102_fb_vpr_scrub(struct nvkm_fb *); int gp102_fb_vpr_scrub(struct nvkm_fb *);
......
...@@ -70,5 +70,6 @@ int gk104_ram_new(struct nvkm_fb *, struct nvkm_ram **); ...@@ -70,5 +70,6 @@ int gk104_ram_new(struct nvkm_fb *, struct nvkm_ram **);
int gm107_ram_new(struct nvkm_fb *, struct nvkm_ram **); int gm107_ram_new(struct nvkm_fb *, struct nvkm_ram **);
int gm200_ram_new(struct nvkm_fb *, struct nvkm_ram **); int gm200_ram_new(struct nvkm_fb *, struct nvkm_ram **);
int gp100_ram_new(struct nvkm_fb *, struct nvkm_ram **); int gp100_ram_new(struct nvkm_fb *, struct nvkm_ram **);
int gp102_ram_new(struct nvkm_fb *, struct nvkm_ram **);
int ga102_ram_new(struct nvkm_fb *, struct nvkm_ram **); int ga102_ram_new(struct nvkm_fb *, struct nvkm_ram **);
#endif #endif
// SPDX-License-Identifier: MIT
#include "ram.h"
#include <subdev/bios.h>
static const struct nvkm_ram_func
gp102_ram = {
};
int
gp102_ram_new(struct nvkm_fb *fb, struct nvkm_ram **pram)
{
enum nvkm_ram_type type = nvkm_fb_bios_memtype(fb->subdev.device->bios);
const u32 rsvd_head = ( 256 * 1024); /* vga memory */
const u32 rsvd_tail = (1024 * 1024); /* vbios etc */
u64 size = fb->func->vidmem.size(fb);
int ret;
ret = nvkm_ram_new_(&gp102_ram, fb, type, size, pram);
if (ret)
return ret;
nvkm_mm_fini(&(*pram)->vram);
return nvkm_mm_init(&(*pram)->vram, NVKM_RAM_MM_NORMAL,
rsvd_head >> NVKM_RAM_MM_SHIFT,
(size - rsvd_head - rsvd_tail) >> NVKM_RAM_MM_SHIFT,
1);
}
...@@ -36,9 +36,10 @@ tu102_fb = { ...@@ -36,9 +36,10 @@ tu102_fb = {
.init_page = gv100_fb_init_page, .init_page = gv100_fb_init_page,
.init_unkn = gp100_fb_init_unkn, .init_unkn = gp100_fb_init_unkn,
.sysmem.flush_page_init = gf100_fb_sysmem_flush_page_init, .sysmem.flush_page_init = gf100_fb_sysmem_flush_page_init,
.vidmem.size = gp102_fb_vidmem_size,
.vpr.scrub_required = tu102_fb_vpr_scrub_required, .vpr.scrub_required = tu102_fb_vpr_scrub_required,
.vpr.scrub = gp102_fb_vpr_scrub, .vpr.scrub = gp102_fb_vpr_scrub,
.ram_new = gp100_ram_new, .ram_new = gp102_ram_new,
.default_bigpage = 16, .default_bigpage = 16,
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment