lkml.org 
[lkml]   [2022]   [Jun]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH RFC v1 5/7] swiotlb: add interface to set dev->dma_io_tlb_mem
Date
The interface re-configures dev->dma_io_tlb_mem conditionally, if the
'io_tlb_high_mem' is active.

Cc: Konrad Wilk <konrad.wilk@oracle.com>
Cc: Joe Jin <joe.jin@oracle.com>
Signed-off-by: Dongli Zhang <dongli.zhang@oracle.com>
---
include/linux/swiotlb.h | 6 ++++++
kernel/dma/swiotlb.c | 10 ++++++++++
2 files changed, 16 insertions(+)

diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h
index 8196bf961aab..78217d8bbee2 100644
--- a/include/linux/swiotlb.h
+++ b/include/linux/swiotlb.h
@@ -131,6 +131,7 @@ unsigned int swiotlb_max_segment(void);
size_t swiotlb_max_mapping_size(struct device *dev);
bool is_swiotlb_active(struct device *dev);
void __init swiotlb_adjust_size(unsigned long size);
+bool swiotlb_use_high(struct device *dev);
#else
static inline void swiotlb_init(bool addressing_limited, unsigned int flags)
{
@@ -163,6 +164,11 @@ static inline bool is_swiotlb_active(struct device *dev)
static inline void swiotlb_adjust_size(unsigned long size)
{
}
+
+static bool swiotlb_use_high(struct device *dev);
+{
+ return false;
+}
#endif /* CONFIG_SWIOTLB */

extern bool swiotlb_high_active(void);
diff --git a/kernel/dma/swiotlb.c b/kernel/dma/swiotlb.c
index ff82b281ce01..0dcdd25ea95d 100644
--- a/kernel/dma/swiotlb.c
+++ b/kernel/dma/swiotlb.c
@@ -121,6 +121,16 @@ bool swiotlb_high_active(void)
return high_nslabs && io_tlb_high_mem.nslabs;
}

+bool swiotlb_use_high(struct device *dev)
+{
+ if (!swiotlb_high_active())
+ return false;
+
+ dev->dma_io_tlb_mem = &io_tlb_high_mem;
+ return true;
+}
+EXPORT_SYMBOL_GPL(swiotlb_use_high);
+
unsigned int swiotlb_max_segment(void)
{
if (!io_tlb_default_mem.nslabs)
--
2.17.1
\
 
 \ /
  Last update: 2022-06-09 03:00    [W:0.165 / U:0.032 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site