All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/i915: Only fence tiled region of object.
@ 2014-12-18 17:51 Bob Paauwe
  2014-12-18 20:37 ` Daniel Vetter
  0 siblings, 1 reply; 13+ messages in thread
From: Bob Paauwe @ 2014-12-18 17:51 UTC (permalink / raw)
  To: intel-gfx; +Cc: danh

When creating a fence for a tiled object, only fence the area that
makes up the actual tiles.  The object may be larger than the tiled
area and if we allow those extra addresses to be fenced, they'll
get converted to addresses beyond where the object is mapped. This
opens up the possiblity of writes beyond the end of object.

To prevent this, we adjust the size of the fence to only encompass
the area that makes up the actual tiles.  The extra space is considered
un-tiled and now behaves as if it was a linear object.

Testcase: igt/gem_tiled_fence_overflow
Reported-by: Dan Hettena <danh@ghs.com>
Signed-off-by: Bob Paauwe <bob.j.paauwe@intel.com>
---
 drivers/gpu/drm/i915/i915_gem.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 67550ac..c9acbfa 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -3173,6 +3173,13 @@ static void i965_write_fence_reg(struct drm_device *dev, int reg,
 		u32 size = i915_gem_obj_ggtt_size(obj);
 		uint64_t val;
 
+		/* Adjust fence size to match tiled area */
+		if (obj->tiling_mode != I915_TILING_NONE) {
+			uint32_t row_size = obj->stride *
+				(obj->tiling_mode == I915_TILING_Y ? 32 : 8);
+			size = (size / row_size) * row_size;
+		}
+
 		val = (uint64_t)((i915_gem_obj_ggtt_offset(obj) + size - 4096) &
 				 0xfffff000) << 32;
 		val |= i915_gem_obj_ggtt_offset(obj) & 0xfffff000;
-- 
2.1.0

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2015-01-21 17:20 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-18 17:51 [PATCH] drm/i915: Only fence tiled region of object Bob Paauwe
2014-12-18 20:37 ` Daniel Vetter
2014-12-18 21:04   ` Ville Syrjälä
2014-12-18 21:19     ` Daniel Vetter
2014-12-18 22:14       ` Imre Deak
2014-12-19  8:26         ` Chris Wilson
2014-12-19  9:05           ` Imre Deak
2014-12-19  9:17             ` Chris Wilson
2014-12-19 10:15               ` Daniel Vetter
2014-12-19 12:31                 ` Dan Hettena
2014-12-19 13:17                 ` Chris Wilson
2014-12-18 21:23     ` Imre Deak
2015-01-21 17:09   ` Jani Nikula

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.