Commit 24d5ff40 authored by Karol Herbst's avatar Karol Herbst Committed by Ben Skeggs

drm/nouveau/device: rework mmio mapping code to get rid of second map

Fixes warnings on GPUs with smaller a smaller mmio region like vGPUs.
Signed-off-by: default avatarKarol Herbst <kherbst@redhat.com>
Signed-off-by: default avatarBen Skeggs <bskeggs@redhat.com>
parent 94db9a3b
...@@ -2935,7 +2935,7 @@ nvkm_device_ctor(const struct nvkm_device_func *func, ...@@ -2935,7 +2935,7 @@ nvkm_device_ctor(const struct nvkm_device_func *func,
struct nvkm_subdev *subdev; struct nvkm_subdev *subdev;
u64 mmio_base, mmio_size; u64 mmio_base, mmio_size;
u32 boot0, strap; u32 boot0, strap;
void __iomem *map; void __iomem *map = NULL;
int ret = -EEXIST, i; int ret = -EEXIST, i;
unsigned chipset; unsigned chipset;
...@@ -2961,12 +2961,17 @@ nvkm_device_ctor(const struct nvkm_device_func *func, ...@@ -2961,12 +2961,17 @@ nvkm_device_ctor(const struct nvkm_device_func *func,
mmio_base = device->func->resource_addr(device, 0); mmio_base = device->func->resource_addr(device, 0);
mmio_size = device->func->resource_size(device, 0); mmio_size = device->func->resource_size(device, 0);
/* identify the chipset, and determine classes of subdev/engines */ if (detect || mmio) {
if (detect) { map = ioremap(mmio_base, mmio_size);
map = ioremap(mmio_base, 0x102000); if (map == NULL) {
if (ret = -ENOMEM, map == NULL) nvdev_error(device, "unable to map PRI\n");
ret = -ENOMEM;
goto done; goto done;
}
}
/* identify the chipset, and determine classes of subdev/engines */
if (detect) {
/* switch mmio to cpu's native endianness */ /* switch mmio to cpu's native endianness */
#ifndef __BIG_ENDIAN #ifndef __BIG_ENDIAN
if (ioread32_native(map + 0x000004) != 0x00000000) { if (ioread32_native(map + 0x000004) != 0x00000000) {
...@@ -2980,7 +2985,6 @@ nvkm_device_ctor(const struct nvkm_device_func *func, ...@@ -2980,7 +2985,6 @@ nvkm_device_ctor(const struct nvkm_device_func *func,
/* read boot0 and strapping information */ /* read boot0 and strapping information */
boot0 = ioread32_native(map + 0x000000); boot0 = ioread32_native(map + 0x000000);
strap = ioread32_native(map + 0x101000); strap = ioread32_native(map + 0x101000);
iounmap(map);
/* chipset can be overridden for devel/testing purposes */ /* chipset can be overridden for devel/testing purposes */
chipset = nvkm_longopt(device->cfgopt, "NvChipset", 0); chipset = nvkm_longopt(device->cfgopt, "NvChipset", 0);
...@@ -3159,12 +3163,7 @@ nvkm_device_ctor(const struct nvkm_device_func *func, ...@@ -3159,12 +3163,7 @@ nvkm_device_ctor(const struct nvkm_device_func *func,
device->name = device->chip->name; device->name = device->chip->name;
if (mmio) { if (mmio) {
device->pri = ioremap(mmio_base, mmio_size); device->pri = map;
if (!device->pri) {
nvdev_error(device, "unable to map PRI\n");
ret = -ENOMEM;
goto done;
}
} }
mutex_init(&device->mutex); mutex_init(&device->mutex);
...@@ -3254,6 +3253,10 @@ nvkm_device_ctor(const struct nvkm_device_func *func, ...@@ -3254,6 +3253,10 @@ nvkm_device_ctor(const struct nvkm_device_func *func,
ret = 0; ret = 0;
done: done:
if (map && (!mmio || ret)) {
device->pri = NULL;
iounmap(map);
}
mutex_unlock(&nv_devices_mutex); mutex_unlock(&nv_devices_mutex);
return ret; return ret;
} }
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