[Nouveau] [PATCH 1/6] platform: specify the IOMMU physical translation bit

Vince Hsu vinceh at nvidia.com
Thu Apr 16 04:06:14 PDT 2015


The IOMMU physical translation bit might vary with different SoCs. So add
a variable to specify this bit for GK20A.

Signed-off-by: Vince Hsu <vinceh at nvidia.com>
---
 drm/nouveau/nouveau_platform.c | 19 +++++++++++++++++++
 drm/nouveau/nouveau_platform.h |  1 +
 2 files changed, 20 insertions(+)

diff --git a/drm/nouveau/nouveau_platform.c b/drm/nouveau/nouveau_platform.c
index 775277f1edb0..0d002f73e356 100644
--- a/drm/nouveau/nouveau_platform.c
+++ b/drm/nouveau/nouveau_platform.c
@@ -25,6 +25,7 @@
 #include <linux/module.h>
 #include <linux/platform_device.h>
 #include <linux/of.h>
+#include <linux/of_device.h>
 #include <linux/reset.h>
 #include <linux/regulator/consumer.h>
 #include <linux/iommu.h>
@@ -92,6 +93,22 @@ static int nouveau_platform_power_down(struct nouveau_platform_gpu *gpu)
 	return 0;
 }
 
+static unsigned long nouveau_platform_get_iommu_bit(struct device *dev)
+{
+	const struct of_device_id *match;
+
+	match = of_match_device(dev->driver->of_match_table, dev);
+	if (!match) {
+		dev_warn(dev, "cannot find OF match for device\n");
+		return 0;
+	}
+
+	if (!strcmp(match->compatible, "nvidia,gk20a"))
+		return 34;
+	else
+		return 0;
+}
+
 static void nouveau_platform_probe_iommu(struct device *dev,
 					 struct nouveau_platform_gpu *gpu)
 {
@@ -122,6 +139,8 @@ static void nouveau_platform_probe_iommu(struct device *dev,
 			gpu->iommu.pgshift -= 1;
 		}
 
+		gpu->iommu.phys_addr_bit = nouveau_platform_get_iommu_bit(dev);
+
 		err = iommu_attach_device(gpu->iommu.domain, dev);
 		if (err)
 			goto free_domain;
diff --git a/drm/nouveau/nouveau_platform.h b/drm/nouveau/nouveau_platform.h
index 392874cf4725..3e9bd7dc0092 100644
--- a/drm/nouveau/nouveau_platform.h
+++ b/drm/nouveau/nouveau_platform.h
@@ -53,6 +53,7 @@ struct nouveau_platform_gpu {
 		struct nvkm_mm *mm;
 		struct iommu_domain *domain;
 		unsigned long pgshift;
+		unsigned long phys_addr_bit;
 	} iommu;
 };
 
-- 
2.1.4



More information about the Nouveau mailing list