diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2009-06-17 17:08:52 -0400 |
---|---|---|
committer | Eric Anholt <eric@anholt.net> | 2009-06-18 14:47:04 -0400 |
commit | 8c4b8c3f34de4e2da20df042bba173fe557f8b45 (patch) | |
tree | 665c717af9a0b630303294bcbe48d9cafb10f186 /drivers/gpu/drm | |
parent | d78b47b9a527bf46cb6081555847facd6efd5f81 (diff) |
drm/i915: Install fence register for tiled scanout on i915
With the work by Jesse Barnes to eliminate allocation of fences during
execbuffer, it becomes possible to write to the scan-out buffer with it
never acquiring a fence (simply by only ever writing to the object using
tiled GPU commands and never writing to it via the GTT). So for pre-i965
chipsets which require fenced access for tiled scan-out buffers, we need
to obtain a fence register.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Eric Anholt <eric@anholt.net>
Diffstat (limited to 'drivers/gpu/drm')
-rw-r--r-- | drivers/gpu/drm/i915/i915_drv.h | 1 | ||||
-rw-r--r-- | drivers/gpu/drm/i915/i915_gem.c | 10 | ||||
-rw-r--r-- | drivers/gpu/drm/i915/intel_display.c | 20 |
3 files changed, 21 insertions, 10 deletions
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index 8ef6bcec211b..451b547352b7 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h | |||
@@ -646,6 +646,7 @@ void i915_gem_object_unpin(struct drm_gem_object *obj); | |||
646 | int i915_gem_object_unbind(struct drm_gem_object *obj); | 646 | int i915_gem_object_unbind(struct drm_gem_object *obj); |
647 | void i915_gem_lastclose(struct drm_device *dev); | 647 | void i915_gem_lastclose(struct drm_device *dev); |
648 | uint32_t i915_get_gem_seqno(struct drm_device *dev); | 648 | uint32_t i915_get_gem_seqno(struct drm_device *dev); |
649 | int i915_gem_object_get_fence_reg(struct drm_gem_object *obj); | ||
649 | void i915_gem_retire_requests(struct drm_device *dev); | 650 | void i915_gem_retire_requests(struct drm_device *dev); |
650 | void i915_gem_retire_work_handler(struct work_struct *work); | 651 | void i915_gem_retire_work_handler(struct work_struct *work); |
651 | void i915_gem_clflush_object(struct drm_gem_object *obj); | 652 | void i915_gem_clflush_object(struct drm_gem_object *obj); |
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c index a5f95ad3c072..4f345414fe7c 100644 --- a/drivers/gpu/drm/i915/i915_gem.c +++ b/drivers/gpu/drm/i915/i915_gem.c | |||
@@ -46,7 +46,6 @@ static void i915_gem_object_set_to_full_cpu_read_domain(struct drm_gem_object *o | |||
46 | static int i915_gem_object_wait_rendering(struct drm_gem_object *obj); | 46 | static int i915_gem_object_wait_rendering(struct drm_gem_object *obj); |
47 | static int i915_gem_object_bind_to_gtt(struct drm_gem_object *obj, | 47 | static int i915_gem_object_bind_to_gtt(struct drm_gem_object *obj, |
48 | unsigned alignment); | 48 | unsigned alignment); |
49 | static int i915_gem_object_get_fence_reg(struct drm_gem_object *obj, bool write); | ||
50 | static void i915_gem_clear_fence_reg(struct drm_gem_object *obj); | 49 | static void i915_gem_clear_fence_reg(struct drm_gem_object *obj); |
51 | static int i915_gem_evict_something(struct drm_device *dev); | 50 | static int i915_gem_evict_something(struct drm_device *dev); |
52 | static int i915_gem_phys_pwrite(struct drm_device *dev, struct drm_gem_object *obj, | 51 | static int i915_gem_phys_pwrite(struct drm_device *dev, struct drm_gem_object *obj, |
@@ -1158,7 +1157,7 @@ int i915_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf) | |||
1158 | /* Need a new fence register? */ | 1157 | /* Need a new fence register? */ |
1159 | if (obj_priv->fence_reg == I915_FENCE_REG_NONE && | 1158 | if (obj_priv->fence_reg == I915_FENCE_REG_NONE && |
1160 | obj_priv->tiling_mode != I915_TILING_NONE) { | 1159 | obj_priv->tiling_mode != I915_TILING_NONE) { |
1161 | ret = i915_gem_object_get_fence_reg(obj, write); | 1160 | ret = i915_gem_object_get_fence_reg(obj); |
1162 | if (ret) { | 1161 | if (ret) { |
1163 | mutex_unlock(&dev->struct_mutex); | 1162 | mutex_unlock(&dev->struct_mutex); |
1164 | return VM_FAULT_SIGBUS; | 1163 | return VM_FAULT_SIGBUS; |
@@ -2169,7 +2168,6 @@ static void i830_write_fence_reg(struct drm_i915_fence_reg *reg) | |||
2169 | /** | 2168 | /** |
2170 | * i915_gem_object_get_fence_reg - set up a fence reg for an object | 2169 | * i915_gem_object_get_fence_reg - set up a fence reg for an object |
2171 | * @obj: object to map through a fence reg | 2170 | * @obj: object to map through a fence reg |
2172 | * @write: object is about to be written | ||
2173 | * | 2171 | * |
2174 | * When mapping objects through the GTT, userspace wants to be able to write | 2172 | * When mapping objects through the GTT, userspace wants to be able to write |
2175 | * to them without having to worry about swizzling if the object is tiled. | 2173 | * to them without having to worry about swizzling if the object is tiled. |
@@ -2180,8 +2178,8 @@ static void i830_write_fence_reg(struct drm_i915_fence_reg *reg) | |||
2180 | * It then sets up the reg based on the object's properties: address, pitch | 2178 | * It then sets up the reg based on the object's properties: address, pitch |
2181 | * and tiling format. | 2179 | * and tiling format. |
2182 | */ | 2180 | */ |
2183 | static int | 2181 | int |
2184 | i915_gem_object_get_fence_reg(struct drm_gem_object *obj, bool write) | 2182 | i915_gem_object_get_fence_reg(struct drm_gem_object *obj) |
2185 | { | 2183 | { |
2186 | struct drm_device *dev = obj->dev; | 2184 | struct drm_device *dev = obj->dev; |
2187 | struct drm_i915_private *dev_priv = dev->dev_private; | 2185 | struct drm_i915_private *dev_priv = dev->dev_private; |
@@ -3550,7 +3548,7 @@ i915_gem_object_pin(struct drm_gem_object *obj, uint32_t alignment) | |||
3550 | if (!IS_I965G(dev) && | 3548 | if (!IS_I965G(dev) && |
3551 | obj_priv->fence_reg == I915_FENCE_REG_NONE && | 3549 | obj_priv->fence_reg == I915_FENCE_REG_NONE && |
3552 | obj_priv->tiling_mode != I915_TILING_NONE) { | 3550 | obj_priv->tiling_mode != I915_TILING_NONE) { |
3553 | ret = i915_gem_object_get_fence_reg(obj, true); | 3551 | ret = i915_gem_object_get_fence_reg(obj); |
3554 | if (ret != 0) { | 3552 | if (ret != 0) { |
3555 | if (ret != -EBUSY && ret != -ERESTARTSYS) | 3553 | if (ret != -EBUSY && ret != -ERESTARTSYS) |
3556 | DRM_ERROR("Failure to install fence: %d\n", | 3554 | DRM_ERROR("Failure to install fence: %d\n", |
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c index 028f5b66e3d8..3e1c78162119 100644 --- a/drivers/gpu/drm/i915/intel_display.c +++ b/drivers/gpu/drm/i915/intel_display.c | |||
@@ -828,19 +828,31 @@ intel_pipe_set_base(struct drm_crtc *crtc, int x, int y, | |||
828 | } | 828 | } |
829 | 829 | ||
830 | mutex_lock(&dev->struct_mutex); | 830 | mutex_lock(&dev->struct_mutex); |
831 | ret = i915_gem_object_pin(intel_fb->obj, alignment); | 831 | ret = i915_gem_object_pin(obj, alignment); |
832 | if (ret != 0) { | 832 | if (ret != 0) { |
833 | mutex_unlock(&dev->struct_mutex); | 833 | mutex_unlock(&dev->struct_mutex); |
834 | return ret; | 834 | return ret; |
835 | } | 835 | } |
836 | 836 | ||
837 | ret = i915_gem_object_set_to_gtt_domain(intel_fb->obj, 1); | 837 | ret = i915_gem_object_set_to_gtt_domain(obj, 1); |
838 | if (ret != 0) { | 838 | if (ret != 0) { |
839 | i915_gem_object_unpin(intel_fb->obj); | 839 | i915_gem_object_unpin(obj); |
840 | mutex_unlock(&dev->struct_mutex); | 840 | mutex_unlock(&dev->struct_mutex); |
841 | return ret; | 841 | return ret; |
842 | } | 842 | } |
843 | 843 | ||
844 | /* Pre-i965 needs to install a fence for tiled scan-out */ | ||
845 | if (!IS_I965G(dev) && | ||
846 | obj_priv->fence_reg == I915_FENCE_REG_NONE && | ||
847 | obj_priv->tiling_mode != I915_TILING_NONE) { | ||
848 | ret = i915_gem_object_get_fence_reg(obj); | ||
849 | if (ret != 0) { | ||
850 | i915_gem_object_unpin(obj); | ||
851 | mutex_unlock(&dev->struct_mutex); | ||
852 | return ret; | ||
853 | } | ||
854 | } | ||
855 | |||
844 | dspcntr = I915_READ(dspcntr_reg); | 856 | dspcntr = I915_READ(dspcntr_reg); |
845 | /* Mask out pixel format bits in case we change it */ | 857 | /* Mask out pixel format bits in case we change it */ |
846 | dspcntr &= ~DISPPLANE_PIXFORMAT_MASK; | 858 | dspcntr &= ~DISPPLANE_PIXFORMAT_MASK; |
@@ -860,7 +872,7 @@ intel_pipe_set_base(struct drm_crtc *crtc, int x, int y, | |||
860 | break; | 872 | break; |
861 | default: | 873 | default: |
862 | DRM_ERROR("Unknown color depth\n"); | 874 | DRM_ERROR("Unknown color depth\n"); |
863 | i915_gem_object_unpin(intel_fb->obj); | 875 | i915_gem_object_unpin(obj); |
864 | mutex_unlock(&dev->struct_mutex); | 876 | mutex_unlock(&dev->struct_mutex); |
865 | return -EINVAL; | 877 | return -EINVAL; |
866 | } | 878 | } |