Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1029011rwd; Thu, 18 May 2023 07:07:15 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4r9+IfIhd9V6zweu4iuuJFEkNabEGvNeWJj6i0oVL3G8UtHFqI9oTPtdIUbPftxZo8tamY X-Received: by 2002:a05:6a00:2313:b0:646:3c2:4d30 with SMTP id h19-20020a056a00231300b0064603c24d30mr4765855pfh.30.1684418834888; Thu, 18 May 2023 07:07:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684418834; cv=none; d=google.com; s=arc-20160816; b=akxfpYMfoBTFzaJA10XA1LdQUmniSF/joCp7fLnJK357QOi73nAHCJA0MLKJWlOnma HL3LZbtvvQF7JD1kzY8FsuYD3mT+cUEUt6T5+1wVI/48umd4lSyvbJmJBiBbiwNpfYOQ KhGjP7jRxvbKZC7N/7D3VSsWXRCE3UccglfGmlf7YC3jpKp089Y9k6/ncvxHlK6KQ7or RuY/tQzMedpH0FYGFobdMWxkRkwr6fAxHd7OSWhwGZhNwzHQksyuJrU5mwkKxQBv8YlZ 0/2fwTHb8dF6QB4yyyrCeBUGSeTtOHHhcMD7cDS7Wko1QFX2Q8YuBGbhrDMGUIVM2Eu6 LDLA== 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 :dkim-signature; bh=05AyJy/WnduYw6cv5NEmxDHJJYQdGW0Vqnw+CujW2f0=; b=vE8xM68zLdyU/c6y3JCWsSYdR6cDh/cBlrbW/Ka5xec5X4M1cm5kyohrtdi7psBxLy s1DCXNORJvLDRmCFpX26vhOSjLoD8Mdh7vRPRES4EF6V5saPvoLtCKK9UzYHQLqh95A+ zfj1pKelMCoyUgaUVP15WKVRyf8mgMlo3NruGjWCAafX0djw6VMwMeZK3OOxuPLwcZp0 wIxCnKhWgy2a1P7ZU+3o3LVKp0A/3Ysh5ujYry8eMNJDpd8KFZRrizGrqB3Qnuqip01u rB+JvRbV1/+8Wxsm+cVnKkmdY6j+gfPxt1Qw8gE0/vsrUfGN2ErK94r0TjlGXisc9rl0 EbTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=YCm6+nCf; 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 a21-20020a637055000000b0052868eb9742si1516901pgn.77.2023.05.18.07.06.58; Thu, 18 May 2023 07:07:14 -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; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=YCm6+nCf; 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 S231309AbjERNn1 (ORCPT + 99 others); Thu, 18 May 2023 09:43:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60642 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231148AbjERNnY (ORCPT ); Thu, 18 May 2023 09:43:24 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B367D19B for ; Thu, 18 May 2023 06:43:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=05AyJy/WnduYw6cv5NEmxDHJJYQdGW0Vqnw+CujW2f0=; b=YCm6+nCfk/tqJs7qLv0fLb0i6p rh6YUXDVTuctprWr6BzRIVl5659Y51hsG50TV0qeGB/0lKu4HFOpG4FGQ2JEFosMgtSoOG1Ow82Uz T9PjamZA1bYNoiR5YkTkBWsX5NhqcUyOh6poOma8ugLkFknBvmIaPStma9KpMTsBbUcJJGJj2GKOM m4FKMYO7r8cwQykZilTii7odYMouDxqaidikNF/yF3CHzf5J2OZ+NbaaCrMe+2WSAAYCfKSuT1EoI IoZGn66ql9UNMrCi9szQ7Xcw0aE6fgi6+RqZgIv8hKUVhPl2kjaVw0wt5trZqQLvqFJegnCIvf3F9 Xml1tTcw==; Received: from [2001:4bb8:188:3dd5:1149:8081:5f51:3e54] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1pzduI-00D6RW-0C; Thu, 18 May 2023 13:43:02 +0000 From: Christoph Hellwig To: Juergen Gross , Stefano Stabellini , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Ben Skeggs , Karol Herbst , Lyude Paul Cc: xen-devel@lists.xenproject.org, iommu@lists.linux.dev, linux-kernel@vger.kernel.org, nouveau@lists.freedesktop.org Subject: [PATCH 2/4] x86: always initialize xen-swiotlb when xen-pcifront is enabling Date: Thu, 18 May 2023 15:42:51 +0200 Message-Id: <20230518134253.909623-3-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230518134253.909623-1-hch@lst.de> References: <20230518134253.909623-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham 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 Remove the dangerous late initialization of xen-swiotlb in pci_xen_swiotlb_init_late and instead just always initialize xen-swiotlb in the boot code if CONFIG_XEN_PCIDEV_FRONTEND is enabled. Signed-off-by: Christoph Hellwig --- arch/x86/include/asm/xen/swiotlb-xen.h | 6 ------ arch/x86/kernel/pci-dma.c | 25 +++---------------------- drivers/pci/xen-pcifront.c | 6 ------ 3 files changed, 3 insertions(+), 34 deletions(-) diff --git a/arch/x86/include/asm/xen/swiotlb-xen.h b/arch/x86/include/asm/xen/swiotlb-xen.h index 77a2d19cc9909e..abde0f44df57dc 100644 --- a/arch/x86/include/asm/xen/swiotlb-xen.h +++ b/arch/x86/include/asm/xen/swiotlb-xen.h @@ -2,12 +2,6 @@ #ifndef _ASM_X86_SWIOTLB_XEN_H #define _ASM_X86_SWIOTLB_XEN_H -#ifdef CONFIG_SWIOTLB_XEN -extern int pci_xen_swiotlb_init_late(void); -#else -static inline int pci_xen_swiotlb_init_late(void) { return -ENXIO; } -#endif - int xen_swiotlb_fixup(void *buf, unsigned long nslabs); int xen_create_contiguous_region(phys_addr_t pstart, unsigned int order, unsigned int address_bits, diff --git a/arch/x86/kernel/pci-dma.c b/arch/x86/kernel/pci-dma.c index f887b08ac5ffe4..c4a7ead9eb674e 100644 --- a/arch/x86/kernel/pci-dma.c +++ b/arch/x86/kernel/pci-dma.c @@ -81,27 +81,6 @@ static void __init pci_xen_swiotlb_init(void) if (IS_ENABLED(CONFIG_PCI)) pci_request_acs(); } - -int pci_xen_swiotlb_init_late(void) -{ - if (dma_ops == &xen_swiotlb_dma_ops) - return 0; - - /* we can work with the default swiotlb */ - if (!io_tlb_default_mem.nslabs) { - int rc = swiotlb_init_late(swiotlb_size_or_default(), - GFP_KERNEL, xen_swiotlb_fixup); - if (rc < 0) - return rc; - } - - /* XXX: this switches the dma ops under live devices! */ - dma_ops = &xen_swiotlb_dma_ops; - if (IS_ENABLED(CONFIG_PCI)) - pci_request_acs(); - return 0; -} -EXPORT_SYMBOL_GPL(pci_xen_swiotlb_init_late); #else static inline void __init pci_xen_swiotlb_init(void) { @@ -111,7 +90,9 @@ static inline void __init pci_xen_swiotlb_init(void) void __init pci_iommu_alloc(void) { if (xen_pv_domain()) { - if (xen_initial_domain() || x86_swiotlb_enable) + if (xen_initial_domain() || + IS_ENABLED(CONFIG_XEN_PCIDEV_FRONTEND) || + x86_swiotlb_enable) pci_xen_swiotlb_init(); return; } diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c index 83c0ab50676dff..11636634ae512f 100644 --- a/drivers/pci/xen-pcifront.c +++ b/drivers/pci/xen-pcifront.c @@ -22,7 +22,6 @@ #include #include #include -#include #include #include @@ -669,11 +668,6 @@ static int pcifront_connect_and_init_dma(struct pcifront_device *pdev) spin_unlock(&pcifront_dev_lock); - if (!err && !is_swiotlb_active(&pdev->xdev->dev)) { - err = pci_xen_swiotlb_init_late(); - if (err) - dev_err(&pdev->xdev->dev, "Could not setup SWIOTLB!\n"); - } return err; } -- 2.39.2