Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/hid
[sfrench/cifs-2.6.git] / drivers / gpu / drm / i915 / i915_gem_tiling.c
index 4cce1aef438e9fc06ed357ccc0c5520b0e9fde27..6be3f927c86a78b9a4e85afbfc8abc48a2619d1b 100644 (file)
@@ -216,6 +216,22 @@ i915_tiling_ok(struct drm_device *dev, int stride, int size, int tiling_mode)
        else
                tile_width = 512;
 
+       /* check maximum stride & object size */
+       if (IS_I965G(dev)) {
+               /* i965 stores the end address of the gtt mapping in the fence
+                * reg, so dont bother to check the size */
+               if (stride / 128 > I965_FENCE_MAX_PITCH_VAL)
+                       return false;
+       } else if (IS_I9XX(dev)) {
+               if (stride / tile_width > I830_FENCE_MAX_PITCH_VAL ||
+                   size > (I830_FENCE_MAX_SIZE_VAL << 20))
+                       return false;
+       } else {
+               if (stride / 128 > I830_FENCE_MAX_PITCH_VAL ||
+                   size > (I830_FENCE_MAX_SIZE_VAL << 19))
+                       return false;
+       }
+
        /* 965+ just needs multiples of tile width */
        if (IS_I965G(dev)) {
                if (stride & (tile_width - 1))