Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2463376imm; Mon, 24 Sep 2018 04:58:14 -0700 (PDT) X-Google-Smtp-Source: ACcGV62bGZRs6mjtcPFCxLitRO0FCCTbbeaMD9BQsC9hG7O+rY7HLFVDuO/8kZqH7pMcPpNa6wmu X-Received: by 2002:a17:902:b092:: with SMTP id p18-v6mr6641527plr.90.1537790293999; Mon, 24 Sep 2018 04:58:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537790293; cv=none; d=google.com; s=arc-20160816; b=F7DQtkdU+Dd8SgUjpLwTqV/AcLgSWd8u7ucVUhnsZGdjNSjzlSzkPXpnalpDy521zb C9WDZIPlwSUGiuaJzIe9c35vLao0M3DvVRs36Sv7B7TsYiA+pWun6X4BJ+w/3QbCrMQa riLKIvdytHfc7b+Xi/Xm6MS+bvZIApynAmWGhiAEy25EuWYlbYcxf6OOY7KrOQn9L05z XPOAtc8C6v2IyUPdw+bH3m41UvY4V0kREYwzuGEV+wgQzeGOjei8IWRkxhTnxh2UfBV6 24DCirjkGHSRAqJmM49C+7A4NtUwC2oawXroorZ9gdHrjDvtNyQdDZHFtLNcwK1/+O/f RCww== 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; bh=i4IFsB+CV0SpH1h10hJkr5TVQCddLIkvXG/IcWHAbSI=; b=gppkTXH/PrNiS663rRJgLr4cHNuaK1rzwKWM8iRovKz3+saxvG0wU3Vh9WxWhH3sdW LUQ3Rp6CjNukOvvyxyZg9byzVPhgVcung1Znx04ttAFbz6b68xhaDWIcyXZo+0A2N2yb mnpZ/qUfJRtYpp+y83mCsSDJe7fj7TNBhh33VsoacWMzK5BPtNN35BdODWYjHQuVNBiA Yck60HGoouSDhOlsmfLHgeHNc9YjffCtqstC1aEAVyIpi46JmCr7CpkMKccLHxwYxrTQ hQ+KkIUKnGhkfTDEfE6IvDZOnbRVJFl0K6jCP+d5jfjOY0nXGKWXS/WN/1t2wXISwyJU J9Mg== ARC-Authentication-Results: i=1; mx.google.com; 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 o7-v6si35522186pfk.356.2018.09.24.04.57.58; Mon, 24 Sep 2018 04:58:13 -0700 (PDT) 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; 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 S1730158AbeIXR6y (ORCPT + 99 others); Mon, 24 Sep 2018 13:58:54 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:52130 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729106AbeIXR6y (ORCPT ); Mon, 24 Sep 2018 13:58:54 -0400 Received: from localhost (ip-213-127-77-73.ip.prioritytelecom.net [213.127.77.73]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 801561075; Mon, 24 Sep 2018 11:57:08 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Thierry Reding , Christoph Hellwig , Robin Murphy , Nicolas Chauvet , Ben Skeggs , Sasha Levin Subject: [PATCH 4.4 54/70] drm/nouveau: tegra: Detach from ARM DMA/IOMMU mapping Date: Mon, 24 Sep 2018 13:52:53 +0200 Message-Id: <20180924113106.129663968@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180924113058.420454070@linuxfoundation.org> References: <20180924113058.420454070@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review 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 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Thierry Reding [ Upstream commit b59fb482b52269977ee5de205308e5b236a03917 ] Depending on the kernel configuration, early ARM architecture setup code may have attached the GPU to a DMA/IOMMU mapping that transparently uses the IOMMU to back the DMA API. Tegra requires special handling for IOMMU backed buffers (a special bit in the GPU's MMU page tables indicates the memory path to take: via the SMMU or directly to the memory controller). Transparently backing DMA memory with an IOMMU prevents Nouveau from properly handling such memory accesses and causes memory access faults. As a side-note: buffers other than those allocated in instance memory don't need to be physically contiguous from the GPU's perspective since the GPU can map them into contiguous buffers using its own MMU. Mapping these buffers through the IOMMU is unnecessary and will even lead to performance degradation because of the additional translation. One exception to this are compressible buffers which need large pages. In order to enable these large pages, multiple small pages will have to be combined into one large (I/O virtually contiguous) mapping via the IOMMU. However, that is a topic outside the scope of this fix and isn't currently supported. An implementation will want to explicitly create these large pages in the Nouveau driver, so detaching from a DMA/IOMMU mapping would still be required. Signed-off-by: Thierry Reding Acked-by: Christoph Hellwig Reviewed-by: Robin Murphy Tested-by: Nicolas Chauvet Signed-off-by: Ben Skeggs Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/nouveau/nvkm/engine/device/tegra.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) --- a/drivers/gpu/drm/nouveau/nvkm/engine/device/tegra.c +++ b/drivers/gpu/drm/nouveau/nvkm/engine/device/tegra.c @@ -23,6 +23,10 @@ #ifdef CONFIG_NOUVEAU_PLATFORM_DRIVER #include "priv.h" +#if IS_ENABLED(CONFIG_ARM_DMA_USE_IOMMU) +#include +#endif + static int nvkm_device_tegra_power_up(struct nvkm_device_tegra *tdev) { @@ -85,6 +89,15 @@ nvkm_device_tegra_probe_iommu(struct nvk unsigned long pgsize_bitmap; int ret; +#if IS_ENABLED(CONFIG_ARM_DMA_USE_IOMMU) + if (dev->archdata.mapping) { + struct dma_iommu_mapping *mapping = to_dma_iommu_mapping(dev); + + arm_iommu_detach_device(dev); + arm_iommu_release_mapping(mapping); + } +#endif + if (!tdev->func->iommu_bit) return;