From nobody Mon Feb 9 17:22:04 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5772FC7EE23 for ; Fri, 12 May 2023 14:15:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241476AbjELOPP (ORCPT ); Fri, 12 May 2023 10:15:15 -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-Google-Smtp-Source: ACHHUZ606I3ZcTGrIAGj3KmtJiebDv5RhcP3DxRfkMrJL64OO+mRwOKUmnmEexp2/X66k3JxQdAsUEMcSict+w== 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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)) =20 +#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; =20 enum pl330_cachectrl dcctl; enum pl330_cachectrl scctl; @@ -1204,7 +1212,10 @@ static int _bursts(struct pl330_dmac *pl330, unsigne= d dry_run, u8 buf[], const struct _xfer_spec *pxs, int cyc) { int off =3D 0; - enum pl330_cond cond =3D BRST_LEN(pxs->ccr) > 1 ? BURST : SINGLE; + enum pl330_cond cond =3D SINGLE; + + if (SRC_BRST_LEN(pxs->ccr) > 1 || DST_BRST_LEN(pxs->ccr) > 1) + cond =3D BURST; =20 if (pl330->quirks & PL330_QUIRK_PERIPH_BURST) cond =3D BURST; @@ -1235,12 +1246,12 @@ static int _bursts(struct pl330_dmac *pl330, unsign= ed 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 =3D 0; int dregs_ccr; =20 - if (transfer_length =3D=3D 0) + if (src_length =3D=3D 0 || dst_length =3D=3D 0) return off; =20 /* @@ -1253,9 +1264,9 @@ static int _dregs(struct pl330_dmac *pl330, unsigned = int dry_run, u8 buf[], dregs_ccr =3D pxs->ccr; dregs_ccr &=3D ~((0xf << CC_SRCBRSTLEN_SHFT) | (0xf << CC_DSTBRSTLEN_SHFT)); - dregs_ccr |=3D (((transfer_length - 1) & 0xf) << + dregs_ccr |=3D (((src_length - 1) & 0xf) << CC_SRCBRSTLEN_SHFT); - dregs_ccr |=3D (((transfer_length - 1) & 0xf) << + dregs_ccr |=3D (((dst_length - 1) & 0xf) << CC_DSTBRSTLEN_SHFT); =20 switch (pxs->desc->rqtype) { @@ -1369,16 +1380,18 @@ static inline int _setup_loops(struct pl330_dmac *p= l330, struct pl330_xfer *x =3D &pxs->desc->px; u32 ccr =3D pxs->ccr; unsigned long c, bursts =3D BYTE_TO_BURST(x->bytes, ccr); - int num_dregs =3D (x->bytes - BURST_TO_BYTE(bursts, ccr)) / - BRST_SIZE(ccr); - int off =3D 0; + int num_dreg_bytes =3D x->bytes - BURST_TO_BYTE(bursts, ccr); + int num_src_dregs, num_dst_dregs, off =3D 0; + + num_src_dregs =3D num_dreg_bytes / SRC_BRST_SIZE(ccr); + num_dst_dregs =3D num_dreg_bytes / DST_BRST_SIZE(ccr); =20 while (bursts) { c =3D bursts; off +=3D _loop(pl330, dry_run, &buf[off], &c, pxs); bursts -=3D c; } - off +=3D _dregs(pl330, dry_run, &buf[off], pxs, num_dregs); + off +=3D _dregs(pl330, dry_run, &buf[off], pxs, num_src_dregs, num_dst_dr= egs); =20 return off; } @@ -1446,11 +1459,11 @@ static inline u32 _prepare_ccr(const struct pl330_r= eqcfg *rqc) if (rqc->insnaccess) ccr |=3D CC_SRCIA | CC_DSTIA; =20 - ccr |=3D (((rqc->brst_len - 1) & 0xf) << CC_SRCBRSTLEN_SHFT); - ccr |=3D (((rqc->brst_len - 1) & 0xf) << CC_DSTBRSTLEN_SHFT); + ccr |=3D (((rqc->src_brst_len - 1) & 0xf) << CC_SRCBRSTLEN_SHFT); + ccr |=3D (((rqc->dst_brst_len - 1) & 0xf) << CC_DSTBRSTLEN_SHFT); =20 - ccr |=3D (rqc->brst_size << CC_SRCBRSTSIZE_SHFT); - ccr |=3D (rqc->brst_size << CC_DSTBRSTSIZE_SHFT); + ccr |=3D (rqc->src_brst_size << CC_SRCBRSTSIZE_SHFT); + ccr |=3D (rqc->dst_brst_size << CC_DSTBRSTSIZE_SHFT); =20 ccr |=3D (rqc->scctl << CC_SRCCCTRL_SHFT); ccr |=3D (rqc->dcctl << CC_DSTCCTRL_SHFT); @@ -2656,7 +2669,7 @@ static inline int get_burst_len(struct dma_pl330_desc= *desc, size_t len) =20 burst_len =3D pl330->pcfg.data_bus_width / 8; burst_len *=3D pl330->pcfg.data_buf_dep / pl330->pcfg.num_chan; - burst_len >>=3D desc->rqcfg.brst_size; + burst_len >>=3D desc->rqcfg.src_brst_size; =20 /* 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_dm= a_cyclic( } =20 desc->rqtype =3D direction; - desc->rqcfg.brst_size =3D pch->burst_sz; - desc->rqcfg.brst_len =3D pch->burst_len; + desc->rqcfg.src_brst_size =3D pch->burst_sz; + desc->rqcfg.src_brst_len =3D pch->burst_len; + desc->rqcfg.dst_brst_size =3D pch->burst_sz; + desc->rqcfg.dst_brst_len =3D pch->burst_len; desc->bytes_requested =3D period_len; fill_px(&desc->px, dst, src, period_len); =20 @@ -2789,17 +2804,21 @@ pl330_prep_dma_memcpy(struct dma_chan *chan, dma_ad= dr_t dst, while ((src | dst | len) & (burst - 1)) burst /=3D 2; =20 - desc->rqcfg.brst_size =3D 0; - while (burst !=3D (1 << desc->rqcfg.brst_size)) - desc->rqcfg.brst_size++; + desc->rqcfg.src_brst_size =3D 0; + while (burst !=3D (1 << desc->rqcfg.src_brst_size)) + desc->rqcfg.src_brst_size++; =20 - desc->rqcfg.brst_len =3D get_burst_len(desc, len); + desc->rqcfg.src_brst_len =3D 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 =3D 1; + desc->rqcfg.src_brst_len =3D 1; + + /* For Mem2Mem, set destination AxSize and AxLen same as source*/ + desc->rqcfg.dst_brst_len =3D desc->rqcfg.src_brst_len; + desc->rqcfg.dst_brst_size =3D desc->rqcfg.src_brst_size; =20 desc->bytes_requested =3D len; =20 @@ -2879,8 +2898,10 @@ pl330_prep_slave_sg(struct dma_chan *chan, struct sc= atterlist *sgl, sg_dma_len(sg)); } =20 - desc->rqcfg.brst_size =3D pch->burst_sz; - desc->rqcfg.brst_len =3D pch->burst_len; + desc->rqcfg.src_brst_size =3D pch->burst_sz; + desc->rqcfg.src_brst_len =3D pch->burst_len; + desc->rqcfg.dst_brst_size =3D pch->burst_sz; + desc->rqcfg.dst_brst_len =3D pch->burst_len; desc->rqtype =3D direction; desc->bytes_requested =3D sg_dma_len(sg); } --=20 2.40.1.606.ga4b1b128d6-goog From nobody Mon Feb 9 17:22:04 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B42C0C7EE23 for ; Fri, 12 May 2023 14:15:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240803AbjELOPX (ORCPT ); Fri, 12 May 2023 10:15:23 -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-Google-Smtp-Source: ACHHUZ5FF1KDxHSmDdCADl9UuEtrVgD3r0eClUYyRAGVWtfRWyouNuYTfOYNJtJsrlXdAXmgpxOCHVAtwCX34Q== 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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_add= r_t dst, while ((src | dst | len) & (burst - 1)) burst /=3D 2; =20 - desc->rqcfg.src_brst_size =3D 0; - while (burst !=3D (1 << desc->rqcfg.src_brst_size)) - desc->rqcfg.src_brst_size++; - + desc->rqcfg.src_brst_size =3D __ffs(burst); desc->rqcfg.src_brst_len =3D get_burst_len(desc, len); /* * If burst size is smaller than bus width then make sure we only --=20 2.40.1.606.ga4b1b128d6-goog From nobody Mon Feb 9 17:22:04 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 07131C7EE23 for ; Fri, 12 May 2023 14:15:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241478AbjELOPf (ORCPT ); Fri, 12 May 2023 10:15:35 -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-Google-Smtp-Source: ACHHUZ6vj73ZJJY9u+8pIa7SQmcBCLaiwjS1XLKrddb4JGDp5BRcKH1etJcsBSg/adpZUKOfhQdn8y9RDHibrQ== 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 s= catterlist *sgl, else list_add_tail(&desc->node, &first->node); =20 - if (direction =3D=3D DMA_MEM_TO_DEV) { + switch (direction) { + case DMA_MEM_TO_DEV: desc->rqcfg.src_inc =3D 1; desc->rqcfg.dst_inc =3D 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 =3D 0; desc->rqcfg.dst_inc =3D 1; fill_px(&desc->px, sg_dma_address(sg), pch->fifo_dma, sg_dma_len(sg)); + break; + default: + break; } =20 desc->rqcfg.src_brst_size =3D pch->burst_sz; --=20 2.40.1.606.ga4b1b128d6-goog From nobody Mon Feb 9 17:22:04 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EA78AC77B7F for ; Fri, 12 May 2023 14:15:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240231AbjELOPl (ORCPT ); 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-Google-Smtp-Source: ACHHUZ5ymR5y6St7F++9mZcC0W4aDFurpqueRtd+CJ72Z1j3cHVCDRUWUF25Pc7VzIilNjjP/KgcUj6STOExXg== 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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, d= ma_addr_t dst, return desc; } =20 -/* 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 =3D desc->pchan; struct pl330_dmac *pl330 =3D pch->dmac; @@ -2669,7 +2668,7 @@ static inline int get_burst_len(struct dma_pl330_desc= *desc, size_t len) =20 burst_len =3D pl330->pcfg.data_bus_width / 8; burst_len *=3D pl330->pcfg.data_buf_dep / pl330->pcfg.num_chan; - burst_len >>=3D desc->rqcfg.src_brst_size; + burst_len >>=3D brst_size; =20 /* 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 /=3D 2; =20 desc->rqcfg.src_brst_size =3D __ffs(burst); - desc->rqcfg.src_brst_len =3D get_burst_len(desc, len); + desc->rqcfg.src_brst_len =3D get_burst_len(desc, desc->rqcfg.src_brst_siz= e); /* * 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. --=20 2.40.1.606.ga4b1b128d6-goog From nobody Mon Feb 9 17:22:04 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 73DEFC7EE23 for ; Fri, 12 May 2023 14:15:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241509AbjELOPw (ORCPT ); Fri, 12 May 2023 10:15:52 -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-Google-Smtp-Source: ACHHUZ74NTF891q+rha9vQxX0ztAqHF8xmg+06mHuF47o0U+NFSy8mVkCqG5vTx05WHIlOepTiBReOAqZ/CQNA== 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 =3D 1 byte and AxLen =3D 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 =3D 16byte, AxLen =3D 1 and store to peripheral with AxSize =3D 1byte, AxLen =3D 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_des= c *desc, unsigned int brst_s return burst_len; } =20 +/* + * 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 =3D 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 /=3D 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 =3D pch->burst_len; + + if (burst_size !=3D pch->burst_sz) { + /* Select max possible burst len */ + burst_len =3D 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 =3D pch->burst_len >> (burst_size - pch->burst_sz); + else + pch->burst_len =3D 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 =3D NULL, *first =3D NULL; struct dma_pl330_chan *pch =3D to_pchan(chan); + unsigned int i, burst_size, burst_len; struct pl330_dmac *pl330 =3D pch->dmac; - unsigned int i; dma_addr_t dst; dma_addr_t src; =20 @@ -2729,28 +2775,35 @@ static struct dma_async_tx_descriptor *pl330_prep_d= ma_cyclic( return NULL; } =20 + burst_size =3D get_periph_mem_brst_sz(dma_addr, period_len, pch); + burst_len =3D get_periph_mem_brst_len(desc, pch, burst_size); + switch (direction) { case DMA_MEM_TO_DEV: desc->rqcfg.src_inc =3D 1; desc->rqcfg.dst_inc =3D 0; src =3D dma_addr; dst =3D pch->fifo_dma; + desc->rqcfg.src_brst_size =3D burst_size; + desc->rqcfg.src_brst_len =3D burst_len; + desc->rqcfg.dst_brst_size =3D pch->burst_sz; + desc->rqcfg.dst_brst_len =3D pch->burst_len; break; case DMA_DEV_TO_MEM: desc->rqcfg.src_inc =3D 0; desc->rqcfg.dst_inc =3D 1; src =3D pch->fifo_dma; dst =3D dma_addr; + desc->rqcfg.src_brst_size =3D pch->burst_sz; + desc->rqcfg.src_brst_len =3D pch->burst_len; + desc->rqcfg.dst_brst_size =3D burst_size; + desc->rqcfg.dst_brst_len =3D burst_len; break; default: break; } =20 desc->rqtype =3D direction; - desc->rqcfg.src_brst_size =3D pch->burst_sz; - desc->rqcfg.src_brst_len =3D pch->burst_len; - desc->rqcfg.dst_brst_size =3D pch->burst_sz; - desc->rqcfg.dst_brst_len =3D pch->burst_len; desc->bytes_requested =3D period_len; fill_px(&desc->px, dst, src, period_len); =20 @@ -2850,7 +2903,10 @@ pl330_prep_slave_sg(struct dma_chan *chan, struct sc= atterlist *sgl, { struct dma_pl330_desc *first, *desc =3D NULL; struct dma_pl330_chan *pch =3D to_pchan(chan); + unsigned int burst_size, burst_len; struct scatterlist *sg; + dma_addr_t mem_addr; + size_t len; int i; =20 if (unlikely(!pch || !sgl || !sg_len)) @@ -2882,29 +2938,37 @@ pl330_prep_slave_sg(struct dma_chan *chan, struct s= catterlist *sgl, else list_add_tail(&desc->node, &first->node); =20 + mem_addr =3D sg_dma_address(sg); + len =3D sg_dma_len(sg); + + burst_size =3D get_periph_mem_brst_sz(mem_addr, len, pch); + burst_len =3D get_periph_mem_brst_len(desc, pch, burst_size); + switch (direction) { case DMA_MEM_TO_DEV: desc->rqcfg.src_inc =3D 1; desc->rqcfg.dst_inc =3D 0; - fill_px(&desc->px, pch->fifo_dma, sg_dma_address(sg), - sg_dma_len(sg)); + desc->rqcfg.src_brst_size =3D burst_size; + desc->rqcfg.src_brst_len =3D burst_len; + desc->rqcfg.dst_brst_size =3D pch->burst_sz; + desc->rqcfg.dst_brst_len =3D pch->burst_len; + fill_px(&desc->px, pch->fifo_dma, mem_addr, len); break; case DMA_DEV_TO_MEM: desc->rqcfg.src_inc =3D 0; desc->rqcfg.dst_inc =3D 1; - fill_px(&desc->px, sg_dma_address(sg), pch->fifo_dma, - sg_dma_len(sg)); + desc->rqcfg.src_brst_size =3D pch->burst_sz; + desc->rqcfg.src_brst_len =3D pch->burst_len; + desc->rqcfg.dst_brst_size =3D burst_size; + desc->rqcfg.dst_brst_len =3D burst_len; + fill_px(&desc->px, mem_addr, pch->fifo_dma, len); break; default: break; } =20 - desc->rqcfg.src_brst_size =3D pch->burst_sz; - desc->rqcfg.src_brst_len =3D pch->burst_len; - desc->rqcfg.dst_brst_size =3D pch->burst_sz; - desc->rqcfg.dst_brst_len =3D pch->burst_len; desc->rqtype =3D direction; - desc->bytes_requested =3D sg_dma_len(sg); + desc->bytes_requested =3D len; } =20 /* Return the last desc in the chain */ --=20 2.40.1.606.ga4b1b128d6-goog From nobody Mon Feb 9 17:22:04 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 04794C77B7F for ; Fri, 12 May 2023 14:16:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241507AbjELOQC (ORCPT ); Fri, 12 May 2023 10:16:02 -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-Google-Smtp-Source: ACHHUZ5n4GOwp+yXNZiY6lRiLp1LINyIY9W5VlLM4zkXtJJ0m6OA3RidwExCa/CyBYADnz8F1YZwsAkCUT1AKw== 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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=3D3 and AxSize=3D16 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; } =20 +/* + * 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 =3D 0; + unsigned int ljmp, lpcnt; + struct _arg_LPEND lpend; + enum dma_transfer_direction direction =3D pxs->desc->rqtype; + + if (direction =3D=3D DMA_MEM_TO_DEV) { + off +=3D _emit_load(dry_run, &buf[off], ALWAYS, direction, + pxs->desc->peri); + lpcnt =3D dst_length; + } else { + lpcnt =3D 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 +=3D _emit_LP(dry_run, &buf[off], 0, lpcnt); + ljmp =3D off; + + /* + * do FLUSHP at beginning to clear any stale dma requests before the + * first WFP. + */ + if (!(pl330->quirks & PL330_QUIRK_BROKEN_NO_FLUSHP)) + off +=3D _emit_FLUSHP(dry_run, &buf[off], pxs->desc->peri); + + off +=3D _emit_WFP(dry_run, &buf[off], SINGLE, pxs->desc->peri); + + if (direction =3D=3D DMA_MEM_TO_DEV) + off +=3D _emit_store(dry_run, &buf[off], SINGLE, direction, + pxs->desc->peri); + else + off +=3D _emit_load(dry_run, &buf[off], SINGLE, direction, + pxs->desc->peri); + + lpend.cond =3D ALWAYS; + lpend.forever =3D false; + lpend.loop =3D 0; + lpend.bjump =3D off - ljmp; + off +=3D _emit_LPEND(dry_run, &buf[off], &lpend); + + if (direction =3D=3D DMA_DEV_TO_MEM) + off +=3D _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 +=3D _emit_MOV(dry_run, &buf[off], CCR, dregs_ccr); - off +=3D _ldst_peripheral(pl330, dry_run, &buf[off], pxs, 1, - BURST); + off +=3D _ldst_periph_single_dregs(pl330, dry_run, &buf[off], + pxs, src_length, dst_length); break; =20 case DMA_MEM_TO_MEM: --=20 2.40.1.606.ga4b1b128d6-goog