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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 50FA0C433EF for ; Wed, 2 Mar 2022 08:15:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240022AbiCBIPx (ORCPT ); Wed, 2 Mar 2022 03:15:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43402 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229518AbiCBIPw (ORCPT ); Wed, 2 Mar 2022 03:15:52 -0500 Received: from verein.lst.de (verein.lst.de [213.95.11.211]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 290A3B7C40; Wed, 2 Mar 2022 00:15:10 -0800 (PST) Received: by verein.lst.de (Postfix, from userid 2407) id 527A368BEB; Wed, 2 Mar 2022 09:15:01 +0100 (CET) Date: Wed, 2 Mar 2022 09:15:00 +0100 From: Christoph Hellwig To: Stefano Stabellini Cc: Christoph Hellwig , iommu@lists.linux-foundation.org, x86@kernel.org, Anshuman Khandual , Tom Lendacky , Konrad Rzeszutek Wilk , Boris Ostrovsky , 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: [PATCH 11/12] swiotlb: merge swiotlb-xen initialization into swiotlb Message-ID: <20220302081500.GB23075@lst.de> References: <20220301105311.885699-1-hch@lst.de> <20220301105311.885699-12-hch@lst.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.17 (2007-11-01) Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org On Tue, Mar 01, 2022 at 06:55:47PM -0800, Stefano Stabellini wrote: > Unrelated to this specific patch series: now that I think about it, if > io_tlb_default_mem.nslabs is already allocated by the time xen_mm_init > is called, wouldn't we potentially have an issue with the GFP flags used > for the earlier allocation (e.g. GFP_DMA32 not used)? Maybe something > for another day. swiotlb_init allocates low memory from meblock, which is roughly equivalent to GFP_DMA allocations, so we'll be fine. > > @@ -143,10 +141,15 @@ static int __init xen_mm_init(void) > > if (!xen_swiotlb_detect()) > > return 0; > > > > - rc = xen_swiotlb_init(); > > /* we can work with the default swiotlb */ > > - if (rc < 0 && rc != -EEXIST) > > - return rc; > > + if (!io_tlb_default_mem.nslabs) { > > + if (!xen_initial_domain()) > > + return -EINVAL; > > I don't think we need this xen_initial_domain() check. It is all > already sorted out by the xen_swiotlb_detect() check above. Is it? static inline int xen_swiotlb_detect(void) { if (!xen_domain()) return 0; if (xen_feature(XENFEAT_direct_mapped)) return 1; /* legacy case */ if (!xen_feature(XENFEAT_not_direct_mapped) && xen_initial_domain()) return 1; return 0; } I think I'd keep it as-is for now, as my planned next step would be to fold xen-swiotlb into swiotlb entirely.