Commit f44001e2 authored by Rob Clark's avatar Rob Clark

drm/msm: use proper memory barriers for updating tail/head

Fixes intermittent corruption of cmdstream dump.
Signed-off-by: default avatarRob Clark <robdclark@gmail.com>
parent aa3c2ba1
...@@ -111,10 +111,14 @@ static void rd_write(struct msm_rd_state *rd, const void *buf, int sz) ...@@ -111,10 +111,14 @@ static void rd_write(struct msm_rd_state *rd, const void *buf, int sz)
wait_event(rd->fifo_event, circ_space(&rd->fifo) > 0); wait_event(rd->fifo_event, circ_space(&rd->fifo) > 0);
/* Note that smp_load_acquire() is not strictly required
* as CIRC_SPACE_TO_END() does not access the tail more
* than once.
*/
n = min(sz, circ_space_to_end(&rd->fifo)); n = min(sz, circ_space_to_end(&rd->fifo));
memcpy(fptr, ptr, n); memcpy(fptr, ptr, n);
fifo->head = (fifo->head + n) & (BUF_SZ - 1); smp_store_release(&fifo->head, (fifo->head + n) & (BUF_SZ - 1));
sz -= n; sz -= n;
ptr += n; ptr += n;
...@@ -145,13 +149,17 @@ static ssize_t rd_read(struct file *file, char __user *buf, ...@@ -145,13 +149,17 @@ static ssize_t rd_read(struct file *file, char __user *buf,
if (ret) if (ret)
goto out; goto out;
/* Note that smp_load_acquire() is not strictly required
* as CIRC_CNT_TO_END() does not access the head more than
* once.
*/
n = min_t(int, sz, circ_count_to_end(&rd->fifo)); n = min_t(int, sz, circ_count_to_end(&rd->fifo));
if (copy_to_user(buf, fptr, n)) { if (copy_to_user(buf, fptr, n)) {
ret = -EFAULT; ret = -EFAULT;
goto out; goto out;
} }
fifo->tail = (fifo->tail + n) & (BUF_SZ - 1); smp_store_release(&fifo->tail, (fifo->tail + n) & (BUF_SZ - 1));
*ppos += n; *ppos += n;
wake_up_all(&rd->fifo_event); wake_up_all(&rd->fifo_event);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment