diff options
author | Dongli Zhang <dongli.zhang@oracle.com> | 2019-01-18 02:10:28 -0500 |
---|---|---|
committer | Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> | 2019-02-12 12:53:01 -0500 |
commit | 60513ed06a41049768a6875229b025b6e726e148 (patch) | |
tree | 4c674fb2f2dcae13ba33ff82f0e937a66ce3b2e7 | |
parent | 71602fe6d4e9291af105adfef8e893b57c735906 (diff) |
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 <joe.jin@oracle.com>
Signed-off-by: Dongli Zhang <dongli.zhang@oracle.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
-rw-r--r-- | kernel/dma/swiotlb.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/kernel/dma/swiotlb.c b/kernel/dma/swiotlb.c index bedc9f945836..a01b83e95a2a 100644 --- a/kernel/dma/swiotlb.c +++ b/kernel/dma/swiotlb.c | |||
@@ -483,6 +483,10 @@ phys_addr_t swiotlb_tbl_map_single(struct device *hwdev, | |||
483 | * request and allocate a buffer from that IO TLB pool. | 483 | * request and allocate a buffer from that IO TLB pool. |
484 | */ | 484 | */ |
485 | spin_lock_irqsave(&io_tlb_lock, flags); | 485 | spin_lock_irqsave(&io_tlb_lock, flags); |
486 | |||
487 | if (unlikely(nslots > io_tlb_nslabs - io_tlb_used)) | ||
488 | goto not_found; | ||
489 | |||
486 | index = ALIGN(io_tlb_index, stride); | 490 | index = ALIGN(io_tlb_index, stride); |
487 | if (index >= io_tlb_nslabs) | 491 | if (index >= io_tlb_nslabs) |
488 | index = 0; | 492 | index = 0; |