From patchwork Sun Jul 6 18:32:31 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: 4490891 X-Patchwork-Delegate: vinod.koul@intel.com Return-Path: X-Original-To: patchwork-dmaengine@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 633A29F390 for ; Sun, 6 Jul 2014 18:32:57 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7A80320219 for ; Sun, 6 Jul 2014 18:32:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B0965202EC for ; Sun, 6 Jul 2014 18:32:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752396AbaGFScv (ORCPT ); Sun, 6 Jul 2014 14:32:51 -0400 Received: from smtp-out-155.synserver.de ([212.40.185.155]:1261 "EHLO smtp-out-155.synserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752391AbaGFScv (ORCPT ); Sun, 6 Jul 2014 14:32:51 -0400 Received: (qmail 13126 invoked by uid 0); 6 Jul 2014 18:32:49 -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:49 -0000 From: Lars-Peter Clausen To: Vinod Koul , Dan Williams Cc: Boojin Kim , dmaengine@vger.kernel.org, Lars-Peter Clausen Subject: [PATCH 14/15] dmaengine: pl330: Simplify marking a request as unused Date: Sun, 6 Jul 2014 20:32:31 +0200 Message-Id: <1404671552-502-15-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 Instead of storing a special instruction in the command buffer to mark a request as currently unused just set the descriptor field to NULL. Signed-off-by: Lars-Peter Clausen --- drivers/dma/pl330.c | 51 +++++++++++++-------------------------------------- 1 file changed, 13 insertions(+), 38 deletions(-) diff --git a/drivers/dma/pl330.c b/drivers/dma/pl330.c index b31c6c3..105e33e 100644 --- a/drivers/dma/pl330.c +++ b/drivers/dma/pl330.c @@ -245,9 +245,6 @@ enum pl330_byteswap { */ #define MCODE_BUFF_PER_REQ 256 -/* If the _pl330_req is available to the client */ -#define IS_FREE(req) (*((u8 *)((req)->mc_cpu)) == CMD_DMAEND) - /* Use this _only_ to wait on transient states */ #define UNTIL(t, s) while (!(_state(t) & (s))) cpu_relax(); @@ -529,14 +526,12 @@ struct _xfer_spec { static inline bool _queue_empty(struct pl330_thread *thrd) { - return (IS_FREE(&thrd->req[0]) && IS_FREE(&thrd->req[1])) - ? true : false; + return thrd->req[0].desc == NULL && thrd->req[1].desc == NULL; } static inline bool _queue_full(struct pl330_thread *thrd) { - return (IS_FREE(&thrd->req[0]) || IS_FREE(&thrd->req[1])) - ? false : true; + return thrd->req[0].desc != NULL && thrd->req[1].desc != NULL; } static inline bool is_manager(struct pl330_thread *thrd) @@ -948,21 +943,6 @@ static inline void _execute_DBGINSN(struct pl330_thread *thrd, writel(0, regs + DBGCMD); } -/* - * Mark a _pl330_req as free. - * We do it by writing DMAEND as the first instruction - * because no valid request is going to have DMAEND as - * its first instruction to execute. - */ -static void mark_free(struct pl330_thread *thrd, int idx) -{ - struct _pl330_req *req = &thrd->req[idx]; - - _emit_END(0, req->mc_cpu); - - thrd->req_running = -1; -} - static inline u32 _state(struct pl330_thread *thrd) { void __iomem *regs = thrd->dmac->base; @@ -1059,18 +1039,18 @@ static bool _trigger(struct pl330_thread *thrd) return true; idx = 1 - thrd->lstenq; - if (!IS_FREE(&thrd->req[idx])) + if (thrd->req[idx].desc != NULL) { req = &thrd->req[idx]; - else { + } else { idx = thrd->lstenq; - if (!IS_FREE(&thrd->req[idx])) + if (thrd->req[idx].desc != NULL) req = &thrd->req[idx]; else req = NULL; } /* Return if no request */ - if (!req || !req->desc) + if (!req) return true; desc = req->desc; @@ -1438,7 +1418,7 @@ static int pl330_submit_req(struct pl330_thread *thrd, ccr = _prepare_ccr(&desc->rqcfg); - idx = IS_FREE(&thrd->req[0]) ? 0 : 1; + idx = thrd->req[0].desc == NULL ? 0 : 1; xs.ccr = ccr; xs.desc = desc; @@ -1532,8 +1512,7 @@ static void pl330_dotask(unsigned long data) thrd->req[0].desc = NULL; thrd->req[1].desc = NULL; - mark_free(thrd, 0); - mark_free(thrd, 1); + thrd->req_running = -1; /* Clear the reset flag */ pl330->dmac_tbd.reset_chan &= ~(1 << i); @@ -1615,8 +1594,6 @@ static int pl330_update(struct pl330_dmac *pl330) descdone = thrd->req[active].desc; thrd->req[active].desc = NULL; - mark_free(thrd, active); - /* Get going again ASAP */ _start(thrd); @@ -1667,8 +1644,7 @@ static int pl330_chan_ctrl(struct pl330_thread *thrd, enum pl330_chan_op op) thrd->req[0].desc = NULL; thrd->req[1].desc = NULL; - mark_free(thrd, 0); - mark_free(thrd, 1); + thrd->req_running = -1; break; case PL330_OP_ABORT: @@ -1680,7 +1656,7 @@ static int pl330_chan_ctrl(struct pl330_thread *thrd, enum pl330_chan_op op) break; thrd->req[active].desc = NULL; - mark_free(thrd, active); + thrd->req_running = -1; /* Start the next */ case PL330_OP_START: @@ -1741,9 +1717,8 @@ static struct pl330_thread *pl330_request_channel(struct pl330_dmac *pl330) thrd->free = false; thrd->lstenq = 1; thrd->req[0].desc = NULL; - mark_free(thrd, 0); thrd->req[1].desc = NULL; - mark_free(thrd, 1); + thrd->req_running = -1; break; } } @@ -1841,14 +1816,14 @@ static inline void _reset_thread(struct pl330_thread *thrd) thrd->req[0].mc_bus = pl330->mcode_bus + (thrd->id * pl330->mcbufsz); thrd->req[0].desc = NULL; - mark_free(thrd, 0); thrd->req[1].mc_cpu = thrd->req[0].mc_cpu + pl330->mcbufsz / 2; thrd->req[1].mc_bus = thrd->req[0].mc_bus + pl330->mcbufsz / 2; thrd->req[1].desc = NULL; - mark_free(thrd, 1); + + thrd->req_running = -1; } static int dmac_alloc_threads(struct pl330_dmac *pl330)