From patchwork Thu Mar 10 10:57:34 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Kochetkov X-Patchwork-Id: 8555351 Return-Path: X-Original-To: patchwork-linux-rockchip@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id C651FC0553 for ; Thu, 10 Mar 2016 10:58:12 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A2AFB2034E for ; Thu, 10 Mar 2016 10:58:11 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 83CC12012B for ; Thu, 10 Mar 2016 10:58:10 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1adyIC-0003YV-Im; Thu, 10 Mar 2016 10:58:08 +0000 Received: from mail-lb0-x243.google.com ([2a00:1450:4010:c04::243]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1adyI8-00037A-58 for linux-rockchip@lists.infradead.org; Thu, 10 Mar 2016 10:58:06 +0000 Received: by mail-lb0-x243.google.com with SMTP id h2so7897348lbs.2 for ; Thu, 10 Mar 2016 02:57:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=CczbW3VNvZraadodD78cHVZ1E/bXkXvg7Wd/RXI7yMI=; b=oVa9mU3ak+5IeHEqMP2OYXaDYqPnJsNl/f+YJ11cL2fRbctdtp61CloA4OFIvZATcS iaY4tkBy0mvB3IBJEVhkfx+snhmJE3xr/3MsgU0thc7VtVV1UWqzJ0hD7YmDcYrJSCKs sqD18xuMJ6wh8MpHZOMVDm2AdoD8vXIk8rHNgoBbIFc1Lw0WnoZRCnrXd8p4F+keIlGB zYN/ZDsCZPF8WxjIQIYNtaTvG6lC63OTdBSh+8B9m/onJA5jDNsFPexxFkPkovXhhj+v lGWpJuEMZ08P5pj5nLEL53Mzo1/B95BQ8JraEF9Mbp5gbzKspNcylZw2i615HVr6YJRK W1FQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=CczbW3VNvZraadodD78cHVZ1E/bXkXvg7Wd/RXI7yMI=; b=Zw523P7M4iQSAgQ7KbNNdAgBpbGy1B+rQ61uTc8qp+1nzlDFgWb2ItdHG7HkI/b4J8 VCOrPh3kdy2KQesJXSGDbLJwnLbiGKe8gcv3plGV33AHh+dAm439uMwLCK4vpOXpy9zf y98//foJgG6RCqp1nfalqqsJLtbjp6C2o9rY5piLx0uoKj4Il9Khnc2G66XkGs/vuqqx jJWWfevmCqhZsgL7RSdJ+g3kvzKis5lcAVrgjH6QkGo8N4v/3Y20k4f0jNzJCVj4VUpp 0I5ihdONIYPeN6cyD5Sze/zIwAHOdRXh65j6+dT0f09j6FxXyWtvvNSCgeaXhjVvePVl m3iQ== X-Gm-Message-State: AD7BkJIQa5ASfsbNAr6MMMIY4PKQFQ9M/X9DDaT7dAY+JZYB/M6B7z9Mf9eeZzwcvHdHLw== X-Received: by 10.25.91.71 with SMTP id p68mr754305lfb.55.1457607461650; Thu, 10 Mar 2016 02:57:41 -0800 (PST) Received: from ubuntu.lintech.ru ([185.35.119.87]) by smtp.gmail.com with ESMTPSA id r20sm257305lfd.4.2016.03.10.02.57.39 (version=TLS1_1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 10 Mar 2016 02:57:40 -0800 (PST) From: Alexander Kochetkov To: Vinod Koul , Dan Williams , dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/3 v2] dmaengine: pl330: cleanup quirk pass code Date: Thu, 10 Mar 2016 13:57:34 +0300 Message-Id: <1457607456-30458-1-git-send-email-al.kochet@gmail.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1455798674-10186-1-git-send-email-al.kochet@gmail.com> References: <1455798674-10186-1-git-send-email-al.kochet@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160310_025804_594834_7EAB779A X-CRM114-Status: GOOD ( 16.80 ) X-Spam-Score: 0.6 (/) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-rockchip@lists.infradead.org, Alexander Kochetkov , Heiko Stuebner , Doug Anderson , Caesar Wang MIME-Version: 1.0 Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-0.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RCVD_IN_SBL_CSS, RP_MATCHES_RCVD, T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=no 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 patch partially revert changes introduced by 271e1b86e691 "dmaengine: pl330: add quirk for broken no flushp" The patch add 'quirk' member to 'struct _xfer_spec' and remove 'struct pl330_dmac *pl330' parameter from many intermediate functions. The patch is intended to hide 'struct pl330_dmac' implementation from Microcode generation functions. The patch is here to allow easy backporting following patches to longterm linux 4.1.x. Signed-off-by: Alexander Kochetkov Reviewed-by: Caesar Wang --- drivers/dma/pl330.c | 59 ++++++++++++++++++++++++--------------------------- 1 file changed, 28 insertions(+), 31 deletions(-) diff --git a/drivers/dma/pl330.c b/drivers/dma/pl330.c index 372b435..4abbc71 100644 --- a/drivers/dma/pl330.c +++ b/drivers/dma/pl330.c @@ -534,6 +534,7 @@ struct dma_pl330_desc { struct _xfer_spec { u32 ccr; struct dma_pl330_desc *desc; + int quirks; }; static inline bool _queue_empty(struct pl330_thread *thrd) @@ -1151,14 +1152,13 @@ static inline int _ldst_memtomem(unsigned dry_run, u8 buf[], return off; } -static inline int _ldst_devtomem(struct pl330_dmac *pl330, unsigned dry_run, - u8 buf[], const struct _xfer_spec *pxs, - int cyc) +static inline int _ldst_devtomem(unsigned dry_run, u8 buf[], + const struct _xfer_spec *pxs, int cyc) { int off = 0; enum pl330_cond cond; - if (pl330->quirks & PL330_QUIRK_BROKEN_NO_FLUSHP) + if (pxs->quirks & PL330_QUIRK_BROKEN_NO_FLUSHP) cond = BURST; else cond = SINGLE; @@ -1168,7 +1168,7 @@ static inline int _ldst_devtomem(struct pl330_dmac *pl330, unsigned dry_run, off += _emit_LDP(dry_run, &buf[off], cond, pxs->desc->peri); off += _emit_ST(dry_run, &buf[off], ALWAYS); - if (!(pl330->quirks & PL330_QUIRK_BROKEN_NO_FLUSHP)) + if (!(pxs->quirks & PL330_QUIRK_BROKEN_NO_FLUSHP)) off += _emit_FLUSHP(dry_run, &buf[off], pxs->desc->peri); } @@ -1176,14 +1176,13 @@ static inline int _ldst_devtomem(struct pl330_dmac *pl330, unsigned dry_run, return off; } -static inline int _ldst_memtodev(struct pl330_dmac *pl330, - unsigned dry_run, u8 buf[], - const struct _xfer_spec *pxs, int cyc) +static inline int _ldst_memtodev(unsigned dry_run, u8 buf[], + const struct _xfer_spec *pxs, int cyc) { int off = 0; enum pl330_cond cond; - if (pl330->quirks & PL330_QUIRK_BROKEN_NO_FLUSHP) + if (pxs->quirks & PL330_QUIRK_BROKEN_NO_FLUSHP) cond = BURST; else cond = SINGLE; @@ -1193,7 +1192,7 @@ static inline int _ldst_memtodev(struct pl330_dmac *pl330, off += _emit_LD(dry_run, &buf[off], ALWAYS); off += _emit_STP(dry_run, &buf[off], cond, pxs->desc->peri); - if (!(pl330->quirks & PL330_QUIRK_BROKEN_NO_FLUSHP)) + if (!(pxs->quirks & PL330_QUIRK_BROKEN_NO_FLUSHP)) off += _emit_FLUSHP(dry_run, &buf[off], pxs->desc->peri); } @@ -1201,17 +1200,17 @@ static inline int _ldst_memtodev(struct pl330_dmac *pl330, return off; } -static int _bursts(struct pl330_dmac *pl330, unsigned dry_run, u8 buf[], +static int _bursts(unsigned dry_run, u8 buf[], const struct _xfer_spec *pxs, int cyc) { int off = 0; switch (pxs->desc->rqtype) { case DMA_MEM_TO_DEV: - off += _ldst_memtodev(pl330, dry_run, &buf[off], pxs, cyc); + off += _ldst_memtodev(dry_run, &buf[off], pxs, cyc); break; case DMA_DEV_TO_MEM: - off += _ldst_devtomem(pl330, dry_run, &buf[off], pxs, cyc); + off += _ldst_devtomem(dry_run, &buf[off], pxs, cyc); break; case DMA_MEM_TO_MEM: off += _ldst_memtomem(dry_run, &buf[off], pxs, cyc); @@ -1225,7 +1224,7 @@ static int _bursts(struct pl330_dmac *pl330, unsigned dry_run, u8 buf[], } /* Returns bytes consumed and updates bursts */ -static inline int _loop(struct pl330_dmac *pl330, unsigned dry_run, u8 buf[], +static inline int _loop(unsigned dry_run, u8 buf[], unsigned long *bursts, const struct _xfer_spec *pxs) { int cyc, cycmax, szlp, szlpend, szbrst, off; @@ -1233,7 +1232,7 @@ static inline int _loop(struct pl330_dmac *pl330, unsigned dry_run, u8 buf[], struct _arg_LPEND lpend; if (*bursts == 1) - return _bursts(pl330, dry_run, buf, pxs, 1); + return _bursts(dry_run, buf, pxs, 1); /* Max iterations possible in DMALP is 256 */ if (*bursts >= 256*256) { @@ -1251,7 +1250,7 @@ static inline int _loop(struct pl330_dmac *pl330, unsigned dry_run, u8 buf[], } szlp = _emit_LP(1, buf, 0, 0); - szbrst = _bursts(pl330, 1, buf, pxs, 1); + szbrst = _bursts(1, buf, pxs, 1); lpend.cond = ALWAYS; lpend.forever = false; @@ -1283,7 +1282,7 @@ static inline int _loop(struct pl330_dmac *pl330, unsigned dry_run, u8 buf[], off += _emit_LP(dry_run, &buf[off], 1, lcnt1); ljmp1 = off; - off += _bursts(pl330, dry_run, &buf[off], pxs, cyc); + off += _bursts(dry_run, &buf[off], pxs, cyc); lpend.cond = ALWAYS; lpend.forever = false; @@ -1306,9 +1305,8 @@ static inline int _loop(struct pl330_dmac *pl330, unsigned dry_run, u8 buf[], return off; } -static inline int _setup_loops(struct pl330_dmac *pl330, - unsigned dry_run, u8 buf[], - const struct _xfer_spec *pxs) +static inline int _setup_loops(unsigned dry_run, u8 buf[], + const struct _xfer_spec *pxs) { struct pl330_xfer *x = &pxs->desc->px; u32 ccr = pxs->ccr; @@ -1317,16 +1315,15 @@ static inline int _setup_loops(struct pl330_dmac *pl330, while (bursts) { c = bursts; - off += _loop(pl330, dry_run, &buf[off], &c, pxs); + off += _loop(dry_run, &buf[off], &c, pxs); bursts -= c; } return off; } -static inline int _setup_xfer(struct pl330_dmac *pl330, - unsigned dry_run, u8 buf[], - const struct _xfer_spec *pxs) +static inline int _setup_xfer(unsigned dry_run, u8 buf[], + const struct _xfer_spec *pxs) { struct pl330_xfer *x = &pxs->desc->px; int off = 0; @@ -1337,7 +1334,7 @@ static inline int _setup_xfer(struct pl330_dmac *pl330, off += _emit_MOV(dry_run, &buf[off], DAR, x->dst_addr); /* Setup Loop(s) */ - off += _setup_loops(pl330, dry_run, &buf[off], pxs); + off += _setup_loops(dry_run, &buf[off], pxs); return off; } @@ -1346,9 +1343,8 @@ static inline int _setup_xfer(struct pl330_dmac *pl330, * A req is a sequence of one or more xfer units. * Returns the number of bytes taken to setup the MC for the req. */ -static int _setup_req(struct pl330_dmac *pl330, unsigned dry_run, - struct pl330_thread *thrd, unsigned index, - struct _xfer_spec *pxs) +static int _setup_req(unsigned dry_run, struct pl330_thread *thrd, + unsigned index, struct _xfer_spec *pxs) { struct _pl330_req *req = &thrd->req[index]; struct pl330_xfer *x; @@ -1365,7 +1361,7 @@ static int _setup_req(struct pl330_dmac *pl330, unsigned dry_run, if (x->bytes % (BRST_SIZE(pxs->ccr) * BRST_LEN(pxs->ccr))) return -EINVAL; - off += _setup_xfer(pl330, dry_run, &buf[off], pxs); + off += _setup_xfer(dry_run, &buf[off], pxs); /* DMASEV peripheral/event */ off += _emit_SEV(dry_run, &buf[off], thrd->ev); @@ -1457,9 +1453,10 @@ static int pl330_submit_req(struct pl330_thread *thrd, xs.ccr = ccr; xs.desc = desc; + xs.quirks = pl330->quirks; /* First dry run to check if req is acceptable */ - ret = _setup_req(pl330, 1, thrd, idx, &xs); + ret = _setup_req(1, thrd, idx, &xs); if (ret < 0) goto xfer_exit; @@ -1473,7 +1470,7 @@ static int pl330_submit_req(struct pl330_thread *thrd, /* Hook the request */ thrd->lstenq = idx; thrd->req[idx].desc = desc; - _setup_req(pl330, 0, thrd, idx, &xs); + _setup_req(0, thrd, idx, &xs); ret = 0;