From patchwork Tue May 23 00:14:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 765644 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3wWwzB3XZvz9s2Q for ; Tue, 23 May 2017 10:15:34 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="MrQSaWIH"; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932854AbdEWAPd (ORCPT ); Mon, 22 May 2017 20:15:33 -0400 Received: from mail-lf0-f68.google.com ([209.85.215.68]:35552 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1763339AbdEWAPc (ORCPT ); Mon, 22 May 2017 20:15:32 -0400 Received: by mail-lf0-f68.google.com with SMTP id 99so6669657lfu.2 for ; Mon, 22 May 2017 17:15:32 -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=MrTbPt9AjQZUXv7ZyCokuhDQoLuqljhFgkSEq/jZDgs=; b=MrQSaWIHAWYropvIp15W/EwxDZArHj73M9bIQpY5ZHNXqX+ZTA/r9rzZobiyJDXW0e JHnsbIxYKU/oVq1pVXd8CO3kwcPAFvaUWFTn+U0C7yLU8j9OZc6UfdSo/ucILgD4QwpA eJLQl0+XyfJ3f359NpeOG+pZNMXK1iidgH+hfErvpL3goUKCrHpuwPdqTzvwj2kAFajq YMP1mBswwWCJ65o6U+YXIRUycyFfX8V/kaaYckkyvGE73JKs4vchD+PuRX8L8TXinRhy VVl7YnOWDhNH4rHd15nQLbAIjZI+wN1rbUhN1nhy5bGrW0FkGRqnVcDYjCQgKAMPQH1y 9Rbw== 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=MrTbPt9AjQZUXv7ZyCokuhDQoLuqljhFgkSEq/jZDgs=; b=m6guDK7XOn7UHGhYAxmQt9P9Hw5+OMIJzypsEv8lhy2DhDHHq9jwVnBbyGmWxuZ+o3 msX4sU+aIJwpcv4szXxy0j9qzpGqW+mEhD5RvKbX1xAzVXKEA41jkM5bCPPbKTf8O0qL QaurDK9NSGOrfLVxkmK4Zy/vcfcLoVUK4/SPQGEo6l3h2aiNeFuiTJ3lKfnefHbRAeVX J4nWbFOfr1nGfM8CXCXpcUpBASCHASoxk+oaUc+2cIEf5roo+KmT+1jqPpEiPf4MzlpN n/vixdxzGBu60BrcgnfRB1gjmr1bdHXDI62XyX2jsFU/WL4MV1NAnLAIrPxCZtAmY9xI m6Aw== X-Gm-Message-State: AODbwcBLoPJ/jUvmKTTQiTaj5aoAIggcYSwSQotO0fhBM1X8WmZ8ErAQ NwOOOK1dHEwr3OBuNkg= X-Received: by 10.46.1.79 with SMTP id 76mr6844506ljb.109.1495498531445; Mon, 22 May 2017 17:15:31 -0700 (PDT) Received: from localhost.localdomain (ppp109-252-91-175.pppoe.spdop.ru. [109.252.91.175]) by smtp.gmail.com with ESMTPSA id v30sm3440904ljd.9.2017.05.22.17.15.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 May 2017 17:15:30 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Mikko Perttunen Cc: linux-tegra@vger.kernel.org, DRI Development , Erik Faye-Lund Subject: [PATCH 17/22] gpu: host1x: Check waits in the firewall Date: Tue, 23 May 2017 03:14:32 +0300 Message-Id: <1c406c0f1ed144abb3d4b5f52272c5cd6faa2d3a.1495498184.git.digetx@gmail.com> X-Mailer: git-send-email 2.13.0 In-Reply-To: References: In-Reply-To: References: Sender: linux-tegra-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-tegra@vger.kernel.org Check waits in the firewall in a way it is done for relocations. Signed-off-by: Dmitry Osipenko Reviewed-by: Mikko Perttunen --- 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 65e12219405a..7bc7d0c64559 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) @@ -339,6 +341,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; @@ -346,6 +359,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; @@ -372,6 +388,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; } @@ -536,6 +566,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++) { @@ -574,8 +606,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;