Re: [PATCH v2 3/5] rust: scatterlist: Add type-state abstraction for sg_table

From: Danilo Krummrich
Date: Sat Aug 23 2025 - 10:57:42 EST


On Sat Aug 23, 2025 at 4:32 PM CEST, Jason Gunthorpe wrote:
> Correct, this is misusing the API, and I don't know if the lengths are
> even guarenteed to be zero.

Hopefully it is. Otherwise, it's not only the documentation if sg_dma_address()
being wrong, but also a few drivers and maybe iommu_dma_unmap_sg(). However,
since it's a specific implementation of the API, it might be correct relying on
the sg_dma_len() == 0 check.

In any case, I think we can just use the nents field of struct sg_table, just
like for_each_sgtable_dma_sg() does.