On Sat, Nov 04, 2023 at 07:59:06AM -0600, Keith Busch wrote:
dma_opt_mapping_size returns "min(dma_max_mapping_size(dev), size)". So you don't have to call dma_max_mapping_size explicitly, you can leave the file drivers/nvme/host/pci.c as it is.
Indeed.
What about the other block device drivers (AHCI, SCSI...)? Should there be some generic framework that restricts max_hw_sectors according to dma_opt_mapping_size?
I think it's just like any other request_queue limits and the individual drivers have to set up these.
Yes, or in case of SCSI the scsi midlayer, which already does it. The block layer itself doesn't even know that we're using DMA to transfer data.
Thinking on this again, this feels more like a max_segment_size limit rather than a max_hw_sectors.
No, it's an overall limit. If we'd have a lot of segments using the max size we'd still starve the swiotlb pool.