Skip to content

Commit

Permalink
drm/nouveau/fifo: add chid_nr()
Browse files Browse the repository at this point in the history
- reads channel count from GPU from gm200 onwards
- removes gm20b/gp10b (they become identical to gm200/gp100)

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
Reviewed-by: Lyude Paul <lyude@redhat.com>
  • Loading branch information
Ben Skeggs committed Nov 9, 2022
1 parent 973b324 commit 8c18138
Show file tree
Hide file tree
Showing 25 changed files with 114 additions and 137 deletions.
1 change: 1 addition & 0 deletions drivers/gpu/drm/nouveau/include/nvkm/core/os.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,5 @@ nvkm_blob_dtor(struct nvkm_blob *blob)
blob->data = NULL;
blob->size = 0;
}

#endif
2 changes: 0 additions & 2 deletions drivers/gpu/drm/nouveau/include/nvkm/engine/fifo.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,7 @@ int gk208_fifo_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct
int gk20a_fifo_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nvkm_fifo **);
int gm107_fifo_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nvkm_fifo **);
int gm200_fifo_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nvkm_fifo **);
int gm20b_fifo_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nvkm_fifo **);
int gp100_fifo_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nvkm_fifo **);
int gp10b_fifo_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nvkm_fifo **);
int gv100_fifo_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nvkm_fifo **);
int tu102_fifo_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nvkm_fifo **);
int ga102_fifo_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nvkm_fifo **);
Expand Down
4 changes: 2 additions & 2 deletions drivers/gpu/drm/nouveau/nvkm/engine/device/base.c
Original file line number Diff line number Diff line change
Expand Up @@ -2130,7 +2130,7 @@ nv12b_chipset = {
.volt = { 0x00000001, gm20b_volt_new },
.ce = { 0x00000004, gm200_ce_new },
.dma = { 0x00000001, gf119_dma_new },
.fifo = { 0x00000001, gm20b_fifo_new },
.fifo = { 0x00000001, gm200_fifo_new },
.gr = { 0x00000001, gm20b_gr_new },
.sw = { 0x00000001, gf100_sw_new },
};
Expand Down Expand Up @@ -2356,7 +2356,7 @@ nv13b_chipset = {
.top = { 0x00000001, gk104_top_new },
.ce = { 0x00000001, gp100_ce_new },
.dma = { 0x00000001, gf119_dma_new },
.fifo = { 0x00000001, gp10b_fifo_new },
.fifo = { 0x00000001, gp100_fifo_new },
.gr = { 0x00000001, gp10b_gr_new },
.sw = { 0x00000001, gf100_sw_new },
};
Expand Down
2 changes: 0 additions & 2 deletions drivers/gpu/drm/nouveau/nvkm/engine/fifo/Kbuild
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ nvkm-y += nvkm/engine/fifo/gk208.o
nvkm-y += nvkm/engine/fifo/gk20a.o
nvkm-y += nvkm/engine/fifo/gm107.o
nvkm-y += nvkm/engine/fifo/gm200.o
nvkm-y += nvkm/engine/fifo/gm20b.o
nvkm-y += nvkm/engine/fifo/gp100.o
nvkm-y += nvkm/engine/fifo/gp10b.o
nvkm-y += nvkm/engine/fifo/gv100.o
nvkm-y += nvkm/engine/fifo/tu102.o
nvkm-y += nvkm/engine/fifo/ga102.o
Expand Down
20 changes: 11 additions & 9 deletions drivers/gpu/drm/nouveau/nvkm/engine/fifo/base.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@
#include "priv.h"
#include "chan.h"

#include <core/client.h>
#include <core/gpuobj.h>
#include <subdev/mc.h>

#include <nvif/event.h>
#include <nvif/cl0080.h>
#include <nvif/unpack.h>

#include "gk104.h"

void
nvkm_fifo_recover_chan(struct nvkm_fifo *fifo, int chid)
{
Expand Down Expand Up @@ -290,25 +290,27 @@ nvkm_fifo = {

int
nvkm_fifo_ctor(const struct nvkm_fifo_func *func, struct nvkm_device *device,
enum nvkm_subdev_type type, int inst, int nr, struct nvkm_fifo *fifo)
enum nvkm_subdev_type type, int inst, struct nvkm_fifo *fifo)
{
int ret;
int ret, nr;

fifo->func = func;
INIT_LIST_HEAD(&fifo->chan);
spin_lock_init(&fifo->lock);
mutex_init(&fifo->mutex);

ret = nvkm_engine_ctor(&nvkm_fifo, device, type, inst, true, &fifo->engine);
if (ret)
return ret;

INIT_LIST_HEAD(&fifo->chan);

nr = func->chid_nr ? func->chid_nr(fifo) : gk104_fifo(fifo)->func->chid_nr(fifo);
if (WARN_ON(fifo->nr > NVKM_FIFO_CHID_NR))
fifo->nr = NVKM_FIFO_CHID_NR;
else
fifo->nr = nr;
bitmap_clear(fifo->mask, 0, fifo->nr);

ret = nvkm_engine_ctor(&nvkm_fifo, device, type, inst, true, &fifo->engine);
if (ret)
return ret;

if (func->uevent_init) {
ret = nvkm_event_init(&nvkm_fifo_uevent_func, &fifo->engine.subdev, 1, 1,
&fifo->uevent);
Expand Down
1 change: 1 addition & 0 deletions drivers/gpu/drm/nouveau/nvkm/engine/fifo/g84.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ static const struct nvkm_fifo_func
g84_fifo = {
.dtor = nv50_fifo_dtor,
.oneinit = nv50_fifo_oneinit,
.chid_nr = nv50_fifo_chid_nr,
.init = nv50_fifo_init,
.intr = nv04_fifo_intr,
.engine_id = g84_fifo_engine_id,
Expand Down
3 changes: 2 additions & 1 deletion drivers/gpu/drm/nouveau/nvkm/engine/fifo/gf100.c
Original file line number Diff line number Diff line change
Expand Up @@ -669,6 +669,7 @@ static const struct nvkm_fifo_func
gf100_fifo = {
.dtor = gf100_fifo_dtor,
.oneinit = gf100_fifo_oneinit,
.chid_nr = nv50_fifo_chid_nr,
.init = gf100_fifo_init,
.fini = gf100_fifo_fini,
.intr = gf100_fifo_intr,
Expand All @@ -695,5 +696,5 @@ gf100_fifo_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst,
INIT_WORK(&fifo->recover.work, gf100_fifo_recover_work);
*pfifo = &fifo->base;

return nvkm_fifo_ctor(&gf100_fifo, device, type, inst, 128, &fifo->base);
return nvkm_fifo_ctor(&gf100_fifo, device, type, inst, &fifo->base);
}
11 changes: 9 additions & 2 deletions drivers/gpu/drm/nouveau/nvkm/engine/fifo/gk104.c
Original file line number Diff line number Diff line change
Expand Up @@ -1055,6 +1055,12 @@ gk104_fifo_init(struct nvkm_fifo *base)
nvkm_wr32(device, 0x002140, 0x7fffffff);
}

int
gk104_fifo_chid_nr(struct nvkm_fifo *fifo)
{
return 4096;
}

void *
gk104_fifo_dtor(struct nvkm_fifo *base)
{
Expand Down Expand Up @@ -1103,7 +1109,7 @@ gk104_fifo_new_(const struct gk104_fifo_func *func, struct nvkm_device *device,
INIT_WORK(&fifo->recover.work, gk104_fifo_recover_work);
*pfifo = &fifo->base;

return nvkm_fifo_ctor(&gk104_fifo_, device, type, inst, nr, &fifo->base);
return nvkm_fifo_ctor(&gk104_fifo_, device, type, inst, &fifo->base);
}

const struct nvkm_enum
Expand Down Expand Up @@ -1230,6 +1236,7 @@ gk104_fifo_fault_gpcclient[] = {

static const struct gk104_fifo_func
gk104_fifo = {
.chid_nr = gk104_fifo_chid_nr,
.intr.fault = gf100_fifo_intr_fault,
.pbdma = &gk104_fifo_pbdma,
.fault.access = gk104_fifo_fault_access,
Expand All @@ -1245,5 +1252,5 @@ int
gk104_fifo_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst,
struct nvkm_fifo **pfifo)
{
return gk104_fifo_new_(&gk104_fifo, device, type, inst, 4096, pfifo);
return gk104_fifo_new_(&gk104_fifo, device, type, inst, 0, pfifo);
}
2 changes: 2 additions & 0 deletions drivers/gpu/drm/nouveau/nvkm/engine/fifo/gk104.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ struct gk104_fifo {
};

struct gk104_fifo_func {
int (*chid_nr)(struct nvkm_fifo *);

struct {
void (*fault)(struct nvkm_fifo *, int unit);
} intr;
Expand Down
3 changes: 2 additions & 1 deletion drivers/gpu/drm/nouveau/nvkm/engine/fifo/gk110.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ gk110_fifo_runlist = {

static const struct gk104_fifo_func
gk110_fifo = {
.chid_nr = gk104_fifo_chid_nr,
.intr.fault = gf100_fifo_intr_fault,
.pbdma = &gk104_fifo_pbdma,
.fault.access = gk104_fifo_fault_access,
Expand All @@ -63,5 +64,5 @@ int
gk110_fifo_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst,
struct nvkm_fifo **pfifo)
{
return gk104_fifo_new_(&gk110_fifo, device, type, inst, 4096, pfifo);
return gk104_fifo_new_(&gk110_fifo, device, type, inst, 0, pfifo);
}
9 changes: 8 additions & 1 deletion drivers/gpu/drm/nouveau/nvkm/engine/fifo/gk208.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,15 @@ gk208_fifo_pbdma = {
.init_timeout = gk208_fifo_pbdma_init_timeout,
};

static int
gk208_fifo_chid_nr(struct nvkm_fifo *fifo)
{
return 1024;
}

static const struct gk104_fifo_func
gk208_fifo = {
.chid_nr = gk208_fifo_chid_nr,
.intr.fault = gf100_fifo_intr_fault,
.pbdma = &gk208_fifo_pbdma,
.fault.access = gk104_fifo_fault_access,
Expand All @@ -60,5 +67,5 @@ int
gk208_fifo_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst,
struct nvkm_fifo **pfifo)
{
return gk104_fifo_new_(&gk208_fifo, device, type, inst, 1024, pfifo);
return gk104_fifo_new_(&gk208_fifo, device, type, inst, 0, pfifo);
}
3 changes: 2 additions & 1 deletion drivers/gpu/drm/nouveau/nvkm/engine/fifo/gk20a.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

static const struct gk104_fifo_func
gk20a_fifo = {
.chid_nr = nv50_fifo_chid_nr,
.intr.fault = gf100_fifo_intr_fault,
.pbdma = &gk208_fifo_pbdma,
.fault.access = gk104_fifo_fault_access,
Expand All @@ -41,5 +42,5 @@ int
gk20a_fifo_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst,
struct nvkm_fifo **pfifo)
{
return gk104_fifo_new_(&gk20a_fifo, device, type, inst, 128, pfifo);
return gk104_fifo_new_(&gk20a_fifo, device, type, inst, 0, pfifo);
}
9 changes: 8 additions & 1 deletion drivers/gpu/drm/nouveau/nvkm/engine/fifo/gm107.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,15 @@ gm107_fifo_intr_fault(struct nvkm_fifo *fifo, int unit)
nvkm_fifo_fault(fifo, &info);
}

static int
gm107_fifo_chid_nr(struct nvkm_fifo *fifo)
{
return 2048;
}

static const struct gk104_fifo_func
gm107_fifo = {
.chid_nr = gm107_fifo_chid_nr,
.intr.fault = gm107_fifo_intr_fault,
.pbdma = &gk208_fifo_pbdma,
.fault.access = gk104_fifo_fault_access,
Expand All @@ -109,5 +116,5 @@ int
gm107_fifo_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst,
struct nvkm_fifo **pfifo)
{
return gk104_fifo_new_(&gm107_fifo, device, type, inst, 2048, pfifo);
return gk104_fifo_new_(&gm107_fifo, device, type, inst, 0, pfifo);
}
9 changes: 8 additions & 1 deletion drivers/gpu/drm/nouveau/nvkm/engine/fifo/gm200.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,15 @@ gm200_fifo_pbdma = {
.init_timeout = gk208_fifo_pbdma_init_timeout,
};

int
gm200_fifo_chid_nr(struct nvkm_fifo *fifo)
{
return nvkm_rd32(fifo->engine.subdev.device, 0x002008);
}

static const struct gk104_fifo_func
gm200_fifo = {
.chid_nr = gm200_fifo_chid_nr,
.intr.fault = gm107_fifo_intr_fault,
.pbdma = &gm200_fifo_pbdma,
.fault.access = gk104_fifo_fault_access,
Expand All @@ -57,5 +64,5 @@ int
gm200_fifo_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst,
struct nvkm_fifo **pfifo)
{
return gk104_fifo_new_(&gm200_fifo, device, type, inst, 4096, pfifo);
return gk104_fifo_new_(&gm200_fifo, device, type, inst, 0, pfifo);
}
45 changes: 0 additions & 45 deletions drivers/gpu/drm/nouveau/nvkm/engine/fifo/gm20b.c

This file was deleted.

3 changes: 2 additions & 1 deletion drivers/gpu/drm/nouveau/nvkm/engine/fifo/gp100.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ gp100_fifo_intr_fault(struct nvkm_fifo *fifo, int unit)

static const struct gk104_fifo_func
gp100_fifo = {
.chid_nr = gm200_fifo_chid_nr,
.intr.fault = gp100_fifo_intr_fault,
.pbdma = &gm200_fifo_pbdma,
.fault.access = gk104_fifo_fault_access,
Expand All @@ -94,5 +95,5 @@ int
gp100_fifo_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst,
struct nvkm_fifo **pfifo)
{
return gk104_fifo_new_(&gp100_fifo, device, type, inst, 4096, pfifo);
return gk104_fifo_new_(&gp100_fifo, device, type, inst, 0, pfifo);
}
46 changes: 0 additions & 46 deletions drivers/gpu/drm/nouveau/nvkm/engine/fifo/gp10b.c

This file was deleted.

3 changes: 2 additions & 1 deletion drivers/gpu/drm/nouveau/nvkm/engine/fifo/gv100.c
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ gv100_fifo_fault_access[] = {

static const struct gk104_fifo_func
gv100_fifo = {
.chid_nr = gm200_fifo_chid_nr,
.pbdma = &gm200_fifo_pbdma,
.fault.access = gv100_fifo_fault_access,
.fault.engine = gv100_fifo_fault_engine,
Expand All @@ -302,5 +303,5 @@ int
gv100_fifo_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst,
struct nvkm_fifo **pfifo)
{
return gk104_fifo_new_(&gv100_fifo, device, type, inst, 4096, pfifo);
return gk104_fifo_new_(&gv100_fifo, device, type, inst, 0, pfifo);
}
Loading

0 comments on commit 8c18138

Please sign in to comment.