From: Fernando Guzman Lugo <x0095840@ti.com>
To: <linux-omap@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Cc: <ohad@wizery.com>, <hiroshi.doyu@nokia.com>,
<ameya.palande@nokia.com>, <felipe.contreras@nokia.com>,
Fernando Guzman Lugo <x0095840@ti.com>
Subject: [PATCH 8/9] dspbridge: add map support for big buffers
Date: Wed, 30 Jun 2010 19:20:59 -0500 [thread overview]
Message-ID: <1277943660-4112-9-git-send-email-x0095840@ti.com> (raw)
In-Reply-To: <1277943660-4112-8-git-send-email-x0095840@ti.com>
due to a restriction in scatter gather lists, it can
not be created a list for a buffer bigger than 1MB.
This patch is spliting big mappings into 1MB mappings.
Signed-off-by: Fernando Guzman Lugo <x0095840@ti.com>
---
arch/arm/plat-omap/include/dspbridge/dsp-mmu.h | 2 +-
drivers/dsp/bridge/core/dsp-mmu.c | 55 ++++++++++++++---------
drivers/dsp/bridge/rmgr/proc.c | 3 +-
3 files changed, 36 insertions(+), 24 deletions(-)
diff --git a/arch/arm/plat-omap/include/dspbridge/dsp-mmu.h b/arch/arm/plat-omap/include/dspbridge/dsp-mmu.h
index 266f38b..2e4bf6a 100644
--- a/arch/arm/plat-omap/include/dspbridge/dsp-mmu.h
+++ b/arch/arm/plat-omap/include/dspbridge/dsp-mmu.h
@@ -85,6 +85,6 @@ int user_to_dsp_map(struct iommu *mmu, u32 uva, u32 da, u32 size,
* This function unmaps a user space buffer into DSP virtual address.
*
*/
-int user_to_dsp_unmap(struct iommu *mmu, u32 da);
+int user_to_dsp_unmap(struct iommu *mmu, u32 da, unsigned size);
#endif
diff --git a/drivers/dsp/bridge/core/dsp-mmu.c b/drivers/dsp/bridge/core/dsp-mmu.c
index e8da327..9a46206 100644
--- a/drivers/dsp/bridge/core/dsp-mmu.c
+++ b/drivers/dsp/bridge/core/dsp-mmu.c
@@ -133,7 +133,7 @@ int user_to_dsp_map(struct iommu *mmu, u32 uva, u32 da, u32 size,
struct page **usr_pgs)
{
int res, w;
- unsigned pages, i;
+ unsigned pages, i, j = 0;
struct vm_area_struct *vma;
struct mm_struct *mm = current->mm;
struct sg_table *sgt;
@@ -162,24 +162,31 @@ int user_to_dsp_map(struct iommu *mmu, u32 uva, u32 da, u32 size,
if (res < 0)
return res;
- sgt = kzalloc(sizeof(*sgt), GFP_KERNEL);
+ while (pages) {
+ sgt = kzalloc(sizeof(*sgt), GFP_KERNEL);
- if (!sgt)
- return -ENOMEM;
+ if (!sgt)
+ return -ENOMEM;
- res = sg_alloc_table(sgt, pages, GFP_KERNEL);
+ res = sg_alloc_table(sgt,
+ min((unsigned)SG_MAX_SINGLE_ALLOC, pages), GFP_KERNEL);
+ pages -= min((unsigned)SG_MAX_SINGLE_ALLOC, pages);
- if (res < 0)
- goto err_sg;
+ if (res < 0)
+ goto err_sg;
+
+ for_each_sg(sgt->sgl, sg, sgt->nents, i)
+ sg_set_page(sg, usr_pgs[j++], PAGE_SIZE, 0);
- 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);
- da = iommu_vmap(mmu, da, sgt, IOVMF_ENDIAN_LITTLE | IOVMF_ELSZ_32);
+ if (IS_ERR_VALUE(da)) {
+ res = (int)da;
+ goto err_map;
+ }
- if (IS_ERR_VALUE(da)) {
- res = (int)da;
- goto err_map;
+ da += SG_MAX_SINGLE_ALLOC * PAGE_SIZE;
}
return 0;
@@ -198,21 +205,25 @@ err_sg:
* This function unmaps a user space buffer into DSP virtual address.
*
*/
-int user_to_dsp_unmap(struct iommu *mmu, u32 da)
+int user_to_dsp_unmap(struct iommu *mmu, u32 da, unsigned size)
{
unsigned i;
struct sg_table *sgt;
struct scatterlist *sg;
+ const unsigned max_sz = SG_MAX_SINGLE_ALLOC * PAGE_SIZE;
- sgt = iommu_vunmap(mmu, da);
- if (!sgt)
- return -EFAULT;
-
- for_each_sg(sgt->sgl, sg, sgt->nents, i)
- put_page(sg_page(sg));
+ while (size) {
+ size -= min(max_sz, size);
+ sgt = iommu_vunmap(mmu, da);
+ if (!sgt)
+ return -EFAULT;
- sg_free_table(sgt);
- kfree(sgt);
+ for_each_sg(sgt->sgl, sg, sgt->nents, i)
+ put_page(sg_page(sg));
+ sg_free_table(sgt);
+ kfree(sgt);
+ da += max_sz;
+ }
return 0;
}
diff --git a/drivers/dsp/bridge/rmgr/proc.c b/drivers/dsp/bridge/rmgr/proc.c
index 4f10a41..997918e 100644
--- a/drivers/dsp/bridge/rmgr/proc.c
+++ b/drivers/dsp/bridge/rmgr/proc.c
@@ -1713,7 +1713,8 @@ int proc_un_map(void *hprocessor, void *map_addr,
/* Remove mapping from the page tables. */
if (DSP_SUCCEEDED(status)) {
status = user_to_dsp_unmap(
- p_proc_object->hbridge_context->dsp_mmu, va_align);
+ p_proc_object->hbridge_context->dsp_mmu,
+ va_align, size_align);
}
mutex_unlock(&proc_lock);
--
1.6.3.3
next prev parent reply other threads:[~2010-07-01 0:11 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-07-01 0:20 [PATCH 0/9] dspbridge: iommu migration Fernando Guzman Lugo
2010-07-01 0:20 ` [PATCH 1/9] dspbridge: replace iommu custom for opensource implementation Fernando Guzman Lugo
2010-07-01 0:20 ` [PATCH 2/9] dspbridge: move shared memory iommu maps to tiomap3430.c Fernando Guzman Lugo
2010-07-01 0:20 ` [PATCH 3/9] dspbridge: rename bridge_brd_mem_map/unmap to a proper name Fernando Guzman Lugo
2010-07-01 0:20 ` [PATCH 4/9] dspbridge: remove custom mmu code from tiomap3430.c Fernando Guzman Lugo
2010-07-01 0:20 ` [PATCH 5/9] dspbridge: add mmufault support Fernando Guzman Lugo
2010-07-01 0:20 ` [PATCH 6/9] dspbridge: remove hw directory Fernando Guzman Lugo
2010-07-01 0:20 ` [PATCH 7/9] dspbridge: move all iommu related code to a new file Fernando Guzman Lugo
2010-07-01 0:20 ` Fernando Guzman Lugo [this message]
2010-07-01 0:21 ` [PATCH 9/9] dspbridge: cleanup bridge_dev_context and cfg_hostres structures Fernando Guzman Lugo
2010-07-01 23:36 ` [PATCH 8/9] dspbridge: add map support for big buffers Kanigeri, Hari
2010-07-02 16:27 ` Guzman Lugo, Fernando
2010-07-02 17:02 ` Kanigeri, Hari
2010-07-02 18:39 ` Guzman Lugo, Fernando
2010-08-24 10:09 ` Felipe Contreras
2010-08-24 16:31 ` Guzman Lugo, Fernando
2010-08-24 17:46 ` Felipe Contreras
2010-08-24 18:44 ` Guzman Lugo, Fernando
2010-08-24 18:55 ` Felipe Contreras
2010-08-24 19:05 ` Guzman Lugo, Fernando
2010-08-24 19:13 ` Felipe Contreras
2010-08-24 19:30 ` Guzman Lugo, Fernando
2010-08-24 21:17 ` Felipe Contreras
2010-08-24 21:55 ` Guzman Lugo, Fernando
2010-08-25 6:05 ` Felipe Contreras
2010-08-25 16:00 ` Guzman Lugo, Fernando
2010-08-25 19:18 ` Felipe Contreras
2010-08-25 19:42 ` Guzman Lugo, Fernando
2010-08-26 10:04 ` Felipe Contreras
2010-08-26 13:00 ` Guzman Lugo, Fernando
2010-08-26 6:55 ` FUJITA Tomonori
2010-08-26 12:38 ` Guzman Lugo, Fernando
2010-08-26 12:56 ` FUJITA Tomonori
2010-08-26 13:16 ` Guzman Lugo, Fernando
2010-08-26 14:03 ` FUJITA Tomonori
2010-08-26 14:13 ` Guzman Lugo, Fernando
2010-07-02 6:27 ` [PATCH 5/9] dspbridge: add mmufault support Hiroshi DOYU
2010-07-02 16:37 ` Guzman Lugo, Fernando
2010-07-02 6:32 ` [PATCH 1/9] dspbridge: replace iommu custom for opensource implementation Hiroshi DOYU
2010-07-02 16:40 ` Guzman Lugo, Fernando
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1277943660-4112-9-git-send-email-x0095840@ti.com \
--to=x0095840@ti.com \
--cc=ameya.palande@nokia.com \
--cc=felipe.contreras@nokia.com \
--cc=hiroshi.doyu@nokia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-omap@vger.kernel.org \
--cc=ohad@wizery.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®