From patchwork Sun Sep 20 17:47:03 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: s-paulraj@ti.com X-Patchwork-Id: 48930 Received: from devils.ext.ti.com (devils.ext.ti.com [198.47.26.153]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n8KHnC2A016589 for ; Sun, 20 Sep 2009 17:49:12 GMT Received: from dlep33.itg.ti.com ([157.170.170.112]) by devils.ext.ti.com (8.13.7/8.13.7) with ESMTP id n8KHl6PI019096; Sun, 20 Sep 2009 12:47:06 -0500 Received: from linux.omap.com (localhost [127.0.0.1]) by dlep33.itg.ti.com (8.13.7/8.13.7) with ESMTP id n8KHl5xu006964; Sun, 20 Sep 2009 12:47:05 -0500 (CDT) Received: from linux.omap.com (localhost [127.0.0.1]) by linux.omap.com (Postfix) with ESMTP id 997D080627; Sun, 20 Sep 2009 12:47:05 -0500 (CDT) X-Original-To: davinci-linux-open-source@linux.davincidsp.com Delivered-To: davinci-linux-open-source@linux.davincidsp.com Received: from dlep36.itg.ti.com (dlep36.itg.ti.com [157.170.170.91]) by linux.omap.com (Postfix) with ESMTP id C75B780626 for ; Sun, 20 Sep 2009 12:47:04 -0500 (CDT) Received: from legion.dal.design.ti.com (localhost [127.0.0.1]) by dlep36.itg.ti.com (8.13.8/8.13.8) with ESMTP id n8KHl4vL025429; Sun, 20 Sep 2009 12:47:04 -0500 (CDT) Received: from gt5d9d821.telogy.design.ti.com (gt5d9d821.telogy.design.ti.com [158.218.100.23]) by legion.dal.design.ti.com (8.11.7p1+Sun/8.11.7) with ESMTP id n8KHl3Z29160; Sun, 20 Sep 2009 12:47:03 -0500 (CDT) Received: from gt5d9d821.telogy.design.ti.com (localhost.localdomain [127.0.0.1]) by gt5d9d821.telogy.design.ti.com (8.13.1/8.13.1) with ESMTP id n8KHl3Rg020186; Sun, 20 Sep 2009 13:47:03 -0400 Received: (from a0866907@localhost) by gt5d9d821.telogy.design.ti.com (8.13.1/8.13.1/Submit) id n8KHl3wF020183; Sun, 20 Sep 2009 13:47:03 -0400 From: s-paulraj@ti.com To: davinci-linux-open-source@linux.davincidsp.com Date: Sun, 20 Sep 2009 13:47:03 -0400 Message-Id: <1253468823-20160-1-git-send-email-s-paulraj@ti.com> X-Mailer: git-send-email 1.6.0.4 Cc: Subject: [PATCH] DaVinci: EDMA: Fix Bug while obtaining contiguous params X-BeenThere: davinci-linux-open-source@linux.davincidsp.com X-Mailman-Version: 2.1.4 Precedence: list List-Id: davinci-linux-open-source.linux.davincidsp.com List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: davinci-linux-open-source-bounces@linux.davincidsp.com Errors-To: davinci-linux-open-source-bounces@linux.davincidsp.com From: Sandeep Paulraj The reserve_contiguous_params function is used to reserve a set of contiguous PARAMs. If we do not find a complete set of contiguous PARAMs, the functions still has to free every PARAM that it found to be free in the process of finding a complete set and thus marked as "in use". This patch mainly deals with correctly handling the freeing of PARAMs. Signed-off-by: Sandeep Paulraj --- arch/arm/mach-davinci/dma.c | 32 ++++++++++++++++++++++++-------- 1 files changed, 24 insertions(+), 8 deletions(-) diff --git a/arch/arm/mach-davinci/dma.c b/arch/arm/mach-davinci/dma.c index 8eda4c3..b097592 100644 --- a/arch/arm/mach-davinci/dma.c +++ b/arch/arm/mach-davinci/dma.c @@ -515,17 +515,30 @@ static int reserve_contiguous_params(int ctlr, unsigned int id, { int i, j; unsigned int count = num_params; + int stop_param = start_param; + DECLARE_BITMAP(tmp_inuse, EDMA_MAX_PARAMENTRY); for (i = start_param; i < edma_info[ctlr]->num_slots; ++i) { j = EDMA_CHAN_SLOT(i); - if (!test_and_set_bit(j, edma_info[ctlr]->edma_inuse)) + if (!test_and_set_bit(j, edma_info[ctlr]->edma_inuse)) { + /* Record our current beginning slot */ + if (count == num_params) + stop_param = i; + count--; + set_bit(j, tmp_inuse); + if (count == 0) break; - else if (id == EDMA_CONT_PARAMS_FIXED_EXACT) - break; - else - count = num_params; + } else { + clear_bit(j, tmp_inuse); + + if (id == EDMA_CONT_PARAMS_FIXED_EXACT) { + stop_param = i; + break; + } else + count = num_params; + } } /* @@ -534,12 +547,15 @@ static int reserve_contiguous_params(int ctlr, unsigned int id, * of contiguous parameter RAMs but do not find the exact number * requested as we may reach the total number of parameter RAMs */ - if (count) { - for (j = i - num_params + count + 1; j <= i ; ++j) + if (i == edma_info[ctlr]->num_slots) + stop_param = i; + + for (j = start_param; j < stop_param; j++) + if (test_bit(j, tmp_inuse)) clear_bit(j, edma_info[ctlr]->edma_inuse); + if (count) return -EBUSY; - } for (j = i - num_params + 1; j <= i; ++j) memcpy_toio(edmacc_regs_base[ctlr] + PARM_OFFSET(j),