RE: [PATCH 1/9] dspbridge: replace iommu custom for opensource implementation

2010-07-02 Thread Guzman Lugo, Fernando


> -Original Message-
> From: Hiroshi DOYU [mailto:hiroshi.d...@nokia.com]
> Sent: Friday, July 02, 2010 1:32 AM
> To: Guzman Lugo, Fernando
> Cc: linux-omap@vger.kernel.org; linux-ker...@vger.kernel.org;
> o...@wizery.com; ameya.pala...@nokia.com; felipe.contre...@nokia.com
> Subject: Re: [PATCH 1/9] dspbridge: replace iommu custom for opensource
> implementation
> 
> Hi Fernando,
> 
> From: ext Fernando Guzman Lugo 
> Subject: [PATCH 1/9] dspbridge: replace iommu custom for opensource
> implementation
> Date: Thu, 1 Jul 2010 02:20:52 +0200
> 
> > This patch replace the call to custom dsp mmu implemenation
> > for the once on iommu module.
> >
> > Signed-off-by: Fernando Guzman Lugo 
> > ---
> >  drivers/dsp/bridge/core/_tiomap.h|   16 +
> >  drivers/dsp/bridge/core/io_sm.c  |  114 ++--
> >  drivers/dsp/bridge/core/tiomap3430.c |  501 +--
> ---
> >  drivers/dsp/bridge/core/ue_deh.c |   10 -
> >  4 files changed, 118 insertions(+), 523 deletions(-)
> >
> > diff --git a/drivers/dsp/bridge/core/_tiomap.h
> b/drivers/dsp/bridge/core/_tiomap.h
> > index bf0164e..d13677a 100644
> > --- a/drivers/dsp/bridge/core/_tiomap.h
> > +++ b/drivers/dsp/bridge/core/_tiomap.h
> > @@ -23,6 +23,8 @@
> >  #include 
> >  #include 
> >  #include 
> > +#include 
> > +#include 
> >  #include 
> >  #include 
> >  #include /* for bridge_ioctl_extproc defn
> */
> > @@ -330,6 +332,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 */
> >
> > @@ -374,4 +377,17 @@ extern s32 dsp_debug;
> >   */
> >  int sm_interrupt_dsp(struct bridge_dev_context *dev_context, u16
> mb_val);
> >
> > +static inline void dsp_iotlb_init(struct iotlb_entry *e, u32 da, u32
> pa,
> > +   u32 pgsz)
> > +{
> > +   e->da = da;
> > +   e->pa = pa;
> > +   e->valid = 1;
> > +   e->prsvd = 1;
> > +   e->pgsz = pgsz & MMU_CAM_PGSZ_MASK;
> > +   e->endian = MMU_RAM_ENDIAN_LITTLE;
> > +   e->elsz = MMU_RAM_ELSZ_32;
> > +   e->mixed = 0;
> > +}
> > +
> >  #endif /* _TIOMAP_ */
> > diff --git a/drivers/dsp/bridge/core/io_sm.c
> b/drivers/dsp/bridge/core/io_sm.c
> > index 7fb840d..1f47f8b 100644
> > --- a/drivers/dsp/bridge/core/io_sm.c
> > +++ b/drivers/dsp/bridge/core/io_sm.c
> > @@ -290,6 +290,8 @@ 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;
> > +   struct iotlb_entry e;
> > u32 ul_shm_base;
> > u32 ul_shm_base_offset;
> > u32 ul_shm_limit;
> > @@ -312,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;
> > @@ -336,6 +337,21 @@ 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");
> 
> +   mmu = iommu_get("iva2", mmu_fault_isr);
> 
> I'm considering that it might be better to pass a mmu fault callback
> at this iommu_get.
> 
> What do you think?

That sounds good.

Thanks and regards,
Fernando.


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


Re: [PATCH 1/9] dspbridge: replace iommu custom for opensource implementation

2010-07-01 Thread Hiroshi DOYU
Hi Fernando,

From: ext Fernando Guzman Lugo 
Subject: [PATCH 1/9] dspbridge: replace iommu custom for opensource 
implementation
Date: Thu, 1 Jul 2010 02:20:52 +0200

> This patch replace the call to custom dsp mmu implemenation
> for the once on iommu module.
> 
> Signed-off-by: Fernando Guzman Lugo 
> ---
>  drivers/dsp/bridge/core/_tiomap.h|   16 +
>  drivers/dsp/bridge/core/io_sm.c  |  114 ++--
>  drivers/dsp/bridge/core/tiomap3430.c |  501 
> +-
>  drivers/dsp/bridge/core/ue_deh.c |   10 -
>  4 files changed, 118 insertions(+), 523 deletions(-)
> 
> diff --git a/drivers/dsp/bridge/core/_tiomap.h 
> b/drivers/dsp/bridge/core/_tiomap.h
> index bf0164e..d13677a 100644
> --- a/drivers/dsp/bridge/core/_tiomap.h
> +++ b/drivers/dsp/bridge/core/_tiomap.h
> @@ -23,6 +23,8 @@
>  #include 
>  #include 
>  #include 
> +#include 
> +#include 
>  #include 
>  #include 
>  #include /* for bridge_ioctl_extproc defn */
> @@ -330,6 +332,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 */
> 
> @@ -374,4 +377,17 @@ extern s32 dsp_debug;
>   */
>  int sm_interrupt_dsp(struct bridge_dev_context *dev_context, u16 mb_val);
> 
> +static inline void dsp_iotlb_init(struct iotlb_entry *e, u32 da, u32 pa,
> +   u32 pgsz)
> +{
> +   e->da = da;
> +   e->pa = pa;
> +   e->valid = 1;
> +   e->prsvd = 1;
> +   e->pgsz = pgsz & MMU_CAM_PGSZ_MASK;
> +   e->endian = MMU_RAM_ENDIAN_LITTLE;
> +   e->elsz = MMU_RAM_ELSZ_32;
> +   e->mixed = 0;
> +}
> +
>  #endif /* _TIOMAP_ */
> diff --git a/drivers/dsp/bridge/core/io_sm.c b/drivers/dsp/bridge/core/io_sm.c
> index 7fb840d..1f47f8b 100644
> --- a/drivers/dsp/bridge/core/io_sm.c
> +++ b/drivers/dsp/bridge/core/io_sm.c
> @@ -290,6 +290,8 @@ 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;
> +   struct iotlb_entry e;
> u32 ul_shm_base;
> u32 ul_shm_base_offset;
> u32 ul_shm_limit;
> @@ -312,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;
> @@ -336,6 +337,21 @@ 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");

+   mmu = iommu_get("iva2", mmu_fault_isr);

I'm considering that it might be better to pass a mmu fault callback
at this iommu_get.

What do you think?
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/9] dspbridge: replace iommu custom for opensource implementation

2010-06-30 Thread Fernando Guzman Lugo
This patch replace the call to custom dsp mmu implemenation
for the once on iommu module.

Signed-off-by: Fernando Guzman Lugo 
---
 drivers/dsp/bridge/core/_tiomap.h|   16 +
 drivers/dsp/bridge/core/io_sm.c  |  114 ++--
 drivers/dsp/bridge/core/tiomap3430.c |  501 +-
 drivers/dsp/bridge/core/ue_deh.c |   10 -
 4 files changed, 118 insertions(+), 523 deletions(-)

diff --git a/drivers/dsp/bridge/core/_tiomap.h 
b/drivers/dsp/bridge/core/_tiomap.h
index bf0164e..d13677a 100644
--- a/drivers/dsp/bridge/core/_tiomap.h
+++ b/drivers/dsp/bridge/core/_tiomap.h
@@ -23,6 +23,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 #include 
 #include 
 #include /* for bridge_ioctl_extproc defn */
@@ -330,6 +332,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 */
 
@@ -374,4 +377,17 @@ extern s32 dsp_debug;
  */
 int sm_interrupt_dsp(struct bridge_dev_context *dev_context, u16 mb_val);
 
+static inline void dsp_iotlb_init(struct iotlb_entry *e, u32 da, u32 pa,
+   u32 pgsz)
+{
+   e->da = da;
+   e->pa = pa;
+   e->valid = 1;
+   e->prsvd = 1;
+   e->pgsz = pgsz & MMU_CAM_PGSZ_MASK;
+   e->endian = MMU_RAM_ENDIAN_LITTLE;
+   e->elsz = MMU_RAM_ELSZ_32;
+   e->mixed = 0;
+}
+
 #endif /* _TIOMAP_ */
diff --git a/drivers/dsp/bridge/core/io_sm.c b/drivers/dsp/bridge/core/io_sm.c
index 7fb840d..1f47f8b 100644
--- a/drivers/dsp/bridge/core/io_sm.c
+++ b/drivers/dsp/bridge/core/io_sm.c
@@ -290,6 +290,8 @@ 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;
+   struct iotlb_entry e;
u32 ul_shm_base;
u32 ul_shm_base_offset;
u32 ul_shm_limit;
@@ -312,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;
@@ -336,6 +337,21 @@ 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)) {
+   pr_err("Error in iommu_get\n");
+   pbridge_context->dsp_mmu = NULL;
+   status = -EFAULT;
+   goto func_end;
+   }
+   pbridge_context->dsp_mmu = mmu;
+
status = dev_get_cod_mgr(hio_mgr->hdev_obj, &cod_man);
if (!cod_man) {
status = -EFAULT;
@@ -477,55 +493,16 @@ int bridge_io_on_loaded(struct io_mgr *hio_mgr)
gpp_va_curr = ul_gpp_va;
num_bytes = ul_seg1_size;
 
-   /*
-* Try to fit into TLB entries. If not possible, push them to page
-* tables. It is quite possible that if sections are not on
-* bigger page boundary, we may end up making several small pages.
-* So, push them onto page tables, if that is the case.
-*/
-   map_attrs = 0x;
-   map_attrs = DSP_MAPLITTLEENDIAN;
-   map_attrs |= DSP_MAPPHYSICALADDR;
-   map_attrs |= DSP_MAPELEMSIZE32;
-   map_attrs |= DSP_MAPDONOTLOCK;
-
-   while (num_bytes) {
-   /*
-* To find the max. page size with which both PA & VA are
-* aligned.
-*/
-   all_bits = pa_curr | va_curr;
-   dev_dbg(bridge, "all_bits %x, pa_curr %x, va_curr %x, "
-   "num_bytes %x\n", all_bits, pa_curr, va_curr,
-   num_bytes);
-   for (i = 0; i < 4; i++) {
-   if ((num_bytes >= page_size[i]) && ((all_bits &
-(page_size[i] -
- 1)) == 0)) {
-   status =
-   hio_mgr->intf_fxns->
-   pfn_brd_mem_map(hio_mgr->hbridge_context,
-   pa_curr, va_curr,
-   page_size[i], map_attrs,
-   NULL);
-   if (DSP_FAILED(status))
-   goto func_end;
-   pa_curr += page_size[i];
-   va_curr += page_size[i];
-   gpp