Skip to contentSkip to conversation

iommu/exynos: Add iommu driver for Exynos Platforms

PATCH Superseded Cho KyongHo 2 participants 5 messages Mar 9, 2012 – Mar 13, 2012

Subsystems (3)

v11 of 12 Superseded Latest is v12 →

lore
Share & tools
lore
#0 lore raw

PATCH v11 3/3 iommu/exynos: Add iommu driver for Exynos Platforms

This is the System MMU driver and IOMMU API implementation for Exynos SOC platforms. Exynos platforms has more than 10 System MMUs dedicated for each multimedia accelerators.

The System MMU driver is already in arc/arm/plat-s5p but it is moved to drivers/iommu due to Ohad Ben-Cohen gathered IOMMU drivers there

Any device driver in Exynos platforms that needs to control its System MMU must call platform_set_sysmmu() to inform System MMU driver who will control it.
platform_set_sysmmu() is defined in <mach/sysmmu.h>

Cc Joerg Roedel <[email protected]>
Cc Kukjin Kim <[email protected]>
---
 drivers/iommu/Kconfig        |   21 +
 drivers/iommu/Makefile       |    1 +
 drivers/iommu/exynos-iommu.c | 1081 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 1103 insertions(+), 0 deletions(-)
 create mode 100644 drivers/iommu/exynos-iommu.c
drivers/iommu/Kconfig +21 -0
index 6bea696..25d3eed 100644
@@ -142,4 +142,25 @@ config OMAP_IOMMU_DEBUG
 
          Say N unless you know you need this.
 
+config EXYNOS_IOMMU
+	bool "Exynos IOMMU Support"
+	depends on EXYNOS_DEV_SYSMMU
+	select IOMMU_API
+	help
+	  Support for the IOMMU(System MMU) of Samsung Exynos application
+	  processor family. This enables H/W multimedia accellerators to see
+	  non-linear physical memory chunks as a linear memory in their
+	  address spaces
+
+	  If unsure, say N here.
+
+config EXYNOS_IOMMU_DEBUG
+	bool "Debugging log for Exynos IOMMU"
+	depends on EXYNOS_IOMMU
+	help
+	  Select this to see the detailed log message that shows what
+	  happens in the IOMMU driver
+
+	  Say N unless you need kernel log message for IOMMU debugging
+
 endif # IOMMU_SUPPORT
drivers/iommu/Makefile +1 -0
index 0e36b49..5a8fd97 100644
@@ -8,3 +8,4 @@ obj-$(CONFIG_IRQ_REMAP) += intr_remapping.o
 obj-$(CONFIG_OMAP_IOMMU) += omap-iommu.o
 obj-$(CONFIG_OMAP_IOVMM) += omap-iovmm.o
 obj-$(CONFIG_OMAP_IOMMU_DEBUG) += omap-iommu-debug.o
+obj-$(CONFIG_EXYNOS_IOMMU) += exynos-iommu.o
drivers/iommu/exynos-iommu.c new file +1081 -0

1,081 lines not on this page · raw message

Signature · 1 line
1.7.1
#1 lore raw
Quoted 17 lines · Cho KyongHo
drivers/iommu/exynos-iommu.c new file +17 -0
+/* We does not consider super section mapping (16MB) */
+struct iommu_client {
+	struct list_head node;
+	struct device *dev;
+};
+
+struct exynos_iommu_domain {
+	struct list_head clients; /* list of iommu_client */
+	unsigned long *pgtable; /* lv1 page table, 16KB */
+	short *lv2entcnt; /* free lv2 entry counter for each section */
+	spinlock_t lock; /* lock for this structure and attached iommu_client */
+	spinlock_t pgtablelock; /* lock for modifying page table @ pgtable */
+};
+
+struct sysmmu_drvdata {
+	struct device *sysmmu;
+	char *dbgname;

drivers/iommu/exynos-iommu.c line 178

Quoted 10 lines
drivers/iommu/exynos-iommu.c new file +10 -0
+	int nsfrs;
+	void __iomem **sfrbases;
+	struct clk *clk[2];
+	int activations;
+	rwlock_t lock;
+	struct iommu_domain *domain;
+	sysmmu_fault_handler_t fault_handler;
+	unsigned long pgtable;
+	struct iommu_client client;
+};

Is there any reason why 'struct iommu_client' is a seperate data structure? Otherwise it can be merged with 'truct sysmmu_drvdata'.

Quoted 8 lines
drivers/iommu/exynos-iommu.c new file +8 -0
+static void exynos_iommu_domain_destroy(struct iommu_domain *domain)
+{
+	struct exynos_iommu_domain *priv = domain->priv;
+	struct list_head *pos, *n;
+	unsigned long flags;
+	int i;
+
+	WARN_ON(!list_empty(&priv->clients));

drivers/iommu/exynos-iommu.c line 748

Quoted 10 lines
drivers/iommu/exynos-iommu.c new file +10 -0
+
+	spin_lock_irqsave(&priv->lock, flags);
+
+	list_for_each_safe(pos, n, &priv->clients) {
+		struct iommu_client *client;
+
+		client = list_entry(pos, struct iommu_client, node);
+		exynos_sysmmu_disable(client->dev);
+		kfree(client);
+	}

Why this kfree here? Aren't all iommu_clients just a part of another data-structre?

Signature · 5 lines
AMD Operating System Research Center

Advanced Micro Devices GmbH Einsteinring 24 85609 Dornach
General Managers: Alberto Bozzo
Registration: Dornach, Landkr. Muenchen; Registerger. Muenchen, HRB Nr. 43632
#2 lore raw
Quoted 23 lines · Joerg Roedel
Quoted 22 lines · Cho KyongHo
(quoted diff) +22 -0
+/* We does not consider super section mapping (16MB) */
+struct iommu_client {
+ ? ? struct list_head node;
+ ? ? struct device *dev;
+};
+
+struct exynos_iommu_domain {
+ ? ? struct list_head clients; /* list of iommu_client */
+ ? ? unsigned long *pgtable; /* lv1 page table, 16KB */
+ ? ? short *lv2entcnt; /* free lv2 entry counter for each section */
+ ? ? spinlock_t lock; /* lock for this structure and attached iommu_client */
+ ? ? spinlock_t pgtablelock; /* lock for modifying page table @ pgtable */
+};
+
+struct sysmmu_drvdata {
+ ? ? struct device *sysmmu;
+ ? ? char *dbgname;
+ ? ? int nsfrs;
+ ? ? void __iomem **sfrbases;
+ ? ? struct clk *clk[2];
+ ? ? int activations;
+ ? ? rwlock_t lock;
Quoted 9 lines
Quoted 5 lines

+ ? ? struct iommu_domain *domain;
+ ? ? sysmmu_fault_handler_t fault_handler;
+ ? ? unsigned long pgtable;
+ ? ? struct iommu_client client;
+};

Is there any reason why 'struct iommu_client' is a seperate data structure? Otherwise it can be merged with 'truct sysmmu_drvdata'.

There is no reason to separate it.
It is not cleanly refactored since patch version 10.

Quoted 13 lines
Quoted 13 lines
(quoted diff) +13 -0
+static void exynos_iommu_domain_destroy(struct iommu_domain *domain)
+{
+ ? ? struct exynos_iommu_domain *priv = domain->priv;
+ ? ? struct list_head *pos, *n;
+ ? ? unsigned long flags;
+ ? ? int i;
+
+ ? ? WARN_ON(!list_empty(&priv->clients));
+
+ ? ? spin_lock_irqsave(&priv->lock, flags);
+
+ ? ? list_for_each_safe(pos, n, &priv->clients) {
+ ? ? ? ? ? ? struct iommu_client *client;
Quoted 8 lines
Quoted 5 lines

+
+ ? ? ? ? ? ? client = list_entry(pos, struct iommu_client, node);
+ ? ? ? ? ? ? exynos_sysmmu_disable(client->dev);
+ ? ? ? ? ? ? kfree(client);
+ ? ? }

Why this kfree here? Aren't all iommu_clients just a part of another data-structre?

It is absolutely my fault. It must be removed.
I have forgot to care about updating iommu_domain_destroy() when modifying exynos_iommu_attach/detach_device().

Thank you.

The problems will be soon fixed and I will post next patch tomorrow.

Cho KyongHo/

#3 lore raw
Quoted 8 lines · KyongHo Cho
Quoted 8 lines
Quoted 8 lines

+struct sysmmu_drvdata {
+ ? ? struct device *sysmmu;
+ ? ? char *dbgname;
+ ? ? int nsfrs;
+ ? ? void __iomem **sfrbases;
+ ? ? struct clk *clk[2];
+ ? ? int activations;
+ ? ? rwlock_t lock;

Quoted 8 lines
Quoted 8 lines
Quoted 5 lines

+ ? ? struct iommu_domain *domain;
+ ? ? sysmmu_fault_handler_t fault_handler;
+ ? ? unsigned long pgtable;
+ ? ? struct iommu_client client;
+};

Is there any reason why 'struct iommu_client' is a seperate data structure? Otherwise it can be merged with 'truct sysmmu_drvdata'.

Of course this doesn't need to be changed immediatly. I just asked if there was a specific reason for this seperation.

Quoted 1 line

The problems will be soon fixed and I will post next patch tomorrow.

Fine. Please also get the Acked-bys from the Exynos maintainer on patches 1 and 2 at least. I'll merge it then.

Joerg

Signature · 5 lines
AMD Operating System Research Center

Advanced Micro Devices GmbH Einsteinring 24 85609 Dornach
General Managers: Alberto Bozzo
Registration: Dornach, Landkr. Muenchen; Registerger. Muenchen, HRB Nr. 43632
#4 lore raw
Quoted 18 lines · Joerg Roedel
Quoted 8 lines · KyongHo Cho
Quoted 8 lines
Quoted 8 lines

+struct sysmmu_drvdata {
+ ? ? struct device *sysmmu;
+ ? ? char *dbgname;
+ ? ? int nsfrs;
+ ? ? void __iomem **sfrbases;
+ ? ? struct clk *clk[2];
+ ? ? int activations;
+ ? ? rwlock_t lock;

Quoted 8 lines
Quoted 8 lines
Quoted 5 lines

+ ? ? struct iommu_domain *domain;
+ ? ? sysmmu_fault_handler_t fault_handler;
+ ? ? unsigned long pgtable;
+ ? ? struct iommu_client client;
+};

Is there any reason why 'struct iommu_client' is a seperate data structure? Otherwise it can be merged with 'truct sysmmu_drvdata'.

Quoted 8 lines

Of course this doesn't need to be changed immediatly. I just asked if there was a specific reason for this seperation.

Quoted 1 line

The problems will be soon fixed and I will post next patch tomorrow.

Fine. Please also get the Acked-bys from the Exynos maintainer on patches 1 and 2 at least. I'll merge it then.

Thank you.
AFAIK, Exynos maintainer is somewhat busy for his own job. I will ask him to ack my patch soon.

Best regards,

Cho KyongHo.