From patchwork Thu Mar 10 11:02:42 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Kochetkov X-Patchwork-Id: 8555461 Return-Path: X-Original-To: patchwork-linux-rockchip@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 7B0B19FDE3 for ; Thu, 10 Mar 2016 11:03:26 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 61FFB2034C for ; Thu, 10 Mar 2016 11:03:25 +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 1E967202F8 for ; Thu, 10 Mar 2016 11:03:24 +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 1adyNH-0000Wn-Na; Thu, 10 Mar 2016 11:03:23 +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 1adyND-0008J6-3Z for linux-rockchip@lists.infradead.org; Thu, 10 Mar 2016 11:03:21 +0000 Received: by mail-lb0-x243.google.com with SMTP id gn5so7894459lbc.3 for ; Thu, 10 Mar 2016 03:02:58 -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=Wsq1utJjhm52qXuJANycdyFsewj/7FIt2TlZ0T3bckGScdgW1HThq/P9zwbp3g9NfT mLAhSG1G6nyj67OmJiOuAcyFHwtoFMO2/j9fceWg3BjCuVagGzvyDgQnKKtn/VUXcJgq iqJ2h6Rv9nQbVaBtXistJBOdAoU8J0fQA9Ol3wfAsbCg6R99yuV/ICBNKsmPgSrH0IFK sKOy0A6HaWX6FXCPECdmzbfGgoSyY3k7VzUzHc+5PcebaxShh9uTzpjR6k3mIB+nVSEc DDoZX2AdfiZc1Asl+2zsi2nXRArWFzCX3fMBld3UlLALaTRWZOk1g7cKGIjRaUB9AlRH ZUCQ== 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=TF0C8LE/83RmSCG6Apo8TegF6kJSkjUZBDiHzT9wNa4l2n1Q61mgsSXcFq2+I4JoX3 UL9AwT1dIxb9Tp9Ww9x24pROsBxK/SYXn7i/lCo0YXT7VFOdDrrosZQ+GuXyOHpuA+co ml8fo0Ri+TpMvwiTRv9P1iTqISz6bbtN8SRY3mU8KhXEfUuuabApNJNBoc/Kyfb7/KbF VW94sefsF4aTj3S3t+9xTQyfKR2gO07B9sWzhK3UegdrplBnnH9xQ67bMhzQ0FYgLUUY 8DtLdHq/WS0L89iI+JEIyxp0S3hs44z8tFoWYv7yxSmmhZdE55tajvzJXU1wlnpLldLz Z1tQ== X-Gm-Message-State: AD7BkJKQqBUZsNa/4Dl7c6ZUL6hb0L8MjiTbEt4FTOAE5FUD8tauhMoVtms02qsJwyDJEQ== X-Received: by 10.25.158.72 with SMTP id h69mr1066230lfe.8.1457607777573; Thu, 10 Mar 2016 03:02:57 -0800 (PST) Received: from ubuntu.lintech.ru ([185.35.119.87]) by smtp.gmail.com with ESMTPSA id f134sm447919lff.34.2016.03.10.03.02.56 (version=TLS1_1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 10 Mar 2016 03:02:56 -0800 (PST) From: Alexander Kochetkov To: Vinod Koul , Dan Williams , dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/3 v3] dmaengine: pl330: cleanup quirk pass code Date: Thu, 10 Mar 2016 14:02:42 +0300 Message-Id: <1457607764-30495-2-git-send-email-al.kochet@gmail.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1457607764-30495-1-git-send-email-al.kochet@gmail.com> References: <1455798674-10186-1-git-send-email-al.kochet@gmail.com> <1457607764-30495-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_030319_615186_782181C1 X-CRM114-Status: GOOD ( 16.79 ) 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;