From patchwork Thu Apr 2 15:29:23 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucas Stach X-Patchwork-Id: 6149811 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 1648B9F1BE for ; Thu, 2 Apr 2015 15:32:19 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3DC1B203AB for ; Thu, 2 Apr 2015 15:32:18 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 8DBD6203AE for ; Thu, 2 Apr 2015 15:32:16 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 40EC06EA89; Thu, 2 Apr 2015 08:31:07 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [92.198.50.35]) by gabe.freedesktop.org (Postfix) with ESMTP id 09D176EA46 for ; Thu, 2 Apr 2015 08:30:57 -0700 (PDT) Received: from dude.hi.4.pengutronix.de ([10.1.0.7] helo=dude.pengutronix.de.) by metis.ext.pengutronix.de with esmtp (Exim 4.72) (envelope-from ) id 1Ydh56-0005OD-92; Thu, 02 Apr 2015 17:30:56 +0200 From: Lucas Stach To: dri-devel@lists.freedesktop.org Subject: [PATCH RFC 021/111] staging: etnaviv: respect the submission command offset Date: Thu, 2 Apr 2015 17:29:23 +0200 Message-Id: <1427988653-754-22-git-send-email-l.stach@pengutronix.de> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1427988653-754-1-git-send-email-l.stach@pengutronix.de> References: <1427988653-754-1-git-send-email-l.stach@pengutronix.de> X-SA-Exim-Connect-IP: 10.1.0.7 X-SA-Exim-Mail-From: l.stach@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: dri-devel@lists.freedesktop.org Cc: Russell King , kernel@pengutronix.de X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Russell King Signed-off-by: Russell King --- 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 --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;