swiotlb: Add is_swiotlb_active() function

This function will be used from dma_direct code to determine
the maximum segment size of a dma mapping.

Cc: [email protected]
Reviewed-by: Konrad Rzeszutek Wilk <[email protected]>
Reviewed-by: Christoph Hellwig <[email protected]>
Signed-off-by: Joerg Roedel <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
This commit is contained in:
Joerg Roedel 2019-02-07 12:59:14 +01:00 • committed by Michael S. Tsirkin
commit 492366f7b4
2 changed files with 15 additions and 0 deletions

View file

@ -667,3 +667,12 @@ size_t swiotlb_max_mapping_size(struct device *dev)
{
return ((size_t)1 << IO_TLB_SHIFT) * IO_TLB_SEGSIZE;
}
bool is_swiotlb_active(void)
{
/*
* When SWIOTLB is initialized, even if io_tlb_start points to physical
* address zero, io_tlb_end surely doesn't.
*/
return io_tlb_end != 0;
}