Skip to contentSkip to conversation

staging tidspbridge: iommu migration

PATCH In review Fernando Guzman Lugo 6 participants 28 messages Oct 5, 2010 – Oct 19, 2010 Staging

lore
Share & tools
lore
#0 lore raw

v3 cover staging tidspbridge: iommu migration

This set of patches remove the dspbridge custom mmu implementation and use iommu module instead.

Version2:
- Comments from FUJITA Tomonori and previous patch "tidspbridge: add map support for big buffers" was removed and instead a patch to define ARCH_HAS_SG_CHAIN in arm architecture will be sent.
- Rebase to the latest tidspbridge.

Version2
- Rebase to the latest staging-next tree commit:

	a747d4b817daf95c64ac6396e27fddc66c83a811

Fernando Guzman Lugo (11):
staging: tidspbridge: replace iommu custom for opensource
implementation
staging: tidspbridge - move shared memory iommu maps to tiomap3430.c
staging: tidspbridge - rename bridge_brd_mem_map/unmap to a proper
name
staging: tidspbridge - remove custom mmu code from tiomap3430.c
staging: tidspbridge - fix mmufault support
staging: tidspbrge - remove hw directory
staging: tidspbridge - move all iommu related code to a new file
staging: tidspbridge: remove dw_dmmu_base from cfg_hostres struct
staging: tidspbridge - remove reserved memory clean up
staging: tidspbridge - deprecate reserve/unreserve_memory funtions
staging: tidspbridge - remove dmm custom module

 drivers/staging/tidspbridge/Makefile               |    7 +-
 drivers/staging/tidspbridge/core/_deh.h            |    5 +-
 drivers/staging/tidspbridge/core/_tiomap.h         |   19 +-
 drivers/staging/tidspbridge/core/dsp-mmu.c         |  316 ++++++
 drivers/staging/tidspbridge/core/io_sm.c           |  180 +---
 drivers/staging/tidspbridge/core/tiomap3430.c      | 1070 ++------------------
 drivers/staging/tidspbridge/core/tiomap3430_pwr.c  |    4 -
 drivers/staging/tidspbridge/core/tiomap_io.c       |   17 +-
 drivers/staging/tidspbridge/core/ue_deh.c          |  115 +---
 drivers/staging/tidspbridge/hw/EasiGlobal.h        |   41 -
 drivers/staging/tidspbridge/hw/MMUAccInt.h         |   76 --
 drivers/staging/tidspbridge/hw/MMURegAcM.h         |  225 ----
 drivers/staging/tidspbridge/hw/hw_defs.h           |   58 --
 drivers/staging/tidspbridge/hw/hw_mmu.c            |  562 ----------
 drivers/staging/tidspbridge/hw/hw_mmu.h            |  163 ---
 .../tidspbridge/include/dspbridge/cfgdefs.h        |    1 -
 .../staging/tidspbridge/include/dspbridge/dev.h    |   24 -
 .../staging/tidspbridge/include/dspbridge/dmm.h    |   75 --
 .../staging/tidspbridge/include/dspbridge/drv.h    |   10 -
 .../tidspbridge/include/dspbridge/dsp-mmu.h        |   67 ++
 .../tidspbridge/include/dspbridge/dspdefs.h        |   44 -
 .../tidspbridge/include/dspbridge/dspioctl.h       |    7 -
 .../staging/tidspbridge/include/dspbridge/proc.h   |   46 -
 drivers/staging/tidspbridge/pmgr/dev.c             |   63 +--
 drivers/staging/tidspbridge/pmgr/dmm.c             |  533 ----------
 drivers/staging/tidspbridge/pmgr/dspapi.c          |   34 +-
 drivers/staging/tidspbridge/rmgr/drv.c             |   15 -
 drivers/staging/tidspbridge/rmgr/drv_interface.c   |    2 -
 drivers/staging/tidspbridge/rmgr/node.c            |   48 +-
 drivers/staging/tidspbridge/rmgr/proc.c            |  197 +----
 30 files changed, 568 insertions(+), 3456 deletions(-)
 create mode 100644 drivers/staging/tidspbridge/core/dsp-mmu.c
 delete mode 100644 drivers/staging/tidspbridge/hw/EasiGlobal.h
 delete mode 100644 drivers/staging/tidspbridge/hw/MMUAccInt.h
 delete mode 100644 drivers/staging/tidspbridge/hw/MMURegAcM.h
 delete mode 100644 drivers/staging/tidspbridge/hw/hw_defs.h
 delete mode 100644 drivers/staging/tidspbridge/hw/hw_mmu.c
 delete mode 100644 drivers/staging/tidspbridge/hw/hw_mmu.h
 delete mode 100644 drivers/staging/tidspbridge/include/dspbridge/dmm.h
 create mode 100644 drivers/staging/tidspbridge/include/dspbridge/dsp-mmu.h
 delete mode 100644 drivers/staging/tidspbridge/pmgr/dmm.c
#1 lore raw

PATCH v3 1/11 staging: tidspbridge: replace iommu custom for opensource implementation

Now the tidspbridge uses the API's from
iovmm module.

---
 drivers/staging/tidspbridge/core/_tiomap.h         |    4 +-
 drivers/staging/tidspbridge/core/io_sm.c           |  121 ++----
 drivers/staging/tidspbridge/core/tiomap3430.c      |  522 ++++----------------
 drivers/staging/tidspbridge/core/ue_deh.c          |    8 -
 .../tidspbridge/include/dspbridge/dspdefs.h        |    2 +-
 drivers/staging/tidspbridge/rmgr/proc.c            |    2 +-
 6 files changed, 138 insertions(+), 521 deletions(-)
drivers/staging/tidspbridge/core/_tiomap.h +3 -1
index 1c1f157..a42c393 100644
@@ -23,6 +23,8 @@
 #include <plat/clockdomain.h>
 #include <mach-omap2/prm-regbits-34xx.h>
 #include <mach-omap2/cm-regbits-34xx.h>
+#include <plat/iommu.h>
+#include <plat/iovmm.h>
 #include <dspbridge/devdefs.h>
 #include <hw_defs.h>
 #include <dspbridge/dspioctl.h>	/* for bridge_ioctl_extproc defn */
@@ -328,7 +330,7 @@ struct bridge_dev_context {
 	u32 dw_internal_size;	/* Internal memory size */
 
 	struct omap_mbox *mbox;		/* Mail box handle */
-
+	struct iommu *dsp_mmu;      /* iommu for iva2 handler */
 	struct cfg_hostres *resources;	/* Host Resources */
 
 	/*
drivers/staging/tidspbridge/core/io_sm.c +36 -85

169 lines not on this page · raw message

drivers/staging/tidspbridge/core/tiomap3430.c +94 -422

634 lines not on this page · raw message

drivers/staging/tidspbridge/core/ue_deh.c +0 -8
index 3430418..14f3191 100644
@@ -115,12 +115,6 @@ int bridge_deh_create(struct deh_mgr **ret_deh,
 	/* Fill in context structure */
 	deh->hbridge_context = hbridge_context;
 
-	/* Install ISR function for DSP MMU fault */
-	status = request_irq(INT_DSP_MMU_IRQ, mmu_fault_isr, 0,
-			"DspBridge\tiommu fault", deh);
-	if (status < 0)
-		goto err;
-
 	*ret_deh = deh;
 	return 0;
 
@@ -140,8 +134,6 @@ int bridge_deh_destroy(struct deh_mgr *deh)
 		ntfy_delete(deh->ntfy_obj);
 		kfree(deh->ntfy_obj);
 	}
-	/* Disable DSP MMU fault */
-	free_irq(INT_DSP_MMU_IRQ, deh);
 
 	/* Free DPC object */
 	tasklet_kill(&deh->dpc_tasklet);
drivers/staging/tidspbridge/include/dspbridge/dspdefs.h +1 -1
index 0ae7d16..173dfbb 100644
@@ -201,7 +201,7 @@ typedef int(*fxn_brd_memmap) (struct bridge_dev_context
  */
 typedef int(*fxn_brd_memunmap) (struct bridge_dev_context
 				       * dev_ctxt,
-				       u32 virt_addr, u32 ul_num_bytes);
+				       u32 da);
 
 /*
  *  ======== bridge_brd_stop ========
drivers/staging/tidspbridge/rmgr/proc.c +1 -1
index b47d7aa..97c5b61 100644
@@ -1723,7 +1723,7 @@ int proc_un_map(void *hprocessor, void *map_addr,
 	/* Remove mapping from the page tables. */
 	if (!status) {
 		status = (*p_proc_object->intf_fxns->pfn_brd_mem_un_map)
-		    (p_proc_object->hbridge_context, va_align, size_align);
+		    (p_proc_object->hbridge_context, va_align);
 	}
 
 	mutex_unlock(&proc_lock);
Signature · 1 line
1.6.3.3
#2 lore raw

PATCH v3 2/11 staging: tidspbridge - move shared memory iommu maps to tiomap3430.c

Now iommu maps of shared memory segments are done in bridge_brd_start and unmaped in bridge_brd_stop.

---
 drivers/staging/tidspbridge/core/_tiomap.h    |   13 +++
 drivers/staging/tidspbridge/core/io_sm.c      |  125 +++--------------------
 drivers/staging/tidspbridge/core/tiomap3430.c |  135 +++++++++++++++++++-----
 drivers/staging/tidspbridge/core/tiomap_io.c  |   12 +-
 4 files changed, 139 insertions(+), 146 deletions(-)
drivers/staging/tidspbridge/core/_tiomap.h +13 -0
index a42c393..c1bf95d 100644
@@ -308,6 +308,18 @@ static const struct bpwr_clk_t bpwr_clks[] = {
 
 #define CLEAR_BIT_INDEX(reg, index)   (reg &= ~(1 << (index)))
 
+struct shm_segs {
+	u32 seg0_da;
+	u32 seg0_pa;
+	u32 seg0_va;
+	u32 seg0_size;
+	u32 seg1_da;
+	u32 seg1_pa;
+	u32 seg1_va;
+	u32 seg1_size;
+};
+
+
 /* This Bridge driver's device context: */
 struct bridge_dev_context {
 	struct dev_object *hdev_obj;	/* Handle to Bridge device object. */
@@ -331,6 +343,7 @@ struct bridge_dev_context {
 
 	struct omap_mbox *mbox;		/* Mail box handle */
 	struct iommu *dsp_mmu;      /* iommu for iva2 handler */
+	struct shm_segs sh_s;
 	struct cfg_hostres *resources;	/* Host Resources */
 
 	/*
drivers/staging/tidspbridge/core/io_sm.c +13 -112

171 lines not on this page · raw message

drivers/staging/tidspbridge/core/tiomap3430.c +107 -28

208 lines not on this page · raw message

drivers/staging/tidspbridge/core/tiomap_io.c +6 -6
index ba29610..5ba6795 100644
@@ -134,10 +134,9 @@ int read_ext_dsp_data(struct bridge_dev_context *dev_ctxt,
 
 		if (!status) {
 			ul_tlb_base_virt =
-			    dev_context->atlb_entry[0].ul_dsp_va * DSPWORDSIZE;
+			    dev_context->sh_s.seg0_da * DSPWORDSIZE;
 			DBC_ASSERT(ul_tlb_base_virt <= ul_shm_base_virt);
-			dw_ext_prog_virt_mem =
-			    dev_context->atlb_entry[0].ul_gpp_va;
+			dw_ext_prog_virt_mem = dev_context->sh_s.seg0_va;
 
 			if (!trace_read) {
 				ul_shm_offset_virt =
@@ -318,8 +317,9 @@ int write_ext_dsp_data(struct bridge_dev_context *dev_context,
 			ret = -EPERM;
 
 		if (!ret) {
-			ul_tlb_base_virt =
-			    dev_context->atlb_entry[0].ul_dsp_va * DSPWORDSIZE;
+			ul_tlb_base_virt = dev_context->sh_s.seg0_da *
+								DSPWORDSIZE;
+
 			DBC_ASSERT(ul_tlb_base_virt <= ul_shm_base_virt);
 
 			if (symbols_reloaded) {
@@ -337,7 +337,7 @@ int write_ext_dsp_data(struct bridge_dev_context *dev_context,
 			    ul_shm_base_virt - ul_tlb_base_virt;
 			if (trace_load) {
 				dw_ext_prog_virt_mem =
-				    dev_context->atlb_entry[0].ul_gpp_va;
+					dev_context->sh_s.seg0_va;
 			} else {
 				dw_ext_prog_virt_mem = host_res->dw_mem_base[1];
 				dw_ext_prog_virt_mem +=
Signature · 1 line
1.6.3.3
#3 lore raw

PATCH v3 3/11 staging: tidspbridge - rename bridge_brd_mem_map/unmap to a proper name

Now these functions only map user space addresses to dsp virtual addresses, so now the functions have a more meaningful name. Also now user_to_dsp_map returns the mapped address.

---
 drivers/staging/tidspbridge/core/_tiomap.h         |   24 +++
 drivers/staging/tidspbridge/core/tiomap3430.c      |  153 ++++++++++----------
 .../tidspbridge/include/dspbridge/dspdefs.h        |   44 ------
 drivers/staging/tidspbridge/pmgr/dev.c             |    2 -
 drivers/staging/tidspbridge/rmgr/proc.c            |   34 +++--
 5 files changed, 116 insertions(+), 141 deletions(-)
drivers/staging/tidspbridge/core/_tiomap.h +24 -0
index c1bf95d..8777492 100644
@@ -383,4 +383,28 @@ extern s32 dsp_debug;
  */
 int sm_interrupt_dsp(struct bridge_dev_context *dev_context, u16 mb_val);
 
+/**
+ * user_to_dsp_map() - maps user to dsp virtual address
+ * @mmu:	Pointer to iommu handle.
+ * @uva:		Virtual user space address.
+ * @da		DSP address
+ * @size		Buffer size to map.
+ * @usr_pgs	struct page array pointer where the user pages will be stored
+ *
+ * This function maps a user space buffer into DSP virtual address.
+ *
+ */
+u32 user_to_dsp_map(struct iommu *mmu, u32 uva, u32 da, u32 size,
+						struct page **usr_pgs);
+
+/**
+ * user_to_dsp_unmap() - unmaps DSP virtual buffer.
+ * @mmu:	Pointer to iommu handle.
+ * @da		DSP address
+ *
+ * This function unmaps a user space buffer into DSP virtual address.
+ *
+ */
+int user_to_dsp_unmap(struct iommu *mmu, u32 da);
+
 #endif /* _TIOMAP_ */
drivers/staging/tidspbridge/core/tiomap3430.c +74 -79

208 lines not on this page · raw message

drivers/staging/tidspbridge/include/dspbridge/dspdefs.h +0 -44

56 lines not on this page · raw message

drivers/staging/tidspbridge/pmgr/dev.c +0 -2
index 132e960..e3c78fb 100644
@@ -1118,8 +1118,6 @@ static void store_interface_fxns(struct bridge_drv_interface *drv_fxns,
 		STORE_FXN(fxn_brd_setstate, pfn_brd_set_state);
 		STORE_FXN(fxn_brd_memcopy, pfn_brd_mem_copy);
 		STORE_FXN(fxn_brd_memwrite, pfn_brd_mem_write);
-		STORE_FXN(fxn_brd_memmap, pfn_brd_mem_map);
-		STORE_FXN(fxn_brd_memunmap, pfn_brd_mem_un_map);
 		STORE_FXN(fxn_chnl_create, pfn_chnl_create);
 		STORE_FXN(fxn_chnl_destroy, pfn_chnl_destroy);
 		STORE_FXN(fxn_chnl_open, pfn_chnl_open);
drivers/staging/tidspbridge/rmgr/proc.c +18 -16
index 97c5b61..59c946b 100644
@@ -52,6 +52,7 @@
 #include <dspbridge/msg.h>
 #include <dspbridge/dspioctl.h>
 #include <dspbridge/drv.h>
+#include <_tiomap.h>
 
 /*  ----------------------------------- This */
 #include <dspbridge/proc.h>
@@ -1357,7 +1358,6 @@ int proc_map(void *hprocessor, void *pmpu_addr, u32 ul_size,
 	int status = 0;
 	struct proc_object *p_proc_object = (struct proc_object *)hprocessor;
 	struct dmm_map_object *map_obj;
-	u32 tmp_addr = 0;
 
 #ifdef CONFIG_TIDSPBRIDGE_CACHE_LINE_CHECK
 	if ((ul_map_attr & BUFMODE_MASK) != RBUF) {
@@ -1390,24 +1390,27 @@ int proc_map(void *hprocessor, void *pmpu_addr, u32 ul_size,
 
 	/* Add mapping to the page tables. */
 	if (!status) {
-
-		/* Mapped address = MSB of VA | LSB of PA */
-		tmp_addr = (va_align | ((u32) pmpu_addr & (PG_SIZE4K - 1)));
 		/* mapped memory resource tracking */
-		map_obj = add_mapping_info(pr_ctxt, pa_align, tmp_addr,
+		map_obj = add_mapping_info(pr_ctxt, pa_align, va_align,
 						size_align);
-		if (!map_obj)
+		if (!map_obj) {
 			status = -ENOMEM;
-		else
-			status = (*p_proc_object->intf_fxns->pfn_brd_mem_map)
-			    (p_proc_object->hbridge_context, pa_align, va_align,
-			     size_align, ul_map_attr, map_obj->pages);
+		} else {
+			va_align = user_to_dsp_map(
+				p_proc_object->hbridge_context->dsp_mmu,
+				pa_align, va_align, size_align,
+				map_obj->pages);
+			if (IS_ERR_VALUE(va_align))
+				status = (int)va_align;
+		}
 	}
 	if (!status) {
 		/* Mapped address = MSB of VA | LSB of PA */
-		*pp_map_addr = (void *) tmp_addr;
+		map_obj->dsp_addr = (va_align |
+					((u32)pmpu_addr & (PG_SIZE4K - 1)));
+		*pp_map_addr = (void *)map_obj->dsp_addr;
 	} else {
-		remove_mapping_information(pr_ctxt, tmp_addr, size_align);
+		remove_mapping_information(pr_ctxt, va_align, size_align);
 		dmm_un_map_memory(dmm_mgr, va_align, &size_align);
 	}
 	mutex_unlock(&proc_lock);
@@ -1721,10 +1724,9 @@ int proc_un_map(void *hprocessor, void *map_addr,
 	 */
 	status = dmm_un_map_memory(dmm_mgr, (u32) va_align, &size_align);
 	/* Remove mapping from the page tables. */
-	if (!status) {
-		status = (*p_proc_object->intf_fxns->pfn_brd_mem_un_map)
-		    (p_proc_object->hbridge_context, va_align);
-	}
+	if (!status)
+		status = user_to_dsp_unmap(
+			p_proc_object->hbridge_context->dsp_mmu, va_align);
 
 	mutex_unlock(&proc_lock);
 	if (status)
Signature · 1 line
1.6.3.3
#4 lore raw

PATCH v3 4/11 staging: tidspbridge - remove custom mmu code from tiomap3430.c

This patch removes all the custom mmu code remaining in tiomap3430.c which is not needed anymore.

---
 drivers/staging/tidspbridge/core/_tiomap.h    |    2 -
 drivers/staging/tidspbridge/core/tiomap3430.c |  425 -------------------------
 2 files changed, 0 insertions(+), 427 deletions(-)
drivers/staging/tidspbridge/core/_tiomap.h +0 -2
index 8777492..394a64a 100644
@@ -330,7 +330,6 @@ struct bridge_dev_context {
 	 */
 	u32 dw_dsp_ext_base_addr;	/* See the comment above */
 	u32 dw_api_reg_base;	/* API mem map'd registers */
-	void __iomem *dw_dsp_mmu_base;	/* DSP MMU Mapped registers */
 	u32 dw_api_clk_base;	/* CLK Registers */
 	u32 dw_dsp_clk_m2_base;	/* DSP Clock Module m2 */
 	u32 dw_public_rhea;	/* Pub Rhea */
@@ -356,7 +355,6 @@ struct bridge_dev_context {
 
 	/* TC Settings */
 	bool tc_word_swap_on;	/* Traffic Controller Word Swap */
-	struct pg_table_attrs *pt_attrs;
 	u32 dsp_per_clks;
 };
 
drivers/staging/tidspbridge/core/tiomap3430.c +0 -425

489 lines not on this page · raw message

Signature · 1 line
1.6.3.3
#5 lore raw

PATCH v3 5/11 staging: tidspbridge - fix mmufault support

With changes for iommu migration mmufault report and dsp track dump is broken, this patch fixes that.

---
 drivers/staging/tidspbridge/core/_deh.h       |    2 +
 drivers/staging/tidspbridge/core/tiomap3430.c |    2 +
 drivers/staging/tidspbridge/core/ue_deh.c     |   93 ++++++++++---------------
 3 files changed, 40 insertions(+), 57 deletions(-)
drivers/staging/tidspbridge/core/_deh.h +2 -0
index 16723cd..f1254f0 100644
@@ -32,4 +32,6 @@ struct deh_mgr {
 	struct tasklet_struct dpc_tasklet;
 };
 
+int mmu_fault_isr(struct iommu *mmu);
+
 #endif /* _DEH_ */
drivers/staging/tidspbridge/core/tiomap3430.c +2 -0
index e5f67be..822226f 100644
@@ -58,6 +58,7 @@
 #include "_tiomap.h"
 #include "_tiomap_pwr.h"
 #include "tiomap_io.h"
+#include "_deh.h"
 
 /* Offset in shared mem to write to in order to synchronize start with DSP */
 #define SHMSYNCOFFSET 4		/* GPP byte offset */
@@ -367,6 +368,7 @@ static int bridge_brd_start(struct bridge_dev_context *dev_ctxt,
 	}
 	if (!status) {
 		dev_context->dsp_mmu = mmu;
+		mmu->isr = mmu_fault_isr;
 		sm_sg = &dev_context->sh_s;
 		sg0_da = iommu_kmap(mmu, sm_sg->seg0_da, sm_sg->seg0_pa,
 			sm_sg->seg0_size, IOVMF_ENDIAN_LITTLE | IOVMF_ELSZ_32);
drivers/staging/tidspbridge/core/ue_deh.c +36 -57

142 lines not on this page · raw message

Signature · 1 line
1.6.3.3
#6 lore raw

PATCH v3 6/11 staging: tidspbridge - remove hw directory

hw directory was only being used for custom iommu implementation APIs, so after the iommu module migration this directory is not needed anymore.

---
 drivers/staging/tidspbridge/Makefile               |    3 +-
 drivers/staging/tidspbridge/core/_tiomap.h         |    1 -
 drivers/staging/tidspbridge/core/io_sm.c           |    4 -
 drivers/staging/tidspbridge/core/tiomap3430.c      |    4 -
 drivers/staging/tidspbridge/core/tiomap3430_pwr.c  |    4 -
 drivers/staging/tidspbridge/core/tiomap_io.c       |    2 +-
 drivers/staging/tidspbridge/hw/EasiGlobal.h        |   41 --
 drivers/staging/tidspbridge/hw/MMUAccInt.h         |   76 ---
 drivers/staging/tidspbridge/hw/MMURegAcM.h         |  225 --------
 drivers/staging/tidspbridge/hw/hw_defs.h           |   58 --
 drivers/staging/tidspbridge/hw/hw_mmu.c            |  562 --------------------
 drivers/staging/tidspbridge/hw/hw_mmu.h            |  163 ------
 .../tidspbridge/include/dspbridge/dspioctl.h       |    7 -
 13 files changed, 2 insertions(+), 1148 deletions(-)
 delete mode 100644 drivers/staging/tidspbridge/hw/EasiGlobal.h
 delete mode 100644 drivers/staging/tidspbridge/hw/MMUAccInt.h
 delete mode 100644 drivers/staging/tidspbridge/hw/MMURegAcM.h
 delete mode 100644 drivers/staging/tidspbridge/hw/hw_defs.h
 delete mode 100644 drivers/staging/tidspbridge/hw/hw_mmu.c
 delete mode 100644 drivers/staging/tidspbridge/hw/hw_mmu.h
drivers/staging/tidspbridge/Makefile +1 -2
index 8082d5c..e09547d 100644
@@ -11,10 +11,9 @@ librmgr = rmgr/dbdcd.o rmgr/disp.o rmgr/drv.o rmgr/mgr.o rmgr/node.o \
 		rmgr/nldr.o rmgr/drv_interface.o
 libdload = dynload/cload.o dynload/getsection.o dynload/reloc.o \
 		 dynload/tramp.o
-libhw = hw/hw_mmu.o
 
 bridgedriver-objs = $(libgen) $(libservices) $(libcore) $(libpmgr) $(librmgr) \
-			$(libdload) $(libhw)
+			$(libdload)
 
 #Machine dependent
 ccflags-y += -D_TI_ -D_DB_TIOMAP -DTMS32060 \
drivers/staging/tidspbridge/core/_tiomap.h +0 -1
index 394a64a..cd7ff88 100644
@@ -26,7 +26,6 @@
 #include <plat/iommu.h>
 #include <plat/iovmm.h>
 #include <dspbridge/devdefs.h>
-#include <hw_defs.h>
 #include <dspbridge/dspioctl.h>	/* for bridge_ioctl_extproc defn */
 #include <dspbridge/sync.h>
 #include <dspbridge/clk.h>
drivers/staging/tidspbridge/core/io_sm.c +0 -4
index 56856ad..194bada 100644
@@ -39,10 +39,6 @@
 #include <dspbridge/ntfy.h>
 #include <dspbridge/sync.h>
 
-/* Hardware Abstraction Layer */
-#include <hw_defs.h>
-#include <hw_mmu.h>
-
 /* Bridge Driver */
 #include <dspbridge/dspdeh.h>
 #include <dspbridge/dspio.h>
drivers/staging/tidspbridge/core/tiomap3430.c +0 -4
index 822226f..8496c83 100644
@@ -35,10 +35,6 @@
 #include <dspbridge/drv.h>
 #include <dspbridge/sync.h>
 
-/* ------------------------------------ Hardware Abstraction Layer */
-#include <hw_defs.h>
-#include <hw_mmu.h>
-
 /*  ----------------------------------- Link Driver */
 #include <dspbridge/dspdefs.h>
 #include <dspbridge/dspchnl.h>
drivers/staging/tidspbridge/core/tiomap3430_pwr.c +0 -4
index fb9026e..b57a9fd 100644
@@ -31,10 +31,6 @@
 #include <dspbridge/dev.h>
 #include <dspbridge/iodefs.h>
 
-/* ------------------------------------ Hardware Abstraction Layer */
-#include <hw_defs.h>
-#include <hw_mmu.h>
-
 #include <dspbridge/pwr_sh.h>
 
 /*  ----------------------------------- Bridge Driver */
drivers/staging/tidspbridge/core/tiomap_io.c +1 -1
index 5ba6795..b526532 100644
@@ -143,7 +143,7 @@ int read_ext_dsp_data(struct bridge_dev_context *dev_ctxt,
 				    ul_shm_base_virt - ul_tlb_base_virt;
 				ul_shm_offset_virt +=
 				    PG_ALIGN_HIGH(ul_ext_end - ul_dyn_ext_base +
-						  1, HW_PAGE_SIZE64KB);
+						  1, PAGE_SIZE * 16);
 				dw_ext_prog_virt_mem -= ul_shm_offset_virt;
 				dw_ext_prog_virt_mem +=
 				    (ul_ext_base - ul_dyn_ext_base);
drivers/staging/tidspbridge/hw/EasiGlobal.h deleted +0 -41

41 lines not on this page · raw message

drivers/staging/tidspbridge/hw/MMUAccInt.h deleted +0 -76

76 lines not on this page · raw message

drivers/staging/tidspbridge/hw/MMURegAcM.h deleted +0 -225

225 lines not on this page · raw message

drivers/staging/tidspbridge/hw/hw_defs.h deleted +0 -58

58 lines not on this page · raw message

drivers/staging/tidspbridge/hw/hw_mmu.c deleted +0 -562

562 lines not on this page · raw message

drivers/staging/tidspbridge/hw/hw_mmu.h deleted +0 -163

163 lines not on this page · raw message

drivers/staging/tidspbridge/include/dspbridge/dspioctl.h +0 -7
index 41e0594..bad1801 100644
@@ -19,10 +19,6 @@
 #ifndef DSPIOCTL_
 #define DSPIOCTL_
 
-/* ------------------------------------ Hardware Abstraction Layer */
-#include <hw_defs.h>
-#include <hw_mmu.h>
-
 /*
  * Any IOCTLS at or above this value are reserved for standard Bridge driver
  * interfaces.
@@ -65,9 +61,6 @@ struct bridge_ioctl_extproc {
 	/* GPP virtual address. __va does not work for ioremapped addresses */
 	u32 ul_gpp_va;
 	u32 ul_size;		/* Size of the mapped memory in bytes */
-	enum hw_endianism_t endianism;
-	enum hw_mmu_mixed_size_t mixed_mode;
-	enum hw_element_size_t elem_size;
 };
 
 #endif /* DSPIOCTL_ */
Signature · 1 line
1.6.3.3
#7 lore raw

PATCH v3 7/11 staging: tidspbridge - move all iommu related code to a new file

Create dsp-mmu module and moves all the iommu code related to this module.

---
 drivers/staging/tidspbridge/Makefile               |    2 +-
 drivers/staging/tidspbridge/core/_deh.h            |    3 -
 drivers/staging/tidspbridge/core/_tiomap.h         |   27 +--
 drivers/staging/tidspbridge/core/dsp-mmu.c         |  316 ++++++++++++++++++++
 drivers/staging/tidspbridge/core/tiomap3430.c      |  178 +-----------
 drivers/staging/tidspbridge/core/ue_deh.c          |   86 +------
 .../tidspbridge/include/dspbridge/dsp-mmu.h        |   67 ++++
 7 files changed, 390 insertions(+), 289 deletions(-)
 create mode 100644 drivers/staging/tidspbridge/core/dsp-mmu.c
 create mode 100644 drivers/staging/tidspbridge/include/dspbridge/dsp-mmu.h
drivers/staging/tidspbridge/Makefile +1 -1
index e09547d..bd36651 100644
@@ -2,7 +2,7 @@ obj-$(CONFIG_TIDSPBRIDGE)	+= bridgedriver.o
 
 libgen = gen/gb.o gen/gs.o gen/gh.o gen/uuidutil.o
 libcore = core/chnl_sm.o core/msg_sm.o core/io_sm.o core/tiomap3430.o \
-		core/tiomap3430_pwr.o core/tiomap_io.o \
+		core/tiomap3430_pwr.o core/tiomap_io.o core/dsp-mmu.o \
 		core/ue_deh.o core/wdt.o core/dsp-clock.o core/sync.o
 libpmgr = pmgr/chnl.o pmgr/io.o pmgr/msg.o pmgr/cod.o pmgr/dev.o pmgr/dspapi.o \
 		pmgr/dmm.o pmgr/cmm.o pmgr/dbll.o
drivers/staging/tidspbridge/core/_deh.h +0 -3
index f1254f0..8ae2633 100644
@@ -27,9 +27,6 @@
 struct deh_mgr {
 	struct bridge_dev_context *hbridge_context;	/* Bridge context. */
 	struct ntfy_object *ntfy_obj;	/* NTFY object */
-
-	/* MMU Fault DPC */
-	struct tasklet_struct dpc_tasklet;
 };
 
 int mmu_fault_isr(struct iommu *mmu);
drivers/staging/tidspbridge/core/_tiomap.h +1 -26
index cd7ff88..e0a801c 100644
@@ -23,8 +23,7 @@
 #include <plat/clockdomain.h>
 #include <mach-omap2/prm-regbits-34xx.h>
 #include <mach-omap2/cm-regbits-34xx.h>
-#include <plat/iommu.h>
-#include <plat/iovmm.h>
+#include <dspbridge/dsp-mmu.h>
 #include <dspbridge/devdefs.h>
 #include <dspbridge/dspioctl.h>	/* for bridge_ioctl_extproc defn */
 #include <dspbridge/sync.h>
@@ -380,28 +379,4 @@ extern s32 dsp_debug;
  */
 int sm_interrupt_dsp(struct bridge_dev_context *dev_context, u16 mb_val);
 
-/**
- * user_to_dsp_map() - maps user to dsp virtual address
- * @mmu:	Pointer to iommu handle.
- * @uva:		Virtual user space address.
- * @da		DSP address
- * @size		Buffer size to map.
- * @usr_pgs	struct page array pointer where the user pages will be stored
- *
- * This function maps a user space buffer into DSP virtual address.
- *
- */
-u32 user_to_dsp_map(struct iommu *mmu, u32 uva, u32 da, u32 size,
-						struct page **usr_pgs);
-
-/**
- * user_to_dsp_unmap() - unmaps DSP virtual buffer.
- * @mmu:	Pointer to iommu handle.
- * @da		DSP address
- *
- * This function unmaps a user space buffer into DSP virtual address.
- *
- */
-int user_to_dsp_unmap(struct iommu *mmu, u32 da);
-
 #endif /* _TIOMAP_ */
drivers/staging/tidspbridge/core/dsp-mmu.c new file +316 -0

316 lines not on this page · raw message

drivers/staging/tidspbridge/core/tiomap3430.c +4 -174

215 lines not on this page · raw message

drivers/staging/tidspbridge/core/ue_deh.c +1 -85

122 lines not on this page · raw message

drivers/staging/tidspbridge/include/dspbridge/dsp-mmu.h new file +67 -0

67 lines not on this page · raw message

Signature · 1 line
1.6.3.3
#8 lore raw

PATCH v3 8/11 staging: tidspbridge: remove dw_dmmu_base from cfg_hostres struct

We don't need to map iva2 iommu register base address anymore.

---
 drivers/staging/tidspbridge/core/tiomap3430.c      |    3 ---
 drivers/staging/tidspbridge/core/tiomap_io.c       |    3 +--
 .../tidspbridge/include/dspbridge/cfgdefs.h        |    1 -
 drivers/staging/tidspbridge/rmgr/drv.c             |    4 ----
 4 files changed, 1 insertions(+), 10 deletions(-)
drivers/staging/tidspbridge/core/tiomap3430.c +0 -3
index 4927ec3..a95ff2f 100644
@@ -833,8 +833,6 @@ static int bridge_dev_destroy(struct bridge_dev_context *dev_ctxt)
 			iounmap((void *)host_res->dw_mem_base[3]);
 		if (host_res->dw_mem_base[4])
 			iounmap((void *)host_res->dw_mem_base[4]);
-		if (host_res->dw_dmmu_base)
-			iounmap(host_res->dw_dmmu_base);
 		if (host_res->dw_per_base)
 			iounmap(host_res->dw_per_base);
 		if (host_res->dw_per_pm_base)
@@ -848,7 +846,6 @@ static int bridge_dev_destroy(struct bridge_dev_context *dev_ctxt)
 		host_res->dw_mem_base[2] = (u32) NULL;
 		host_res->dw_mem_base[3] = (u32) NULL;
 		host_res->dw_mem_base[4] = (u32) NULL;
-		host_res->dw_dmmu_base = NULL;
 		host_res->dw_sys_ctrl_base = NULL;
 
 		kfree(host_res);
drivers/staging/tidspbridge/core/tiomap_io.c +1 -2
index b526532..66dbf02 100644
@@ -393,7 +393,6 @@ int sm_interrupt_dsp(struct bridge_dev_context *dev_context, u16 mb_val)
 		omap_dspbridge_dev->dev.platform_data;
 	struct cfg_hostres *resources = dev_context->resources;
 	int status = 0;
-	u32 temp;
 
 	if (!dev_context->mbox)
 		return 0;
@@ -437,7 +436,7 @@ int sm_interrupt_dsp(struct bridge_dev_context *dev_context, u16 mb_val)
 		omap_mbox_restore_ctx(dev_context->mbox);
 
 		/* Access MMU SYS CONFIG register to generate a short wakeup */
-		temp = readl(resources->dw_dmmu_base + 0x10);
+		iommu_read_reg(dev_context->dsp_mmu, MMU_SYSCONFIG);
 
 		dev_context->dw_brd_state = BRD_RUNNING;
 	} else if (dev_context->dw_brd_state == BRD_RETENTION) {
drivers/staging/tidspbridge/include/dspbridge/cfgdefs.h +0 -1
index 38122db..dfb55cc 100644
@@ -68,7 +68,6 @@ struct cfg_hostres {
 	void __iomem *dw_per_base;
 	u32 dw_per_pm_base;
 	u32 dw_core_pm_base;
-	void __iomem *dw_dmmu_base;
 	void __iomem *dw_sys_ctrl_base;
 };
 
drivers/staging/tidspbridge/rmgr/drv.c +0 -4
index 81b1b90..0c857b9 100644
@@ -743,7 +743,6 @@ static int request_bridge_resources(struct cfg_hostres *res)
 	host_res->dw_sys_ctrl_base = ioremap(OMAP_SYSC_BASE, OMAP_SYSC_SIZE);
 	dev_dbg(bridge, "dw_mem_base[0] 0x%x\n", host_res->dw_mem_base[0]);
 	dev_dbg(bridge, "dw_mem_base[3] 0x%x\n", host_res->dw_mem_base[3]);
-	dev_dbg(bridge, "dw_dmmu_base %p\n", host_res->dw_dmmu_base);
 
 	/* for 24xx base port is not mapping the mamory for DSP
 	 * internal memory TODO Do a ioremap here */
@@ -797,8 +796,6 @@ int drv_request_bridge_res_dsp(void **phost_resources)
 							 OMAP_PER_PRM_SIZE);
 		host_res->dw_core_pm_base = (u32) ioremap(OMAP_CORE_PRM_BASE,
 							  OMAP_CORE_PRM_SIZE);
-		host_res->dw_dmmu_base = ioremap(OMAP_DMMU_BASE,
-						 OMAP_DMMU_SIZE);
 
 		dev_dbg(bridge, "dw_mem_base[0] 0x%x\n",
 			host_res->dw_mem_base[0]);
@@ -810,7 +807,6 @@ int drv_request_bridge_res_dsp(void **phost_resources)
 			host_res->dw_mem_base[3]);
 		dev_dbg(bridge, "dw_mem_base[4] 0x%x\n",
 			host_res->dw_mem_base[4]);
-		dev_dbg(bridge, "dw_dmmu_base %p\n", host_res->dw_dmmu_base);
 
 		shm_size = drv_datap->shm_size;
 		if (shm_size >= 0x10000) {
Signature · 1 line
1.6.3.3
#9 lore raw

PATCH v3 9/11 staging: tidspbridge - remove reserved memory clean up

Now iommv module keeps track of iommu memory used, we do not need resource cleanup for reserved memories anymore.

---
 .../staging/tidspbridge/include/dspbridge/drv.h    |    4 --
 drivers/staging/tidspbridge/rmgr/drv.c             |   11 ------
 drivers/staging/tidspbridge/rmgr/drv_interface.c   |    2 -
 drivers/staging/tidspbridge/rmgr/proc.c            |   36 --------------------
 4 files changed, 0 insertions(+), 53 deletions(-)
drivers/staging/tidspbridge/include/dspbridge/drv.h +0 -4
index c1f363e..427f38b 100644
@@ -165,10 +165,6 @@ struct process_context {
 	struct list_head dmm_map_list;
 	spinlock_t dmm_map_lock;
 
-	/* DMM reserved memory resources */
-	struct list_head dmm_rsv_list;
-	spinlock_t dmm_rsv_lock;
-
 	/* DSP Heap resources */
 	struct dspheap_res_object *pdspheap_list;
 
drivers/staging/tidspbridge/rmgr/drv.c +0 -11
index 0c857b9..91cc168 100644
@@ -146,7 +146,6 @@ int drv_remove_all_dmm_res_elements(void *process_ctxt)
 	struct process_context *ctxt = (struct process_context *)process_ctxt;
 	int status = 0;
 	struct dmm_map_object *temp_map, *map_obj;
-	struct dmm_rsv_object *temp_rsv, *rsv_obj;
 
 	/* Free DMM mapped memory resources */
 	list_for_each_entry_safe(map_obj, temp_map, &ctxt->dmm_map_list, link) {
@@ -156,16 +155,6 @@ int drv_remove_all_dmm_res_elements(void *process_ctxt)
 			pr_err("%s: proc_un_map failed!"
 			       " status = 0x%xn", __func__, status);
 	}
-
-	/* Free DMM reserved memory resources */
-	list_for_each_entry_safe(rsv_obj, temp_rsv, &ctxt->dmm_rsv_list, link) {
-		status = proc_un_reserve_memory(ctxt->hprocessor, (void *)
-						rsv_obj->dsp_reserved_addr,
-						ctxt);
-		if (status)
-			pr_err("%s: proc_un_reserve_memory failed!"
-			       " status = 0x%xn", __func__, status);
-	}
 	return status;
 }
 
drivers/staging/tidspbridge/rmgr/drv_interface.c +0 -2
index 5d0670c..63052b0 100644
@@ -509,8 +509,6 @@ static int bridge_open(struct inode *ip, struct file *filp)
 		pr_ctxt->res_state = PROC_RES_ALLOCATED;
 		spin_lock_init(&pr_ctxt->dmm_map_lock);
 		INIT_LIST_HEAD(&pr_ctxt->dmm_map_list);
-		spin_lock_init(&pr_ctxt->dmm_rsv_lock);
-		INIT_LIST_HEAD(&pr_ctxt->dmm_rsv_list);
 
 		pr_ctxt->node_id = kzalloc(sizeof(struct idr), GFP_KERNEL);
 		if (pr_ctxt->node_id) {
drivers/staging/tidspbridge/rmgr/proc.c +0 -36
index 59c946b..e5fec57 100644
@@ -1515,7 +1515,6 @@ int proc_reserve_memory(void *hprocessor, u32 ul_size,
 	struct dmm_object *dmm_mgr;
 	int status = 0;
 	struct proc_object *p_proc_object = (struct proc_object *)hprocessor;
-	struct dmm_rsv_object *rsv_obj;
 
 	if (!p_proc_object) {
 		status = -EFAULT;
@@ -1529,22 +1528,6 @@ int proc_reserve_memory(void *hprocessor, u32 ul_size,
 	}
 
 	status = dmm_reserve_memory(dmm_mgr, ul_size, (u32 *) pp_rsv_addr);
-	if (status != 0)
-		goto func_end;
-
-	/*
-	 * A successful reserve should be followed by insertion of rsv_obj
-	 * into dmm_rsv_list, so that reserved memory resource tracking
-	 * remains uptodate
-	 */
-	rsv_obj = kmalloc(sizeof(struct dmm_rsv_object), GFP_KERNEL);
-	if (rsv_obj) {
-		rsv_obj->dsp_reserved_addr = (u32) *pp_rsv_addr;
-		spin_lock(&pr_ctxt->dmm_rsv_lock);
-		list_add(&rsv_obj->link, &pr_ctxt->dmm_rsv_list);
-		spin_unlock(&pr_ctxt->dmm_rsv_lock);
-	}
-
 func_end:
 	dev_dbg(bridge, "%s: hprocessor: 0x%p ul_size: 0x%x pp_rsv_addr: 0x%p "
 		"status 0x%x\n", __func__, hprocessor,
@@ -1756,7 +1739,6 @@ int proc_un_reserve_memory(void *hprocessor, void *prsv_addr,
 	struct dmm_object *dmm_mgr;
 	int status = 0;
 	struct proc_object *p_proc_object = (struct proc_object *)hprocessor;
-	struct dmm_rsv_object *rsv_obj;
 
 	if (!p_proc_object) {
 		status = -EFAULT;
@@ -1770,24 +1752,6 @@ int proc_un_reserve_memory(void *hprocessor, void *prsv_addr,
 	}
 
 	status = dmm_un_reserve_memory(dmm_mgr, (u32) prsv_addr);
-	if (status != 0)
-		goto func_end;
-
-	/*
-	 * A successful unreserve should be followed by removal of rsv_obj
-	 * from dmm_rsv_list, so that reserved memory resource tracking
-	 * remains uptodate
-	 */
-	spin_lock(&pr_ctxt->dmm_rsv_lock);
-	list_for_each_entry(rsv_obj, &pr_ctxt->dmm_rsv_list, link) {
-		if (rsv_obj->dsp_reserved_addr == (u32) prsv_addr) {
-			list_del(&rsv_obj->link);
-			kfree(rsv_obj);
-			break;
-		}
-	}
-	spin_unlock(&pr_ctxt->dmm_rsv_lock);
-
 func_end:
 	dev_dbg(bridge, "%s: hprocessor: 0x%p prsv_addr: 0x%p status: 0x%x\n",
 		__func__, hprocessor, prsv_addr, status);
Signature · 1 line
1.6.3.3
#10 lore raw

PATCH v3 10/11 staging: tidspbridge - deprecate reserve/unreserve_memory funtions

Now what iommu memory usage is kept track by iommu module the functions reserve/unreserve_memory are not needed anymore.

---
 .../staging/tidspbridge/include/dspbridge/proc.h   |   46 --------
 drivers/staging/tidspbridge/pmgr/dspapi.c          |   34 +-----
 drivers/staging/tidspbridge/rmgr/node.c            |   20 +----
 drivers/staging/tidspbridge/rmgr/proc.c            |  114 ++------------------
 4 files changed, 17 insertions(+), 197 deletions(-)
drivers/staging/tidspbridge/include/dspbridge/proc.h +0 -46
index 5e09fd1..2d12aab 100644
@@ -551,29 +551,6 @@ extern int proc_map(void *hprocessor,
 			   struct process_context *pr_ctxt);
 
 /*
- *  ======== proc_reserve_memory ========
- *  Purpose:
- *      Reserve a virtually contiguous region of DSP address space.
- *  Parameters:
- *      hprocessor      :   The processor handle.
- *      ul_size	  :   Size of the address space to reserve.
- *      pp_rsv_addr       :   Ptr to DSP side reserved u8 address.
- *  Returns:
- *      0	 :   Success.
- *      -EFAULT     :   Invalid processor handle.
- *      -EPERM       :   General failure.
- *      -ENOMEM     :   Cannot reserve chunk of this size.
- *  Requires:
- *      pp_rsv_addr is not NULL
- *      PROC Initialized.
- *  Ensures:
- *  Details:
- */
-extern int proc_reserve_memory(void *hprocessor,
-				      u32 ul_size, void **pp_rsv_addr,
-				      struct process_context *pr_ctxt);
-
-/*
  *  ======== proc_un_map ========
  *  Purpose:
  *      Removes a MPU buffer mapping from the DSP address space.
@@ -595,27 +572,4 @@ extern int proc_reserve_memory(void *hprocessor,
 extern int proc_un_map(void *hprocessor, void *map_addr,
 			      struct process_context *pr_ctxt);
 
-/*
- *  ======== proc_un_reserve_memory ========
- *  Purpose:
- *      Frees a previously reserved region of DSP address space.
- *  Parameters:
- *      hprocessor      :   The processor handle.
- *      prsv_addr	:   Ptr to DSP side reservedBYTE address.
- *  Returns:
- *      0	 :   Success.
- *      -EFAULT     :   Invalid processor handle.
- *      -EPERM       :   General failure.
- *      -ENOENT   :   Cannot find a reserved region starting with this
- *		      :   address.
- *  Requires:
- *      prsv_addr is not NULL
- *      PROC Initialized.
- *  Ensures:
- *  Details:
- */
-extern int proc_un_reserve_memory(void *hprocessor,
-					 void *prsv_addr,
-					 struct process_context *pr_ctxt);
-
 #endif /* PROC_ */
drivers/staging/tidspbridge/pmgr/dspapi.c +6 -28
index faf8304..0187c47 100644
@@ -989,27 +989,10 @@ u32 procwrap_register_notify(union trapped_args *args, void *pr_ctxt)
 /*
  * ======== procwrap_reserve_memory ========
  */
-u32 procwrap_reserve_memory(union trapped_args *args, void *pr_ctxt)
+u32 __deprecated procwrap_reserve_memory(union trapped_args *args,
+							void *pr_ctxt)
 {
-	int status;
-	void *prsv_addr;
-	void *hprocessor = ((struct process_context *)pr_ctxt)->hprocessor;
-
-	if ((args->args_proc_rsvmem.ul_size <= 0) ||
-	    (args->args_proc_rsvmem.ul_size & (PG_SIZE4K - 1)) != 0)
-		return -EINVAL;
-
-	status = proc_reserve_memory(hprocessor,
-				     args->args_proc_rsvmem.ul_size, &prsv_addr,
-				     pr_ctxt);
-	if (!status) {
-		if (put_user(prsv_addr, args->args_proc_rsvmem.pp_rsv_addr)) {
-			status = -EINVAL;
-			proc_un_reserve_memory(args->args_proc_rsvmem.
-					       hprocessor, prsv_addr, pr_ctxt);
-		}
-	}
-	return status;
+	return 0;
 }
 
 /*
@@ -1038,15 +1021,10 @@ u32 procwrap_un_map(union trapped_args *args, void *pr_ctxt)
 /*
  * ======== procwrap_un_reserve_memory ========
  */
-u32 procwrap_un_reserve_memory(union trapped_args *args, void *pr_ctxt)
+u32 __deprecated procwrap_un_reserve_memory(union trapped_args *args,
+							void *pr_ctxt)
 {
-	int status;
-	void *hprocessor = ((struct process_context *)pr_ctxt)->hprocessor;
-
-	status = proc_un_reserve_memory(hprocessor,
-					args->args_proc_unrsvmem.prsv_addr,
-					pr_ctxt);
-	return status;
+	return 0;
 }
 
 /*
drivers/staging/tidspbridge/rmgr/node.c +1 -19
index 1562f3c..ccb1811 100644
@@ -430,17 +430,6 @@ int node_allocate(struct proc_object *hprocessor,
 	if (status)
 		goto func_cont;
 
-	status = proc_reserve_memory(hprocessor,
-				     pnode->create_args.asa.task_arg_obj.
-				     heap_size + PAGE_SIZE,
-				     (void **)&(pnode->create_args.asa.
-					task_arg_obj.udsp_heap_res_addr),
-				     pr_ctxt);
-	if (status) {
-		pr_err("%s: Failed to reserve memory for heap: 0x%x\n",
-		       __func__, status);
-		goto func_cont;
-	}
 #ifdef DSP_DMM_DEBUG
 	status = dmm_get_handle(p_proc_object, &dmm_mgr);
 	if (!dmm_mgr) {
@@ -456,8 +445,7 @@ int node_allocate(struct proc_object *hprocessor,
 	map_attrs |= DSP_MAPVIRTUALADDR;
 	status = proc_map(hprocessor, (void *)attr_in->pgpp_virt_addr,
 			  pnode->create_args.asa.task_arg_obj.heap_size,
-			  (void *)pnode->create_args.asa.task_arg_obj.
-			  udsp_heap_res_addr, (void **)&mapped_addr, map_attrs,
+			  NULL, (void **)&mapped_addr, map_attrs,
 			  pr_ctxt);
 	if (status)
 		pr_err("%s: Failed to map memory for Heap: 0x%x\n",
@@ -2576,12 +2564,6 @@ static void delete_node(struct node_object *hnode,
 			status = proc_un_map(hnode->hprocessor, (void *)
 					     task_arg_obj.udsp_heap_addr,
 					     pr_ctxt);
-
-			status = proc_un_reserve_memory(hnode->hprocessor,
-							(void *)
-							task_arg_obj.
-							udsp_heap_res_addr,
-							pr_ctxt);
 #ifdef DSP_DMM_DEBUG
 			status = dmm_get_handle(p_proc_object, &dmm_mgr);
 			if (dmm_mgr)
drivers/staging/tidspbridge/rmgr/proc.c +10 -104

182 lines not on this page · raw message

Signature · 1 line
1.6.3.3
#11 lore raw

PATCH v3 11/11 staging: tidspbridge - remove dmm custom module

Dmm custom module is not needed anymore.

---
 drivers/staging/tidspbridge/Makefile               |    2 +-
 drivers/staging/tidspbridge/core/tiomap3430.c      |    1 -
 .../staging/tidspbridge/include/dspbridge/dev.h    |   24 -
 .../staging/tidspbridge/include/dspbridge/dmm.h    |   75 ---
 .../staging/tidspbridge/include/dspbridge/drv.h    |    6 -
 drivers/staging/tidspbridge/pmgr/dev.c             |   61 +---
 drivers/staging/tidspbridge/pmgr/dmm.c             |  533 --------------------
 drivers/staging/tidspbridge/rmgr/node.c            |   28 +-
 drivers/staging/tidspbridge/rmgr/proc.c            |   23 -
 9 files changed, 6 insertions(+), 747 deletions(-)
 delete mode 100644 drivers/staging/tidspbridge/include/dspbridge/dmm.h
 delete mode 100644 drivers/staging/tidspbridge/pmgr/dmm.c
drivers/staging/tidspbridge/Makefile +1 -1
index bd36651..7c122fa 100644
@@ -5,7 +5,7 @@ libcore = core/chnl_sm.o core/msg_sm.o core/io_sm.o core/tiomap3430.o \
 		core/tiomap3430_pwr.o core/tiomap_io.o core/dsp-mmu.o \
 		core/ue_deh.o core/wdt.o core/dsp-clock.o core/sync.o
 libpmgr = pmgr/chnl.o pmgr/io.o pmgr/msg.o pmgr/cod.o pmgr/dev.o pmgr/dspapi.o \
-		pmgr/dmm.o pmgr/cmm.o pmgr/dbll.o
+		pmgr/cmm.o pmgr/dbll.o
 librmgr = rmgr/dbdcd.o rmgr/disp.o rmgr/drv.o rmgr/mgr.o rmgr/node.o \
 		rmgr/proc.o rmgr/pwr.o rmgr/rmm.o rmgr/strm.o rmgr/dspdrv.o \
 		rmgr/nldr.o rmgr/drv_interface.o
drivers/staging/tidspbridge/core/tiomap3430.c +0 -1
index a95ff2f..f22bc12 100644
@@ -47,7 +47,6 @@
 /*  ----------------------------------- Platform Manager */
 #include <dspbridge/dev.h>
 #include <dspbridge/dspapi.h>
-#include <dspbridge/dmm.h>
 #include <dspbridge/wdt.h>
 
 /*  ----------------------------------- Local */
drivers/staging/tidspbridge/include/dspbridge/dev.h +0 -24
index 357458f..9bdd48f 100644
@@ -27,7 +27,6 @@
 #include <dspbridge/nodedefs.h>
 #include <dspbridge/dispdefs.h>
 #include <dspbridge/dspdefs.h>
-#include <dspbridge/dmm.h>
 #include <dspbridge/host_os.h>
 
 /*  ----------------------------------- This */
@@ -234,29 +233,6 @@ extern int dev_get_cmm_mgr(struct dev_object *hdev_obj,
 				  struct cmm_object **mgr);
 
 /*
- *  ======== dev_get_dmm_mgr ========
- *  Purpose:
- *      Retrieve the handle to the dynamic memory manager created for this
- *      device.
- *  Parameters:
- *      hdev_obj:     Handle to device object created with
- *                      dev_create_device().
- *      *mgr:           Ptr to location to store handle.
- *  Returns:
- *      0:        Success.
- *      -EFAULT:    Invalid hdev_obj.
- *  Requires:
- *      mgr != NULL.
- *      DEV Initialized.
- *  Ensures:
- *      0:        *mgr contains a handle to a channel manager object,
- *                      or NULL.
- *      else:           *mgr is NULL.
- */
-extern int dev_get_dmm_mgr(struct dev_object *hdev_obj,
-				  struct dmm_object **mgr);
-
-/*
  *  ======== dev_get_cod_mgr ========
  *  Purpose:
  *      Retrieve the COD manager create for this device.
drivers/staging/tidspbridge/include/dspbridge/dmm.h deleted +0 -75

75 lines not on this page · raw message

drivers/staging/tidspbridge/include/dspbridge/drv.h +0 -6
index 427f38b..75a2c9b 100644
@@ -108,12 +108,6 @@ struct dmm_map_object {
 	struct bridge_dma_map_info dma_info;
 };
 
-/* Used for DMM reserved memory accounting */
-struct dmm_rsv_object {
-	struct list_head link;
-	u32 dsp_reserved_addr;
-};
-
 /* New structure (member of process context) abstracts DMM resource info */
 struct dspheap_res_object {
 	s32 heap_allocated;	/* DMM status */
drivers/staging/tidspbridge/pmgr/dev.c +4 -57

113 lines not on this page · raw message

drivers/staging/tidspbridge/pmgr/dmm.c deleted +0 -533

533 lines not on this page · raw message

drivers/staging/tidspbridge/rmgr/node.c +1 -27
index ccb1811..a660247 100644
@@ -56,7 +56,6 @@
 /*  ----------------------------------- This */
 #include <dspbridge/nodepriv.h>
 #include <dspbridge/node.h>
-#include <dspbridge/dmm.h>
 
 /* Static/Dynamic Loader includes */
 #include <dspbridge/dbll.h>
@@ -317,10 +316,6 @@ int node_allocate(struct proc_object *hprocessor,
 	u32 mapped_addr = 0;
 	u32 map_attrs = 0x0;
 	struct dsp_processorstate proc_state;
-#ifdef DSP_DMM_DEBUG
-	struct dmm_object *dmm_mgr;
-	struct proc_object *p_proc_object = (struct proc_object *)hprocessor;
-#endif
 
 	void *node_res;
 
@@ -430,16 +425,6 @@ int node_allocate(struct proc_object *hprocessor,
 	if (status)
 		goto func_cont;
 
-#ifdef DSP_DMM_DEBUG
-	status = dmm_get_handle(p_proc_object, &dmm_mgr);
-	if (!dmm_mgr) {
-		status = DSP_EHANDLE;
-		goto func_cont;
-	}
-
-	dmm_mem_map_dump(dmm_mgr);
-#endif
-
 	map_attrs |= DSP_MAPLITTLEENDIAN;
 	map_attrs |= DSP_MAPELEMSIZE32;
 	map_attrs |= DSP_MAPVIRTUALADDR;
@@ -2499,11 +2484,7 @@ static void delete_node(struct node_object *hnode,
 	struct stream_chnl stream;
 	struct node_msgargs node_msg_args;
 	struct node_taskargs task_arg_obj;
-#ifdef DSP_DMM_DEBUG
-	struct dmm_object *dmm_mgr;
-	struct proc_object *p_proc_object =
-	    (struct proc_object *)hnode->hprocessor;
-#endif
+
 	int status;
 	if (!hnode)
 		goto func_end;
@@ -2564,13 +2545,6 @@ static void delete_node(struct node_object *hnode,
 			status = proc_un_map(hnode->hprocessor, (void *)
 					     task_arg_obj.udsp_heap_addr,
 					     pr_ctxt);
-#ifdef DSP_DMM_DEBUG
-			status = dmm_get_handle(p_proc_object, &dmm_mgr);
-			if (dmm_mgr)
-				dmm_mem_map_dump(dmm_mgr);
-			else
-				status = DSP_EHANDLE;
-#endif
 		}
 	}
 	if (node_type != NODE_MESSAGE) {
drivers/staging/tidspbridge/rmgr/proc.c +0 -23
index 429f354..7a15a02 100644
@@ -39,7 +39,6 @@
 #include <dspbridge/cod.h>
 #include <dspbridge/dev.h>
 #include <dspbridge/procpriv.h>
-#include <dspbridge/dmm.h>
 
 /*  ----------------------------------- Resource Manager */
 #include <dspbridge/mgr.h>
@@ -1078,7 +1077,6 @@ int proc_load(void *hprocessor, const s32 argc_index,
 	s32 cnew_envp;		/* "  " in new_envp[] */
 	s32 nproc_id = 0;	/* Anticipate MP version. */
 	struct dcd_manager *hdcd_handle;
-	struct dmm_object *dmm_mgr;
 	u32 dw_ext_end;
 	u32 proc_id;
 	int brd_state;
@@ -1269,25 +1267,6 @@ int proc_load(void *hprocessor, const s32 argc_index,
 			if (!status)
 				status = cod_get_sym_value(cod_mgr, EXTEND,
 							   &dw_ext_end);
-
-			/* Reset DMM structs and add an initial free chunk */
-			if (!status) {
-				status =
-				    dev_get_dmm_mgr(p_proc_object->hdev_obj,
-						    &dmm_mgr);
-				if (dmm_mgr) {
-					/* Set dw_ext_end to DMM START u8
-					 * address */
-					dw_ext_end =
-					    (dw_ext_end + 1) * DSPWORDSIZE;
-					/* DMM memory is from EXT_END */
-					status = dmm_create_tables(dmm_mgr,
-								   dw_ext_end,
-								   DMMPOOLSIZE);
-				} else {
-					status = -EFAULT;
-				}
-			}
 		}
 	}
 	/* Restore the original argv[0] */
@@ -1390,7 +1369,6 @@ int proc_map(void *hprocessor, void *pmpu_addr, u32 ul_size,
 		map_obj->dsp_addr = (va_align |
 					((u32)pmpu_addr & (PG_SIZE4K - 1)));
 		*pp_map_addr = (void *)map_obj->dsp_addr;
-		pr_err("%s: mapped address %x\n", __func__, *pp_map_addr);
 	} else {
 		remove_mapping_information(pr_ctxt, va_align);
 	}
@@ -1633,7 +1611,6 @@ int proc_un_map(void *hprocessor, void *map_addr,
 	int status = 0;
 	struct proc_object *p_proc_object = (struct proc_object *)hprocessor;
 	u32 va_align;
-	u32 size_align;
 
 	va_align = PG_ALIGN_LOW((u32) map_addr, PG_SIZE4K);
 	if (!p_proc_object) {
Signature · 1 line
1.6.3.3
#12 lore raw

Re: [PATCHv3 01/11] staging: tidspbridge: replace iommu custom for opensource implementation

In reply to Fernando Guzman Lugo

Hi Fernando,

I have few comments below.

Quoted 21 lines
drivers/staging/tidspbridge/core/io_sm.c +1 -1
index 5718645..842b8db 100644
@@ -291,6 +291,7 @@ int bridge_io_on_loaded(struct io_mgr *hio_mgr)
        struct cod_manager *cod_man;
        struct chnl_mgr *hchnl_mgr;
        struct msg_mgr *hmsg_mgr;
+       struct iommu *mmu;
        u32 ul_shm_base;
        u32 ul_shm_base_offset;
        u32 ul_shm_limit;
@@ -313,7 +314,6 @@ int bridge_io_on_loaded(struct io_mgr *hio_mgr)
        struct bridge_ioctl_extproc ae_proc[BRDIOCTL_NUMOFMMUTLB];
        struct cfg_hostres *host_res;
        struct bridge_dev_context *pbridge_context;
-       u32 map_attrs;
        u32 shm0_end;
        u32 ul_dyn_ext_base;
        u32 ul_seg1_size = 0;

drivers/staging/tidspbridge/core/io_sm.c int bridge_io_on_loaded(struct io_mgr *hio_mgr) · line 346

Quoted 10 lines
drivers/staging/tidspbridge/core/io_sm.c +7 -0
@@ -337,6 +337,20 @@ int bridge_io_on_loaded(struct io_mgr *hio_mgr)
                status = -EFAULT;
                goto func_end;
        }
+       mmu = pbridge_context->dsp_mmu;
+
+       if (mmu)
+               iommu_put(mmu);
+       mmu = iommu_get("iva2");
+
+       if (IS_ERR_OR_NULL(mmu)) {

You can use IS_ERR() instead.

[snip]

Quoted 88 lines
drivers/staging/tidspbridge/core/io_sm.c +11 -68
@@ -1122,217 +1081,81 @@ static int bridge_brd_mem_write(struct bridge_dev_context *dev_ctxt,
  *
  *  TODO: Disable MMU while updating the page tables (but that'll stall DSP)
  */
-static int bridge_brd_mem_map(struct bridge_dev_context *dev_ctxt,
-                                 u32 ul_mpu_addr, u32 virt_addr,
-                                 u32 ul_num_bytes, u32 ul_map_attr,
-                                 struct page **mapped_pages)
+static int bridge_brd_mem_map(struct bridge_dev_context *dev_ctx,
+                       u32 uva, u32 da, u32 size, u32 attr,
+                       struct page **usr_pgs)
+
 {
-       u32 attrs;
-       int status = 0;
-       struct bridge_dev_context *dev_context = dev_ctxt;
-       struct hw_mmu_map_attrs_t hw_attrs;
+       int res, w;
+       unsigned pages, i;
+       struct iommu *mmu = dev_ctx->dsp_mmu;
        struct vm_area_struct *vma;
        struct mm_struct *mm = current->mm;
-       u32 write = 0;
-       u32 num_usr_pgs = 0;
-       struct page *mapped_page, *pg;
-       s32 pg_num;
-       u32 va = virt_addr;
-       struct task_struct *curr_task = current;
-       u32 pg_i = 0;
-       u32 mpu_addr, pa;
-
-       dev_dbg(bridge,
-               "%s hDevCtxt %p, pa %x, va %x, size %x, ul_map_attr %x\n",
-               __func__, dev_ctxt, ul_mpu_addr, virt_addr, ul_num_bytes,
-               ul_map_attr);
-       if (ul_num_bytes == 0)
-               return -EINVAL;
+       struct sg_table *sgt;
+       struct scatterlist *sg;
 
-       if (ul_map_attr & DSP_MAP_DIR_MASK) {
-               attrs = ul_map_attr;
-       } else {
-               /* Assign default attributes */
-               attrs = ul_map_attr | (DSP_MAPVIRTUALADDR | DSP_MAPELEMSIZE16);
-       }
-       /* Take mapping properties */
-       if (attrs & DSP_MAPBIGENDIAN)
-               hw_attrs.endianism = HW_BIG_ENDIAN;
-       else
-               hw_attrs.endianism = HW_LITTLE_ENDIAN;
-
-       hw_attrs.mixed_size = (enum hw_mmu_mixed_size_t)
-           ((attrs & DSP_MAPMIXEDELEMSIZE) >> 2);
-       /* Ignore element_size if mixed_size is enabled */
-       if (hw_attrs.mixed_size == 0) {
-               if (attrs & DSP_MAPELEMSIZE8) {
-                       /* Size is 8 bit */
-                       hw_attrs.element_size = HW_ELEM_SIZE8BIT;
-               } else if (attrs & DSP_MAPELEMSIZE16) {
-                       /* Size is 16 bit */
-                       hw_attrs.element_size = HW_ELEM_SIZE16BIT;
-               } else if (attrs & DSP_MAPELEMSIZE32) {
-                       /* Size is 32 bit */
-                       hw_attrs.element_size = HW_ELEM_SIZE32BIT;
-               } else if (attrs & DSP_MAPELEMSIZE64) {
-                       /* Size is 64 bit */
-                       hw_attrs.element_size = HW_ELEM_SIZE64BIT;
-               } else {
-                       /*
-                        * Mixedsize isn't enabled, so size can't be
-                        * zero here
-                        */
-                       return -EINVAL;
-               }
-       }
-       if (attrs & DSP_MAPDONOTLOCK)
-               hw_attrs.donotlockmpupage = 1;
-       else
-               hw_attrs.donotlockmpupage = 0;
+       if (!size || !usr_pgs)
+               return -EINVAL;
 
-       if (attrs & DSP_MAPVMALLOCADDR) {
-               return mem_map_vmalloc(dev_ctxt, ul_mpu_addr, virt_addr,
-                                      ul_num_bytes, &hw_attrs);
-       }
-       /*

drivers/staging/tidspbridge/core/io_sm.c static int bridge_brd_mem_write(struct bridge_dev_context *dev_ctxt, · line 1100

Quoted 10 lines
drivers/staging/tidspbridge/core/io_sm.c +1 -9
-        * Do OS-specific user-va to pa translation.
-        * Combine physically contiguous regions to reduce TLBs.
-        * Pass the translated pa to pte_update.
-        */
-       if ((attrs & DSP_MAPPHYSICALADDR)) {
-               status = pte_update(dev_context, ul_mpu_addr, virt_addr,
-                                   ul_num_bytes, &hw_attrs);
-               goto func_cont;
-       }
+       pages = size / PG_SIZE4K;

Can you ensure 'size' is always PG_SIZE4K aligned?
I don't have so much knowledge about the dsp bridge implementation, but you're testing only if size == 0.

Quoted 156 lines
drivers/staging/tidspbridge/core/io_sm.c +27 -118
-       /*
-        * Important Note: ul_mpu_addr is mapped from user application process
-        * to current process - it must lie completely within the current
-        * virtual memory address space in order to be of use to us here!
-        */
        down_read(&mm->mmap_sem);
-       vma = find_vma(mm, ul_mpu_addr);
-       if (vma)
-               dev_dbg(bridge,
-                       "VMAfor UserBuf: ul_mpu_addr=%x, ul_num_bytes=%x, "
-                       "vm_start=%lx, vm_end=%lx, vm_flags=%lx\n", ul_mpu_addr,
-                       ul_num_bytes, vma->vm_start, vma->vm_end,
-                       vma->vm_flags);
-
-       /*
-        * It is observed that under some circumstances, the user buffer is
-        * spread across several VMAs. So loop through and check if the entire
-        * user buffer is covered
-        */
-       while ((vma) && (ul_mpu_addr + ul_num_bytes > vma->vm_end)) {
-               /* jump to the next VMA region */
+       vma = find_vma(mm, uva);
+       while (vma && (uva + size > vma->vm_end))
                vma = find_vma(mm, vma->vm_end + 1);
-               dev_dbg(bridge,
-                       "VMA for UserBuf ul_mpu_addr=%x ul_num_bytes=%x, "
-                       "vm_start=%lx, vm_end=%lx, vm_flags=%lx\n", ul_mpu_addr,
-                       ul_num_bytes, vma->vm_start, vma->vm_end,
-                       vma->vm_flags);
-       }
+
        if (!vma) {
                pr_err("%s: Failed to get VMA region for 0x%x (%d)\n",
-                      __func__, ul_mpu_addr, ul_num_bytes);
-               status = -EINVAL;
+                                               __func__, uva, size);
                up_read(&mm->mmap_sem);
-               goto func_cont;
+               return -EINVAL;
        }
+       if (vma->vm_flags & (VM_WRITE | VM_MAYWRITE))
+               w = 1;
 
-       if (vma->vm_flags & VM_IO) {
-               num_usr_pgs = ul_num_bytes / PG_SIZE4K;
-               mpu_addr = ul_mpu_addr;
-
-               /* Get the physical addresses for user buffer */
-               for (pg_i = 0; pg_i < num_usr_pgs; pg_i++) {
-                       pa = user_va2_pa(mm, mpu_addr);
-                       if (!pa) {
-                               status = -EPERM;
-                               pr_err("DSPBRIDGE: VM_IO mapping physical"
-                                      "address is invalid\n");
-                               break;
-                       }
-                       if (pfn_valid(__phys_to_pfn(pa))) {
-                               pg = PHYS_TO_PAGE(pa);
-                               get_page(pg);
-                               if (page_count(pg) < 1) {
-                                       pr_err("Bad page in VM_IO buffer\n");
-                                       bad_page_dump(pa, pg);
-                               }
-                       }
-                       status = pte_set(dev_context->pt_attrs, pa,
-                                        va, HW_PAGE_SIZE4KB, &hw_attrs);
-                       if (status)
-                               break;
+       if (vma->vm_flags & VM_IO)
+               i = get_io_pages(mm, uva, pages, usr_pgs);
+       else
+               i = get_user_pages(current, mm, uva, pages, w, 1,
+                                                       usr_pgs, NULL);
+       up_read(&mm->mmap_sem);
 
-                       va += HW_PAGE_SIZE4KB;
-                       mpu_addr += HW_PAGE_SIZE4KB;
-                       pa += HW_PAGE_SIZE4KB;
-               }
-       } else {
-               num_usr_pgs = ul_num_bytes / PG_SIZE4K;
-               if (vma->vm_flags & (VM_WRITE | VM_MAYWRITE))
-                       write = 1;
-
-               for (pg_i = 0; pg_i < num_usr_pgs; pg_i++) {
-                       pg_num = get_user_pages(curr_task, mm, ul_mpu_addr, 1,
-                                               write, 1, &mapped_page, NULL);
-                       if (pg_num > 0) {
-                               if (page_count(mapped_page) < 1) {
-                                       pr_err("Bad page count after doing"
-                                              "get_user_pages on"
-                                              "user buffer\n");
-                                       bad_page_dump(page_to_phys(mapped_page),
-                                                     mapped_page);
-                               }
-                               status = pte_set(dev_context->pt_attrs,
-                                                page_to_phys(mapped_page), va,
-                                                HW_PAGE_SIZE4KB, &hw_attrs);
-                               if (status)
-                                       break;
-
-                               if (mapped_pages)
-                                       mapped_pages[pg_i] = mapped_page;
-
-                               va += HW_PAGE_SIZE4KB;
-                               ul_mpu_addr += HW_PAGE_SIZE4KB;
-                       } else {
-                               pr_err("DSPBRIDGE: get_user_pages FAILED,"
-                                      "MPU addr = 0x%x,"
-                                      "vma->vm_flags = 0x%lx,"
-                                      "get_user_pages Err"
-                                      "Value = %d, Buffer"
-                                      "size=0x%x\n", ul_mpu_addr,
-                                      vma->vm_flags, pg_num, ul_num_bytes);
-                               status = -EPERM;
-                               break;
-                       }
-               }
+       if (i < 0)
+               return i;
+
+       if (i < pages) {
+               res = -EFAULT;
+               goto err_pages;
        }
-       up_read(&mm->mmap_sem);
-func_cont:
-       if (status) {
-               /*
-                * Roll out the mapped pages incase it failed in middle of
-                * mapping
-                */
-               if (pg_i) {
-                       bridge_brd_mem_un_map(dev_context, virt_addr,
-                                          (pg_i * PG_SIZE4K));
-               }
-               status = -EPERM;
+
+       sgt = kzalloc(sizeof(*sgt), GFP_KERNEL);
+       if (!sgt) {
+               res = -ENOMEM;
+               goto err_pages;
        }
-       /*
-        * In any case, flush the TLB
-        * This is called from here instead from pte_update to avoid unnecessary
-        * repetition while mapping non-contiguous physical regions of a virtual
-        * region
-        */
-       flush_all(dev_context);
-       dev_dbg(bridge, "%s status %x\n", __func__, status);
-       return status;
+
+       res = sg_alloc_table(sgt, pages, GFP_KERNEL);
+

drivers/staging/tidspbridge/core/io_sm.c static int bridge_brd_mem_write(struct bridge_dev_context *dev_ctxt, · line 1147

Quoted 10 lines
drivers/staging/tidspbridge/core/io_sm.c +10 -0
+       if (res < 0)
+               goto err_sg;
+
+       for_each_sg(sgt->sgl, sg, sgt->nents, i)
+               sg_set_page(sg, usr_pgs[i], PAGE_SIZE, 0);
+
+       da = iommu_vmap(mmu, da, sgt, IOVMF_ENDIAN_LITTLE | IOVMF_ELSZ_32);
+
+       if (!IS_ERR_VALUE(da))
+               return 0;

It might be a matter of taste, but you could unconditionally return 0 and add a goto in case of error like you're doing in the rest of the function. IMO it would improve readability to point out the code for non-error condition has ended here.

Br,

David

Quoted 12 lines
drivers/staging/tidspbridge/core/io_sm.c +10 -0
+       res = (int)da;
+
+       sg_free_table(sgt);
+err_sg:
+       kfree(sgt);
+       i = pages;
+err_pages:
+       while (i--)
+               put_page(usr_pgs[i]);
+       return res;
 }
 
#13 lore raw

RE: [PATCHv3 01/11] staging: tidspbridge: replace iommu custom for opensource implementation

Quoted 14 lines

-----Original Message-----
From: David Cohen [mailto:[email protected]]
Sent: Wednesday, October 06, 2010 12:33 PM
To: Guzman Lugo, Fernando
Cc: [email protected]; Contreras Felipe (Nokia-MS/Helsinki); Palande Ameya (Nokia-MS/Helsinki); Menon, Nishanth; Doyu Hiroshi (Nokia-MS/Espoo); [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCHv3 01/11] staging: tidspbridge: replace iommu custom for opensource implementation

Quoted 3 lines

Hi Fernando,

I have few comments below.

Hi David,

Thanks for review.

Quoted 27 lines
Quoted 27 lines
drivers/staging/tidspbridge/core/io_sm.c +2 -1
index 5718645..842b8db 100644
@@ -291,6 +291,7 @@ int bridge_io_on_loaded(struct io_mgr *hio_mgr)
        struct cod_manager *cod_man;
        struct chnl_mgr *hchnl_mgr;
        struct msg_mgr *hmsg_mgr;
+       struct iommu *mmu;
        u32 ul_shm_base;
        u32 ul_shm_base_offset;
        u32 ul_shm_limit;
@@ -313,7 +314,6 @@ int bridge_io_on_loaded(struct io_mgr *hio_mgr)
        struct bridge_ioctl_extproc ae_proc[BRDIOCTL_NUMOFMMUTLB];
        struct cfg_hostres *host_res;
        struct bridge_dev_context *pbridge_context;
-       u32 map_attrs;
        u32 shm0_end;
        u32 ul_dyn_ext_base;
        u32 ul_seg1_size = 0;
@@ -337,6 +337,20 @@ int bridge_io_on_loaded(struct io_mgr *hio_mgr)
                status = -EFAULT;
                goto func_end;
        }
+       mmu = pbridge_context->dsp_mmu;
Quoted 9 lines

drivers/staging/tidspbridge/core/io_sm.c int bridge_io_on_loaded(struct io_mgr *hio_mgr) · line 346

Quoted 6 lines
drivers/staging/tidspbridge/core/io_sm.c +6 -0
+
+       if (mmu)
+               iommu_put(mmu);
+       mmu = iommu_get("iva2");
+
+       if (IS_ERR_OR_NULL(mmu)) {

You can use IS_ERR() instead.

The patch are already merged, so I cannot modified this patch. Even tought That change is done when all related code is change to the new file Dsp-mmu.c. Please check patch 7/11.

Quoted 103 lines

[snip]

drivers/staging/tidspbridge/core/io_sm.c static int

Quoted 1 line
drivers/staging/tidspbridge/core/io_sm.c +0 -0
@@ -1122,217 +1081,81 @@ static int

bridge_brd_mem_write(struct bridge_dev_context *dev_ctxt,

drivers/staging/tidspbridge/core/io_sm.c static int · line 1082

Quoted 2 lines
drivers/staging/tidspbridge/core/io_sm.c +0 -0
  *
  *  TODO: Disable MMU while updating the page tables (but

that'll stall DSP)

Quoted 20 lines
drivers/staging/tidspbridge/core/io_sm.c +7 -9
  */
-static int bridge_brd_mem_map(struct bridge_dev_context *dev_ctxt,
-                                 u32 ul_mpu_addr, u32 virt_addr,
-                                 u32 ul_num_bytes, u32 ul_map_attr,
-                                 struct page **mapped_pages)
+static int bridge_brd_mem_map(struct bridge_dev_context *dev_ctx,
+                       u32 uva, u32 da, u32 size, u32 attr,
+                       struct page **usr_pgs)
+
 {
-       u32 attrs;
-       int status = 0;
-       struct bridge_dev_context *dev_context = dev_ctxt;
-       struct hw_mmu_map_attrs_t hw_attrs;
+       int res, w;
+       unsigned pages, i;
+       struct iommu *mmu = dev_ctx->dsp_mmu;
        struct vm_area_struct *vma;
        struct mm_struct *mm = current->mm;
-       u32 write = 0;

drivers/staging/tidspbridge/core/io_sm.c static int · line 1146

Quoted 10 lines
drivers/staging/tidspbridge/core/io_sm.c +0 -10
-       u32 num_usr_pgs = 0;
-       struct page *mapped_page, *pg;
-       s32 pg_num;
-       u32 va = virt_addr;
-       struct task_struct *curr_task = current;
-       u32 pg_i = 0;
-       u32 mpu_addr, pa;
-
-       dev_dbg(bridge,
-               "%s hDevCtxt %p, pa %x, va %x, size %x,

ul_map_attr %x\n",

drivers/staging/tidspbridge/core/io_sm.c static int · line 1147

Quoted 1 line
drivers/staging/tidspbridge/core/io_sm.c +0 -1
-               __func__, dev_ctxt, ul_mpu_addr, virt_addr,

ul_num_bytes,

drivers/staging/tidspbridge/core/io_sm.c static int · line 1156

Quoted 11 lines
drivers/staging/tidspbridge/core/io_sm.c +2 -8
-               ul_map_attr);
-       if (ul_num_bytes == 0)
-               return -EINVAL;
+       struct sg_table *sgt;
+       struct scatterlist *sg;
 
-       if (ul_map_attr & DSP_MAP_DIR_MASK) {
-               attrs = ul_map_attr;
-       } else {
-               /* Assign default attributes */
-               attrs = ul_map_attr | (DSP_MAPVIRTUALADDR |

DSP_MAPELEMSIZE16);

Quoted 30 lines
drivers/staging/tidspbridge/core/io_sm.c +0 -30
-       }
-       /* Take mapping properties */
-       if (attrs & DSP_MAPBIGENDIAN)
-               hw_attrs.endianism = HW_BIG_ENDIAN;
-       else
-               hw_attrs.endianism = HW_LITTLE_ENDIAN;
-
-       hw_attrs.mixed_size = (enum hw_mmu_mixed_size_t)
-           ((attrs & DSP_MAPMIXEDELEMSIZE) >> 2);
-       /* Ignore element_size if mixed_size is enabled */
-       if (hw_attrs.mixed_size == 0) {
-               if (attrs & DSP_MAPELEMSIZE8) {
-                       /* Size is 8 bit */
-                       hw_attrs.element_size = HW_ELEM_SIZE8BIT;
-               } else if (attrs & DSP_MAPELEMSIZE16) {
-                       /* Size is 16 bit */
-                       hw_attrs.element_size = HW_ELEM_SIZE16BIT;
-               } else if (attrs & DSP_MAPELEMSIZE32) {
-                       /* Size is 32 bit */
-                       hw_attrs.element_size = HW_ELEM_SIZE32BIT;
-               } else if (attrs & DSP_MAPELEMSIZE64) {
-                       /* Size is 64 bit */
-                       hw_attrs.element_size = HW_ELEM_SIZE64BIT;
-               } else {
-                       /*
-                        * Mixedsize isn't enabled, so size can't be
-                        * zero here
-                        */
-                       return -EINVAL;
-               }

drivers/staging/tidspbridge/core/io_sm.c static int · line 1194

Quoted 10 lines
drivers/staging/tidspbridge/core/io_sm.c +2 -7
-       }
-       if (attrs & DSP_MAPDONOTLOCK)
-               hw_attrs.donotlockmpupage = 1;
-       else
-               hw_attrs.donotlockmpupage = 0;
+       if (!size || !usr_pgs)
+               return -EINVAL;
 
-       if (attrs & DSP_MAPVMALLOCADDR) {
-               return mem_map_vmalloc(dev_ctxt,

ul_mpu_addr, virt_addr,

drivers/staging/tidspbridge/core/io_sm.c static int · line 1203

Quoted 9 lines
drivers/staging/tidspbridge/core/io_sm.c +0 -9
-                                      ul_num_bytes, &hw_attrs);
-       }
-       /*
-        * Do OS-specific user-va to pa translation.
-        * Combine physically contiguous regions to reduce TLBs.
-        * Pass the translated pa to pte_update.
-        */
-       if ((attrs & DSP_MAPPHYSICALADDR)) {
-               status = pte_update(dev_context,

ul_mpu_addr, virt_addr,

Quoted 8 lines

drivers/staging/tidspbridge/core/io_sm.c static int · line 1100

Quoted 4 lines
drivers/staging/tidspbridge/core/io_sm.c +1 -3
-                                   ul_num_bytes, &hw_attrs);
-               goto func_cont;
-       }
+       pages = size / PG_SIZE4K;

Can you ensure 'size' is always PG_SIZE4K aligned? I don't have so much knowledge about the dsp bridge implementation, but you're testing only if size == 0.

That is checked in proc_map() in .../tidspbridge/rmgr/proc.c

We always receive a PAGE aligned size in bridge_brd_mem_map, I just keep the 0 check for size just for precaution in case Of some overflow when roundup.

Quoted 195 lines

drivers/staging/tidspbridge/core/io_sm.c static int · line 1208

Quoted 4 lines
drivers/staging/tidspbridge/core/io_sm.c +0 -2
-       /*
-        * Important Note: ul_mpu_addr is mapped from user

application process

drivers/staging/tidspbridge/core/io_sm.c static int · line 1209

Quoted 1 line
drivers/staging/tidspbridge/core/io_sm.c +0 -1
-        * to current process - it must lie completely

within the current

drivers/staging/tidspbridge/core/io_sm.c static int · line 1210

Quoted 1 line
drivers/staging/tidspbridge/core/io_sm.c +0 -1
-        * virtual memory address space in order to be of

use to us here!

drivers/staging/tidspbridge/core/io_sm.c static int · line 1216

Quoted 6 lines
drivers/staging/tidspbridge/core/io_sm.c +0 -5
-        */
        down_read(&mm->mmap_sem);
-       vma = find_vma(mm, ul_mpu_addr);
-       if (vma)
-               dev_dbg(bridge,
-                       "VMAfor UserBuf: ul_mpu_addr=%x,

ul_num_bytes=%x, "

drivers/staging/tidspbridge/core/io_sm.c static int · line 1217

Quoted 1 line
drivers/staging/tidspbridge/core/io_sm.c +0 -1
-                       "vm_start=%lx, vm_end=%lx,

vm_flags=%lx\n", ul_mpu_addr,

drivers/staging/tidspbridge/core/io_sm.c static int · line 1222

Quoted 5 lines
drivers/staging/tidspbridge/core/io_sm.c +0 -5
-                       ul_num_bytes, vma->vm_start, vma->vm_end,
-                       vma->vm_flags);
-
-       /*
-        * It is observed that under some circumstances,

the user buffer is

drivers/staging/tidspbridge/core/io_sm.c static int · line 1223

Quoted 1 line
drivers/staging/tidspbridge/core/io_sm.c +0 -1
-        * spread across several VMAs. So loop through and

check if the entire

drivers/staging/tidspbridge/core/io_sm.c static int · line 1226

Quoted 3 lines
drivers/staging/tidspbridge/core/io_sm.c +0 -3
-        * user buffer is covered
-        */
-       while ((vma) && (ul_mpu_addr + ul_num_bytes >

vma->vm_end)) {

drivers/staging/tidspbridge/core/io_sm.c static int · line 1230

Quoted 6 lines
drivers/staging/tidspbridge/core/io_sm.c +2 -3
-               /* jump to the next VMA region */
+       vma = find_vma(mm, uva);
+       while (vma && (uva + size > vma->vm_end))
                vma = find_vma(mm, vma->vm_end + 1);
-               dev_dbg(bridge,
-                       "VMA for UserBuf ul_mpu_addr=%x

ul_num_bytes=%x, "

drivers/staging/tidspbridge/core/io_sm.c static int · line 1231

Quoted 1 line
drivers/staging/tidspbridge/core/io_sm.c +0 -1
-                       "vm_start=%lx, vm_end=%lx,

vm_flags=%lx\n", ul_mpu_addr,

drivers/staging/tidspbridge/core/io_sm.c static int · line 1107

Quoted 6 lines
drivers/staging/tidspbridge/core/io_sm.c +1 -3
-                       ul_num_bytes, vma->vm_start, vma->vm_end,
-                       vma->vm_flags);
-       }
+
        if (!vma) {
                pr_err("%s: Failed to get VMA region for

0x%x (%d)\n",

drivers/staging/tidspbridge/core/io_sm.c static int · line 1108

Quoted 3 lines
drivers/staging/tidspbridge/core/io_sm.c +1 -2
-                      __func__, ul_mpu_addr, ul_num_bytes);
-               status = -EINVAL;
+                                               __func__,

uva, size);

Quoted 7 lines
drivers/staging/tidspbridge/core/io_sm.c +3 -1
                up_read(&mm->mmap_sem);
-               goto func_cont;
+               return -EINVAL;
        }
+       if (vma->vm_flags & (VM_WRITE | VM_MAYWRITE))
+               w = 1;
 

drivers/staging/tidspbridge/core/io_sm.c static int · line 1252

Quoted 10 lines
drivers/staging/tidspbridge/core/io_sm.c +0 -10
-       if (vma->vm_flags & VM_IO) {
-               num_usr_pgs = ul_num_bytes / PG_SIZE4K;
-               mpu_addr = ul_mpu_addr;
-
-               /* Get the physical addresses for user buffer */
-               for (pg_i = 0; pg_i < num_usr_pgs; pg_i++) {
-                       pa = user_va2_pa(mm, mpu_addr);
-                       if (!pa) {
-                               status = -EPERM;
-                               pr_err("DSPBRIDGE: VM_IO

mapping physical"

drivers/staging/tidspbridge/core/io_sm.c static int · line 1260

Quoted 8 lines
drivers/staging/tidspbridge/core/io_sm.c +0 -8
-                                      "address is invalid\n");
-                               break;
-                       }
-                       if (pfn_valid(__phys_to_pfn(pa))) {
-                               pg = PHYS_TO_PAGE(pa);
-                               get_page(pg);
-                               if (page_count(pg) < 1) {
-                                       pr_err("Bad page in

VM_IO buffer\n");

drivers/staging/tidspbridge/core/io_sm.c static int · line 1265

Quoted 5 lines
drivers/staging/tidspbridge/core/io_sm.c +0 -5
-                                       bad_page_dump(pa, pg);
-                               }
-                       }
-                       status = pte_set(dev_context->pt_attrs, pa,
-                                        va,

HW_PAGE_SIZE4KB, &hw_attrs);

drivers/staging/tidspbridge/core/io_sm.c static int · line 1119

Quoted 7 lines
drivers/staging/tidspbridge/core/io_sm.c +5 -2
-                       if (status)
-                               break;
+       if (vma->vm_flags & VM_IO)
+               i = get_io_pages(mm, uva, pages, usr_pgs);
+       else
+               i = get_user_pages(current, mm, uva, pages, w, 1,
+

usr_pgs, NULL);

drivers/staging/tidspbridge/core/io_sm.c static int · line 1279

Quoted 13 lines
drivers/staging/tidspbridge/core/io_sm.c +1 -11
+       up_read(&mm->mmap_sem);
 
-                       va += HW_PAGE_SIZE4KB;
-                       mpu_addr += HW_PAGE_SIZE4KB;
-                       pa += HW_PAGE_SIZE4KB;
-               }
-       } else {
-               num_usr_pgs = ul_num_bytes / PG_SIZE4K;
-               if (vma->vm_flags & (VM_WRITE | VM_MAYWRITE))
-                       write = 1;
-
-               for (pg_i = 0; pg_i < num_usr_pgs; pg_i++) {
-                       pg_num = get_user_pages(curr_task,

mm, ul_mpu_addr, 1,

drivers/staging/tidspbridge/core/io_sm.c static int · line 1280

Quoted 1 line
drivers/staging/tidspbridge/core/io_sm.c +0 -1
-                                               write, 1,

&mapped_page, NULL);

drivers/staging/tidspbridge/core/io_sm.c static int · line 1283

Quoted 3 lines
drivers/staging/tidspbridge/core/io_sm.c +0 -3
-                       if (pg_num > 0) {
-                               if (page_count(mapped_page) < 1) {
-                                       pr_err("Bad page

count after doing"

drivers/staging/tidspbridge/core/io_sm.c static int · line 1286

Quoted 3 lines
drivers/staging/tidspbridge/core/io_sm.c +0 -3
-                                              "get_user_pages on"
-                                              "user buffer\n");
-

bad_page_dump(page_to_phys(mapped_page),

drivers/staging/tidspbridge/core/io_sm.c static int · line 1289

Quoted 3 lines
drivers/staging/tidspbridge/core/io_sm.c +0 -3
-                                                     mapped_page);
-                               }
-                               status =

pte_set(dev_context->pt_attrs,

drivers/staging/tidspbridge/core/io_sm.c static int · line 1290

Quoted 1 line
drivers/staging/tidspbridge/core/io_sm.c +0 -1
-

page_to_phys(mapped_page), va,

drivers/staging/tidspbridge/core/io_sm.c static int · line 1291

Quoted 1 line
drivers/staging/tidspbridge/core/io_sm.c +0 -1
-

HW_PAGE_SIZE4KB, &hw_attrs);

drivers/staging/tidspbridge/core/io_sm.c static int · line 1296

Quoted 5 lines
drivers/staging/tidspbridge/core/io_sm.c +0 -5
-                               if (status)
-                                       break;
-
-                               if (mapped_pages)
-                                       mapped_pages[pg_i]

= mapped_page;

drivers/staging/tidspbridge/core/io_sm.c static int · line 1301

Quoted 5 lines
drivers/staging/tidspbridge/core/io_sm.c +0 -5
-
-                               va += HW_PAGE_SIZE4KB;
-                               ul_mpu_addr += HW_PAGE_SIZE4KB;
-                       } else {
-                               pr_err("DSPBRIDGE:

get_user_pages FAILED,"

drivers/staging/tidspbridge/core/io_sm.c static int · line 1307

Quoted 6 lines
drivers/staging/tidspbridge/core/io_sm.c +0 -6
-                                      "MPU addr = 0x%x,"
-                                      "vma->vm_flags = 0x%lx,"
-                                      "get_user_pages Err"
-                                      "Value = %d, Buffer"
-                                      "size=0x%x\n", ul_mpu_addr,
-                                      vma->vm_flags,

pg_num, ul_num_bytes);

Quoted 6 lines
drivers/staging/tidspbridge/core/io_sm.c +2 -4
-                               status = -EPERM;
-                               break;
-                       }
-               }
+       if (i < 0)
+               return i;

drivers/staging/tidspbridge/core/io_sm.c static int · line 1317

Quoted 10 lines
drivers/staging/tidspbridge/core/io_sm.c +4 -5
+
+       if (i < pages) {
+               res = -EFAULT;
+               goto err_pages;
        }
-       up_read(&mm->mmap_sem);
-func_cont:
-       if (status) {
-               /*
-                * Roll out the mapped pages incase it

failed in middle of

drivers/staging/tidspbridge/core/io_sm.c static int · line 1321

Quoted 4 lines
drivers/staging/tidspbridge/core/io_sm.c +0 -4
-                * mapping
-                */
-               if (pg_i) {
-                       bridge_brd_mem_un_map(dev_context,

virt_addr,

drivers/staging/tidspbridge/core/io_sm.c static int · line 1328

Quoted 12 lines
drivers/staging/tidspbridge/core/io_sm.c +5 -6
-                                          (pg_i * PG_SIZE4K));
-               }
-               status = -EPERM;
+
+       sgt = kzalloc(sizeof(*sgt), GFP_KERNEL);
+       if (!sgt) {
+               res = -ENOMEM;
+               goto err_pages;
        }
-       /*
-        * In any case, flush the TLB
-        * This is called from here instead from pte_update

to avoid unnecessary

drivers/staging/tidspbridge/core/io_sm.c static int · line 1329

Quoted 1 line
drivers/staging/tidspbridge/core/io_sm.c +0 -1
-        * repetition while mapping non-contiguous physical

regions of a virtual

Quoted 16 lines
drivers/staging/tidspbridge/core/io_sm.c +11 -5
-        * region
-        */
-       flush_all(dev_context);
-       dev_dbg(bridge, "%s status %x\n", __func__, status);
-       return status;
+
+       res = sg_alloc_table(sgt, pages, GFP_KERNEL);
+
+       if (res < 0)
+               goto err_sg;
+
+       for_each_sg(sgt->sgl, sg, sgt->nents, i)
+               sg_set_page(sg, usr_pgs[i], PAGE_SIZE, 0);
+
+       da = iommu_vmap(mmu, da, sgt, IOVMF_ENDIAN_LITTLE |
+ IOVMF_ELSZ_32);
Quoted 8 lines

drivers/staging/tidspbridge/core/io_sm.c static int · line 1148

Quoted 3 lines
drivers/staging/tidspbridge/core/io_sm.c +3 -0
+
+       if (!IS_ERR_VALUE(da))
+               return 0;

It might be a matter of taste, but you could unconditionally return 0 and add a goto in case of error like you're doing in the rest of the function. IMO it would improve readability to point out the code for non-error condition has ended here.

You mean?

                if (!IS_ERR_VALUE(da))
                        goto error;
                return 0;

error:

I thought that, but a goto that just skip one line of code does Not look good to me. Also you don't need to look deeper to realize That is the sucessful case, also the "return 0" gives you a clue :). Moreover I am getting rid of a goto and the lable that are not needed.

Thanks for the comments,
Fernando Guzman Lugo.

Quoted 19 lines

Br,

David

Quoted 12 lines
drivers/staging/tidspbridge/core/io_sm.c +10 -0
+       res = (int)da;
+
+       sg_free_table(sgt);
+err_sg:
+       kfree(sgt);
+       i = pages;
+err_pages:
+       while (i--)
+               put_page(usr_pgs[i]);
+       return res;
 }
 
#14 lore raw

Re: [PATCHv3 01/11] staging: tidspbridge: replace iommu custom for opensource implementation

In reply to Fernando Guzman Lugo
Quoted 4 lines · Fernando Guzman Lugo

Now the tidspbridge uses the API's from
iovmm module.

NAK. This patch doesn't work... I guess it's supposed to.

So far I've found these errors, but it still doesn't work, maybe we should start thinking of reverting the whole iommu stuff:

(quoted diff) +0 -0

b/drivers/staging/tidspbridge/core/io_sm.c
index 842b8db..16cf246 100644

drivers/staging/tidspbridge/core/io_sm.c +17 -0
@@ -541,6 +541,14 @@ int bridge_io_on_loaded(struct io_mgr *hio_mgr)
 					ae_proc[ndx].ul_dsp_va *
 					hio_mgr->word_size, page_size[i]);
 				ndx++;
+			} else {
+				u32 tmp_curr;
+				tmp_curr = iommu_kmap(mmu, va_curr, pa_curr, page_size[i],
+						IOVMF_ENDIAN_LITTLE | IOVMF_ELSZ_32);
+				if (IS_ERR_VALUE(tmp_curr)) {
+					status = (int)tmp_curr;
+					goto func_end;
+				}
 			}
 			pa_curr += page_size[i];
 			va_curr += page_size[i];
@@ -593,6 +601,15 @@ int bridge_io_on_loaded(struct io_mgr *hio_mgr)
 					"DSP_VA 0x%x\n", ae_proc[ndx].ul_gpp_pa,
 					ae_proc[ndx].ul_dsp_va);
 				ndx++;
+			} else {
+				u32 tmp_curr;
+				tmp_curr = iommu_kmap(mmu,
+						hio_mgr->ext_proc_info.ty_tlb[i].ul_dsp_virt,
+						hio_mgr->ext_proc_info.ty_tlb[i].ul_gpp_phys,
+						0x100000,
+						IOVMF_ENDIAN_LITTLE | IOVMF_ELSZ_32);
+				if (IS_ERR_VALUE(tmp_curr))
+					status = (int)tmp_curr;
 			}
 		}
 		if (status)
(quoted diff) +0 -0

b/drivers/staging/tidspbridge/core/tiomap3430.c
index c2f5105..92774fc 100644

drivers/staging/tidspbridge/core/tiomap3430.c +0 -0
@@ -1195,7 +1195,7 @@ static int get_io_pages(struct mm_struct *mm,

u32 uva, unsigned pages,
struct page *pg;

for (i = 0; i < pages; i++) {
- pa = user_va2_pa(mm, uva);
+ pa = user_va2_pa(mm, uva + i * PAGE_SIZE);

if (!pfn_valid(__phys_to_pfn(pa)))
break;

Signature · 1 line
Felipe Contreras
#15 lore raw

Re: [PATCHv3 01/11] staging: tidspbridge: replace iommu custom for opensource implementation

Hi,

Quoted 11 lines · Felipe Contreras
Quoted 4 lines · Fernando Guzman Lugo

Now the tidspbridge uses the API's from
iovmm module.

NAK. This patch doesn't work... I guess it's supposed to.

So far I've found these errors, but it still doesn't work, maybe we should start thinking of reverting the whole iommu stuff:

I also tested it with the userspace-dspbridge tools and it doesn't work for me either.

Maybe it's better to revert this patch series for now and re-submit it when all necessary patches get merged and it actually works on top of the staging-next tree?

Regards,
Ionut.

#16 lore raw

Re: [PATCHv3 01/11] staging: tidspbridge: replace iommu custom for opensource implementation

Quoted 12 lines · Ionut Nicu
Quoted 10 lines · Felipe Contreras
Quoted 4 lines · Fernando Guzman Lugo

Now the tidspbridge uses the API's from
iovmm module.

NAK. This patch doesn't work... I guess it's supposed to.

So far I've found these errors, but it still doesn't work, maybe we should start thinking of reverting the whole iommu stuff:

Quoted 6 lines

I also tested it with the userspace-dspbridge tools and it doesn't work for me either.

Maybe it's better to revert this patch series for now and re-submit it when all necessary patches get merged and it actually works on top of the staging-next tree?

I was thinking that rather than reverting it might make sense to have configuration option to choose from one to the other. I'm trying to minimize the changes on this patch to see what else I can catch, apply the fixes on top of staging-next, and then add support for the old mmu part, hopefully in a form that is similar to the current iommu.

Signature · 1 line
Felipe Contreras
#17 lore raw
In reply to Fernando Guzman Lugo
Quoted 2 lines · Fernando Guzman Lugo

This set of patches remove the dspbridge custom mmu implementation and use iommu module instead.

I have tried this, it works for simple tests, but not real use-cases. I applied all your iommu patches. How did you test this?

Signature · 1 line
Felipe Contreras
#18 lore raw
Quoted 13 lines

-----Original Message-----
From: Felipe Contreras [mailto:[email protected]]
Sent: Sunday, October 10, 2010 12:33 PM
To: Guzman Lugo, Fernando
Cc: [email protected]; [email protected]; [email protected]; Menon, Nishanth; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCHv3 00/11] staging tidspbridge: iommu migration

Quoted 8 lines
Quoted 1 line · Fernando Guzman Lugo

This set of patches remove the dspbridge custom mmu

implementation and

Quoted 1 line

use iommu module instead.

I have tried this, it works for simple tests, but not real use-cases. I applied all your iommu patches. How did you test this?

Have you applied:

- "scatterlist: define SG chain for arm architecture"
- "iovmm: replace __iounmap with omap_iounmap"
- "iovmm: add superpages support to fixed da address"
- "iovmm: IVA2 MMU range is from 0x11000000 to 0xFFFFFFFF"
- "iovmm: no gap checking for fixed address"

Also make sure your baseline have this patch:

- "omap:iommu-load cam register before flushing the entry"

What kind of error are you getting?

I don't have a complete framework to test MM testcases at this moment I did not stress test but a bridge level, and they were good, just some Mailbox issues beucase of the lack of some patches. So I was waiting All missing patches are merge in order to do more stressing testing because I think there is some race conditions in iommu module that need to be fixed.

You can email me the case and erros you are facing privately and I will Check them, maybe it is because of missing patches.

Regards,
Fernando.

Quoted 4 lines

--
Felipe Contreras

#19 lore raw
Quoted 9 lines · Fernando
Quoted 8 lines
Quoted 1 line · Fernando Guzman Lugo

This set of patches remove the dspbridge custom mmu

implementation and

Quoted 1 line

use iommu module instead.

I have tried this, it works for simple tests, but not real use-cases. I applied all your iommu patches. How did you test this?

Quoted 7 lines

Have you applied:

- "scatterlist: define SG chain for arm architecture"
- "iovmm: replace __iounmap with omap_iounmap"
- "iovmm: add superpages support to fixed da address"
- "iovmm: IVA2 MMU range is from 0x11000000 to 0xFFFFFFFF"
- "iovmm: no gap checking for fixed address"

Yes.

Quoted 3 lines

Also make sure your baseline have this patch:

- "omap:iommu-load cam register before flushing the entry"

Huh? That's not even in v2.6.36-rc7, in which baseline is this supposed to be in? Anyway, I'll try adding that.

Quoted 1 line

What kind of error are you getting?

Node allocation failing IIRC.

Quoted 1 line

I don't have a complete framework to test MM testcases at this moment

See:
http://felipec.wordpress.com/2010/10/08/my-arm-development-notes/

I even prepared a tarball so you just need to extract it on your device. It's not difficult to test this with GStreamer, and I don't see how you can be confident that they indeed work without testing some real use-cases. Anyway, I'll try that missing patch.

Cheers.

Signature · 1 line
Felipe Contreras
#20 lore raw
Quoted 33 lines

-----Original Message-----
From: Felipe Contreras [mailto:[email protected]]
Sent: Tuesday, October 12, 2010 6:21 AM
To: Guzman Lugo, Fernando
Cc: [email protected]; [email protected]; [email protected]; Menon, Nishanth; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCHv3 00/11] staging tidspbridge: iommu migration

Quoted 7 lines · Fernando
Quoted 7 lines
Quoted 1 line · Fernando Guzman Lugo

This set of patches remove the dspbridge custom mmu

implementation and

Quoted 1 line

use iommu module instead.

I have tried this, it works for simple tests, but not real

use-cases.

Quoted 9 lines
Quoted 1 line

I applied all your iommu patches. How did you test this?

Have you applied:

- "scatterlist: define SG chain for arm architecture"
- "iovmm: replace __iounmap with omap_iounmap"
- "iovmm: add superpages support to fixed da address"
- "iovmm: IVA2 MMU range is from 0x11000000 to 0xFFFFFFFF"
- "iovmm: no gap checking for fixed address"

Quoted 8 lines

Yes.

Quoted 3 lines

Also make sure your baseline have this patch:

- "omap:iommu-load cam register before flushing the entry"

Huh? That's not even in v2.6.36-rc7, in which baseline is this supposed to be in? Anyway, I'll try adding that.

That's is in latest Hiroshi's tree and it is really needed, Otherwise You will have wrong traslations which can cause unexpected behavior.

Quoted 4 lines
Quoted 2 lines

What kind of error are you getting?

Node allocation failing IIRC.

Is it falling to map the Heap??
I mean you see this trace?

	if (status)
		pr_err("%s: Failed to map memory for Heap: 0x%x\n",
		       __func__, status);

Otherwise, I don't see how that fail is related with iommu changes.

Quoted 4 lines
Quoted 2 lines

I don't have a complete framework to test MM testcases at

this moment

Quoted 8 lines

See:
http://felipec.wordpress.com/2010/10/08/my-arm-development-notes/

I even prepared a tarball so you just need to extract it on your device. It's not difficult to test this with GStreamer, and I don't see how you can be confident that they indeed work without testing some real use-cases. Anyway, I'll try that missing patch.

Most of time real use-cases are not so stressing like testcases We can make to test under real stress in order to find out corner cases. However when I test it was pretty stable and just few erros because staging Does not have latest mailbox patches. Also I test in a .35 version of staging. So now I am using a branch with all new patches and I will recheck and test Again any possible issue. Also I will look at your gstreamer fail too.

Regards,
Fernando.

Quoted 6 lines

Cheers.

--
Felipe Contreras

#21 lore raw
Quoted 24 lines · Fernando
Quoted 24 lines
Quoted 7 lines · Fernando
Quoted 7 lines
Quoted 1 line · Fernando Guzman Lugo

This set of patches remove the dspbridge custom mmu

implementation and

Quoted 1 line

use iommu module instead.

I have tried this, it works for simple tests, but not real

use-cases.

Quoted 9 lines
Quoted 1 line

I applied all your iommu patches. How did you test this?

Have you applied:

- "scatterlist: define SG chain for arm architecture"
- "iovmm: replace __iounmap with omap_iounmap"
- "iovmm: add superpages support to fixed da address"
- "iovmm: IVA2 MMU range is from 0x11000000 to 0xFFFFFFFF"
- "iovmm: no gap checking for fixed address"

Yes.

Quoted 2 lines

Also make sure your baseline have this patch:

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

- "omap:iommu-load cam register before flushing the entry"

Huh? That's not even in v2.6.36-rc7, in which baseline is this supposed to be in? Anyway, I'll try adding that.

That's is in latest Hiroshi's tree and it is really needed, Otherwise You will have wrong traslations which can cause unexpected behavior.

Now I applied that, still fails.

Quoted 4 lines
Quoted 3 lines
Quoted 1 line

What kind of error are you getting?

Node allocation failing IIRC.

Quoted 8 lines

Is it falling to map the Heap??
I mean you see this trace?

       if (status)
               pr_err("%s: Failed to map memory for Heap: 0x%x\n", __func__, status);

Otherwise, I don't see how that fail is related with iommu changes.

Nope.

Quoted 12 lines
Quoted 11 lines
Quoted 1 line

I don't have a complete framework to test MM testcases at

this moment

See:
http://felipec.wordpress.com/2010/10/08/my-arm-development-notes/

I even prepared a tarball so you just need to extract it on your device. It's not difficult to test this with GStreamer, and I don't see how you can be confident that they indeed work without testing some real use-cases. Anyway, I'll try that missing patch.

Quoted 6 lines

Most of time real use-cases are not so stressing like testcases We can make to test under real stress in order to find out corner cases. However when I test it was pretty stable and just few erros because staging Does not have latest mailbox patches. Also I test in a .35 version of staging. So now I am using a branch with all new patches and I will recheck and test Again any possible issue. Also I will look at your gstreamer fail too.

Well, in my experience it's the other way around, the stress test-cases don't catch the errors that happen on real use-case scenarios, no matter how extensive they are. This is a good example.

Cheers.

Signature · 1 line
Felipe Contreras
#22 lore raw
Quoted 84 lines

-----Original Message-----
From: Felipe Contreras [mailto:[email protected]]
Sent: Thursday, October 14, 2010 7:27 AM
To: Guzman Lugo, Fernando
Cc: [email protected]; [email protected]; [email protected]; Menon, Nishanth; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCHv3 00/11] staging tidspbridge: iommu migration

Quoted 22 lines · Fernando
Quoted 22 lines
Quoted 7 lines · Fernando
Quoted 7 lines
Quoted 1 line · Fernando Guzman Lugo

This set of patches remove the dspbridge custom mmu

implementation and

Quoted 1 line

use iommu module instead.

I have tried this, it works for simple tests, but not real

use-cases.

Quoted 9 lines
Quoted 1 line

I applied all your iommu patches. How did you test this?

Have you applied:

- "scatterlist: define SG chain for arm architecture"
- "iovmm: replace __iounmap with omap_iounmap"
- "iovmm: add superpages support to fixed da address"
- "iovmm: IVA2 MMU range is from 0x11000000 to 0xFFFFFFFF"
- "iovmm: no gap checking for fixed address"

Yes.

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

Also make sure your baseline have this patch:

- "omap:iommu-load cam register before flushing the entry"

Huh? That's not even in v2.6.36-rc7, in which baseline is this supposed to be in? Anyway, I'll try adding that.

That's is in latest Hiroshi's tree and it is really needed,

Otherwise

Quoted 1 line

You will have wrong traslations which can cause unexpected behavior.

Now I applied that, still fails.

Quoted 4 lines
Quoted 3 lines
Quoted 1 line

What kind of error are you getting?

Node allocation failing IIRC.

Quoted 8 lines

Is it falling to map the Heap??
I mean you see this trace?

       if (status)
               pr_err("%s: Failed to map memory for Heap: 0x%x\n", __func__, status);

Otherwise, I don't see how that fail is related with iommu changes.

Nope.

Quoted 8 lines
Quoted 8 lines
Quoted 1 line

I don't have a complete framework to test MM testcases at

this moment

See:
http://felipec.wordpress.com/2010/10/08/my-arm-development-notes/

I even prepared a tarball so you just need to extract it on your device. It's not difficult to test this with GStreamer,

and I don't

Quoted 4 lines
Quoted 2 lines

see how you can be confident that they indeed work without testing some real use-cases. Anyway, I'll try that missing patch.

Most of time real use-cases are not so stressing like

testcases We can

Quoted 3 lines

make to test under real stress in order to find out corner cases. However when I test it was pretty stable and just few erros because staging Does not have latest mailbox patches. Also I test

in a .35 version of staging.

Quoted 1 line

So now I am using a branch with all new patches and I will

Quoted 8 lines

recheck and

Quoted 1 line

test Again any possible issue. Also I will look at your

gstreamer fail too.

Well, in my experience it's the other way around, the stress test-cases don't catch the errors that happen on real use-case scenarios, no matter how extensive they are. This is a good example.

I am facing some unstability with the latest bridge merge. I am looing into That once it is stable I wil check you testcase too to confirm everything is Working fine.

Thanks,
Fernando.

Quoted 6 lines

Cheers.

--
Felipe Contreras
--

To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#23 lore raw
Quoted 8 lines · Fernando
Quoted 4 lines

Well, in my experience it's the other way around, the stress test-cases don't catch the errors that happen on real use-case scenarios, no matter how extensive they are. This is a good example.

I am facing some unstability with the latest bridge merge. I am looing into That once it is stable I wil check you testcase too to confirm everything is Working fine.

If you want I can provide my working branch on top of .36-rc8 with next-staging merged. If I revert your patches, it works fine.

Signature · 1 line
Felipe Contreras
#24 lore raw
Quoted 20 lines

-----Original Message-----
From: Felipe Contreras [mailto:[email protected]]
Sent: Friday, October 15, 2010 11:28 AM
To: Guzman Lugo, Fernando
Cc: [email protected]; [email protected]; [email protected]; Menon, Nishanth; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCHv3 00/11] staging tidspbridge: iommu migration

Quoted 3 lines · Fernando
Quoted 3 lines

Well, in my experience it's the other way around, the stress test-cases don't catch the errors that happen on real use-case scenarios, no matter how extensive they are. This is a

good example.

Quoted 1 line
Quoted 7 lines
Quoted 1 line

I am facing some unstability with the latest bridge merge.

I am looing

Quoted 2 lines

into That once it is stable I wil check you testcase too to confirm everything is Working fine.

If you want I can provide my working branch on top of .36-rc8 with next-staging merged. If I revert your patches, it works fine.

That could be interested. Can you send me the link?

Regards,
Fernando.

Quoted 4 lines

--
Felipe Contreras

#25 lore raw
Quoted 4 lines · Fernando
Quoted 2 lines

If you want I can provide my working branch on top of .36-rc8 with next-staging merged. If I revert your patches, it works fine.

That could be interested. Can you send me the link?

There you go:
git://gitorious.org/~felipec/linux-omap/felipec.git (fc-dsp-work)

HEAD works, HEAD^ doesn't.

Signature · 1 line
Felipe Contreras
#26 lore raw
Quoted 11 lines · Felipe Contreras
Quoted 4 lines · Fernando
Quoted 2 lines

If you want I can provide my working branch on top of .36-rc8 with next-staging merged. If I revert your patches, it works fine.

That could be interested. Can you send me the link?

There you go:
git://gitorious.org/~felipec/linux-omap/felipec.git (fc-dsp-work)

HEAD works, HEAD^ doesn't.

Great, can you please also let us know what if anything should be still queued for the merge window that's about to open?

I've lost track of the dspbridge mutations by now..

Tony

#27 lore raw
Quoted 11 lines · Tony Lindgren
Quoted 10 lines · Felipe Contreras
Quoted 4 lines · Fernando
Quoted 2 lines

If you want I can provide my working branch on top of .36-rc8 with next-staging merged. If I revert your patches, it works fine.

That could be interested. Can you send me the link?

There you go:
git://gitorious.org/~felipec/linux-omap/felipec.git (fc-dsp-work)

Quoted 6 lines
Quoted 1 line

HEAD works, HEAD^ doesn't.

Great, can you please also let us know what if anything should be still queued for the merge window that's about to open?

I've lost track of the dspbridge mutations by now..

We would need these:
http://article.gmane.org/gmane.linux.kernel/1044209
http://article.gmane.org/gmane.linux.ports.arm.omap/45076 (just sent)

The first one is in staging-next, you have ack'ed it, but Paul nak'ed it. We would need it on mainline if dsp has any chances of working there.

Signature · 1 line
Felipe Contreras