From patchwork Thu Feb 11 18:03:09 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tvrtko Ursulin X-Patchwork-Id: 8283641 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 7FE72BEEE5 for ; Thu, 11 Feb 2016 18:03:44 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id ABE1420373 for ; Thu, 11 Feb 2016 18:03:43 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id AA68420398 for ; Thu, 11 Feb 2016 18:03:42 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3AC966E21D; Thu, 11 Feb 2016 10:03:42 -0800 (PST) X-Original-To: Intel-gfx@lists.freedesktop.org Delivered-To: Intel-gfx@lists.freedesktop.org Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by gabe.freedesktop.org (Postfix) with ESMTP id 00E8B6E21D for ; Thu, 11 Feb 2016 10:03:40 -0800 (PST) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga101.jf.intel.com with ESMTP; 11 Feb 2016 10:03:14 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.22,432,1449561600"; d="scan'208";a="650796614" Received: from tursulin-linux.isw.intel.com ([10.102.226.196]) by FMSMGA003.fm.intel.com with ESMTP; 11 Feb 2016 10:03:12 -0800 From: Tvrtko Ursulin To: Intel-gfx@lists.freedesktop.org Date: Thu, 11 Feb 2016 18:03:09 +0000 Message-Id: <1455213790-4724-1-git-send-email-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 1.9.1 Subject: [Intel-gfx] [PATCH 1/2] drm/i915: Do not return stale status / remove impossible WARN X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Spam-Status: No, score=-3.4 required=5.0 tests=BAYES_00,HK_RANDOM_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Tvrtko Ursulin Only caller to get_context_status ensures read pointer stays in range so the WARN is impossible. Also, if the WARN would be triggered by a hypothetical new caller stale status would be returned to them. Maybe it is better to wrap the pointer in the function itself then to avoid both and even results in smaller code. Signed-off-by: Tvrtko Ursulin --- drivers/gpu/drm/i915/intel_lrc.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/i915/intel_lrc.c b/drivers/gpu/drm/i915/intel_lrc.c index 89eb892df4ae..951f1e6af947 100644 --- a/drivers/gpu/drm/i915/intel_lrc.c +++ b/drivers/gpu/drm/i915/intel_lrc.c @@ -507,17 +507,16 @@ static bool execlists_check_remove_request(struct intel_engine_cs *ring, return false; } -static void get_context_status(struct intel_engine_cs *ring, - u8 read_pointer, - u32 *status, u32 *context_id) +static u32 get_context_status(struct intel_engine_cs *ring, u8 read_pointer, + u32 *context_id) { struct drm_i915_private *dev_priv = ring->dev->dev_private; - if (WARN_ON(read_pointer >= GEN8_CSB_ENTRIES)) - return; + read_pointer %= GEN8_CSB_ENTRIES; - *status = I915_READ(RING_CONTEXT_STATUS_BUF_LO(ring, read_pointer)); *context_id = I915_READ(RING_CONTEXT_STATUS_BUF_HI(ring, read_pointer)); + + return I915_READ(RING_CONTEXT_STATUS_BUF_LO(ring, read_pointer)); } /** @@ -547,9 +546,7 @@ void intel_lrc_irq_handler(struct intel_engine_cs *ring) spin_lock(&ring->execlist_lock); while (read_pointer < write_pointer) { - - get_context_status(ring, ++read_pointer % GEN8_CSB_ENTRIES, - &status, &status_id); + status = get_context_status(ring, ++read_pointer, &status_id); if (status & GEN8_CTX_STATUS_IDLE_ACTIVE) continue;