sna: Guard the replace-with-xor fallback path
authorChris Wilson <chris@chris-wilson.co.uk>
Fri, 1 Nov 2013 15:57:56 +0000 (15:57 +0000)
committerChris Wilson <chris@chris-wilson.co.uk>
Fri, 1 Nov 2013 15:57:56 +0000 (15:57 +0000)
Before attempting to map the destination for uploading into after a
failure to use the BLT, we need to recheck that it is indeed mappable.

References: https://bugs.freedesktop.org/show_bug.cgi?id=70924
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
src/sna/kgem.h
src/sna/sna_io.c

index 9804d6c..7da359e 100644 (file)
@@ -530,7 +530,7 @@ static inline bool __kgem_bo_is_mappable(struct kgem *kgem,
        if (kgem->gen == 021 && bo->tiling == I915_TILING_Y)
                return false;
 
-       if (kgem->has_llc && bo->tiling == I915_TILING_NONE)
+       if (!bo->tiling && (kgem->has_llc || bo->domain == DOMAIN_CPU))
                return true;
 
        if (!bo->presumed_offset)
index cf3c4d1..5d238f4 100644 (file)
@@ -581,6 +581,7 @@ write_boxes_inplace__tiled(struct kgem *kgem,
 {
        uint8_t *dst;
 
+       assert(kgem_bo_can_map__cpu(kgem, bo, true));
        assert(bo->tiling == I915_TILING_X);
 
        dst = kgem_bo_map__cpu(kgem, bo);
@@ -718,7 +719,7 @@ bool sna_write_boxes(struct sna *sna, PixmapPtr dst,
 
        DBG(("%s x %d, src stride=%d,  src dx=(%d, %d)\n", __FUNCTION__, nbox, stride, src_dx, src_dy));
 
-       if (upload_inplace(kgem, dst_bo, box, nbox, dst->drawable.bitsPerPixel)&&
+       if (upload_inplace(kgem, dst_bo, box, nbox, dst->drawable.bitsPerPixel) &&
            write_boxes_inplace(kgem,
                                src, stride, dst->drawable.bitsPerPixel, src_dx, src_dy,
                                dst_bo, dst_dx, dst_dy,
@@ -1039,6 +1040,9 @@ write_boxes_inplace__xor(struct kgem *kgem,
 
        DBG(("%s x %d, tiling=%d\n", __FUNCTION__, n, bo->tiling));
 
+       if (!kgem_bo_can_map(kgem, bo))
+               return false;
+
        kgem_bo_submit(kgem, bo);
 
        dst = kgem_bo_map(kgem, bo);
@@ -1110,14 +1114,17 @@ bool sna_write_boxes__xor(struct sna *sna, PixmapPtr dst,
 
        DBG(("%s x %d\n", __FUNCTION__, nbox));
 
-       if (upload_inplace__xor(kgem, dst_bo, box, nbox, dst->drawable.bitsPerPixel)) {
-fallback:
-               return write_boxes_inplace__xor(kgem,
-                                               src, stride, dst->drawable.bitsPerPixel, src_dx, src_dy,
-                                               dst_bo, dst_dx, dst_dy,
-                                               box, nbox,
-                                               and, or);
-       }
+       if (upload_inplace__xor(kgem, dst_bo, box, nbox, dst->drawable.bitsPerPixel) &&
+           write_boxes_inplace__xor(kgem,
+                                    src, stride, dst->drawable.bitsPerPixel, src_dx, src_dy,
+                                    dst_bo, dst_dx, dst_dy,
+                                    box, nbox,
+                                    and, or))
+               return true;
+
+       if (wedged(sna))
+               return false;
+
 
        can_blt = kgem_bo_can_blt(kgem, dst_bo) &&
                (box[0].x2 - box[0].x1) * dst->drawable.bitsPerPixel < 8 * (MAXSHORT - 4);
@@ -1406,6 +1413,13 @@ tile:
 
        sna->blt_state.fill_bo = 0;
        return true;
+
+fallback:
+       return write_boxes_inplace__xor(kgem,
+                                       src, stride, dst->drawable.bitsPerPixel, src_dx, src_dy,
+                                       dst_bo, dst_dx, dst_dy,
+                                       box, nbox,
+                                       and, or);
 }
 
 static bool