summaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/nouveau/nvkm/core
diff options
context:
space:
mode:
authorBen Skeggs <bskeggs@redhat.com>2020-07-25 16:40:07 +1000
committerBen Skeggs <bskeggs@redhat.com>2021-02-11 10:14:28 +1000
commit65a279c1a9709edc00a5859737d0abd50c029ca0 (patch)
tree477e9f0480f10d94de99bcd76411b091779fe88d /drivers/gpu/drm/nouveau/nvkm/core
parent9c28abb7db540a9c1f4dedaaf547503adfc87394 (diff)
downloadlwn-65a279c1a9709edc00a5859737d0abd50c029ca0.tar.gz
lwn-65a279c1a9709edc00a5859737d0abd50c029ca0.zip
drm/nouveau/subdev: track type+instance separately
We use subdev id bitmasks (as a u64) in a number of places, and GA100 adds enough new engine instances that we run out of bits. We could alias IDs of engines that no longer exist, but it's cleaner for a number of reasons to just split the subdev index into a subdev type, and instance ID instead. Just a lot more painful to do. This magics up the values for old-style subdev constructors, and provides a way to incrementally transition each subdev to the new style. Signed-off-by: Ben Skeggs <bskeggs@redhat.com> Reviewed-by: Lyude Paul <lyude@redhat.com>
Diffstat (limited to 'drivers/gpu/drm/nouveau/nvkm/core')
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/core/subdev.c34
1 files changed, 30 insertions, 4 deletions
diff --git a/drivers/gpu/drm/nouveau/nvkm/core/subdev.c b/drivers/gpu/drm/nouveau/nvkm/core/subdev.c
index 7759e6e56ab4..12a13d634a70 100644
--- a/drivers/gpu/drm/nouveau/nvkm/core/subdev.c
+++ b/drivers/gpu/drm/nouveau/nvkm/core/subdev.c
@@ -208,14 +208,40 @@ nvkm_subdev_del(struct nvkm_subdev **psubdev)
}
void
-nvkm_subdev_ctor(const struct nvkm_subdev_func *func,
- struct nvkm_device *device, int index,
+nvkm_subdev_ctor_(const struct nvkm_subdev_func *func, bool old,
+ struct nvkm_device *device, enum nvkm_subdev_type type, int inst,
struct nvkm_subdev *subdev)
{
subdev->func = func;
subdev->device = device;
- subdev->index = index;
- strscpy(subdev->name, nvkm_subdev_type[index], sizeof(subdev->name));
+ subdev->type = type;
+ subdev->inst = inst < 0 ? 0 : inst;
+ subdev->index = type + subdev->inst;
+
+ if (old) {
+ switch (subdev->type) {
+ case NVKM_ENGINE_CE0 ... NVKM_ENGINE_CE_LAST:
+ subdev->type = NVKM_ENGINE_CE;
+ subdev->inst = subdev->index - NVKM_ENGINE_CE0;
+ break;
+ case NVKM_ENGINE_NVENC0 ... NVKM_ENGINE_NVENC_LAST:
+ subdev->type = NVKM_ENGINE_NVENC;
+ subdev->inst = subdev->index - NVKM_ENGINE_NVENC0;
+ break;
+ case NVKM_ENGINE_NVDEC0 ... NVKM_ENGINE_NVDEC_LAST:
+ subdev->type = NVKM_ENGINE_NVDEC;
+ subdev->inst = subdev->index - NVKM_ENGINE_NVDEC0;
+ break;
+ default:
+ break;
+ }
+ inst = -1;
+ }
+
+ if (inst >= 0)
+ snprintf(subdev->name, sizeof(subdev->name), "%s%d", nvkm_subdev_type[type], inst);
+ else
+ strscpy(subdev->name, nvkm_subdev_type[type], sizeof(subdev->name));
subdev->debug = nvkm_dbgopt(device->dbgopt, subdev->name);
list_add_tail(&subdev->head, &device->subdev);
}