From patchwork Mon May 24 16:05:17 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ohad Ben Cohen X-Patchwork-Id: 101899 X-Patchwork-Delegate: omar.ramirez@ti.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o4OG65HN017715 for ; Mon, 24 May 2010 16:06:24 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757731Ab0EXQGX (ORCPT ); Mon, 24 May 2010 12:06:23 -0400 Received: from mail-bw0-f46.google.com ([209.85.214.46]:64406 "EHLO mail-bw0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757725Ab0EXQGW (ORCPT ); Mon, 24 May 2010 12:06:22 -0400 Received: by mail-bw0-f46.google.com with SMTP id 7so1076486bwz.19 for ; Mon, 24 May 2010 09:06:22 -0700 (PDT) Received: by 10.204.142.147 with SMTP id q19mr2161512bku.169.1274717181327; Mon, 24 May 2010 09:06:21 -0700 (PDT) Received: from localhost.localdomain (93-173-213-238.bb.netvision.net.il [93.173.213.238]) by mx.google.com with ESMTPS id l1sm19706202bkl.8.2010.05.24.09.06.16 (version=TLSv1/SSLv3 cipher=RC4-MD5); Mon, 24 May 2010 09:06:20 -0700 (PDT) From: Ohad Ben-Cohen To: Cc: Felipe Contreras , Ivan Gomez Castellanos , Kanigeri Hari , Omar Ramirez Luna , Guzman Lugo Fernando , Menon Nishanth , Hiroshi Doyu , Ohad Ben-Cohen Subject: [PATCH v2 6/7] DSPBRIDGE: add dspbridge API to mark end of DMA Date: Mon, 24 May 2010 19:05:17 +0300 Message-Id: <1274717118-15226-7-git-send-email-ohad@wizery.com> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1274717118-15226-1-git-send-email-ohad@wizery.com> References: <1274717118-15226-1-git-send-email-ohad@wizery.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]); Mon, 24 May 2010 16:06:24 +0000 (UTC) diff --git a/drivers/dsp/bridge/rmgr/proc.c b/drivers/dsp/bridge/rmgr/proc.c index 9ab633d..08d1408 100644 --- a/drivers/dsp/bridge/rmgr/proc.c +++ b/drivers/dsp/bridge/rmgr/proc.c @@ -647,6 +647,36 @@ out: return ret; } +static int memory_regain_ownership(struct dmm_map_object *map_obj, + unsigned long start, ssize_t len, enum dma_data_direction dir) +{ + int ret = 0; + unsigned long first_data_page = start >> PAGE_SHIFT; + unsigned long last_data_page = ((u32)(start + len - 1) >> PAGE_SHIFT); + /* calculating the number of pages this area spans */ + unsigned long num_pages = last_data_page - first_data_page + 1; + struct bridge_dma_map_info *dma_info = &map_obj->dma_info; + + if (!dma_info->sg) + goto out; + + if (dma_info->dir != dir || dma_info->num_pages != num_pages) { + pr_err("%s: dma info doesn't match given params\n", __func__); + return -EINVAL; + } + + dma_unmap_sg(bridge, dma_info->sg, num_pages, dma_info->dir); + + pr_debug("%s: dma_map_sg unmapped\n", __func__); + + kfree(dma_info->sg); + + map_obj->dma_info.sg = NULL; + +out: + return ret; +} + /* Cache operation against kernel address instead of users */ static int memory_give_ownership(struct dmm_map_object *map_obj, unsigned long start, ssize_t len, enum dma_data_direction dir) @@ -743,6 +773,44 @@ err_out: return status; } +static int proc_end_dma(void *hprocessor, void *pmpu_addr, u32 ul_size, + enum dma_data_direction dir) +{ + /* Keep STATUS here for future additions to this function */ + int status = 0; + struct process_context *pr_ctxt = (struct process_context *) hprocessor; + struct dmm_map_object *map_obj; + + DBC_REQUIRE(refs > 0); + + if (!pr_ctxt) { + status = -EFAULT; + goto err_out; + } + + pr_debug("%s: addr 0x%x, size 0x%x, type %d\n", __func__, + (u32)pmpu_addr, + ul_size, dir); + + /* find requested memory are in cached mapping information */ + map_obj = find_containing_mapping(pr_ctxt, (u32) pmpu_addr, ul_size); + if (!map_obj) { + pr_err("%s: find_containing_mapping failed\n", __func__); + status = -EFAULT; + goto err_out; + } + + if (memory_regain_ownership(map_obj, (u32) pmpu_addr, ul_size, dir)) { + pr_err("%s: InValid address parameters %p %x\n", + __func__, pmpu_addr, ul_size); + status = -EFAULT; + goto err_out; + } + +err_out: + return status; +} + /* * ======== proc_flush_memory ======== * Purpose: