From 78957dcb2c825a7b9f1417c3a18e3bfeed8744b1 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Sat, 8 May 2021 13:01:08 +0200 Subject: [PATCH] Revert "swiotlb: factor out an io_tlb_offset helper" This reverts commit 1bbcc985d19524114bd2e0db1d826807043348cd. 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: I88427586de4df897c39bb3d48e8cba86ebf5c4bb --- kernel/dma/swiotlb.c | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/kernel/dma/swiotlb.c b/kernel/dma/swiotlb.c index f55248f16366..fb88c2982645 100644 --- a/kernel/dma/swiotlb.c +++ b/kernel/dma/swiotlb.c @@ -50,6 +50,9 @@ #define CREATE_TRACE_POINTS #include +#define OFFSET(val,align) ((unsigned long) \ + ( (val) & ( (align) - 1))) + #define SLABS_PER_PAGE (1 << (PAGE_SHIFT - IO_TLB_SHIFT)) /* @@ -173,11 +176,6 @@ void swiotlb_print_info(void) bytes >> 20); } -static inline unsigned long io_tlb_offset(unsigned long val) -{ - return val & (IO_TLB_SEGSIZE - 1); -} - /* * Early SWIOTLB allocation may be too early to allow an architecture to * perform the desired operations. This function allows the architecture to @@ -227,7 +225,7 @@ int __init swiotlb_init_with_tbl(char *tlb, unsigned long nslabs, int verbose) __func__, alloc_size, PAGE_SIZE); for (i = 0; i < io_tlb_nslabs; i++) { - io_tlb_list[i] = IO_TLB_SEGSIZE - io_tlb_offset(i); + io_tlb_list[i] = IO_TLB_SEGSIZE - OFFSET(i, IO_TLB_SEGSIZE); io_tlb_orig_addr[i] = INVALID_PHYS_ADDR; } io_tlb_index = 0; @@ -361,7 +359,7 @@ swiotlb_late_init_with_tbl(char *tlb, unsigned long nslabs) goto cleanup4; for (i = 0; i < io_tlb_nslabs; i++) { - io_tlb_list[i] = IO_TLB_SEGSIZE - io_tlb_offset(i); + io_tlb_list[i] = IO_TLB_SEGSIZE - OFFSET(i, IO_TLB_SEGSIZE); io_tlb_orig_addr[i] = INVALID_PHYS_ADDR; } io_tlb_index = 0; @@ -532,9 +530,7 @@ phys_addr_t swiotlb_tbl_map_single(struct device *hwdev, phys_addr_t orig_addr, for (i = index; i < (int) (index + nslots); i++) io_tlb_list[i] = 0; - for (i = index - 1; - io_tlb_offset(i) != IO_TLB_SEGSIZE - 1 && - io_tlb_list[i]; i--) + for (i = index - 1; (OFFSET(i, IO_TLB_SEGSIZE) != IO_TLB_SEGSIZE - 1) && io_tlb_list[i]; i--) io_tlb_list[i] = ++count; tlb_addr = io_tlb_start + (index << IO_TLB_SHIFT); @@ -620,9 +616,7 @@ void swiotlb_tbl_unmap_single(struct device *hwdev, phys_addr_t tlb_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--) + for (i = index - 1; (OFFSET(i, IO_TLB_SEGSIZE) != IO_TLB_SEGSIZE -1) && io_tlb_list[i]; i--) io_tlb_list[i] = ++count; io_tlb_used -= nslots;