[PATCH RFC 027/111] staging: etnaviv: ensure that ring buffer wraps
Lucas Stach
l.stach at pengutronix.de
Thu Apr 2 08:29:29 PDT 2015
From: Russell King <rmk+kernel at arm.linux.org.uk>
Ensure that the ring buffer wraps when we fill the buffer.
Signed-off-by: Russell King <rmk+kernel at arm.linux.org.uk>
---
drivers/staging/etnaviv/etnaviv_buffer.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/staging/etnaviv/etnaviv_buffer.c b/drivers/staging/etnaviv/etnaviv_buffer.c
index a93d5091828e..a8b42a1ec7db 100644
--- a/drivers/staging/etnaviv/etnaviv_buffer.c
+++ b/drivers/staging/etnaviv/etnaviv_buffer.c
@@ -30,7 +30,7 @@
static inline void OUT(struct etnaviv_gem_object *buffer, uint32_t data)
{
u32 *vaddr = (u32 *)buffer->vaddr;
- BUG_ON(buffer->offset * sizeof(*vaddr) >= buffer->base.size);
+ BUG_ON(buffer->offset >= buffer->base.size / sizeof(*vaddr));
vaddr[buffer->offset++] = data;
}
@@ -154,6 +154,12 @@ void etnaviv_buffer_queue(struct etnaviv_gpu *gpu, unsigned int event, struct et
if (drm_debug & DRM_UT_DRIVER)
etnaviv_buffer_dump(gpu, buffer, 0, 0x50);
+ /*
+ * if we are going to completely overflow the buffer, we need to wrap.
+ */
+ if (buffer->offset + 6 > buffer->base.size / sizeof(uint32_t))
+ buffer->offset = 0;
+
/* save offset back into main buffer */
back = buffer->offset;
link_target = buffer->paddr + buffer->offset * 4;
--
2.1.4
More information about the dri-devel
mailing list