From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ben Widawsky Subject: [PATCH 4/5] drm/i915: more semaphore cleanup Date: Thu, 15 Sep 2011 19:09:00 -0700 Message-ID: <1316138941-6537-5-git-send-email-ben@bwidawsk.net> References: <1316138941-6537-1-git-send-email-ben@bwidawsk.net> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from cloud01.chad-versace.us (184-106-247-128.static.cloud-ips.com [184.106.247.128]) by gabe.freedesktop.org (Postfix) with ESMTP id AF52C9E8B8 for ; Thu, 15 Sep 2011 19:08:56 -0700 (PDT) In-Reply-To: <1316138941-6537-1-git-send-email-ben@bwidawsk.net> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: intel-gfx-bounces+gcfxdi-intel-gfx=m.gmane.org@lists.freedesktop.org Errors-To: intel-gfx-bounces+gcfxdi-intel-gfx=m.gmane.org@lists.freedesktop.org To: intel-gfx@lists.freedesktop.org Cc: Daniel Vetter , Ben Widawsky List-Id: intel-gfx@lists.freedesktop.org This turns the black magic into brown magic. It's arguable whether or not this is more readable than the existing code. It does add a nice assertion, fewer lines of actual code, and some nice comments - as well as sticking to semantics now used in the ringbuffer code. Cc: Daniel Vetter Signed-off-by: Ben Widawsky --- drivers/gpu/drm/i915/intel_ringbuffer.h | 26 ++++++++++++-------------- 1 files changed, 12 insertions(+), 14 deletions(-) diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.h b/drivers/gpu/drm/i915/intel_ringbuffer.h index 61790c8..e4516e4 100644 --- a/drivers/gpu/drm/i915/intel_ringbuffer.h +++ b/drivers/gpu/drm/i915/intel_ringbuffer.h @@ -119,23 +119,21 @@ intel_ring_flag(struct intel_ring_buffer *ring) return (1 << ring->id); } +/* intel_ring_sync_index - return the index (0-n, where n is total rings - 1) + * of the ring we're synchronizing to. + * + * @signaller - ring which last updated the mailbox + * @waiter - ring waiting on seqno in mailbox + */ static inline u32 -intel_ring_sync_index(struct intel_ring_buffer *ring, - struct intel_ring_buffer *other) +intel_ring_sync_index(struct intel_ring_buffer *signaller, + struct intel_ring_buffer *waiter) { - int idx; - - /* - * cs -> 0 = vcs, 1 = bcs - * vcs -> 0 = bcs, 1 = cs, - * bcs -> 0 = cs, 1 = vcs. + /* This bit of magic is based on the fact that there are 3 rings, and + * the value of bit 17 is a unique way to identify the mailbox */ - - idx = (other->id - ring->id) - 1; - if (idx < 0) - idx += I915_NUM_RINGS; - - return idx; + BUG_ON(signaller->semaphore_register[waiter->id] >> 17 > 1); + return (signaller->semaphore_register[waiter->id] >> 17); } static inline u32 -- 1.7.6.1