From 28a2f5f10f39c652e1754166bc89e7b842d3436c Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Sat, 8 May 2021 13:00:55 +0200 Subject: [PATCH] Revert "swiotlb: clean up swiotlb_tbl_unmap_single" This reverts commit 9efd5df078a7e1aa2a825855688025b586ed880f. Fixes the ABI issues in 5.10.35 that at the moment, we can't handle due to the KABI freeze. These are not patches that mean much for android systems, and will be reverted the next KABI "reset" point. Bug: 161946584 Signed-off-by: Greg Kroah-Hartman Change-Id: Ia22b608e4d017c6056e481d2ec819074b35810cf --- kernel/dma/swiotlb.c | 41 ++++++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/kernel/dma/swiotlb.c b/kernel/dma/swiotlb.c index f5530336d7ca..f0be199da527 100644 --- a/kernel/dma/swiotlb.c +++ b/kernel/dma/swiotlb.c @@ -610,29 +610,28 @@ void swiotlb_tbl_unmap_single(struct device *hwdev, phys_addr_t tlb_addr, * with slots below and above the pool being returned. */ spin_lock_irqsave(&io_tlb_lock, flags); - if (index + nslots < ALIGN(index + 1, IO_TLB_SEGSIZE)) - count = io_tlb_list[index + nslots]; - else - count = 0; + { + count = ((index + nslots) < ALIGN(index + 1, IO_TLB_SEGSIZE) ? + io_tlb_list[index + nslots] : 0); + /* + * Step 1: return the slots to the free list, merging the + * slots with superceeding slots + */ + for (i = index + nslots - 1; i >= index; i--) { + io_tlb_list[i] = ++count; + io_tlb_orig_addr[i] = INVALID_PHYS_ADDR; + } + /* + * Step 2: merge the returned slots with the preceding slots, + * if available (non zero) + */ + for (i = index - 1; + io_tlb_offset(i) != IO_TLB_SEGSIZE - 1 && + io_tlb_list[i]; i--) + io_tlb_list[i] = ++count; - /* - * Step 1: return the slots to the free list, merging the slots with - * superceeding slots - */ - for (i = index + nslots - 1; i >= index; i--) { - io_tlb_list[i] = ++count; - io_tlb_orig_addr[i] = INVALID_PHYS_ADDR; + io_tlb_used -= nslots; } - - /* - * Step 2: merge the returned slots with the preceding slots, if - * available (non zero) - */ - for (i = index - 1; - io_tlb_offset(i) != IO_TLB_SEGSIZE - 1 && io_tlb_list[i]; - i--) - io_tlb_list[i] = ++count; - io_tlb_used -= nslots; spin_unlock_irqrestore(&io_tlb_lock, flags); }