From: Dongli Zhang Date: Mon, 1 Apr 2019 06:30:05 +0000 (+0800) Subject: swiotlb: checking whether swiotlb buffer is full with io_tlb_used X-Git-Tag: v4.1.12-124.31.3~208 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=ec98a38a45459a0f779685588b3f3df23969ba2e;p=users%2Fjedix%2Flinux-maple.git swiotlb: checking whether swiotlb buffer is full with io_tlb_used 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 Signed-off-by: Dongli Zhang Signed-off-by: Konrad Rzeszutek Wilk Orabug: 29582587 (cherry picked from commit 60513ed06a41049768a6875229b025b6e726e148) Signed-off-by: Dongli Zhang Reviewed-by: Konrad Rzeszutek Wilk Signed-off-by: Brian Maly --- diff --git a/lib/swiotlb.c b/lib/swiotlb.c index f41f1be70367..c9d2b32c70b5 100644 --- a/lib/swiotlb.c +++ b/lib/swiotlb.c @@ -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;