Skip to content

Commit

Permalink
swiotlb: checking whether swiotlb buffer is full with io_tlb_used
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Dongli Zhang authored and Konrad Rzeszutek Wilk committed Feb 12, 2019
1 parent 71602fe commit 60513ed
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions kernel/dma/swiotlb.c
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,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;
Expand Down

0 comments on commit 60513ed

Please sign in to comment.