From patchwork Mon Oct 28 12:37:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 11215295 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C9E6C112C for ; Mon, 28 Oct 2019 12:37:37 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B296F208C0 for ; Mon, 28 Oct 2019 12:37:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B296F208C0 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D42176E82B; Mon, 28 Oct 2019 12:37:36 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wr1-x443.google.com (mail-wr1-x443.google.com [IPv6:2a00:1450:4864:20::443]) by gabe.freedesktop.org (Postfix) with ESMTPS id 788D86E82B for ; Mon, 28 Oct 2019 12:37:35 +0000 (UTC) Received: by mail-wr1-x443.google.com with SMTP id w18so9726010wrt.3 for ; Mon, 28 Oct 2019 05:37:35 -0700 (PDT) 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:mime-version:content-transfer-encoding; bh=YGu5TjyuaHf7D/YFViamxWFcAcwWPrmI9iCh49BU0qM=; b=j+9SZD0lkH7hLDngjY2qxyUlkGdyc6cyqhxicwPRYEbafEewcys7PBBp6xyspPpA/Y mdN2ShqOUPb7CwGajKTgFeS+peUP/wjQsgRZJ+XbzlodSj1lFwjlF3QKcRLkHRiUVmz5 SqKCoUkK/kyddhvkHX1S4mgTcFZ/xd4zl3nFRdvQy7iMS41sEdql0VfbJpV05Nf12gVC 0aoczeatlkGY4Z+DrQg7a25tBgy8YkwjO07SIEnLmBpUOE8krOpT7NCyMnckgvPtypmQ HR4G36qW5fPLS3mXHiFVaZfKM+0jNLgVrRaM9OB4plQNXEly1Hm+Sv5LMv5A8czvJCZP kwTA== X-Gm-Message-State: APjAAAX11oCpcgrleZ55SYyJsLD7aP8Klde279bFzAPZqk3JpLP2//jJ c5az9RWYsWwwNLQ1SCZNHmk= X-Google-Smtp-Source: APXvYqz7QNZG6RSaXHUuYYcJVyTDml0KvIAScsBZprWSCdNBiGZVAoDWl7Flo6yTPY3bLHEYb3ebhw== X-Received: by 2002:a5d:4283:: with SMTP id k3mr14839241wrq.236.1572266253975; Mon, 28 Oct 2019 05:37:33 -0700 (PDT) Received: from localhost (p2E5BE2CE.dip0.t-ipconnect.de. [46.91.226.206]) by smtp.gmail.com with ESMTPSA id d16sm1542915wmb.27.2019.10.28.05.37.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Oct 2019 05:37:32 -0700 (PDT) From: Thierry Reding To: Thierry Reding Subject: [PATCH 06/12] gpu: host1x: Allocate gather copy for host1x Date: Mon, 28 Oct 2019 13:37:12 +0100 Message-Id: <20191028123718.3890217-7-thierry.reding@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191028123718.3890217-1-thierry.reding@gmail.com> References: <20191028123718.3890217-1-thierry.reding@gmail.com> MIME-Version: 1.0 X-Mailman-Original-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 :mime-version:content-transfer-encoding; bh=YGu5TjyuaHf7D/YFViamxWFcAcwWPrmI9iCh49BU0qM=; b=J6T8Et3Q9OPbN2qUhiKDlDj4XkuDt/ejRzmA4Y+vOMYWTSHcAmlFNIDC9V9jAW4w+p 48GR6SvU7LTdX9aAiXbed/AX8rODJnC6qHCRM9qwMuVKohbGVxqnbmoCdKbSBjrbJhAj 6RqYc7u4Q4YrZGyrNliJFpbCmlI0Gm+W+126GLBIqEkC4yoTQir++QrqrSzgONFmd+cY TA7yFW0twfdoblb5IrT4oQO/jrCTT/Ds+fwh3Tp4Cx7CWl2bOWsurn2p/uaox4dNVBCY Er3trvhH2kF0ENxCN9pN7J1Ts/AFK4smzAbkpnZR0ptF+Ujj0sC66JBQgmvUNBL3xRb6 LSBg== X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-tegra@vger.kernel.org, Sachin Nikam , dri-devel@lists.freedesktop.org, Puneet Saxena Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Thierry Reding 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 --- 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 90dd592fdfca..2e0c3e0ca1fa 100644 --- a/drivers/gpu/host1x/job.c +++ b/drivers/gpu/host1x/job.c @@ -445,7 +445,8 @@ static int validate(struct host1x_firewall *fw, struct host1x_job_gather *g) 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; @@ -468,12 +469,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) @@ -521,7 +522,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; } @@ -582,7 +583,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);