From: Christoph Hellwig <hch@lst.de>
Date: Wed, 11 May 2022 08:44:29 +0200
Subject: swiotlb: don't panic when the swiotlb buffer can't be allocated
Git-commit: 1521c607cabe7c7edb028e211e88ba1e0f19714e
Patch-mainline: v5.19-rc1
References: jsc#PED-3259
For historical reasons the switlb code paniced when the metadata could
not be allocated, but just printed a warning when the actual main
swiotlb buffer could not be allocated. Restore this somewhat unexpected
behavior as changing it caused a boot failure on the Microchip RISC-V
PolarFire SoC Icicle kit.
Fixes: 6424e31b1c05 ("swiotlb: remove swiotlb_init_with_tbl and swiotlb_init_late_with_tbl")
Reported-by: Conor Dooley <Conor.Dooley@microchip.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
Acked-by: Conor Dooley <conor.dooley@microchip.com>
Tested-by: Conor Dooley <Conor.Dooley@microchip.com>
Acked-by: Joerg Roedel <jroedel@suse.de>
---
kernel/dma/swiotlb.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
--- a/kernel/dma/swiotlb.c
+++ b/kernel/dma/swiotlb.c
@@ -261,8 +261,10 @@ retry:
tlb = memblock_alloc(bytes, PAGE_SIZE);
else
tlb = memblock_alloc_low(bytes, PAGE_SIZE);
- if (!tlb)
- panic("%s: failed to allocate tlb structure\n", __func__);
+ if (!tlb) {
+ pr_warn("%s: failed to allocate tlb structure\n", __func__);
+ return;
+ }
if (remap && remap(tlb, nslabs) < 0) {
memblock_free(__pa(tlb), PAGE_ALIGN(bytes));