From: Greg Kroah-Hartman Date: Mon, 24 Jan 2022 15:41:44 +0000 (+0100) Subject: 4.9-stable patches X-Git-Tag: v4.4.300~26 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8e8d1da69057ea09371954e20e06cc1248f683b0;p=thirdparty%2Fkernel%2Fstable-queue.git 4.9-stable patches added patches: drm-ttm-nouveau-don-t-call-tt-destroy-callback-on-alloc-failure.patch --- diff --git a/queue-4.9/drm-ttm-nouveau-don-t-call-tt-destroy-callback-on-alloc-failure.patch b/queue-4.9/drm-ttm-nouveau-don-t-call-tt-destroy-callback-on-alloc-failure.patch new file mode 100644 index 00000000000..4dc532931b1 --- /dev/null +++ b/queue-4.9/drm-ttm-nouveau-don-t-call-tt-destroy-callback-on-alloc-failure.patch @@ -0,0 +1,71 @@ +From 5de5b6ecf97a021f29403aa272cb4e03318ef586 Mon Sep 17 00:00:00 2001 +From: Dave Airlie +Date: Tue, 28 Jul 2020 14:17:36 +1000 +Subject: drm/ttm/nouveau: don't call tt destroy callback on alloc failure. +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Dave Airlie + +commit 5de5b6ecf97a021f29403aa272cb4e03318ef586 upstream. + +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 +Signed-off-by: Dave Airlie +Link: https://patchwork.freedesktop.org/patch/msgid/20200728041736.20689-1-airlied@gmail.com +[bwh: Backported to 4.14: + - Drop change in ttm_sg_tt_init() + - Adjust context] +Signed-off-by: Ben Hutchings +Signed-off-by: Greg Kroah-Hartman +--- + drivers/gpu/drm/nouveau/nouveau_sgdma.c | 9 +++------ + drivers/gpu/drm/ttm/ttm_tt.c | 2 -- + 2 files changed, 3 insertions(+), 8 deletions(-) + +--- a/drivers/gpu/drm/nouveau/nouveau_sgdma.c ++++ b/drivers/gpu/drm/nouveau/nouveau_sgdma.c +@@ -105,12 +105,9 @@ nouveau_sgdma_create_ttm(struct ttm_bo_d + else + nvbe->ttm.ttm.func = &nv50_sgdma_backend; + +- if (ttm_dma_tt_init(&nvbe->ttm, bdev, size, page_flags, dummy_read_page)) +- /* +- * A failing ttm_dma_tt_init() will call ttm_tt_destroy() +- * and thus our nouveau_sgdma_destroy() hook, so we don't need +- * to free nvbe here. +- */ ++ if (ttm_dma_tt_init(&nvbe->ttm, bdev, size, page_flags, dummy_read_page)) { ++ kfree(nvbe); + return NULL; ++ } + return &nvbe->ttm.ttm; + } +--- a/drivers/gpu/drm/ttm/ttm_tt.c ++++ b/drivers/gpu/drm/ttm/ttm_tt.c +@@ -195,7 +195,6 @@ int ttm_tt_init(struct ttm_tt *ttm, stru + + ttm_tt_alloc_page_directory(ttm); + if (!ttm->pages) { +- ttm_tt_destroy(ttm); + pr_err("Failed allocating page table\n"); + return -ENOMEM; + } +@@ -228,7 +227,6 @@ int ttm_dma_tt_init(struct ttm_dma_tt *t + INIT_LIST_HEAD(&ttm_dma->pages_list); + ttm_dma_tt_alloc_page_directory(ttm_dma); + if (!ttm->pages) { +- ttm_tt_destroy(ttm); + pr_err("Failed allocating page table\n"); + return -ENOMEM; + } diff --git a/queue-4.9/series b/queue-4.9/series index 9d8a6461170..f0d31b5f875 100644 --- a/queue-4.9/series +++ b/queue-4.9/series @@ -145,3 +145,4 @@ scripts-dtc-dtx_diff-remove-broken-example-from-help-text.patch lib82596-fix-irq-check-in-sni_82596_probe.patch revert-gup-document-and-work-around-cow-can-break-either-way-issue.patch gup-document-and-work-around-cow-can-break-either-way-issue.patch +drm-ttm-nouveau-don-t-call-tt-destroy-callback-on-alloc-failure.patch