From 8dbe481c4553f8bdd6d146e2d85ddefb8587f2b6 Mon Sep 17 00:00:00 2001 From: Srivatsa Vaddagiri Date: Thu, 7 Jan 2021 09:08:14 -0800 Subject: [PATCH] swiotlb: Limit max bounce buffer size Limiting to 4096, assuming this is used for virtual io block device. The default maximum (256kB) would result in overflowing of bounce buffers and stalling of IO (max_segments of 254 for block device and max bounce size of 256kB could result in block layer submitting a huge IO request that can never be finished successfully). With 4096, we have the max size of request set to 254*4096, which is a reasonable space to set aside per block device. Change-Id: I8a3b0ec6d26a1b7f5ccdcee649f02c3556bce93b Signed-off-by: Srivatsa Vaddagiri --- kernel/dma/swiotlb.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/kernel/dma/swiotlb.c b/kernel/dma/swiotlb.c index c0e877cf4348..342e3694ca25 100644 --- a/kernel/dma/swiotlb.c +++ b/kernel/dma/swiotlb.c @@ -794,7 +794,12 @@ dma_addr_t swiotlb_map(struct device *dev, phys_addr_t paddr, size_t size, } #ifdef CONFIG_SWIOTLB_NONLINEAR EXPORT_SYMBOL(swiotlb_map); -#endif + +size_t swiotlb_max_mapping_size(struct device *dev) +{ + return 4096; +} +#else size_t swiotlb_max_mapping_size(struct device *dev) { @@ -811,6 +816,7 @@ size_t swiotlb_max_mapping_size(struct device *dev) return ((size_t)IO_TLB_SIZE) * IO_TLB_SEGSIZE - min_align; } +#endif bool is_swiotlb_active(struct device *dev) {