]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
swiotlb: checking whether swiotlb buffer is full with io_tlb_used
authorDongli Zhang <dongli.zhang@oracle.com>
Mon, 1 Apr 2019 06:30:05 +0000 (14:30 +0800)
committerBrian Maly <brian.maly@oracle.com>
Tue, 9 Apr 2019 21:23:21 +0000 (17:23 -0400)
This patch uses io_tlb_used to help check whether swiotlb buffer is full.
io_tlb_used is no longer used for only debugfs. It is also used to help
optimize swiotlb_tbl_map_single().

Suggested-by: Joe Jin <joe.jin@oracle.com>
Signed-off-by: Dongli Zhang <dongli.zhang@oracle.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Orabug: 29582587
(cherry picked from commit 60513ed06a41049768a6875229b025b6e726e148)

Signed-off-by: Dongli Zhang <dongli.zhang@oracle.com>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Signed-off-by: Brian Maly <brian.maly@oracle.com>
lib/swiotlb.c

index f41f1be70367c4c318ffa1a221ded6e2ec8f7f11..c9d2b32c70b5393c3c67386ad8874ea39cf3ca4a 100644 (file)
@@ -476,6 +476,10 @@ phys_addr_t swiotlb_tbl_map_single(struct device *hwdev,
         * request and allocate a buffer from that IO TLB pool.
         */
        spin_lock_irqsave(&io_tlb_lock, flags);
+
+       if (unlikely(nslots > io_tlb_nslabs - io_tlb_used))
+               goto not_found;
+
        index = ALIGN(io_tlb_index, stride);
        if (index >= io_tlb_nslabs)
                index = 0;