From: Greg Kroah-Hartman Date: Sun, 2 Oct 2022 15:41:05 +0000 (+0200) Subject: 5.15-stable patches X-Git-Tag: v5.19.13~17 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=722d55b60aa5bec58329b1b14ae5fa216c5d3b0e;p=thirdparty%2Fkernel%2Fstable-queue.git 5.15-stable patches added patches: swiotlb-max-mapping-size-takes-min-align-mask-into-account.patch --- diff --git a/queue-5.15/series b/queue-5.15/series index 76b2c6df9cc..643ce312d69 100644 --- a/queue-5.15/series +++ b/queue-5.15/series @@ -35,3 +35,4 @@ mm-hwpoison-check-mm-when-killing-accessing-process.patch media-dvb_vb2-fix-possible-out-of-bound-access.patch media-rkvdec-disable-h.264-error-detection.patch media-v4l2-compat-ioctl32.c-zero-buffer-passed-to-v4l2_compat_get_array_args.patch +swiotlb-max-mapping-size-takes-min-align-mask-into-account.patch diff --git a/queue-5.15/swiotlb-max-mapping-size-takes-min-align-mask-into-account.patch b/queue-5.15/swiotlb-max-mapping-size-takes-min-align-mask-into-account.patch new file mode 100644 index 00000000000..e68a17477f7 --- /dev/null +++ b/queue-5.15/swiotlb-max-mapping-size-takes-min-align-mask-into-account.patch @@ -0,0 +1,53 @@ +From 82806744fd7dde603b64c151eeddaa4ee62193fd Mon Sep 17 00:00:00 2001 +From: Tianyu Lan +Date: Tue, 10 May 2022 10:21:09 -0400 +Subject: swiotlb: max mapping size takes min align mask into account + +From: Tianyu Lan + +commit 82806744fd7dde603b64c151eeddaa4ee62193fd upstream. + +swiotlb_find_slots() skips slots according to io tlb aligned mask +calculated from min aligned mask and original physical address +offset. This affects max mapping size. The mapping size can't +achieve the IO_TLB_SEGSIZE * IO_TLB_SIZE when original offset is +non-zero. This will cause system boot up failure in Hyper-V +Isolation VM where swiotlb force is enabled. Scsi layer use return +value of dma_max_mapping_size() to set max segment size and it +finally calls swiotlb_max_mapping_size(). Hyper-V storage driver +sets min align mask to 4k - 1. Scsi layer may pass 256k length of +request buffer with 0~4k offset and Hyper-V storage driver can't +get swiotlb bounce buffer via DMA API. Swiotlb_find_slots() can't +find 256k length bounce buffer with offset. Make swiotlb_max_mapping +_size() take min align mask into account. + +Signed-off-by: Tianyu Lan +Signed-off-by: Christoph Hellwig +Signed-off-by: Rishabh Bhatnagar +Signed-off-by: Greg Kroah-Hartman +--- + kernel/dma/swiotlb.c | 13 ++++++++++++- + 1 file changed, 12 insertions(+), 1 deletion(-) + +--- a/kernel/dma/swiotlb.c ++++ b/kernel/dma/swiotlb.c +@@ -709,7 +709,18 @@ dma_addr_t swiotlb_map(struct device *de + + size_t swiotlb_max_mapping_size(struct device *dev) + { +- return ((size_t)IO_TLB_SIZE) * IO_TLB_SEGSIZE; ++ int min_align_mask = dma_get_min_align_mask(dev); ++ int min_align = 0; ++ ++ /* ++ * swiotlb_find_slots() skips slots according to ++ * min align mask. This affects max mapping size. ++ * Take it into acount here. ++ */ ++ if (min_align_mask) ++ min_align = roundup(min_align_mask, IO_TLB_SIZE); ++ ++ return ((size_t)IO_TLB_SIZE) * IO_TLB_SEGSIZE - min_align; + } + + bool is_swiotlb_active(struct device *dev)