Self NAK, this isn't sufficient to fix events. On Mon, 20 Nov 2023 at 12:07, Dave Airlie <airlied@xxxxxxxxx> wrote: > > From: Dave Airlie <airlied@xxxxxxxxxx> > > The fence code uses the total number of channel ids to allocate a > bunch of memory for fencing. This is probably not the best way to > do this, but it's hard to fix right now. > > The GSP code realises it can fit 8 channels into a USERD > page, so it claims it can support 256 channels max, but it then > allocates channel ids sparsely (0, 8, 16 etc). > > This just exposes the multiplier to userspace so the fence code > gets things right, however I think this might all need more thought. > > Link: https://gitlab.freedesktop.org/drm/nouveau/-/issues/274 > Signed-off-by: Dave Airlie <airlied@xxxxxxxxxx> > --- > drivers/gpu/drm/nouveau/nvkm/engine/fifo/base.c | 7 ++++++- > drivers/gpu/drm/nouveau/nvkm/engine/fifo/priv.h | 2 ++ > drivers/gpu/drm/nouveau/nvkm/engine/fifo/r535.c | 7 +++++++ > 3 files changed, 15 insertions(+), 1 deletion(-) > > diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/base.c b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/base.c > index 22443fe4a39f..8e36cdd0e5fb 100644 > --- a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/base.c > +++ b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/base.c > @@ -178,7 +178,12 @@ nvkm_fifo_info(struct nvkm_engine *engine, u64 mthd, u64 *data) > return ret; > > switch (mthd) { > - case NV_DEVICE_HOST_CHANNELS: *data = fifo->chid ? fifo->chid->nr : 0; return 0; > + case NV_DEVICE_HOST_CHANNELS: > + if (fifo->func->chid_total) > + *data = fifo->func->chid_total(fifo); > + else > + *data = fifo->chid ? fifo->chid->nr : 0; > + return 0; > case NV_DEVICE_HOST_RUNLISTS: > *data = 0; > nvkm_runl_foreach(runl, fifo) > diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/priv.h b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/priv.h > index a0f3277605a5..c21e982b03a5 100644 > --- a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/priv.h > +++ b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/priv.h > @@ -17,6 +17,8 @@ struct nvkm_fifo_func { > > int (*chid_nr)(struct nvkm_fifo *); > int (*chid_ctor)(struct nvkm_fifo *, int nr); > + > + int (*chid_total)(struct nvkm_fifo *); > int (*runq_nr)(struct nvkm_fifo *); > int (*runl_ctor)(struct nvkm_fifo *); > > diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/r535.c b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/r535.c > index b374d72fd1c1..1e9c0b113cb5 100644 > --- a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/r535.c > +++ b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/r535.c > @@ -641,6 +641,12 @@ r535_fifo_dtor(struct nvkm_fifo *fifo) > kfree(fifo->func); > } > > +static int > +r535_fifo_chid_total(struct nvkm_fifo *fifo) > +{ > + return fifo->chid->nr * CHID_PER_USERD; > +} > + > int > r535_fifo_new(const struct nvkm_fifo_func *hw, struct nvkm_device *device, > enum nvkm_subdev_type type, int inst, struct nvkm_fifo **pfifo) > @@ -652,6 +658,7 @@ r535_fifo_new(const struct nvkm_fifo_func *hw, struct nvkm_device *device, > > rm->dtor = r535_fifo_dtor; > rm->runl_ctor = r535_fifo_runl_ctor; > + rm->chid_total = r535_fifo_chid_total; > rm->runl = &r535_runl; > rm->cgrp = hw->cgrp; > rm->cgrp.func = &r535_cgrp; > -- > 2.42.0 >