From patchwork Tue Aug 24 10:27:33 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuanhan Liu X-Patchwork-Id: 123811 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by demeter.kernel.org (8.14.4/8.14.3) with ESMTP id o7NASGfG009522 for ; Mon, 23 Aug 2010 10:28:51 GMT Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id ACDC59EED8 for ; Mon, 23 Aug 2010 03:28:16 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by gabe.freedesktop.org (Postfix) with ESMTP id E14849E7EE for ; Mon, 23 Aug 2010 03:27:45 -0700 (PDT) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP; 23 Aug 2010 03:27:45 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.56,256,1280732400"; d="scan'208";a="650288967" Received: from unknown (HELO localhost.localdomain.sh.intel.com) ([10.239.36.8]) by orsmga001.jf.intel.com with ESMTP; 23 Aug 2010 03:27:45 -0700 From: Yuanhan Liu To: intel-gfx@lists.freedesktop.org Date: Tue, 24 Aug 2010 18:27:33 +0800 Message-Id: <1282645653-7870-2-git-send-email-yuanhan.liu@intel.com> X-Mailer: git-send-email 1.7.2.1 In-Reply-To: <1282645653-7870-1-git-send-email-yuanhan.liu@intel.com> References: <1282645653-7870-1-git-send-email-yuanhan.liu@intel.com> Subject: [Intel-gfx] [PATCH 2/2] drm/i915: ringbuffer: Add a helper function to update ring buffer space X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: intel-gfx-bounces+patchwork-intel-gfx=patchwork.kernel.org@lists.freedesktop.org Errors-To: intel-gfx-bounces+patchwork-intel-gfx=patchwork.kernel.org@lists.freedesktop.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Mon, 23 Aug 2010 10:28:51 +0000 (UTC) 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,