On 9/28/26 14:58, Jason Gunthorpe wrote:
On Mon, Sep 28, 2026 at 10:27:32AM +0200, Christian König wrote:
In general I think that the sg_alloc_table_from_pages_segment() approach is because of the broken design of the old DMA API.
The scatterlist and the DMA API use of it is very specialized to serve the needs of the storage stack without performance cost. Segmentation is intended to make the sgl entries map 1:1 to HW entries so the block layer can schedule correctly.
Yeah and that is a clear violation of the principle that kernel APIs shouldn't be designed with the use case in mind.
Instead the API should reflect what the HW does and needs, e.g. in this case what the bus systems and IOMMU engines can or can't do.
How it is used in the end should be irrelevant to that, it only servers as validation if the design fulfills all requirements or not.
Regards, Christian.
Nothing else needs something like this but still has to tip toe around these rules. It makes it more complicated to map and then in some cases you have to undo it when programming HW :\
Reviewed-by: Jason Gunthorpe jgg@nvidia.com
Jason