From: sashiko-bot@kernel.org
To: "Frank Li" <Frank.Li@nxp.com>
Cc: linux-pci@vger.kernel.org
Subject: Re: [PATCH v4 5/9] dmaengine: dw-edma: Pass dma_slave_config to dw_edma_device_transfer()
Date: Wed, 06 May 2026 22:36:31 +0000 [thread overview]
Message-ID: <20260506223632.3515EC2BCB0@smtp.kernel.org> (raw)
In-Reply-To: <20260506-dma_prep_config-v4-5-85b3d22babff@nxp.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Ignored return value of dw_edma_device_config() causes transfer to proceed with rejected configuration.
- [High] Data races and violation of atomic configuration due to lockless global state mutation in dw_edma_device_prep_config_sg().
--
commit c3c3192e70e9eff9723db89a8944f9898577a1fd
Author: Frank Li <Frank.Li@nxp.com>
dmaengine: dw-edma: Pass dma_slave_config to dw_edma_device_transfer()
Pass dma_slave_config to dw_edma_device_transfer() to support atomic
configuration and descriptor preparation when a non-NULL config is
provided to device_prep_config_sg().
Tested-by: Niklas Cassel <cassel@kernel.org>
Signed-off-by: Frank Li <Frank.Li@nxp.com>
> diff --git a/drivers/dma/dw-edma/dw-edma-core.c b/drivers/dma/dw-edma/dw-edma-core.c
> index f7f58b0010e26..ec6f6b1e48256 100644
> --- a/drivers/dma/dw-edma/dw-edma-core.c
> +++ b/drivers/dma/dw-edma/dw-edma-core.c
[ ... ]
> @@ -595,7 +610,7 @@ dw_edma_device_prep_config_sg(struct dma_chan *dchan, struct scatterlist *sgl,
> if (config)
> dw_edma_device_config(dchan, config);
Is it safe to ignore the return value of dw_edma_device_config() here?
If dw_edma_device_config() fails, for example by returning -EINVAL due to a
peripheral_size mismatch, the code will still call dw_edma_device_transfer()
with the rejected config.
Since dw_edma_device_config() sets chan->non_ll = false before validating the
peripheral config, a failed call might also leave the channel in an
inconsistent state.
Should this check the return value and return NULL on failure?
Additionally, the commit message mentions this change is to support atomic
configuration. When device_prep_config_sg() is implemented, the dmaengine
core deliberately bypasses chan->lock via dmaengine_prep_config_sg_safe(),
expecting the callback to be re-entrant and thread-safe.
However, dw_edma_device_config() modifies global channel state:
drivers/dma/dw-edma/dw-edma-core.c:dw_edma_device_config() {
...
chan->non_ll = false;
...
memcpy(&chan->config, config, sizeof(*config));
chan->configured = true;
...
}
If multiple threads prepare descriptors on the same channel concurrently,
won't they data race on these fields?
Furthermore, dw_edma_device_transfer() still reads the mutated chan->non_ll
to determine bursts_max. Does this break the re-entrancy promised by the safe
API, potentially leading to incorrectly programmed hardware descriptors?
> - return dw_edma_device_transfer(&xfer);
> + return dw_edma_device_transfer(&xfer, dw_edma_device_get_config(dchan, config));
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260506-dma_prep_config-v4-0-85b3d22babff@nxp.com?part=5
next prev parent reply other threads:[~2026-05-06 22:36 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-06 20:44 [PATCH v4 0/9] dmaengine: Add new API to combine configuration and descriptor preparation Frank Li
2026-05-06 20:44 ` [PATCH v4 1/9] dmaengine: Add API to combine configuration and preparation (sg and single) Frank Li
2026-05-06 21:39 ` sashiko-bot
2026-05-06 20:44 ` [PATCH v4 2/9] dmaengine: Add safe API to combine configuration and preparation Frank Li
2026-05-06 22:02 ` sashiko-bot
2026-05-06 20:44 ` [PATCH v4 3/9] PCI: endpoint: pci-epf-test: Use dmaenigne_prep_config_single() to simplify code Frank Li
2026-05-06 20:44 ` [PATCH v4 4/9] dmaengine: dw-edma: Use new .device_prep_config_sg() callback Frank Li
2026-05-06 22:17 ` sashiko-bot
2026-05-06 20:44 ` [PATCH v4 5/9] dmaengine: dw-edma: Pass dma_slave_config to dw_edma_device_transfer() Frank Li
2026-05-06 22:36 ` sashiko-bot [this message]
2026-05-06 20:44 ` [PATCH v4 6/9] nvmet: pci-epf: Remove unnecessary dmaengine_terminate_sync() on each DMA transfer Frank Li
2026-05-06 20:44 ` [PATCH v4 7/9] nvmet: pci-epf: Use dmaengine_prep_config_single_safe() API Frank Li
2026-05-06 23:05 ` sashiko-bot
2026-05-06 20:44 ` [PATCH v4 8/9] PCI: epf-mhi: Use dmaengine_prep_config_single() to simplify code Frank Li
2026-05-06 23:26 ` sashiko-bot
2026-05-06 20:44 ` [PATCH v4 9/9] crypto: atmel: Use dmaengine_prep_config_single() API Frank Li
2026-05-06 23:31 ` sashiko-bot
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=20260506223632.3515EC2BCB0@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=Frank.Li@nxp.com \
--cc=linux-pci@vger.kernel.org \
--cc=sashiko@lists.linux.dev \
/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