DMA Engine development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Vishnu Santhosh" <vishnu.santhosh@oss.qualcomm.com>
Cc: dmaengine@vger.kernel.org, vkoul@kernel.org, Frank.Li@kernel.org
Subject: Re: [PATCH net-next 1/3] dmaengine: qcom: bam_dma: report residue for completed RX transfers
Date: Fri, 04 Dec 2026 16:11:38 +0000	[thread overview]
Message-ID: <sashiko-outbox-250165@kernel.org> (raw)
In-Reply-To: <20261203-qcom-bam-dmux-qmap-v1-1-abc2e80a03af@oss.qualcomm.com>

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] dmaengine: qcom: bam_dma: uncached RX FIFO reads when
  callback_result is NULL
- [Medium] dmaengine: qcom: bam_dma: dma_rmb() does not order MMIO
  readl_relaxed()
--

commit cd588835da7396c54277f73b33e53000bbc1fb9a
Author: Vishnu Santhosh <vishnu.santhosh@oss.qualcomm.com>

dmaengine: qcom: bam_dma: report residue for completed RX transfers

This commit adds bam_update_rx_result() to read hardware-written descriptor
sizes from the RX FIFO on transfer completion and report the unused bytes as
residue via callback_result.

> diff --git a/drivers/dma/qcom/bam_dma.c b/drivers/dma/qcom/bam_dma.c
> index e62e411dc8f8b..b5d661b9af3df 100644
> --- a/drivers/dma/qcom/bam_dma.c
> +++ b/drivers/dma/qcom/bam_dma.c
> @@ -834,6 +834,57 @@ static int bam_resume(struct dma_chan *chan)

[ ... ]

> +static void bam_update_rx_result(struct bam_chan *bchan,
> +				 struct bam_async_desc *async_desc)
> +{
> +	struct bam_desc_hw *fifo = PTR_ALIGN(bchan->fifo_virt,
> +					    sizeof(struct bam_desc_hw));
> +	u32 i;
> +
> +	if (async_desc->dir != DMA_DEV_TO_MEM)
> +		return;
> +
> +	/* Read the written back sizes only after reading BAM_P_SW_OFSTS */
> +	dma_rmb();

[Severity: Medium]
Is dma_rmb() sufficient to order FIFO reads after the readl_relaxed() of
BAM_P_SW_OFSTS in process_channel_irqs()?

As Documentation/memory-barriers.txt notes, dma_*() barriers do not order
MMIO accesses.  On 32-bit ARMv7, dma_rmb() emits dmb(osh) instead of the
dsb() used by readl(), allowing bchan->fifo_virt reads to see stale sizes
and report a wrong residue to clients like BAM-DMUX.

Also, because process_channel_irqs() calls bam_update_rx_result() inside
the desc_list loop, the barrier runs once per completed descriptor instead
of once per channel interrupt.  Using readl() for BAM_P_SW_OFSTS in
process_channel_irqs() and removing dma_rmb() here addresses both.

> +
> +	for (i = 0; i < async_desc->xfer_len; i++) {
> +		u16 expected = le16_to_cpu(async_desc->curr_desc[i].size);
> +		u16 received = le16_to_cpu(fifo[(bchan->head + i) %
> +						 MAX_DESCRIPTORS].size);

[Severity: Medium]
Should bam_update_rx_result() return early when
!async_desc->vd.tx.callback_result?

bchan->fifo_virt is allocated with dma_alloc_wc(), so this loop does up to
async_desc->xfer_len uncached reads in hardirq under bchan->vc.lock.
Existing clients such as QCE crypto set only a plain callback, so
vd->tx_result is discarded and every RX completion pays this latency hit.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261203-qcom-bam-dmux-qmap-v1-0-abc2e80a03af@oss.qualcomm.com?part=1

  parent reply	other threads:[~2026-12-04 16:11 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-03 16:10 [PATCH net-next 0/3] net: wwan: qcom_bam_dmux: Add QMAP support Vishnu Santhosh
2026-12-03 16:10 ` [PATCH net-next 1/3] dmaengine: qcom: bam_dma: report residue for completed RX transfers Vishnu Santhosh
2026-12-03 16:19   ` Frank Li
2026-12-04 10:10   ` Stephan Gerhold
2026-12-04 11:18     ` Nickolay Goppen
2026-12-04 11:31     ` Nickolay Goppen
2026-12-04 16:11   ` sashiko-bot [this message]
2026-12-04 17:06   ` netdev-bot+sashiko
2026-12-03 16:10 ` [PATCH net-next 2/3] net: wwan: qcom_bam_dmux: use DMA transfer size for RX packets Vishnu Santhosh
2026-12-04 10:14   ` Stephan Gerhold
2026-12-04 17:06   ` netdev-bot+sashiko
2026-12-03 16:10 ` [PATCH net-next 3/3] net: wwan: qcom_bam_dmux: enable QMAP if supported by the modem Vishnu Santhosh
2026-12-03 19:22   ` Loic Poulain
2026-12-04 10:42   ` Stephan Gerhold
2026-12-04 16:11   ` sashiko-bot
2026-12-04 17:06   ` netdev-bot+sashiko

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=sashiko-outbox-250165@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=Frank.Li@kernel.org \
    --cc=dmaengine@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=vishnu.santhosh@oss.qualcomm.com \
    --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