Commit be0ed63f authored by Ben Skeggs's avatar Ben Skeggs

drm/nouveau/nvkm: determine subdev id/order from layout

Signed-off-by: default avatarBen Skeggs <bskeggs@redhat.com>
Reviewed-by: default avatarLyude Paul <lyude@redhat.com>
parent 0fa5680c
......@@ -4,78 +4,15 @@
#include <core/device.h>
enum nvkm_subdev_type {
NVKM_SUBDEV_PCI,
NVKM_SUBDEV_VBIOS,
NVKM_SUBDEV_DEVINIT,
NVKM_SUBDEV_TOP,
NVKM_SUBDEV_IBUS,
NVKM_SUBDEV_GPIO,
NVKM_SUBDEV_I2C,
NVKM_SUBDEV_FUSE,
NVKM_SUBDEV_MXM,
NVKM_SUBDEV_MC,
NVKM_SUBDEV_BUS,
NVKM_SUBDEV_TIMER,
NVKM_SUBDEV_INSTMEM,
NVKM_SUBDEV_FB,
NVKM_SUBDEV_LTC,
NVKM_SUBDEV_MMU,
NVKM_SUBDEV_BAR,
NVKM_SUBDEV_FAULT,
NVKM_SUBDEV_ACR,
NVKM_SUBDEV_PMU,
NVKM_SUBDEV_VOLT,
NVKM_SUBDEV_ICCSENSE,
NVKM_SUBDEV_THERM,
NVKM_SUBDEV_CLK,
NVKM_SUBDEV_GSP,
NVKM_ENGINE_BSP,
NVKM_ENGINE_CE0,
NVKM_ENGINE_CE = NVKM_ENGINE_CE0,
NVKM_ENGINE_CE1,
NVKM_ENGINE_CE2,
NVKM_ENGINE_CE3,
NVKM_ENGINE_CE4,
NVKM_ENGINE_CE5,
NVKM_ENGINE_CE6,
NVKM_ENGINE_CE7,
NVKM_ENGINE_CE8,
NVKM_ENGINE_CE_LAST = NVKM_ENGINE_CE8,
NVKM_ENGINE_CIPHER,
NVKM_ENGINE_DISP,
NVKM_ENGINE_DMAOBJ,
NVKM_ENGINE_FIFO,
NVKM_ENGINE_GR,
NVKM_ENGINE_IFB,
NVKM_ENGINE_ME,
NVKM_ENGINE_MPEG,
NVKM_ENGINE_MSENC,
NVKM_ENGINE_MSPDEC,
NVKM_ENGINE_MSPPP,
NVKM_ENGINE_MSVLD,
NVKM_ENGINE_NVENC0,
NVKM_ENGINE_NVENC = NVKM_ENGINE_NVENC0,
NVKM_ENGINE_NVENC1,
NVKM_ENGINE_NVENC2,
NVKM_ENGINE_NVENC_LAST = NVKM_ENGINE_NVENC2,
NVKM_ENGINE_NVDEC0,
NVKM_ENGINE_NVDEC = NVKM_ENGINE_NVDEC0,
NVKM_ENGINE_NVDEC1,
NVKM_ENGINE_NVDEC2,
NVKM_ENGINE_NVDEC_LAST = NVKM_ENGINE_NVDEC2,
NVKM_ENGINE_PM,
NVKM_ENGINE_SEC,
NVKM_ENGINE_SEC2,
NVKM_ENGINE_SW,
NVKM_ENGINE_VIC,
NVKM_ENGINE_VP,
#define NVKM_LAYOUT_ONCE(t,s,p) t,
#define NVKM_LAYOUT_INST_3(t) t, t##0 = t, t##1, t##2, t##_LAST = t##2,
#define NVKM_LAYOUT_INST_9(t) t, t##0 = t, t##1, t##2, t##3, t##4, t##5, t##6, t##7, t##8, t##_LAST = t##8,
#define NVKM_LAYOUT_INST(t,s,p,c) NVKM_LAYOUT_INST_##c(t)
#include <core/layout.h>
#undef NVKM_LAYOUT_INST_9
#undef NVKM_LAYOUT_INST_3
#undef NVKM_LAYOUT_INST
#undef NVKM_LAYOUT_ONCE
NVKM_SUBDEV_NR
};
......
......@@ -2848,7 +2848,7 @@ nvkm_device_ctor(const struct nvkm_device_func *func,
struct nvkm_subdev *subdev;
u64 mmio_base, mmio_size;
u32 boot0, boot1, strap;
int ret = -EEXIST, i, j;
int ret = -EEXIST, j;
unsigned chipset;
mutex_lock(&nv_devices_mutex);
......@@ -3099,9 +3099,7 @@ nvkm_device_ctor(const struct nvkm_device_func *func,
mutex_init(&device->mutex);
for (i = 0; i < NVKM_SUBDEV_NR; i++) {
switch (i) {
#define NVKM_LAYOUT_ONCE(type,data,ptr) case type: \
#define NVKM_LAYOUT_ONCE(type,data,ptr) \
if (device->chip->ptr.inst && (subdev_mask & (BIT_ULL(type)))) { \
WARN_ON(device->chip->ptr.inst != 0x00000001); \
ret = device->chip->ptr.ctor(device, (type), -1, &device->ptr); \
......@@ -3117,9 +3115,8 @@ nvkm_device_ctor(const struct nvkm_device_func *func,
} else { \
subdev->pself = (void **)&device->ptr; \
} \
} \
break;
#define NVKM_LAYOUT_INST(type,data,ptr,cnt) case type: \
}
#define NVKM_LAYOUT_INST(type,data,ptr,cnt) \
WARN_ON(device->chip->ptr.inst & ~((1 << ARRAY_SIZE(device->ptr)) - 1)); \
for (j = 0; device->chip->ptr.inst && j < ARRAY_SIZE(device->ptr); j++) { \
if ((device->chip->ptr.inst & BIT(j)) && (subdev_mask & BIT_ULL(type))) { \
......@@ -3138,29 +3135,10 @@ nvkm_device_ctor(const struct nvkm_device_func *func,
subdev->pself = (void **)&device->ptr[j]; \
} \
} \
} \
break;
}
#include <core/layout.h>
#undef NVKM_LAYOUT_INST
#undef NVKM_LAYOUT_ONCE
case NVKM_ENGINE_CE1:
case NVKM_ENGINE_CE2:
case NVKM_ENGINE_CE3:
case NVKM_ENGINE_CE4:
case NVKM_ENGINE_CE5:
case NVKM_ENGINE_CE6:
case NVKM_ENGINE_CE7:
case NVKM_ENGINE_CE8:
case NVKM_ENGINE_NVDEC1:
case NVKM_ENGINE_NVDEC2:
case NVKM_ENGINE_NVENC1:
case NVKM_ENGINE_NVENC2:
break;
default:
WARN_ON(1);
continue;
}
}
ret = 0;
done:
......
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