From patchwork Fri Jun 27 22:09:45 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Widawsky X-Patchwork-Id: 4437951 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.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id DBAF5BEEAA for ; Fri, 27 Jun 2014 22:09:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1573620221 for ; Fri, 27 Jun 2014 22:09:52 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 2DCD32021B for ; Fri, 27 Jun 2014 22:09:51 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B97B26E828; Fri, 27 Jun 2014 15:09:50 -0700 (PDT) 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 51C196E828 for ; Fri, 27 Jun 2014 15:09:49 -0700 (PDT) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga101.jf.intel.com with ESMTP; 27 Jun 2014 15:09:49 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.01,563,1400050800"; d="scan'208";a="535294737" Received: from ironside.jf.intel.com ([10.7.197.216]) by orsmga001.jf.intel.com with ESMTP; 27 Jun 2014 15:09:48 -0700 From: Ben Widawsky To: Intel GFX Date: Fri, 27 Jun 2014 15:09:45 -0700 Message-Id: <1403906985-11045-1-git-send-email-benjamin.widawsky@intel.com> X-Mailer: git-send-email 2.0.0 Cc: Ben Widawsky , Ben Widawsky Subject: [Intel-gfx] [PATCH] drm/i915: Fix some NUM_RING iterators X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.15 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=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_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 There are some cases in the code where we need to know how many rings to iterate over, but cannot use for_each_ring(). These are always error cases which happen either before ring setup, or after ring teardown (or reset). Note, a NUM_RINGS issue exists in semaphores, but this is fixed by the remaining semaphore patches which Rodrigo will resubmit shortly. I'd rather see those patches for fixing the problem than fix it here. I found this initially for the BSD2 case where on the same platform we can have differing rings. AFAICT however this effects many platforms. I'd CC stable on this, except I think all the issues have been around for multiple releases without bug reports. Compile tested only for now. Signed-off-by: Ben Widawsky Reviewed-by: Rodrigo Vivi --- drivers/gpu/drm/i915/i915_gem_context.c | 6 +++--- drivers/gpu/drm/i915/i915_gpu_error.c | 2 +- drivers/gpu/drm/i915/intel_ringbuffer.h | 2 ++ 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_gem_context.c b/drivers/gpu/drm/i915/i915_gem_context.c index b9bac25..0c044a9 100644 --- a/drivers/gpu/drm/i915/i915_gem_context.c +++ b/drivers/gpu/drm/i915/i915_gem_context.c @@ -403,7 +403,7 @@ void i915_gem_context_reset(struct drm_device *dev) /* Prevent the hardware from restoring the last context (which hung) on * the next switch */ - for (i = 0; i < I915_NUM_RINGS; i++) { + for (i = 0; i < I915_ACTIVE_RINGS(dev); i++) { struct intel_engine_cs *ring = &dev_priv->ring[i]; struct intel_context *dctx = ring->default_context; @@ -456,7 +456,7 @@ int i915_gem_context_init(struct drm_device *dev) } /* NB: RCS will hold a ref for all rings */ - for (i = 0; i < I915_NUM_RINGS; i++) + for (i = 0; i < I915_ACTIVE_RINGS(dev); i++) dev_priv->ring[i].default_context = ctx; DRM_DEBUG_DRIVER("%s context support initialized\n", dev_priv->hw_context_size ? "HW" : "fake"); @@ -493,7 +493,7 @@ void i915_gem_context_fini(struct drm_device *dev) i915_gem_object_ggtt_unpin(dctx->obj); } - for (i = 0; i < I915_NUM_RINGS; i++) { + for (i = 0; i < I915_ACTIVE_RINGS(dev); i++) { struct intel_engine_cs *ring = &dev_priv->ring[i]; if (ring->last_context) diff --git a/drivers/gpu/drm/i915/i915_gpu_error.c b/drivers/gpu/drm/i915/i915_gpu_error.c index 86362de..6e5250d 100644 --- a/drivers/gpu/drm/i915/i915_gpu_error.c +++ b/drivers/gpu/drm/i915/i915_gpu_error.c @@ -848,7 +848,7 @@ static uint32_t i915_error_generate_code(struct drm_i915_private *dev_priv, * synchronization commands which almost always appear in the case * strictly a client bug. Use instdone to differentiate those some. */ - for (i = 0; i < I915_NUM_RINGS; i++) { + for (i = 0; i < I915_ACTIVE_RINGS(dev_priv->dev); i++) { if (error->ring[i].hangcheck_action == HANGCHECK_HUNG) { if (ring_id) *ring_id = i; diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.h b/drivers/gpu/drm/i915/intel_ringbuffer.h index e72017b..67e2919 100644 --- a/drivers/gpu/drm/i915/intel_ringbuffer.h +++ b/drivers/gpu/drm/i915/intel_ringbuffer.h @@ -90,6 +90,8 @@ struct intel_engine_cs { } id; #define I915_NUM_RINGS 5 #define LAST_USER_RING (VECS + 1) +#define I915_ACTIVE_RINGS(dev) hweight8(INTEL_INFO(dev)->ring_mask) + u32 mmio_base; struct drm_device *dev; struct intel_ringbuffer *buffer;