[PATCH v2 0/2] iio: buffer-dmaengine: fix dma_vec building for coalesced sg tables

Nuno Sá <[email protected]>
Newsgroups org.kernel.vger.linux-iio
Message-ID <20260828-iio-buffer-dmabuf-iommu-fic-v2-0-b4dd71827621@analog.com>
Patch 1 fixes iio_dmaengine_buffer_submit_block() mixing up the CPU and the
DMA view of a DMABUF's scatterlist: it counted entries with
sg_nents_for_len() (CPU lengths) but consumed sg_dma_address()/sg_dma_len(),
which are only valid for the first sgt->nents entries. With an IOMMU
coalescing the mapping, the loop walks past the mapped set and hands a
garbage vec to the DMA engine, which wedges the buffer.

Patch 2 is the cleanup Jonathan spotted while reviewing v1: the max_size
computation at the top of the same function is dead, as only the fileio
branch consumes it and that branch computes it again where it is used.

---
Changes in v2:
- Patch 1:
  - Size the vec array with sgt->nents instead of sg_nents_for_dma().
  - Cut the new comment down to the invariant a reader needs.
  - Moved 'nents = i' up to right after the fill loop.
  - MOved `sgl = block->sg_table->sgl` to the place where we need sgl.
- Patch 2:
  - New patch dropping the dead max_size computation at the top of
    iio_dmaengine_buffer_submit_block() (Jonathan).
- Link to v1: https://patch.msgid.link/20260818-iio-buffer-dmabuf-iommu-fic-v1-1-4ff1e44a5073@analog.com

---
Michael Hennerich (1):
      iio: buffer-dmaengine: fix sg entry iteration when building dma_vecs

Nuno Sá (1):
      iio: buffer-dmaengine: drop dead max_size computation

 drivers/iio/buffer/industrialio-buffer-dmaengine.c | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)
---
base-commit: b756b143e5391151e577ae645b1378a43f93c2f5
change-id: 20260818-iio-buffer-dmabuf-iommu-fic-1b281f15e5a4
--

Thanks!
- Nuno Sá
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.