From patchwork Wed Jun 14 23:18:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 9787771 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B850E602CB for ; Thu, 15 Jun 2017 01:00:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ADD1523B24 for ; Thu, 15 Jun 2017 01:00:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A28BE284E4; Thu, 15 Jun 2017 01:00:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 2071223B24 for ; Thu, 15 Jun 2017 01:00:56 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6C2BC6E662; Thu, 15 Jun 2017 00:58:15 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-lf0-x242.google.com (mail-lf0-x242.google.com [IPv6:2a00:1450:4010:c07::242]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4A34A6E63D for ; Wed, 14 Jun 2017 23:19:14 +0000 (UTC) Received: by mail-lf0-x242.google.com with SMTP id o28so1618613lfk.1 for ; Wed, 14 Jun 2017 16:19:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=eDoLFFScMtSBkGeHQm9WEjwB6n2PlBAaoGn53GTNJ/0=; b=Kc8jhJL69ZHj/NLgdpuvaPhCMswxcpwMmSiZ0SS+rJwjlJkh9VO5BFHdznkgfbonjv xV/kfgFo78j+iPIxDA9uMjyVFZFHb22G9oEwYD9v+xcXARbHUMRlV9TLb8iBHsibfUaL HQtJfgaxSG9cOiYqe75v3/FV3K0EgN3kRV0v9blFqfKvu8B+bGAut1iwx80nQMw1EwOG cRrQdeNBH5sYTPvWkyl4PHIMhhYHqwFnZiwe9LhF2yLGcv9QmPjqUTxy5ylW58KixqXY y6NbfcrHi75bKFwWQfViuG15OkJmDERfVmRldXpfebuTkqlGPFNt88zhBo8/7Rrc9udn PtzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=eDoLFFScMtSBkGeHQm9WEjwB6n2PlBAaoGn53GTNJ/0=; b=YfAy0Tomn1U190VHZHmOKJWGyxmLHOhrz2BQsUQOdoEhbxBPSZyPGtvj3hNp3SXVvC 4BWTgqScUgHEi4BJMGTCqmYRrWJfyjBwJx9iNtV1gp2GiAuqBnh1XEaG5hHeu9/V08Um PHffQEXZIC6oRqi+Fkp7oj2eBv46Ftp3UTXq6kra7aAWOXLOSBa9xud1EC5FZA9MIr3N q7A5jyu4KHVX38XBAAdAB7v2NTfmkc7EqrJtt1xmCF/DnKbLfUWMfkjGyvetmcacmPZB CnbsZS9I6OKD5sI1bTRCJ6pPsfeZ0vimoq2+tmz21dnRlm3w3dKJpGhNuA4erSSUN+8C 2KPg== X-Gm-Message-State: AKS2vOwaJRNzFJoXFSzYxN5r2EHvMtvjZLRf3bktcH27fzLFqCOU07l2 EG2Nm34nhNiZ6Q== X-Received: by 10.25.29.20 with SMTP id d20mr795709lfd.77.1497482352763; Wed, 14 Jun 2017 16:19:12 -0700 (PDT) Received: from localhost.localdomain (ppp109-252-91-7.pppoe.spdop.ru. [109.252.91.7]) by smtp.gmail.com with ESMTPSA id i24sm290165ljb.63.2017.06.14.16.19.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 14 Jun 2017 16:19:12 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Mikko Perttunen , Erik Faye-Lund Subject: [PATCH v3 16/20] gpu: host1x: Check waits in the firewall Date: Thu, 15 Jun 2017 02:18:39 +0300 Message-Id: <6f3c72dc6f12a0436b1587cb73cf82885df13385.1497480757.git.digetx@gmail.com> X-Mailer: git-send-email 2.13.0 In-Reply-To: References: In-Reply-To: References: X-Mailman-Approved-At: Thu, 15 Jun 2017 00:57:20 +0000 Cc: linux-tegra@vger.kernel.org, DRI Development 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-Virus-Scanned: ClamAV using ClamSMTP Check waits in the firewall in a way it is done for relocations. Signed-off-by: Dmitry Osipenko Reviewed-by: Mikko Perttunen Reviewed-by: Erik Faye-Lund --- drivers/gpu/host1x/job.c | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/host1x/job.c b/drivers/gpu/host1x/job.c index ef746f7afb88..f32ae69a68c7 100644 --- a/drivers/gpu/host1x/job.c +++ b/drivers/gpu/host1x/job.c @@ -31,6 +31,8 @@ #include "job.h" #include "syncpt.h" +#define HOST1X_WAIT_SYNCPT_OFFSET 0x8 + struct host1x_job *host1x_job_alloc(struct host1x_channel *ch, u32 num_cmdbufs, u32 num_relocs, u32 num_waitchks) @@ -337,6 +339,17 @@ static bool check_reloc(struct host1x_reloc *reloc, struct host1x_bo *cmdbuf, return true; } +static bool check_wait(struct host1x_waitchk *wait, struct host1x_bo *cmdbuf, + unsigned int offset) +{ + offset *= sizeof(u32); + + if (wait->bo != cmdbuf || wait->offset != offset) + return false; + + return true; +} + struct host1x_firewall { struct host1x_job *job; struct device *dev; @@ -344,6 +357,9 @@ struct host1x_firewall { unsigned int num_relocs; struct host1x_reloc *reloc; + unsigned int num_waitchks; + struct host1x_waitchk *waitchk; + struct host1x_bo *cmdbuf; unsigned int offset; @@ -370,6 +386,20 @@ static int check_register(struct host1x_firewall *fw, unsigned long offset) fw->reloc++; } + if (offset == HOST1X_WAIT_SYNCPT_OFFSET) { + if (fw->class != HOST1X_CLASS_HOST1X) + return -EINVAL; + + if (!fw->num_waitchks) + return -EINVAL; + + if (!check_wait(fw->waitchk, fw->cmdbuf, fw->offset)) + return -EINVAL; + + fw->num_waitchks--; + fw->waitchk++; + } + return 0; } @@ -534,6 +564,8 @@ static inline int copy_gathers(struct host1x_job *job, struct device *dev) fw.dev = dev; fw.reloc = job->relocarray; fw.num_relocs = job->num_relocs; + fw.waitchk = job->waitchk; + fw.num_waitchks = job->num_waitchk; fw.class = job->class; for (i = 0; i < job->num_gathers; i++) { @@ -572,8 +604,8 @@ static inline int copy_gathers(struct host1x_job *job, struct device *dev) offset += g->words * sizeof(u32); } - /* No relocs should remain at this point */ - if (fw.num_relocs) + /* No relocs and waitchks should remain at this point */ + if (fw.num_relocs || fw.num_waitchks) return -EINVAL; return 0;