Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp5306622rwb; Mon, 31 Jul 2023 23:41:17 -0700 (PDT) X-Google-Smtp-Source: APBJJlFZftNhm3aJsGDb3J98LvmGKybdN1HUdp9Iv/cfX4AyouY9q7CVhG+hbAfnTiJbHQJg2B3f X-Received: by 2002:a05:6a00:1147:b0:66a:6339:e8f9 with SMTP id b7-20020a056a00114700b0066a6339e8f9mr12859379pfm.0.1690872077002; Mon, 31 Jul 2023 23:41:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690872076; cv=none; d=google.com; s=arc-20160816; b=fN6tPp0ISkxzAQE/9FjTkMpLHAtaXpKWcI+E6uwXZVYXVGPAe2oZZd78GiZotNlUhk Pf0BVtLrcplEx5utJz6UM5iFJECOCMfzvOxY9XOoGR+OHXuw4wKL2/aAi0Xl0C81PhUB hr1qwCohoEZVy4wlwTl568ROrU0RDDgxlp6AegEGtmAYpnASBcXTnkC06qTZvnt6cyx4 g3nRDKU61yZMcfbkTvk/u4OioqyF52wlYbuGlzBKIydv3ZVIc/S98KtDBmNp8+YRT2DN 58QLG7dPhAJdP38GJrc15nIOghoXKx6bySJ9vaVNT/RLKdoLO9xNu6tcOKV7gdU7DsNg zCmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=FVo8jCfoTVZD1lvRVCW27rQF94LgmZBgzj+PNwf1Of8=; fh=DKumEaufGum+opV/LxWkRQDD7BZ2+JV9pgiokJ35bEM=; b=bwKhkk+hWWu4V88MzUrDPc53PM6/RaDfurXNLsWaxBfLsesLsmxa/+qt7zFUgOnYA3 giYCrt5fB0xKvQLQk3dT0kC0HQKYkmHEbYZCg3HruSHW68ry5BnAd1/b4wcBMzAFRTmI 0ecaly3W1WpGyM/9aL81zNMdLW04113YMAPnzKVu7nIBHc+6RKKiufxIr6YyEbL1Eqam vvG8Nfr2aw9DlFaqhkGQNho5tFGKWu3crMlriGJ5Vj/whnGD304ihjvTavjcPNqZKd/z 83Rn1etJIWYEsys4MVbpedWciliCbrN5ZXTuIUb8VRLO6C5BMYZCA4PU9tMutnuSmJIe SLbA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id fd28-20020a056a002e9c00b0067d12984ec5si1527804pfb.289.2023.07.31.23.41.04; Mon, 31 Jul 2023 23:41:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230342AbjHAG0H (ORCPT + 99 others); Tue, 1 Aug 2023 02:26:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39438 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230254AbjHAG0B (ORCPT ); Tue, 1 Aug 2023 02:26:01 -0400 Received: from frasgout13.his.huawei.com (unknown [14.137.139.46]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E5BF31BF3; Mon, 31 Jul 2023 23:25:58 -0700 (PDT) Received: from mail02.huawei.com (unknown [172.18.147.229]) by frasgout13.his.huawei.com (SkyGuard) with ESMTP id 4RFPvp2DqHz9xvdn; Tue, 1 Aug 2023 14:14:30 +0800 (CST) Received: from A2101119013HW2.china.huawei.com (unknown [10.81.220.249]) by APP1 (Coremail) with SMTP id LxC2BwCHOroapchkgAwYAA--.27948S3; Tue, 01 Aug 2023 07:25:04 +0100 (CET) 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 v7 1/9] swiotlb: bail out of swiotlb_init_late() if swiotlb is already allocated Date: Tue, 1 Aug 2023 08:23:56 +0200 Message-Id: <2d7e1823e264aa1990899cc95736e78e1ec21084.1690871004.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: 8bit X-CM-TRANSID: LxC2BwCHOroapchkgAwYAA--.27948S3 X-Coremail-Antispam: 1UD129KBjvJXoW7WFWxCFyrZr4rWFyUJw18Krg_yoW8Jw1rp3 47AFyvgFWFg3WxArW7C3ZrAFyjkaykK347urW5Wry3Jry5J34rG34UtrWa934rWFW8WF4S yFy5ZFyYv3W2qw7anT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUQm14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_Jr4l82xGYIkIc2 x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2z4x0 Y4vE2Ix0cI8IcVAFwI0_Gr0_Xr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F4UJw A2z4x0Y4vEx4A2jsIE14v26r4j6F4UM28EF7xvwVC2z280aVCY1x0267AKxVW8Jr0_Cr1U M2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj6xIIjx v20xvE14v26r1Y6r17McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr0_Gr1l F7xvr2IYc2Ij64vIr41lF7I21c0EjII2zVCS5cI20VAGYxC7M4IIrI8v6xkF7I0E8cxan2 IY04v7MxkF7I0En4kS14v26r1q6r43MxkF7I0Ew4C26cxK6c8Ij28IcwCF04k20xvY0x0E wIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v26r1j6r18MI8I3I0E74 80Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_Wrv_Gr1UMIIYrxkI7VAKI48JMIIF0xvE 2Ix0cI8IcVAFwI0_Gr0_Xr1lIxAIcVC0I7IYx2IY6xkF7I0E14v26r4UJVWxJr1lIxAIcV CF04k26cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r4j6F4UMIIF0xvEx4A2jsIE c7CjxVAFwI0_Gr1j6F4UJbIYCTnIWIevJa73UjIFyTuYvjfU8ApnDUUUU X-CM-SenderInfo: hshw23xhvd2x3n6k3tpzhluzxrxghudrp/ X-CFilter-Loop: Reflected X-Spam-Status: No, score=0.1 required=5.0 tests=BAYES_00,MAY_BE_FORGED, RCVD_IN_DNSWL_BLOCKED,RDNS_DYNAMIC,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 ++++------ 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