Skip to content

Commit 5de5b6e

Browse files
committed
drm/ttm/nouveau: don't call tt destroy callback on alloc failure.
This is confusing, and from my reading of all the drivers only nouveau got this right. Just make the API act under driver control of it's own allocation failing, and don't call destroy, if the page table fails to create there is nothing to cleanup here. (I'm willing to believe I've missed something here, so please review deeply). Reviewed-by: Christian König <christian.koenig@amd.com> Signed-off-by: Dave Airlie <airlied@redhat.com> Link: https://patchwork.freedesktop.org/patch/msgid/20200728041736.20689-1-airlied@gmail.com
1 parent ec731e5 commit 5de5b6e

2 files changed

Lines changed: 3 additions & 9 deletions

File tree

drivers/gpu/drm/nouveau/nouveau_sgdma.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,9 @@ nouveau_sgdma_create_ttm(struct ttm_buffer_object *bo, uint32_t page_flags)
9595
else
9696
nvbe->ttm.ttm.func = &nv50_sgdma_backend;
9797

98-
if (ttm_dma_tt_init(&nvbe->ttm, bo, page_flags))
99-
/*
100-
* A failing ttm_dma_tt_init() will call ttm_tt_destroy()
101-
* and thus our nouveau_sgdma_destroy() hook, so we don't need
102-
* to free nvbe here.
103-
*/
98+
if (ttm_dma_tt_init(&nvbe->ttm, bo, page_flags)) {
99+
kfree(nvbe);
104100
return NULL;
101+
}
105102
return &nvbe->ttm.ttm;
106103
}

drivers/gpu/drm/ttm/ttm_tt.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,6 @@ int ttm_tt_init(struct ttm_tt *ttm, struct ttm_buffer_object *bo,
244244
ttm_tt_init_fields(ttm, bo, page_flags);
245245

246246
if (ttm_tt_alloc_page_directory(ttm)) {
247-
ttm_tt_destroy(ttm);
248247
pr_err("Failed allocating page table\n");
249248
return -ENOMEM;
250249
}
@@ -268,7 +267,6 @@ int ttm_dma_tt_init(struct ttm_dma_tt *ttm_dma, struct ttm_buffer_object *bo,
268267

269268
INIT_LIST_HEAD(&ttm_dma->pages_list);
270269
if (ttm_dma_tt_alloc_page_directory(ttm_dma)) {
271-
ttm_tt_destroy(ttm);
272270
pr_err("Failed allocating page table\n");
273271
return -ENOMEM;
274272
}
@@ -290,7 +288,6 @@ int ttm_sg_tt_init(struct ttm_dma_tt *ttm_dma, struct ttm_buffer_object *bo,
290288
else
291289
ret = ttm_dma_tt_alloc_page_directory(ttm_dma);
292290
if (ret) {
293-
ttm_tt_destroy(ttm);
294291
pr_err("Failed allocating page table\n");
295292
return -ENOMEM;
296293
}

0 commit comments

Comments
 (0)