[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v7 1/9] swiotlb: bail out of swiotlb_init_late() if swiotlb is already allocated
- To: Stefano Stabellini <sstabellini@xxxxxxxxxx>, Russell King <linux@xxxxxxxxxxxxxxx>, Thomas Bogendoerfer <tsbogend@xxxxxxxxxxxxxxxx>, Thomas Gleixner <tglx@xxxxxxxxxxxxx>, Ingo Molnar <mingo@xxxxxxxxxx>, Borislav Petkov <bp@xxxxxxxxx>, Dave Hansen <dave.hansen@xxxxxxxxxxxxxxx>, x86@xxxxxxxxxx (maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)), "H. Peter Anvin" <hpa@xxxxxxxxx>, Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>, "Rafael J. Wysocki" <rafael@xxxxxxxxxx>, Juergen Gross <jgross@xxxxxxxx>, Oleksandr Tyshchenko <oleksandr_tyshchenko@xxxxxxxx>, Christoph Hellwig <hch@xxxxxx>, Marek Szyprowski <m.szyprowski@xxxxxxxxxxx>, Robin Murphy <robin.murphy@xxxxxxx>, Christoph Lameter <cl@xxxxxxxxx>, Pekka Enberg <penberg@xxxxxxxxxx>, David Rientjes <rientjes@xxxxxxxxxx>, Joonsoo Kim <iamjoonsoo.kim@xxxxxxx>, Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>, Vlastimil Babka <vbabka@xxxxxxx>, Roman Gushchin <roman.gushchin@xxxxxxxxx>, Hyeonggon Yoo <42.hyeyoo@xxxxxxxxx>, Petr Tesarik <petr.tesarik.ext@xxxxxxxxxx>, Jonathan Corbet <corbet@xxxxxxx>, Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>, Hans de Goede <hdegoede@xxxxxxxxxx>, James Seo <james@xxxxxxxxxx>, James Clark <james.clark@xxxxxxx>, Kees Cook <keescook@xxxxxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx (moderated list:XEN HYPERVISOR ARM), linux-arm-kernel@xxxxxxxxxxxxxxxxxxx (moderated list:ARM PORT), linux-kernel@xxxxxxxxxxxxxxx (open list), linux-mips@xxxxxxxxxxxxxxx (open list:MIPS), iommu@xxxxxxxxxxxxxxx (open list:XEN SWIOTLB SUBSYSTEM), linux-mm@xxxxxxxxx (open list:SLAB ALLOCATOR)
- From: Petr Tesarik <petrtesarik@xxxxxxxxxxxxxxx>
- Date: Tue, 1 Aug 2023 08:23:56 +0200
- Cc: Roberto Sassu <roberto.sassu@xxxxxxxxxxxxxxx>, petr@xxxxxxxxxxx
- Delivery-date: Tue, 01 Aug 2023 06:25:49 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
From: Petr Tesarik <petr.tesarik.ext@xxxxxxxxxx>
If swiotlb is allocated, immediately return 0, so callers do not have to
check io_tlb_default_mem.nslabs explicitly.
Signed-off-by: Petr Tesarik <petr.tesarik.ext@xxxxxxxxxx>
---
arch/arm/xen/mm.c | 10 ++++------
kernel/dma/swiotlb.c | 3 +++
2 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/arch/arm/xen/mm.c b/arch/arm/xen/mm.c
index 3d826c0b5fee..882cd70c7a2f 100644
--- a/arch/arm/xen/mm.c
+++ b/arch/arm/xen/mm.c
@@ -125,12 +125,10 @@ static int __init xen_mm_init(void)
return 0;
/* we can work with the default swiotlb */
- if (!io_tlb_default_mem.nslabs) {
- rc = swiotlb_init_late(swiotlb_size_or_default(),
- xen_swiotlb_gfp(), NULL);
- if (rc < 0)
- return rc;
- }
+ rc = swiotlb_init_late(swiotlb_size_or_default(),
+ xen_swiotlb_gfp(), NULL);
+ if (rc < 0)
+ return rc;
cflush.op = 0;
cflush.a.dev_bus_addr = 0;
diff --git a/kernel/dma/swiotlb.c b/kernel/dma/swiotlb.c
index 1c0a49e6685a..ee57fd9949dc 100644
--- a/kernel/dma/swiotlb.c
+++ b/kernel/dma/swiotlb.c
@@ -384,6 +384,9 @@ int swiotlb_init_late(size_t size, gfp_t gfp_mask,
bool retried = false;
int rc = 0;
+ if (io_tlb_default_mem.nslabs)
+ return 0;
+
if (swiotlb_force_disable)
return 0;
--
2.25.1
|