Commit f10b83de authored by Jon Derrick's avatar Jon Derrick Committed by Ben Skeggs

drm/nouveau/bar/nv50: ensure BAR is mapped

If the BAR is zero size, it indicates it was never successfully mapped.
Ensure that the BAR is valid during initialization before attempting to
use it.
Signed-off-by: default avatarJon Derrick <jonathan.derrick@intel.com>
Signed-off-by: default avatarBen Skeggs <bskeggs@redhat.com>
parent 307a312d
...@@ -109,7 +109,7 @@ nv50_bar_oneinit(struct nvkm_bar *base) ...@@ -109,7 +109,7 @@ nv50_bar_oneinit(struct nvkm_bar *base)
struct nvkm_device *device = bar->base.subdev.device; struct nvkm_device *device = bar->base.subdev.device;
static struct lock_class_key bar1_lock; static struct lock_class_key bar1_lock;
static struct lock_class_key bar2_lock; static struct lock_class_key bar2_lock;
u64 start, limit; u64 start, limit, size;
int ret; int ret;
ret = nvkm_gpuobj_new(device, 0x20000, 0, false, NULL, &bar->mem); ret = nvkm_gpuobj_new(device, 0x20000, 0, false, NULL, &bar->mem);
...@@ -127,7 +127,10 @@ nv50_bar_oneinit(struct nvkm_bar *base) ...@@ -127,7 +127,10 @@ nv50_bar_oneinit(struct nvkm_bar *base)
/* BAR2 */ /* BAR2 */
start = 0x0100000000ULL; start = 0x0100000000ULL;
limit = start + device->func->resource_size(device, 3); size = device->func->resource_size(device, 3);
if (!size)
return -ENOMEM;
limit = start + size;
ret = nvkm_vmm_new(device, start, limit-- - start, NULL, 0, ret = nvkm_vmm_new(device, start, limit-- - start, NULL, 0,
&bar2_lock, "bar2", &bar->bar2_vmm); &bar2_lock, "bar2", &bar->bar2_vmm);
...@@ -164,7 +167,10 @@ nv50_bar_oneinit(struct nvkm_bar *base) ...@@ -164,7 +167,10 @@ nv50_bar_oneinit(struct nvkm_bar *base)
/* BAR1 */ /* BAR1 */
start = 0x0000000000ULL; start = 0x0000000000ULL;
limit = start + device->func->resource_size(device, 1); size = device->func->resource_size(device, 1);
if (!size)
return -ENOMEM;
limit = start + size;
ret = nvkm_vmm_new(device, start, limit-- - start, NULL, 0, ret = nvkm_vmm_new(device, start, limit-- - start, NULL, 0,
&bar1_lock, "bar1", &bar->bar1_vmm); &bar1_lock, "bar1", &bar->bar1_vmm);
......
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