The subject looks wrong - this just touches the swiotlb code, and nothing x86 or AMD specific. The code flow now looks a little confusing. Can yu just add a little swiotlb_memblock_alloc helper that does the two variants of memblock allocation and remap, so that we can keep a simply loop around them in the caller?