]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
swiotlb: save io_tlb_used to local variable before leaving critical section
authorDongli Zhang <dongli.zhang@oracle.com>
Tue, 16 Apr 2019 23:49:20 +0000 (07:49 +0800)
committerBrian Maly <brian.maly@oracle.com>
Fri, 10 May 2019 21:24:06 +0000 (17:24 -0400)
When swiotlb is full, the kernel would print io_tlb_used. However, the
result might be inaccurate at that time because we have left the critical
section protected by spinlock.

Therefore, we backup the io_tlb_used into local variable before leaving
critical section.

Fixes: 83ca25948940 ("swiotlb: dump used and total slots when swiotlb buffer is full")
Suggested-by: HÃ¥kon Bugge <haakon.bugge@oracle.com>
Signed-off-by: Dongli Zhang <dongli.zhang@oracle.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Orabug: 29637525

(cherry picked from commit 53b29c336830db48ad3dc737f88b8c065b1f0851)
Signed-off-by: Brian Maly <brian.maly@oracle.com>
Conflicts:
    kernel/dma/swiotlb.c does not exist.

Signed-off-by: Dongli Zhang <dongli.zhang@oracle.com>
Reviewed-By: Joe Jin <joe.jin@oracle.com>
Signed-off-by: Brian Maly <brian.maly@oracle.com>
lib/swiotlb.c

index d08ce286e1d2895c4059142ae358b2bd187229ea..6ef2098cbd89b1a89be332a9f28ede28e1ed4195 100644 (file)
@@ -442,6 +442,7 @@ phys_addr_t swiotlb_tbl_map_single(struct device *hwdev,
        unsigned long mask;
        unsigned long offset_slots;
        unsigned long max_slots;
+       unsigned long tmp_io_tlb_used;
 
        if (no_iotlb_memory)
                panic("Can not allocate SWIOTLB buffer earlier and can't now provide you with the DMA bounce buffer");
@@ -524,10 +525,12 @@ phys_addr_t swiotlb_tbl_map_single(struct device *hwdev,
        } while (index != wrap);
 
 not_found:
+       tmp_io_tlb_used = io_tlb_used;
+
        spin_unlock_irqrestore(&io_tlb_lock, flags);
        if (printk_ratelimit())
-               dev_warn(hwdev, "swiotlb buffer is full (sz: %zd bytes), total %lu, used %lu\n",
-                        size, io_tlb_nslabs, io_tlb_used);
+               dev_warn(hwdev, "swiotlb buffer is full (sz: %zd bytes), total %lu (slots), used %lu (slots)\n",
+                        size, io_tlb_nslabs, tmp_io_tlb_used);
        return SWIOTLB_MAP_ERROR;
 found:
        io_tlb_used += nslots;