File tree Expand file tree Collapse file tree 3 files changed +9
-5
lines changed Expand file tree Collapse file tree 3 files changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -929,7 +929,9 @@ EXPORT_SYMBOL(drm_gem_prime_export);
929929 * &drm_driver.gem_prime_import_sg_table internally.
930930 *
931931 * Drivers must arrange to call drm_prime_gem_destroy() from their
932- * &drm_gem_object_funcs.free hook when using this function.
932+ * &ttm_buffer_object.destroy hook when using this function,
933+ * to avoid the dma_buf being freed while the ttm_buffer_object can still
934+ * dereference it.
933935 */
934936struct drm_gem_object * drm_gem_prime_import_dev (struct drm_device * dev ,
935937 struct dma_buf * dma_buf ,
@@ -999,7 +1001,9 @@ EXPORT_SYMBOL(drm_gem_prime_import_dev);
9991001 * implementation in drm_gem_prime_fd_to_handle().
10001002 *
10011003 * Drivers must arrange to call drm_prime_gem_destroy() from their
1002- * &drm_gem_object_funcs.free hook when using this function.
1004+ * &ttm_buffer_object.destroy hook when using this function,
1005+ * to avoid the dma_buf being freed while the ttm_buffer_object can still
1006+ * dereference it.
10031007 */
10041008struct drm_gem_object * drm_gem_prime_import (struct drm_device * dev ,
10051009 struct dma_buf * dma_buf )
Original file line number Diff line number Diff line change @@ -144,6 +144,9 @@ nouveau_bo_del_ttm(struct ttm_buffer_object *bo)
144144 nouveau_bo_del_io_reserve_lru (bo );
145145 nv10_bo_put_tile_region (dev , nvbo -> tile , NULL );
146146
147+ if (bo -> base .import_attach )
148+ drm_prime_gem_destroy (& bo -> base , bo -> sg );
149+
147150 /*
148151 * If nouveau_bo_new() allocated this buffer, the GEM object was never
149152 * initialized, so don't attempt to release it.
Original file line number Diff line number Diff line change @@ -87,9 +87,6 @@ nouveau_gem_object_del(struct drm_gem_object *gem)
8787 return ;
8888 }
8989
90- if (gem -> import_attach )
91- drm_prime_gem_destroy (gem , nvbo -> bo .sg );
92-
9390 ttm_bo_put (& nvbo -> bo );
9491
9592 pm_runtime_mark_last_busy (dev );
You can’t perform that action at this time.
0 commit comments