drm/nouveau/fb/tu102-: prepare for GSP-RM
- add (initial) R535 implementation of FB, need VRAM size etc for boot - expose a way to "wrap" vram at a specific address/size as a standard nvkm_memory allocation, which will be used to write PTEs etc for RM- defined memory regions Signed-off-by: Ben Skeggs <bskeggs@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> Link: https://patchwork.freedesktop.org/patch/msgid/20230918202149.4343-11-skeggsb@gmail.com
This commit is contained in:
parent
a613e7f3fe
commit
834a712b6e
@ -158,9 +158,9 @@ struct nvkm_ram {
|
||||
struct nvkm_ram_data target;
|
||||
};
|
||||
|
||||
int
|
||||
nvkm_ram_get(struct nvkm_device *, u8 heap, u8 type, u8 page, u64 size,
|
||||
bool contig, bool back, struct nvkm_memory **);
|
||||
int nvkm_ram_wrap(struct nvkm_device *, u64 addr, u64 size, struct nvkm_memory **);
|
||||
int nvkm_ram_get(struct nvkm_device *, u8 heap, u8 type, u8 page, u64 size,
|
||||
bool contig, bool back, struct nvkm_memory **);
|
||||
|
||||
struct nvkm_ram_func {
|
||||
u64 upper;
|
||||
|
@ -36,6 +36,8 @@ nvkm-y += nvkm/subdev/fb/tu102.o
|
||||
nvkm-y += nvkm/subdev/fb/ga100.o
|
||||
nvkm-y += nvkm/subdev/fb/ga102.o
|
||||
|
||||
nvkm-y += nvkm/subdev/fb/r535.o
|
||||
|
||||
nvkm-y += nvkm/subdev/fb/ram.o
|
||||
nvkm-y += nvkm/subdev/fb/ramnv04.o
|
||||
nvkm-y += nvkm/subdev/fb/ramnv10.o
|
||||
|
@ -22,6 +22,8 @@
|
||||
#include "gf100.h"
|
||||
#include "ram.h"
|
||||
|
||||
#include <subdev/gsp.h>
|
||||
|
||||
static const struct nvkm_fb_func
|
||||
ga100_fb = {
|
||||
.dtor = gf100_fb_dtor,
|
||||
@ -38,5 +40,8 @@ ga100_fb = {
|
||||
int
|
||||
ga100_fb_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst, struct nvkm_fb **pfb)
|
||||
{
|
||||
if (nvkm_gsp_rm(device->gsp))
|
||||
return r535_fb_new(&ga100_fb, device, type, inst, pfb);
|
||||
|
||||
return gf100_fb_new_(&ga100_fb, device, type, inst, pfb);
|
||||
}
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "gf100.h"
|
||||
#include "ram.h"
|
||||
|
||||
#include <subdev/gsp.h>
|
||||
#include <engine/nvdec.h>
|
||||
|
||||
static u64
|
||||
@ -59,6 +60,9 @@ ga102_fb = {
|
||||
int
|
||||
ga102_fb_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst, struct nvkm_fb **pfb)
|
||||
{
|
||||
if (nvkm_gsp_rm(device->gsp))
|
||||
return r535_fb_new(&ga102_fb, device, type, inst, pfb);
|
||||
|
||||
return gf100_fb_new_(&ga102_fb, device, type, inst, pfb);
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,9 @@
|
||||
#include <subdev/therm.h>
|
||||
struct nvkm_bios;
|
||||
|
||||
int r535_fb_new(const struct nvkm_fb_func *,
|
||||
struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nvkm_fb **);
|
||||
|
||||
struct nvkm_fb_func {
|
||||
void *(*dtor)(struct nvkm_fb *);
|
||||
u32 (*tags)(struct nvkm_fb *);
|
||||
|
50
drivers/gpu/drm/nouveau/nvkm/subdev/fb/r535.c
Normal file
50
drivers/gpu/drm/nouveau/nvkm/subdev/fb/r535.c
Normal file
@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright 2023 Red Hat Inc.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
#include "priv.h"
|
||||
|
||||
static void *
|
||||
r535_fb_dtor(struct nvkm_fb *fb)
|
||||
{
|
||||
kfree(fb->func);
|
||||
return fb;
|
||||
}
|
||||
|
||||
int
|
||||
r535_fb_new(const struct nvkm_fb_func *hw,
|
||||
struct nvkm_device *device, enum nvkm_subdev_type type, int inst, struct nvkm_fb **pfb)
|
||||
{
|
||||
struct nvkm_fb_func *rm;
|
||||
int ret;
|
||||
|
||||
if (!(rm = kzalloc(sizeof(*rm), GFP_KERNEL)))
|
||||
return -ENOMEM;
|
||||
|
||||
rm->dtor = r535_fb_dtor;
|
||||
rm->sysmem.flush_page_init = hw->sysmem.flush_page_init;
|
||||
rm->vidmem.size = hw->vidmem.size;
|
||||
|
||||
ret = nvkm_fb_new_(rm, device, type, inst, pfb);
|
||||
if (ret)
|
||||
kfree(rm);
|
||||
|
||||
return ret;
|
||||
}
|
@ -88,12 +88,20 @@ nvkm_vram_dtor(struct nvkm_memory *memory)
|
||||
struct nvkm_vram *vram = nvkm_vram(memory);
|
||||
struct nvkm_mm_node *next = vram->mn;
|
||||
struct nvkm_mm_node *node;
|
||||
mutex_lock(&vram->ram->mutex);
|
||||
while ((node = next)) {
|
||||
next = node->next;
|
||||
nvkm_mm_free(&vram->ram->vram, &node);
|
||||
|
||||
if (next) {
|
||||
if (likely(next->nl_entry.next)){
|
||||
mutex_lock(&vram->ram->mutex);
|
||||
while ((node = next)) {
|
||||
next = node->next;
|
||||
nvkm_mm_free(&vram->ram->vram, &node);
|
||||
}
|
||||
mutex_unlock(&vram->ram->mutex);
|
||||
} else {
|
||||
kfree(vram->mn);
|
||||
}
|
||||
}
|
||||
mutex_unlock(&vram->ram->mutex);
|
||||
|
||||
return vram;
|
||||
}
|
||||
|
||||
@ -108,6 +116,34 @@ nvkm_vram = {
|
||||
.kmap = nvkm_vram_kmap,
|
||||
};
|
||||
|
||||
int
|
||||
nvkm_ram_wrap(struct nvkm_device *device, u64 addr, u64 size,
|
||||
struct nvkm_memory **pmemory)
|
||||
{
|
||||
struct nvkm_ram *ram;
|
||||
struct nvkm_vram *vram;
|
||||
|
||||
if (!device->fb || !(ram = device->fb->ram))
|
||||
return -ENODEV;
|
||||
ram = device->fb->ram;
|
||||
|
||||
if (!(vram = kzalloc(sizeof(*vram), GFP_KERNEL)))
|
||||
return -ENOMEM;
|
||||
|
||||
nvkm_memory_ctor(&nvkm_vram, &vram->memory);
|
||||
vram->ram = ram;
|
||||
vram->page = NVKM_RAM_MM_SHIFT;
|
||||
*pmemory = &vram->memory;
|
||||
|
||||
vram->mn = kzalloc(sizeof(*vram->mn), GFP_KERNEL);
|
||||
if (!vram->mn)
|
||||
return -ENOMEM;
|
||||
|
||||
vram->mn->offset = addr >> NVKM_RAM_MM_SHIFT;
|
||||
vram->mn->length = size >> NVKM_RAM_MM_SHIFT;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
nvkm_ram_get(struct nvkm_device *device, u8 heap, u8 type, u8 rpage, u64 size,
|
||||
bool contig, bool back, struct nvkm_memory **pmemory)
|
||||
|
@ -22,6 +22,8 @@
|
||||
#include "gf100.h"
|
||||
#include "ram.h"
|
||||
|
||||
#include <subdev/gsp.h>
|
||||
|
||||
bool
|
||||
tu102_fb_vpr_scrub_required(struct nvkm_fb *fb)
|
||||
{
|
||||
@ -46,6 +48,9 @@ tu102_fb = {
|
||||
int
|
||||
tu102_fb_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst, struct nvkm_fb **pfb)
|
||||
{
|
||||
if (nvkm_gsp_rm(device->gsp))
|
||||
return r535_fb_new(&tu102_fb, device, type, inst, pfb);
|
||||
|
||||
return gf100_fb_new_(&tu102_fb, device, type, inst, pfb);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user