@@ -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;
@@ -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;
@@ -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,