From: sashiko-bot@kernel.org
To: "Frank Li" <Frank.Li@nxp.com>
Cc: linux-pci@vger.kernel.org
Subject: Re: [PATCH v4 7/9] nvmet: pci-epf: Use dmaengine_prep_config_single_safe() API
Date: Wed, 06 May 2026 23:05:38 +0000 [thread overview]
Message-ID: <20260506230539.1257EC2BCB0@smtp.kernel.org> (raw)
In-Reply-To: <20260506-dma_prep_config-v4-7-85b3d22babff@nxp.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Removing the mutex introduces a severe concurrency bug, leading to spurious channel-wide termination of DMA transfers and CPU starvation.
- [Low] The local variable `lock` is assigned but never used, resulting in a compiler warning.
--
commit 36bcfc6ae688edc18d4bf05e641f168d44b9db2c
Author: Frank Li <Frank.Li@nxp.com>
nvmet: pci-epf: Use dmaengine_prep_config_single_safe() API
This commit updates the driver to use the new
dmaengine_prep_config_single_safe() API, combining configuration and
descriptor preparation into a single call. It also removes the mutex lock
used during the transfer since the combined preparation is atomic.
> diff --git a/drivers/nvme/target/pci-epf.c b/drivers/nvme/target/pci-epf.c
> index 2afe8f4d0e461..04d8f48d69503 100644
> --- a/drivers/nvme/target/pci-epf.c
> +++ b/drivers/nvme/target/pci-epf.c
> @@ -388,22 +388,15 @@ static int nvmet_pci_epf_dma_transfer(struct nvmet_pci_epf *nvme_epf,
> return -EINVAL;
> }
>
> - mutex_lock(lock);
> -
Is the local variable lock still needed here? Since the mutex_lock() and
mutex_unlock() calls are removed, the earlier assignments of this variable
in the switch statement appear to be unused and might trigger a compiler
warning.
[ ... ]
> @@ -426,9 +419,6 @@ static int nvmet_pci_epf_dma_transfer(struct nvmet_pci_epf *nvme_epf,
> unmap:
> dma_unmap_single(dma_dev, dma_addr, seg->length, dir);
>
> -unlock:
> - mutex_unlock(lock);
> -
> return ret;
> }
Does removing this lock introduce concurrency issues with dma_sync_wait()
and the error handling path?
Looking at the remainder of nvmet_pci_epf_dma_transfer(), it calls:
if (dma_sync_wait(chan, cookie) != DMA_COMPLETE) {
dev_err(dev, "DMA transfer failed\n");
ret = -EIO;
dmaengine_terminate_sync(chan);
}
If the mutex is removed, multiple threads could concurrently submit
transfers to the same DMA channel and enter dma_sync_wait(). Since
dma_sync_wait() polls for completion, could this lead to CPU starvation
from multiple threads busy-spinning concurrently?
Additionally, if one thread fails or times out in dma_sync_wait(), it
will call dmaengine_terminate_sync(chan). Will this indiscriminately
abort the in-flight transfers of all other concurrently executing threads
on the same channel?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260506-dma_prep_config-v4-0-85b3d22babff@nxp.com?part=7
next prev parent reply other threads:[~2026-05-06 23:05 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
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 [this message]
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=20260506230539.1257EC2BCB0@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