From patchwork Thu Dec 19 10:16:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rolf Eike Beer X-Patchwork-Id: 13915198 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 0CBA2E7718C for ; Thu, 19 Dec 2024 16:07:30 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3C68610E4A4; Thu, 19 Dec 2024 16:07:26 +0000 (UTC) Received: from mx1.emlix.com (mx1.emlix.com [178.63.209.131]) by gabe.freedesktop.org (Postfix) with ESMTPS id 308BF10E2BB for ; Thu, 19 Dec 2024 10:26:42 +0000 (UTC) Received: from mailer.emlix.com (p5098be52.dip0.t-ipconnect.de [80.152.190.82]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.emlix.com (Postfix) with ESMTPS id B17CC5F8DD; Thu, 19 Dec 2024 11:18:36 +0100 (CET) From: Rolf Eike Beer To: Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Tvrtko Ursulin Cc: intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] drm/i915/selftests: check the return value of i915_gem_object_trylock() Date: Thu, 19 Dec 2024 11:16:51 +0100 Message-ID: <9379466.CDJkKcVGEf@devpool47.emlix.com> Organization: emlix GmbH In-Reply-To: <7746997.EvYhyI6sBW@devpool47.emlix.com> References: <7746997.EvYhyI6sBW@devpool47.emlix.com> MIME-Version: 1.0 X-Mailman-Approved-At: Thu, 19 Dec 2024 16:07:24 +0000 X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" A trylock can fail, in which case operating on the object is unsafe and unconditionally unlocking is wrong. Signed-off-by: Rolf Eike Beer --- drivers/gpu/drm/i915/gt/selftest_migrate.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/i915/gt/selftest_migrate.c b/drivers/gpu/drm/i915/gt/selftest_migrate.c index ca460cee4f8b..b2cb501febe8 100644 --- a/drivers/gpu/drm/i915/gt/selftest_migrate.c +++ b/drivers/gpu/drm/i915/gt/selftest_migrate.c @@ -822,7 +822,10 @@ create_init_lmem_internal(struct intel_gt *gt, size_t sz, bool try_lmem) return obj; } - i915_gem_object_trylock(obj, NULL); + if (!i915_gem_object_trylock(obj, NULL)) { + i915_gem_object_put(obj); + return ERR_PTR(-EBUSY); + } err = i915_gem_object_pin_pages(obj); if (err) { i915_gem_object_unlock(obj);