From patchwork Wed May 30 08:03:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 922607 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-tegra-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="fn8PZjBv"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 40wjlt0nLjz9s0q for ; Wed, 30 May 2018 18:03:54 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935827AbeE3IDx (ORCPT ); Wed, 30 May 2018 04:03:53 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:35463 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935429AbeE3IDv (ORCPT ); Wed, 30 May 2018 04:03:51 -0400 Received: by mail-wm0-f65.google.com with SMTP id o78-v6so46031627wmg.0 for ; Wed, 30 May 2018 01:03:51 -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; bh=U0e1INlYNiVrC0pChYYWneuiRk8CvSOc17GYO6usKdw=; b=fn8PZjBvldQYPvBW4KYX3OatmT/i8/RNrgPkuJLDqfpWUK9xnzjdeyjPeGWuTQIAyU jY9lJvrMyr04nDn8w2kjcX0cKTDoBEKOqOGgoUwykU3ptNMri9gQ/R3ukYNUo2BmKaWE wAAWlhhDPq5xPGl29guSrkUECjaapl2BNEELpJCVavarwVhSMo3PqNX3jE4Ud4wlvaYg ifiGJH/KEgGLC9Nym3R+oYvznZWVjpBpevGcxruoCl6kUOQgaRfEyBOAYH6BCwfqv5FU X0uazbNVUzdWIY7JBbpZZ1Jo9n5DkSigNrUzyVRXgIHEa7Jr5jKbw0Yd7/m7s1iLFn42 zDJg== 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; bh=U0e1INlYNiVrC0pChYYWneuiRk8CvSOc17GYO6usKdw=; b=FuqDPDB7Lzz3EbQtd7Xf1rJBDVPi0RY+NSZYoeNUyP7fYBa95CWfHg0v5xrhQgcHNk 3KnoA90pn/ep/eK6C+NrPE/Y8VZPLku2rLTY6P1c8oRrkYiBZZqwpwZaSk/Ro5jTXbxv JkiCif/kQBh0R8qeZnHgyYsPqqeEWCYJjFlnY7/rD9CLKQlE8u6/TjDuYhAD9vaNlBU4 p+u6wYaPqz6SRiFh+s4ZvXmLKYQJb5xgQkgvm2Pgv6BTbffgCUazZKugVaX2WF4kYc6V ax+lDOVAkrpQP7JpW6zFE4DISx1jUNeF+VJVrndlzN7f7+TKAHFB3B4b9z38jgv+oUZa SDlQ== X-Gm-Message-State: APt69E1WdcJty4Wy6/zbik+42mT4XHgE980W6/aw/vheBh+VENQT6wbq OcLszGXTrvfmYfiPi4XDOkL18Q== X-Google-Smtp-Source: ADUXVKIUc9gaVMd7brBoMu6p3sNf/q7HPjSMOB7gAd2vnPOHh6igchGMk35ywLM1Ui49bvWJ4S1cxQ== X-Received: by 2002:a1c:eb0e:: with SMTP id j14-v6mr631109wmh.87.1527667430591; Wed, 30 May 2018 01:03:50 -0700 (PDT) Received: from localhost (p2E5BEDA6.dip0.t-ipconnect.de. [46.91.237.166]) by smtp.gmail.com with ESMTPSA id n7-v6sm16363951wri.27.2018.05.30.01.03.49 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 30 May 2018 01:03:49 -0700 (PDT) From: Thierry Reding To: Ben Skeggs , Christoph Hellwig , Russell King Cc: Robin Murphy , Joerg Roedel , Daniel Vetter , Jordan Crouse , nouveau@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, iommu@lists.linux-foundation.org, linux-tegra@vger.kernel.org Subject: [PATCH v3 2/2] drm/nouveau: tegra: Detach from ARM DMA/IOMMU mapping Date: Wed, 30 May 2018 10:03:45 +0200 Message-Id: <20180530080345.2353-3-thierry.reding@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180530080345.2353-1-thierry.reding@gmail.com> References: <20180530080345.2353-1-thierry.reding@gmail.com> Sender: linux-tegra-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-tegra@vger.kernel.org From: Thierry Reding 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 --- Changes in v3: - clarify the use of IOMMU mapping for compressible buffers - squash multiple patches into this drivers/gpu/drm/nouveau/nvkm/engine/device/tegra.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/device/tegra.c b/drivers/gpu/drm/nouveau/nvkm/engine/device/tegra.c index 78597da6313a..d0538af1b967 100644 --- a/drivers/gpu/drm/nouveau/nvkm/engine/device/tegra.c +++ b/drivers/gpu/drm/nouveau/nvkm/engine/device/tegra.c @@ -105,6 +105,11 @@ nvkm_device_tegra_probe_iommu(struct nvkm_device_tegra *tdev) unsigned long pgsize_bitmap; int ret; +#if IS_ENABLED(CONFIG_ARM) + /* make sure we can use the IOMMU exclusively */ + arm_dma_iommu_detach_device(dev); +#endif + if (!tdev->func->iommu_bit) return;