Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp13385939ybl; Sun, 29 Dec 2019 10:37:40 -0800 (PST) X-Google-Smtp-Source: APXvYqzE8THUmatq3RcGs1tTNItED18gFE4wF0ks1zcKtbkuuCX0NT7H9xEvSo71+bWhETHTIbJ6 X-Received: by 2002:a05:6830:109a:: with SMTP id y26mr66270935oto.227.1577644660798; Sun, 29 Dec 2019 10:37:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577644660; cv=none; d=google.com; s=arc-20160816; b=bP21e0B3hkCJsqTcpJ/r5Vz0bUGk8cyjj0oyqAcR4tuepTQKziYLLYENUKbVYQmLai pF2xtZZ3y59ygoQWvN90kRu+LGbapUA5kJBWCwGmOp6U8pMYsCnsckJieXU3Q79HYY9l YnAp8eaScCAkfKLljmDK0qpok7YP8iFgVFr0qOUVbfwrfB0CppqBssG7rRgBUNNBPBby ZUbCY2G3WsY5KA6JD90wS4+iGk60oZbZ2aET1GJPWS2NPyz9SCGJ6vLd+13GsojNn2vV T4hw+wxL9Q0bJBYPUsr+WRVSU/M9IwD04NdhuTOcOuhenrqNqdKnz+K++3Q2gsS/DFUZ 4SEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=QKGSk25TxZxJst3K2Q4nGlJTn/KFY60GenRUcKp1ff0=; b=Tj1J/wgmyh6q7rhMY3/z4Dol+9sx6Brg4Q9S8aDMZDYVlNZmsnvii4JZs365Zuhuxf ksrj7Y01A8un4RnOE5jTNCQXRlGxoZ5ohPzA24EByCgq3kF68I5a3m3OnCBSi6uKA4bt bCsFeYMg54Cq9eUHIXBIq5+36t/C/ya8cvhGH3bjONNwiYIDhoP0dIn1afKh4Rot1ATN 0KfWR1bdX+y+74RnX10FRCC2MMJTs8i0rGyXZ5Jpoqd7PVzHAvppOsGal1G0Qyd5C4pw t+pJPRpyyGVr/YM7wc+Fwvaxqcj7+3p3obIcybbxaMHE1rVWFI0RcqUlAozpElNXv7dC 2LCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=zm6FoArY; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z22si14170431otq.94.2019.12.29.10.37.29; Sun, 29 Dec 2019 10:37:40 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=zm6FoArY; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727657AbfL2RYB (ORCPT + 99 others); Sun, 29 Dec 2019 12:24:01 -0500 Received: from mail.kernel.org ([198.145.29.99]:42126 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727627AbfL2RX4 (ORCPT ); Sun, 29 Dec 2019 12:23:56 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A2FCC207FF; Sun, 29 Dec 2019 17:23:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1577640236; bh=QCY32OuSxcr3Fkj8QMYFUED5pQtEic9wMvrsiTraGzI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zm6FoArYh1Dqwcjk6dtJ3kFY/MJHXGbk+xX7ihqidw5wCAnsQ4FUVOdsYQBbzsSYz CBq3hKJIPR+JyVxSdbsLDZbz6znf9pofmsSfSx2kJNvOLirqyGtaUyTzVvKg7Vfx/U 0PbYyiT34pNcXUl+AnE0tvDOe++Bn8um6/9bKDX4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Thierry Reding , Sasha Levin Subject: [PATCH 4.14 073/161] gpu: host1x: Allocate gather copy for host1x Date: Sun, 29 Dec 2019 18:18:41 +0100 Message-Id: <20191229162422.283605497@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20191229162355.500086350@linuxfoundation.org> References: <20191229162355.500086350@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Thierry Reding [ Upstream commit b78e70c04c149299bd210759d7c7af7c86b89ca8 ] Currently when the gather buffers are copied, they are copied to a buffer that is allocated for the host1x client that wants to execute the command streams in the buffers. However, the gather buffers will be read by the host1x device, which causes SMMU faults if the DMA API is backed by an IOMMU. Fix this by allocating the gather buffer copy for the host1x device, which makes sure that it will be mapped into the host1x's IOVA space if the DMA API is backed by an IOMMU. Signed-off-by: Thierry Reding Signed-off-by: Sasha Levin --- drivers/gpu/host1x/job.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/host1x/job.c b/drivers/gpu/host1x/job.c index acd99783bbca..67f3c050c4cf 100644 --- a/drivers/gpu/host1x/job.c +++ b/drivers/gpu/host1x/job.c @@ -545,7 +545,8 @@ out: return err; } -static inline int copy_gathers(struct host1x_job *job, struct device *dev) +static inline int copy_gathers(struct device *host, struct host1x_job *job, + struct device *dev) { struct host1x_firewall fw; size_t size = 0; @@ -570,12 +571,12 @@ static inline int copy_gathers(struct host1x_job *job, struct device *dev) * Try a non-blocking allocation from a higher priority pools first, * as awaiting for the allocation here is a major performance hit. */ - job->gather_copy_mapped = dma_alloc_wc(dev, size, &job->gather_copy, + job->gather_copy_mapped = dma_alloc_wc(host, size, &job->gather_copy, GFP_NOWAIT); /* the higher priority allocation failed, try the generic-blocking */ if (!job->gather_copy_mapped) - job->gather_copy_mapped = dma_alloc_wc(dev, size, + job->gather_copy_mapped = dma_alloc_wc(host, size, &job->gather_copy, GFP_KERNEL); if (!job->gather_copy_mapped) @@ -636,7 +637,7 @@ int host1x_job_pin(struct host1x_job *job, struct device *dev) goto out; if (IS_ENABLED(CONFIG_TEGRA_HOST1X_FIREWALL)) { - err = copy_gathers(job, dev); + err = copy_gathers(host->dev, job, dev); if (err) goto out; } @@ -701,7 +702,7 @@ void host1x_job_unpin(struct host1x_job *job) job->num_unpins = 0; if (job->gather_copy_size) - dma_free_wc(job->channel->dev, job->gather_copy_size, + dma_free_wc(host->dev, job->gather_copy_size, job->gather_copy_mapped, job->gather_copy); } EXPORT_SYMBOL(host1x_job_unpin); -- 2.20.1