Skip to content

Commit

Permalink
omap: iommu: migrate to the generic IOMMU API
Browse files Browse the repository at this point in the history
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).

Signed-off-by: Ohad Ben-Cohen <ohad@wizery.com>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Hiroshi DOYU <Hiroshi.DOYU@nokia.com>
Acked-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
  • Loading branch information
Ohad Ben-Cohen authored and Joerg Roedel committed Aug 26, 2011
1 parent fcb8ce5 commit f626b52
Show file tree
Hide file tree
Showing 11 changed files with 422 additions and 125 deletions.
4 changes: 3 additions & 1 deletion arch/arm/plat-omap/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
5 changes: 2 additions & 3 deletions arch/arm/plat-omap/include/plat/iommu.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ struct iommu {
void *isr_priv;

unsigned int refcount;
struct mutex iommu_lock; /* global for this whole object */
spinlock_t iommu_lock; /* global for this whole object */

/*
* We don't change iopgd for a situation like pgd for a task,
Expand Down Expand Up @@ -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),
Expand All @@ -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 */
27 changes: 16 additions & 11 deletions arch/arm/plat-omap/include/plat/iovmm.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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);

Expand Down
Loading

0 comments on commit f626b52

Please sign in to comment.