From patchwork Fri May 12 14:14:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joy Chakraborty X-Patchwork-Id: 93224 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp5152477vqo; Fri, 12 May 2023 07:31:55 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ46ypuXLwO9HpnhbrgDGBlmKiwqG/5VpGlVJHraePw8+qaV23NCUzb3pgjr0XZkj4AROQIN X-Received: by 2002:a05:6a00:2d25:b0:643:6b94:374b with SMTP id fa37-20020a056a002d2500b006436b94374bmr37319635pfb.1.1683901915287; Fri, 12 May 2023 07:31:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683901915; cv=none; d=google.com; s=arc-20160816; b=o3FvFLlPN6Aw0drOeWoSkyuq1YIDb3wtjAQsDOngVnHyWPpip8Svo+Kobx0sgf6eDb XWKIMzSVlO1oWkm/2J77bsK7ei00vmq7nzqrvzl48UT3K7xzf6qp3XIrj65rO1MB7b5x ueaxV7vs0b6FZcanbhf+uE59lAWllEa93m+GLRdxiJ6bB5it90R9JWwdkI5WZIW7CUjY dGP1Y1giKuDPQby6C7MgF1trj57HmTFCCt8UrRHQpj6IZ2X7at2pkSxQuMZCR20erjL/ gAAOvyrJv7w8meM58Lo/oIllFHNNUha2kXafUcKBg0LlpIZ/sgEp9gNJhK/xP0MoDAjH wa7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=9fd/5tDM33mlBKRPz7g7eHWJD79X5yTFlYNSGMw+woI=; b=XLGIVhnBWHPyoRRTd7LbRF12YrDD/Gw9CmbCvH6DTqP/cAOfKmqsgk6AMdsO4Uehe5 vcSeauXOJLZngeWO/nX7yOo7OHNMlHjiv8R/QzdostrCGm8v7o84jhtzoY9O1KHL2nMQ a6w1w+r8WnloxW9Jcg+Idle5sYuU4SqcEaFl55144cd6hWiVeagYRvo1eAjHkKUQSRdS +kSvF+3ytN6ZjGl6iNROLizxdRQGU8A/21OLk8V8wDU5IknO4dB4w3eKZYRO/vzUOrjH J8Cz1k9fDLCDb+bMdTtr2g3j5xrMVHGsWZYuhNkpNYvcYiNnn/TlRT8aH/x/nOyXqBnp b3aw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=ZtsTNy2P; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a19-20020aa795b3000000b0063d26262efasi10507473pfk.187.2023.05.12.07.31.43; Fri, 12 May 2023 07:31:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=ZtsTNy2P; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241491AbjELOPO (ORCPT + 99 others); Fri, 12 May 2023 10:15:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46800 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241470AbjELOPJ (ORCPT ); Fri, 12 May 2023 10:15:09 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 59A8A124B6 for ; Fri, 12 May 2023 07:15:07 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-b9e2b65f2eeso17970626276.2 for ; Fri, 12 May 2023 07:15:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1683900906; x=1686492906; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=9fd/5tDM33mlBKRPz7g7eHWJD79X5yTFlYNSGMw+woI=; b=ZtsTNy2PVfhlpb/JuCfk1p8ZXlnYWWxWxMEu1Lva2/0XLeNRSoREIJqChnS3XuVtdr BE5huxYM2URNE4X1IxhxOTZISn4KuZI2Yqn/u6yGjFFj+RInj169E8ItPuxQQGs9QzoV 4Dvr7N/r//TmFUqT233y4l29SSmOpi3WqZsSVqkrH4NscGes5SFDHTVJ8TrYzYpED4Kf 7d23qfy07kmel36g5Qh/hO+vjVplrl5L+5RmkW/RECjDn8VO6EMQ3QulL97z7jfNOtKq e5+3GV/laP5C/Cao4Jsxp0p52Tp/DJuee8K0eFFT0VPDhl/QxO6pMNVlT4e39qP0nYlw 329w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683900906; x=1686492906; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=9fd/5tDM33mlBKRPz7g7eHWJD79X5yTFlYNSGMw+woI=; b=AXo/cOgdZItD0hofW6c360QzdYhWmTHQO/iSEozLx43TydEmwo8pbQXcKK2Xtl27VV we7NVqQ2Fc1CrU9gMIJb06E96RsJXEr7PyrHnTOm39qsoJ/gJT85QFVyxJ1QtVKHb+Un /bVRMXu18bYDhhWelU3vxmqhEkH9fzajifQSFtayCIBATlD5ufJ38ncYc0MItiywQj5P i04SIdiwv2d2yjP3lZTutUEov3m8rW2bnuv7vBAHYj/aBj/WBUkUIOarZDhRrfCUgW44 ukBUbAzTwO0XZju6xeRBU1MkFjBfsqJyS4xHRmhac82OGmG1i/ZrAXicjema0MqYK2E9 k/fQ== X-Gm-Message-State: AC+VfDz9QGU/CRLl3uWk3bUf6B3fOrNn3vfgd6Oyep4C5Ol1WOuQgseX HIL34re0i8aFKU/Vvoq2j78V8RYGZJpcrA== X-Received: from joychakr.c.googlers.com ([fda3:e722:ac3:cc00:4f:4b78:c0a8:6ea]) (user=joychakr job=sendgmr) by 2002:a05:6902:114e:b0:b4a:3896:bc17 with SMTP id p14-20020a056902114e00b00b4a3896bc17mr11151964ybu.0.1683900906639; Fri, 12 May 2023 07:15:06 -0700 (PDT) Date: Fri, 12 May 2023 14:14:40 +0000 In-Reply-To: <20230512141445.2026660-1-joychakr@google.com> Mime-Version: 1.0 References: <20230512141445.2026660-1-joychakr@google.com> X-Mailer: git-send-email 2.40.1.606.ga4b1b128d6-goog Message-ID: <20230512141445.2026660-2-joychakr@google.com> Subject: [PATCH v2 1/6] dmaengine: pl330: Separate SRC and DST burst size and len From: Joy Chakraborty To: Vinod Koul Cc: dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, manugautam@google.com, danielmentz@google.com, sjadavani@google.com, Joy Chakraborty X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765699135001481637?= X-GMAIL-MSGID: =?utf-8?q?1765699135001481637?= Add new variables in request configuration to handle source and destination AxSize and AxLen separately and allow them to have different values. This allows further patches to configure different AxSize and AxLen for optimum bus utilisation. Signed-off-by: Joy Chakraborty --- drivers/dma/pl330.c | 71 +++++++++++++++++++++++++++++---------------- 1 file changed, 46 insertions(+), 25 deletions(-) diff --git a/drivers/dma/pl330.c b/drivers/dma/pl330.c index 0d9257fbdfb0..c006e481b4c5 100644 --- a/drivers/dma/pl330.c +++ b/drivers/dma/pl330.c @@ -240,6 +240,12 @@ enum pl330_byteswap { #define BYTE_TO_BURST(b, ccr) ((b) / BRST_SIZE(ccr) / BRST_LEN(ccr)) #define BURST_TO_BYTE(c, ccr) ((c) * BRST_SIZE(ccr) * BRST_LEN(ccr)) +#define SRC_BRST_SIZE(ccr) BRST_SIZE(ccr) +#define DST_BRST_SIZE(ccr) (1 << (((ccr) >> CC_DSTBRSTSIZE_SHFT) & 0x7)) + +#define SRC_BRST_LEN(ccr) BRST_LEN(ccr) +#define DST_BRST_LEN(ccr) ((((ccr) >> CC_DSTBRSTLEN_SHFT) & 0xf) + 1) + /* * With 256 bytes, we can do more than 2.5MB and 5MB xfers per req * at 1byte/burst for P<->M and M<->M respectively. @@ -305,8 +311,10 @@ struct pl330_reqcfg { bool nonsecure; bool privileged; bool insnaccess; - unsigned brst_len:5; - unsigned brst_size:3; /* in power of 2 */ + unsigned src_brst_size : 3; /* in power of 2 */ + unsigned src_brst_len:5; + unsigned dst_brst_size : 3; /* in power of 2 */ + unsigned dst_brst_len:5; enum pl330_cachectrl dcctl; enum pl330_cachectrl scctl; @@ -1204,7 +1212,10 @@ static int _bursts(struct pl330_dmac *pl330, unsigned dry_run, u8 buf[], const struct _xfer_spec *pxs, int cyc) { int off = 0; - enum pl330_cond cond = BRST_LEN(pxs->ccr) > 1 ? BURST : SINGLE; + enum pl330_cond cond = SINGLE; + + if (SRC_BRST_LEN(pxs->ccr) > 1 || DST_BRST_LEN(pxs->ccr) > 1) + cond = BURST; if (pl330->quirks & PL330_QUIRK_PERIPH_BURST) cond = BURST; @@ -1235,12 +1246,12 @@ static int _bursts(struct pl330_dmac *pl330, unsigned dry_run, u8 buf[], * for mem-to-mem, mem-to-dev or dev-to-mem. */ static int _dregs(struct pl330_dmac *pl330, unsigned int dry_run, u8 buf[], - const struct _xfer_spec *pxs, int transfer_length) + const struct _xfer_spec *pxs, int src_length, int dst_length) { int off = 0; int dregs_ccr; - if (transfer_length == 0) + if (src_length == 0 || dst_length == 0) return off; /* @@ -1253,9 +1264,9 @@ static int _dregs(struct pl330_dmac *pl330, unsigned int dry_run, u8 buf[], dregs_ccr = pxs->ccr; dregs_ccr &= ~((0xf << CC_SRCBRSTLEN_SHFT) | (0xf << CC_DSTBRSTLEN_SHFT)); - dregs_ccr |= (((transfer_length - 1) & 0xf) << + dregs_ccr |= (((src_length - 1) & 0xf) << CC_SRCBRSTLEN_SHFT); - dregs_ccr |= (((transfer_length - 1) & 0xf) << + dregs_ccr |= (((dst_length - 1) & 0xf) << CC_DSTBRSTLEN_SHFT); switch (pxs->desc->rqtype) { @@ -1369,16 +1380,18 @@ static inline int _setup_loops(struct pl330_dmac *pl330, struct pl330_xfer *x = &pxs->desc->px; u32 ccr = pxs->ccr; unsigned long c, bursts = BYTE_TO_BURST(x->bytes, ccr); - int num_dregs = (x->bytes - BURST_TO_BYTE(bursts, ccr)) / - BRST_SIZE(ccr); - int off = 0; + int num_dreg_bytes = x->bytes - BURST_TO_BYTE(bursts, ccr); + int num_src_dregs, num_dst_dregs, off = 0; + + num_src_dregs = num_dreg_bytes / SRC_BRST_SIZE(ccr); + num_dst_dregs = num_dreg_bytes / DST_BRST_SIZE(ccr); while (bursts) { c = bursts; off += _loop(pl330, dry_run, &buf[off], &c, pxs); bursts -= c; } - off += _dregs(pl330, dry_run, &buf[off], pxs, num_dregs); + off += _dregs(pl330, dry_run, &buf[off], pxs, num_src_dregs, num_dst_dregs); return off; } @@ -1446,11 +1459,11 @@ static inline u32 _prepare_ccr(const struct pl330_reqcfg *rqc) if (rqc->insnaccess) ccr |= CC_SRCIA | CC_DSTIA; - ccr |= (((rqc->brst_len - 1) & 0xf) << CC_SRCBRSTLEN_SHFT); - ccr |= (((rqc->brst_len - 1) & 0xf) << CC_DSTBRSTLEN_SHFT); + ccr |= (((rqc->src_brst_len - 1) & 0xf) << CC_SRCBRSTLEN_SHFT); + ccr |= (((rqc->dst_brst_len - 1) & 0xf) << CC_DSTBRSTLEN_SHFT); - ccr |= (rqc->brst_size << CC_SRCBRSTSIZE_SHFT); - ccr |= (rqc->brst_size << CC_DSTBRSTSIZE_SHFT); + ccr |= (rqc->src_brst_size << CC_SRCBRSTSIZE_SHFT); + ccr |= (rqc->dst_brst_size << CC_DSTBRSTSIZE_SHFT); ccr |= (rqc->scctl << CC_SRCCCTRL_SHFT); ccr |= (rqc->dcctl << CC_DSTCCTRL_SHFT); @@ -2656,7 +2669,7 @@ static inline int get_burst_len(struct dma_pl330_desc *desc, size_t len) burst_len = pl330->pcfg.data_bus_width / 8; burst_len *= pl330->pcfg.data_buf_dep / pl330->pcfg.num_chan; - burst_len >>= desc->rqcfg.brst_size; + burst_len >>= desc->rqcfg.src_brst_size; /* src/dst_burst_len can't be more than 16 */ if (burst_len > PL330_MAX_BURST) @@ -2735,8 +2748,10 @@ static struct dma_async_tx_descriptor *pl330_prep_dma_cyclic( } desc->rqtype = direction; - desc->rqcfg.brst_size = pch->burst_sz; - desc->rqcfg.brst_len = pch->burst_len; + desc->rqcfg.src_brst_size = pch->burst_sz; + desc->rqcfg.src_brst_len = pch->burst_len; + desc->rqcfg.dst_brst_size = pch->burst_sz; + desc->rqcfg.dst_brst_len = pch->burst_len; desc->bytes_requested = period_len; fill_px(&desc->px, dst, src, period_len); @@ -2789,17 +2804,21 @@ pl330_prep_dma_memcpy(struct dma_chan *chan, dma_addr_t dst, while ((src | dst | len) & (burst - 1)) burst /= 2; - desc->rqcfg.brst_size = 0; - while (burst != (1 << desc->rqcfg.brst_size)) - desc->rqcfg.brst_size++; + desc->rqcfg.src_brst_size = 0; + while (burst != (1 << desc->rqcfg.src_brst_size)) + desc->rqcfg.src_brst_size++; - desc->rqcfg.brst_len = get_burst_len(desc, len); + desc->rqcfg.src_brst_len = get_burst_len(desc, len); /* * If burst size is smaller than bus width then make sure we only * transfer one at a time to avoid a burst stradling an MFIFO entry. */ if (burst * 8 < pl330->pcfg.data_bus_width) - desc->rqcfg.brst_len = 1; + desc->rqcfg.src_brst_len = 1; + + /* For Mem2Mem, set destination AxSize and AxLen same as source*/ + desc->rqcfg.dst_brst_len = desc->rqcfg.src_brst_len; + desc->rqcfg.dst_brst_size = desc->rqcfg.src_brst_size; desc->bytes_requested = len; @@ -2879,8 +2898,10 @@ pl330_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl, sg_dma_len(sg)); } - desc->rqcfg.brst_size = pch->burst_sz; - desc->rqcfg.brst_len = pch->burst_len; + desc->rqcfg.src_brst_size = pch->burst_sz; + desc->rqcfg.src_brst_len = pch->burst_len; + desc->rqcfg.dst_brst_size = pch->burst_sz; + desc->rqcfg.dst_brst_len = pch->burst_len; desc->rqtype = direction; desc->bytes_requested = sg_dma_len(sg); } From patchwork Fri May 12 14:14:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joy Chakraborty X-Patchwork-Id: 93219 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp5150372vqo; Fri, 12 May 2023 07:29:01 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ72lYO/QbIGwEDT8zYbJ/vzrmRuNsXwtVpsyui4caDCYKIrBpvXumM4RSl0Tp7i9F/n7RkD X-Received: by 2002:a17:90b:384b:b0:252:c3b7:6689 with SMTP id nl11-20020a17090b384b00b00252c3b76689mr683593pjb.49.1683901741036; Fri, 12 May 2023 07:29:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683901741; cv=none; d=google.com; s=arc-20160816; b=agFQrfcqmPezHLt0ZXRWzBwctXnGYFD1tlrK8vpuS3k32UYXtgdAnDwYPw7mglw4Rs grTZaTqJSGhOEU57ONAgJl4xRYGOtuVpt/G+E2vczEXhRMycY1BHUrtS/zA2ebnFgGmc METti95/w94ZDE2rtiuwbIWYu+yq0I+t3QPwIjgq/ZpYH3HHBRJPi4ZK+rso2fwBXX51 o7T1L9O818MwQ6Y1k//Ph+1eshDfaqI9K01+AqbUbVoWCtjQhDtacmLmph7uqCmnMgMw Us4Xx7t+kCvQgXRaiNH500F9uwGJqZzxz/vdRZS6zA7WgOArIdHZjL/D9N3z2OGrs0U8 YhfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=7kJtzV8QKLK33nINo9QDGOG+IeWyuMdmVEqS+yux294=; b=E76sysrm1BeiOTKaDygg3WavDEVPiyOa/CN6jrBwmmxOtKtUJwg7833G9KLHQ5qFaY Qztk45jsEXCKdsAXGmhVW1Qsfn7a4v6ZrF+9sqQuy6c2D6l2LWAO+YYsvBGrWfnHh6Kd r4l8hUjrAV7E5wcNgAw3lTaTnnhvRos3EOhpWxlQ4eS1WDA/1GIWTP2Prf/DHjKNo2VZ jN7MUBovpHFm5MArrv53rAIEL7Bu/eaUmyW8T2Pg3oRiObb+FfFwDMtv9Iz6edcs/RN5 SGuY+IxsA7W0AJlyDusMVDf8zVnE0qKiSFJBoLJpq0lwPxAcNbRcfzWQCxHLjuS02HJl +vlA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=73+KE2jJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id mn16-20020a17090b189000b00246e9abad4bsi23069402pjb.85.2023.05.12.07.28.39; Fri, 12 May 2023 07:29:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=73+KE2jJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241162AbjELOPU (ORCPT + 99 others); Fri, 12 May 2023 10:15:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46874 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240231AbjELOPN (ORCPT ); Fri, 12 May 2023 10:15:13 -0400 Received: from mail-yw1-x114a.google.com (mail-yw1-x114a.google.com [IPv6:2607:f8b0:4864:20::114a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3EACDA268 for ; Fri, 12 May 2023 07:15:11 -0700 (PDT) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-55ffc3d2b63so98243567b3.2 for ; Fri, 12 May 2023 07:15:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1683900911; x=1686492911; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=7kJtzV8QKLK33nINo9QDGOG+IeWyuMdmVEqS+yux294=; b=73+KE2jJZgkKQVWCaUtcFRpHwxmCoknACAnlzWzTTYdIeY0sf1xAPMDgtao4FVuH4k cIXrqnoPUk9E9aw5oY+NH0+jpuVYn11HOwCNYKqqhyAGlgtS8CuLEkii2U8zX7IDZGG3 tlE3p6UYcl+Dl7nnZLCUsFMsZHAaumD1Hky/+FyLVDvK5mKqHYq7x4LBEhc2fAIii/2H yPQQh3WUAMDhsWLQPzOgM2V6SxOObNDmTh0RskA9oAhKJX3QfNpu7Df6AIEjOpTY2N4T xslSmLB6C898lbkzltwNSx1CNN9tRFjI/b5qSyKnAI4MQmIHDWG5CVYIHlhWqrVQXrDd gaMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683900911; x=1686492911; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=7kJtzV8QKLK33nINo9QDGOG+IeWyuMdmVEqS+yux294=; b=PBDw+ZIpMCa8FVM83v1gq3i5GGShrMnId7eNbEZW5s0/0bj7GBWqZOnj1FiKhdWNg8 ZMm76+fAg3a8TWxH1Kokie05ZIDHygHWL/vAeU7WHm8Uwc4KTXdemTXu7SV3bETorBXt f+lLj2CxxDA+9eij2cV8893khmYPUcHqA9Qi+c8+RLC1s9nUSvYv2+R4Y0gCjuHM66ZS uwA57WSkUcIxSM2+YBvb2NzGT2UnTWFXoRK10oFAfcr4ljSACCIwqZYkQHIOyWI/c2Ov aJBEQh1HA6koIzbfyfFabr3lg/bH16DdRcHgvzXpOXuglA/o/g7B59lDjTjDJc8N+zcq XAHA== X-Gm-Message-State: AC+VfDxLzPeKQNx4GUCtj0YR2kj5J6j38ZM9ttmHdei/BGyqbKfgu/No QaJXg2ZFRS9hHMmxXwUEFgOK2mh6saDbRA== X-Received: from joychakr.c.googlers.com ([fda3:e722:ac3:cc00:4f:4b78:c0a8:6ea]) (user=joychakr job=sendgmr) by 2002:a81:430b:0:b0:55d:9a6d:8ce5 with SMTP id q11-20020a81430b000000b0055d9a6d8ce5mr15219383ywa.1.1683900911005; Fri, 12 May 2023 07:15:11 -0700 (PDT) Date: Fri, 12 May 2023 14:14:41 +0000 In-Reply-To: <20230512141445.2026660-1-joychakr@google.com> Mime-Version: 1.0 References: <20230512141445.2026660-1-joychakr@google.com> X-Mailer: git-send-email 2.40.1.606.ga4b1b128d6-goog Message-ID: <20230512141445.2026660-3-joychakr@google.com> Subject: [PATCH v2 2/6] dmaengine: pl330: Use FFS to calculate burst size From: Joy Chakraborty To: Vinod Koul Cc: dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, manugautam@google.com, danielmentz@google.com, sjadavani@google.com, Joy Chakraborty X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765698951932819230?= X-GMAIL-MSGID: =?utf-8?q?1765698951932819230?= Use __ffs to calculate burst size in pl330_prep_dma_memcpy() for consistency across the driver as other functions already use __ffs for the same functionality. Signed-off-by: Joy Chakraborty --- drivers/dma/pl330.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/dma/pl330.c b/drivers/dma/pl330.c index c006e481b4c5..39a66ff29e27 100644 --- a/drivers/dma/pl330.c +++ b/drivers/dma/pl330.c @@ -2804,10 +2804,7 @@ pl330_prep_dma_memcpy(struct dma_chan *chan, dma_addr_t dst, while ((src | dst | len) & (burst - 1)) burst /= 2; - desc->rqcfg.src_brst_size = 0; - while (burst != (1 << desc->rqcfg.src_brst_size)) - desc->rqcfg.src_brst_size++; - + desc->rqcfg.src_brst_size = __ffs(burst); desc->rqcfg.src_brst_len = get_burst_len(desc, len); /* * If burst size is smaller than bus width then make sure we only From patchwork Fri May 12 14:14:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joy Chakraborty X-Patchwork-Id: 93223 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp5152043vqo; Fri, 12 May 2023 07:31:27 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4LG2iUODmVcqon/CGNUTh4gGbeZzRuz1WL39IJPdDnGM8HlS1FmnOZzsAaKAxRF66uWPLq X-Received: by 2002:a05:6a21:78a9:b0:102:a593:a158 with SMTP id bf41-20020a056a2178a900b00102a593a158mr13062660pzc.47.1683901886803; Fri, 12 May 2023 07:31:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683901886; cv=none; d=google.com; s=arc-20160816; b=ktEQ6RinPg0DgyF7SwZWeRFf1SqHsWNrML3QTn6LE170GiwqxrL31SmlLKfw0LDTNk 9ymAZzFNPwH9c+ba9ubdFWCfQP4vWgt2KsGzXWRknuaTJxJ2t+I8pyGZBK1n2YAOG7a9 Lk7hdrOdLd8+lBGBmxmUl6tph8W6wrZ7W9JVhwpJhMueRe34ac3D4/lQJwq0T9dYH5DC qrNIKOtJb7Qxq73O+gDDgMn1plNH8319W2fvUSDrLfn4Mkb0iDgVnmxaLEd5a231uFBm GHeABzZlSyCC9Zx3xmcCCQXsRHu5e9dxQwMfWzM7at4JUnDmwNsvTJlDDN4vb6uUwY8K gJcw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=AwCGXSf8iY+/DH2QgsH2WgzsBbqjZwTLYrp1XXczDUM=; b=trIacBVmdpnZnHET06zkrW6IkyehCHSFzeP+swfbiNL+ew7OKjnCfpfAIhQ+qARu05 QkbPaQeKFRNSGc0j/iRHGlsq2YdCZgH2YwPERY3bHU4xqj8BdR1+CWwOSkPps2fM4WZO Pz/olKJP1lsb9WBvCnChIbRxqrvHTTTJFl1NHROEasdWhtIUSRV1eGxG0CUwj1SwAYJT hwizw/O0rLOmjfb//XCBx9kITTpgU0Sixl7lmzzhFIf7BpNfYP3e6iOb1jEseMu8IX+z 7xumq91sitiqygmiWQgb4kMQV+1HRQcSt8sYZCVty3sIWw7LCZx8j+W/YU2KW+UXoisF evHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=OY9dkKT5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h16-20020a056a00001000b0064693201e15si10392358pfk.344.2023.05.12.07.31.14; Fri, 12 May 2023 07:31:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=OY9dkKT5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241504AbjELOPe (ORCPT + 99 others); Fri, 12 May 2023 10:15:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241475AbjELOPY (ORCPT ); Fri, 12 May 2023 10:15:24 -0400 Received: from mail-yw1-x1149.google.com (mail-yw1-x1149.google.com [IPv6:2607:f8b0:4864:20::1149]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ABC341491C for ; Fri, 12 May 2023 07:15:16 -0700 (PDT) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-552cb28adfeso110550697b3.3 for ; Fri, 12 May 2023 07:15:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1683900916; x=1686492916; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=AwCGXSf8iY+/DH2QgsH2WgzsBbqjZwTLYrp1XXczDUM=; b=OY9dkKT5GQA0dusKiKaS7jrpoAGc7STMoAC5iq8ZfQ23vIfNvff8zDGgoY30mJ/5tD 9i5nx/eeF4spSmwJa6idZkSXZNinZO9XvLfzF6UvdZkIqXG9NT4b8J8zNPdj8LzTmHxk 7REBcii9VONQpxmUV1ZgJuykuVbQPVtAhPWlMybn7UfMyv8CfnQ7ky/YyFRHSkAev3PK MeZXSlsVN9NAYV0dajL373J8mY+unWtwU0Y3WI1cw/zYGoJPInHFFssN72jUC6uC7mFG TIRG8oqiyD1k+RdxYwV8T1XyV86Lt927tbp7/DrwyLP1upxf9Pd2O0L0eEZ2NhxUSfZf BmbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683900916; x=1686492916; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=AwCGXSf8iY+/DH2QgsH2WgzsBbqjZwTLYrp1XXczDUM=; b=TLL4w+cv6k25hK85NLjo+36C79Ht7uYl4J3aeCKdTBozFM+SKtxIyOiTi/pWwAlqQy 7bvvCzWuksKfcFWDe4ELNaJroDXElHDRB4IkSiCvMShYVsMseW0DZZnoPiUsyEtCsWy0 IcbeO7Us/ET5LPLaqsnXf5346jJdyKMRtUjUMwdQuPoqfWt9Yvs5bHyY1hsUrtVBp1ZT eXS9SbE0sZVL7Qy/R2AGdxjEi+ZJGRgUW2kfe3ENq5WM/6P3WJe50ci7mmvRBfKcghOH 5/+qS8ItSsB7OQgd2UcEgeVKoO9dELrYcPXx/AjZcZEjxFjcRn0KxO99QPl6jD3P0c4V GaDA== X-Gm-Message-State: AC+VfDxR/F/R+kCg4y7sybH3YTDLaqa0uVldDtN7mLslQ7IE4MbCEKUx zkxgW75Z5pPpNRo9WhMT3oV3AC6hwN25zQ== X-Received: from joychakr.c.googlers.com ([fda3:e722:ac3:cc00:4f:4b78:c0a8:6ea]) (user=joychakr job=sendgmr) by 2002:a81:a9c3:0:b0:54c:a67:90b with SMTP id g186-20020a81a9c3000000b0054c0a67090bmr16185230ywh.5.1683900915935; Fri, 12 May 2023 07:15:15 -0700 (PDT) Date: Fri, 12 May 2023 14:14:42 +0000 In-Reply-To: <20230512141445.2026660-1-joychakr@google.com> Mime-Version: 1.0 References: <20230512141445.2026660-1-joychakr@google.com> X-Mailer: git-send-email 2.40.1.606.ga4b1b128d6-goog Message-ID: <20230512141445.2026660-4-joychakr@google.com> Subject: [PATCH v2 3/6] dmaengine: pl330: Change if-else to switch-case for consistency From: Joy Chakraborty To: Vinod Koul Cc: dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, manugautam@google.com, danielmentz@google.com, sjadavani@google.com, Joy Chakraborty X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765699104699075899?= X-GMAIL-MSGID: =?utf-8?q?1765699104699075899?= Change if-else to switch-case in pl330_prep_slave_sg() function for consistency with other peripheral transfer functions in the driver. Signed-off-by: Joy Chakraborty --- drivers/dma/pl330.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/dma/pl330.c b/drivers/dma/pl330.c index 39a66ff29e27..746da0bbea92 100644 --- a/drivers/dma/pl330.c +++ b/drivers/dma/pl330.c @@ -2883,16 +2883,21 @@ pl330_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl, else list_add_tail(&desc->node, &first->node); - if (direction == DMA_MEM_TO_DEV) { + switch (direction) { + case DMA_MEM_TO_DEV: desc->rqcfg.src_inc = 1; desc->rqcfg.dst_inc = 0; fill_px(&desc->px, pch->fifo_dma, sg_dma_address(sg), sg_dma_len(sg)); - } else { + break; + case DMA_DEV_TO_MEM: desc->rqcfg.src_inc = 0; desc->rqcfg.dst_inc = 1; fill_px(&desc->px, sg_dma_address(sg), pch->fifo_dma, sg_dma_len(sg)); + break; + default: + break; } desc->rqcfg.src_brst_size = pch->burst_sz; From patchwork Fri May 12 14:14:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joy Chakraborty X-Patchwork-Id: 93217 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp5142811vqo; Fri, 12 May 2023 07:17:33 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6J5rZko1TwULqHtD+tTcKEmddW/NmM+O49eyYEhJy+STENxqMGvUQZosz9T6sr95Cs4q/g X-Received: by 2002:a05:6870:c7b2:b0:18e:7c5e:b58c with SMTP id dy50-20020a056870c7b200b0018e7c5eb58cmr13186664oab.9.1683901052879; Fri, 12 May 2023 07:17:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683901052; cv=none; d=google.com; s=arc-20160816; b=swthPpQtUVLLUVHzmL5AMN81VULduXmbWdfOQY6EtVQSzgUz1clTo3Pp7oMOSLBo5g k3TvmQ36Xuu5xVSEZUhQhKYQYKvJlv9DK8PS1ihi7dgRmIfRz1wMHqxKYQbKxy40bqNS lOhH7Vi/Z7uzI0ViM3M4egY19V311zRkd7slcTT0v3pGfbBkYYqa38xGgwN8GfkbQKqA Xfnh0pfPwUT6tDzxzrsQlEgI7zhINCdrz5tBXkAlD6bAoFQoJqFs0KnWbbgKRNiCPNie MkkC8pRKUK/B1/pNJ3w8re5i+7YN6FF24cnQ2vfojsNjY8xOu7QQnn5vjAAr+5VCvKFy GSfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=FfQ+/r7s1P5a9jjV8O7nCqUbRdU0vkaUxYBVOduQXjQ=; b=S0GefunbkooaFmrzRJa5Bpf49k9EsgbKUTQN+kxPmo9bnZ1i1PbygW70YgALQN60QR Ve25SkB0v9EFS/OYifWFmB3uX6AMYfC/LghV93Avzo9Io1CIKKf/Bg9iAMfNURhPWLf3 5wwSkTj6vuSWi8SvFbNp4OMjSCpJDS1eXtEw+JMSpfMFRPrKTZ9yK+P9kvFAZbhs6Q/H TmoWgWUCXOBlXk8DvVczj0F6sN8hD7IWsn4nIE5W9UCYt4qjr6wdmRIoeCIrJgDwE3zX 27NT67rH8hRNc+Mxanh9f9rm3gLI3stf0V4wdLIbvkUuc8gf0ZcisYeoRTtfMDxucTFb ZRJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=IBQZt7Jb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g7-20020a056870c38700b001927ba97737si12494129oao.149.2023.05.12.07.17.19; Fri, 12 May 2023 07:17:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=IBQZt7Jb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241514AbjELOPl (ORCPT + 99 others); Fri, 12 May 2023 10:15:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47506 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241494AbjELOPa (ORCPT ); Fri, 12 May 2023 10:15:30 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2AB3614370 for ; Fri, 12 May 2023 07:15:20 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-b8f324b3ef8so12331118276.0 for ; Fri, 12 May 2023 07:15:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1683900920; x=1686492920; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=FfQ+/r7s1P5a9jjV8O7nCqUbRdU0vkaUxYBVOduQXjQ=; b=IBQZt7JbR+LudSxsdF3I2W7xeLwAEvXnvns938oEU3VVcdBX8lAvplQRg7xLBCUB4C ibIFadhFDSBkJSFTFTmgkfksiGNjcAaBORXO437XVKfkkkB7GVcSGu6rsigHjTGBODI2 MWcaHPbDRpwxLs0HJz0hA8eAfv1TccaO1pNBYr0ZBV3LwULnXcqNv9myVmpjESVEcG90 rhWaoqsxTJHrZkCQSCr4y7iMc0j6LT/JRTEqunc/ujfyQ6IMSf8X5LprFe5Wp7uTzytW vsyHe3eB7xsk7CNt0uDT/dS0HwFRgH1fmlICo8/Fz7mDK/QHxJGzWVWNDSZTPj2tG6tN kyog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683900920; x=1686492920; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=FfQ+/r7s1P5a9jjV8O7nCqUbRdU0vkaUxYBVOduQXjQ=; b=YH1nXEc5ehDVeFjXk+B3zPxf8xW7I8sFX0s56qnw2Hfu7P7WF1lF/bZvS1qJ/5LT3K 0NL4AAdgGAppXHJhJ6LwBEf690oi8l+Pd1LWfytNPobyeeItKrebYtaQKKDT0Uc5m9bM +yiXdTH/Ww6oLTsi9BvVvER2/PHIE//PiUSofFKXhEF7pcZbZr2V8loUP05Ie4NGwOlv Cg10FZW2D9GwSPn/eMbyJ6cPXLvRNdzACD2nuUNIt4q4qUz8wE+cGOa/PFvSQuQv8UFX Y4fgmbzgx78POijke7qmz7l4lpUU6L/J8m7b4yplV02zLDMRX+A4Vj5pGqGpbGlU5ef1 5kLQ== X-Gm-Message-State: AC+VfDwHcODOSLBV0UTjWaSYS1T7uGIqkKhsBfHcFQGC9FgxNyzDyRRV e61zsswsGTrxa0yQT5FVJY1tB2jGJqt/gw== X-Received: from joychakr.c.googlers.com ([fda3:e722:ac3:cc00:4f:4b78:c0a8:6ea]) (user=joychakr job=sendgmr) by 2002:a25:1d84:0:b0:ba2:526a:c84e with SMTP id d126-20020a251d84000000b00ba2526ac84emr12761168ybd.9.1683900920221; Fri, 12 May 2023 07:15:20 -0700 (PDT) Date: Fri, 12 May 2023 14:14:43 +0000 In-Reply-To: <20230512141445.2026660-1-joychakr@google.com> Mime-Version: 1.0 References: <20230512141445.2026660-1-joychakr@google.com> X-Mailer: git-send-email 2.40.1.606.ga4b1b128d6-goog Message-ID: <20230512141445.2026660-5-joychakr@google.com> Subject: [PATCH v2 4/6] dmaengine: pl330: Change unused arg "len" from get_burst_len() From: Joy Chakraborty To: Vinod Koul Cc: dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, manugautam@google.com, danielmentz@google.com, sjadavani@google.com, Joy Chakraborty X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765698230363826303?= X-GMAIL-MSGID: =?utf-8?q?1765698230363826303?= Remove unused length argument from get_burst_len() and add burst size as an argument to allow usage of this function in other places as source and destination burst sizes are handled separately. Signed-off-by: Joy Chakraborty --- drivers/dma/pl330.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/dma/pl330.c b/drivers/dma/pl330.c index 746da0bbea92..e5e610c91f18 100644 --- a/drivers/dma/pl330.c +++ b/drivers/dma/pl330.c @@ -2660,8 +2660,7 @@ __pl330_prep_dma_memcpy(struct dma_pl330_chan *pch, dma_addr_t dst, return desc; } -/* Call after fixing burst size */ -static inline int get_burst_len(struct dma_pl330_desc *desc, size_t len) +static inline int get_burst_len(struct dma_pl330_desc *desc, unsigned int brst_size) { struct dma_pl330_chan *pch = desc->pchan; struct pl330_dmac *pl330 = pch->dmac; @@ -2669,7 +2668,7 @@ static inline int get_burst_len(struct dma_pl330_desc *desc, size_t len) burst_len = pl330->pcfg.data_bus_width / 8; burst_len *= pl330->pcfg.data_buf_dep / pl330->pcfg.num_chan; - burst_len >>= desc->rqcfg.src_brst_size; + burst_len >>= brst_size; /* src/dst_burst_len can't be more than 16 */ if (burst_len > PL330_MAX_BURST) @@ -2805,7 +2804,7 @@ pl330_prep_dma_memcpy(struct dma_chan *chan, dma_addr_t dst, burst /= 2; desc->rqcfg.src_brst_size = __ffs(burst); - desc->rqcfg.src_brst_len = get_burst_len(desc, len); + desc->rqcfg.src_brst_len = get_burst_len(desc, desc->rqcfg.src_brst_size); /* * If burst size is smaller than bus width then make sure we only * transfer one at a time to avoid a burst stradling an MFIFO entry. From patchwork Fri May 12 14:14:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joy Chakraborty X-Patchwork-Id: 93222 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp5151756vqo; Fri, 12 May 2023 07:31:04 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7UZXuzT0MHuBAyDS3OJJJSHLJm2JC7+4zNN8/lKezIIqD2n8UK4MnA9DoHSWeLT+R2j0ze X-Received: by 2002:a05:6a00:2e10:b0:5a8:8535:18b with SMTP id fc16-20020a056a002e1000b005a88535018bmr29688418pfb.11.1683901864322; Fri, 12 May 2023 07:31:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683901864; cv=none; d=google.com; s=arc-20160816; b=xTPtUq+hNDlJM8DxWpTzq1jQ9OAjEFbltuO81wM2q7vk5nP5CQLkUJHMxGwBaq9DMM tFx9zvAT+1K1W/3D2Siwbd3skTwybP5WFXx2TmVlWtPSDA0AipcPXrAMXAlbCjPGrAKh h6BY+2GQCSairSTUoCyllHx/+jfCcNxzN0K8L0i9Oz+iGzg30U4Et+sGrqSoZd3Ejr3a ibMVXGTHlg+CN8VSTp07lTkCFSupvfvjnrBr+WTOPnyhlrfywn9UHjXyxMUI7evtKaML u129dFkK+s8zyVEXsUVxQ9fQKKggReNQMxIBv/dQa4Ges17SfgWS69rqMLIlvGT8W3SL PLrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=DBrF5DHnKIcDo8+7KXBxIWAhYs0e5wcmWXF/2mvOoX0=; b=aauNJVUquxloREFpGLjrVDd5ilg7Qiu5SZ8x8KnP/NKVrCGvj6bZm7Gr1uK7MlZD8A f3QeeW3UmdiCsAbtDFRSZzoTFChUaNVTCj3dAriqszJ4k68HQgjjx8/GiDyrF2MSoPkX a6lriYioZ8gUKL6MovztK6mjzVbbvQymisK69xNUTS6Cs97pI8itM0DscrgnbhtXxjFD cVYV9Q1YSIRv4wElSdNHscczWmH2lVOh0E4ODIzNTh4yHZocV5weOSv7cjxBsCpmf1io IdabEERLtBFD4fOq2LwD9Zc04FbzvtEqZ9Bz62N1E7t0cuuJ1/2rHHntlC9noDnhRsTt YTig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=EONdOzyG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h16-20020a056a00001000b0064693201e15si10392358pfk.344.2023.05.12.07.30.52; Fri, 12 May 2023 07:31:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=EONdOzyG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241490AbjELOPu (ORCPT + 99 others); Fri, 12 May 2023 10:15:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47108 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241506AbjELOPi (ORCPT ); Fri, 12 May 2023 10:15:38 -0400 Received: from mail-yw1-x114a.google.com (mail-yw1-x114a.google.com [IPv6:2607:f8b0:4864:20::114a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1386E150C4 for ; Fri, 12 May 2023 07:15:27 -0700 (PDT) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-56098b41d42so57933327b3.0 for ; Fri, 12 May 2023 07:15:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1683900926; x=1686492926; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=DBrF5DHnKIcDo8+7KXBxIWAhYs0e5wcmWXF/2mvOoX0=; b=EONdOzyG1A039q9TIagzHY6fFI1rVU8j8RfaY005zsbMET+fIElC7gxK8sx0Vsbb+s pSTTsT66jPni2V+txz15o1bHYwb+q3i1Ro2WMm9WcWd6Wb15w8vYK+acVehdrA2TGnkQ rMM8mVUCubXv1/aIYEsmdbP3RS71eBBvPTgxZO9ZFY9MbiKaGrI09akfU/7GUPivWGAv ncwdUmZTbtP9/bSGq7Sc8MgGVVEjADk2Xls/KOw8jR6SftsyaPO0RSsn0UMNBpaaaQaR EOoTQ+i5XopPmCMoVmtL7yfxALXdH4BcwshdmcXjv/sWuRx6ztWLCphAchPsjNNjuc5C kdiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683900926; x=1686492926; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=DBrF5DHnKIcDo8+7KXBxIWAhYs0e5wcmWXF/2mvOoX0=; b=C3a/zxLNOEvfCN20kdNdWdiLu1xiC6wpRaJPR7oze/LFrKzegZZ3pMcEbUMuLdPFrn xPaOejAWNgrN3uoUqy5m1JBvSTS5m43TnMUYTQMytpPJsFqCGBJviKcW2Sck2I5PTGUf f5c7d/fYyMVKpKCX5JHM+Aq/q7ZEpiUildbBd03AlU7jY46fMc9yrXAJlRy40kNEif2G g+15b6RALjluyKoHMPnT7m2QIwsmsk64JVlae7tDM9aFIYhYMZGzkI9z4gPTTllpWL1K Wy4GMx0XvdIpTmygMcexZceQDPmddk9WIxRWF2tOohd1l2VZWdcFtedYHVo0LpuL3b7a cqIw== X-Gm-Message-State: AC+VfDxt5qVTlIN0Shb5Po7/wmxKNpzoqibBk9sAKieA5y+MiWdws+N+ Sk/9/JQ4WKgY7t/fe6+S/TXM2uir7kM/Xg== X-Received: from joychakr.c.googlers.com ([fda3:e722:ac3:cc00:4f:4b78:c0a8:6ea]) (user=joychakr job=sendgmr) by 2002:a81:bd52:0:b0:54f:b986:9c60 with SMTP id n18-20020a81bd52000000b0054fb9869c60mr16276082ywk.7.1683900926764; Fri, 12 May 2023 07:15:26 -0700 (PDT) Date: Fri, 12 May 2023 14:14:44 +0000 In-Reply-To: <20230512141445.2026660-1-joychakr@google.com> Mime-Version: 1.0 References: <20230512141445.2026660-1-joychakr@google.com> X-Mailer: git-send-email 2.40.1.606.ga4b1b128d6-goog Message-ID: <20230512141445.2026660-6-joychakr@google.com> Subject: [PATCH v2 5/6] dmaengine: pl330: Optimize AxSize for peripheral usecases From: Joy Chakraborty To: Vinod Koul Cc: dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, manugautam@google.com, danielmentz@google.com, sjadavani@google.com, Joy Chakraborty X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765699081099172072?= X-GMAIL-MSGID: =?utf-8?q?1765699081099172072?= Add logic to choose the maximum possible AxSize for transactions towards memory during usecases which copy data between memory and peripherals. Currently PL330 driver chooses equal AxLen and AxSize for both loads and stores to/from memory and peripherals which is inefficient towards memory as the whole bus width is not used for transfers as a peripheral might be limited to use only a narrow size of the buswidth available. Example scenario: A peripheral might require data byte by byte which would make AxSize = 1 byte and AxLen = 16 for both load from memory and store to Peripheral. This can be optimized for memory by using maximum AxSize (say 16bytes) then load from memory can be done with AxSize = 16byte, AxLen = 1 and store to peripheral with AxSize = 1byte, AxLen = 16 beats. Instruction setup post changes : 512bytes copy from Memory(16bytes * 4beats) to Peripheral(4bytes * 16 beats) --- DMAMOV CCR 0xbd0239 DMAMOV SAR 0xffffe000 DMAMOV DAR 0xffffc860 DMALP_1 7 DMAFLUSHP 0 DMAWFPB 0 DMALDB DMASTPB 0 DMALPENDA_1 bjmpto_7 DMASEV 3 DMAEND --- Signed-off-by: Joy Chakraborty --- drivers/dma/pl330.c | 92 ++++++++++++++++++++++++++++++++++++++------- 1 file changed, 78 insertions(+), 14 deletions(-) diff --git a/drivers/dma/pl330.c b/drivers/dma/pl330.c index e5e610c91f18..46e254fd4007 100644 --- a/drivers/dma/pl330.c +++ b/drivers/dma/pl330.c @@ -2677,6 +2677,52 @@ static inline int get_burst_len(struct dma_pl330_desc *desc, unsigned int brst_s return burst_len; } +/* + * Returns burst size to be used to copy data from/to memory during a + * peripheral transfer + */ +static unsigned int get_periph_mem_brst_sz(dma_addr_t addr, size_t len, + struct dma_pl330_chan *pch) +{ + unsigned int burst; + + /* Select max possible burst size */ + burst = pch->dmac->pcfg.data_bus_width / 8; + + /* + * Make sure we use a burst size that aligns with the memory and length. + */ + while ((addr | len) & (burst - 1)) + burst /= 2; + + return __ffs(burst); +} + +/* + * Returns burst length to be used to copy data from/to memory during a + * peripheral transfer + */ +static unsigned int get_periph_mem_brst_len(struct dma_pl330_desc *desc, + struct dma_pl330_chan *pch, + unsigned int burst_size) +{ + unsigned int burst_len = pch->burst_len; + + if (burst_size != pch->burst_sz) { + /* Select max possible burst len */ + burst_len = get_burst_len(desc, burst_size); + + /* + * Adjust AxLen to keep number of bytes same in Load/Store + */ + if (burst_size > pch->burst_sz) + burst_len = pch->burst_len >> (burst_size - pch->burst_sz); + else + pch->burst_len = burst_len >> (pch->burst_sz - burst_size); + } + return burst_len; +} + static struct dma_async_tx_descriptor *pl330_prep_dma_cyclic( struct dma_chan *chan, dma_addr_t dma_addr, size_t len, size_t period_len, enum dma_transfer_direction direction, @@ -2684,8 +2730,8 @@ static struct dma_async_tx_descriptor *pl330_prep_dma_cyclic( { struct dma_pl330_desc *desc = NULL, *first = NULL; struct dma_pl330_chan *pch = to_pchan(chan); + unsigned int i, burst_size, burst_len; struct pl330_dmac *pl330 = pch->dmac; - unsigned int i; dma_addr_t dst; dma_addr_t src; @@ -2729,28 +2775,35 @@ static struct dma_async_tx_descriptor *pl330_prep_dma_cyclic( return NULL; } + burst_size = get_periph_mem_brst_sz(dma_addr, period_len, pch); + burst_len = get_periph_mem_brst_len(desc, pch, burst_size); + switch (direction) { case DMA_MEM_TO_DEV: desc->rqcfg.src_inc = 1; desc->rqcfg.dst_inc = 0; src = dma_addr; dst = pch->fifo_dma; + desc->rqcfg.src_brst_size = burst_size; + desc->rqcfg.src_brst_len = burst_len; + desc->rqcfg.dst_brst_size = pch->burst_sz; + desc->rqcfg.dst_brst_len = pch->burst_len; break; case DMA_DEV_TO_MEM: desc->rqcfg.src_inc = 0; desc->rqcfg.dst_inc = 1; src = pch->fifo_dma; dst = dma_addr; + desc->rqcfg.src_brst_size = pch->burst_sz; + desc->rqcfg.src_brst_len = pch->burst_len; + desc->rqcfg.dst_brst_size = burst_size; + desc->rqcfg.dst_brst_len = burst_len; break; default: break; } desc->rqtype = direction; - desc->rqcfg.src_brst_size = pch->burst_sz; - desc->rqcfg.src_brst_len = pch->burst_len; - desc->rqcfg.dst_brst_size = pch->burst_sz; - desc->rqcfg.dst_brst_len = pch->burst_len; desc->bytes_requested = period_len; fill_px(&desc->px, dst, src, period_len); @@ -2850,7 +2903,10 @@ pl330_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl, { struct dma_pl330_desc *first, *desc = NULL; struct dma_pl330_chan *pch = to_pchan(chan); + unsigned int burst_size, burst_len; struct scatterlist *sg; + dma_addr_t mem_addr; + size_t len; int i; if (unlikely(!pch || !sgl || !sg_len)) @@ -2882,29 +2938,37 @@ pl330_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl, else list_add_tail(&desc->node, &first->node); + mem_addr = sg_dma_address(sg); + len = sg_dma_len(sg); + + burst_size = get_periph_mem_brst_sz(mem_addr, len, pch); + burst_len = get_periph_mem_brst_len(desc, pch, burst_size); + switch (direction) { case DMA_MEM_TO_DEV: desc->rqcfg.src_inc = 1; desc->rqcfg.dst_inc = 0; - fill_px(&desc->px, pch->fifo_dma, sg_dma_address(sg), - sg_dma_len(sg)); + desc->rqcfg.src_brst_size = burst_size; + desc->rqcfg.src_brst_len = burst_len; + desc->rqcfg.dst_brst_size = pch->burst_sz; + desc->rqcfg.dst_brst_len = pch->burst_len; + fill_px(&desc->px, pch->fifo_dma, mem_addr, len); break; case DMA_DEV_TO_MEM: desc->rqcfg.src_inc = 0; desc->rqcfg.dst_inc = 1; - fill_px(&desc->px, sg_dma_address(sg), pch->fifo_dma, - sg_dma_len(sg)); + desc->rqcfg.src_brst_size = pch->burst_sz; + desc->rqcfg.src_brst_len = pch->burst_len; + desc->rqcfg.dst_brst_size = burst_size; + desc->rqcfg.dst_brst_len = burst_len; + fill_px(&desc->px, mem_addr, pch->fifo_dma, len); break; default: break; } - desc->rqcfg.src_brst_size = pch->burst_sz; - desc->rqcfg.src_brst_len = pch->burst_len; - desc->rqcfg.dst_brst_size = pch->burst_sz; - desc->rqcfg.dst_brst_len = pch->burst_len; desc->rqtype = direction; - desc->bytes_requested = sg_dma_len(sg); + desc->bytes_requested = len; } /* Return the last desc in the chain */ From patchwork Fri May 12 14:14:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joy Chakraborty X-Patchwork-Id: 93220 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp5151364vqo; Fri, 12 May 2023 07:30:33 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4KYQDzLyut1Vtvk4JQeIPBR0mjeba1C52va2G1Cp+c9G3H/3dkXUwZlv3flGCzNEsU43xp X-Received: by 2002:a05:6a21:33a8:b0:103:ee82:dc92 with SMTP id yy40-20020a056a2133a800b00103ee82dc92mr7720773pzb.60.1683901833301; Fri, 12 May 2023 07:30:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683901833; cv=none; d=google.com; s=arc-20160816; b=FoLzEzTi+T9XmAQ9JupwN29iYLdNb9aD+KXATz9fH4/lHBgSFUJRSdbRR2Di0XXV/e 87TwHHygjGqBU8+Qwiwv0fW31iiV3ECmbZzaqA/7l7hHgGb6S+0Dmu1d8piqeeEtI6j6 7LElgWIFWkjlMeV5gMSfVMTJRjltVzXpJYzHqaKmECrg0fnPZxtHq9ldsT7+KMcPCN4J UMqS8UFc5w/AukXXOXfqlTy63ds8WgxlHfY3RTRkJd4ZGu9PFYymy1BOTxtsQgzEbOtg 7/zEydOeq94ojdW0Fidzvx4GrOgbL384+m9IvCsTmGXSfgT4jA/tl4g8xVoXDr95CUrz xZkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=ghbGq9THJREEhkrSIStzO+A3rtDBCJPDalH7s9571pA=; b=k69++5uFj64B83MCKSKTqm19DJ8JfpV9C9r31LeZVn2p5sQiLtDOxG/TJNdByjxnIC u3h60790Kdi9rfrgNySL7Rgf1hnXsWv4V2LoZSBkEZ7UdQQSUrqKA+bSXCtWVXLbWedw 82Y1KLjOxwopUcAf4myucr5Cvdy6SczK2jzr1gumXn1dPZ9eSRyTnqMasCBh3E2ycotN BlwZgTf2UitqMH+KxEwxWgwC7b5kbBqLOcBZUvq4Xe/pV9BPKI+8fjOCh0VfM6XgV50d GCGB57Jeax//tel01UulFpEzAtS1UH8mQYdgzWN/zU7pDaVcmLDgKMPe//ONPnjw/3pr 39bA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=vF0Us9Ul; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h16-20020a056a00001000b0064693201e15si10392358pfk.344.2023.05.12.07.30.20; Fri, 12 May 2023 07:30:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=vF0Us9Ul; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241494AbjELOQB (ORCPT + 99 others); Fri, 12 May 2023 10:16:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47524 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241506AbjELOPx (ORCPT ); Fri, 12 May 2023 10:15:53 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F1F0D14E4C for ; Fri, 12 May 2023 07:15:32 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-b9a7553f95dso19610777276.2 for ; Fri, 12 May 2023 07:15:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1683900932; x=1686492932; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=ghbGq9THJREEhkrSIStzO+A3rtDBCJPDalH7s9571pA=; b=vF0Us9UlMXGLXLj1s1tWk3AyVw8tBCXUEnr9XNTtQ8N7JaOIqkdLiflH0w9EI9IaKU 6scnMtkiKb8kdFRAbRJ8uxb3wv8c6l6s7HCInpDhGo+HHup+aVHJfh4DVLtoEXs8+qni 31D/glRmakh4+sRhXNpuME3k1C7c6RRwKOgO3Ge3+dpvH6Q/HAPQnxd2uQd/C0VpSRN8 uX7KyG2x8Krb+3eoDO31JgPReMPbtHBoNpgSOMel1zh64Cr/kYop3aOITI3teaPF++Vz /HbNprO+LkKJ90JAZ3vjXe1sy8vKkJEPoTgkCpGzg2tNwx4lnwcWwdQFQYzSE446QO5S QX3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683900932; x=1686492932; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ghbGq9THJREEhkrSIStzO+A3rtDBCJPDalH7s9571pA=; b=UFg4OyfejL4EQ9FGOX8Ae3AaDSRZ1SzkXqoC8YniMJ+4ePF7aVeD0XmrPG6tD8hkES 3QULpFGp8LD2MelutHpDQnyk/KttK/bql4K/pTIIXmkEA/rywty2EDADr33B23GKbe0Z xI2WTeTJC2nIqcjhUN6r8zsZ45Be3YL/bIVek/M4BOeuKhmlukFz6KPQe072CXYZ4rKM sMwp4SZLudDswyr1sLwQVyRMHS8hUOYz1sYtmtC7Yf4RILirV8zav9gYx3Dy/a3yHxIm 4kkoIjlRr9YHI5juaZ5CvKzW+lfzUXbSMl3BS9pJn1WbMHK0k6R3VoMWLZbtV0IUYhlX iLUg== X-Gm-Message-State: AC+VfDyeyIliehzRDYp2LkBcQcquRzSpufM4jLfiovKN0cqoJ6oxXDpJ Gw1qqySkoZO2zMEWsWQO+MMnBwDW/+h8Ww== X-Received: from joychakr.c.googlers.com ([fda3:e722:ac3:cc00:4f:4b78:c0a8:6ea]) (user=joychakr job=sendgmr) by 2002:a25:c7d0:0:b0:ba7:1cea:ee12 with SMTP id w199-20020a25c7d0000000b00ba71ceaee12mr954256ybe.12.1683900931853; Fri, 12 May 2023 07:15:31 -0700 (PDT) Date: Fri, 12 May 2023 14:14:45 +0000 In-Reply-To: <20230512141445.2026660-1-joychakr@google.com> Mime-Version: 1.0 References: <20230512141445.2026660-1-joychakr@google.com> X-Mailer: git-send-email 2.40.1.606.ga4b1b128d6-goog Message-ID: <20230512141445.2026660-7-joychakr@google.com> Subject: [PATCH v2 6/6] dmaengine: pl330: Use dma singles for peripheral _dregs From: Joy Chakraborty To: Vinod Koul Cc: dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, manugautam@google.com, danielmentz@google.com, sjadavani@google.com, Joy Chakraborty X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765699048871850009?= X-GMAIL-MSGID: =?utf-8?q?1765699048871850009?= Use DMA singles in a loop to load/store data to the peripheral for the remaining bytes left after chucks of bursts are done, which is handled by the _dregs() function. If the transfer length is not a multiple of (AxLen*AxSize) then the _dregs function takes care of setting up CCR with residual burst required to complete the transaction. It does so by changing the AxLen in CCR and 1 burst of Load and Store. But some peripherals might not set the burst request signal to the DMA controller since the number of bytes to transfer is less then the initial size of burst requested i.e. AxLen*AxSize leading to a forever wait. Example of such a case : Considering a peripheral having an RX FIFO of n bytes and a sw configurable threshold level logic which drives the RX burst req signal to PL330 i.e. when data in the RX fifo crosses the threshold value the peripheral asserts the RX burst request to PL330 to copy data from the fifo in bursts. Taking an example say the Rx Fifo is 256 bytes in depth, the max AxLen is 16, max AxSize is 4bytes and 304 bytes had to copied from peripheral to memory. In this case the peripheral SW driver would configure the threshold to the maximum possible burst size (AxLen*AxSize) i.e. 64 bytes and pass the same to pl330 driver using src/dst_maxburst variable. PL330 would copy the first 256 bytes with 4 burst transactions and the 48 remaining bytes would be handled by _dregs(). Currently _dregs() would setup a burst for AxLen=3 and AxSize=16 to copy the 48bytes but since 48bytes is below the threshold configured at the peripheral the Rx burst request signal would not get set leading to a forever wait and timeout. This logic will copy the remaining 48bytes using single transactions of 4bytes each which would not depend on the burst req signal from the peripheral. Instructions generated for above example with logic change: DMAMOV CCR 0xbd0239 DMAMOV SAR 0xffffe000 DMAMOV DAR 0xffffc860 DMALP_1 3 DMAFLUSHP 0 DMAWFPB 0 DMALDB DMASTPB 0 DMALPENDA_1 bjmpto_7 DMAMOV CCR 0xad0229 DMALDA DMALP_0 11 DMAFLUSHP 0 DMAWFPS 0 DMASTPS 0 DMALPENDA_0 bjmpto_6 DMASEV 3 DMAEND Signed-off-by: Joy Chakraborty --- drivers/dma/pl330.c | 65 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 63 insertions(+), 2 deletions(-) diff --git a/drivers/dma/pl330.c b/drivers/dma/pl330.c index 46e254fd4007..2145f601939e 100644 --- a/drivers/dma/pl330.c +++ b/drivers/dma/pl330.c @@ -1208,6 +1208,67 @@ static inline int _ldst_peripheral(struct pl330_dmac *pl330, return off; } +/* + * Sets up transfers to peripheral using DMA Singles instead of Bursts. + * Data is moved between fifo and memory in bursts following which it is + * loaded/stored to peripheral using Loops of DMA singles based on + * transfer direction. + */ +static inline int _ldst_periph_single_dregs(struct pl330_dmac *pl330, + unsigned int dry_run, u8 buf[], + const struct _xfer_spec *pxs, + int src_length, int dst_length) +{ + int off = 0; + unsigned int ljmp, lpcnt; + struct _arg_LPEND lpend; + enum dma_transfer_direction direction = pxs->desc->rqtype; + + if (direction == DMA_MEM_TO_DEV) { + off += _emit_load(dry_run, &buf[off], ALWAYS, direction, + pxs->desc->peri); + lpcnt = dst_length; + } else { + lpcnt = src_length; + } + + /* + * Use Loop Cnt 0 to load/store from/to peripheral in single transactions + * since Burst Req might not be set as pending transfer length maybe less + * size of bytes to burst (AxSize * AxLen). + */ + off += _emit_LP(dry_run, &buf[off], 0, lpcnt); + ljmp = off; + + /* + * do FLUSHP at beginning to clear any stale dma requests before the + * first WFP. + */ + if (!(pl330->quirks & PL330_QUIRK_BROKEN_NO_FLUSHP)) + off += _emit_FLUSHP(dry_run, &buf[off], pxs->desc->peri); + + off += _emit_WFP(dry_run, &buf[off], SINGLE, pxs->desc->peri); + + if (direction == DMA_MEM_TO_DEV) + off += _emit_store(dry_run, &buf[off], SINGLE, direction, + pxs->desc->peri); + else + off += _emit_load(dry_run, &buf[off], SINGLE, direction, + pxs->desc->peri); + + lpend.cond = ALWAYS; + lpend.forever = false; + lpend.loop = 0; + lpend.bjump = off - ljmp; + off += _emit_LPEND(dry_run, &buf[off], &lpend); + + if (direction == DMA_DEV_TO_MEM) + off += _emit_store(dry_run, &buf[off], ALWAYS, direction, + pxs->desc->peri); + + return off; +} + static int _bursts(struct pl330_dmac *pl330, unsigned dry_run, u8 buf[], const struct _xfer_spec *pxs, int cyc) { @@ -1273,8 +1334,8 @@ static int _dregs(struct pl330_dmac *pl330, unsigned int dry_run, u8 buf[], case DMA_MEM_TO_DEV: case DMA_DEV_TO_MEM: off += _emit_MOV(dry_run, &buf[off], CCR, dregs_ccr); - off += _ldst_peripheral(pl330, dry_run, &buf[off], pxs, 1, - BURST); + off += _ldst_periph_single_dregs(pl330, dry_run, &buf[off], + pxs, src_length, dst_length); break; case DMA_MEM_TO_MEM: