From nobody Wed Nov 27 20:31:37 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1690459644137492.77488822431326; Thu, 27 Jul 2023 05:07:24 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.571052.893959 (Exim 4.92) (envelope-from ) id 1qOzlp-0007SA-Lj; Thu, 27 Jul 2023 12:07:05 +0000 Received: by outflank-mailman (output) from mailman id 571052.893959; Thu, 27 Jul 2023 12:07:05 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qOzlp-0007Rz-HW; Thu, 27 Jul 2023 12:07:05 +0000 Received: by outflank-mailman (input) for mailman id 571052; Thu, 27 Jul 2023 12:07:04 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qOzlo-00079h-Cg for xen-devel@lists.xenproject.org; Thu, 27 Jul 2023 12:07:04 +0000 Received: from frasgout13.his.huawei.com (unknown [14.137.139.46]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 17a2d36d-2c76-11ee-8613-37d641c3527e; Thu, 27 Jul 2023 14:07:02 +0200 (CEST) Received: from mail02.huawei.com (unknown [172.18.147.228]) by frasgout13.his.huawei.com (SkyGuard) with ESMTP id 4RBTjl4nZ5z9xFHD for ; Thu, 27 Jul 2023 19:55:39 +0800 (CST) Received: from A2101119013HW2.china.huawei.com (unknown [10.81.209.69]) by APP2 (Coremail) with SMTP id GxC2BwBnGkGaXcJkfMYUBQ--.33878S3; Thu, 27 Jul 2023 13:06:23 +0100 (CET) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 17a2d36d-2c76-11ee-8613-37d641c3527e From: Petr Tesarik To: Stefano Stabellini , Russell King , Thomas Bogendoerfer , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org (maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)), "H. Peter Anvin" , Greg Kroah-Hartman , "Rafael J. Wysocki" , Juergen Gross , Oleksandr Tyshchenko , Christoph Hellwig , Marek Szyprowski , Robin Murphy , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , Vlastimil Babka , Roman Gushchin , Hyeonggon Yoo <42.hyeyoo@gmail.com>, Petr Tesarik , Jonathan Corbet , Andy Shevchenko , Hans de Goede , James Seo , James Clark , Kees Cook , xen-devel@lists.xenproject.org (moderated list:XEN HYPERVISOR ARM), linux-arm-kernel@lists.infradead.org (moderated list:ARM PORT), linux-kernel@vger.kernel.org (open list), linux-mips@vger.kernel.org (open list:MIPS), iommu@lists.linux.dev (open list:XEN SWIOTLB SUBSYSTEM), linux-mm@kvack.org (open list:SLAB ALLOCATOR) Cc: Roberto Sassu , petr@tesarici.cz Subject: [PATCH v6 1/9] swiotlb: bail out of swiotlb_init_late() if swiotlb is already allocated Date: Thu, 27 Jul 2023 14:05:29 +0200 Message-Id: <04fd8e9caf7acf45651e1bea3878f59f0b390b9e.1690459412.git.petr.tesarik.ext@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: GxC2BwBnGkGaXcJkfMYUBQ--.33878S3 X-Coremail-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JVWUCwCI42IY6I8E87Iv67AKxVW8JVWxJwCI42IY6I8E87Iv6xkF 7I0E14v26r4UJVWxJrUvcSsGvfC2KfnxnUUI43ZEXa7VUjjNt3UUUUU== X-CM-SenderInfo: hshw23xhvd2x3n6k3tpzhluzxrxghudrp/ X-CFilter-Loop: Reflected X-ZM-MESSAGEID: 1690459646789100001 Content-Type: text/plain; charset="utf-8" From: Petr Tesarik 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 --- arch/arm/xen/mm.c | 10 ++++------ arch/x86/kernel/pci-dma.c | 12 ++++++------ kernel/dma/swiotlb.c | 3 +++ 3 files changed, 13 insertions(+), 12 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; =20 /* we can work with the default swiotlb */ - if (!io_tlb_default_mem.nslabs) { - rc =3D swiotlb_init_late(swiotlb_size_or_default(), - xen_swiotlb_gfp(), NULL); - if (rc < 0) - return rc; - } + rc =3D swiotlb_init_late(swiotlb_size_or_default(), + xen_swiotlb_gfp(), NULL); + if (rc < 0) + return rc; =20 cflush.op =3D 0; cflush.a.dev_bus_addr =3D 0; diff --git a/arch/x86/kernel/pci-dma.c b/arch/x86/kernel/pci-dma.c index de6be0a3965e..08988b0a1c91 100644 --- a/arch/x86/kernel/pci-dma.c +++ b/arch/x86/kernel/pci-dma.c @@ -86,16 +86,16 @@ static void __init pci_xen_swiotlb_init(void) =20 int pci_xen_swiotlb_init_late(void) { + int rc; + if (dma_ops =3D=3D &xen_swiotlb_dma_ops) return 0; =20 /* we can work with the default swiotlb */ - if (!io_tlb_default_mem.nslabs) { - int rc =3D swiotlb_init_late(swiotlb_size_or_default(), - GFP_KERNEL, xen_swiotlb_fixup); - if (rc < 0) - return rc; - } + rc =3D swiotlb_init_late(swiotlb_size_or_default(), + GFP_KERNEL, xen_swiotlb_fixup); + if (rc < 0) + return rc; =20 /* XXX: this switches the dma ops under live devices! */ dma_ops =3D &xen_swiotlb_dma_ops; diff --git a/kernel/dma/swiotlb.c b/kernel/dma/swiotlb.c index 2b83e3ad9dca..66fc8ec9ae45 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 =3D false; int rc =3D 0; =20 + if (io_tlb_default_mem.nslabs) + return 0; + if (swiotlb_force_disable) return 0; =20 --=20 2.25.1