Skip to contentSkip to conversation

OMAP:IOMMU support for OMAP4 and TLB preservation support

PATCH New Hari Kanigeri 1 participant 5 messages Apr 22, 2010

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

v4 cover OMAP:IOMMU support for OMAP4 and TLB preservation support

Following are the revised patches addressing the comments from Tony, Felipe, and Hiroshi to address multi-omap support and make TLB locking mechanism generic.

Hari Kanigeri (4):
OMAP:iommu renamed omap3-iommu to omap-iommu
OMAP:iommu support for OMAP4
OMAP:iommu - missing check for TLB valid entry
OMAP:iommu- add TLB preservation support

 arch/arm/mach-omap2/Makefile               |    4 +-
 arch/arm/mach-omap2/iommu2.c               |    6 +-
 arch/arm/mach-omap2/omap-iommu.c           |  157 ++++++++++++++++++++++++++++
 arch/arm/mach-omap2/omap3-iommu.c          |  105 -------------------
 arch/arm/plat-omap/include/plat/omap44xx.h |    3 +
 arch/arm/plat-omap/iommu.c                 |   43 +++++---
 6 files changed, 191 insertions(+), 127 deletions(-)
 create mode 100644 arch/arm/mach-omap2/omap-iommu.c
 delete mode 100644 arch/arm/mach-omap2/omap3-iommu.c
#1 lore raw

PATCH v4 1/4 OMAP:iommu renamed omap3-iommu to omap-iommu

This patch includes changes to omap3-iommu.c file to make it generic for all OMAPs. Renamed omap3-iommu.c to omap-iommu.c

---
 arch/arm/mach-omap2/Makefile                       |    4 +--
 .../arm/mach-omap2/{omap3-iommu.c => omap-iommu.c} |   23 +++++++++++--------
 2 files changed, 14 insertions(+), 13 deletions(-)
 rename arch/arm/mach-omap2/{omap3-iommu.c => omap-iommu.c} (79%)
arch/arm/mach-omap2/Makefile +1 -3
index dac3e56..0f616cb 100644
@@ -88,9 +88,7 @@ obj-$(CONFIG_ARCH_OMAP2)		+= remoteproc24xx.o
 obj-$(CONFIG_ARCH_OMAP3)		+= remoteproc3xxx.o
 obj-$(CONFIG_ARCH_OMAP4)		+= remoteproc44xx.o
 endif
-iommu-y					+= iommu2.o
-iommu-$(CONFIG_ARCH_OMAP3)		+= omap3-iommu.o
-
+iommu-y					+= iommu2.o omap-iommu.o
 obj-$(CONFIG_OMAP_IOMMU)		+= $(iommu-y)
 
 i2c-omap-$(CONFIG_I2C_OMAP)		:= i2c.o
arch/arm/mach-omap2/omap-iommu.c renamed from arch/arm/mach-omap2/omap3-iommu.c +13 -10
similarity index 79%
rename from arch/arm/mach-omap2/omap3-iommu.c
rename to arch/arm/mach-omap2/omap-iommu.c
index fbbcb5c..416a65d 100644
@@ -1,5 +1,5 @@
 /*
- * omap iommu: omap3 device registration
+ * omap iommu: omap device registration
  *
  * Copyright (C) 2008-2009 Nokia Corporation
  *
@@ -21,6 +21,7 @@ struct iommu_device {
 	struct resource res[2];
 };
 
+#ifdef CONFIG_ARCH_OMAP3
 static struct iommu_device devices[] = {
 	{
 		.base = 0x480bd400,
@@ -43,11 +44,13 @@ static struct iommu_device devices[] = {
 	},
 #endif
 };
+#endif
+
 #define NR_IOMMU_DEVICES ARRAY_SIZE(devices)
 
-static struct platform_device *omap3_iommu_pdev[NR_IOMMU_DEVICES];
+static struct platform_device *omap_iommu_pdev[NR_IOMMU_DEVICES];
 
-static int __init omap3_iommu_init(void)
+static int __init omap_iommu_init(void)
 {
 	int i, err;
 	struct resource res[] = {
@@ -80,26 +83,26 @@ static int __init omap3_iommu_init(void)
 		err = platform_device_add(pdev);
 		if (err)
 			goto err_out;
-		omap3_iommu_pdev[i] = pdev;
+		omap_iommu_pdev[i] = pdev;
 	}
 	return 0;
 
 err_out:
 	while (i--)
-		platform_device_put(omap3_iommu_pdev[i]);
+		platform_device_put(omap_iommu_pdev[i]);
 	return err;
 }
-module_init(omap3_iommu_init);
+module_init(omap_iommu_init);
 
-static void __exit omap3_iommu_exit(void)
+static void __exit omap_iommu_exit(void)
 {
 	int i;
 
 	for (i = 0; i < NR_IOMMU_DEVICES; i++)
-		platform_device_unregister(omap3_iommu_pdev[i]);
+		platform_device_unregister(omap_iommu_pdev[i]);
 }
-module_exit(omap3_iommu_exit);
+module_exit(omap_iommu_exit);
 
 MODULE_AUTHOR("Hiroshi DOYU");
-MODULE_DESCRIPTION("omap iommu: omap3 device registration");
+MODULE_DESCRIPTION("omap iommu: omap device registration");
 MODULE_LICENSE("GPL v2");
Signature · 1 line
1.7.0
#2 lore raw

PATCH v4 2/4 OMAP:iommu support for OMAP4

In reply to Hari Kanigeri

This patch provides the iommu support for OMAP4 co-processors.

---
 arch/arm/mach-omap2/omap-iommu.c           |   59 +++++++++++++++++++++++++--
 arch/arm/plat-omap/include/plat/omap44xx.h |    3 +
 2 files changed, 57 insertions(+), 5 deletions(-)
arch/arm/mach-omap2/omap-iommu.c +54 -5
index 416a65d..eb9bee7 100644
@@ -13,6 +13,7 @@
 #include <linux/platform_device.h>
 
 #include <plat/iommu.h>
+#include <plat/irqs.h>
 
 struct iommu_device {
 	resource_size_t base;
@@ -20,9 +21,11 @@ struct iommu_device {
 	struct iommu_platform_data pdata;
 	struct resource res[2];
 };
+static struct iommu_device *devices;
+static int num_iommu_devices;
 
 #ifdef CONFIG_ARCH_OMAP3
-static struct iommu_device devices[] = {
+static struct iommu_device omap3_devices[] = {
 	{
 		.base = 0x480bd400,
 		.irq = 24,
@@ -44,11 +47,46 @@ static struct iommu_device devices[] = {
 	},
 #endif
 };
+#define NR_OMAP3_IOMMU_DEVICES ARRAY_SIZE(omap3_devices)
+static struct platform_device *omap3_iommu_pdev[NR_OMAP3_IOMMU_DEVICES];
+#else
+#define omap3_devices		NULL
+#define NR_OMAP3_IOMMU_DEVICES	0
+#define omap3_iommu_pdev	NULL
 #endif
 
-#define NR_IOMMU_DEVICES ARRAY_SIZE(devices)
+#ifdef CONFIG_ARCH_OMAP4
+static struct iommu_device omap4_devices[] = {
+	{
+		.base = OMAP4_MMU1_BASE,
+		.irq = INT_44XX_DUCATI_MMU_IRQ,
+		.pdata = {
+			.name = "ducati",
+			.nr_tlb_entries = 32,
+			.clk_name = "ducati_ick",
+		},
+	},
+#if defined(CONFIG_MPU_TESLA_IOMMU)
+	{
+		.base = OMAP4_MMU2_BASE,
+		.irq = INT_44XX_DSP_MMU,
+		.pdata = {
+			.name = "tesla",
+			.nr_tlb_entries = 32,
+			.clk_name = "tesla_ick",
+		},
+	},
+#endif
+};
+#define NR_OMAP4_IOMMU_DEVICES ARRAY_SIZE(omap4_devices)
+static struct platform_device *omap4_iommu_pdev[NR_OMAP4_IOMMU_DEVICES];
+#else
+#define omap4_devices		NULL
+#define NR_OMAP4_IOMMU_DEVICES	0
+#define omap4_iommu_pdev	NULL
+#endif
 
-static struct platform_device *omap_iommu_pdev[NR_IOMMU_DEVICES];
+static struct platform_device **omap_iommu_pdev;
 
 static int __init omap_iommu_init(void)
 {
@@ -58,7 +96,18 @@ static int __init omap_iommu_init(void)
 		{ .flags = IORESOURCE_IRQ },
 	};
 
-	for (i = 0; i < NR_IOMMU_DEVICES; i++) {
+	if (cpu_is_omap34xx()) {
+		devices = omap3_devices;
+		omap_iommu_pdev = omap3_iommu_pdev;
+		num_iommu_devices = NR_OMAP3_IOMMU_DEVICES;
+	} else if (cpu_is_omap44xx()) {
+		devices = omap4_devices;
+		omap_iommu_pdev = omap4_iommu_pdev;
+		num_iommu_devices = NR_OMAP4_IOMMU_DEVICES;
+	} else
+		return -ENODEV;
+
+	for (i = 0; i < num_iommu_devices; i++) {
 		struct platform_device *pdev;
 		const struct iommu_device *d = &devices[i];
 
@@ -98,7 +147,7 @@ static void __exit omap_iommu_exit(void)
 {
 	int i;
 
-	for (i = 0; i < NR_IOMMU_DEVICES; i++)
+	for (i = 0; i < num_iommu_devices; i++)
 		platform_device_unregister(omap_iommu_pdev[i]);
 }
 module_exit(omap_iommu_exit);
arch/arm/plat-omap/include/plat/omap44xx.h +3 -0
index 9cb1e9d..1b5b786 100644
@@ -47,5 +47,8 @@
 #define OMAP44XX_MAILBOX_BASE		(L4_44XX_BASE + 0xF4000)
 #define OMAP44XX_HSUSB_OTG_BASE		(L4_44XX_BASE + 0xAB000)
 
+#define OMAP4_MMU1_BASE			0x55082000
+#define OMAP4_MMU2_BASE			0x4A066000
+
 #endif /* __ASM_ARCH_OMAP44XX_H */
 
Signature · 1 line
1.7.0
#3 lore raw

PATCH v4 3/4 OMAP:iommu - missing check for TLB valid entry

In reply to Hari Kanigeri

Added the missing TLB valid entry setting for cam register

---
 arch/arm/mach-omap2/iommu2.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
arch/arm/mach-omap2/iommu2.c +1 -1
index 6f4b7cc..f01f985 100644
@@ -183,7 +183,7 @@ static struct cr_regs *omap2_alloc_cr(struct iommu *obj, struct iotlb_entry *e)
 	if (!cr)
 		return ERR_PTR(-ENOMEM);
 
-	cr->cam = (e->da & MMU_CAM_VATAG_MASK) | e->prsvd | e->pgsz;
+	cr->cam = (e->da & MMU_CAM_VATAG_MASK) | e->prsvd | e->pgsz | e->valid;
 	cr->ram = e->pa | e->endian | e->elsz | e->mixed;
 
 	return cr;
Signature · 1 line
1.7.0
#4 lore raw

PATCH v4 4/4 OMAP:iommu- add TLB preservation support

In reply to Hari Kanigeri

This patch adds TLB preservation support to IOMMU module

---
 arch/arm/mach-omap2/iommu2.c |    4 ++-
 arch/arm/plat-omap/iommu.c   |   43 +++++++++++++++++++++++++----------------
 2 files changed, 29 insertions(+), 18 deletions(-)
arch/arm/mach-omap2/iommu2.c +3 -1
index f01f985..5ce76e4 100644
@@ -146,6 +146,7 @@ static u32 omap2_iommu_fault_isr(struct iommu *obj, u32 *ra)
 	printk("\n");
 
 	iommu_write_reg(obj, stat, MMU_IRQSTATUS);
+	omap2_iommu_disable(obj);
 	return stat;
 }
 
@@ -211,7 +212,8 @@ static ssize_t omap2_dump_cr(struct iommu *obj, struct cr_regs *cr, char *buf)
 	char *p = buf;
 
 	/* FIXME: Need more detail analysis of cam/ram */
-	p += sprintf(p, "%08x %08x\n", cr->cam, cr->ram);
+	p += sprintf(p, "%08x %08x %01x\n", cr->cam, cr->ram,
+					(cr->cam & MMU_CAM_P) ? 1 : 0);
 
 	return p - buf;
 }
arch/arm/plat-omap/iommu.c +26 -17

72 lines not on this page · raw message

Signature · 1 line
1.7.0