Linux PCI subsystem development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Frank Li" <Frank.Li@nxp.com>
Cc: vkoul@kernel.org, Frank.Li@kernel.org, linux-pci@vger.kernel.org,
	imx@lists.linux.dev, dmaengine@vger.kernel.org
Subject: Re: [PATCH v5 7/9] nvmet: pci-epf: Use dmaengine_prep_config_single_safe() API
Date: Thu, 14 May 2026 01:16:20 +0000	[thread overview]
Message-ID: <20260514011621.065FDC19425@smtp.kernel.org> (raw)
In-Reply-To: <20260512-dma_prep_config-v5-7-26865bf7d935@nxp.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Removing the DMA serialization mutex causes severe CPU starvation, spurious timeouts, and cascading DMA transfer aborts.
- [Low] Unused local variable triggers a compiler warning and leaves dead mutexes in the device structure.
--

commit 4b68a703ef44d7ed4b6b20d869ad94bab23d5076
Author: Frank Li <Frank.Li@nxp.com>

nvmet: pci-epf: Use dmaengine_prep_config_single_safe() API

This commit uses the new dmaengine_prep_config_single_safe() API to combine
DMA configuration and descriptor preparation into a single call. It also
removes the mutex that was previously used in the DMA transfer path.

> Since dmaengine_prep_config_single_safe() performs the configuration and
> preparation atomically and the mutex can be removed.

Is this description entirely accurate?

While the configuration and preparation might now be atomic, the mutex also
strictly serialized the DMA transaction pipeline.

> 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);

Does removing this mutex introduce concurrency regressions with the shared DMA
channel during the wait phase?

With the mutex removed, multiple concurrent NVMe worker threads can submit
transfers to the same channel. Since dma_sync_wait() busy-waits using
cpu_relax(), could multiple threads spinning simultaneously lead to severe CPU
starvation?

Additionally, dma_sync_wait() has a hardcoded 5-second timeout computed at
entry. If concurrent transfers queue up, could later transfers spuriously
time out while waiting for earlier ones to finish in hardware?

If a spurious timeout occurs, the error path further down calls
dmaengine_terminate_sync(chan). Does this unconditionally abort all active
and pending transfers on the shared channel, potentially causing cascading
data transfer failures?

Could unbounded concurrent submissions also exhaust the DMA channel's
fixed-size descriptor pool under load?

> -
>  	dma_dev = dmaengine_get_dma_device(chan);
>  	dma_addr = dma_map_single(dma_dev, seg->buf, seg->length, dir);
>  	ret = dma_mapping_error(dma_dev, dma_addr);
>  	if (ret)
> -		goto unlock;
> -
> -	ret = dmaengine_slave_config(chan, &sconf);
> -	if (ret) {
> -		dev_err(dev, "Failed to configure DMA channel\n");
> -		goto unmap;
> -	}
> +		return ret;

[ ... ]

> @@ -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;
>  }

This isn't a bug, but does leaving the local lock variable and its assignments
in the preceding switch statement trigger a -Wunused-but-set-variable compiler
warning?

Also, since dma_rx_lock and dma_tx_lock in struct nvmet_pci_epf are no
longer used anywhere else, should they be removed from the structure to avoid
leaving dead code?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260512-dma_prep_config-v5-0-26865bf7d935@nxp.com?part=7

  reply	other threads:[~2026-05-14  1:16 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-12 16:41 [PATCH v5 0/9] dmaengine: Add new API to combine configuration and descriptor preparation Frank Li
2026-05-12 16:41 ` [PATCH v5 1/9] dmaengine: Add API to combine configuration and preparation (sg and single) Frank Li
2026-05-12 16:42 ` [PATCH v5 2/9] dmaengine: Add safe API to combine configuration and preparation Frank Li
2026-05-13 23:54   ` sashiko-bot
2026-05-12 16:42 ` [PATCH v5 3/9] PCI: endpoint: pci-epf-test: Use dmaenigne_prep_config_single() to simplify code Frank Li
2026-05-12 16:42 ` [PATCH v5 4/9] dmaengine: dw-edma: Use new .device_prep_config_sg() callback Frank Li
2026-05-14  0:10   ` sashiko-bot
2026-05-12 16:42 ` [PATCH v5 5/9] dmaengine: dw-edma: Pass dma_slave_config to dw_edma_device_transfer() Frank Li
2026-05-14  0:38   ` sashiko-bot
2026-05-12 16:42 ` [PATCH v5 6/9] nvmet: pci-epf: Remove unnecessary dmaengine_terminate_sync() on each DMA transfer Frank Li
2026-05-12 16:42 ` [PATCH v5 7/9] nvmet: pci-epf: Use dmaengine_prep_config_single_safe() API Frank Li
2026-05-14  1:16   ` sashiko-bot [this message]
2026-05-12 16:42 ` [PATCH v5 8/9] PCI: epf-mhi: Use dmaengine_prep_config_single() to simplify code Frank Li
2026-05-12 16:42 ` [PATCH v5 9/9] crypto: atmel: Use dmaengine_prep_config_single() API Frank Li
2026-05-14  1:49   ` 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=20260514011621.065FDC19425@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=Frank.Li@kernel.org \
    --cc=Frank.Li@nxp.com \
    --cc=dmaengine@vger.kernel.org \
    --cc=imx@lists.linux.dev \
    --cc=linux-pci@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --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