summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2012-10-07 22:41:25 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2012-10-07 22:43:45 +0100
commit2ac3776be85d857a57ce7b742e52cd6091d2befb (patch)
tree5850e134546db79ee1641b4f5da3e639a0595f74 /src
parent1a5d5b9ae5771d81da16222582acedb1557386c8 (diff)
sna: Check that we have sufficient space for a copy when replacing a fill
Reported-by: Timo Kamph <timo@kamph.org> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=55700 Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'src')
-rw-r--r--src/sna/sna_blt.c29
1 files changed, 17 insertions, 12 deletions
diff --git a/src/sna/sna_blt.c b/src/sna/sna_blt.c
index c3c47357..7410eb11 100644
--- a/src/sna/sna_blt.c
+++ b/src/sna/sna_blt.c
@@ -435,18 +435,23 @@ static void sna_blt_copy_one(struct sna *sna,
kgem->batch[kgem->nbatch-3] == ((uint32_t)(dst_y+height) << 16 | (uint16_t)(dst_x+width)) &&
kgem->reloc[kgem->nreloc-1].target_handle == blt->bo[1]->handle) {
DBG(("%s: replacing last fill\n", __FUNCTION__));
- b = kgem->batch + kgem->nbatch - 6;
- b[0] = blt->cmd;
- b[1] = blt->br13;
- b[5] = (src_y << 16) | src_x;
- b[6] = blt->pitch[0];
- b[7] = kgem_add_reloc(kgem, kgem->nbatch + 7 - 6,
- blt->bo[0],
- I915_GEM_DOMAIN_RENDER << 16 |
- KGEM_RELOC_FENCED,
- 0);
- kgem->nbatch += 8 - 6;
- return;
+ if (kgem_check_batch(kgem, 8-6)) {
+ b = kgem->batch + kgem->nbatch - 6;
+ b[0] = blt->cmd;
+ b[1] = blt->br13;
+ b[5] = (src_y << 16) | src_x;
+ b[6] = blt->pitch[0];
+ b[7] = kgem_add_reloc(kgem, kgem->nbatch + 7 - 6,
+ blt->bo[0],
+ I915_GEM_DOMAIN_RENDER << 16 |
+ KGEM_RELOC_FENCED,
+ 0);
+ kgem->nbatch += 8 - 6;
+ assert(kgem->nbatch < kgem->surface);
+ return;
+ }
+ kgem->nbatch -= 6;
+ kgem->nreloc--;
}
if (!kgem_check_batch(kgem, 8) ||