sna: Initialise and check for batch space

commit 30932a7b9d
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date:   Mon Sep 8 12:41:06 2014 +0100

    sna: Avoid u16 underflow when computing reserved batch space

relied on gcc a little to much to warn me when I missed initialising 'rem'

References: https://bugs.freedesktop.org/show_bug.cgi?id=77074
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
This commit is contained in:
Chris Wilson 2014-09-08 16:49:29 +01:00
parent 30932a7b9d
commit e0f7e9fc2f
1 changed files with 7 additions and 2 deletions

View File

@ -176,7 +176,8 @@ static bool sna_blt_fill_init(struct sna *sna,
{
uint32_t *b;
if (!kgem_check_reloc(kgem, 1)) {
if (!kgem_check_batch(kgem, 24) ||
!kgem_check_reloc(kgem, 1)) {
_kgem_submit(kgem);
if (!kgem_check_bo_fenced(kgem, bo))
return false;
@ -1799,6 +1800,7 @@ static void blt_composite_copy_boxes__thread64(struct sna *sna,
int nbox_this_time, rem;
nbox_this_time = nbox;
rem = kgem_batch_space(kgem);
if (10*nbox_this_time > rem)
nbox_this_time = rem / 10;
if (2*nbox_this_time > KGEM_RELOC_SIZE(kgem) - kgem->nreloc)
@ -3496,7 +3498,8 @@ bool sna_blt_fill_boxes(struct sna *sna, uint8_t alu,
{
uint32_t *b;
if (!kgem_check_reloc(kgem, 1)) {
if (!kgem_check_batch(kgem, 24) ||
!kgem_check_reloc(kgem, 1)) {
_kgem_submit(kgem);
if (!kgem_check_bo_fenced(&sna->kgem, bo))
return false;
@ -3556,6 +3559,7 @@ bool sna_blt_fill_boxes(struct sna *sna, uint8_t alu,
int nbox_this_time, rem;
nbox_this_time = nbox;
rem = kgem_batch_space(kgem);
if (3*nbox_this_time > rem)
nbox_this_time = rem / 3;
assert(nbox_this_time);
@ -3632,6 +3636,7 @@ bool sna_blt_fill_boxes(struct sna *sna, uint8_t alu,
kgem->nbatch += 9;
}
assert(kgem->nbatch < kgem->surface);
assert(kgem_check_batch(kgem, 3));
}
} while (nbox);