From patchwork Mon Jun 26 09:14:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Hellstr=C3=B6m?= X-Patchwork-Id: 13292545 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 630EBEB64DC for ; Mon, 26 Jun 2023 09:15:14 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4B21710E0BB; Mon, 26 Jun 2023 09:15:11 +0000 (UTC) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by gabe.freedesktop.org (Postfix) with ESMTPS id 53A7A10E0A2; Mon, 26 Jun 2023 09:15:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1687770905; x=1719306905; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=c8zPgWJY6SC59lOQdr8vPRntj39QqPiFfis3EjYD9Kg=; b=NpWE4pQGKHaCyRoScpbzDGEQkUqlMCFk6x70txO44kihzmcpjeUyvKyC tnAxwohk4l4IKvps5jCF2EINk9JAbK+0taITi65Sdxit2cGP00YczOB7P /EtrFIbPtN+uXGqxecGFXaFwu4c2VmAFuM0m2n1o4Q2UVXH8I4JiPDMIe 6lBWduCRmvBr1ZwlvxfdUBd2Q8qg+GvLD04A0nMfp1T4DPMrigEIk9dOA D5OCk6ctMGt7jfw24hdJLanPJzQ/U6HAN6Fdi0NGtBHn7niIZaVdVICRy WcEB3s5NzsBngoSmKVmA8ghwT/yP+mutM9Pj5F8B5QmN3KjZwCrqAPL1k Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10752"; a="345974079" X-IronPort-AV: E=Sophos;i="6.01,159,1684825200"; d="scan'208";a="345974079" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jun 2023 02:15:04 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10752"; a="781357733" X-IronPort-AV: E=Sophos;i="6.01,159,1684825200"; d="scan'208";a="781357733" Received: from ettammin-mobl1.ger.corp.intel.com (HELO thellstr-mobl1.intel.com) ([10.249.254.105]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jun 2023 02:15:02 -0700 From: =?utf-8?q?Thomas_Hellstr=C3=B6m?= To: intel-xe@lists.freedesktop.org Subject: [PATCH v2 1/4] drm/ttm: Fix ttm_lru_bulk_move_pos_tail() Date: Mon, 26 Jun 2023 11:14:47 +0200 Message-Id: <20230626091450.14757-2-thomas.hellstrom@linux.intel.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230626091450.14757-1-thomas.hellstrom@linux.intel.com> References: <20230626091450.14757-1-thomas.hellstrom@linux.intel.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Thomas_Hellstr=C3=B6m?= , Daniel Vetter , intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, dri-devel@lists.freedesktop.org, Andi Shyti , =?utf-8?q?Christian_K=C3=B6nig?= , =?utf-8?q?Christian_K=C3=B6nig?= Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The value of pos->first was not updated when the first resource of the range was moved. This could lead to errors like the one below. Fix this by updating pos->first when needed. <3> [218.963342] BUG: KASAN: null-ptr-deref in ttm_lru_bulk_move_del+0xc5/0x180 [ttm] <3> [218.963456] Read of size 8 at addr 0000000000000038 by task xe_evict/1529 <3> [218.963546] <3> [218.963566] CPU: 0 PID: 1529 Comm: xe_evict Not tainted 6.3.0-xe #1 <3> [218.963664] Hardware name: Intel Corporation Tiger Lake Client Platform/TigerLake H DDR4 SODIMM RVP, BIOS TGLSFWI1.R00.4064.A00.2102041619 02/04/2021 <3> [218.963841] Call Trace: <3> [218.963881] <3> [218.963915] dump_stack_lvl+0x64/0xb0 <3> [218.963976] print_report+0x3e5/0x600 <3> [218.964036] ? ttm_lru_bulk_move_del+0xc5/0x180 [ttm] <3> [218.964127] kasan_report+0x96/0xc0 <3> [218.964183] ? ttm_lru_bulk_move_del+0xc5/0x180 [ttm] <3> [218.964276] ttm_lru_bulk_move_del+0xc5/0x180 [ttm] <3> [218.964365] ttm_bo_set_bulk_move+0x92/0x140 [ttm] <3> [218.964454] xe_gem_object_close+0xc8/0x120 [xe] <3> [218.964675] ? __pfx_xe_gem_object_close+0x10/0x10 [xe] <3> [218.964908] ? drm_gem_object_handle_put_unlocked+0xc7/0x170 [drm] <3> [218.965071] drm_gem_object_release_handle+0x45/0x80 [drm] <3> [218.965220] ? __pfx_drm_gem_object_release_handle+0x10/0x10 [drm] <3> [218.965381] idr_for_each+0xc9/0x180 <3> [218.965437] ? __pfx_idr_for_each+0x10/0x10 <3> [218.965504] drm_gem_release+0x20/0x30 [drm] <3> [218.965637] drm_file_free.part.0+0x4cb/0x4f0 [drm] <3> [218.965778] ? drm_close_helper.isra.0+0xb7/0xe0 [drm] <3> [218.965921] drm_release_noglobal+0x49/0x90 [drm] <3> [218.966061] __fput+0x122/0x450 <3> [218.966115] task_work_run+0xfe/0x190 <3> [218.966175] ? __pfx_task_work_run+0x10/0x10 <3> [218.966239] ? do_raw_spin_unlock+0xa7/0x140 <3> [218.966308] do_exit+0x55f/0x1430 <3> [218.966364] ? __pfx_lock_release+0x10/0x10 <3> [218.966431] ? do_raw_spin_lock+0x11d/0x1e0 <3> [218.966498] ? __pfx_do_exit+0x10/0x10 <3> [218.966554] ? __pfx_do_raw_spin_lock+0x10/0x10 <3> [218.966625] ? mark_held_locks+0x24/0x90 <3> [218.966688] ? lockdep_hardirqs_on_prepare+0x136/0x210 <3> [218.966768] do_group_exit+0x68/0x110 <3> [218.966828] __x64_sys_exit_group+0x2c/0x30 <3> [218.966896] do_syscall_64+0x3c/0x90 <3> [218.966955] entry_SYSCALL_64_after_hwframe+0x72/0xdc <3> [218.967035] RIP: 0033:0x7f77b194f146 <3> [218.967094] Code: Unable to access opcode bytes at 0x7f77b194f11c. <3> [218.967174] RSP: 002b:00007ffc64791188 EFLAGS: 00000246 ORIG_RAX: 00000000000000e7 <3> [218.967271] RAX: ffffffffffffffda RBX: 00007f77b1a548a0 RCX: 00007f77b194f146 <3> [218.967364] RDX: 0000000000000062 RSI: 000000000000003c RDI: 0000000000000062 <3> [218.967458] RBP: 0000000000000062 R08: 00000000000000e7 R09: ffffffffffffff78 <3> [218.967553] R10: 0000000000000058 R11: 0000000000000246 R12: 00007f77b1a548a0 <3> [218.967648] R13: 0000000000000003 R14: 00007f77b1a5d2e8 R15: 0000000000000000 <3> [218.967745] Fixes: fee2ede15542 ("drm/ttm: rework bulk move handling v5") Cc: "Christian König" Cc: "Christian König" Cc: Daniel Vetter Cc: dri-devel@lists.freedesktop.org Cc: # v5.19+ Link: https://gitlab.freedesktop.org/drm/xe/kernel/-/issues/411 Signed-off-by: Thomas Hellström --- drivers/gpu/drm/ttm/ttm_resource.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/gpu/drm/ttm/ttm_resource.c b/drivers/gpu/drm/ttm/ttm_resource.c index 7333f7a87a2f..cb05e0a36576 100644 --- a/drivers/gpu/drm/ttm/ttm_resource.c +++ b/drivers/gpu/drm/ttm/ttm_resource.c @@ -86,6 +86,8 @@ static void ttm_lru_bulk_move_pos_tail(struct ttm_lru_bulk_move_pos *pos, struct ttm_resource *res) { if (pos->last != res) { + if (pos->first == res) + pos->first = list_next_entry(res, lru); list_move(&res->lru, &pos->last->lru); pos->last = res; } From patchwork Mon Jun 26 09:14:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Hellstr=C3=B6m?= X-Patchwork-Id: 13292546 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 764ECEB64D7 for ; Mon, 26 Jun 2023 09:15:18 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BA78D10E1D0; Mon, 26 Jun 2023 09:15:12 +0000 (UTC) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3E46A10E1CC; Mon, 26 Jun 2023 09:15:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1687770908; x=1719306908; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=8NHvqn83ZvFUkevP/WNZb8GNDLDy33tL9NNl4xX0eyI=; b=eReJh9QSXmeyxS0FkZ0jKd+wIsCnWGQGk/F0TqNielT2dJnZHxi9y7dV HzeB+uBeL3EnROMulhX5gCpzHOJK1O8SE933vLS0FwJsDHf1jDe5NXoDX sOfVWRH6iWa8AGmdTSHTlN/caJvm+7cbC3c85RttPeIlMATlaOzxNGn16 mCb6eMMNZ4VoFjffkHMJ+shgxo1eEx4pSg4wQ3/GJKuAk8l/fBBFbbSP8 JSd/zNiMzH6O4EIxqS7RdrMH9dcJUjzEXl8ZBUD679/ZwkIcFR6d8Vx4V 9W36gPJSLSfZ2E2LZlvva9bvZl+y7HFdfPlzaQm2WLaVw1q46IWndT6Dy A==; X-IronPort-AV: E=McAfee;i="6600,9927,10752"; a="345974098" X-IronPort-AV: E=Sophos;i="6.01,159,1684825200"; d="scan'208";a="345974098" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jun 2023 02:15:07 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10752"; a="781357775" X-IronPort-AV: E=Sophos;i="6.01,159,1684825200"; d="scan'208";a="781357775" Received: from ettammin-mobl1.ger.corp.intel.com (HELO thellstr-mobl1.intel.com) ([10.249.254.105]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jun 2023 02:15:05 -0700 From: =?utf-8?q?Thomas_Hellstr=C3=B6m?= To: intel-xe@lists.freedesktop.org Subject: [PATCH v2 2/4] drm/ttm: Don't shadow the operation context Date: Mon, 26 Jun 2023 11:14:48 +0200 Message-Id: <20230626091450.14757-3-thomas.hellstrom@linux.intel.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230626091450.14757-1-thomas.hellstrom@linux.intel.com> References: <20230626091450.14757-1-thomas.hellstrom@linux.intel.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Matthew Brost , =?utf-8?q?Thomas_Hellstr=C3=B6m?= , =?utf-8?q?Christian_K=C3=B6nig?= , intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, Roger He , dri-devel@lists.freedesktop.org, Andi Shyti , =?utf-8?q?Christian_K=C3=B6nig?= Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" ttm_bo_swapout() shadows the ttm operation context which may cause major confusion in driver callbacks when swapping out !TTM_PL_SYSTEM memory. Fix this by reusing the operation context argument to ttm_bo_swapout(). Cc: "Christian König" Cc: Roger He Cc: Cc: Cc: # v4.16+ Fixes: dc947770cf34 ("drm/ttm: enable swapout for reserved BOs during allocation") Signed-off-by: Thomas Hellström Acked-by: Matthew Brost --- drivers/gpu/drm/ttm/ttm_bo.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c index bd5dae4d1624..615d30c4262d 100644 --- a/drivers/gpu/drm/ttm/ttm_bo.c +++ b/drivers/gpu/drm/ttm/ttm_bo.c @@ -1154,7 +1154,6 @@ int ttm_bo_swapout(struct ttm_buffer_object *bo, struct ttm_operation_ctx *ctx, * Move to system cached */ if (bo->resource->mem_type != TTM_PL_SYSTEM) { - struct ttm_operation_ctx ctx = { false, false }; struct ttm_resource *evict_mem; struct ttm_place hop; @@ -1164,7 +1163,7 @@ int ttm_bo_swapout(struct ttm_buffer_object *bo, struct ttm_operation_ctx *ctx, if (unlikely(ret)) goto out; - ret = ttm_bo_handle_move_mem(bo, evict_mem, true, &ctx, &hop); + ret = ttm_bo_handle_move_mem(bo, evict_mem, true, ctx, &hop); if (unlikely(ret != 0)) { WARN(ret == -EMULTIHOP, "Unexpected multihop in swaput - likely driver bug.\n"); goto out; From patchwork Mon Jun 26 09:14:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Hellstr=C3=B6m?= X-Patchwork-Id: 13292547 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 72063EB64D7 for ; Mon, 26 Jun 2023 09:15:20 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A671D10E1D9; Mon, 26 Jun 2023 09:15:14 +0000 (UTC) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1ED2910E1D0; Mon, 26 Jun 2023 09:15:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1687770912; x=1719306912; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=wfgL9qGgPwrycb+pq8eWWsXWs7vH+aYL2R+tvWwCzhA=; b=GclskB8oK8soLkc0zhCIwF99jx8si8BHqszmcvrCs1ZSI7947fVvBufr F1EddqeR16Xm/YKXyGg8uoj8fadiGVKoEd8qHMFwTQorad0aDJuh3BQKp 3meHeSICXkxMTPd/GozVLFpSq+XSKMHM7Pz+j6ExYPawgcDpmlDcBPO6T c+7Q5xo3TY01FGjC4HaTfB/1OavPkMMuX0iT+P3lv+uYcHngViHzzHm5U M34z4vLOJ3gDZnOuUwdn51URcBQZ5YXVw9dJIUwA81i3hZR6frjApuu7A IoLto/mhOG05+D52jRLGioZ7KpdLTmoR1QJWvmv34O3GYwr7FDBNOZO4E A==; X-IronPort-AV: E=McAfee;i="6600,9927,10752"; a="345974123" X-IronPort-AV: E=Sophos;i="6.01,159,1684825200"; d="scan'208";a="345974123" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jun 2023 02:15:11 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10752"; a="781357795" X-IronPort-AV: E=Sophos;i="6.01,159,1684825200"; d="scan'208";a="781357795" Received: from ettammin-mobl1.ger.corp.intel.com (HELO thellstr-mobl1.intel.com) ([10.249.254.105]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jun 2023 02:15:08 -0700 From: =?utf-8?q?Thomas_Hellstr=C3=B6m?= To: intel-xe@lists.freedesktop.org Subject: [PATCH v2 3/4] drm/ttm: Don't leak a resource on eviction error Date: Mon, 26 Jun 2023 11:14:49 +0200 Message-Id: <20230626091450.14757-4-thomas.hellstrom@linux.intel.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230626091450.14757-1-thomas.hellstrom@linux.intel.com> References: <20230626091450.14757-1-thomas.hellstrom@linux.intel.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Thomas_Hellstr=C3=B6m?= , Andrey Grodzovsky , =?utf-8?q?Christian_K=C3=B6n?= =?utf-8?q?ig?= , intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, Huang Rui , dri-devel@lists.freedesktop.org, Andi Shyti , =?utf-8?q?Christian_K=C3=B6nig?= , Nirmoy Das Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" On eviction errors other than -EMULTIHOP we were leaking a resource. Fix. v2: - Avoid yet another goto (Andi Shyti) Fixes: 403797925768 ("drm/ttm: Fix multihop assert on eviction.") Cc: Andrey Grodzovsky Cc: Christian König Cc: Christian Koenig Cc: Huang Rui Cc: dri-devel@lists.freedesktop.org Cc: # v5.15+ Signed-off-by: Thomas Hellström Reviewed-by: Nirmoy Das #v1 Reviewed-by: Andi Shyti Reviewed-by: Christian König --- drivers/gpu/drm/ttm/ttm_bo.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c index 615d30c4262d..c0e3bbd21d3d 100644 --- a/drivers/gpu/drm/ttm/ttm_bo.c +++ b/drivers/gpu/drm/ttm/ttm_bo.c @@ -458,18 +458,18 @@ static int ttm_bo_evict(struct ttm_buffer_object *bo, goto out; } -bounce: - ret = ttm_bo_handle_move_mem(bo, evict_mem, true, ctx, &hop); - if (ret == -EMULTIHOP) { + do { + ret = ttm_bo_handle_move_mem(bo, evict_mem, true, ctx, &hop); + if (ret != -EMULTIHOP) + break; + ret = ttm_bo_bounce_temp_buffer(bo, &evict_mem, ctx, &hop); - if (ret) { - if (ret != -ERESTARTSYS && ret != -EINTR) - pr_err("Buffer eviction failed\n"); - ttm_resource_free(bo, &evict_mem); - goto out; - } - /* try and move to final place now. */ - goto bounce; + } while (!ret); + + if (ret) { + ttm_resource_free(bo, &evict_mem); + if (ret != -ERESTARTSYS && ret != -EINTR) + pr_err("Buffer eviction failed\n"); } out: return ret; From patchwork Mon Jun 26 09:14:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Hellstr=C3=B6m?= X-Patchwork-Id: 13292548 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CACE4EB64D7 for ; Mon, 26 Jun 2023 09:15:23 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 05BF010E1DB; Mon, 26 Jun 2023 09:15:19 +0000 (UTC) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by gabe.freedesktop.org (Postfix) with ESMTPS id 49B7610E1D9; Mon, 26 Jun 2023 09:15:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1687770914; x=1719306914; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=63Y0TPem7frMMGW3N/FgR3d/cjkXyqdp+LijdVM6QYA=; b=mFX3pFT+hTbMAKp3apbGTMrvH3o3srV3sgN5/QrYTkCzMBfg8xKxg5Ik Rv7rMuoKMXtf+htvZIQ1/Ym6S0URq7Ed3Za58ZWVZRvfO5yNJl2bLqLLd xwM3D/H8dKyshc8S6sfME5BBR8lbgpRNOpKNaIU2GfVVOxVySq+WIrdl6 eShDow537BAqj9KMMD6QiCad3VGFodjV2VQPGlna4ECqjoqfxT/7kxSNz VAGvmnn92N5r0B29r2ISggW0dOBiSzgKSHJQg3UZQsJJaZIrCLA70Sh/X K5W8/8IpbSMbJLGgrfvrHq+vmjjj2mwkDE/S41qAAhEL/lmVl4d15OUZF Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10752"; a="345974134" X-IronPort-AV: E=Sophos;i="6.01,159,1684825200"; d="scan'208";a="345974134" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jun 2023 02:15:13 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10752"; a="781357838" X-IronPort-AV: E=Sophos;i="6.01,159,1684825200"; d="scan'208";a="781357838" Received: from ettammin-mobl1.ger.corp.intel.com (HELO thellstr-mobl1.intel.com) ([10.249.254.105]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jun 2023 02:15:11 -0700 From: =?utf-8?q?Thomas_Hellstr=C3=B6m?= To: intel-xe@lists.freedesktop.org Subject: [PATCH v2 4/4] drm/ttm: Don't leak a resource on swapout move error Date: Mon, 26 Jun 2023 11:14:50 +0200 Message-Id: <20230626091450.14757-5-thomas.hellstrom@linux.intel.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230626091450.14757-1-thomas.hellstrom@linux.intel.com> References: <20230626091450.14757-1-thomas.hellstrom@linux.intel.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Thomas_Hellstr=C3=B6m?= , =?utf-8?q?Christian_K=C3=B6nig?= , intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, dri-devel@lists.freedesktop.org, Andi Shyti , =?utf-8?q?Christian_K=C3=B6nig?= , Nirmoy Das Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" If moving the bo to system for swapout failed, we were leaking a resource. Fix. Fixes: bfa3357ef9ab ("drm/ttm: allocate resource object instead of embedding it v2") Cc: Christian König Cc: "Christian König" Cc: dri-devel@lists.freedesktop.org Cc: # v5.14+ Signed-off-by: Thomas Hellström Reviewed-by: Nirmoy Das Reviewed-by: Andi Shyti Reviewed-by: Christian König --- drivers/gpu/drm/ttm/ttm_bo.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c index c0e3bbd21d3d..d9a8f227f310 100644 --- a/drivers/gpu/drm/ttm/ttm_bo.c +++ b/drivers/gpu/drm/ttm/ttm_bo.c @@ -1166,6 +1166,7 @@ int ttm_bo_swapout(struct ttm_buffer_object *bo, struct ttm_operation_ctx *ctx, ret = ttm_bo_handle_move_mem(bo, evict_mem, true, ctx, &hop); if (unlikely(ret != 0)) { WARN(ret == -EMULTIHOP, "Unexpected multihop in swaput - likely driver bug.\n"); + ttm_resource_free(bo, &evict_mem); goto out; } }