Skip to contentSkip to conversation

nouveau/gsp: fix getting max channel id for GSP

PATCH In review Dave Airlie 1 participant 2 messages Nov 20, 2023 – Nov 21, 2023

Subsystems (3)
lore
Share & tools
lore

Dave Airlie

author maintainer
#0 lore raw

PATCH 1/1 nouveau/gsp: fix getting max channel id for GSP

From: Dave Airlie <[email protected]>

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.

---
 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(-)
drivers/gpu/drm/nouveau/nvkm/engine/fifo/base.c +6 -1
index 22443fe4a39f..8e36cdd0e5fb 100644
@@ -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)
drivers/gpu/drm/nouveau/nvkm/engine/fifo/priv.h +2 -0
index a0f3277605a5..c21e982b03a5 100644
@@ -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 *);
 
drivers/gpu/drm/nouveau/nvkm/engine/fifo/r535.c +7 -0
index b374d72fd1c1..1e9c0b113cb5 100644
@@ -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;
Signature · 1 line
2.42.0
author maintainer
#1 lore raw

Self NAK, this isn't sufficient to fix events.

Quoted 81 lines · Dave Airlie

From: Dave Airlie <[email protected]>

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.

---
 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(-)
drivers/gpu/drm/nouveau/nvkm/engine/fifo/base.c +6 -1
index 22443fe4a39f..8e36cdd0e5fb 100644
@@ -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)
drivers/gpu/drm/nouveau/nvkm/engine/fifo/priv.h +2 -0
index a0f3277605a5..c21e982b03a5 100644
@@ -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 *);
 
drivers/gpu/drm/nouveau/nvkm/engine/fifo/r535.c +7 -1
index b374d72fd1c1..1e9c0b113cb5 100644
@@ -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