From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796403969; b=kGpz7e9XVFPCMR/fzqtMj3Nc3eBPRaGI+5joa2syhodv8l3yVEH/t0+qA7FCPcsCHGzd WpaCPOtD7LDo4uI5j97bquP1Kx3F1M3bD/nGGkeLLq7eZMGJ61vNBFQPWDMFXuPT8fvqp dz59ywjEUmZuijZ16zxqsxLUoo+L0yGQMmQOQdJrjr1bUUI+XJEBBSVks93ah0tex048n TgCuXSi348x1mBSriqulQnY4vtmQ5e6Fz4Ad9Yhbxcu3vlpPE+tg21TlERQRNyK6DmFs5 qlnCEgK6zR+ZhKNiL9qZEwgquvqlktRDHMY2+r6eW4dvv615zT5M7jC/u1xkrfzqAqA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796403969; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=Wod5ol48sWL4LACMzogKRZspc5XxS3C8asNfEvSYc4U=; b=gNBMCEmVmDWTDgKBfatJW3D9mPJIZtxarq0sClGzRKlKLKvLBGQk8BpFCwrX18V4Aeab XGvQMSXqcXdX9EAQsp0Co+8xAHutf9XYTCzhyvWUQyjaD32EzwvXegq9oifbuCJ4DZ38P DAp646r0zS3NmtaxyCBrGueE/i9krDfNA+GiuyxgFodnI/lkOxRSdDvbto2Q9pIHwo7s0 nuD8nZ5AdHaDir889tD1+CwJ4BE91IDsFM2WhJiVIqA7UQ/NIkuRGxTU9LeZT9JoCTJw8 19tQ4sC1hPEM061yuTJMRis2Mzaj8/q+sy08CvGtkOmbbF3q6GKh3gO/boWXujQFFew== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=mDVjd7e4; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1C4F8606A322; Fri, 4 Dec 2026 17:06:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=mDVjd7e4 Received: by smtp.kernel.org (Postfix) with ESMTPSA id BC4471F0093B; Fri, 4 Dec 2026 17:06:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796403968; bh=Wod5ol48sWL4LACMzogKRZspc5XxS3C8asNfEvSYc4U=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=mDVjd7e4SCJCcvThYTr0kiytHGj7UKtAZ3HHZwHreczbcseostkMxouP3MUOIH9BI FS4PZOxc5HNZ5QQHhA5XTIwav7FceBfroVVz1YcxtE9Pgx04QPpqZXrpypdwjUrAgI tGUtQUck5LRdvdyz6Fxq7D3rDxXB8QPR4OmEvUe5QzvDjjmuq65RZVM0csC0t6haEE 3kmPB8JwCyIrjmwI+feIxo/6b2KLNdVCzyxxkHVG5mbvB8rnb6i47yWtbbTZW8LU0w Knbs9JYgZ2Knnq2SI6qsLnAsF5RxgbCns9PdWKadFqlETADyvPEIwDj2jQAF7vlwMx rhqLQsxtJzHRA== Subject: Re: [PATCH net-next 1/3] dmaengine: qcom: bam_dma: report residue for completed RX transfers From: netdev-bot+sashiko@kernel.org To: vishnu.santhosh@oss.qualcomm.com Cc: vkoul@kernel.org, Frank.Li@kernel.org, stephan@gerhold.net, loic.poulain@oss.qualcomm.com, ryazanov.s.a@gmail.com, johannes@sipsolutions.net, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, linux-arm-msm@vger.kernel.org, dmaengine@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, deepak.singh@oss.qualcomm.com Date: Fri, 04 Dec 2026 17:06:07 +0000 Message-ID: <179640396727.3146.6895938404656144166@kernel.org> In-Reply-To: <20261203-qcom-bam-dmux-qmap-v1-1-abc2e80a03af@oss.qualcomm.com> References: <20261203-qcom-bam-dmux-qmap-v1-1-abc2e80a03af@oss.qualcomm.com> X-sashiko-severity: Medium Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider. Critical: 0 · High: 0 · Medium: 1 · Low: 0 If you believe none of the issues are legitimate, please reply to each issue of Medium severity or higher and explain why the AI is wrong. If any of them are legitimate and you plan to respin, please let patchwork know by including "pw-bot: cr" as a separate line at the end of your reply (one such reply per series is enough). - [Medium] dmaengine: qcom: bam_dma: dma_rmb() does not order MMIO readl_relaxed() -- > diff --git a/drivers/dma/qcom/bam_dma.c b/drivers/dma/qcom/bam_dma.c > --- 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) > return 0; > } > > +/** > + * bam_update_rx_result - account for bytes received by completed descriptors > + * @bchan: bam channel > + * @async_desc: descriptor whose hardware descriptors have completed > + * > + * On a producer pipe the BAM writes the number of bytes it transferred back > + * into the size field of each completed descriptor in the FIFO. Report the > + * unused part of the buffers as residue, so that clients using > + * callback_result know how much data was received. Only the last descriptor > + * of a transfer may be short, otherwise the transfer is marked as aborted. > + * Clients that rely on the residue should therefore use a single buffer of > + * at most BAM_FIFO_SIZE bytes per transfer. The residue is undefined if the > + * result is not DMA_TRANS_NOERROR. > + */ > +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(); > + > + 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); > + > + if (received > expected) { > + async_desc->vd.tx_result.result = DMA_TRANS_WRITE_FAILED; > + async_desc->vd.tx_result.residue += expected; > + continue; > + } > + > + /* > + * The next descriptor writes from its own address, so a short > + * write before the last one leaves a hole in the buffer that > + * cannot be described by the residue. > + */ > + if (received < expected && i != async_desc->num_desc - 1 && > + async_desc->vd.tx_result.result == DMA_TRANS_NOERROR) > + async_desc->vd.tx_result.result = DMA_TRANS_ABORTED; > + > + async_desc->vd.tx_result.residue += expected - received; > + } > +} > + > /** > * process_channel_irqs - processes the channel interrupts > * @bdev: bam controller [Severity: Medium] The comment says the FIFO size fields must be read only after the BAM_P_SW_OFSTS read. That read in process_channel_irqs() is a readl_relaxed(), and dma_rmb() is not specified to order MMIO accesses against normal memory. Documentation/memory-barriers.txt says the dma_*() barriers give no ordering guarantees for MMIO. It also says readX() is what you need when a device status read must complete before you look at a buffer the device has written. This matters on the platforms that use bam-dmux. On 32-bit ARMv7 (msm8974, msm8226 and friends) readl() ends in rmb(), which is a dsb. dma_rmb() is only dmb(osh). So nothing guarantees the CPU won't see a stale pre-transfer size in fifo_virt. It would then compute a wrong residue, which for qcom_bam_dmux means a wrong packet length. arm64 happens to be fine because its __io_ar() is dma_rmb() anyway. As a side effect, placing the barrier in bam_update_rx_result() issues it once per completed async_desc rather than once per interrupt. Would it be simpler to switch the BAM_P_SW_OFSTS read in process_channel_irqs() to readl() and drop the dma_rmb() here? That gives the right ordering on both arm and arm64 and costs only one barrier per channel per IRQ. An rmb() right after the readl_relaxed() would also work, if you prefer to keep the relaxed accessor. -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261203-qcom-bam-dmux-qmap-v1-0-abc2e80a03af%40oss.qualcomm.com