Karol Herbst
2020-Apr-17 18:09 UTC
[Nouveau] [PATCH v2 1/3] device: use the correct mmio size when mapping
Fixes warnings on GPUs with smaller a smaller mmio region like vGPUs. Signed-off-by: Karol Herbst <kherbst at redhat.com> --- drm/nouveau/nvkm/engine/device/base.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drm/nouveau/nvkm/engine/device/base.c b/drm/nouveau/nvkm/engine/device/base.c index 8ebbe1656..17676c75a 100644 --- a/drm/nouveau/nvkm/engine/device/base.c +++ b/drm/nouveau/nvkm/engine/device/base.c @@ -2963,7 +2963,7 @@ nvkm_device_ctor(const struct nvkm_device_func *func, /* identify the chipset, and determine classes of subdev/engines */ if (detect) { - map = ioremap(mmio_base, 0x102000); + map = ioremap(mmio_base, mmio_size); if (ret = -ENOMEM, map == NULL) goto done; -- 2.25.2
Karol Herbst
2020-Apr-17 18:09 UTC
[Nouveau] [PATCH v2 2/3] device: detect if changing endianness failed
v2: relax the checks a little Signed-off-by: Karol Herbst <kherbst at redhat.com> --- drm/nouveau/nvkm/engine/device/base.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/drm/nouveau/nvkm/engine/device/base.c b/drm/nouveau/nvkm/engine/device/base.c index 17676c75a..ddaa96a75 100644 --- a/drm/nouveau/nvkm/engine/device/base.c +++ b/drm/nouveau/nvkm/engine/device/base.c @@ -2924,6 +2924,20 @@ nvkm_device_del(struct nvkm_device **pdevice) } } +static inline bool +nvkm_device_endianness(void __iomem *pri) +{ + u32 boot1 = ioread32_native(pri + 0x000004) & 0x01000001; +#ifdef __BIG_ENDIAN + if (!boot1) + return false; +#else + if (boot1) + return false; +#endif + return true; +} + int nvkm_device_ctor(const struct nvkm_device_func *func, const struct nvkm_device_quirk *quirk, @@ -2968,13 +2982,15 @@ nvkm_device_ctor(const struct nvkm_device_func *func, goto done; /* switch mmio to cpu's native endianness */ -#ifndef __BIG_ENDIAN - if (ioread32_native(map + 0x000004) != 0x00000000) { -#else - if (ioread32_native(map + 0x000004) == 0x00000000) { -#endif + if (!nvkm_device_endianness(map)) { iowrite32_native(0x01000001, map + 0x000004); ioread32_native(map); + if (!nvkm_device_endianness(map)) { + nvdev_error(device, + "GPU not supported on big-endian\n"); + ret = -ENOSYS; + goto done; + } } /* read boot0 and strapping information */ -- 2.25.2
Using ENODEV as this prevents probe failed errors in dmesg. Signed-off-by: Karol Herbst <kherbst at redhat.com> --- drm/nouveau/nvkm/engine/device/base.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/drm/nouveau/nvkm/engine/device/base.c b/drm/nouveau/nvkm/engine/device/base.c index ddaa96a75..70effb36e 100644 --- a/drm/nouveau/nvkm/engine/device/base.c +++ b/drm/nouveau/nvkm/engine/device/base.c @@ -2948,7 +2948,7 @@ nvkm_device_ctor(const struct nvkm_device_func *func, { struct nvkm_subdev *subdev; u64 mmio_base, mmio_size; - u32 boot0, strap; + u32 boot0, boot1, strap; void __iomem *map; int ret = -EEXIST, i; unsigned chipset; @@ -2993,8 +2993,19 @@ nvkm_device_ctor(const struct nvkm_device_func *func, } } - /* read boot0 and strapping information */ + /* vGPU detection */ boot0 = ioread32_native(map + 0x000000); + boot1 = ioread32_native(map + 0x000004); + chipset = (boot0 & 0x1ff00000) >> 20; + + if (chipset >= 0x160 && (boot1 & 0x00030000)) { + iounmap(map); + nvdev_info(device, "vGPUs are not supported\n"); + ret = -ENODEV; + goto done; + } + + /* read strapping information */ strap = ioread32_native(map + 0x101000); iounmap(map); -- 2.25.2
Apparently Analagous Threads
- [PATCH 1/3] device: use the correct mmio size when mapping
- [PATCH v3 1/3] device: rework mmio mapping code to get rid of second map
- [PATCH] drm/nouveau/device: fix changing endianess code to work on older GPUs
- [PATCH v3 2/3] device: detect if changing endianness failed
- [PATCH] drm/nouveau/device: fix changing endianess code to work on older GPUs