Skip to contentSkip to conversation

drm/i915: Reject fence stride=0 on gen4+

PATCH Superseded [email protected] 2 participants 5 messages Apr 9, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/i915: Reject fence stride=0 on gen4+

From: Ville Syrjälä <[email protected]>

Our checks for an invalid fence stride forgot to guard against zero stride on gen4+. Fix it.

---
 drivers/gpu/drm/i915/i915_gem_tiling.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/i915/i915_gem_tiling.c +2 -0
index 139d17d..16ff6e7 100644
@@ -240,6 +240,8 @@ i915_tiling_ok(struct drm_device *dev, int stride, int size, int tiling_mode)
 
 	/* 965+ just needs multiples of tile width */
 	if (INTEL_INFO(dev)->gen >= 4) {
+		if (stride < tile_width)
+			return false;
 		if (stride & (tile_width - 1))
 			return false;
 		return true;
Signature · 6 lines
1.8.1.5

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#1 lore raw
Quoted 6 lines · On Tue, Apr 09, 2013 at 05:46:45PM +0300, [email protected] wrote:

From: Ville Syrjälä <[email protected]>

Our checks for an invalid fence stride forgot to guard against zero stride on gen4+. Fix it.

This duplicates the tiny stride check a bit with the gen2/3 code. What about

drivers/gpu/drm/i915/i915_gem_tiling.c +3 -3
index c807eb9..b56185f 100644
@@ -235,6 +235,9 @@ i915_tiling_ok(struct drm_device *dev, int stride, int size, int tiling_mode)
 		}
 	}
 
+	if (stride < tile_width)
+		return false;
+
 	/* 965+ just needs multiples of tile width */
 	if (INTEL_INFO(dev)->gen >= 4) {
 		if (stride & (tile_width - 1))
@@ -243,9 +246,6 @@ i915_tiling_ok(struct drm_device *dev, int stride, int size, int tiling_mode)
 	}
 
 	/* Pre-965 needs power of two tile widths */
-	if (stride < tile_width)
-		return false;
-
 	if (stride & (stride - 1))
 		return false;
 

instead?
-Daniel

Quoted 24 lines
---
 drivers/gpu/drm/i915/i915_gem_tiling.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/i915/i915_gem_tiling.c +2 -0
index 139d17d..16ff6e7 100644
@@ -240,6 +240,8 @@ i915_tiling_ok(struct drm_device *dev, int stride, int size, int tiling_mode)
 
 	/* 965+ just needs multiples of tile width */
 	if (INTEL_INFO(dev)->gen >= 4) {
+		if (stride < tile_width)
+			return false;
 		if (stride & (tile_width - 1))
 			return false;
 		return true;
Signature · 6 lines
1.8.1.5

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
#2 lore raw
Quoted 36 lines · Daniel Vetter
Quoted 6 lines · On Tue, Apr 09, 2013 at 05:46:45PM +0300, [email protected] wrote:

From: Ville Syrjälä <[email protected]>

Our checks for an invalid fence stride forgot to guard against zero stride on gen4+. Fix it.

This duplicates the tiny stride check a bit with the gen2/3 code. What about

drivers/gpu/drm/i915/i915_gem_tiling.c +3 -3
index c807eb9..b56185f 100644
@@ -235,6 +235,9 @@ i915_tiling_ok(struct drm_device *dev, int stride, int size, int tiling_mode)
 		}
 	}
 
+	if (stride < tile_width)
+		return false;
+
 	/* 965+ just needs multiples of tile width */
 	if (INTEL_INFO(dev)->gen >= 4) {
 		if (stride & (tile_width - 1))
@@ -243,9 +246,6 @@ i915_tiling_ok(struct drm_device *dev, int stride, int size, int tiling_mode)
 	}
 
 	/* Pre-965 needs power of two tile widths */
-	if (stride < tile_width)
-		return false;
-
 	if (stride & (stride - 1))
 		return false;
 
Quoted 1 line

instead?

Looks OK. The same idea occured to me, but only after hitting enter.

Quoted 31 lines

-Daniel

Quoted 24 lines
---
 drivers/gpu/drm/i915/i915_gem_tiling.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/i915/i915_gem_tiling.c +2 -0
index 139d17d..16ff6e7 100644
@@ -240,6 +240,8 @@ i915_tiling_ok(struct drm_device *dev, int stride, int size, int tiling_mode)
 
 	/* 965+ just needs multiples of tile width */
 	if (INTEL_INFO(dev)->gen >= 4) {
+		if (stride < tile_width)
+			return false;
 		if (stride & (tile_width - 1))
 			return false;
 		return true;
Signature · 6 lines
1.8.1.5

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
Signature · 2 lines
Ville Syrjälä
Intel OTC
#3 lore raw

PATCH v2 1/1 drm/i915: Reject fence stride=0 on gen4+

In reply to Daniel Vetter

From: Ville Syrjälä <[email protected]>

Our checks for an invalid fence stride forgot to guard against zero stride on gen4+. Fix it.

v2: Avoid duplicated code (danvet)

---
 drivers/gpu/drm/i915/i915_gem_tiling.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/i915_gem_tiling.c +3 -3
index 139d17d..537545b 100644
@@ -238,6 +238,9 @@ i915_tiling_ok(struct drm_device *dev, int stride, int size, int tiling_mode)
 		}
 	}
 
+	if (stride < tile_width)
+		return false;
+
 	/* 965+ just needs multiples of tile width */
 	if (INTEL_INFO(dev)->gen >= 4) {
 		if (stride & (tile_width - 1))
@@ -246,9 +249,6 @@ i915_tiling_ok(struct drm_device *dev, int stride, int size, int tiling_mode)
 	}
 
 	/* Pre-965 needs power of two tile widths */
-	if (stride < tile_width)
-		return false;
-
 	if (stride & (stride - 1))
 		return false;
 
Signature · 6 lines
1.8.1.5

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#4 lore raw
Quoted 8 lines · On Tue, Apr 09, 2013 at 08:09:13PM +0300, [email protected] wrote:

From: Ville Syrjälä <[email protected]>

Our checks for an invalid fence stride forgot to guard against zero stride on gen4+. Fix it.

v2: Avoid duplicated code (danvet)

Queued for -next, thanks for the patch.
-Daniel

Quoted 31 lines
---
 drivers/gpu/drm/i915/i915_gem_tiling.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/i915_gem_tiling.c +3 -3
index 139d17d..537545b 100644
@@ -238,6 +238,9 @@ i915_tiling_ok(struct drm_device *dev, int stride, int size, int tiling_mode)
 		}
 	}
 
+	if (stride < tile_width)
+		return false;
+
 	/* 965+ just needs multiples of tile width */
 	if (INTEL_INFO(dev)->gen >= 4) {
 		if (stride & (tile_width - 1))
@@ -246,9 +249,6 @@ i915_tiling_ok(struct drm_device *dev, int stride, int size, int tiling_mode)
 	}
 
 	/* Pre-965 needs power of two tile widths */
-	if (stride < tile_width)
-		return false;
-
 	if (stride & (stride - 1))
 		return false;
 
Signature · 1 line
1.8.1.5
Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch