From patchwork Thu Jul 1 00:00:00 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Guzman Lugo, Fernando" X-Patchwork-Id: 108972 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.4/8.14.3) with ESMTP id o5UNrwa5014167 for ; Wed, 30 Jun 2010 23:53:58 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757538Ab0F3XwG (ORCPT ); Wed, 30 Jun 2010 19:52:06 -0400 Received: from comal.ext.ti.com ([198.47.26.152]:52311 "EHLO comal.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755400Ab0F3Xue (ORCPT ); Wed, 30 Jun 2010 19:50:34 -0400 Received: from dlep35.itg.ti.com ([157.170.170.118]) by comal.ext.ti.com (8.13.7/8.13.7) with ESMTP id o5UNoWum010940 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 30 Jun 2010 18:50:33 -0500 Received: from legion.dal.design.ti.com (localhost [127.0.0.1]) by dlep35.itg.ti.com (8.13.7/8.13.7) with ESMTP id o5UNoW9q004497; Wed, 30 Jun 2010 18:50:32 -0500 (CDT) Received: from localhost (x0095840-desktop.am.dhcp.ti.com [128.247.77.44]) by legion.dal.design.ti.com (8.11.7p1+Sun/8.11.7) with ESMTP id o5UNoWP07705; Wed, 30 Jun 2010 18:50:32 -0500 (CDT) From: Fernando Guzman Lugo To: , Cc: , , , , Fernando Guzman Lugo Subject: [PATCHv3 8/9] dspbridge: add map support for big buffers Date: Wed, 30 Jun 2010 19:00:00 -0500 Message-Id: <1277942401-3566-9-git-send-email-x0095840@ti.com> X-Mailer: git-send-email 1.6.3.3 In-Reply-To: <1277942401-3566-8-git-send-email-x0095840@ti.com> References: <1277942401-3566-1-git-send-email-x0095840@ti.com> <1277942401-3566-2-git-send-email-x0095840@ti.com> <1277942401-3566-3-git-send-email-x0095840@ti.com> <1277942401-3566-4-git-send-email-x0095840@ti.com> <1277942401-3566-5-git-send-email-x0095840@ti.com> <1277942401-3566-6-git-send-email-x0095840@ti.com> <1277942401-3566-7-git-send-email-x0095840@ti.com> <1277942401-3566-8-git-send-email-x0095840@ti.com> Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Wed, 30 Jun 2010 23:53:58 +0000 (UTC) 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);