Re: [PATCH v2 1/3] swiotlb: Fix allocation alignment requirement when searching slots

From: Will Deacon
Date: Wed Jan 31 2024 - 12:46:17 EST


On Wed, Jan 31, 2024 at 12:25:41PM +0000, Will Deacon wrote:
> @@ -1015,14 +1014,16 @@ static int swiotlb_search_pool_area(struct device *dev, struct io_tlb_pool *pool
> index = area->index;
>
> for (slots_checked = 0; slots_checked < pool->area_nslabs; ) {
> - slot_index = slot_base + index;
> + phys_addr_t tlb_addr;
>
> - if (orig_addr &&
> - (slot_addr(tbl_dma_addr, slot_index) &
> - iotlb_align_mask) != (orig_addr & iotlb_align_mask)) {
> + slot_index = slot_base + index;
> + tlb_addr = slot_addr(tbl_dma_addr, slot_index);
> +
> + if ((tlb_addr & alloc_align_mask) ||
> + (orig_addr && (tlb_addr & iotlb_align_mask) !=
> + (orig_addr & iotlb_align_mask))) {
> index = wrap_area_index(pool, index + 1);
> slots_checked++;
> - continue;

Bah, I accidentally dropped this 'continue' when addressing the review
comments, so I'll add it back in v3.

Will