diff options
author | Harshdeep Dhatt <hdhatt@codeaurora.org> | 2016-06-15 10:37:53 -0600 |
---|---|---|
committer | Carter Cooper <ccooper@codeaurora.org> | 2016-08-09 14:59:22 -0600 |
commit | 204483da6978a5973d97df0a3da123c2c66d785a (patch) | |
tree | f8fbf9711adcc1d33d8419362788ab3f6a37aea4 /drivers/gpu/msm/adreno_ringbuffer.c | |
parent | e94b446eac88a43e42ecde105275d48b677ea5b3 (diff) |
msm: kgsl: Fix the ringbuffer wrap around logic
Currently, if read pointer is behind write pointer and there
is not enough space toward the end of the ringbuffer for
new commands, then write pointer is being set to 0.
This is problematic, because it leads to the overwriting of
unexecuted commands with new commands at the start of the
ringbuffer. So, instead of setting the write pointer to 0,
look for space from the start of the ringbuffer up till the
read pointer and if there is room, update the write pointer
accordingly.
CRs-Fixed: 1028465
Change-Id: I1cbdbf139b14988513a22030aa2be4a99a221880
Signed-off-by: Harshdeep Dhatt <hdhatt@codeaurora.org>
Diffstat (limited to 'drivers/gpu/msm/adreno_ringbuffer.c')
-rw-r--r-- | drivers/gpu/msm/adreno_ringbuffer.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/drivers/gpu/msm/adreno_ringbuffer.c b/drivers/gpu/msm/adreno_ringbuffer.c index 0160939e97f9..5ffb0b2513f3 100644 --- a/drivers/gpu/msm/adreno_ringbuffer.c +++ b/drivers/gpu/msm/adreno_ringbuffer.c @@ -158,11 +158,18 @@ unsigned int *adreno_ringbuffer_allocspace(struct adreno_ringbuffer *rb, return RB_HOSTPTR(rb, ret); } - cmds = RB_HOSTPTR(rb, rb->_wptr); - *cmds = cp_packet(adreno_dev, CP_NOP, - KGSL_RB_DWORDS - rb->_wptr - 1); - - rb->_wptr = 0; + /* + * There isn't enough space toward the end of ringbuffer. So + * look for space from the beginning of ringbuffer upto the + * read pointer. + */ + if (dwords < rptr) { + cmds = RB_HOSTPTR(rb, rb->_wptr); + *cmds = cp_packet(adreno_dev, CP_NOP, + KGSL_RB_DWORDS - rb->_wptr - 1); + rb->_wptr = dwords; + return RB_HOSTPTR(rb, 0); + } } if (rb->_wptr + dwords < rptr) { |