diff mbox

[RFC,021/111] staging: etnaviv: respect the submission command offset

Message ID 1427988653-754-22-git-send-email-l.stach@pengutronix.de (mailing list archive)
State New, archived
Headers show

Commit Message

Lucas Stach April 2, 2015, 3:29 p.m. UTC
From: Russell King <rmk+kernel@arm.linux.org.uk>

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
---
 drivers/staging/etnaviv/etnaviv_buffer.c     | 10 ++++++++--
 drivers/staging/etnaviv/etnaviv_gem.h        |  1 +
 drivers/staging/etnaviv/etnaviv_gem_submit.c |  8 ++++++++
 3 files changed, 17 insertions(+), 2 deletions(-)
diff mbox

Patch

diff --git a/drivers/staging/etnaviv/etnaviv_buffer.c b/drivers/staging/etnaviv/etnaviv_buffer.c
index 729387571537..30ef93aed22a 100644
--- a/drivers/staging/etnaviv/etnaviv_buffer.c
+++ b/drivers/staging/etnaviv/etnaviv_buffer.c
@@ -165,7 +165,8 @@  void etnaviv_buffer_queue(struct etnaviv_gpu *gpu, unsigned int event, struct et
 
 	/* update offset for every cmd stream */
 	for (i = 0; i < submit->nr_cmds; i++)
-		submit->cmd[i].obj->offset = submit->cmd[i].size;
+		submit->cmd[i].obj->offset = submit->cmd[i].offset +
+					     submit->cmd[i].size;
 
 	/* TODO: inter-connect all cmd buffers */
 
@@ -173,6 +174,11 @@  void etnaviv_buffer_queue(struct etnaviv_gpu *gpu, unsigned int event, struct et
 	cmd = submit->cmd[submit->nr_cmds - 1].obj;
 	CMD_LINK(cmd, 4, buffer->paddr + (back * 4));
 
+	/* update the size */
+	for (i = 0; i < submit->nr_cmds; i++)
+		submit->cmd[i].size = submit->cmd[i].obj->offset -
+				      submit->cmd[i].offset;
+
 	printk(KERN_ERR "stream link @ 0x%08x\n", cmd->paddr + ((cmd->offset - 1) * 4));
 	printk(KERN_ERR "stream link @ %p\n", cmd->vaddr + ((cmd->offset - 1) * 4));
 
@@ -193,7 +199,7 @@  void etnaviv_buffer_queue(struct etnaviv_gpu *gpu, unsigned int event, struct et
 
 	/* Change WAIT into a LINK command; write the address first. */
 	i = VIV_FE_LINK_HEADER_OP_LINK | VIV_FE_LINK_HEADER_PREFETCH(submit->cmd[0].size * 2);
-	*(lw + 1) = submit->cmd[0].obj->paddr;
+	*(lw + 1) = submit->cmd[0].obj->paddr + submit->cmd[0].offset * 4;
 	mb();
 	*(lw)= i;
 	mb();
diff --git a/drivers/staging/etnaviv/etnaviv_gem.h b/drivers/staging/etnaviv/etnaviv_gem.h
index 597ff8233fb1..97302ca6efaa 100644
--- a/drivers/staging/etnaviv/etnaviv_gem.h
+++ b/drivers/staging/etnaviv/etnaviv_gem.h
@@ -87,6 +87,7 @@  struct etnaviv_gem_submit {
 	unsigned int nr_bos;
 	struct {
 		uint32_t type;
+		uint32_t offset; /* in dwords */
 		uint32_t size;  /* in dwords */
 		struct etnaviv_gem_object *obj;
 	} cmd[MAX_CMDS];
diff --git a/drivers/staging/etnaviv/etnaviv_gem_submit.c b/drivers/staging/etnaviv/etnaviv_gem_submit.c
index 78c56adfcffc..7eb02a121cff 100644
--- a/drivers/staging/etnaviv/etnaviv_gem_submit.c
+++ b/drivers/staging/etnaviv/etnaviv_gem_submit.c
@@ -382,6 +382,13 @@  int etnaviv_ioctl_gem_submit(struct drm_device *dev, void *data,
 			goto out;
 		}
 
+		if (submit_cmd.submit_offset % 8) {
+			DRM_ERROR("non-aligned cmdstream buffer size: %u\n",
+					submit_cmd.size);
+			ret = -EINVAL;
+			goto out;
+		}
+
 		/*
 		 * We must have space to add a LINK command at the end of
 		 * the command buffer.
@@ -396,6 +403,7 @@  int etnaviv_ioctl_gem_submit(struct drm_device *dev, void *data,
 		}
 
 		submit->cmd[i].type = submit_cmd.type;
+		submit->cmd[i].offset = submit_cmd.submit_offset / 4;
 		submit->cmd[i].size = submit_cmd.size / 4;
 		submit->cmd[i].obj = etnaviv_obj;