staging tidspbridge: iommu migration
v4 cover staging tidspbridge: iommu migration
DO-NOT-APPLY to staging yet.
Rework and rebase of the previous set of patches for iommu migration[1].
Reorganized the patches to avoid several iterations to change the same code.
Patches were tested with an OMAP3630 board, with both, basic samples and gst-dsp; these are dependant on patch:
"OMAP: iovmm: fix SW flags passed by user"[2].
[1] http://bit.ly/lUxbRO
[2] http://bit.ly/mgSrr8
Fernando Guzman Lugo (3):
staging: tidspbridge: remove custom mmu code
staging: tidspbridge: remove dmm module
staging: tidspbridge: decouple mmu functions from regular code
Omar Ramirez Luna (3):
staging: tidspbridge: introduce mapping search based on device
address
staging: tidspbridge: replace custom mmu for omap iommu framework
staging: tidspbridge: mapping support when SG_CHAIN is not defined
drivers/staging/tidspbridge/Kconfig | 11 + 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 | 396 +++++++ drivers/staging/tidspbridge/core/io_sm.c | 181 +--- drivers/staging/tidspbridge/core/tiomap3430.c | 1087 +++----------------- drivers/staging/tidspbridge/core/tiomap3430_pwr.c | 6 +- drivers/staging/tidspbridge/core/tiomap_io.c | 14 +- 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 | 13 - .../tidspbridge/include/dspbridge/dsp_mmu.h | 33 + .../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 | 36 +- drivers/staging/tidspbridge/rmgr/drv.c | 14 - drivers/staging/tidspbridge/rmgr/drv_interface.c | 2 - drivers/staging/tidspbridge/rmgr/node.c | 57 +- drivers/staging/tidspbridge/rmgr/proc.c | 224 +--- 31 files changed, 684 insertions(+), 3454 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
PATCH v4 1/6 staging: tidspbridge: introduce mapping search based on device address
Create function find_containing_mapping_da to search mapping objects given the dsp va instead of the mpu va, in preparation to delete dmm functions altogether.
--- drivers/staging/tidspbridge/rmgr/proc.c | 41 +++++++++++++++++++++++++++++- 1 files changed, 39 insertions(+), 2 deletions(-)
drivers/staging/tidspbridge/rmgr/proc.c +39 -2
@@ -231,6 +231,37 @@ out:return map_obj; } +static struct dmm_map_object *find_containing_mapping_da ( +struct process_context *pr_ctxt, +u32 dsp_addr) +{ +struct dmm_map_object *map_obj; + +pr_debug ("%s: looking for virt 0x%x\n" , __func__, dsp_addr); + +spin_lock (&pr_ctxt->dmm_map_lock); +list_for_each_entry (map_obj, &pr_ctxt->dmm_map_list, link) { +pr_debug ("%s: candidate: mpu_addr 0x%x virt 0x%x size 0x%x\n" , + __func__, + map_obj->mpu_addr, + map_obj->dsp_addr, + map_obj->size); + +if (map_obj->dsp_addr == dsp_addr) { +pr_debug ("%s: match!\n" , __func__); + goto out; + } +pr_debug ("%s: candidate didn't match\n" , __func__); + } + + map_obj =NULL ; + +pr_err ("%s: failed to find given map info\n" , __func__); +out: +spin_unlock (&pr_ctxt->dmm_map_lock); +return map_obj; +} +static int find_first_page_in_cache (struct dmm_map_object *map_obj,unsigned long mpu_addr) {
@@ -1703,6 +1734,7 @@ int proc_un_map(void *hprocessor, void *map_addr,int status =0 ;struct proc_object *p_proc_object = (struct proc_object *)hprocessor;struct dmm_object *dmm_mgr; +struct dmm_map_object *dmo;u32 va_align;u32 size_align;
@@ -1725,10 +1757,15 @@ int proc_un_map(void *hprocessor, void *map_addr,* This function returns error if the VA is not mapped */ status =dmm_un_map_memory (dmm_mgr, (u32 ) va_align, &size_align); + + dmo =find_containing_mapping_da (pr_ctxt, (u32 )map_addr); +if (!dmo) + goto unmap_failed; +/* Remove mapping from the page tables. */ if (!status) { status = (*p_proc_object->intf_fxns->brd_mem_un_map) - (p_proc_object->bridge_context, va_align, size_align); + (p_proc_object->bridge_context, va_align, dmo->size); }if (status)
@@ -1739,7 +1776,7 @@ int proc_un_map(void *hprocessor, void *map_addr,* from dmm_map_list, so that mapped memory resource tracking * remains uptodate */ -remove_mapping_information (pr_ctxt, (u32 ) map_addr, size_align); +remove_mapping_information (pr_ctxt, (u32 ) map_addr, dmo->size); unmap_failed:mutex_unlock (&proc_lock);
Signature · 1 line
1.7.1
PATCH v4 2/6 staging: tidspbridge: replace custom mmu for omap iommu framework
In reply to Omar Ramirez LunaUse omap iommu framework to control IVA mmu and map/unmap buffers to the dsp.
Changes to select IOMMU module and IVA IOMMU support are needed when using tidspbridge, Kconfig has been updated for that.
Remove code from proc_reserve/un_reserve which is intended to manage the available virtual address space, since iovmm does that.
BEWARE: Due to SG_CHAIN not being reviewed/fully-tested within the ARM architecture, if not selected, sg_alloc_table can't allocate SG tables representing large buffers (usually ~2MB+), this limitation translates into a panic if attempted.
--- drivers/staging/tidspbridge/Kconfig | 10 + drivers/staging/tidspbridge/core/_deh.h | 2 + drivers/staging/tidspbridge/core/_tiomap.h | 16 +- drivers/staging/tidspbridge/core/io_sm.c | 177 +----- drivers/staging/tidspbridge/core/tiomap3430.c | 676 +++++++------------- drivers/staging/tidspbridge/core/tiomap3430_pwr.c | 2 +- drivers/staging/tidspbridge/core/tiomap_io.c | 12 +- drivers/staging/tidspbridge/core/ue_deh.c | 100 +-- .../tidspbridge/include/dspbridge/dspdefs.h | 3 +- drivers/staging/tidspbridge/rmgr/proc.c | 95 +--- 10 files changed, 326 insertions(+), 767 deletions(-)
drivers/staging/tidspbridge/Kconfig +10 -0
@@ -6,6 +6,8 @@ menuconfig TIDSPBRIDGE tristate "DSP Bridge driver" depends on ARCH_OMAP3 select OMAP_MBOX_FWK + select OMAP_IOMMU + select OMAP_IOMMU_IVA2 help DSP/BIOS Bridge is designed for platforms that contain a GPP and one or more attached DSPs. The GPP is considered the master or
@@ -31,6 +33,14 @@ config TIDSPBRIDGE_MEMPOOL_SIZE Allocate specified size of memory at booting time to avoid allocation failure under heavy memory fragmentation after some use time. +config TIDSPBRIDGE_DMM_SIZE + hex "DMM capable memory size (Byte)" + depends on TIDSPBRIDGE + default "0x10000000" + help + Memory size of DSP virtual address for Dynamic Memory Mapping. + Please make sure the size is 4K aligned. + config TIDSPBRIDGE_DEBUG bool "Debug Support" depends on TIDSPBRIDGE
drivers/staging/tidspbridge/core/_deh.h +2 -0
@@ -32,4 +32,6 @@ struct deh_mgr { struct tasklet_struct dpc_tasklet; }; +int mmu_fault_isr (struct iommu *mmu,u32 da,u32 iommu_errs,void *priv); +#endif /* _DEH_ */
drivers/staging/tidspbridge/core/_tiomap.h +15 -1
@@ -34,6 +34,8 @@#include <mach-omap2/cm2xxx_3xxx.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 */
@@ -317,6 +319,17 @@ 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 *dev_obj;/* Handle to Bridge device object. */
@@ -339,7 +352,8 @@ struct bridge_dev_context {u32 internal_size;/* Internal memory size */ 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 +15 -162
232 lines not on this page · raw message
drivers/staging/tidspbridge/core/tiomap3430.c +220 -448
824 lines not on this page · raw message
drivers/staging/tidspbridge/core/tiomap3430_pwr.c +1 -1
@@ -333,7 +333,7 @@ int wake_dsp(struct bridge_dev_context *dev_context, void *pargs)omap_mbox_restore_ctx (dev_context->mbox);/* Access MMU SYS CONFIG register to generate a short wakeup */ -readl (resources->dmmu_base +0x10 ); +iommu_read_reg (dev_context->dsp_mmu,MMU_SYSCONFIG ); dev_context->brd_state =BRD_RUNNING ;
drivers/staging/tidspbridge/core/tiomap_io.c +6 -6
@@ -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 ].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 ].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 ].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 ].gpp_va; + dev_context->sh_s.seg0_va; }else { dw_ext_prog_virt_mem = host_res->mem_base[1 ]; dw_ext_prog_virt_mem +=
drivers/staging/tidspbridge/core/ue_deh.c +36 -64
162 lines not on this page · raw message
drivers/staging/tidspbridge/include/dspbridge/dspdefs.h +1 -2
@@ -175,7 +175,6 @@ typedef int(*fxn_brd_memwrite) (struct bridge_dev_contexttypedef int (*fxn_brd_memmap ) (struct bridge_dev_context * dev_ctxt,u32 ul_mpu_addr,u32 virt_addr,u32 ul_num_bytes, -u32 map_attr,struct page **mapped_pages);/*
@@ -195,7 +194,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 +16 -79
164 lines not on this page · raw message
Signature · 1 line
1.7.1
PATCH v4 3/6 staging: tidspbridge: mapping support when SG_CHAIN is not defined
In reply to Omar Ramirez LunaIf ARCH_HAS_SG_CHAIN is not defined a scatter-gather table can hold a fixed number of entries, otherwise it results in a panic when allocating bigger tables.
Use generic allocator to manage the mapped memory in such cases and ignore iovmm functions.
--- drivers/staging/tidspbridge/Kconfig | 1 + drivers/staging/tidspbridge/core/tiomap3430.c | 94 +++++++++++++++++++- .../tidspbridge/include/dspbridge/dspdefs.h | 3 +- drivers/staging/tidspbridge/rmgr/proc.c | 3 +- 4 files changed, 96 insertions(+), 5 deletions(-)
drivers/staging/tidspbridge/Kconfig +1 -0
@@ -8,6 +8,7 @@ menuconfig TIDSPBRIDGE select OMAP_MBOX_FWK select OMAP_IOMMU select OMAP_IOMMU_IVA2 + select GENERIC_ALLOCATOR help DSP/BIOS Bridge is designed for platforms that contain a GPP and one or more attached DSPs. The GPP is considered the master or
drivers/staging/tidspbridge/core/tiomap3430.c +91 -3
157 lines not on this page · raw message
drivers/staging/tidspbridge/include/dspbridge/dspdefs.h +2 -1
@@ -194,7 +194,8 @@ typedef int(*fxn_brd_memmap) (struct bridge_dev_context*/ typedef int (*fxn_brd_memunmap ) (struct bridge_dev_context * dev_ctxt, -u32 da); +u32 da,size_t size, +struct page **usr_pgs);/* * ======== bridge_brd_stop ========
drivers/staging/tidspbridge/rmgr/proc.c +2 -1
@@ -1731,7 +1731,8 @@ int proc_un_map(void *hprocessor, void *map_addr,/* Remove mapping from the page tables. */ status = (*p_proc_object->intf_fxns->brd_mem_un_map) - (p_proc_object->bridge_context, va_align); + (p_proc_object->bridge_context, va_align, dmo->size, + dmo->pages);if (status) goto unmap_failed;
Signature · 1 line
1.7.1
PATCH v4 4/6 staging: tidspbridge: remove custom mmu code
In reply to Omar Ramirez LunaFrom: Fernando Guzman Lugo <[email protected]>
This code is not needed anymore.
--- drivers/staging/tidspbridge/Makefile | 3 +- drivers/staging/tidspbridge/core/_tiomap.h | 3 - drivers/staging/tidspbridge/core/io_sm.c | 4 - drivers/staging/tidspbridge/core/tiomap3430.c | 427 --------------- 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/cfgdefs.h | 1 - .../staging/tidspbridge/include/dspbridge/drv.h | 3 - .../tidspbridge/include/dspbridge/dspioctl.h | 7 - drivers/staging/tidspbridge/rmgr/drv.c | 4 - 16 files changed, 2 insertions(+), 1581 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
@@ -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-y := $(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 -3
@@ -37,7 +37,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>
@@ -340,7 +339,6 @@ struct bridge_dev_context {*/ u32 dsp_ext_base_addr;/* See the comment above */ u32 api_reg_base;/* API mem map'd registers */ -void __iomem *dsp_mmu_base;/* DSP MMU Mapped registers */ u32 api_clk_base;/* CLK Registers */ u32 dsp_clk_m2_base;/* DSP Clock Module m2 */ u32 public_rhea;/* Pub Rhea */
@@ -366,7 +364,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/io_sm.c +0 -4
@@ -40,10 +40,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 -427
511 lines not on this page · raw message
drivers/staging/tidspbridge/core/tiomap3430_pwr.c +0 -4
@@ -31,10 +31,6 @@#include <dspbridge/dev.h> #include <dspbridge/io.h> -/* ------------------------------------ Hardware Abstraction Layer */ -#include <hw_defs.h> -#include <hw_mmu.h> -#include <dspbridge/pwr.h> /* ----------------------------------- Bridge Driver */
drivers/staging/tidspbridge/core/tiomap_io.c +1 -1
@@ -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 ,SZ_64K ); 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/cfgdefs.h +0 -1
@@ -55,7 +55,6 @@ struct cfg_hostres {void __iomem *per_base;u32 per_pm_base; u32 core_pm_base; - void __iomem *dmmu_base; };#endif /* CFGDEFS_ */
drivers/staging/tidspbridge/include/dspbridge/drv.h +0 -3
@@ -55,9 +55,6 @@ struct drv_object;#define OMAP_CORE_PRM_BASE 0x48306A00#define OMAP_CORE_PRM_SIZE 0x1000 -#define OMAP_DMMU_BASE 0x5D000000 -#define OMAP_DMMU_SIZE 0x1000 -/* GPP PROCESS CLEANUP Data structures */ /* New structure (member of process context) abstracts NODE resource info */
drivers/staging/tidspbridge/include/dspbridge/dspioctl.h +0 -7
@@ -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.
@@ -60,9 +56,6 @@ struct bridge_ioctl_extproc {/* GPP virtual address. __va does not work for ioremapped addresses */ u32 gpp_va; u32 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_ */
drivers/staging/tidspbridge/rmgr/drv.c +0 -4
@@ -689,7 +689,6 @@ static int request_bridge_resources(struct cfg_hostres *res)/* First window is for DSP internal memory */ dev_dbg (bridge,"mem_base[0] 0x%x\n" , host_res->mem_base[0 ]);dev_dbg (bridge,"mem_base[3] 0x%x\n" , host_res->mem_base[3 ]); -dev_dbg (bridge,"dmmu_base %p\n" , host_res->dmmu_base);/* for 24xx base port is not mapping the mamory for DSP * internal memory TODO Do a ioremap here */
@@ -743,8 +742,6 @@ int drv_request_bridge_res_dsp(void **phost_resources) OMAP_PER_PRM_SIZE); host_res->core_pm_base = (u32 )ioremap (OMAP_CORE_PRM_BASE ,OMAP_CORE_PRM_SIZE ); - host_res->dmmu_base =ioremap (OMAP_DMMU_BASE , -OMAP_DMMU_SIZE );dev_dbg (bridge,"mem_base[0] 0x%x\n" , host_res->mem_base[0 ]);
@@ -756,7 +753,6 @@ int drv_request_bridge_res_dsp(void **phost_resources) host_res->mem_base[3]);dev_dbg (bridge,"mem_base[4] 0x%x\n" , host_res->mem_base[4 ]); -dev_dbg (bridge,"dmmu_base %p\n" , host_res->dmmu_base); shm_size = drv_datap->shm_size;if (shm_size >=0x10000 ) {
Signature · 1 line
1.7.1
PATCH v4 5/6 staging: tidspbridge: remove dmm module
In reply to Omar Ramirez LunaFrom: Fernando Guzman Lugo <[email protected]>
With iommu migration in place, there is no need to manage the dsp va space with dmm module or proc_reserve/unreserve functions.
Deprecate reserve/un_reserve ioctls, given that there is a heavy usage of these functions, print error message only if dynamic debug is enabled.
--- 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 | 10 - .../staging/tidspbridge/include/dspbridge/proc.h | 46 -- drivers/staging/tidspbridge/pmgr/dev.c | 61 +--- drivers/staging/tidspbridge/pmgr/dmm.c | 533 -------------------- drivers/staging/tidspbridge/pmgr/dspapi.c | 36 +- drivers/staging/tidspbridge/rmgr/drv.c | 10 - drivers/staging/tidspbridge/rmgr/drv_interface.c | 2 - drivers/staging/tidspbridge/rmgr/node.c | 57 +-- drivers/staging/tidspbridge/rmgr/proc.c | 90 ---- 13 files changed, 18 insertions(+), 929 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
@@ -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/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
@@ -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
@@ -27,7 +27,6 @@#include <dspbridge/nodedefs.h> #include <dspbridge/disp.h> #include <dspbridge/dspdefs.h> -#include <dspbridge/dmm.h> #include <dspbridge/host_os.h> /* ----------------------------------- This */
@@ -197,29 +196,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 -10
@@ -89,12 +89,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 stream resource info */ struct strm_res_object {s32 stream_allocated;/* Stream status */
@@ -135,10 +129,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; -/* Stream resources */ struct idr *stream_id; };
drivers/staging/tidspbridge/include/dspbridge/proc.h +0 -46
56 lines not on this page · raw message
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/pmgr/dspapi.c +8 -28
@@ -993,27 +993,11 @@ 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)->processor; - -if ((args->args_proc_rsvmem.size <=0 ) || - (args->args_proc_rsvmem.size & (PG_SIZE4K -1 )) !=0 ) -return -EINVAL ; - - status =proc_reserve_memory (hprocessor, - args->args_proc_rsvmem.size, &prsv_addr, - pr_ctxt); -if (!status) { -if (put_user (prsv_addr, args->args_proc_rsvmem.rsv_addr)) { - status = -EINVAL ; -proc_un_reserve_memory (args->args_proc_rsvmem. - processor, prsv_addr, pr_ctxt); - } - } -return status; +dev_dbg (bridge,"%s: deprecated dspbridge ioctl\n" , __func__); +return 0 ; }/*
@@ -1042,15 +1026,11 @@ 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)->processor; - - status =proc_un_reserve_memory (hprocessor, - args->args_proc_unrsvmem.rsv_addr, - pr_ctxt); -return status; +dev_dbg (bridge,"%s: deprecated dspbridge ioctl\n" , __func__); +return 0 ; }/*
drivers/staging/tidspbridge/rmgr/drv.c +0 -10
@@ -144,7 +144,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) {
@@ -155,15 +154,6 @@ int drv_remove_all_dmm_res_elements(void *process_ctxt) " 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->processor, (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
@@ -508,8 +508,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/node.c +5 -52
94 lines not on this page · raw message
drivers/staging/tidspbridge/rmgr/proc.c +0 -90
144 lines not on this page · raw message
Signature · 1 line
1.7.1
PATCH v4 6/6 staging: tidspbridge: decouple mmu functions from regular code
In reply to Omar Ramirez LunaFrom: Fernando Guzman Lugo <[email protected]>
Create a new dsp mmu file containing the functions needed to interact with iommu block (map, unmap, mmufault handling, etc).
While at it, give meaningful names to map and unmap functions and remove them from bridge's pointer-to-func structure.
--- drivers/staging/tidspbridge/Makefile | 2 +- drivers/staging/tidspbridge/core/_deh.h | 3 - drivers/staging/tidspbridge/core/dsp_mmu.c | 396 ++++++++++++++++++++ drivers/staging/tidspbridge/core/tiomap3430.c | 271 +------------- drivers/staging/tidspbridge/core/ue_deh.c | 87 +----- .../tidspbridge/include/dspbridge/dsp_mmu.h | 33 ++ .../tidspbridge/include/dspbridge/dspdefs.h | 44 --- drivers/staging/tidspbridge/pmgr/dev.c | 2 - drivers/staging/tidspbridge/rmgr/proc.c | 13 +- 9 files changed, 442 insertions(+), 409 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
@@ -2,7 +2,7 @@ obj-$(CONFIG_TIDSPBRIDGE) += bridgedriver.o libgen = 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/cmm.o pmgr/dbll.o
drivers/staging/tidspbridge/core/_deh.h +0 -3
@@ -27,9 +27,6 @@struct deh_mgr {struct bridge_dev_context *bridge_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,u32 da,u32 iommu_errs,void *priv);
drivers/staging/tidspbridge/core/dsp_mmu.c new file +396 -0
396 lines not on this page · raw message
drivers/staging/tidspbridge/core/tiomap3430.c +4 -267
328 lines not on this page · raw message
drivers/staging/tidspbridge/core/ue_deh.c +1 -86
123 lines not on this page · raw message
drivers/staging/tidspbridge/include/dspbridge/dsp_mmu.h new file +33 -0
@@ -0,0 +1,33 @@ +/* +* Copyright (C) 2011 Texas Instruments, Inc. +* +* This package is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +* +* THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR +* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED +* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. +*/ + +#ifndef _DSP_MMU_ +#define _DSP_MMU_ + +#include <linux/string.h> +#include <linux/mutex.h> +#include <linux/spinlock.h> +#include <linux/genalloc.h> + +#include <plat/iommu.h> +#include <plat/iovmm.h> + +struct bridge_dev_context ; + +u32 user_to_dsp_map (struct bridge_dev_context *dev_ctx,u32 uva,u32 da, +u32 size,struct page **usr_pgs); +int user_to_dsp_unmap (struct bridge_dev_context *dev_ctx,u32 da,size_t size, +struct page **usr_pgs); +struct iommu *dsp_mmu_init (void ); +void dsp_mmu_exit (struct iommu *mmu); + +#endif /* _DSP_MMU_ */
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
@@ -1038,8 +1038,6 @@ static void store_interface_fxns(struct bridge_drv_interface *drv_fxns,STORE_FXN (fxn_brd_setstate, brd_set_state);STORE_FXN (fxn_brd_memcopy, brd_mem_copy);STORE_FXN (fxn_brd_memwrite, brd_mem_write); -STORE_FXN (fxn_brd_memmap, brd_mem_map); -STORE_FXN (fxn_brd_memunmap, brd_mem_un_map);STORE_FXN (fxn_chnl_create, chnl_create);STORE_FXN (fxn_chnl_destroy, chnl_destroy);STORE_FXN (fxn_chnl_open, chnl_open);
drivers/staging/tidspbridge/rmgr/proc.c +7 -6
@@ -21,6 +21,7 @@#include <linux/dma-mapping.h> #include <linux/scatterlist.h> #include <dspbridge/host_os.h> +#include <dspbridge/dsp_mmu.h> /* ----------------------------------- DSP/BIOS Bridge */ #include <dspbridge/dbdefs.h>
@@ -1392,9 +1393,10 @@ int proc_map(void *hprocessor, void *pmpu_addr, u32 ul_size,if (!map_obj) { status = -ENOMEM ; }else { - va_align = (*p_proc_object->intf_fxns->brd_mem_map) - (p_proc_object->bridge_context, pa_align,0 , - size_align, map_obj->pages); + va_align = +user_to_dsp_map (p_proc_object->bridge_context, + pa_align,0 , size_align, + map_obj->pages);if (IS_ERR_VALUE (va_align)) status = va_align; }
@@ -1662,9 +1664,8 @@ int proc_un_map(void *hprocessor, void *map_addr, goto unmap_failed;/* Remove mapping from the page tables. */ - status = (*p_proc_object->intf_fxns->brd_mem_un_map) - (p_proc_object->bridge_context, va_align, dmo->size, - dmo->pages); + status =user_to_dsp_unmap (p_proc_object->bridge_context, va_align, + dmo->size, dmo->pages);if (status) goto unmap_failed;
Signature · 1 line
1.7.1
Quoted 1 line · Omar Ramirez Luna
DO-NOT-APPLY to staging yet.
Then don't send them to me :)
Seriously, why are you sending this with me as the "To:" if you don't want me to do something with them? If you want others to review them, fine, but put their names in the "To:" line, not me.
I really don't care about this driver at all, sorry.
greg k-h
Quoted 4 lines · Greg KH
Quoted 1 line · Omar Ramirez Luna
DO-NOT-APPLY to staging yet.
Then don't send them to me :)
Not a problem.
Thanks,
Omar
Quoted 7 lines · On Thursday 28 April 2011 17:31:46 Omar Ramirez Luna wrote:
Rework and rebase of the previous set of patches for iommu migration[1].
Reorganized the patches to avoid several iterations to change the same code.
Patches were tested with an OMAP3630 board, with both, basic samples and gst-dsp; these are dependant on patch:
"OMAP: iovmm: fix SW flags passed by user"[2].
The code removal in this series looks good, but the move from one proprietary iommu API to another proprietary iommu API seems pointless.
It would be much more helpful if you could convert the tidspbridge code to the dma-mapping API, or to the generic iommu API and provide these interfaces from the omap code.
Arnd
Hi Arnd,
Quoted 9 lines · Arnd Bergmann
Quoted 7 lines · On Thursday 28 April 2011 17:31:46 Omar Ramirez Luna wrote:
Rework and rebase of the previous set of patches for iommu migration[1].
Reorganized the patches to avoid several iterations to change the same code.
Patches were tested with an OMAP3630 board, with both, basic samples and gst-dsp; these are dependant on patch:
"OMAP: iovmm: fix SW flags passed by user"[2].
Quoted 7 lines
The code removal in this series looks good, but the move from one proprietary iommu API to another proprietary iommu API seems pointless.
It would be much more helpful if you could convert the tidspbridge code to the dma-mapping API, or to the generic iommu API and provide these interfaces from the omap code.
Yes, I thought removing a bunch of lines from staging might be good. I'll check what can be done to use generic iommu or dma-mapping.
Thanks,
Omar
Quoted 11 lines · Omar
Quoted 8 lines
The code removal in this series looks good, but the move from one proprietary iommu API to another proprietary iommu API seems pointless.
It would be much more helpful if you could convert the tidspbridge code to the dma-mapping API, or to the generic iommu API and provide these interfaces from the omap code.
Yes, I thought removing a bunch of lines from staging might be good. I'll check what can be done to use generic iommu or dma-mapping.
Ok, excellent. Have you seen the recent discussions on the [email protected] mailing lists? We've been thinking about how it should be done there, and will continue the discussions in the upcoming Linaro@UDS meeting in Budapest next week.
Arnd