From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AA9A2C433EF for ; Fri, 25 Feb 2022 08:49:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=QKSDCjz/GSESdyd5/fIwFdRgVMuWHOJ8RQutTm/EqBM=; b=0caA+xaFtJ1TZn vxRYWibuJiw+q//em63HfsjyC326YQ7VyA3OL4iT3qQa+K6fqm1vpCxguyX77PelkPsTYyVoEtvly /hkneIaW49zPSGDCXuHi7N3zwqyiV6GZUJSlQJZ3I/QgOUGvgXnadVFU5Ddy3tM16KQbHc0WJalpp 4fedEaqgsifd01zspdja+7B2dGEdW2V15U7nLCU7qldu3tRD8HIkVQw3gmWZPYxtT+lOXbtg/iO1G 4rA56avGvb+dJFKgIPfheW9BMk3nOFFJ97semtRRtzO2mMxzJggnI8S009cymL9z8H4iXNOEw4C77 Oxgd6DW2qnj/89myMa8g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nNWGo-0040yC-NG; Fri, 25 Feb 2022 08:48:10 +0000 Received: from verein.lst.de ([213.95.11.211]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nNWGj-0040wu-8L; Fri, 25 Feb 2022 08:48:08 +0000 Received: by verein.lst.de (Postfix, from userid 2407) id 364BF68AA6; Fri, 25 Feb 2022 09:47:56 +0100 (CET) Date: Fri, 25 Feb 2022 09:47:55 +0100 From: Christoph Hellwig To: Boris Ostrovsky Cc: Christoph Hellwig , iommu@lists.linux-foundation.org, x86@kernel.org, Stefano Stabellini , Juergen Gross , Joerg Roedel , David Woodhouse , Lu Baolu , Robin Murphy , linux-arm-kernel@lists.infradead.org, xen-devel@lists.xenproject.org, linux-ia64@vger.kernel.org, linux-mips@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-hyperv@vger.kernel.org, tboot-devel@lists.sourceforge.net, linux-pci@vger.kernel.org Subject: Re: cleanup swiotlb initialization Message-ID: <20220225084755.GA29630@lst.de> References: <20220222153514.593231-1-hch@lst.de> <09cb4ad3-88e7-3744-b4b8-a6d745ecea9e@oracle.com> <20220224155854.GA30938@lst.de> <206ba6a3-770a-70ad-96bc-76c6380da988@oracle.com> <20220224163943.GA32088@lst.de> <8ffd8587-7eb3-d5b6-eab0-b86df5c0ebbd@oracle.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <8ffd8587-7eb3-d5b6-eab0-b86df5c0ebbd@oracle.com> User-Agent: Mutt/1.5.17 (2007-11-01) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220225_004805_469497_D7319F2D X-CRM114-Status: GOOD ( 16.44 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, Feb 24, 2022 at 12:07:26PM -0500, Boris Ostrovsky wrote: >>> Just to be clear: this crashes only as dom0. Boots fine as baremetal. >> Ah. I can gues what this might be. On Xen the hypervisor controls the >> IOMMU and we should never end up initializing it in Linux, right? > > > Right, we shouldn't be in that code path. Can you try the patch below on top of the series? diff --git a/arch/x86/kernel/pci-dma.c b/arch/x86/kernel/pci-dma.c index b849f11a756d0..f88c9a4a5ed12 100644 --- a/arch/x86/kernel/pci-dma.c +++ b/arch/x86/kernel/pci-dma.c @@ -47,22 +47,6 @@ static unsigned int x86_swiotlb_flags; */ static void __init pci_swiotlb_detect_4gb(void) { -#ifdef CONFIG_SWIOTLB_XEN - if (xen_pv_domain()) { - if (xen_initial_domain()) - x86_swiotlb_enable = true; - - if (x86_swiotlb_enable) { - dma_ops = &xen_swiotlb_dma_ops; -#ifdef CONFIG_PCI - /* Make sure ACS will be enabled */ - pci_request_acs(); -#endif - } - return; - } -#endif /* CONFIG_SWIOTLB_XEN */ - /* don't initialize swiotlb if iommu=off (no_iommu=1) */ if (!no_iommu && max_possible_pfn > MAX_DMA32_PFN) x86_swiotlb_enable = true; @@ -82,16 +66,36 @@ static inline void __init pci_swiotlb_detect_4gb(void) } #endif /* CONFIG_SWIOTLB */ +#ifdef CONFIG_SWIOTLB_XEN +static void __init xen_swiotlb_init(void) +{ + if (!xen_initial_domain() && !x86_swiotlb_enable) + return; + x86_swiotlb_enable = true; + dma_ops = &xen_swiotlb_dma_ops; +#ifdef CONFIG_PCI + /* Make sure ACS will be enabled */ + pci_request_acs(); +#endif + swiotlb_init_remap(true, x86_swiotlb_flags, xen_swiotlb_fixup); +} +#else +static inline void __init xen_swiotlb_init(void) +{ +} +#endif /* CONFIG_SWIOTLB_XEN */ + void __init pci_iommu_alloc(void) { + if (xen_pv_domain()) { + xen_swiotlb_init(); + return; + } pci_swiotlb_detect_4gb(); gart_iommu_hole_init(); amd_iommu_detect(); detect_intel_iommu(); -#ifdef CONFIG_SWIOTLB - swiotlb_init_remap(x86_swiotlb_enable, x86_swiotlb_flags, - xen_pv_domain() ? xen_swiotlb_fixup : NULL); -#endif + swiotlb_init(x86_swiotlb_enable, x86_swiotlb_flags); } /* _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel