aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/i915/i915_gem.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2017-01-09 11:16:09 -0500
committerChris Wilson <chris@chris-wilson.co.uk>2017-01-10 03:12:20 -0500
commit5b30694b474d00f8588fa367f9562d8f2e4c7075 (patch)
treebddd98d76a0ad390e2e592dce15d54db7260a64d /drivers/gpu/drm/i915/i915_gem.c
parent6649a0b6501d78042fd0fffaaefab1aeee27e75d (diff)
drm/i915: Align GGTT sizes to a fence tile row
Ensure the view occupies the full tile row so that reads/writes into the VMA do not escape (via fenced detiling) into neighbouring objects - we will pad the object with scratch pages to satisfy the fence. This applies the lazy-tiling we employed on gen2/3 to gen4+. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com> Link: http://patchwork.freedesktop.org/patch/msgid/20170109161613.11881-2-chris@chris-wilson.co.uk
Diffstat (limited to 'drivers/gpu/drm/i915/i915_gem.c')
-rw-r--r--drivers/gpu/drm/i915/i915_gem.c27
1 files changed, 19 insertions, 8 deletions
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index e8e278f6312e..07cc0d01915f 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -2021,21 +2021,29 @@ void i915_gem_runtime_suspend(struct drm_i915_private *dev_priv)
2021 * @dev_priv: i915 device 2021 * @dev_priv: i915 device
2022 * @size: object size 2022 * @size: object size
2023 * @tiling_mode: tiling mode 2023 * @tiling_mode: tiling mode
2024 * @stride: tiling stride
2024 * 2025 *
2025 * Return the required global GTT size for an object, taking into account 2026 * Return the required global GTT size for an object, taking into account
2026 * potential fence register mapping. 2027 * potential fence register mapping.
2027 */ 2028 */
2028u64 i915_gem_get_ggtt_size(struct drm_i915_private *dev_priv, 2029u64 i915_gem_get_ggtt_size(struct drm_i915_private *dev_priv,
2029 u64 size, int tiling_mode) 2030 u64 size, int tiling_mode, unsigned int stride)
2030{ 2031{
2031 u64 ggtt_size; 2032 u64 ggtt_size;
2032 2033
2033 GEM_BUG_ON(size == 0); 2034 GEM_BUG_ON(!size);
2034 2035
2035 if (INTEL_GEN(dev_priv) >= 4 || 2036 if (tiling_mode == I915_TILING_NONE)
2036 tiling_mode == I915_TILING_NONE)
2037 return size; 2037 return size;
2038 2038
2039 GEM_BUG_ON(!stride);
2040
2041 if (INTEL_GEN(dev_priv) >= 4) {
2042 stride *= i915_gem_tile_height(tiling_mode);
2043 GEM_BUG_ON(stride & 4095);
2044 return roundup(size, stride);
2045 }
2046
2039 /* Previous chips need a power-of-two fence region when tiling */ 2047 /* Previous chips need a power-of-two fence region when tiling */
2040 if (IS_GEN3(dev_priv)) 2048 if (IS_GEN3(dev_priv))
2041 ggtt_size = 1024*1024; 2049 ggtt_size = 1024*1024;
@@ -2053,15 +2061,17 @@ u64 i915_gem_get_ggtt_size(struct drm_i915_private *dev_priv,
2053 * @dev_priv: i915 device 2061 * @dev_priv: i915 device
2054 * @size: object size 2062 * @size: object size
2055 * @tiling_mode: tiling mode 2063 * @tiling_mode: tiling mode
2064 * @stride: tiling stride
2056 * @fenced: is fenced alignment required or not 2065 * @fenced: is fenced alignment required or not
2057 * 2066 *
2058 * Return the required global GTT alignment for an object, taking into account 2067 * Return the required global GTT alignment for an object, taking into account
2059 * potential fence register mapping. 2068 * potential fence register mapping.
2060 */ 2069 */
2061u64 i915_gem_get_ggtt_alignment(struct drm_i915_private *dev_priv, u64 size, 2070u64 i915_gem_get_ggtt_alignment(struct drm_i915_private *dev_priv, u64 size,
2062 int tiling_mode, bool fenced) 2071 int tiling_mode, unsigned int stride,
2072 bool fenced)
2063{ 2073{
2064 GEM_BUG_ON(size == 0); 2074 GEM_BUG_ON(!size);
2065 2075
2066 /* 2076 /*
2067 * Minimum alignment is 4k (GTT page size), but might be greater 2077 * Minimum alignment is 4k (GTT page size), but might be greater
@@ -2076,7 +2086,7 @@ u64 i915_gem_get_ggtt_alignment(struct drm_i915_private *dev_priv, u64 size,
2076 * Previous chips need to be aligned to the size of the smallest 2086 * Previous chips need to be aligned to the size of the smallest
2077 * fence register that can contain the object. 2087 * fence register that can contain the object.
2078 */ 2088 */
2079 return i915_gem_get_ggtt_size(dev_priv, size, tiling_mode); 2089 return i915_gem_get_ggtt_size(dev_priv, size, tiling_mode, stride);
2080} 2090}
2081 2091
2082static int i915_gem_object_create_mmap_offset(struct drm_i915_gem_object *obj) 2092static int i915_gem_object_create_mmap_offset(struct drm_i915_gem_object *obj)
@@ -3696,7 +3706,8 @@ i915_gem_object_ggtt_pin(struct drm_i915_gem_object *obj,
3696 u32 fence_size; 3706 u32 fence_size;
3697 3707
3698 fence_size = i915_gem_get_ggtt_size(dev_priv, vma->size, 3708 fence_size = i915_gem_get_ggtt_size(dev_priv, vma->size,
3699 i915_gem_object_get_tiling(obj)); 3709 i915_gem_object_get_tiling(obj),
3710 i915_gem_object_get_stride(obj));
3700 /* If the required space is larger than the available 3711 /* If the required space is larger than the available
3701 * aperture, we will not able to find a slot for the 3712 * aperture, we will not able to find a slot for the
3702 * object and unbinding the object now will be in 3713 * object and unbinding the object now will be in