Skip to content

Commit afe705b

Browse files
ickleairlied
authored andcommitted
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 b82caaf (drm/vc4: Use lockless gem BO free callback) on his vc4 device, but that just serves as an enabler for 9f0ba53 (drm/gem: support BO freeing without dev->struct_mutex). Reported-by: Robert Foss <[email protected]> Fixes: 9f0ba53 (drm/gem: support BO freeing without dev->struct_mutex) Signed-off-by: Chris Wilson <[email protected]> Cc: Robert Foss <[email protected]> Cc: Daniel Vetter <[email protected]> Cc: Eric Anholt <[email protected]> Cc: Alex Deucher <[email protected]> Cc: Lucas Stach <[email protected]> Cc: [email protected] Reviewed-by: Daniel Vetter <[email protected]> Tested-by: Robert Foss <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
1 parent 1e8985a commit afe705b

File tree

2 files changed

+4
-10
lines changed

2 files changed

+4
-10
lines changed

drivers/gpu/drm/drm_fb_cma_helper.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ int drm_fbdev_cma_create_with_funcs(struct drm_fb_helper *helper,
445445
err_fb_info_destroy:
446446
drm_fb_helper_release_fbi(helper);
447447
err_gem_free_object:
448-
dev->driver->gem_free_object(&obj->base);
448+
drm_gem_object_unreference_unlocked(&obj->base);
449449
return ret;
450450
}
451451
EXPORT_SYMBOL(drm_fbdev_cma_create_with_funcs);

drivers/gpu/drm/drm_gem_cma_helper.c

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ struct drm_gem_cma_object *drm_gem_cma_create(struct drm_device *drm,
121121
return cma_obj;
122122

123123
error:
124-
drm->driver->gem_free_object(&cma_obj->base);
124+
drm_gem_object_unreference_unlocked(&cma_obj->base);
125125
return ERR_PTR(ret);
126126
}
127127
EXPORT_SYMBOL_GPL(drm_gem_cma_create);
@@ -162,18 +162,12 @@ drm_gem_cma_create_with_handle(struct drm_file *file_priv,
162162
* and handle has the id what user can see.
163163
*/
164164
ret = drm_gem_handle_create(file_priv, gem_obj, handle);
165-
if (ret)
166-
goto err_handle_create;
167-
168165
/* drop reference from allocate - handle holds it now. */
169166
drm_gem_object_unreference_unlocked(gem_obj);
167+
if (ret)
168+
return ERR_PTR(ret);
170169

171170
return cma_obj;
172-
173-
err_handle_create:
174-
drm->driver->gem_free_object(gem_obj);
175-
176-
return ERR_PTR(ret);
177171
}
178172

179173
/**

0 commit comments

Comments
 (0)