On Fri, Nov 03, 2023 at 09:50:53PM +0100, Petr Tesařík wrote: > Seconded. I have also been struggling with the various alignment > constraints. I have even written (but not yet submitted) a patch to > calculate the combined alignment mask in swiotlb_tbl_map_single() and > pass it down to all other functions, just to make it clear what > alignment mask is used. That does sound like a good idea. > My understanding is that buffer alignment may be required by: > > 1. hardware which cannot handle an unaligned base address (presumably > because the chip performs a simple OR operation to get the addresses > of individual fields); There's all kinds of weird encodings that discard the low bits. For NVMe it's the PRPs (that is actually documented in the NVMe spec, so it might be easiest to grasp), but except for a Mellox vendor extension this is also how all RDMA memory registrations work.