From patchwork Thu Jun 13 22:24:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andi Shyti X-Patchwork-Id: 13697549 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 AD851C27C4F for ; Thu, 13 Jun 2024 22:27:16 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id EEBB510EBDB; Thu, 13 Jun 2024 22:27:15 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="gvr/FziJ"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.9]) by gabe.freedesktop.org (Postfix) with ESMTPS id A6E1010EBDC; Thu, 13 Jun 2024 22:27:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1718317633; x=1749853633; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=7QDd6cePhK8QHB5XjMVL3VXLSQFYxqKwR/SMxkipkhk=; b=gvr/FziJGsMppHXvZ7EIAZuIxxjr/Q/C0jw2PJZM0iNUn3E+8k3ihURL Q2LTS4ZmDS3+KsZ1zwKfqT84KbFfTzXPkOMmf/nkPdaYGKqutfE3XFZvn 5sGRQGppt62BDc+8Yih3ps0+LYMl4dSEoxfQ/n6NZ8nKxj4N0mSD6cZlt LJmJ+c5mXDrRw/jQ/xdIxmjej3n5YeFpaZ+d2eIWhcJkDMoIT4HHz0mh1 6ShINXsYtktkiLkfyXgExxWdG+oJt/Smxm0DDyzASTs0vzAViuGCwmF3f 3+UU2h5rP0MRxGN6mi91latcbgNRBhyPxe3bhDn/fNUdRXURqr7XqTxpB A==; X-CSE-ConnectionGUID: T1VIy+3iTpKdgsfgsW1DGw== X-CSE-MsgGUID: WW9HO6I0Ssy3O6Dsova5Wg== X-IronPort-AV: E=McAfee;i="6700,10204,11102"; a="25855172" X-IronPort-AV: E=Sophos;i="6.08,236,1712646000"; d="scan'208";a="25855172" Received: from orviesa008.jf.intel.com ([10.64.159.148]) by fmvoesa103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Jun 2024 15:24:19 -0700 X-CSE-ConnectionGUID: Bd3wn/CvSNqWtRRM4iePqg== X-CSE-MsgGUID: B+dQYD1XR0+4DFWauxRZWw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,236,1712646000"; d="scan'208";a="40963074" Received: from bergbenj-mobl1.ger.corp.intel.com (HELO intel.com) ([10.245.246.176]) by orviesa008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Jun 2024 15:24:16 -0700 From: Andi Shyti To: intel-gfx , dri-devel Cc: Andi Shyti , Matthew Brost , Daniele Ceraolo Spurio Subject: [PATCH] drm/i915/gt/uc: Evaluate GuC priority within locks Date: Fri, 14 Jun 2024 00:24:01 +0200 Message-ID: <20240613222402.551625-1-andi.shyti@linux.intel.com> X-Mailer: git-send-email 2.45.1 MIME-Version: 1.0 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" The ce->guc_state.lock was made to protect guc_prio, which indicates the GuC priority level. But at the begnning of the function we perform some sanity check of guc_prio outside its protected section. Move them within the locked region. Use this occasion to expand the if statement to make it clearer. Signed-off-by: Andi Shyti Cc: Matthew Brost Reviewed-by: Matthew Brost --- Cc: Daniele Ceraolo Spurio Changelog ========= - Removed the stable tags as this path is not normally under multi task stress. - Refactored the if statements in order to remove unnecessary checks (thanks, Daniele) - Added Matt's r-b. .../gpu/drm/i915/gt/uc/intel_guc_submission.c | 27 +++++++++++-------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c b/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c index 0eaa1064242c..9400d0eb682b 100644 --- a/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c +++ b/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c @@ -4267,20 +4267,25 @@ static void guc_bump_inflight_request_prio(struct i915_request *rq, u8 new_guc_prio = map_i915_prio_to_guc_prio(prio); /* Short circuit function */ - if (prio < I915_PRIORITY_NORMAL || - rq->guc_prio == GUC_PRIO_FINI || - (rq->guc_prio != GUC_PRIO_INIT && - !new_guc_prio_higher(rq->guc_prio, new_guc_prio))) + if (prio < I915_PRIORITY_NORMAL) return; spin_lock(&ce->guc_state.lock); - if (rq->guc_prio != GUC_PRIO_FINI) { - if (rq->guc_prio != GUC_PRIO_INIT) - sub_context_inflight_prio(ce, rq->guc_prio); - rq->guc_prio = new_guc_prio; - add_context_inflight_prio(ce, rq->guc_prio); - update_context_prio(ce); - } + + if (rq->guc_prio == GUC_PRIO_FINI) + goto exit; + + if (!new_guc_prio_higher(rq->guc_prio, new_guc_prio)) + goto exit; + + if (rq->guc_prio != GUC_PRIO_INIT) + sub_context_inflight_prio(ce, rq->guc_prio); + + rq->guc_prio = new_guc_prio; + add_context_inflight_prio(ce, rq->guc_prio); + update_context_prio(ce); + +exit: spin_unlock(&ce->guc_state.lock); }