Commit da1fbcc0 authored by Ben Skeggs's avatar Ben Skeggs Committed by Dave Airlie

drm/nouveau/fifo/tu102-: prepare for GSP-RM

- (temporarily) disable if GSP-RM detected, will be added later
- add dtor() so GSP-RM paths can cleanup properly
- add alternate engine context mapping interface for RM engines
- add alternate chid interfaces to handle RM USERD oddities
Signed-off-by: default avatarBen Skeggs <bskeggs@redhat.com>
Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20230918202149.4343-26-skeggsb@gmail.com
parent 8c186c83
...@@ -66,6 +66,9 @@ struct nvkm_fifo { ...@@ -66,6 +66,9 @@ struct nvkm_fifo {
struct { struct {
struct nvkm_memory *mem; struct nvkm_memory *mem;
struct nvkm_vma *bar1; struct nvkm_vma *bar1;
struct mutex mutex;
struct list_head list;
} userd; } userd;
spinlock_t lock; spinlock_t lock;
......
...@@ -347,8 +347,14 @@ nvkm_fifo_dtor(struct nvkm_engine *engine) ...@@ -347,8 +347,14 @@ nvkm_fifo_dtor(struct nvkm_engine *engine)
nvkm_chid_unref(&fifo->cgid); nvkm_chid_unref(&fifo->cgid);
nvkm_chid_unref(&fifo->chid); nvkm_chid_unref(&fifo->chid);
mutex_destroy(&fifo->userd.mutex);
nvkm_event_fini(&fifo->nonstall.event); nvkm_event_fini(&fifo->nonstall.event);
mutex_destroy(&fifo->mutex); mutex_destroy(&fifo->mutex);
if (fifo->func->dtor)
fifo->func->dtor(fifo);
return fifo; return fifo;
} }
...@@ -383,5 +389,8 @@ nvkm_fifo_new_(const struct nvkm_fifo_func *func, struct nvkm_device *device, ...@@ -383,5 +389,8 @@ nvkm_fifo_new_(const struct nvkm_fifo_func *func, struct nvkm_device *device,
spin_lock_init(&fifo->lock); spin_lock_init(&fifo->lock);
mutex_init(&fifo->mutex); mutex_init(&fifo->mutex);
INIT_LIST_HEAD(&fifo->userd.list);
mutex_init(&fifo->userd.mutex);
return nvkm_engine_ctor(&nvkm_fifo, device, type, inst, true, &fifo->engine); return nvkm_engine_ctor(&nvkm_fifo, device, type, inst, true, &fifo->engine);
} }
...@@ -156,6 +156,9 @@ nvkm_cgrp_vctx_get(struct nvkm_cgrp *cgrp, struct nvkm_engn *engn, struct nvkm_c ...@@ -156,6 +156,9 @@ nvkm_cgrp_vctx_get(struct nvkm_cgrp *cgrp, struct nvkm_engn *engn, struct nvkm_c
atomic_inc(&vctx->vmm->engref[engn->engine->subdev.type]); atomic_inc(&vctx->vmm->engref[engn->engine->subdev.type]);
/* Allocate the HW structures. */ /* Allocate the HW structures. */
if (engn->func->ctor2) {
ret = engn->func->ctor2(engn, vctx, chan);
} else
if (engn->func->bind) { if (engn->func->bind) {
ret = nvkm_object_bind(vctx->ectx->object, NULL, 0, &vctx->inst); ret = nvkm_object_bind(vctx->ectx->object, NULL, 0, &vctx->inst);
if (ret == 0 && engn->func->ctor) if (ret == 0 && engn->func->ctor)
......
...@@ -275,13 +275,17 @@ nvkm_chan_del(struct nvkm_chan **pchan) ...@@ -275,13 +275,17 @@ nvkm_chan_del(struct nvkm_chan **pchan)
nvkm_gpuobj_del(&chan->cache); nvkm_gpuobj_del(&chan->cache);
nvkm_gpuobj_del(&chan->ramfc); nvkm_gpuobj_del(&chan->ramfc);
nvkm_memory_unref(&chan->userd.mem);
if (chan->cgrp) { if (chan->cgrp) {
if (!chan->func->id_put)
nvkm_chid_put(chan->cgrp->runl->chid, chan->id, &chan->cgrp->lock); nvkm_chid_put(chan->cgrp->runl->chid, chan->id, &chan->cgrp->lock);
else
chan->func->id_put(chan);
nvkm_cgrp_unref(&chan->cgrp); nvkm_cgrp_unref(&chan->cgrp);
} }
nvkm_memory_unref(&chan->userd.mem);
if (chan->vmm) { if (chan->vmm) {
nvkm_vmm_part(chan->vmm, chan->inst->memory); nvkm_vmm_part(chan->vmm, chan->inst->memory);
nvkm_vmm_unref(&chan->vmm); nvkm_vmm_unref(&chan->vmm);
...@@ -438,18 +442,12 @@ nvkm_chan_new_(const struct nvkm_chan_func *func, struct nvkm_runl *runl, int ru ...@@ -438,18 +442,12 @@ nvkm_chan_new_(const struct nvkm_chan_func *func, struct nvkm_runl *runl, int ru
} }
/* Allocate channel ID. */ /* Allocate channel ID. */
if (!chan->func->id_get) {
chan->id = nvkm_chid_get(runl->chid, chan); chan->id = nvkm_chid_get(runl->chid, chan);
if (chan->id < 0) { if (chan->id >= 0) {
RUNL_ERROR(runl, "!chids");
return -ENOSPC;
}
if (cgrp->id < 0)
cgrp->id = chan->id;
/* Initialise USERD. */
if (func->userd->bar < 0) { if (func->userd->bar < 0) {
if (ouserd + chan->func->userd->size >= nvkm_memory_size(userd)) { if (ouserd + chan->func->userd->size >=
nvkm_memory_size(userd)) {
RUNL_DEBUG(runl, "ouserd %llx", ouserd); RUNL_DEBUG(runl, "ouserd %llx", ouserd);
return -EINVAL; return -EINVAL;
} }
...@@ -465,7 +463,20 @@ nvkm_chan_new_(const struct nvkm_chan_func *func, struct nvkm_runl *runl, int ru ...@@ -465,7 +463,20 @@ nvkm_chan_new_(const struct nvkm_chan_func *func, struct nvkm_runl *runl, int ru
chan->userd.mem = nvkm_memory_ref(fifo->userd.mem); chan->userd.mem = nvkm_memory_ref(fifo->userd.mem);
chan->userd.base = chan->id * chan->func->userd->size; chan->userd.base = chan->id * chan->func->userd->size;
} }
}
} else {
chan->id = chan->func->id_get(chan, userd, ouserd);
}
if (chan->id < 0) {
RUNL_ERROR(runl, "!chids");
return -ENOSPC;
}
if (cgrp->id < 0)
cgrp->id = chan->id;
/* Initialise USERD. */
if (chan->func->userd->clear) if (chan->func->userd->clear)
chan->func->userd->clear(chan); chan->func->userd->clear(chan);
......
...@@ -17,6 +17,9 @@ struct nvkm_cctx { ...@@ -17,6 +17,9 @@ struct nvkm_cctx {
}; };
struct nvkm_chan_func { struct nvkm_chan_func {
int (*id_get)(struct nvkm_chan *, struct nvkm_memory *userd, u64 ouserd);
void (*id_put)(struct nvkm_chan *);
const struct nvkm_chan_func_inst { const struct nvkm_chan_func_inst {
u32 size; u32 size;
bool zero; bool zero;
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include "runq.h" #include "runq.h"
#include <core/gpuobj.h> #include <core/gpuobj.h>
#include <subdev/gsp.h>
#include <subdev/top.h> #include <subdev/top.h>
#include <subdev/vfn.h> #include <subdev/vfn.h>
...@@ -607,5 +608,8 @@ int ...@@ -607,5 +608,8 @@ int
ga100_fifo_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst, ga100_fifo_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst,
struct nvkm_fifo **pfifo) struct nvkm_fifo **pfifo)
{ {
if (nvkm_gsp_rm(device->gsp))
return -ENODEV;
return nvkm_fifo_new_(&ga100_fifo, device, type, inst, pfifo); return nvkm_fifo_new_(&ga100_fifo, device, type, inst, pfifo);
} }
...@@ -21,6 +21,8 @@ ...@@ -21,6 +21,8 @@
*/ */
#include "priv.h" #include "priv.h"
#include <subdev/gsp.h>
#include <nvif/class.h> #include <nvif/class.h>
static const struct nvkm_fifo_func static const struct nvkm_fifo_func
...@@ -41,5 +43,8 @@ int ...@@ -41,5 +43,8 @@ int
ga102_fifo_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst, ga102_fifo_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst,
struct nvkm_fifo **pfifo) struct nvkm_fifo **pfifo)
{ {
if (nvkm_gsp_rm(device->gsp))
return -ENODEV;
return nvkm_fifo_new_(&ga102_fifo, device, type, inst, pfifo); return nvkm_fifo_new_(&ga102_fifo, device, type, inst, pfifo);
} }
...@@ -13,6 +13,8 @@ struct nvkm_runq; ...@@ -13,6 +13,8 @@ struct nvkm_runq;
struct nvkm_vctx; struct nvkm_vctx;
struct nvkm_fifo_func { struct nvkm_fifo_func {
void (*dtor)(struct nvkm_fifo *);
int (*chid_nr)(struct nvkm_fifo *); int (*chid_nr)(struct nvkm_fifo *);
int (*chid_ctor)(struct nvkm_fifo *, int nr); int (*chid_ctor)(struct nvkm_fifo *, int nr);
int (*runq_nr)(struct nvkm_fifo *); int (*runq_nr)(struct nvkm_fifo *);
......
...@@ -18,6 +18,7 @@ struct nvkm_engn { ...@@ -18,6 +18,7 @@ struct nvkm_engn {
bool (*mmu_fault_triggered)(struct nvkm_engn *); bool (*mmu_fault_triggered)(struct nvkm_engn *);
int (*ctor)(struct nvkm_engn *, struct nvkm_vctx *); int (*ctor)(struct nvkm_engn *, struct nvkm_vctx *);
void (*bind)(struct nvkm_engn *, struct nvkm_cctx *, struct nvkm_chan *); void (*bind)(struct nvkm_engn *, struct nvkm_cctx *, struct nvkm_chan *);
int (*ctor2)(struct nvkm_engn *, struct nvkm_vctx *, struct nvkm_chan *);
int (*ramht_add)(struct nvkm_engn *, struct nvkm_object *, struct nvkm_chan *); int (*ramht_add)(struct nvkm_engn *, struct nvkm_object *, struct nvkm_chan *);
void (*ramht_del)(struct nvkm_chan *, int hash); void (*ramht_del)(struct nvkm_chan *, int hash);
} *func; } *func;
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include "runl.h" #include "runl.h"
#include <core/memory.h> #include <core/memory.h>
#include <subdev/gsp.h>
#include <subdev/mc.h> #include <subdev/mc.h>
#include <subdev/vfn.h> #include <subdev/vfn.h>
...@@ -282,5 +283,8 @@ int ...@@ -282,5 +283,8 @@ int
tu102_fifo_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst, tu102_fifo_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst,
struct nvkm_fifo **pfifo) struct nvkm_fifo **pfifo)
{ {
if (nvkm_gsp_rm(device->gsp))
return -ENODEV;
return nvkm_fifo_new_(&tu102_fifo, device, type, inst, pfifo); return nvkm_fifo_new_(&tu102_fifo, device, type, inst, pfifo);
} }
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