aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorJon Derrick <jonathan.derrick@intel.com>2019-03-15 20:05:16 -0400
committerBen Skeggs <bskeggs@redhat.com>2019-04-30 21:08:39 -0400
commitf10b83de1fd49216a4c657816f48001437e4bdd5 (patch)
tree2f3db3c580ab3e0d69a107316bd24fb43901c8ed /drivers
parent307a312df9c43fdea286ad17f748aaf777cc434a (diff)
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: Jon Derrick <jonathan.derrick@intel.com> Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/subdev/bar/nv50.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/bar/nv50.c b/drivers/gpu/drm/nouveau/nvkm/subdev/bar/nv50.c
index 8e64b19f3f8a..f23a0ccc2bec 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/bar/nv50.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/bar/nv50.c
@@ -109,7 +109,7 @@ nv50_bar_oneinit(struct nvkm_bar *base)
109 struct nvkm_device *device = bar->base.subdev.device; 109 struct nvkm_device *device = bar->base.subdev.device;
110 static struct lock_class_key bar1_lock; 110 static struct lock_class_key bar1_lock;
111 static struct lock_class_key bar2_lock; 111 static struct lock_class_key bar2_lock;
112 u64 start, limit; 112 u64 start, limit, size;
113 int ret; 113 int ret;
114 114
115 ret = nvkm_gpuobj_new(device, 0x20000, 0, false, NULL, &bar->mem); 115 ret = nvkm_gpuobj_new(device, 0x20000, 0, false, NULL, &bar->mem);
@@ -127,7 +127,10 @@ nv50_bar_oneinit(struct nvkm_bar *base)
127 127
128 /* BAR2 */ 128 /* BAR2 */
129 start = 0x0100000000ULL; 129 start = 0x0100000000ULL;
130 limit = start + device->func->resource_size(device, 3); 130 size = device->func->resource_size(device, 3);
131 if (!size)
132 return -ENOMEM;
133 limit = start + size;
131 134
132 ret = nvkm_vmm_new(device, start, limit-- - start, NULL, 0, 135 ret = nvkm_vmm_new(device, start, limit-- - start, NULL, 0,
133 &bar2_lock, "bar2", &bar->bar2_vmm); 136 &bar2_lock, "bar2", &bar->bar2_vmm);
@@ -164,7 +167,10 @@ nv50_bar_oneinit(struct nvkm_bar *base)
164 167
165 /* BAR1 */ 168 /* BAR1 */
166 start = 0x0000000000ULL; 169 start = 0x0000000000ULL;
167 limit = start + device->func->resource_size(device, 1); 170 size = device->func->resource_size(device, 1);
171 if (!size)
172 return -ENOMEM;
173 limit = start + size;
168 174
169 ret = nvkm_vmm_new(device, start, limit-- - start, NULL, 0, 175 ret = nvkm_vmm_new(device, start, limit-- - start, NULL, 0,
170 &bar1_lock, "bar1", &bar->bar1_vmm); 176 &bar1_lock, "bar1", &bar->bar1_vmm);