From patchwork Tue Jun 13 23:15:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 9785065 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 5A68760384 for ; Wed, 14 Jun 2017 00:42:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4BBC028567 for ; Wed, 14 Jun 2017 00:42:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3EF4F28573; Wed, 14 Jun 2017 00:42:02 +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 E361C28567 for ; Wed, 14 Jun 2017 00:42:01 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B91146E3FE; Wed, 14 Jun 2017 00:41:03 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-lf0-x244.google.com (mail-lf0-x244.google.com [IPv6:2a00:1450:4010:c07::244]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0CE2B6E3D9 for ; Tue, 13 Jun 2017 23:39:04 +0000 (UTC) Received: by mail-lf0-x244.google.com with SMTP id o28so14873098lfk.1 for ; Tue, 13 Jun 2017 16:39:03 -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=fHtfKlUDyaeQ9035f4gPbhSyHJu0Eg2krJWLMwXEToY=; b=goY+TqgSx1DnklWYJq5cHFZwu5AvDzFti9sMbf1+8CT+37rHoxKJuceWyZ4jHYBsQA 1JL31OFDTioWVjhiVIuIHK4ZLn1pDmiPVgQqo2TrFKRa2Rv2nDIT3D4aUL9XtEPsZuUP 3vJl0qUrSTq097ptk3NUNcWlF4iguUiqlhY/Zx1pXJ5iubsKs+vNcFqEli/9rbuuBkCd xwpgQfjJxqJlgN4wUchCgjh1eS8gFSwlYVmPiIj8nhCsKWS0Q5FaRlcGGihoCF377fJ0 GL2uGIkhzOCNPjbY2fTgzz//4XLs+3lR4dXyCZVhNBRhCHec0cod6Ae1+NuNRnXNzjaI hhHQ== 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=fHtfKlUDyaeQ9035f4gPbhSyHJu0Eg2krJWLMwXEToY=; b=II5rLmXGG0rb/sOJrzDmzm/yAMamTM2Y1i2nXoL1VvYDfXTRgD5p6ezH29z2gamw/n n4kxh21YSjIuUvzXrxFZqpGpuwmHKVrUMFHgnLKc+504qVxnKIZfNKhwHWoLVpiY2lG1 hrvFaAocx+myDO96Ei3b+n7sMQIKqKqbR+QqmlD8o98bt2Cco8I04w4smrxdgWJGvdYU UtgKQwn7qWAEjoespTmdbxnrvJhK3XIdM98OLMc95ubwPJzB7pRXZiVziEXj1Gc9Jt0G bFeH/VPJBPoJB4uCUzmMtq+tEZTMjrAlU8we0y21r7z1bAFKQWIT1Rb+bhRXb3hWj2pa P89w== X-Gm-Message-State: AKS2vOxZ7DpNv5NQ3dPM/dJkL489fSy7u5IQiMyLLbeXDN8aJc7XBTkc 2LqZ+VT4QIldo1JDaVI= X-Received: by 10.25.207.79 with SMTP id f76mr708322lfg.58.1497397142526; Tue, 13 Jun 2017 16:39:02 -0700 (PDT) Received: from localhost.localdomain (ppp109-252-91-7.pppoe.spdop.ru. [109.252.91.7]) by smtp.gmail.com with ESMTPSA id f27sm3785725lfa.27.2017.06.13.16.39.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 Jun 2017 16:39:01 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Mikko Perttunen , Erik Faye-Lund Subject: [PATCH v2 18/22] gpu: host1x: Check waits in the firewall Date: Wed, 14 Jun 2017 02:15:57 +0300 Message-Id: X-Mailer: git-send-email 2.13.0 In-Reply-To: References: In-Reply-To: References: X-Mailman-Approved-At: Wed, 14 Jun 2017 00:40:59 +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 32d3300bcf99..fc194c676d91 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) @@ -354,6 +356,17 @@ static bool check_reloc_shift(struct device *dev, struct host1x_reloc *reloc) 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; @@ -361,6 +374,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; @@ -390,6 +406,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; } @@ -554,6 +584,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++) { @@ -592,8 +624,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;