Skip to contentSkip to conversation

omap: iommu migration, relocation and cleanups

PATCH New Ohad Ben-Cohen 6 participants 31 messages Aug 17, 2011 – Aug 24, 2011

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

cover omap: iommu migration, relocation and cleanups

1. Migrate OMAP's iommu driver to the generic IOMMU API, and move it to the dedicated iommu folder.

2. Fix omap3isp appropriately so it doesn't break.

3. Adapt OMAP's iovmm appropriately as well, because omap3isp still relies on it. The plan is eventually to remove iovmm and replace it with the upcoming IOMMU-based generic DMA-API. Move iovmm to the iommu folder too; it belongs there more than it belongs in the OMAP folders.

4. Start cleaning up OMAP's iommu components towards the end goal, where
1) omap-iommu no longer exports public API (and instead provides its entire functionality via the generic IOMMU API).
2) omap-iovmm is removed.

Changes:
1. Migrate iommu, iovmm and omap3isp in a single patch for bisectibility sake.
2. Apply Laurent Pinchart's comments (thanks Laurent!)
3. Rebase to 3.1-rc2

Ohad Ben-Cohen (7):
omap: iommu: migrate to the generic IOMMU API
omap: iommu/iovmm: move to dedicated iommu folder
omap: iommu: stop exporting local functions
omap: iommu: PREFETCH_IOTLB cleanup
omap: iovmm: remove unused functionality
omap: iommu: remove unused exported API
omap: iommu: omapify 'struct iommu' and exposed API

 arch/arm/mach-omap2/iommu2.c                       |   31 +-
 arch/arm/plat-omap/Kconfig                         |   12 -
 arch/arm/plat-omap/Makefile                        |    2 -
 arch/arm/plat-omap/include/plat/iommu.h            |   75 ++--
 arch/arm/plat-omap/include/plat/iommu2.h           |    4 +-
 arch/arm/plat-omap/{ => include/plat}/iopgtable.h  |   20 +-
 arch/arm/plat-omap/include/plat/iovmm.h            |   30 +-
 drivers/iommu/Kconfig                              |   18 +
 drivers/iommu/Makefile                             |    3 +
 .../iommu/omap-iommu-debug.c                       |   36 +-
 .../iommu.c => drivers/iommu/omap-iommu.c          |  495 +++++++++++++-------
 .../iovmm.c => drivers/iommu/omap-iovmm.c          |  304 ++++---------
 drivers/media/video/Kconfig                        |    2 +-
 drivers/media/video/omap3isp/isp.c                 |   45 ++-
 drivers/media/video/omap3isp/isp.h                 |    5 +-
 drivers/media/video/omap3isp/ispccdc.c             |   25 +-
 drivers/media/video/omap3isp/ispstat.c             |   11 +-
 drivers/media/video/omap3isp/ispvideo.c            |    4 +-
 18 files changed, 600 insertions(+), 522 deletions(-)
 rename arch/arm/plat-omap/{ => include/plat}/iopgtable.h (82%)
 rename arch/arm/plat-omap/iommu-debug.c => drivers/iommu/omap-iommu-debug.c (91%)
 rename arch/arm/plat-omap/iommu.c => drivers/iommu/omap-iommu.c (62%)
 rename arch/arm/plat-omap/iovmm.c => drivers/iommu/omap-iovmm.c (68%)
Signature · 1 line
1.7.4.1
#1 lore raw

PATCH 1/7 omap: iommu: migrate to the generic IOMMU API

Migrate OMAP's iommu driver to the generic IOMMU API, so users can stay generic, and any generic IOMMU functionality can be developed once in the generic framework.

Migrate omap's iovmm (virtual memory manager) to the generic IOMMU API, and adapt omap3isp as needed, so the latter won't break.

The plan is to eventually remove iovmm completely by replacing it with the (upcoming) IOMMU-based DMA-API.

Tested on OMAP3 (with omap3isp) and OMAP4 (with rpmsg/remoteproc).

---
 arch/arm/plat-omap/Kconfig              |    4 +-
 arch/arm/plat-omap/include/plat/iommu.h |    3 +-
 arch/arm/plat-omap/include/plat/iovmm.h |   27 ++--
 arch/arm/plat-omap/iommu.c              |  295 +++++++++++++++++++++++++++----
 arch/arm/plat-omap/iopgtable.h          |   18 ++
 arch/arm/plat-omap/iovmm.c              |  115 +++++++-----
 drivers/media/video/omap3isp/isp.c      |   41 ++++-
 drivers/media/video/omap3isp/isp.h      |    3 +
 drivers/media/video/omap3isp/ispccdc.c  |   16 +-
 drivers/media/video/omap3isp/ispstat.c  |    6 +-
 drivers/media/video/omap3isp/ispvideo.c |    4 +-
 11 files changed, 414 insertions(+), 118 deletions(-)
arch/arm/plat-omap/Kconfig +3 -1
index bb8f4a6..e1e954d 100644
@@ -132,8 +132,10 @@ config OMAP_MBOX_KFIFO_SIZE
 	  This can also be changed at runtime (via the mbox_kfifo_size
 	  module parameter).
 
+#can't be tristate; iommu api doesn't support un-registration
 config OMAP_IOMMU
-	tristate
+	bool
+	select IOMMU_API
 
 config OMAP_IOMMU_DEBUG
        tristate "Export OMAP IOMMU internals in DebugFS"
arch/arm/plat-omap/include/plat/iommu.h +1 -2
index 174f1b9..db1c492 100644
@@ -167,8 +167,6 @@ extern void iopgtable_lookup_entry(struct iommu *obj, u32 da, u32 **ppgd,
 extern size_t iopgtable_clear_entry(struct iommu *obj, u32 iova);
 
 extern int iommu_set_da_range(struct iommu *obj, u32 start, u32 end);
-extern struct iommu *iommu_get(const char *name);
-extern void iommu_put(struct iommu *obj);
 extern int iommu_set_isr(const char *name,
 			 int (*isr)(struct iommu *obj, u32 da, u32 iommu_errs,
 				    void *priv),
@@ -185,5 +183,6 @@ extern int foreach_iommu_device(void *data,
 
 extern ssize_t iommu_dump_ctx(struct iommu *obj, char *buf, ssize_t len);
 extern size_t dump_tlb_entries(struct iommu *obj, char *buf, ssize_t len);
+struct device *omap_find_iommu_device(const char *name);
 
 #endif /* __MACH_IOMMU_H */
arch/arm/plat-omap/include/plat/iovmm.h +16 -11
index e992b96..e2f0b38 100644
@@ -13,6 +13,8 @@
 #ifndef __IOMMU_MMAP_H
 #define __IOMMU_MMAP_H
 
+#include <linux/iommu.h>
+
 struct iovm_struct {
 	struct iommu		*iommu;	/* iommu object which this belongs to */
 	u32			da_start; /* area definition */
@@ -71,18 +73,21 @@ struct iovm_struct {
 
 
 extern struct iovm_struct *find_iovm_area(struct iommu *obj, u32 da);
-extern u32 iommu_vmap(struct iommu *obj, u32 da,
+extern u32 iommu_vmap(struct iommu_domain *domain, struct iommu *obj, u32 da,
 			const struct sg_table *sgt, u32 flags);
-extern struct sg_table *iommu_vunmap(struct iommu *obj, u32 da);
-extern u32 iommu_vmalloc(struct iommu *obj, u32 da, size_t bytes,
-			   u32 flags);
-extern void iommu_vfree(struct iommu *obj, const u32 da);
-extern u32 iommu_kmap(struct iommu *obj, u32 da, u32 pa, size_t bytes,
-			u32 flags);
-extern void iommu_kunmap(struct iommu *obj, u32 da);
-extern u32 iommu_kmalloc(struct iommu *obj, u32 da, size_t bytes,
-			   u32 flags);
-extern void iommu_kfree(struct iommu *obj, u32 da);
+extern struct sg_table *iommu_vunmap(struct iommu_domain *domain,
+				struct iommu *obj, u32 da);
+extern u32 iommu_vmalloc(struct iommu_domain *domain, struct iommu *obj,
+				u32 da, size_t bytes, u32 flags);
+extern void iommu_vfree(struct iommu_domain *domain, struct iommu *obj,
+				const u32 da);
+extern u32 iommu_kmap(struct iommu_domain *domain, struct iommu *obj, u32 da,
+				u32 pa, size_t bytes, u32 flags);
+extern void iommu_kunmap(struct iommu_domain *domain, struct iommu *obj,
+				u32 da);
+extern u32 iommu_kmalloc(struct iommu_domain *domain, struct iommu *obj,
+				u32 da, size_t bytes, u32 flags);
+extern void iommu_kfree(struct iommu_domain *domain, struct iommu *obj, u32 da);
 
 extern void *da_to_va(struct iommu *obj, u32 da);
 
arch/arm/plat-omap/iommu.c +259 -36

374 lines not on this page · raw message

arch/arm/plat-omap/iopgtable.h +18 -0
index c3e93bb..33c7aa9 100644
@@ -56,6 +56,19 @@
 
 #define IOPAGE_MASK		IOPTE_MASK
 
+/**
+ * omap_iommu_translate() - va to pa translation
+ * @d:		omap iommu descriptor
+ * @va:		virtual address
+ * @mask:	omap iommu descriptor mask
+ *
+ * va to pa translation
+ */
+static inline phys_addr_t omap_iommu_translate(u32 d, u32 va, u32 mask)
+{
+	return (d & mask) | (va & (~mask));
+}
+
 /*
  * some descriptor attributes.
  */
@@ -64,10 +77,15 @@
 #define IOPGD_SUPER		(1 << 18 | 2 << 0)
 
 #define iopgd_is_table(x)	(((x) & 3) == IOPGD_TABLE)
+#define iopgd_is_section(x)	(((x) & (1 << 18 | 3)) == IOPGD_SECTION)
+#define iopgd_is_super(x)	(((x) & (1 << 18 | 3)) == IOPGD_SUPER)
 
 #define IOPTE_SMALL		(2 << 0)
 #define IOPTE_LARGE		(1 << 0)
 
+#define iopte_is_small(x)	(((x) & 2) == IOPTE_SMALL)
+#define iopte_is_large(x)	(((x) & 3) == IOPTE_LARGE)
+
 /* to find an entry in a page-table-directory */
 #define iopgd_index(da)		(((da) >> IOPGD_SHIFT) & (PTRS_PER_IOPGD - 1))
 #define iopgd_offset(obj, da)	((obj)->iopgd + iopgd_index(da))
arch/arm/plat-omap/iovmm.c +67 -48

303 lines not on this page · raw message

drivers/media/video/omap3isp/isp.c +34 -7

80 lines not on this page · raw message

drivers/media/video/omap3isp/isp.h +3 -0
index 529e582..c9ec7a2 100644
@@ -32,6 +32,7 @@
 #include <linux/io.h>
 #include <linux/platform_device.h>
 #include <linux/wait.h>
+#include <linux/iommu.h>
 #include <plat/iommu.h>
 #include <plat/iovmm.h>
 
@@ -295,6 +296,8 @@ struct isp_device {
 	unsigned int subclk_resources;
 
 	struct iommu *iommu;
+	struct iommu_domain *domain;
+	struct device *iommu_dev;
 
 	struct isp_platform_callback platform_cb;
 };
drivers/media/video/omap3isp/ispccdc.c +8 -8
index 9d3459d..de25474 100644
@@ -365,7 +365,7 @@ static void ccdc_lsc_free_request(struct isp_ccdc_device *ccdc,
 		dma_unmap_sg(isp->dev, req->iovm->sgt->sgl,
 			     req->iovm->sgt->nents, DMA_TO_DEVICE);
 	if (req->table)
-		iommu_vfree(isp->iommu, req->table);
+		iommu_vfree(isp->domain, isp->iommu, req->table);
 	kfree(req);
 }
 
@@ -437,8 +437,8 @@ static int ccdc_lsc_config(struct isp_ccdc_device *ccdc,
 
 		req->enable = 1;
 
-		req->table = iommu_vmalloc(isp->iommu, 0, req->config.size,
-					   IOMMU_FLAG);
+		req->table = iommu_vmalloc(isp->domain, isp->iommu, 0,
+					req->config.size, IOMMU_FLAG);
 		if (IS_ERR_VALUE(req->table)) {
 			req->table = 0;
 			ret = -ENOMEM;
@@ -733,15 +733,15 @@ static int ccdc_config(struct isp_ccdc_device *ccdc,
 			 * already done by iommu_vmalloc().
 			 */
 			size = ccdc->fpc.fpnum * 4;
-			table_new = iommu_vmalloc(isp->iommu, 0, size,
-						  IOMMU_FLAG);
+			table_new = iommu_vmalloc(isp->domain, isp->iommu, 0,
+							size, IOMMU_FLAG);
 			if (IS_ERR_VALUE(table_new))
 				return -ENOMEM;
 
 			if (copy_from_user(da_to_va(isp->iommu, table_new),
 					   (__force void __user *)
 					   ccdc->fpc.fpcaddr, size)) {
-				iommu_vfree(isp->iommu, table_new);
+				iommu_vfree(isp->domain, isp->iommu, table_new);
 				return -EFAULT;
 			}
 
@@ -751,7 +751,7 @@ static int ccdc_config(struct isp_ccdc_device *ccdc,
 
 		ccdc_configure_fpc(ccdc);
 		if (table_old != 0)
-			iommu_vfree(isp->iommu, table_old);
+			iommu_vfree(isp->domain, isp->iommu, table_old);
 	}
 
 	return ccdc_lsc_config(ccdc, ccdc_struct);
@@ -2286,5 +2286,5 @@ void omap3isp_ccdc_cleanup(struct isp_device *isp)
 	ccdc_lsc_free_queue(ccdc, &ccdc->lsc.free_queue);
 
 	if (ccdc->fpc.fpcaddr != 0)
-		iommu_vfree(isp->iommu, ccdc->fpc.fpcaddr);
+		iommu_vfree(isp->domain, isp->iommu, ccdc->fpc.fpcaddr);
 }
drivers/media/video/omap3isp/ispstat.c +3 -3
index 8080659..98af736 100644
@@ -366,7 +366,7 @@ static void isp_stat_bufs_free(struct ispstat *stat)
 				dma_unmap_sg(isp->dev, buf->iovm->sgt->sgl,
 					     buf->iovm->sgt->nents,
 					     DMA_FROM_DEVICE);
-			iommu_vfree(isp->iommu, buf->iommu_addr);
+			iommu_vfree(isp->domain, isp->iommu, buf->iommu_addr);
 		} else {
 			if (!buf->virt_addr)
 				continue;
@@ -399,8 +399,8 @@ static int isp_stat_bufs_alloc_iommu(struct ispstat *stat, unsigned int size)
 		struct iovm_struct *iovm;
 
 		WARN_ON(buf->dma_addr);
-		buf->iommu_addr = iommu_vmalloc(isp->iommu, 0, size,
-						IOMMU_FLAG);
+		buf->iommu_addr = iommu_vmalloc(isp->domain, isp->iommu, 0,
+							size, IOMMU_FLAG);
 		if (IS_ERR((void *)buf->iommu_addr)) {
 			dev_err(stat->isp->dev,
 				 "%s: Can't acquire memory for "
drivers/media/video/omap3isp/ispvideo.c +2 -2
index fd965ad..023b502 100644
@@ -446,7 +446,7 @@ ispmmu_vmap(struct isp_device *isp, const struct scatterlist *sglist, int sglen)
 	sgt->nents = sglen;
 	sgt->orig_nents = sglen;
 
-	da = iommu_vmap(isp->iommu, 0, sgt, IOMMU_FLAG);
+	da = iommu_vmap(isp->domain, isp->iommu, 0, sgt, IOMMU_FLAG);
 	if (IS_ERR_VALUE(da))
 		kfree(sgt);
 
@@ -462,7 +462,7 @@ static void ispmmu_vunmap(struct isp_device *isp, dma_addr_t da)
 {
 	struct sg_table *sgt;
 
-	sgt = iommu_vunmap(isp->iommu, (u32)da);
+	sgt = iommu_vunmap(isp->domain, isp->iommu, (u32)da);
 	kfree(sgt);
 }
 
Signature · 1 line
1.7.4.1
#2 lore raw

PATCH 1/7 omap: iommu: migrate to the generic IOMMU API

Hi Ohad,

Thanks for the patch.

Just one small comment in case you resubmit the whole series for another reason.

Quoted 13 lines · On Thursday 18 August 2011 01:10:02 Ohad Ben-Cohen wrote:

Migrate OMAP's iommu driver to the generic IOMMU API, so users can stay generic, and any generic IOMMU functionality can be developed once in the generic framework.

Migrate omap's iovmm (virtual memory manager) to the generic IOMMU API, and adapt omap3isp as needed, so the latter won't break.

The plan is to eventually remove iovmm completely by replacing it with the (upcoming) IOMMU-based DMA-API.

Tested on OMAP3 (with omap3isp) and OMAP4 (with rpmsg/remoteproc).

[snip]

Quoted 22 lines
arch/arm/plat-omap/iommu.c +22 -0
+static void omap_iommu_detach_dev(struct iommu_domain *domain,
+				 struct device *dev)
+{
+	struct omap_iommu_domain *omap_domain = domain->priv;
+	struct iommu *oiommu = to_iommu(dev);
+
+	mutex_lock(&omap_domain->lock);
+
+	/* only a single device is supported per domain for now */
+	if (omap_domain->iommu_dev != oiommu) {
+		dev_err(dev, "invalid iommu device\n");
+		goto out;
+	}
+
+	iopgtable_clear_entry_all(oiommu);
+
+	omap_iommu_detach(oiommu);
+
+	omap_domain->iommu_dev = NULL;
+
+out:
+	mutex_unlock(&omap_domain->lock);

arch/arm/plat-omap/iommu.c static void iopte_cachep_ctor(void *iopte) · line 1210

Quoted 10 lines
arch/arm/plat-omap/iommu.c +10 -0
+}
+
+static int omap_iommu_domain_init(struct iommu_domain *domain)
+{
+	struct omap_iommu_domain *omap_domain;
+
+	omap_domain = kzalloc(sizeof(*omap_domain), GFP_KERNEL);
+	if (!omap_domain) {
+		pr_err("kzalloc failed\n");
+		goto out;

You can directly return -ENOMEM here, and remove the "out:" label.

Quoted 26 lines
arch/arm/plat-omap/iommu.c +26 -0
+	}
+
+	omap_domain->pgtable = kzalloc(IOPGD_TABLE_SIZE, GFP_KERNEL);
+	if (!omap_domain->pgtable) {
+		pr_err("kzalloc failed\n");
+		goto fail_nomem;
+	}
+
+	/*
+	 * should never fail, but please keep this around to ensure
+	 * we keep the hardware happy
+	 */
+	BUG_ON(!IS_ALIGNED((long)omap_domain->pgtable, IOPGD_TABLE_SIZE));
+
+	clean_dcache_area(omap_domain->pgtable, IOPGD_TABLE_SIZE);
+	mutex_init(&omap_domain->lock);
+
+	domain->priv = omap_domain;
+
+	return 0;
+
+fail_nomem:
+	kfree(omap_domain);
+out:
+	return -ENOMEM;
+}
Signature · 3 lines
Regards,

Laurent Pinchart
#3 lore raw

PATCH 1/7 omap: iommu: migrate to the generic IOMMU API

Hi Laurent,

Quoted 2 lines · Laurent Pinchart

Just one small comment in case you resubmit the whole series for another reason.

..

Quoted 1 line

You can directly return -ENOMEM here, and remove the "out:" label.

Sure thing,

Thanks,
Ohad.

#4 lore raw

PATCH 1/7 omap: iommu: migrate to the generic IOMMU API

In reply to Laurent Pinchart
Quoted 10 lines · Laurent Pinchart

arch/arm/plat-omap/iommu.c static void iopte_cachep_ctor(void *iopte) · line 1210

Quoted 8 lines
arch/arm/plat-omap/iommu.c +8 -0
+static int omap_iommu_domain_init(struct iommu_domain *domain)
+{
+     struct omap_iommu_domain *omap_domain;
+
+     omap_domain = kzalloc(sizeof(*omap_domain), GFP_KERNEL);
+     if (!omap_domain) {
+             pr_err("kzalloc failed\n");
+             goto out;

You can directly return -ENOMEM here, and remove the "out:" label.

Risking to get into bike-shedding here, I would comment that the current code is actually better. I would not mix the two methods of error handling in one function. If you use goto labels, better use them consistenly and have only one 'return' statement.

Arnd

#5 lore raw

PATCH 1/7 omap: iommu: migrate to the generic IOMMU API

In reply to Ohad Ben-Cohen
Quoted 11 lines · Ohad Ben-Cohen
arch/arm/plat-omap/iommu.c +5 -3
+/**
+ * omap_iommu_attach() - attach iommu device to an iommu domain
+ * @dev:       target omap iommu device
+ * @iopgd:     page table
  **/
-struct iommu *iommu_get(const char *name)
+static struct iommu *omap_iommu_attach(struct device *dev, u32 *iopgd)
 {
        int err = -ENOMEM;
-       struct device *dev;
-       struct iommu *obj;

arch/arm/plat-omap/iommu.c int iommu_set_da_range(struct iommu *obj, u32 start, u32 end) · line 900

Quoted 10 lines
arch/arm/plat-omap/iommu.c +1 -7
-
-       dev = driver_find_device(&omap_iommu_driver.driver, NULL, (void *)name,
-                                device_match_by_alias);
-       if (!dev)
-               return ERR_PTR(-ENODEV);
-
-       obj = to_iommu(dev);
+       struct iommu *obj = to_iommu(dev);
 
        mutex_lock(&obj->iommu_lock);

I don't think using a mutex here is a good idea. This prevents this function to be called from atomic context. The iommu_map and _unmap functions need to allowed in atomic-context and I don't want different context constraints within the iommu-api. Can this be easily converted to a spin_lock?

Joerg

Signature · 5 lines
AMD Operating System Research Center

Advanced Micro Devices GmbH Einsteinring 24 85609 Dornach
General Managers: Alberto Bozzo, Andrew Bowd
Registration: Dornach, Landkr. Muenchen; Registerger. Muenchen, HRB Nr. 43632
#6 lore raw

PATCH 1/7 omap: iommu: migrate to the generic IOMMU API

Quoted 1 line · Joerg

Can this be easily converted to a spin_lock?

Sure, thanks for reviewing.

#7 lore raw

PATCH 1/7 omap: iommu: migrate to the generic IOMMU API

Quoted 4 lines · Ohad Ben-Cohen
Quoted 1 line · Joerg

Can this be easily converted to a spin_lock?

Sure, thanks for reviewing.

Taking a second look, I don't think it's necessary - the mutex isn't used to protect the page table. The page table is protected by a spin lock, so map/unmap operations can be called from an atomic context.

The mutex is only part of the attach/deattach operations, which are already used today in process context, so I guess it's safe.

#8 lore raw

PATCH 1/7 omap: iommu: migrate to the generic IOMMU API

Quoted 4 lines · Ohad Ben-Cohen
Quoted 3 lines · Ohad Ben-Cohen
Quoted 1 line · Joerg

Can this be easily converted to a spin_lock?

Quoted 8 lines
Quoted 1 line

Sure, thanks for reviewing.

Taking a second look, I don't think it's necessary - the mutex isn't used to protect the page table. The page table is protected by a spin lock, so map/unmap operations can be called from an atomic context.

The mutex is only part of the attach/deattach operations, which are already used today in process context, so I guess it's safe.

Yes, it should be safe in your context. But the iommu-api is generic and I would prefer that all functions it provides can be called from any context.
Or is the time required for attaching/detaching too long so that it makes sense to put secondary threads to sleep?

Joerg

Signature · 5 lines
AMD Operating System Research Center

Advanced Micro Devices GmbH Einsteinring 24 85609 Dornach
General Managers: Alberto Bozzo, Andrew Bowd
Registration: Dornach, Landkr. Muenchen; Registerger. Muenchen, HRB Nr. 43632
#9 lore raw

PATCH 1/7 omap: iommu: migrate to the generic IOMMU API

Quoted 3 lines · Joerg

Yes, it should be safe in your context. But the iommu-api is generic and I would prefer that all functions it provides can be called from any context.

Not a problem.

I thought you only cared about map/unmap, but if you prefer attach/deattach to be atomic too, I'll migrate the driver to use a spin lock.

Quoted 2 lines

Or is the time required for attaching/detaching too long so that it makes sense to put secondary threads to sleep?

It doesn't look like it. I think a mutex was originally chosen at that point because those functions were used in a process context.

Thanks,
Ohad.

#10 lore raw

PATCH 2/7 omap: iommu/iovmm: move to dedicated iommu folder

In reply to Ohad Ben-Cohen

Move OMAP's iommu drivers to the dedicated iommu drivers folder.

While OMAP's iovmm (virtual memory manager) driver does not strictly belong to the iommu drivers folder, move it there as well, because it's by no means OMAP-specific (in concept. technically it is still coupled with OMAP's iommu).

Eventually, iovmm will be completely replaced with the generic, iommu-based, dma-mapping API.

---
 arch/arm/plat-omap/Kconfig                         |   14 --------------
 arch/arm/plat-omap/Makefile                        |    2 --
 arch/arm/plat-omap/{ => include/plat}/iopgtable.h  |    0
 drivers/iommu/Kconfig                              |   18 ++++++++++++++++++
 drivers/iommu/Makefile                             |    3 +++
 .../iommu/omap-iommu-debug.c                       |    2 +-
 .../iommu.c => drivers/iommu/omap-iommu.c          |    2 +-
 .../iovmm.c => drivers/iommu/omap-iovmm.c          |    2 +-
 drivers/media/video/Kconfig                        |    2 +-
 9 files changed, 25 insertions(+), 20 deletions(-)
 rename arch/arm/plat-omap/{ => include/plat}/iopgtable.h (100%)
 rename arch/arm/plat-omap/iommu-debug.c => drivers/iommu/omap-iommu-debug.c (99%)
 rename arch/arm/plat-omap/iommu.c => drivers/iommu/omap-iommu.c (99%)
 rename arch/arm/plat-omap/iovmm.c => drivers/iommu/omap-iovmm.c (99%)
arch/arm/plat-omap/Kconfig +0 -14
index e1e954d..fa62037 100644
@@ -132,20 +132,6 @@ config OMAP_MBOX_KFIFO_SIZE
 	  This can also be changed at runtime (via the mbox_kfifo_size
 	  module parameter).
 
-#can't be tristate; iommu api doesn't support un-registration
-config OMAP_IOMMU
-	bool
-	select IOMMU_API
-
-config OMAP_IOMMU_DEBUG
-       tristate "Export OMAP IOMMU internals in DebugFS"
-       depends on OMAP_IOMMU && DEBUG_FS
-       help
-         Select this to see extensive information about
-         the internal state of OMAP IOMMU in debugfs.
-
-         Say N unless you know you need this.
-
 config OMAP_IOMMU_IVA2
 	bool
 
arch/arm/plat-omap/Makefile +0 -2
index f0233e6..9852622 100644
@@ -18,8 +18,6 @@ obj-$(CONFIG_ARCH_OMAP3) += omap_device.o
 obj-$(CONFIG_ARCH_OMAP4) += omap_device.o
 
 obj-$(CONFIG_OMAP_MCBSP) += mcbsp.o
-obj-$(CONFIG_OMAP_IOMMU) += iommu.o iovmm.o
-obj-$(CONFIG_OMAP_IOMMU_DEBUG) += iommu-debug.o
 
 obj-$(CONFIG_CPU_FREQ) += cpu-omap.o
 obj-$(CONFIG_OMAP_DM_TIMER) += dmtimer.o
arch/arm/plat-omap/include/plat/iopgtable.h renamed from arch/arm/plat-omap/iopgtable.h +0 -0
similarity index 100%
rename from arch/arm/plat-omap/iopgtable.h
rename to arch/arm/plat-omap/include/plat/iopgtable.h
drivers/iommu/Kconfig +18 -0
index b57b3fa..432463b 100644
@@ -107,4 +107,22 @@ config INTR_REMAP
 	  To use x2apic mode in the CPU's which support x2APIC enhancements or
 	  to support platforms with CPU's having > 8 bit APIC ID, say Y.
 
+# OMAP IOMMU support
+config OMAP_IOMMU
+	bool "OMAP IOMMU Support"
+	select IOMMU_API
+
+config OMAP_IOVMM
+	tristate
+	select OMAP_IOMMU
+
+config OMAP_IOMMU_DEBUG
+       tristate "Export OMAP IOMMU/IOVMM internals in DebugFS"
+       depends on OMAP_IOVMM && DEBUG_FS
+       help
+         Select this to see extensive information about
+         the internal state of OMAP IOMMU/IOVMM in debugfs.
+
+         Say N unless you know you need this.
+
 endif # IOMMU_SUPPORT
drivers/iommu/Makefile +3 -0
index 4d4d77d..f798cdd 100644
@@ -3,3 +3,6 @@ obj-$(CONFIG_MSM_IOMMU) += msm_iommu.o msm_iommu_dev.o
 obj-$(CONFIG_AMD_IOMMU) += amd_iommu.o amd_iommu_init.o
 obj-$(CONFIG_DMAR) += dmar.o iova.o intel-iommu.o
 obj-$(CONFIG_INTR_REMAP) += dmar.o 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
drivers/iommu/omap-iommu-debug.c renamed from arch/arm/plat-omap/iommu-debug.c +1 -1
similarity index 99%
rename from arch/arm/plat-omap/iommu-debug.c
rename to drivers/iommu/omap-iommu-debug.c
index f07cf2f..0f8c8dd 100644
@@ -21,7 +21,7 @@
 #include <plat/iommu.h>
 #include <plat/iovmm.h>
 
-#include "iopgtable.h"
+#include <plat/iopgtable.h>
 
 #define MAXCOLUMN 100 /* for short messages */
 
drivers/iommu/omap-iommu.c renamed from arch/arm/plat-omap/iommu.c +1 -1
similarity index 99%
rename from arch/arm/plat-omap/iommu.c
rename to drivers/iommu/omap-iommu.c
index 70a271c..ffd1b27 100644
@@ -25,7 +25,7 @@
 
 #include <plat/iommu.h>
 
-#include "iopgtable.h"
+#include <plat/iopgtable.h>
 
 #define for_each_iotlb_cr(obj, n, __i, cr)				\
 	for (__i = 0;							\
drivers/iommu/omap-iovmm.c renamed from arch/arm/plat-omap/iovmm.c +1 -1
similarity index 99%
rename from arch/arm/plat-omap/iovmm.c
rename to drivers/iommu/omap-iovmm.c
index aa2c478..809ca12 100644
@@ -23,7 +23,7 @@
 #include <plat/iommu.h>
 #include <plat/iovmm.h>
 
-#include "iopgtable.h"
+#include <plat/iopgtable.h>
 
 /*
  * A device driver needs to create address mappings between:
drivers/media/video/Kconfig +1 -1
index f574dc0..6a25fad 100644
@@ -763,7 +763,7 @@ source "drivers/media/video/m5mols/Kconfig"
 
 config VIDEO_OMAP3
 	tristate "OMAP 3 Camera support (EXPERIMENTAL)"
-	select OMAP_IOMMU
+	select OMAP_IOVMM
 	depends on VIDEO_V4L2 && I2C && VIDEO_V4L2_SUBDEV_API && ARCH_OMAP3 && EXPERIMENTAL
 	---help---
 	  Driver for an OMAP 3 camera controller.
Signature · 1 line
1.7.4.1
#11 lore raw

PATCH 2/7 omap: iommu/iovmm: move to dedicated iommu folder

Quoted 9 lines · Ohad Ben-Cohen
 arch/arm/plat-omap/Kconfig                         |   14 --------------
 arch/arm/plat-omap/Makefile                        |    2 --
 arch/arm/plat-omap/{ => include/plat}/iopgtable.h  |    0
 drivers/iommu/Kconfig                              |   18 ++++++++++++++++++
 drivers/iommu/Makefile                             |    3 +++
 .../iommu/omap-iommu-debug.c                       |    2 +-
 .../iommu.c => drivers/iommu/omap-iommu.c          |    2 +-
 .../iovmm.c => drivers/iommu/omap-iovmm.c          |    2 +-
 drivers/media/video/Kconfig                        |    2 +-

Do you need the header file to be globally visible?

If not, I think it would be better to move it to the iommu directory along with the files using it.

Arnd

#12 lore raw

PATCH 2/7 omap: iommu/iovmm: move to dedicated iommu folder

Quoted 11 lines · Arnd Bergmann
Quoted 9 lines · Ohad Ben-Cohen
?arch/arm/plat-omap/Kconfig ? ? ? ? ? ? ? ? ? ? ? ? | ? 14 --------------
?arch/arm/plat-omap/Makefile ? ? ? ? ? ? ? ? ? ? ? ?| ? ?2 --
?arch/arm/plat-omap/{ => include/plat}/iopgtable.h ?| ? ?0
?drivers/iommu/Kconfig ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?| ? 18 ++++++++++++++++++
?drivers/iommu/Makefile ? ? ? ? ? ? ? ? ? ? ? ? ? ? | ? ?3 +++
?.../iommu/omap-iommu-debug.c ? ? ? ? ? ? ? ? ? ? ? | ? ?2 +-
?.../iommu.c => drivers/iommu/omap-iommu.c ? ? ? ? ?| ? ?2 +-
?.../iovmm.c => drivers/iommu/omap-iovmm.c ? ? ? ? ?| ? ?2 +-
?drivers/media/video/Kconfig ? ? ? ? ? ? ? ? ? ? ? ?| ? ?2 +-
Quoted 1 line

Do you need the header file to be globally visible?

Yeah; Unfortunately omap3isp is not yet completely decoupled from omap's iommu, so it needs it.

Once the generic DMA-API will settle in, we will completely decouple omap3isp and then will be able to move this header file into drivers/iommu/, and remove omap-iovmm.c.

Thanks,
Ohad.

#13 lore raw

PATCH 3/7 omap: iommu: stop exporting local functions

In reply to Ohad Ben-Cohen

Stop exporting functions that are used only within the iommu driver itself.

Eventually OMAP's iommu driver should only expose API via the generic IOMMU framework.

---
 arch/arm/plat-omap/include/plat/iommu.h |    8 --------
 drivers/iommu/omap-iommu.c              |   19 +++++++------------
 2 files changed, 7 insertions(+), 20 deletions(-)
arch/arm/plat-omap/include/plat/iommu.h +0 -8
index db1c492..961b64f 100644
@@ -153,18 +153,10 @@ struct iommu_platform_data {
 extern u32 iommu_arch_version(void);
 
 extern void iotlb_cr_to_e(struct cr_regs *cr, struct iotlb_entry *e);
-extern u32 iotlb_cr_to_virt(struct cr_regs *cr);
-
-extern int load_iotlb_entry(struct iommu *obj, struct iotlb_entry *e);
 extern void iommu_set_twl(struct iommu *obj, bool on);
-extern void flush_iotlb_page(struct iommu *obj, u32 da);
 extern void flush_iotlb_range(struct iommu *obj, u32 start, u32 end);
-extern void flush_iotlb_all(struct iommu *obj);
 
 extern int iopgtable_store_entry(struct iommu *obj, struct iotlb_entry *e);
-extern void iopgtable_lookup_entry(struct iommu *obj, u32 da, u32 **ppgd,
-				   u32 **ppte);
-extern size_t iopgtable_clear_entry(struct iommu *obj, u32 iova);
 
 extern int iommu_set_da_range(struct iommu *obj, u32 start, u32 end);
 extern int iommu_set_isr(const char *name,
drivers/iommu/omap-iommu.c +7 -12
index ffd1b27..ed81977 100644
@@ -170,11 +170,10 @@ static inline struct cr_regs *iotlb_alloc_cr(struct iommu *obj,
 	return arch_iommu->alloc_cr(obj, e);
 }
 
-u32 iotlb_cr_to_virt(struct cr_regs *cr)
+static u32 iotlb_cr_to_virt(struct cr_regs *cr)
 {
 	return arch_iommu->cr_to_virt(cr);
 }
-EXPORT_SYMBOL_GPL(iotlb_cr_to_virt);
 
 static u32 get_iopte_attr(struct iotlb_entry *e)
 {
@@ -253,7 +252,7 @@ static struct cr_regs __iotlb_read_cr(struct iommu *obj, int n)
  * @obj:	target iommu
  * @e:		an iommu tlb entry info
  **/
-int load_iotlb_entry(struct iommu *obj, struct iotlb_entry *e)
+static int load_iotlb_entry(struct iommu *obj, struct iotlb_entry *e)
 {
 	int err = 0;
 	struct iotlb_lock l;
@@ -309,7 +308,6 @@ out:
 	clk_disable(obj->clk);
 	return err;
 }
-EXPORT_SYMBOL_GPL(load_iotlb_entry);
 
 /**
  * flush_iotlb_page - Clear an iommu tlb entry
@@ -318,7 +316,7 @@ EXPORT_SYMBOL_GPL(load_iotlb_entry);
  *
  * Clear an iommu tlb entry which includes 'da' address.
  **/
-void flush_iotlb_page(struct iommu *obj, u32 da)
+static void flush_iotlb_page(struct iommu *obj, u32 da)
 {
 	int i;
 	struct cr_regs cr;
@@ -347,7 +345,6 @@ void flush_iotlb_page(struct iommu *obj, u32 da)
 	if (i == obj->nr_tlb_entries)
 		dev_dbg(obj->dev, "%s: no page for %08x\n", __func__, da);
 }
-EXPORT_SYMBOL_GPL(flush_iotlb_page);
 
 /**
  * flush_iotlb_range - Clear an iommu tlb entries
@@ -373,7 +370,7 @@ EXPORT_SYMBOL_GPL(flush_iotlb_range);
  * flush_iotlb_all - Clear all iommu tlb entries
  * @obj:	target iommu
  **/
-void flush_iotlb_all(struct iommu *obj)
+static void flush_iotlb_all(struct iommu *obj)
 {
 	struct iotlb_lock l;
 
@@ -387,7 +384,6 @@ void flush_iotlb_all(struct iommu *obj)
 
 	clk_disable(obj->clk);
 }
-EXPORT_SYMBOL_GPL(flush_iotlb_all);
 
 /**
  * iommu_set_twl - enable/disable table walking logic
@@ -681,7 +677,8 @@ EXPORT_SYMBOL_GPL(iopgtable_store_entry);
  * @ppgd:	iommu pgd entry pointer to be returned
  * @ppte:	iommu pte entry pointer to be returned
  **/
-void iopgtable_lookup_entry(struct iommu *obj, u32 da, u32 **ppgd, u32 **ppte)
+static void
+iopgtable_lookup_entry(struct omap_iommu *obj, u32 da, u32 **ppgd, u32 **ppte)
 {
 	u32 *iopgd, *iopte = NULL;
 
@@ -695,7 +692,6 @@ out:
 	*ppgd = iopgd;
 	*ppte = iopte;
 }
-EXPORT_SYMBOL_GPL(iopgtable_lookup_entry);
 
 static size_t iopgtable_clear_entry_core(struct iommu *obj, u32 da)
 {
@@ -750,7 +746,7 @@ out:
  * @obj:	target iommu
  * @da:		iommu device virtual address
  **/
-size_t iopgtable_clear_entry(struct iommu *obj, u32 da)
+static size_t iopgtable_clear_entry(struct iommu *obj, u32 da)
 {
 	size_t bytes;
 
@@ -763,7 +759,6 @@ size_t iopgtable_clear_entry(struct iommu *obj, u32 da)
 
 	return bytes;
 }
-EXPORT_SYMBOL_GPL(iopgtable_clear_entry);
 
 static void iopgtable_clear_entry_all(struct iommu *obj)
 {
Signature · 1 line
1.7.4.1
#14 lore raw

PATCH 4/7 omap: iommu: PREFETCH_IOTLB cleanup

In reply to Ohad Ben-Cohen

Use PREFETCH_IOTLB to control the content of the called function, instead of inlining it in the code.

This improves readability of the code, and also prevents an "unused function" warning to show up when PREFETCH_IOTLB isn't set.

While we're at it, rename load_iotlb_entry to prefetch_iotlb_entry to better reflect the purpose of that function.

---
 drivers/iommu/omap-iommu.c |   18 +++++++++++++-----
 1 files changed, 13 insertions(+), 5 deletions(-)
drivers/iommu/omap-iommu.c +13 -5
index ed81977..7280e5b 100644
@@ -248,11 +248,12 @@ static struct cr_regs __iotlb_read_cr(struct iommu *obj, int n)
 }
 
 /**
- * load_iotlb_entry - Set an iommu tlb entry
+ * prefetch_iotlb_entry - Set an iommu tlb entry
  * @obj:	target iommu
  * @e:		an iommu tlb entry info
  **/
-static int load_iotlb_entry(struct iommu *obj, struct iotlb_entry *e)
+#ifdef PREFETCH_IOTLB
+static int prefetch_iotlb_entry(struct iommu *obj, struct iotlb_entry *e)
 {
 	int err = 0;
 	struct iotlb_lock l;
@@ -309,6 +310,15 @@ out:
 	return err;
 }
 
+#else /* !PREFETCH_IOTLB */
+
+static int prefetch_iotlb_entry(struct iommu *obj, struct iotlb_entry *e)
+{
+	return 0;
+}
+
+#endif /* !PREFETCH_IOTLB */
+
 /**
  * flush_iotlb_page - Clear an iommu tlb entry
  * @obj:	target iommu
@@ -662,10 +672,8 @@ int iopgtable_store_entry(struct iommu *obj, struct iotlb_entry *e)
 
 	flush_iotlb_page(obj, e->da);
 	err = iopgtable_store_entry_core(obj, e);
-#ifdef PREFETCH_IOTLB
 	if (!err)
-		load_iotlb_entry(obj, e);
-#endif
+		prefetch_iotlb_entry(obj, e);
 	return err;
 }
 EXPORT_SYMBOL_GPL(iopgtable_store_entry);
Signature · 1 line
1.7.4.1
#15 lore raw

PATCH 4/7 omap: iommu: PREFETCH_IOTLB cleanup

Hi Ohad,

From: ext Ohad Ben-Cohen <[email protected]>
Subject: [PATCH 4/7] omap: iommu: PREFETCH_IOTLB cleanup
Date: Thu, 18 Aug 2011 02:10:05 +0300

Quoted 5 lines

Use PREFETCH_IOTLB to control the content of the called function, instead of inlining it in the code.

This improves readability of the code, and also prevents an "unused function" warning to show up when PREFETCH_IOTLB isn't set.

Great, much better.

Quoted 2 lines

While we're at it, rename load_iotlb_entry to prefetch_iotlb_entry to better reflect the purpose of that function.

Considering that, originally this function is the counterpart of "flush_iotlb_page()" among load_iotlb_/flush_iotlb_*() family and OMAP1 doesn't use H/W page table but only uses TLB(only prefetch/load_tlb), what about keeping the original function "load_iotlb_entry()", and make inline function "prefetch_iotlb_entry()" has it?

Something like below?

static int inline prefetch_iotlb_entry(struct iommu *obj, struct iotlb_entry *e)

{
	return load_iotlb_entry(obj, e);
}

The above may keep a little bit more sense both for TLB only case too, also for some function name consistency?

Quoted 56 lines
---
 drivers/iommu/omap-iommu.c |   18 +++++++++++++-----
 1 files changed, 13 insertions(+), 5 deletions(-)
drivers/iommu/omap-iommu.c +13 -5
index ed81977..7280e5b 100644
@@ -248,11 +248,12 @@ static struct cr_regs __iotlb_read_cr(struct iommu *obj, int n)
 }
 
 /**
- * load_iotlb_entry - Set an iommu tlb entry
+ * prefetch_iotlb_entry - Set an iommu tlb entry
  * @obj:	target iommu
  * @e:		an iommu tlb entry info
  **/
-static int load_iotlb_entry(struct iommu *obj, struct iotlb_entry *e)
+#ifdef PREFETCH_IOTLB
+static int prefetch_iotlb_entry(struct iommu *obj, struct iotlb_entry *e)
 {
 	int err = 0;
 	struct iotlb_lock l;
@@ -309,6 +310,15 @@ out:
 	return err;
 }
 
+#else /* !PREFETCH_IOTLB */
+
+static int prefetch_iotlb_entry(struct iommu *obj, struct iotlb_entry *e)
+{
+	return 0;
+}
+
+#endif /* !PREFETCH_IOTLB */
+
 /**
  * flush_iotlb_page - Clear an iommu tlb entry
  * @obj:	target iommu
@@ -662,10 +672,8 @@ int iopgtable_store_entry(struct iommu *obj, struct iotlb_entry *e)
 
 	flush_iotlb_page(obj, e->da);
 	err = iopgtable_store_entry_core(obj, e);
-#ifdef PREFETCH_IOTLB
 	if (!err)
-		load_iotlb_entry(obj, e);
-#endif
+		prefetch_iotlb_entry(obj, e);
 	return err;
 }
 EXPORT_SYMBOL_GPL(iopgtable_store_entry);
Signature · 1 line
1.7.4.1
#16 lore raw

PATCH 4/7 omap: iommu: PREFETCH_IOTLB cleanup

Hi Hiroshi,

Quoted 9 lines · Hiroshi DOYU
Quoted 2 lines

While we're at it, rename load_iotlb_entry to prefetch_iotlb_entry to better reflect the purpose of that function.

Considering that, originally this function is the counterpart of "flush_iotlb_page()" among load_iotlb_/flush_iotlb_*() family and OMAP1 doesn't use H/W page table but only uses TLB(only prefetch/load_tlb), what about keeping the original function "load_iotlb_entry()", and make inline function "prefetch_iotlb_entry()" has it?

Sure, np (I have considered doing that, but decided to drop it for now since there's no other user of load_iotlb_entry currently. Now that you mention it too, I'll do that).

Thanks,
Ohad.

#17 lore raw

PATCH 5/7 omap: iovmm: remove unused functionality

In reply to Ohad Ben-Cohen

Remove unused functionality from OMAP's iovmm module.

The intention is to eventually completely replace iovmm with the generic DMA-API, so new code that'd need this iovmm functionality will have to extend the DMA-API instead.

---
 arch/arm/plat-omap/include/plat/iovmm.h |    8 --
 drivers/iommu/omap-iovmm.c              |  167 -------------------------------
 2 files changed, 0 insertions(+), 175 deletions(-)
arch/arm/plat-omap/include/plat/iovmm.h +0 -8
index e2f0b38..fc9aa6f 100644
@@ -81,14 +81,6 @@ extern u32 iommu_vmalloc(struct iommu_domain *domain, struct iommu *obj,
 				u32 da, size_t bytes, u32 flags);
 extern void iommu_vfree(struct iommu_domain *domain, struct iommu *obj,
 				const u32 da);
-extern u32 iommu_kmap(struct iommu_domain *domain, struct iommu *obj, u32 da,
-				u32 pa, size_t bytes, u32 flags);
-extern void iommu_kunmap(struct iommu_domain *domain, struct iommu *obj,
-				u32 da);
-extern u32 iommu_kmalloc(struct iommu_domain *domain, struct iommu *obj,
-				u32 da, size_t bytes, u32 flags);
-extern void iommu_kfree(struct iommu_domain *domain, struct iommu *obj, u32 da);
-
 extern void *da_to_va(struct iommu *obj, u32 da);
 
 #endif /* __IOMMU_MMAP_H */
drivers/iommu/omap-iovmm.c +0 -167

179 lines not on this page · raw message

Signature · 1 line
1.7.4.1
#18 lore raw

PATCH 5/7 omap: iovmm: remove unused functionality

Hi Ohad,

From: ext Ohad Ben-Cohen <[email protected]>
Subject: [PATCH 5/7] omap: iovmm: remove unused functionality
Date: Thu, 18 Aug 2011 02:10:06 +0300

Quoted 5 lines

Remove unused functionality from OMAP's iovmm module.

The intention is to eventually completely replace iovmm with the generic DMA-API, so new code that'd need this iovmm functionality will have to extend the DMA-API instead.

Maybe it's better to remove the comments explaining unnecessary functions too. Now the function comparison table doesn't make sense....

#19 lore raw

PATCH 5/7 omap: iovmm: remove unused functionality

Quoted 2 lines · Hiroshi DOYU

Maybe it's better to remove the comments explaining unnecessary functions too. Now the function comparison table doesn't make sense....

Sure, will do.

Quoted 5 lines

From: Hiroshi DOYU <[email protected]>
Date: Thu, 18 Aug 2011 13:13:53 +0300
Subject: [PATCH 1/1] omap: iommu: remove obsolete comments

Remove ones referring to non-existing functions.

I think it might be better to squash it with the original patch though
- are you ok with it ?

Thanks,
Ohad.

#20 lore raw

PATCH 5/7 omap: iovmm: remove unused functionality

From: ext Ohad Ben-Cohen <[email protected]>
Subject: Re: [PATCH 5/7] omap: iovmm: remove unused functionality
Date: Thu, 18 Aug 2011 13:23:44 +0300

Quoted 6 lines · Hiroshi DOYU
Quoted 2 lines

Maybe it's better to remove the comments explaining unnecessary functions too. Now the function comparison table doesn't make sense....

Sure, will do.

Quoted 8 lines
Quoted 5 lines

From: Hiroshi DOYU <[email protected]>
Date: Thu, 18 Aug 2011 13:13:53 +0300
Subject: [PATCH 1/1] omap: iommu: remove obsolete comments

Remove ones referring to non-existing functions.

I think it might be better to squash it with the original patch though
- are you ok with it ?

Sure.

Quoted 3 lines

Thanks,
Ohad.

#21 lore raw

PATCH 6/7 omap: iommu: remove unused exported API

In reply to Ohad Ben-Cohen

Remove unused public APIs from OMAP's iommu driver.

IOMMU functionality should be exposed only via the generic IOMMU API; this way drivers stay generic, and different IOMMU drivers don't need to duplicate similar functionalities.

The rest of the API still exposed by OMAP's iommu will be evaluated and eventually either added to the generic IOMMU API (if relevant), or completely removed.

The intention is that OMAP's iommu driver will eventually not expose any public API.

---
 arch/arm/plat-omap/include/plat/iommu.h |    3 --
 drivers/iommu/omap-iommu.c              |   59 -------------------------------
 2 files changed, 0 insertions(+), 62 deletions(-)
arch/arm/plat-omap/include/plat/iommu.h +0 -3
index 961b64f..eed5bdc 100644
@@ -153,12 +153,9 @@ struct iommu_platform_data {
 extern u32 iommu_arch_version(void);
 
 extern void iotlb_cr_to_e(struct cr_regs *cr, struct iotlb_entry *e);
-extern void iommu_set_twl(struct iommu *obj, bool on);
-extern void flush_iotlb_range(struct iommu *obj, u32 start, u32 end);
 
 extern int iopgtable_store_entry(struct iommu *obj, struct iotlb_entry *e);
 
-extern int iommu_set_da_range(struct iommu *obj, u32 start, u32 end);
 extern int iommu_set_isr(const char *name,
 			 int (*isr)(struct iommu *obj, u32 da, u32 iommu_errs,
 				    void *priv),
drivers/iommu/omap-iommu.c +0 -59

77 lines not on this page · raw message

Signature · 1 line
1.7.4.1
#22 lore raw

PATCH 6/7 omap: iommu: remove unused exported API

Hi Ohad,

Just small question inlined....

From: ext Ohad Ben-Cohen <[email protected]>
Subject: [PATCH 6/7] omap: iommu: remove unused exported API
Date: Thu, 18 Aug 2011 02:10:07 +0300

Quoted 24 lines

Remove unused public APIs from OMAP's iommu driver.

IOMMU functionality should be exposed only via the generic IOMMU API; this way drivers stay generic, and different IOMMU drivers don't need to duplicate similar functionalities.

The rest of the API still exposed by OMAP's iommu will be evaluated and eventually either added to the generic IOMMU API (if relevant), or completely removed.

The intention is that OMAP's iommu driver will eventually not expose any public API.

---
 arch/arm/plat-omap/include/plat/iommu.h |    3 --
 drivers/iommu/omap-iommu.c              |   59 -------------------------------
 2 files changed, 0 insertions(+), 62 deletions(-)
arch/arm/plat-omap/include/plat/iommu.h +0 -0
index 961b64f..eed5bdc 100644

arch/arm/plat-omap/include/plat/iommu.h struct iommu_platform_data { · line 156

Quoted 4 lines
arch/arm/plat-omap/include/plat/iommu.h +0 -1
@@ -153,12 +153,9 @@ struct iommu_platform_data {
 extern u32 iommu_arch_version(void);
 
 extern void iotlb_cr_to_e(struct cr_regs *cr, struct iotlb_entry *e);
-extern void iommu_set_twl(struct iommu *obj, bool on);

This function was introduced by "Hari Kanigeri" for some OMAP4 case, which is only using TLB, not H/W table walk.

arch/arm/plat-omap/include/plat/iommu.h struct iommu_platform_data { · line 161

Quoted 2 lines
arch/arm/plat-omap/include/plat/iommu.h +0 -2
-extern void flush_iotlb_range(struct iommu *obj, u32 start, u32 end);
-extern int iommu_set_da_range(struct iommu *obj, u32 start, u32 end);

This function was introduced by "David Cohen" to specify the available ISP virtual address range.

Both requirements were quite reasonable at that time. Not necessary anymore?

Quoted 90 lines
arch/arm/plat-omap/include/plat/iommu.h +0 -0
 extern int iommu_set_isr(const char *name,
 			 int (*isr)(struct iommu *obj, u32 da, u32 iommu_errs,
 				    void *priv),
drivers/iommu/omap-iommu.c +0 -59
index 7280e5b..d6b77c4 100644
@@ -357,26 +357,6 @@ static void flush_iotlb_page(struct iommu *obj, u32 da)
 }
 
 /**
- * flush_iotlb_range - Clear an iommu tlb entries
- * @obj:	target iommu
- * @start:	iommu device virtual address(start)
- * @end:	iommu device virtual address(end)
- *
- * Clear an iommu tlb entry which includes 'da' address.
- **/
-void flush_iotlb_range(struct iommu *obj, u32 start, u32 end)
-{
-	u32 da = start;
-
-	while (da < end) {
-		flush_iotlb_page(obj, da);
-		/* FIXME: Optimize for multiple page size */
-		da += IOPTE_SIZE;
-	}
-}
-EXPORT_SYMBOL_GPL(flush_iotlb_range);
-
-/**
  * flush_iotlb_all - Clear all iommu tlb entries
  * @obj:	target iommu
  **/
@@ -395,23 +375,6 @@ static void flush_iotlb_all(struct iommu *obj)
 	clk_disable(obj->clk);
 }
 
-/**
- * iommu_set_twl - enable/disable table walking logic
- * @obj:	target iommu
- * @on:		enable/disable
- *
- * Function used to enable/disable TWL. If one wants to work
- * exclusively with locked TLB entries and receive notifications
- * for TLB miss then call this function to disable TWL.
- */
-void iommu_set_twl(struct iommu *obj, bool on)
-{
-	clk_enable(obj->clk);
-	arch_iommu->set_twl(obj, on);
-	clk_disable(obj->clk);
-}
-EXPORT_SYMBOL_GPL(iommu_set_twl);
-
 #if defined(CONFIG_OMAP_IOMMU_DEBUG_MODULE)
 
 ssize_t iommu_dump_ctx(struct iommu *obj, char *buf, ssize_t bytes)
@@ -848,28 +811,6 @@ static int device_match_by_alias(struct device *dev, void *data)
 }
 
 /**
- * iommu_set_da_range - Set a valid device address range
- * @obj:		target iommu
- * @start		Start of valid range
- * @end			End of valid range
- **/
-int iommu_set_da_range(struct iommu *obj, u32 start, u32 end)
-{
-
-	if (!obj)
-		return -EFAULT;
-
-	if (end < start || !PAGE_ALIGN(start | end))
-		return -EINVAL;
-
-	obj->da_start = start;
-	obj->da_end = end;
-
-	return 0;
-}
-EXPORT_SYMBOL_GPL(iommu_set_da_range);
-
-/**
  * omap_find_iommu_device() - find an omap iommu device by name
  * @name:	name of the iommu device
  *
Signature · 1 line
1.7.4.1
#23 lore raw

PATCH 6/7 omap: iommu: remove unused exported API

Hi Hiroshi,

Quoted 4 lines · Hiroshi DOYU
Quoted 1 line

-extern void iommu_set_twl(struct iommu *obj, bool on);

This function was introduced by "Hari Kanigeri" for some OMAP4 case, which is only using TLB, not H/W table walk.

We discussed that internally, and concluded it's not needed anymore. I still kept the underlying plumbing mechanism, just in case it'd still be needed for some hw quirks in the future, but removed the interface (in case a future hw revision will seem to need it, it would probably make more sense to invoke the relevant mechanism from the underlying layers rather than from a higher layer).

Quoted 4 lines
Quoted 1 line

-extern int iommu_set_da_range(struct iommu *obj, u32 start, u32 end);

This function was introduced by "David Cohen" to specify the available ISP virtual address range.

Not sure if David or anyone is using this, but if someone is, it must be out-of-tree.

In that case, even if it is needed, adding a mainline user for this function at this point will most likely not be accepted anymore, and instead, one will be suggested to use (and extend as necessary) the DMA-API.

Thanks,
Ohad.

#24 lore raw

PATCH 6/7 omap: iommu: remove unused exported API

Hi Ohad,

Quoted 8 lines · Ohad Ben-Cohen

Hi Hiroshi,

Quoted 4 lines · Hiroshi DOYU
Quoted 1 line

-extern void iommu_set_twl(struct iommu *obj, bool on);

This function was introduced by "Hari Kanigeri" for some OMAP4 case, which is only using TLB, not H/W table walk.

Quoted 11 lines

We discussed that internally, and concluded it's not needed anymore. I still kept the underlying plumbing mechanism, just in case it'd still be needed for some hw quirks in the future, but removed the interface (in case a future hw revision will seem to need it, it would probably make more sense to invoke the relevant mechanism from the underlying layers rather than from a higher layer).

Quoted 4 lines
Quoted 1 line

-extern int iommu_set_da_range(struct iommu *obj, u32 start, u32 end);

This function was introduced by "David Cohen" to specify the available ISP virtual address range.

This function wasn't actually introduced by me, but I remember to refer it when I was discussing to not define address 0x0 as valid in da range by default (unless intentionally specified by client).

Quoted 3 lines

Not sure if David or anyone is using this, but if someone is, it must be out-of-tree.

I am fine to remove it.

Br,

David

Quoted 13 lines

In that case, even if it is needed, adding a mainline user for this function at this point will most likely not be accepted anymore, and instead, one will be suggested to use (and extend as necessary) the DMA-API.

Thanks,
Ohad.
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majordomo at vger.kernel.org
More majordomo info at ?http://vger.kernel.org/majordomo-info.html

#25 lore raw

PATCH 6/7 omap: iommu: remove unused exported API

Hi David,

Quoted 4 lines · David Cohen
Quoted 2 lines

Not sure if David or anyone is using this, but if someone is, it must be out-of-tree.

I am fine to remove it.

OK, thanks for confirming!

Ohad.

#26 lore raw

PATCH 7/7 omap: iommu: omapify 'struct iommu' and exposed API

In reply to Ohad Ben-Cohen

Prepend 'omap_' to OMAP's 'struct iommu' and exposed API, to prevent namespace pollution and generally to improve readability of the code that still uses the driver directly.

Update the users as needed as well.

---
 arch/arm/mach-omap2/iommu2.c                |   31 +++---
 arch/arm/plat-omap/include/plat/iommu.h     |   55 ++++++-----
 arch/arm/plat-omap/include/plat/iommu2.h    |    4 +-
 arch/arm/plat-omap/include/plat/iopgtable.h |    2 +-
 arch/arm/plat-omap/include/plat/iovmm.h     |   19 ++--
 drivers/iommu/omap-iommu-debug.c            |   34 +++---
 drivers/iommu/omap-iommu.c                  |  144 ++++++++++++++-------------
 drivers/iommu/omap-iovmm.c                  |   62 ++++++------
 drivers/media/video/omap3isp/isp.c          |    6 +-
 drivers/media/video/omap3isp/isp.h          |    2 +-
 drivers/media/video/omap3isp/ispccdc.c      |   23 +++--
 drivers/media/video/omap3isp/ispstat.c      |    9 +-
 drivers/media/video/omap3isp/ispvideo.c     |    4 +-
 13 files changed, 207 insertions(+), 188 deletions(-)
arch/arm/mach-omap2/iommu2.c +17 -14
index f286012..eefc379 100644
@@ -66,7 +66,7 @@
 	 ((pgsz) == MMU_CAM_PGSZ_4K)  ? 0xfffff000 : 0)
 
 
-static void __iommu_set_twl(struct iommu *obj, bool on)
+static void __iommu_set_twl(struct omap_iommu *obj, bool on)
 {
 	u32 l = iommu_read_reg(obj, MMU_CNTL);
 
@@ -85,7 +85,7 @@ static void __iommu_set_twl(struct iommu *obj, bool on)
 }
 
 
-static int omap2_iommu_enable(struct iommu *obj)
+static int omap2_iommu_enable(struct omap_iommu *obj)
 {
 	u32 l, pa;
 	unsigned long timeout;
@@ -127,7 +127,7 @@ static int omap2_iommu_enable(struct iommu *obj)
 	return 0;
 }
 
-static void omap2_iommu_disable(struct iommu *obj)
+static void omap2_iommu_disable(struct omap_iommu *obj)
 {
 	u32 l = iommu_read_reg(obj, MMU_CNTL);
 
@@ -138,12 +138,12 @@ static void omap2_iommu_disable(struct iommu *obj)
 	dev_dbg(obj->dev, "%s is shutting down\n", obj->name);
 }
 
-static void omap2_iommu_set_twl(struct iommu *obj, bool on)
+static void omap2_iommu_set_twl(struct omap_iommu *obj, bool on)
 {
 	__iommu_set_twl(obj, false);
 }
 
-static u32 omap2_iommu_fault_isr(struct iommu *obj, u32 *ra)
+static u32 omap2_iommu_fault_isr(struct omap_iommu *obj, u32 *ra)
 {
 	u32 stat, da;
 	u32 errs = 0;
@@ -173,13 +173,13 @@ static u32 omap2_iommu_fault_isr(struct iommu *obj, u32 *ra)
 	return errs;
 }
 
-static void omap2_tlb_read_cr(struct iommu *obj, struct cr_regs *cr)
+static void omap2_tlb_read_cr(struct omap_iommu *obj, struct cr_regs *cr)
 {
 	cr->cam = iommu_read_reg(obj, MMU_READ_CAM);
 	cr->ram = iommu_read_reg(obj, MMU_READ_RAM);
 }
 
-static void omap2_tlb_load_cr(struct iommu *obj, struct cr_regs *cr)
+static void omap2_tlb_load_cr(struct omap_iommu *obj, struct cr_regs *cr)
 {
 	iommu_write_reg(obj, cr->cam | MMU_CAM_V, MMU_CAM);
 	iommu_write_reg(obj, cr->ram, MMU_RAM);
@@ -193,7 +193,8 @@ static u32 omap2_cr_to_virt(struct cr_regs *cr)
 	return cr->cam & mask;
 }
 
-static struct cr_regs *omap2_alloc_cr(struct iommu *obj, struct iotlb_entry *e)
+static struct cr_regs *omap2_alloc_cr(struct omap_iommu *obj,
+						struct iotlb_entry *e)
 {
 	struct cr_regs *cr;
 
@@ -230,7 +231,8 @@ static u32 omap2_get_pte_attr(struct iotlb_entry *e)
 	return attr;
 }
 
-static ssize_t omap2_dump_cr(struct iommu *obj, struct cr_regs *cr, char *buf)
+static ssize_t
+omap2_dump_cr(struct omap_iommu *obj, struct cr_regs *cr, char *buf)
 {
 	char *p = buf;
 
@@ -254,7 +256,8 @@ static ssize_t omap2_dump_cr(struct iommu *obj, struct cr_regs *cr, char *buf)
 			goto out;					\
 	} while (0)
 
-static ssize_t omap2_iommu_dump_ctx(struct iommu *obj, char *buf, ssize_t len)
+static ssize_t
+omap2_iommu_dump_ctx(struct omap_iommu *obj, char *buf, ssize_t len)
 {
 	char *p = buf;
 
@@ -280,7 +283,7 @@ out:
 	return p - buf;
 }
 
-static void omap2_iommu_save_ctx(struct iommu *obj)
+static void omap2_iommu_save_ctx(struct omap_iommu *obj)
 {
 	int i;
 	u32 *p = obj->ctx;
@@ -293,7 +296,7 @@ static void omap2_iommu_save_ctx(struct iommu *obj)
 	BUG_ON(p[0] != IOMMU_ARCH_VERSION);
 }
 
-static void omap2_iommu_restore_ctx(struct iommu *obj)
+static void omap2_iommu_restore_ctx(struct omap_iommu *obj)
 {
 	int i;
 	u32 *p = obj->ctx;
@@ -343,13 +346,13 @@ static const struct iommu_functions omap2_iommu_ops = {
 
 static int __init omap2_iommu_init(void)
 {
-	return install_iommu_arch(&omap2_iommu_ops);
+	return omap_install_iommu_arch(&omap2_iommu_ops);
 }
 module_init(omap2_iommu_init);
 
 static void __exit omap2_iommu_exit(void)
 {
-	uninstall_iommu_arch(&omap2_iommu_ops);
+	omap_uninstall_iommu_arch(&omap2_iommu_ops);
 }
 module_exit(omap2_iommu_exit);
 
arch/arm/plat-omap/include/plat/iommu.h +30 -25

97 lines not on this page · raw message

arch/arm/plat-omap/include/plat/iommu2.h +2 -2
index 10ad05f..d4116b5 100644
@@ -83,12 +83,12 @@
 /*
  * register accessors
  */
-static inline u32 iommu_read_reg(struct iommu *obj, size_t offs)
+static inline u32 iommu_read_reg(struct omap_iommu *obj, size_t offs)
 {
 	return __raw_readl(obj->regbase + offs);
 }
 
-static inline void iommu_write_reg(struct iommu *obj, u32 val, size_t offs)
+static inline void iommu_write_reg(struct omap_iommu *obj, u32 val, size_t offs)
 {
 	__raw_writel(val, obj->regbase + offs);
 }
arch/arm/plat-omap/include/plat/iopgtable.h +1 -1
index 33c7aa9..66a8139 100644
@@ -115,6 +115,6 @@ static inline u32 iotlb_init_entry(struct iotlb_entry *e, u32 da, u32 pa,
 }
 
 #define to_iommu(dev)							\
-	(struct iommu *)platform_get_drvdata(to_platform_device(dev))
+	(struct omap_iommu *)platform_get_drvdata(to_platform_device(dev))
 
 #endif /* __PLAT_OMAP_IOMMU_H */
arch/arm/plat-omap/include/plat/iovmm.h +11 -8
index fc9aa6f..6af1a91 100644
@@ -16,7 +16,7 @@
 #include <linux/iommu.h>
 
 struct iovm_struct {
-	struct iommu		*iommu;	/* iommu object which this belongs to */
+	struct omap_iommu	*iommu;	/* iommu object which this belongs to */
 	u32			da_start; /* area definition */
 	u32			da_end;
 	u32			flags; /* IOVMF_: see below */
@@ -72,15 +72,18 @@ struct iovm_struct {
 #define IOVMF_DA_FIXED		(1 << (4 + IOVMF_SW_SHIFT))
 
 
-extern struct iovm_struct *find_iovm_area(struct iommu *obj, u32 da);
-extern u32 iommu_vmap(struct iommu_domain *domain, struct iommu *obj, u32 da,
+extern struct iovm_struct *omap_find_iovm_area(struct omap_iommu *obj, u32 da);
+extern u32
+omap_iommu_vmap(struct iommu_domain *domain, struct omap_iommu *obj, u32 da,
 			const struct sg_table *sgt, u32 flags);
-extern struct sg_table *iommu_vunmap(struct iommu_domain *domain,
-				struct iommu *obj, u32 da);
-extern u32 iommu_vmalloc(struct iommu_domain *domain, struct iommu *obj,
+extern struct sg_table *omap_iommu_vunmap(struct iommu_domain *domain,
+				struct omap_iommu *obj, u32 da);
+extern u32
+omap_iommu_vmalloc(struct iommu_domain *domain, struct omap_iommu *obj,
 				u32 da, size_t bytes, u32 flags);
-extern void iommu_vfree(struct iommu_domain *domain, struct iommu *obj,
+extern void
+omap_iommu_vfree(struct iommu_domain *domain, struct omap_iommu *obj,
 				const u32 da);
-extern void *da_to_va(struct iommu *obj, u32 da);
+extern void *omap_da_to_va(struct omap_iommu *obj, u32 da);
 
 #endif /* __IOMMU_MMAP_H */
drivers/iommu/omap-iommu-debug.c +17 -17
index 0f8c8dd..9c192e7 100644
@@ -32,7 +32,7 @@ static struct dentry *iommu_debug_root;
 static ssize_t debug_read_ver(struct file *file, char __user *userbuf,
 			      size_t count, loff_t *ppos)
 {
-	u32 ver = iommu_arch_version();
+	u32 ver = omap_iommu_arch_version();
 	char buf[MAXCOLUMN], *p = buf;
 
 	p += sprintf(p, "H/W version: %d.%d\n", (ver >> 4) & 0xf , ver & 0xf);
@@ -43,7 +43,7 @@ static ssize_t debug_read_ver(struct file *file, char __user *userbuf,
 static ssize_t debug_read_regs(struct file *file, char __user *userbuf,
 			       size_t count, loff_t *ppos)
 {
-	struct iommu *obj = file->private_data;
+	struct omap_iommu *obj = file->private_data;
 	char *p, *buf;
 	ssize_t bytes;
 
@@ -54,7 +54,7 @@ static ssize_t debug_read_regs(struct file *file, char __user *userbuf,
 
 	mutex_lock(&iommu_debug_lock);
 
-	bytes = iommu_dump_ctx(obj, p, count);
+	bytes = omap_iommu_dump_ctx(obj, p, count);
 	bytes = simple_read_from_buffer(userbuf, count, ppos, buf, bytes);
 
 	mutex_unlock(&iommu_debug_lock);
@@ -66,7 +66,7 @@ static ssize_t debug_read_regs(struct file *file, char __user *userbuf,
 static ssize_t debug_read_tlb(struct file *file, char __user *userbuf,
 			      size_t count, loff_t *ppos)
 {
-	struct iommu *obj = file->private_data;
+	struct omap_iommu *obj = file->private_data;
 	char *p, *buf;
 	ssize_t bytes, rest;
 
@@ -80,7 +80,7 @@ static ssize_t debug_read_tlb(struct file *file, char __user *userbuf,
 	p += sprintf(p, "%8s %8s\n", "cam:", "ram:");
 	p += sprintf(p, "-----------------------------------------\n");
 	rest = count - (p - buf);
-	p += dump_tlb_entries(obj, p, rest);
+	p += omap_dump_tlb_entries(obj, p, rest);
 
 	bytes = simple_read_from_buffer(userbuf, count, ppos, buf, p - buf);
 
@@ -96,7 +96,7 @@ static ssize_t debug_write_pagetable(struct file *file,
 	struct iotlb_entry e;
 	struct cr_regs cr;
 	int err;
-	struct iommu *obj = file->private_data;
+	struct omap_iommu *obj = file->private_data;
 	char buf[MAXCOLUMN], *p = buf;
 
 	count = min(count, sizeof(buf));
@@ -113,8 +113,8 @@ static ssize_t debug_write_pagetable(struct file *file,
 		return -EINVAL;
 	}
 
-	iotlb_cr_to_e(&cr, &e);
-	err = iopgtable_store_entry(obj, &e);
+	omap_iotlb_cr_to_e(&cr, &e);
+	err = omap_iopgtable_store_entry(obj, &e);
 	if (err)
 		dev_err(obj->dev, "%s: fail to store cr\n", __func__);
 
@@ -136,7 +136,7 @@ static ssize_t debug_write_pagetable(struct file *file,
 		__err;						\
 	})
 
-static ssize_t dump_ioptable(struct iommu *obj, char *buf, ssize_t len)
+static ssize_t dump_ioptable(struct omap_iommu *obj, char *buf, ssize_t len)
 {
 	int i;
 	u32 *iopgd;
@@ -183,7 +183,7 @@ out:
 static ssize_t debug_read_pagetable(struct file *file, char __user *userbuf,
 				    size_t count, loff_t *ppos)
 {
-	struct iommu *obj = file->private_data;
+	struct omap_iommu *obj = file->private_data;
 	char *p, *buf;
 	size_t bytes;
 
@@ -211,7 +211,7 @@ static ssize_t debug_read_pagetable(struct file *file, char __user *userbuf,
 static ssize_t debug_read_mmap(struct file *file, char __user *userbuf,
 			       size_t count, loff_t *ppos)
 {
-	struct iommu *obj = file->private_data;
+	struct omap_iommu *obj = file->private_data;
 	char *p, *buf;
 	struct iovm_struct *tmp;
 	int uninitialized_var(i);
@@ -253,7 +253,7 @@ static ssize_t debug_read_mmap(struct file *file, char __user *userbuf,
 static ssize_t debug_read_mem(struct file *file, char __user *userbuf,
 			      size_t count, loff_t *ppos)
 {
-	struct iommu *obj = file->private_data;
+	struct omap_iommu *obj = file->private_data;
 	char *p, *buf;
 	struct iovm_struct *area;
 	ssize_t bytes;
@@ -267,7 +267,7 @@ static ssize_t debug_read_mem(struct file *file, char __user *userbuf,
 
 	mutex_lock(&iommu_debug_lock);
 
-	area = find_iovm_area(obj, (u32)ppos);
+	area = omap_find_iovm_area(obj, (u32)ppos);
 	if (IS_ERR(area)) {
 		bytes = -EINVAL;
 		goto err_out;
@@ -286,7 +286,7 @@ err_out:
 static ssize_t debug_write_mem(struct file *file, const char __user *userbuf,
 			       size_t count, loff_t *ppos)
 {
-	struct iommu *obj = file->private_data;
+	struct omap_iommu *obj = file->private_data;
 	struct iovm_struct *area;
 	char *p, *buf;
 
@@ -304,7 +304,7 @@ static ssize_t debug_write_mem(struct file *file, const char __user *userbuf,
 		goto err_out;
 	}
 
-	area = find_iovm_area(obj, (u32)ppos);
+	area = omap_find_iovm_area(obj, (u32)ppos);
 	if (IS_ERR(area)) {
 		count = -EINVAL;
 		goto err_out;
@@ -360,7 +360,7 @@ DEBUG_FOPS(mem);
 static int iommu_debug_register(struct device *dev, void *data)
 {
 	struct platform_device *pdev = to_platform_device(dev);
-	struct iommu *obj = platform_get_drvdata(pdev);
+	struct omap_iommu *obj = platform_get_drvdata(pdev);
 	struct dentry *d, *parent;
 
 	if (!obj || !obj->dev)
@@ -396,7 +396,7 @@ static int __init iommu_debug_init(void)
 		return -ENOMEM;
 	iommu_debug_root = d;
 
-	err = foreach_iommu_device(d, iommu_debug_register);
+	err = omap_foreach_iommu_device(d, iommu_debug_register);
 	if (err)
 		goto err_out;
 	return 0;
drivers/iommu/omap-iommu.c +73 -71

479 lines not on this page · raw message

drivers/iommu/omap-iovmm.c +33 -29

205 lines not on this page · raw message

drivers/media/video/omap3isp/isp.c +3 -3
index 0db45ac..a4baa61 100644
@@ -85,7 +85,7 @@
  * any omap-specific iommu API
  */
 #define to_iommu(dev)							\
-	(struct iommu *)platform_get_drvdata(to_platform_device(dev))
+	(struct omap_iommu *)platform_get_drvdata(to_platform_device(dev))
 
 static unsigned int autoidle;
 module_param(autoidle, int, 0444);
@@ -1115,7 +1115,7 @@ static void isp_save_ctx(struct isp_device *isp)
 {
 	isp_save_context(isp, isp_reg_list);
 	if (isp->iommu)
-		iommu_save_ctx(isp->iommu);
+		omap_iommu_save_ctx(isp->iommu);
 }
 
 /*
@@ -1129,7 +1129,7 @@ static void isp_restore_ctx(struct isp_device *isp)
 {
 	isp_restore_context(isp, isp_reg_list);
 	if (isp->iommu)
-		iommu_restore_ctx(isp->iommu);
+		omap_iommu_restore_ctx(isp->iommu);
 	omap3isp_ccdc_restore_context(isp);
 	omap3isp_preview_restore_context(isp);
 }
drivers/media/video/omap3isp/isp.h +1 -1
index c9ec7a2..81fdd85 100644
@@ -295,7 +295,7 @@ struct isp_device {
 	unsigned int sbl_resources;
 	unsigned int subclk_resources;
 
-	struct iommu *iommu;
+	struct omap_iommu *iommu;
 	struct iommu_domain *domain;
 	struct device *iommu_dev;
 
drivers/media/video/omap3isp/ispccdc.c +12 -11
index de25474..9891dde 100644
@@ -365,7 +365,7 @@ static void ccdc_lsc_free_request(struct isp_ccdc_device *ccdc,
 		dma_unmap_sg(isp->dev, req->iovm->sgt->sgl,
 			     req->iovm->sgt->nents, DMA_TO_DEVICE);
 	if (req->table)
-		iommu_vfree(isp->domain, isp->iommu, req->table);
+		omap_iommu_vfree(isp->domain, isp->iommu, req->table);
 	kfree(req);
 }
 
@@ -437,7 +437,7 @@ static int ccdc_lsc_config(struct isp_ccdc_device *ccdc,
 
 		req->enable = 1;
 
-		req->table = iommu_vmalloc(isp->domain, isp->iommu, 0,
+		req->table = omap_iommu_vmalloc(isp->domain, isp->iommu, 0,
 					req->config.size, IOMMU_FLAG);
 		if (IS_ERR_VALUE(req->table)) {
 			req->table = 0;
@@ -445,7 +445,7 @@ static int ccdc_lsc_config(struct isp_ccdc_device *ccdc,
 			goto done;
 		}
 
-		req->iovm = find_iovm_area(isp->iommu, req->table);
+		req->iovm = omap_find_iovm_area(isp->iommu, req->table);
 		if (req->iovm == NULL) {
 			ret = -ENOMEM;
 			goto done;
@@ -461,7 +461,7 @@ static int ccdc_lsc_config(struct isp_ccdc_device *ccdc,
 		dma_sync_sg_for_cpu(isp->dev, req->iovm->sgt->sgl,
 				    req->iovm->sgt->nents, DMA_TO_DEVICE);
 
-		table = da_to_va(isp->iommu, req->table);
+		table = omap_da_to_va(isp->iommu, req->table);
 		if (copy_from_user(table, config->lsc, req->config.size)) {
 			ret = -EFAULT;
 			goto done;
@@ -730,18 +730,19 @@ static int ccdc_config(struct isp_ccdc_device *ccdc,
 
 			/*
 			 * table_new must be 64-bytes aligned, but it's
-			 * already done by iommu_vmalloc().
+			 * already done by omap_iommu_vmalloc().
 			 */
 			size = ccdc->fpc.fpnum * 4;
-			table_new = iommu_vmalloc(isp->domain, isp->iommu, 0,
-							size, IOMMU_FLAG);
+			table_new = omap_iommu_vmalloc(isp->domain, isp->iommu,
+							0, size, IOMMU_FLAG);
 			if (IS_ERR_VALUE(table_new))
 				return -ENOMEM;
 
-			if (copy_from_user(da_to_va(isp->iommu, table_new),
+			if (copy_from_user(omap_da_to_va(isp->iommu, table_new),
 					   (__force void __user *)
 					   ccdc->fpc.fpcaddr, size)) {
-				iommu_vfree(isp->domain, isp->iommu, table_new);
+				omap_iommu_vfree(isp->domain, isp->iommu,
+								table_new);
 				return -EFAULT;
 			}
 
@@ -751,7 +752,7 @@ static int ccdc_config(struct isp_ccdc_device *ccdc,
 
 		ccdc_configure_fpc(ccdc);
 		if (table_old != 0)
-			iommu_vfree(isp->domain, isp->iommu, table_old);
+			omap_iommu_vfree(isp->domain, isp->iommu, table_old);
 	}
 
 	return ccdc_lsc_config(ccdc, ccdc_struct);
@@ -2286,5 +2287,5 @@ void omap3isp_ccdc_cleanup(struct isp_device *isp)
 	ccdc_lsc_free_queue(ccdc, &ccdc->lsc.free_queue);
 
 	if (ccdc->fpc.fpcaddr != 0)
-		iommu_vfree(isp->domain, isp->iommu, ccdc->fpc.fpcaddr);
+		omap_iommu_vfree(isp->domain, isp->iommu, ccdc->fpc.fpcaddr);
 }
drivers/media/video/omap3isp/ispstat.c +5 -4
index 98af736..7329055 100644
@@ -366,7 +366,8 @@ static void isp_stat_bufs_free(struct ispstat *stat)
 				dma_unmap_sg(isp->dev, buf->iovm->sgt->sgl,
 					     buf->iovm->sgt->nents,
 					     DMA_FROM_DEVICE);
-			iommu_vfree(isp->domain, isp->iommu, buf->iommu_addr);
+			omap_iommu_vfree(isp->domain, isp->iommu,
+							buf->iommu_addr);
 		} else {
 			if (!buf->virt_addr)
 				continue;
@@ -399,7 +400,7 @@ static int isp_stat_bufs_alloc_iommu(struct ispstat *stat, unsigned int size)
 		struct iovm_struct *iovm;
 
 		WARN_ON(buf->dma_addr);
-		buf->iommu_addr = iommu_vmalloc(isp->domain, isp->iommu, 0,
+		buf->iommu_addr = omap_iommu_vmalloc(isp->domain, isp->iommu, 0,
 							size, IOMMU_FLAG);
 		if (IS_ERR((void *)buf->iommu_addr)) {
 			dev_err(stat->isp->dev,
@@ -409,7 +410,7 @@ static int isp_stat_bufs_alloc_iommu(struct ispstat *stat, unsigned int size)
 			return -ENOMEM;
 		}
 
-		iovm = find_iovm_area(isp->iommu, buf->iommu_addr);
+		iovm = omap_find_iovm_area(isp->iommu, buf->iommu_addr);
 		if (!iovm ||
 		    !dma_map_sg(isp->dev, iovm->sgt->sgl, iovm->sgt->nents,
 				DMA_FROM_DEVICE)) {
@@ -418,7 +419,7 @@ static int isp_stat_bufs_alloc_iommu(struct ispstat *stat, unsigned int size)
 		}
 		buf->iovm = iovm;
 
-		buf->virt_addr = da_to_va(stat->isp->iommu,
+		buf->virt_addr = omap_da_to_va(stat->isp->iommu,
 					  (u32)buf->iommu_addr);
 		buf->empty = 1;
 		dev_dbg(stat->isp->dev, "%s: buffer[%d] allocated."
drivers/media/video/omap3isp/ispvideo.c +2 -2
index 023b502..912ac07 100644
@@ -446,7 +446,7 @@ ispmmu_vmap(struct isp_device *isp, const struct scatterlist *sglist, int sglen)
 	sgt->nents = sglen;
 	sgt->orig_nents = sglen;
 
-	da = iommu_vmap(isp->domain, isp->iommu, 0, sgt, IOMMU_FLAG);
+	da = omap_iommu_vmap(isp->domain, isp->iommu, 0, sgt, IOMMU_FLAG);
 	if (IS_ERR_VALUE(da))
 		kfree(sgt);
 
@@ -462,7 +462,7 @@ static void ispmmu_vunmap(struct isp_device *isp, dma_addr_t da)
 {
 	struct sg_table *sgt;
 
-	sgt = iommu_vunmap(isp->domain, isp->iommu, (u32)da);
+	sgt = omap_iommu_vunmap(isp->domain, isp->iommu, (u32)da);
 	kfree(sgt);
 }
 
Signature · 1 line
1.7.4.1
#27 lore raw

cover omap: iommu migration, relocation and cleanups

In reply to Ohad Ben-Cohen

Hi Ohad,

Quoted 15 lines · On Thursday 18 August 2011 01:10:01 Ohad Ben-Cohen wrote:

1. Migrate OMAP's iommu driver to the generic IOMMU API, and move it to the dedicated iommu folder.

2. Fix omap3isp appropriately so it doesn't break.

3. Adapt OMAP's iovmm appropriately as well, because omap3isp still relies on it. The plan is eventually to remove iovmm and replace it with the upcoming IOMMU-based generic DMA-API. Move iovmm to the iommu folder too; it belongs there more than it belongs in the OMAP folders.

4. Start cleaning up OMAP's iommu components towards the end goal, where
1) omap-iommu no longer exports public API (and instead provides its entire functionality via the generic IOMMU API).
2) omap-iovmm is removed.

Quoted 4 lines

Changes:
1. Migrate iommu, iovmm and omap3isp in a single patch for bisectibility sake.
2. Apply Laurent Pinchart's comments (thanks Laurent!)

You're welcome.

Quoted 1 line

3. Rebase to 3.1-rc2

For the OMAP3 ISP driver changes,

Signature · 3 lines
Regards,

Laurent Pinchart
#28 lore raw

cover omap: iommu migration, relocation and cleanups

Hi Ohad,

From: ext Laurent Pinchart <[email protected]>
Subject: Re: [PATCH 0/7] omap: iommu migration, relocation and cleanups
Date: Thu, 18 Aug 2011 11:12:55 +0200

Quoted 17 lines

Hi Ohad,

Quoted 14 lines · On Thursday 18 August 2011 01:10:01 Ohad Ben-Cohen wrote:

1. Migrate OMAP's iommu driver to the generic IOMMU API, and move it to the dedicated iommu folder.

2. Fix omap3isp appropriately so it doesn't break.

3. Adapt OMAP's iovmm appropriately as well, because omap3isp still relies on it. The plan is eventually to remove iovmm and replace it with the upcoming IOMMU-based generic DMA-API. Move iovmm to the iommu folder too; it belongs there more than it belongs in the OMAP folders.

4. Start cleaning up OMAP's iommu components towards the end goal, where
1) omap-iommu no longer exports public API (and instead provides its entire functionality via the generic IOMMU API).
2) omap-iovmm is removed.

Good migration path!

Quoted 5 lines
Quoted 4 lines

Changes:
1. Migrate iommu, iovmm and omap3isp in a single patch for bisectibility sake.
2. Apply Laurent Pinchart's comments (thanks Laurent!)

Quoted 7 lines

You're welcome.

Quoted 1 line

3. Rebase to 3.1-rc2

For the OMAP3 ISP driver changes,

For the rest of omap iommu/iovmm patches, they look good:

#29 lore raw

cover omap: iommu migration, relocation and cleanups

In reply to Ohad Ben-Cohen
Quoted 10 lines · Ohad Ben-Cohen

1. Migrate OMAP's iommu driver to the generic IOMMU API, and move it to the dedicated iommu folder.

2. Fix omap3isp appropriately so it doesn't break.

3. Adapt OMAP's iovmm appropriately as well, because omap3isp still relies on it. The plan is eventually to remove iovmm and replace it with the upcoming IOMMU-based generic DMA-API. Move iovmm to the iommu folder too; it belongs there more than it belongs in the OMAP folders.

Quoted 4 lines

4. Start cleaning up OMAP's iommu components towards the end goal, where
1) omap-iommu no longer exports public API (and instead provides its entire functionality via the generic IOMMU API).
2) omap-iovmm is removed.

Besides the locking issue these patches look good to me. Please repost when this is solved and I will put it in my tree then.

Joerg

Signature · 5 lines
AMD Operating System Research Center

Advanced Micro Devices GmbH Einsteinring 24 85609 Dornach
General Managers: Alberto Bozzo, Andrew Bowd
Registration: Dornach, Landkr. Muenchen; Registerger. Muenchen, HRB Nr. 43632
#30 lore raw

cover omap: iommu migration, relocation and cleanups

Quoted 2 lines · Joerg

Besides the locking issue these patches look good to me. Please repost when this is solved and I will put it in my tree then.

Great, thanks !

I'll do a quick re-spin with the collected comments and ACKs and repost.

At least for the first few patches, which still change stuff in the OMAP folders, we will also need Tony's ACK.

Tony can you please take a look ?

Thanks!
Ohad.