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: Thomas Hellstrom 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;