[Intel-gfx] [PATCH 4/5] drm/i915: more semaphore cleanup
Zou, Nanhai
nanhai.zou at intel.com
Fri Sep 16 07:12:23 CEST 2011
>>-----Original Message-----
>>From: intel-gfx-bounces+nanhai.zou=intel.com at lists.freedesktop.org
>>[mailto:intel-gfx-bounces+nanhai.zou=intel.com at lists.freedesktop.org] On
>>Behalf Of Ben Widawsky
>>Sent: 2011年9月16日 10:09
>>To: intel-gfx at lists.freedesktop.org
>>Cc: Daniel Vetter; Ben Widawsky
>>Subject: [Intel-gfx] [PATCH 4/5] drm/i915: more semaphore cleanup
>>
>>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 <daniel.vetter at ffwll.ch>
>>Signed-off-by: Ben Widawsky <ben at bwidawsk.net>
>>---
>> 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
Can we get rid of all those magic calculations by simple lookup table?
Consider there will be more rings in future hardware.
E.g. video enhancement ring.
Thanks
Zou Nanhai
>>
>>_______________________________________________
>>Intel-gfx mailing list
>>Intel-gfx at lists.freedesktop.org
>>http://lists.freedesktop.org/mailman/listinfo/intel-gfx
More information about the Intel-gfx
mailing list