From mboxrd@z Thu Jan 1 00:00:00 1970 From: Tvrtko Ursulin Subject: Re: [PATCH] drm/i915: Broadwell expands ACTHD to 64bit Date: Fri, 21 Mar 2014 12:19:28 +0000 Message-ID: <532C2E50.7030009@linux.intel.com> References: <532B1DD9.8010008@linux.intel.com> <1395352091-24460-1-git-send-email-chris@chris-wilson.co.uk> <532C0E7A.9090900@linux.intel.com> <20140321101428.GE5419@nuc-i3427.alporthouse.com> <532C195D.6010708@linux.intel.com> <20140321120054.GF5419@nuc-i3427.alporthouse.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; Format="flowed" Content-Transfer-Encoding: 7bit Return-path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by gabe.freedesktop.org (Postfix) with ESMTP id DD75E6E2E1 for ; Fri, 21 Mar 2014 05:19:30 -0700 (PDT) In-Reply-To: <20140321120054.GF5419@nuc-i3427.alporthouse.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" To: Chris Wilson , intel-gfx@lists.freedesktop.org, Ben Widawsky , Timo Aaltonen List-Id: intel-gfx@lists.freedesktop.org On 03/21/2014 12:00 PM, Chris Wilson wrote: > On Fri, Mar 21, 2014 at 10:50:05AM +0000, Tvrtko Ursulin wrote: >> No, think you misunderstood me. I said "slightly more defensive" >> just in the sense that in case of weird hardware failures you have a >> potentially infinite loop now, where you don't really need a loop - >> probabilities strongly suggest you cannot get two upper dword wraps >> between the reads. So it is enough to read the upper dword twice, >> without the loop. Same effect, slightly more defensive in reality. > > Yup, misunderstood what you wanted. If in doubt, C is much more > concise ;-) > > diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.c b/drivers/gpu/drm/i915/intel_ringbuffer.c > index 45d8011..8c82316 100644 > --- a/drivers/gpu/drm/i915/intel_ringbuffer.c > +++ b/drivers/gpu/drm/i915/intel_ringbuffer.c > @@ -425,12 +425,14 @@ u64 intel_ring_get_active_head(struct intel_ring_buffer *ring) > if (INTEL_INFO(ring->dev)->gen >= 8) { > u32 upper, lower, tmp; > > + upper = I915_READ(RING_ACTHD_UDW(ring->mmio_base)); > + lower = I915_READ(RING_ACTHD(ring->mmio_base)); > tmp = I915_READ(RING_ACTHD_UDW(ring->mmio_base)); > - do { > + if (upper != tmp) { > upper = tmp; > lower = I915_READ(RING_ACTHD(ring->mmio_base)); > - tmp = I915_READ(RING_ACTHD_UDW(ring->mmio_base)); > - } while (upper != tmp); > + WARN_ON(I915_READ(RING_ACTHD_UDW(ring->mmio_base) != upper); > + } > > acthd = (u64)upper << 32 | lower; > } else if (INTEL_INFO(ring->dev)->gen >= 4) Yes, I was just uneasy with the loop. Also Ben's suggestion in case of wrap was I think: WARN_ON(I915_READ(RING_ACTHD(ring->mmio_base) >= lower); Or in other words, if we have observed the upper wrap, check that the lower matches with that observation. But I feel bad now that we are over-engineering this. Perhaps these WARNs are just silly. Tvrtko