nvkm_device_tegra_new uses iommu_bit to set the DMA mask before
constructing the device. On GK20A, GM20B and GP10B, the IOMMU selector
is the first bit above the platform DMA mask. GV11B bypasses the system
IOMMU while still needing to set a DMA mask.

Give the Tegra platform data a dma_bits field and use it for the early
dma_set_mask call. Keep iommu_bit for the private IOMMU domain and its
address tag. Set dma_bits to 34 on GK20A and GM20B and to 36 on GP10B
to preserve their existing masks.

Signed-off-by: Mikko Perttunen <[email protected]>
---
 drivers/gpu/drm/nouveau/include/nvkm/core/tegra.h  | 1 +
 drivers/gpu/drm/nouveau/nouveau_platform.c         | 3 +++
 drivers/gpu/drm/nouveau/nvkm/engine/device/tegra.c | 5 +----
 3 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/include/nvkm/core/tegra.h 
b/drivers/gpu/drm/nouveau/include/nvkm/core/tegra.h
index 0189043382d0..5900e3336db6 100644
--- a/drivers/gpu/drm/nouveau/include/nvkm/core/tegra.h
+++ b/drivers/gpu/drm/nouveau/include/nvkm/core/tegra.h
@@ -37,6 +37,7 @@ struct nvkm_device_tegra {
 };
 
 struct nvkm_device_tegra_func {
+       u8 dma_bits;
        /*
         * If an IOMMU is used, indicates which address bit will trigger a
         * IOMMU translation when set (when this bit is not set, IOMMU is
diff --git a/drivers/gpu/drm/nouveau/nouveau_platform.c 
b/drivers/gpu/drm/nouveau/nouveau_platform.c
index 9fd351273236..9ca6272ce809 100644
--- a/drivers/gpu/drm/nouveau/nouveau_platform.c
+++ b/drivers/gpu/drm/nouveau/nouveau_platform.c
@@ -59,17 +59,20 @@ static SIMPLE_DEV_PM_OPS(nouveau_pm_ops, 
nouveau_platform_suspend,
 
 #if IS_ENABLED(CONFIG_OF)
 static const struct nvkm_device_tegra_func gk20a_platform_data = {
+       .dma_bits = 34,
        .iommu_bit = 34,
        .require_vdd = true,
 };
 
 static const struct nvkm_device_tegra_func gm20b_platform_data = {
+       .dma_bits = 34,
        .iommu_bit = 34,
        .require_vdd = true,
        .require_ref_clk = true,
 };
 
 static const struct nvkm_device_tegra_func gp10b_platform_data = {
+       .dma_bits = 36,
        .iommu_bit = 36,
        /* power provided by generic PM domains */
        .require_vdd = false,
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/device/tegra.c 
b/drivers/gpu/drm/nouveau/nvkm/engine/device/tegra.c
index c04006d38c64..7070d991f3ee 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/device/tegra.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/device/tegra.c
@@ -325,10 +325,7 @@ nvkm_device_tegra_new(const struct nvkm_device_tegra_func 
*func,
                goto free;
        }
 
-       /**
-        * The IOMMU bit defines the upper limit of the GPU-addressable space.
-        */
-       ret = dma_set_mask(&pdev->dev, DMA_BIT_MASK(tdev->func->iommu_bit));
+       ret = dma_set_mask(&pdev->dev, DMA_BIT_MASK(func->dma_bits));
        if (ret)
                goto free;
 

-- 
2.56.1

Reply via email to