All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yuanhan Liu <yuanhan.liu@intel.com>
To: intel-gfx@lists.freedesktop.org
Subject: [PATCH 2/2] drm/i915: ringbuffer: Add a helper function to update ring buffer space
Date: Tue, 24 Aug 2010 18:27:33 +0800	[thread overview]
Message-ID: <1282645653-7870-2-git-send-email-yuanhan.liu@intel.com> (raw)
In-Reply-To: <1282645653-7870-1-git-send-email-yuanhan.liu@intel.com>

There are several places will calc the space of ring buffer. To make it clear
and simple, define a helper function called intel_ring_update_space to do this.

Signed-off-by: Yuanhan Liu <yuanhan.liu@intel.com>
---
 drivers/gpu/drm/i915/i915_dma.c         |    4 +---
 drivers/gpu/drm/i915/intel_ringbuffer.c |   14 ++++----------
 drivers/gpu/drm/i915/intel_ringbuffer.h |    8 ++++++++
 3 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
index c5d6021..aa1f311 100644
--- a/drivers/gpu/drm/i915/i915_dma.c
+++ b/drivers/gpu/drm/i915/i915_dma.c
@@ -109,9 +109,7 @@ void i915_kernel_lost_context(struct drm_device * dev)
 
 	ring->head = ring->get_head(dev, ring);
 	ring->tail = ring->get_tail(dev, ring);
-	ring->space = ring->head - (ring->tail + 8);
-	if (ring->space < 0)
-		ring->space += ring->size;
+	intel_ring_update_space(ring);
 
 	if (!dev->primary->master)
 		return;
diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.c b/drivers/gpu/drm/i915/intel_ringbuffer.c
index 0140f80..4a17851 100644
--- a/drivers/gpu/drm/i915/intel_ringbuffer.c
+++ b/drivers/gpu/drm/i915/intel_ringbuffer.c
@@ -208,9 +208,7 @@ static int init_ring_common(struct drm_device *dev,
 	else {
 		ring->head = ring->get_head(dev, ring);
 		ring->tail = ring->get_tail(dev, ring);
-		ring->space = ring->head - (ring->tail + 8);
-		if (ring->space < 0)
-			ring->space += ring->size;
+		intel_ring_update_space(ring);
 	}
 	return 0;
 }
@@ -666,9 +664,7 @@ int intel_init_ring_buffer(struct drm_device *dev,
 	else {
 		ring->head = ring->get_head(dev, ring);
 		ring->tail = ring->get_tail(dev, ring);
-		ring->space = ring->head - (ring->tail + 8);
-		if (ring->space < 0)
-			ring->space += ring->size;
+		intel_ring_update_space(ring);
 	}
 	INIT_LIST_HEAD(&ring->active_list);
 	INIT_LIST_HEAD(&ring->request_list);
@@ -721,7 +717,7 @@ int intel_wrap_ring_buffer(struct drm_device *dev,
 	}
 
 	ring->tail = 0;
-	ring->space = ring->head - 8;
+	intel_ring_update_space(ring);
 
 	return 0;
 }
@@ -735,9 +731,7 @@ int intel_wait_ring_buffer(struct drm_device *dev,
 	end = jiffies + 3 * HZ;
 	do {
 		ring->head = ring->get_head(dev, ring);
-		ring->space = ring->head - (ring->tail + 8);
-		if (ring->space < 0)
-			ring->space += ring->size;
+		intel_ring_update_space(ring);
 		if (ring->space >= n) {
 			trace_i915_ring_wait_end (dev);
 			return 0;
diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.h b/drivers/gpu/drm/i915/intel_ringbuffer.h
index 525e7d3..86d9f2e 100644
--- a/drivers/gpu/drm/i915/intel_ringbuffer.h
+++ b/drivers/gpu/drm/i915/intel_ringbuffer.h
@@ -115,6 +115,14 @@ static inline void intel_ring_emit(struct drm_device *dev,
 	ring->tail += 4;
 }
 
+static inline void intel_ring_update_space(struct intel_ring_buffer *ring)
+{
+	ring->space = ring->head - (ring->tail + 8);
+	if (ring->space < 0)
+		ring->space += ring->size;
+}
+
+
 void intel_fill_struct(struct drm_device *dev,
 		struct intel_ring_buffer *ring,
 		void *data,
-- 
1.7.2.1

  parent reply	other threads:[~2010-08-23 10:27 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-24 10:27 [PATCH 1/2] drm/i915: ringbuffer: use defined get_head/tail method Yuanhan Liu
2010-08-23 11:16 ` Chris Wilson
2010-08-24 10:27 ` Yuanhan Liu [this message]
2010-08-23 11:13   ` [PATCH 2/2] drm/i915: ringbuffer: Add a helper function to update ring buffer space Chris Wilson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1282645653-7870-2-git-send-email-yuanhan.liu@intel.com \
    --to=yuanhan.liu@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.