diff options
author | Maarten Lankhorst <m.b.lankhorst@gmail.com> | 2013-06-27 07:38:21 -0400 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2013-06-27 21:56:00 -0400 |
commit | 1e2bd5f53b6282e711e9f074765911868f8e7dc1 (patch) | |
tree | 8dea7ed39b4809bba8b4a899f82d08e97fb37ab9 | |
parent | 198c14a0da9d9407c7394e1a346d4b95fc6258a6 (diff) |
drm/nouveau: fixup fbcon failure paths
Add missing calls, and fix a leak from forgetting to call the unpin function.
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@canonical.com>
Acked-by: Ben Skeggs <bskeggs@redhat.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
-rw-r--r-- | drivers/gpu/drm/nouveau/nouveau_fbcon.c | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/drivers/gpu/drm/nouveau/nouveau_fbcon.c b/drivers/gpu/drm/nouveau/nouveau_fbcon.c index b03531781580..ecbfe691400c 100644 --- a/drivers/gpu/drm/nouveau/nouveau_fbcon.c +++ b/drivers/gpu/drm/nouveau/nouveau_fbcon.c | |||
@@ -289,16 +289,13 @@ nouveau_fbcon_create(struct drm_fb_helper *helper, | |||
289 | ret = nouveau_bo_pin(nvbo, TTM_PL_FLAG_VRAM); | 289 | ret = nouveau_bo_pin(nvbo, TTM_PL_FLAG_VRAM); |
290 | if (ret) { | 290 | if (ret) { |
291 | NV_ERROR(drm, "failed to pin fb: %d\n", ret); | 291 | NV_ERROR(drm, "failed to pin fb: %d\n", ret); |
292 | nouveau_bo_ref(NULL, &nvbo); | 292 | goto out_unref; |
293 | goto out; | ||
294 | } | 293 | } |
295 | 294 | ||
296 | ret = nouveau_bo_map(nvbo); | 295 | ret = nouveau_bo_map(nvbo); |
297 | if (ret) { | 296 | if (ret) { |
298 | NV_ERROR(drm, "failed to map fb: %d\n", ret); | 297 | NV_ERROR(drm, "failed to map fb: %d\n", ret); |
299 | nouveau_bo_unpin(nvbo); | 298 | goto out_unpin; |
300 | nouveau_bo_ref(NULL, &nvbo); | ||
301 | goto out; | ||
302 | } | 299 | } |
303 | 300 | ||
304 | chan = nouveau_nofbaccel ? NULL : drm->channel; | 301 | chan = nouveau_nofbaccel ? NULL : drm->channel; |
@@ -316,13 +313,14 @@ nouveau_fbcon_create(struct drm_fb_helper *helper, | |||
316 | info = framebuffer_alloc(0, &pdev->dev); | 313 | info = framebuffer_alloc(0, &pdev->dev); |
317 | if (!info) { | 314 | if (!info) { |
318 | ret = -ENOMEM; | 315 | ret = -ENOMEM; |
319 | goto out_unref; | 316 | goto out_unlock; |
320 | } | 317 | } |
321 | 318 | ||
322 | ret = fb_alloc_cmap(&info->cmap, 256, 0); | 319 | ret = fb_alloc_cmap(&info->cmap, 256, 0); |
323 | if (ret) { | 320 | if (ret) { |
324 | ret = -ENOMEM; | 321 | ret = -ENOMEM; |
325 | goto out_unref; | 322 | framebuffer_release(info); |
323 | goto out_unlock; | ||
326 | } | 324 | } |
327 | 325 | ||
328 | info->par = fbcon; | 326 | info->par = fbcon; |
@@ -337,7 +335,7 @@ nouveau_fbcon_create(struct drm_fb_helper *helper, | |||
337 | fbcon->helper.fbdev = info; | 335 | fbcon->helper.fbdev = info; |
338 | 336 | ||
339 | strcpy(info->fix.id, "nouveaufb"); | 337 | strcpy(info->fix.id, "nouveaufb"); |
340 | if (nouveau_nofbaccel) | 338 | if (!chan) |
341 | info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_DISABLED; | 339 | info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_DISABLED; |
342 | else | 340 | else |
343 | info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_COPYAREA | | 341 | info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_COPYAREA | |
@@ -383,8 +381,14 @@ nouveau_fbcon_create(struct drm_fb_helper *helper, | |||
383 | vga_switcheroo_client_fb_set(dev->pdev, info); | 381 | vga_switcheroo_client_fb_set(dev->pdev, info); |
384 | return 0; | 382 | return 0; |
385 | 383 | ||
386 | out_unref: | 384 | out_unlock: |
387 | mutex_unlock(&dev->struct_mutex); | 385 | mutex_unlock(&dev->struct_mutex); |
386 | if (chan) | ||
387 | nouveau_bo_vma_del(nvbo, &fbcon->nouveau_fb.vma); | ||
388 | out_unpin: | ||
389 | nouveau_bo_unpin(nvbo); | ||
390 | out_unref: | ||
391 | nouveau_bo_ref(NULL, &nvbo); | ||
388 | out: | 392 | out: |
389 | return ret; | 393 | return ret; |
390 | } | 394 | } |
@@ -413,6 +417,7 @@ nouveau_fbcon_destroy(struct drm_device *dev, struct nouveau_fbdev *fbcon) | |||
413 | if (nouveau_fb->nvbo) { | 417 | if (nouveau_fb->nvbo) { |
414 | nouveau_bo_unmap(nouveau_fb->nvbo); | 418 | nouveau_bo_unmap(nouveau_fb->nvbo); |
415 | nouveau_bo_vma_del(nouveau_fb->nvbo, &nouveau_fb->vma); | 419 | nouveau_bo_vma_del(nouveau_fb->nvbo, &nouveau_fb->vma); |
420 | nouveau_bo_unpin(nouveau_fb->nvbo); | ||
416 | drm_gem_object_unreference_unlocked(nouveau_fb->nvbo->gem); | 421 | drm_gem_object_unreference_unlocked(nouveau_fb->nvbo->gem); |
417 | nouveau_fb->nvbo = NULL; | 422 | nouveau_fb->nvbo = NULL; |
418 | } | 423 | } |