From patchwork Mon Dec 20 14:25:34 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 421141 X-Patchwork-Delegate: omar.ramirez@ti.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id oBKEQhBX023073 for ; Mon, 20 Dec 2010 14:27:08 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757926Ab0LTO0q (ORCPT ); Mon, 20 Dec 2010 09:26:46 -0500 Received: from smtp.nokia.com ([147.243.1.48]:33768 "EHLO mgw-sa02.nokia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757922Ab0LTO0p (ORCPT ); Mon, 20 Dec 2010 09:26:45 -0500 Received: from nokia.com (localhost [127.0.0.1]) by mgw-sa02.nokia.com (Switch-3.4.3/Switch-3.4.3) with ESMTP id oBKEQIWp031757; Mon, 20 Dec 2010 16:26:19 +0200 Received: from localhost ([ucofw-nat2.nokia.com [131.228.1.90]]) by mgw-sa02.nokia.com with RELAY id oBKEPpqb031028 ; Mon, 20 Dec 2010 16:25:52 +0200 From: Felipe Contreras To: linux-main , linux-omap , Greg KH , Omar Ramirez Luna Cc: Ohad Ben-Cohen , Fernando Guzman Lugo , Nishanth Menon , Ameya Palande , Felipe Contreras Subject: [PATCH 2/2] staging: tidspbridge: extend dmm_map semaphore Date: Mon, 20 Dec 2010 16:25:34 +0200 Message-Id: <1292855134-14374-3-git-send-email-felipe.contreras@nokia.com> X-Mailer: git-send-email 1.7.3.3 In-Reply-To: <1292855134-14374-1-git-send-email-felipe.contreras@nokia.com> References: <1292855134-14374-1-git-send-email-felipe.contreras@nokia.com> X-Nokia-AV: Clean 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 (demeter1.kernel.org [140.211.167.41]); Mon, 20 Dec 2010 14:27:09 +0000 (UTC) diff --git a/drivers/staging/tidspbridge/rmgr/proc.c b/drivers/staging/tidspbridge/rmgr/proc.c index 77ab5f5..ea2d105 100644 --- a/drivers/staging/tidspbridge/rmgr/proc.c +++ b/drivers/staging/tidspbridge/rmgr/proc.c @@ -203,6 +203,7 @@ static int match_containing_map_obj(struct dmm_map_object *map_obj, mpu_addr + size <= map_obj_end; } +/* must be called while holding dmm_map semaphore */ static struct dmm_map_object *find_containing_mapping( struct process_context *pr_ctxt, u32 mpu_addr, u32 size) @@ -211,7 +212,6 @@ static struct dmm_map_object *find_containing_mapping( pr_debug("%s: looking for mpu_addr 0x%x size 0x%x\n", __func__, mpu_addr, size); - down(&pr_ctxt->dmm_map_sema); 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__, @@ -228,7 +228,6 @@ static struct dmm_map_object *find_containing_mapping( map_obj = NULL; out: - up(&pr_ctxt->dmm_map_sema); return map_obj; } @@ -781,12 +780,14 @@ int proc_begin_dma(void *hprocessor, void *pmpu_addr, u32 ul_size, (u32)pmpu_addr, ul_size, dir); + down(&pr_ctxt->dmm_map_sema); + /* 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; + goto no_map; } if (memory_give_ownership(map_obj, (u32) pmpu_addr, ul_size, dir)) { @@ -795,6 +796,8 @@ int proc_begin_dma(void *hprocessor, void *pmpu_addr, u32 ul_size, status = -EFAULT; } +no_map: + up(&pr_ctxt->dmm_map_sema); err_out: return status; @@ -819,12 +822,14 @@ int proc_end_dma(void *hprocessor, void *pmpu_addr, u32 ul_size, (u32)pmpu_addr, ul_size, dir); + down(&pr_ctxt->dmm_map_sema); + /* 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; + goto no_map; } if (memory_regain_ownership(map_obj, (u32) pmpu_addr, ul_size, dir)) { @@ -834,6 +839,8 @@ int proc_end_dma(void *hprocessor, void *pmpu_addr, u32 ul_size, goto err_out; } +no_map: + up(&pr_ctxt->dmm_map_sema); err_out: return status; }