From: Frank Li <Frank.li@nxp.com>
To: Xianwei Zhao <xianwei.zhao@amlogic.com>
Cc: Vinod Koul <vkoul@kernel.org>, Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>, Kees Cook <kees@kernel.org>,
"Gustavo A. R. Silva" <gustavoars@kernel.org>,
linux-amlogic@lists.infradead.org, dmaengine@vger.kernel.org,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-hardening@vger.kernel.org
Subject: Re: [PATCH v2 2/3] dma: amlogic: Add general DMA driver for A9
Date: Mon, 2 Feb 2026 11:10:08 -0500 [thread overview]
Message-ID: <aYDMYPwNM9WnTl2u@lizhi-Precision-Tower-5810> (raw)
In-Reply-To: <260d0d7d-4324-4fd6-b12d-50ffeaa82114@amlogic.com>
On Mon, Feb 02, 2026 at 05:23:13PM +0800, Xianwei Zhao wrote:
> Hi Frank,
> Thanks for your reply.
>
> On 2026/1/30 02:04, Frank Li wrote:
> > [You don't often get email from frank.li@nxp.com. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
> >
>
> Will do.
>
Needn't this next time to save reader time. Just leave part, which need
discussion.
> > > +
...
> > > + /* set dma address and len to sglink*/
> > > + sg_link->address = sg->dma_address;
> > > + sg_link->ctl = FIELD_PREP(LINK_LEN, sg_dma_len(sg));
> > > +
> > > + aml_chan->data_len += sg_dma_len(sg);
> > > + }
> > > + aml_chan->sg_link_cnt = idx;
> > > +
> > > + return &aml_chan->desc;
> >
> > Here have problems, if caller
> >
> > a = dmaengine_prep_slave_sg();
> > ...
> > b = dmaengine_prep_slave_sg();
> >
> > submit(a); submit(b);
> >
> > API don't limit that prep_slave_sg() must follow submit().
> >
>
> Our DMA module uses a dedicated DMA channel per device and supports
> scatter-gather mode.
>
> In function "prep_slave_sg" , data list has been placed in the hardware
> executable queue,
> and the "submit" do nothing but assign cookies to prevent function
> dma_async_is_tx_complete called error.
Vnod can provide more comments. but according to my options, you should
not have such assumption. If one driver use dma provider 1 work, some daysi
later, switch to provider 2, it fail to work slience.
DMA doc already define API and hehavors, it'd better to follow it.
>
> When device_issue_pending is called, all data list will be processed.
>
> > > +}
> > > +
...
> > > +static void aml_dma_enable_chan(struct dma_chan *chan)
> > > +{
> > > + struct aml_dma_chan *aml_chan = to_aml_dma_chan(chan);
> > > + struct aml_dma_dev *aml_dma = aml_chan->aml_dma;
> > > + struct aml_dma_sg_link *sg_link;
> > > + int chan_id = aml_chan->chan_id;
> > > + int idx = aml_chan->sg_link_cnt - 1;
> > > +
> > > + /* the last sg set eoc flag */
> > > + sg_link = &aml_chan->sg_link[idx];
> > > + sg_link->ctl |= LINK_EOC;
> > > + dma_wmb();
> >
> > why need it? regmap_write() already have dma_wmb();
> >
>
> regmap_write will call wmb() / iowmb(), not dma_wmb.
> So I think it's best to keep it.
It included dma_wmb() in iowmb(), some system use the same implemention for
iowmb to dwm_wmb().
All memory barray require comments. Redundant dwm will cause others
confuse.
If it doesn't work without dma_wmb(), your wmb() will have bigger problem
in your system, which will be really hard to debug.
Frank
>
> > Frank
> > > + if (aml_chan->direction == DMA_MEM_TO_DEV) {
> > > + regmap_write(aml_dma->regmap, aml_chan->reg_offs + RCH_ADDR,
> > > + aml_chan->sg_link_phys);
> > > + regmap_write(aml_dma->regmap, aml_chan->reg_offs + RCH_LEN, aml_chan->data_len);
> > > + regmap_update_bits(aml_dma->regmap, RCH_INT_MASK, BIT(chan_id), 0);
> > > + /* for rch (tx) need set cfg 0 to trigger start */
> > > + regmap_write(aml_dma->regmap, aml_chan->reg_offs + RCH_CFG, 0);
> > > + } else if (aml_chan->direction == DMA_DEV_TO_MEM) {
> > > + regmap_write(aml_dma->regmap, aml_chan->reg_offs + WCH_ADDR,
> > > + aml_chan->sg_link_phys);
> > > + regmap_write(aml_dma->regmap, aml_chan->reg_offs + WCH_LEN, aml_chan->data_len);
> > > + regmap_update_bits(aml_dma->regmap, WCH_INT_MASK, BIT(chan_id), 0);
> > > + }
> > > +}
...
> > > +
> > > + .of_match_table = aml_dma_ids,
> > > + },
> > > +};
> > > +
> > > +module_platform_driver(aml_dma_driver);
> > > +
> > > +MODULE_DESCRIPTION("GENERAL DMA driver for Amlogic");
> > > +MODULE_AUTHOR("Xianwei Zhao <xianwei.zhao@amlogic.com>");
> > > +MODULE_LICENSE("GPL");
> > >
> > > --
> > > 2.52.0
> > >
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
next prev parent reply other threads:[~2026-02-02 16:10 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-27 3:27 [PATCH v2 0/3] Add Amlogic general DMA Xianwei Zhao via B4 Relay
2026-01-27 3:27 ` [PATCH v2 1/3] dt-bindings: dma: Add Amlogic A9 SoC DMA Xianwei Zhao via B4 Relay
2026-01-29 17:54 ` Frank Li
2026-02-02 8:21 ` Xianwei Zhao
2026-01-27 3:27 ` [PATCH v2 2/3] dma: amlogic: Add general DMA driver for A9 Xianwei Zhao via B4 Relay
2026-01-29 18:04 ` Frank Li
2026-02-02 9:23 ` Xianwei Zhao
2026-02-02 16:10 ` Frank Li [this message]
2026-01-27 3:27 ` [PATCH v2 3/3] MAINTAINERS: Add an entry for Amlogic DMA driver Xianwei Zhao via B4 Relay
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aYDMYPwNM9WnTl2u@lizhi-Precision-Tower-5810 \
--to=frank.li@nxp.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dmaengine@vger.kernel.org \
--cc=gustavoars@kernel.org \
--cc=kees@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linux-amlogic@lists.infradead.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=robh@kernel.org \
--cc=vkoul@kernel.org \
--cc=xianwei.zhao@amlogic.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®