All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Vetter <daniel.vetter@ffwll.ch>
To: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Indan Zupancic <indan@nul.nu>,
	Daniel Vetter <daniel.vetter@ffwll.ch>,
	dri-devel@lists.freedesktop.org
Subject: [PATCH] drm/i915: fix corruptions on i8xx due to relaxed fencing
Date: Tue, 22 Feb 2011 18:25:49 +0100	[thread overview]
Message-ID: <1298395549-4064-1-git-send-email-daniel.vetter@ffwll.ch> (raw)
In-Reply-To: <af572f9c6c75d54f1f81e51f508358dd.squirrel@webmail.greenhost.nl>

It looks like gen2 has a peculiar interleaved 2-row inter-tile
layout. Probably inherited from i81x which had 2kb tiles (which
naturally fit an even-number-of-tile-rows scheme to fit onto 4kb
pages). There is no other mention of this in any docs (also not
in the Intel internal documention according to Chris Wilson).

Problem manifests itself in corruptions in the second half of the
last tile row (if the bo has an odd number of tiles). Which can
only happen with relaxed tiling (introduced in a00b10c360b35d6431a9).

So reject set_tiling calls that don't satisfy this constrain to
prevent broken userspace from causing havoc. While at it, also
check the size for newer chipsets.

LKML: https://lkml.org/lkml/2011/2/19/5
Reported-by: Indan Zupancic <indan@nul.nu>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 drivers/gpu/drm/i915/i915_gem_tiling.c |   16 +++++++++++++++-
 1 files changed, 15 insertions(+), 1 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_gem_tiling.c b/drivers/gpu/drm/i915/i915_gem_tiling.c
index 22a32b9..79a04fd 100644
--- a/drivers/gpu/drm/i915/i915_gem_tiling.c
+++ b/drivers/gpu/drm/i915/i915_gem_tiling.c
@@ -184,7 +184,7 @@ i915_gem_detect_bit_6_swizzle(struct drm_device *dev)
 static bool
 i915_tiling_ok(struct drm_device *dev, int stride, int size, int tiling_mode)
 {
-	int tile_width;
+	int tile_width, tile_height;
 
 	/* Linear is always fine */
 	if (tiling_mode == I915_TILING_NONE)
@@ -215,6 +215,20 @@ i915_tiling_ok(struct drm_device *dev, int stride, int size, int tiling_mode)
 		}
 	}
 
+	if (IS_GEN2(dev) ||
+	    (tiling_mode == I915_TILING_Y && HAS_128_BYTE_Y_TILING(dev)))
+		tile_height = 32;
+	else
+		tile_height = 8;
+	/* i8xx is strange: It has 2 interleaved rows of tiles, so needs an even
+	 * number of tile rows. */
+	if (IS_GEN2(dev))
+		tile_height *= 2;
+
+	/* Size needs to be aligned to a full tile row */
+	if (size & (tile_height * stride - 1))
+		return false;
+
 	/* 965+ just needs multiples of tile width */
 	if (INTEL_INFO(dev)->gen >= 4) {
 		if (stride & (tile_width - 1))
-- 
1.7.4.1

  reply	other threads:[~2011-02-22 17:21 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-19  5:58 [BUG] drm/i915 Screen corruption introduced by a00b10c360b35d6431a94cb Indan Zupancic
2011-02-19  5:58 ` Indan Zupancic
2011-02-19 18:25 ` Daniel Vetter
2011-02-19 18:25   ` Daniel Vetter
2011-02-20  2:20   ` Indan Zupancic
2011-02-20  2:20     ` Indan Zupancic
2011-02-20  2:26     ` Indan Zupancic
2011-02-20  2:26       ` Indan Zupancic
2011-02-20  9:20     ` Daniel Vetter
2011-02-20 11:02       ` Indan Zupancic
2011-02-20 11:02         ` Indan Zupancic
2011-02-20 10:55     ` Daniel Vetter
2011-02-20 11:19       ` Indan Zupancic
2011-02-20 11:19         ` Indan Zupancic
2011-02-20 13:21         ` Daniel Vetter
2011-02-21  1:11           ` Indan Zupancic
2011-02-21  1:11             ` Indan Zupancic
2011-02-22 17:25             ` Daniel Vetter [this message]
2011-02-22 17:32               ` [PATCH] drm/i915: fix corruptions on i8xx due to relaxed fencing Thierry Vignaud
2011-02-22 17:42                 ` Daniel Vetter
2011-02-23  6:59               ` Indan Zupancic
2011-02-23  7:10                 ` Daniel Vetter
2011-02-23  7:10                   ` Daniel Vetter
2011-03-10  5:06                   ` Indan Zupancic
2011-03-10  5:06                     ` Indan Zupancic
2011-03-10  7:52                     ` Daniel Vetter
2011-03-10 10:36                       ` Indan Zupancic
2011-03-10 10:36                         ` Indan Zupancic
2011-03-10 13:31                         ` Daniel Vetter
2011-03-10 13:31                           ` Daniel Vetter
2011-03-11  1:08                           ` Indan Zupancic
2011-03-11  1:08                             ` Indan Zupancic
2011-03-11  9:23                             ` Daniel Vetter
2011-03-11  9:23                               ` Daniel Vetter
2011-02-21  2:51       ` [BUG] drm/i915 Screen corruption introduced by a00b10c360b35d6431a94cb Indan Zupancic
2011-02-21  2:51         ` Indan Zupancic
2011-02-20  3:51   ` Peter Stuge
2011-02-20  6:13     ` Indan Zupancic
2011-02-20  6:13       ` Indan Zupancic
2011-02-21  4:10       ` Peter Stuge
2011-02-21  5:26         ` Indan Zupancic
2011-02-21  5:26           ` Indan Zupancic

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1298395549-4064-1-git-send-email-daniel.vetter@ffwll.ch \
    --to=daniel.vetter@ffwll.ch \
    --cc=chris@chris-wilson.co.uk \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=indan@nul.nu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.