1 From abe420bfae528c92bd8cc5ecb62dc95672b1fd6f Mon Sep 17 00:00:00 2001
2 From: Joerg Roedel <jroedel@suse.de>
3 Date: Thu, 7 Feb 2019 12:59:13 +0100
4 Subject: swiotlb: Introduce swiotlb_max_mapping_size()
6 From: Joerg Roedel <jroedel@suse.de>
8 commit abe420bfae528c92bd8cc5ecb62dc95672b1fd6f upstream.
10 The function returns the maximum size that can be remapped
11 by the SWIOTLB implementation. This function will be later
12 exposed to users through the DMA-API.
14 Cc: stable@vger.kernel.org
15 Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
16 Reviewed-by: Christoph Hellwig <hch@lst.de>
17 Signed-off-by: Joerg Roedel <jroedel@suse.de>
18 Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
19 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
22 include/linux/swiotlb.h | 5 +++++
23 kernel/dma/swiotlb.c | 5 +++++
24 2 files changed, 10 insertions(+)
26 --- a/include/linux/swiotlb.h
27 +++ b/include/linux/swiotlb.h
28 @@ -76,6 +76,7 @@ bool swiotlb_map(struct device *dev, phy
29 size_t size, enum dma_data_direction dir, unsigned long attrs);
30 void __init swiotlb_exit(void);
31 unsigned int swiotlb_max_segment(void);
32 +size_t swiotlb_max_mapping_size(struct device *dev);
34 #define swiotlb_force SWIOTLB_NO_FORCE
35 static inline bool is_swiotlb_buffer(phys_addr_t paddr)
36 @@ -95,6 +96,10 @@ static inline unsigned int swiotlb_max_s
40 +static inline size_t swiotlb_max_mapping_size(struct device *dev)
44 #endif /* CONFIG_SWIOTLB */
46 extern void swiotlb_print_info(void);
47 --- a/kernel/dma/swiotlb.c
48 +++ b/kernel/dma/swiotlb.c
49 @@ -662,3 +662,8 @@ swiotlb_dma_supported(struct device *hwd
51 return __phys_to_dma(hwdev, io_tlb_end - 1) <= mask;
54 +size_t swiotlb_max_mapping_size(struct device *dev)
56 + return ((size_t)1 << IO_TLB_SHIFT) * IO_TLB_SEGSIZE;