From: Xianwei Zhao <xianwei.zhao@amlogic.com>
To: Vinod Koul <vkoul@kernel.org>
Cc: 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>,
Frank Li <Frank.Li@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 v6 2/3] dmaengine: amlogic: Add general DMA driver for A9
Date: Thu, 19 Mar 2026 17:17:10 +0800 [thread overview]
Message-ID: <7ad0af10-5999-4cc1-88da-089c4174bcde@amlogic.com> (raw)
In-Reply-To: <abk3TUTaov3zIfFm@vaman>
Hi Vinod,
Thanks for your advice.
On 2026/3/17 19:13, Vinod Koul wrote:
> On 09-03-26, 06:33, Xianwei Zhao via B4 Relay wrote:
>> From: Xianwei Zhao<xianwei.zhao@amlogic.com>
>> +static dma_cookie_t aml_dma_tx_submit(struct dma_async_tx_descriptor *tx)
>> +{
>> + return dma_cookie_assign(tx);
>> +}
> You lost tx, why was it not saved into a queue?
>
>> +static struct dma_async_tx_descriptor *aml_dma_prep_slave_sg
>> + (struct dma_chan *chan, struct scatterlist *sgl,
>> + unsigned int sg_len, enum dma_transfer_direction direction,
>> + unsigned long flags, void *context)
>> +{
>> + 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;
>> + struct scatterlist *sg;
>> + int idx = 0;
>> + u64 paddr;
>> + u32 reg, link_count, avail, chan_id;
>> + u32 i;
>> +
>> + if (aml_chan->direction != direction) {
>> + dev_err(aml_dma->dma_device.dev, "direction not support\n");
>> + return NULL;
>> + }
>> +
>> + switch (aml_chan->status) {
>> + case DMA_IN_PROGRESS:
>> + dev_err(aml_dma->dma_device.dev, "not support multi tx_desciptor\n");
>> + return NULL;
> And why is that. You are preparing a descriptor and keep it ready and
> submit after the current one finishes
>
>
>> +
>> + case DMA_COMPLETE:
>> + aml_chan->data_len = 0;
>> + chan_id = aml_chan->chan_id;
>> + reg = (direction == DMA_DEV_TO_MEM) ? WCH_INT_MASK : RCH_INT_MASK;
>> + regmap_set_bits(aml_dma->regmap, reg, BIT(chan_id));
>> +
>> + break;
>> + default:
>> + dev_err(aml_dma->dma_device.dev, "status error\n");
>> + return NULL;
>> + }
>> +
>> + link_count = sg_nents_for_dma(sgl, sg_len, SG_MAX_LEN);
>> +
>> + if (link_count > DMA_MAX_LINK) {
>> + dev_err(aml_dma->dma_device.dev,
>> + "maximum number of sg exceeded: %d > %d\n",
>> + sg_len, DMA_MAX_LINK);
>> + aml_chan->status = DMA_ERROR;
>> + return NULL;
>> + }
>> +
>> + aml_chan->status = DMA_IN_PROGRESS;
>> +
>> + for_each_sg(sgl, sg, sg_len, i) {
>> + avail = sg_dma_len(sg);
>> + paddr = sg->dma_address;
>> + while (avail > SG_MAX_LEN) {
>> + sg_link = &aml_chan->sg_link[idx++];
>> + /* set dma address and len to sglink*/
>> + sg_link->address = paddr;
>> + sg_link->ctl = FIELD_PREP(LINK_LEN, SG_MAX_LEN);
>> + paddr = paddr + SG_MAX_LEN;
>> + avail = avail - SG_MAX_LEN;
>> + }
>> + sg_link = &aml_chan->sg_link[idx++];
>> + /* set dma address and len to sglink*/
>> + sg_link->address = paddr;
>> + sg_link->ctl = FIELD_PREP(LINK_LEN, avail);
>> +
>> + aml_chan->data_len += sg_dma_len(sg);
>> + }
>> + aml_chan->sg_link_cnt = idx;
> There is no descriptor management here. You are directly writing to
> channel. This is_very_ inefficient and defeats the use of dmaengine.
>
> Please revise the driver. Implement queues to manage multiple txns and
> we have vchan to help you implement these, so take use of that
>
I will take use vchan to support mltiple txns.
> --
> ~Vinod
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
next prev parent reply other threads:[~2026-03-19 9:17 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-09 6:33 [PATCH v6 0/3] Add Amlogic general DMA Xianwei Zhao via B4 Relay
2026-03-09 6:33 ` [PATCH v6 1/3] dt-bindings: dma: Add Amlogic A9 SoC DMA Xianwei Zhao via B4 Relay
2026-03-09 6:33 ` [PATCH v6 2/3] dmaengine: amlogic: Add general DMA driver for A9 Xianwei Zhao via B4 Relay
2026-03-09 15:50 ` Frank Li
2026-03-17 11:13 ` Vinod Koul
2026-03-19 9:17 ` Xianwei Zhao [this message]
2026-03-09 6:33 ` [PATCH v6 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=7ad0af10-5999-4cc1-88da-089c4174bcde@amlogic.com \
--to=xianwei.zhao@amlogic.com \
--cc=Frank.Li@kernel.org \
--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 \
/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®