From: Rajneesh Bhardwaj Date: Sat, 8 Jul 2023 01:13:55 +0000 (-0400) Subject: drm/ttm: Use init_on_free to delay release TTM BOs X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=35d67ee3e9c9bcaaab9f217cb3cc6dacf21f2b96;p=linux.git drm/ttm: Use init_on_free to delay release TTM BOs Delay release TTM BOs when the kernel default setting is init_on_free. This offloads the overhead of clearing the system memory to the work item and potentially a different CPU. This could be very beneficial when the application does a lot of malloc/free style allocations of system memory. Signed-off-by: Rajneesh Bhardwaj Reviewed-by: Christian König . Link: https://patchwork.freedesktop.org/patch/msgid/20230708011355.853-1-rajneesh.bhardwaj@amd.com Signed-off-by: Christian König --- diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c index 615d30c4262df..758f980e3e161 100644 --- a/drivers/gpu/drm/ttm/ttm_bo.c +++ b/drivers/gpu/drm/ttm/ttm_bo.c @@ -345,6 +345,7 @@ static void ttm_bo_release(struct kref *kref) if (!dma_resv_test_signaled(bo->base.resv, DMA_RESV_USAGE_BOOKKEEP) || + (want_init_on_free() && (bo->ttm != NULL)) || !dma_resv_trylock(bo->base.resv)) { /* The BO is not idle, resurrect it for delayed destroy */ ttm_bo_flush_all_fences(bo);