From dabc7ac977e7e6ad9a32bab6b5a0141461164eb0 Mon Sep 17 00:00:00 2001 From: Peter Robinson Date: Thu, 12 Apr 2018 08:25:54 +0100 Subject: [PATCH] fix nouveau on Tegra, Enable IOMMU on Exynos --- arm-tegra-fix-nouveau-crash.patch | 64 +++++++++++++++++++ .../generic/arm/armv7/CONFIG_DRM_EXYNOS_IOMMU | 2 +- .../generic/arm/armv7/CONFIG_EXYNOS_IOMMU | 2 +- kernel-armv7hl-debug.config | 4 +- kernel-armv7hl-lpae-debug.config | 4 +- kernel-armv7hl-lpae.config | 4 +- kernel-armv7hl.config | 4 +- kernel.spec | 6 ++ 8 files changed, 80 insertions(+), 10 deletions(-) create mode 100644 arm-tegra-fix-nouveau-crash.patch diff --git a/arm-tegra-fix-nouveau-crash.patch b/arm-tegra-fix-nouveau-crash.patch new file mode 100644 index 000000000..d1d7c61a6 --- /dev/null +++ b/arm-tegra-fix-nouveau-crash.patch @@ -0,0 +1,64 @@ +From 369971aa0101c4cfb84dacaaaa1b5cc5790c14ff Mon Sep 17 00:00:00 2001 +From: Thierry Reding +Date: Wed, 11 Apr 2018 10:34:17 +0200 +Subject: [PATCH] drm/nouveau: tegra: Detach from ARM DMA/IOMMU mapping + +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. + +Signed-off-by: Thierry Reding +--- + drivers/gpu/drm/nouveau/nvkm/engine/device/tegra.c | 19 +++++++++++++++++++ + 1 file changed, 19 insertions(+) + +diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/device/tegra.c b/drivers/gpu/drm/nouveau/nvkm/engine/device/tegra.c +index 1f07999aea1d..ac7706f56f6f 100644 +--- a/drivers/gpu/drm/nouveau/nvkm/engine/device/tegra.c ++++ b/drivers/gpu/drm/nouveau/nvkm/engine/device/tegra.c +@@ -19,6 +19,11 @@ + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ ++ ++#if IS_ENABLED(CONFIG_ARM_DMA_USE_IOMMU) ++#include ++#endif ++ + #include + #ifdef CONFIG_NOUVEAU_PLATFORM_DRIVER + #include "priv.h" +@@ -105,6 +110,20 @@ nvkm_device_tegra_probe_iommu(struct nvkm_device_tegra *tdev) + 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_release_mapping(mapping); ++ arm_iommu_detach_device(dev); ++ ++ if (dev->archdata.dma_coherent) ++ set_dma_ops(dev, &arm_coherent_dma_ops); ++ else ++ set_dma_ops(dev, &arm_dma_ops); ++ } ++#endif ++ + if (!tdev->func->iommu_bit) + return; + +-- +2.16.3 + diff --git a/configs/fedora/generic/arm/armv7/CONFIG_DRM_EXYNOS_IOMMU b/configs/fedora/generic/arm/armv7/CONFIG_DRM_EXYNOS_IOMMU index 1c741aa22..5975dfe01 100644 --- a/configs/fedora/generic/arm/armv7/CONFIG_DRM_EXYNOS_IOMMU +++ b/configs/fedora/generic/arm/armv7/CONFIG_DRM_EXYNOS_IOMMU @@ -1 +1 @@ -# CONFIG_DRM_EXYNOS_IOMMU is not set +CONFIG_DRM_EXYNOS_IOMMU=y diff --git a/configs/fedora/generic/arm/armv7/CONFIG_EXYNOS_IOMMU b/configs/fedora/generic/arm/armv7/CONFIG_EXYNOS_IOMMU index 76ab03ad5..6a0844a77 100644 --- a/configs/fedora/generic/arm/armv7/CONFIG_EXYNOS_IOMMU +++ b/configs/fedora/generic/arm/armv7/CONFIG_EXYNOS_IOMMU @@ -1 +1 @@ -# CONFIG_EXYNOS_IOMMU is not set +CONFIG_EXYNOS_IOMMU=y diff --git a/kernel-armv7hl-debug.config b/kernel-armv7hl-debug.config index 84ee3e7ca..20c123d6e 100644 --- a/kernel-armv7hl-debug.config +++ b/kernel-armv7hl-debug.config @@ -1386,7 +1386,7 @@ CONFIG_DRM_EXYNOS_DSI=y CONFIG_DRM_EXYNOS_FIMD=y CONFIG_DRM_EXYNOS_G2D=y CONFIG_DRM_EXYNOS_HDMI=y -# CONFIG_DRM_EXYNOS_IOMMU is not set +CONFIG_DRM_EXYNOS_IOMMU=y CONFIG_DRM_EXYNOS=m CONFIG_DRM_EXYNOS_MIC=y CONFIG_DRM_EXYNOS_MIXER=y @@ -1702,7 +1702,7 @@ CONFIG_EXYNOS5420_MCPM=y CONFIG_EXYNOS_ADC=m CONFIG_EXYNOS_AUDSS_CLK_CON=m # CONFIG_EXYNOS_IOMMU_DEBUG is not set -# CONFIG_EXYNOS_IOMMU is not set +CONFIG_EXYNOS_IOMMU=y CONFIG_EXYNOS_THERMAL=y # CONFIG_EZNPS_GIC is not set # CONFIG_EZX_PCAP is not set diff --git a/kernel-armv7hl-lpae-debug.config b/kernel-armv7hl-lpae-debug.config index 31525f06c..36f707b0a 100644 --- a/kernel-armv7hl-lpae-debug.config +++ b/kernel-armv7hl-lpae-debug.config @@ -1328,7 +1328,7 @@ CONFIG_DRM_EXYNOS_DSI=y CONFIG_DRM_EXYNOS_FIMD=y CONFIG_DRM_EXYNOS_G2D=y CONFIG_DRM_EXYNOS_HDMI=y -# CONFIG_DRM_EXYNOS_IOMMU is not set +CONFIG_DRM_EXYNOS_IOMMU=y CONFIG_DRM_EXYNOS=m CONFIG_DRM_EXYNOS_MIC=y CONFIG_DRM_EXYNOS_MIXER=y @@ -1611,7 +1611,7 @@ CONFIG_EXYNOS5420_MCPM=y CONFIG_EXYNOS_ADC=m CONFIG_EXYNOS_AUDSS_CLK_CON=m # CONFIG_EXYNOS_IOMMU_DEBUG is not set -# CONFIG_EXYNOS_IOMMU is not set +CONFIG_EXYNOS_IOMMU=y CONFIG_EXYNOS_THERMAL=y # CONFIG_EZNPS_GIC is not set # CONFIG_EZX_PCAP is not set diff --git a/kernel-armv7hl-lpae.config b/kernel-armv7hl-lpae.config index 5b8cf7c51..2d8d79cf3 100644 --- a/kernel-armv7hl-lpae.config +++ b/kernel-armv7hl-lpae.config @@ -1318,7 +1318,7 @@ CONFIG_DRM_EXYNOS_DSI=y CONFIG_DRM_EXYNOS_FIMD=y CONFIG_DRM_EXYNOS_G2D=y CONFIG_DRM_EXYNOS_HDMI=y -# CONFIG_DRM_EXYNOS_IOMMU is not set +CONFIG_DRM_EXYNOS_IOMMU=y CONFIG_DRM_EXYNOS=m CONFIG_DRM_EXYNOS_MIC=y CONFIG_DRM_EXYNOS_MIXER=y @@ -1601,7 +1601,7 @@ CONFIG_EXYNOS5420_MCPM=y CONFIG_EXYNOS_ADC=m CONFIG_EXYNOS_AUDSS_CLK_CON=m # CONFIG_EXYNOS_IOMMU_DEBUG is not set -# CONFIG_EXYNOS_IOMMU is not set +CONFIG_EXYNOS_IOMMU=y CONFIG_EXYNOS_THERMAL=y # CONFIG_EZNPS_GIC is not set # CONFIG_EZX_PCAP is not set diff --git a/kernel-armv7hl.config b/kernel-armv7hl.config index 958e145a4..e79bc3e44 100644 --- a/kernel-armv7hl.config +++ b/kernel-armv7hl.config @@ -1376,7 +1376,7 @@ CONFIG_DRM_EXYNOS_DSI=y CONFIG_DRM_EXYNOS_FIMD=y CONFIG_DRM_EXYNOS_G2D=y CONFIG_DRM_EXYNOS_HDMI=y -# CONFIG_DRM_EXYNOS_IOMMU is not set +CONFIG_DRM_EXYNOS_IOMMU=y CONFIG_DRM_EXYNOS=m CONFIG_DRM_EXYNOS_MIC=y CONFIG_DRM_EXYNOS_MIXER=y @@ -1692,7 +1692,7 @@ CONFIG_EXYNOS5420_MCPM=y CONFIG_EXYNOS_ADC=m CONFIG_EXYNOS_AUDSS_CLK_CON=m # CONFIG_EXYNOS_IOMMU_DEBUG is not set -# CONFIG_EXYNOS_IOMMU is not set +CONFIG_EXYNOS_IOMMU=y CONFIG_EXYNOS_THERMAL=y # CONFIG_EZNPS_GIC is not set # CONFIG_EZX_PCAP is not set diff --git a/kernel.spec b/kernel.spec index 598026368..543af1c54 100644 --- a/kernel.spec +++ b/kernel.spec @@ -583,6 +583,8 @@ Patch304: arm-dts-imx6qdl-udoo-Disable-usbh1-to-avoid-kernel-hang.patch # https://marc.info/?l=linux-kernel&m=152328880417846&w=2 Patch308: arm64-thunderx-crypto-zip-fixes.patch +Patch309: arm-tegra-fix-nouveau-crash.patch + # Fix USB on the RPi https://patchwork.kernel.org/patch/9879371/ Patch320: bcm283x-dma-mapping-skip-USB-devices-when-configuring-DMA-during-probe.patch @@ -1856,6 +1858,10 @@ fi # # %changelog +* Thu Apr 12 2018 Peter Robinson +- Patch to fix nouveau on Tegra platforms +- Enable IOMMU on Exynos now upstream does + * Wed Apr 11 2018 Laura Abbott - Enable JFFS2 and some MTD modules (rhbz 1474493) - Enable a few infiniband options (rhbz 1291902)