Commit afe705be authored by Chris Wilson's avatar Chris Wilson Committed by Dave Airlie

drm: Wrap direct calls to driver->gem_free_object from CMA

Since the introduction of (struct_mutex) lockless GEM bo freeing, there
are a pair of driver vfuncs for freeing the GEM bo, of which the driver
may choose to only implement driver->gem_object_free_unlocked (and so
avoid taking the struct_mutex along the free path). However, the CMA GEM
helpers were still calling driver->gem_free_object directly, now NULL,
and promptly dying on the fancy new lockless drivers. Oops.

Robert Foss bisected this to b82caafc (drm/vc4: Use lockless gem BO
free callback) on his vc4 device, but that just serves as an enabler for
9f0ba539 (drm/gem: support BO freeing without dev->struct_mutex).
Reported-by: default avatarRobert Foss <robert.foss@collabora.com>
Fixes: 9f0ba539 (drm/gem: support BO freeing without dev->struct_mutex)
Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
Cc: Robert Foss <robert.foss@collabora.com>
Cc: Daniel Vetter <daniel.vetter@intel.com>
Cc: Eric Anholt <eric@anholt.net>
Cc: Alex Deucher <alexdeucher@gmail.com>
Cc: Lucas Stach <l.stach@pengutronix.de>
Cc: stable@vger.kernel.org
Reviewed-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
Tested-by: default avatarRobert Foss <robert.foss@collabora.com>
Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
parent 1e8985a8
...@@ -445,7 +445,7 @@ int drm_fbdev_cma_create_with_funcs(struct drm_fb_helper *helper, ...@@ -445,7 +445,7 @@ int drm_fbdev_cma_create_with_funcs(struct drm_fb_helper *helper,
err_fb_info_destroy: err_fb_info_destroy:
drm_fb_helper_release_fbi(helper); drm_fb_helper_release_fbi(helper);
err_gem_free_object: err_gem_free_object:
dev->driver->gem_free_object(&obj->base); drm_gem_object_unreference_unlocked(&obj->base);
return ret; return ret;
} }
EXPORT_SYMBOL(drm_fbdev_cma_create_with_funcs); EXPORT_SYMBOL(drm_fbdev_cma_create_with_funcs);
......
...@@ -121,7 +121,7 @@ struct drm_gem_cma_object *drm_gem_cma_create(struct drm_device *drm, ...@@ -121,7 +121,7 @@ struct drm_gem_cma_object *drm_gem_cma_create(struct drm_device *drm,
return cma_obj; return cma_obj;
error: error:
drm->driver->gem_free_object(&cma_obj->base); drm_gem_object_unreference_unlocked(&cma_obj->base);
return ERR_PTR(ret); return ERR_PTR(ret);
} }
EXPORT_SYMBOL_GPL(drm_gem_cma_create); EXPORT_SYMBOL_GPL(drm_gem_cma_create);
...@@ -162,18 +162,12 @@ drm_gem_cma_create_with_handle(struct drm_file *file_priv, ...@@ -162,18 +162,12 @@ drm_gem_cma_create_with_handle(struct drm_file *file_priv,
* and handle has the id what user can see. * and handle has the id what user can see.
*/ */
ret = drm_gem_handle_create(file_priv, gem_obj, handle); ret = drm_gem_handle_create(file_priv, gem_obj, handle);
if (ret)
goto err_handle_create;
/* drop reference from allocate - handle holds it now. */ /* drop reference from allocate - handle holds it now. */
drm_gem_object_unreference_unlocked(gem_obj); drm_gem_object_unreference_unlocked(gem_obj);
if (ret)
return ERR_PTR(ret);
return cma_obj; return cma_obj;
err_handle_create:
drm->driver->gem_free_object(gem_obj);
return ERR_PTR(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