From patchwork Sun Jul 6 18:32:32 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lars-Peter Clausen X-Patchwork-Id: 4490901 X-Patchwork-Delegate: vinod.koul@intel.com Return-Path: X-Original-To: patchwork-dmaengine@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 3E58DBEEAA for ; Sun, 6 Jul 2014 18:32:58 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6686C20219 for ; Sun, 6 Jul 2014 18:32:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7A8732022D for ; Sun, 6 Jul 2014 18:32:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752398AbaGFScw (ORCPT ); Sun, 6 Jul 2014 14:32:52 -0400 Received: from smtp-out-155.synserver.de ([212.40.185.155]:1139 "EHLO smtp-out-155.synserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752395AbaGFScw (ORCPT ); Sun, 6 Jul 2014 14:32:52 -0400 Received: (qmail 13171 invoked by uid 0); 6 Jul 2014 18:32:50 -0000 X-SynServer-TrustedSrc: 1 X-SynServer-AuthUser: lars@metafoo.de X-SynServer-PPID: 12384 Received: from ppp-46-244-166-46.dynamic.mnet-online.de (HELO lars-adi-laptop.fritz.box) [46.244.166.46] by 217.119.54.73 with SMTP; 6 Jul 2014 18:32:50 -0000 From: Lars-Peter Clausen To: Vinod Koul , Dan Williams Cc: Boojin Kim , dmaengine@vger.kernel.org, Lars-Peter Clausen Subject: [PATCH 15/15] dmaengine: pl330: Remove pl330_chan_ctrl() Date: Sun, 6 Jul 2014 20:32:32 +0200 Message-Id: <1404671552-502-16-git-send-email-lars@metafoo.de> X-Mailer: git-send-email 1.8.0 In-Reply-To: <1404671552-502-1-git-send-email-lars@metafoo.de> References: <1404671552-502-1-git-send-email-lars@metafoo.de> Sender: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The pl330_chan_ctrl() function has 3 internal code paths which, except for the locking, do not share any code outside of their sections. One code path is never exercised and can be removed. The other two are mostly just forwards to the _start() and _stop() calls. This patch modifies the code to instead of going via pl330_chan_ctrl() to call _start() and _stop() directly. This allows to completely remove pl330_chan_ctrl(). Signed-off-by: Lars-Peter Clausen --- drivers/dma/pl330.c | 71 ++++++++--------------------------------------------- 1 file changed, 10 insertions(+), 61 deletions(-) diff --git a/drivers/dma/pl330.c b/drivers/dma/pl330.c index 105e33e..bc5878a 100644 --- a/drivers/dma/pl330.c +++ b/drivers/dma/pl330.c @@ -329,15 +329,6 @@ enum pl330_op_err { PL330_ERR_FAIL, }; -enum pl330_chan_op { - /* Start the channel */ - PL330_OP_START, - /* Abort the active xfer */ - PL330_OP_ABORT, - /* Stop xfer and flush queue */ - PL330_OP_FLUSH, -}; - enum dmamov_dst { SAR = 0, CCR, @@ -1623,55 +1614,6 @@ updt_exit: return ret; } -static int pl330_chan_ctrl(struct pl330_thread *thrd, enum pl330_chan_op op) -{ - struct pl330_dmac *pl330; - unsigned long flags; - int ret = 0, active; - - if (!thrd || thrd->free || thrd->dmac->state == DYING) - return -EINVAL; - - pl330 = thrd->dmac; - active = thrd->req_running; - - spin_lock_irqsave(&pl330->lock, flags); - - switch (op) { - case PL330_OP_FLUSH: - /* Make sure the channel is stopped */ - _stop(thrd); - - thrd->req[0].desc = NULL; - thrd->req[1].desc = NULL; - thrd->req_running = -1; - break; - - case PL330_OP_ABORT: - /* Make sure the channel is stopped */ - _stop(thrd); - - /* ABORT is only for the active req */ - if (active == -1) - break; - - thrd->req[active].desc = NULL; - thrd->req_running = -1; - - /* Start the next */ - case PL330_OP_START: - if ((active == -1) && !_start(thrd)) - ret = -EIO; - break; - - default: - ret = -EINVAL; - } - - spin_unlock_irqrestore(&pl330->lock, flags); - return ret; -} - /* Reserve an event */ static inline int _alloc_event(struct pl330_thread *thrd) { @@ -2033,7 +1975,9 @@ static void pl330_tasklet(unsigned long data) fill_queue(pch); /* Make sure the PL330 Channel thread is active */ - pl330_chan_ctrl(pch->thread, PL330_OP_START); + spin_lock(&pch->thread->dmac->lock); + _start(pch->thread); + spin_unlock(&pch->thread->dmac->lock); while (!list_empty(&pch->completed_list)) { dma_async_tx_callback callback; @@ -2133,8 +2077,13 @@ static int pl330_control(struct dma_chan *chan, enum dma_ctrl_cmd cmd, unsigned case DMA_TERMINATE_ALL: spin_lock_irqsave(&pch->lock, flags); - /* FLUSH the PL330 Channel thread */ - pl330_chan_ctrl(pch->thread, PL330_OP_FLUSH); + spin_lock(&pl330->lock); + _stop(pch->thread); + spin_unlock(&pl330->lock); + + pch->thread->req[0].desc = NULL; + pch->thread->req[1].desc = NULL; + pch->thread->req_running = -1; /* Mark all desc done */ list_for_each_entry(desc, &pch->submitted_list, node) {