Skip to content

Commit 3b401e3

Browse files
drobnikChristianKoenigAMD
authored andcommitted
drm/ttm: Reorder sys manager cleanup step
With the current cleanup flow, we could trigger a NULL pointer dereference if there is a delayed destruction of a BO with a system resource that gets executed on drain_workqueue() call, as we attempt to free a resource using an already released resource manager. Remove the device from the device list and drain its workqueue before releasing the system domain manager in ttm_device_fini(). Signed-off-by: Karolina Stolarek <karolina.stolarek@intel.com> Reviewed-by: Christian König <christian.koenig@amd.com> Link: https://patchwork.freedesktop.org/patch/msgid/20231016121525.2237838-1-karolina.stolarek@intel.com Signed-off-by: Christian König <christian.koenig@amd.com>
1 parent 4366faf commit 3b401e3

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

drivers/gpu/drm/ttm/ttm_device.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -232,17 +232,17 @@ void ttm_device_fini(struct ttm_device *bdev)
232232
struct ttm_resource_manager *man;
233233
unsigned i;
234234

235-
man = ttm_manager_type(bdev, TTM_PL_SYSTEM);
236-
ttm_resource_manager_set_used(man, false);
237-
ttm_set_driver_manager(bdev, TTM_PL_SYSTEM, NULL);
238-
239235
mutex_lock(&ttm_global_mutex);
240236
list_del(&bdev->device_list);
241237
mutex_unlock(&ttm_global_mutex);
242238

243239
drain_workqueue(bdev->wq);
244240
destroy_workqueue(bdev->wq);
245241

242+
man = ttm_manager_type(bdev, TTM_PL_SYSTEM);
243+
ttm_resource_manager_set_used(man, false);
244+
ttm_set_driver_manager(bdev, TTM_PL_SYSTEM, NULL);
245+
246246
spin_lock(&bdev->lru_lock);
247247
for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i)
248248
if (list_empty(&man->lru[0]))

0 commit comments

Comments
 (0)