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 033EDEB64DA for ; Thu, 20 Jul 2023 06:38:19 +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=r5sz+s1mxnjn3Arzg7hcqBpAeOLI3bSRODgVdsahBDM=; b=1PeDzJ0JOQZAq7 O9P6RFOVn126yVnHKgo5e6qFJw0iERInHsLfT7esE5XHJ2BjcB5x+CDjzu0huuZ2oZwXe/pXVeZEc kyKpdtGRTOrrNcymWnfQGUAssu7K8M2uVURFGHAjiQ52H1/NKCiczWVnfTfQEkSVoMaoRmQ+8I6XD kZTDGPhPVHmoXClN9zBiNr5CFL6jXArGqeuad7w33ApN8pssh4mKao2NtHNFxK7cdcn57lBGoKu+3 EvJAVtsp/v01BTiSCHcnDZl9iRnsfE3vWPVLR7AtEJwy7Lp/VLG6VUKVK/LVhl/Oo1AO5g2ioj06w uK91O0AKZfP+h5Gh71BQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qMNIV-009xmH-17; Thu, 20 Jul 2023 06:37:59 +0000 Received: from verein.lst.de ([213.95.11.211]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qMNIR-009xiJ-2D for linux-arm-kernel@lists.infradead.org; Thu, 20 Jul 2023 06:37:57 +0000 Received: by verein.lst.de (Postfix, from userid 2407) id 6AB1267373; Thu, 20 Jul 2023 08:37:44 +0200 (CEST) Date: Thu, 20 Jul 2023 08:37:44 +0200 From: Christoph Hellwig To: Petr Tesarik Cc: Stefano Stabellini , Russell King , Thomas Bogendoerfer , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "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 , Petr Tesarik , Jonathan Corbet , Andy Shevchenko , Hans de Goede , James Seo , James Clark , Kees Cook , "moderated list:XEN HYPERVISOR ARM" , "moderated list:ARM PORT" , open list , "open list:MIPS" , "open list:XEN SWIOTLB SUBSYSTEM" , Roberto Sassu , Kefeng Wang , petr@tesarici.cz Subject: Re: [PATCH v4 1/8] swiotlb: make io_tlb_default_mem local to swiotlb.c Message-ID: <20230720063744.GA3842@lst.de> References: <7f64111986f4f361a2deb4a1a1b6f588e63a851b.1689261692.git.petr.tesarik.ext@huawei.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <7f64111986f4f361a2deb4a1a1b6f588e63a851b.1689261692.git.petr.tesarik.ext@huawei.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-20230719_233756_029388_B1827AAD X-CRM114-Status: GOOD ( 26.92 ) 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, Jul 13, 2023 at 05:23:12PM +0200, Petr Tesarik wrote: > From: Petr Tesarik > > SWIOTLB implementation details should not be exposed to the rest of the > kernel. This will allow to make changes to the implementation without > modifying non-swiotlb code. > > To avoid breaking existing users, provide helper functions for the few > required fields. > > As a bonus, using a helper function to initialize struct device allows to > get rid of an #ifdef in driver core. > > Signed-off-by: Petr Tesarik > --- > arch/arm/xen/mm.c | 2 +- > arch/mips/pci/pci-octeon.c | 2 +- > arch/x86/kernel/pci-dma.c | 2 +- > drivers/base/core.c | 4 +--- > drivers/xen/swiotlb-xen.c | 2 +- > include/linux/swiotlb.h | 25 +++++++++++++++++++++++- > kernel/dma/swiotlb.c | 39 +++++++++++++++++++++++++++++++++++++- > 7 files changed, 67 insertions(+), 9 deletions(-) > > diff --git a/arch/arm/xen/mm.c b/arch/arm/xen/mm.c > index 3d826c0b5fee..0f32c14eb786 100644 > --- a/arch/arm/xen/mm.c > +++ b/arch/arm/xen/mm.c > @@ -125,7 +125,7 @@ static int __init xen_mm_init(void) > return 0; > > /* we can work with the default swiotlb */ > - if (!io_tlb_default_mem.nslabs) { > + if (!is_swiotlb_allocated()) { > rc = swiotlb_init_late(swiotlb_size_or_default(), > xen_swiotlb_gfp(), NULL); > if (rc < 0) I'd much rather move the already initialized check into swiotlb_init_late, which is a much cleaer interface. > /* we can work with the default swiotlb */ > - if (!io_tlb_default_mem.nslabs) { > + if (!is_swiotlb_allocated()) { > int rc = swiotlb_init_late(swiotlb_size_or_default(), > GFP_KERNEL, xen_swiotlb_fixup); > if (rc < 0) .. and would take care of this one as well. > +bool is_swiotlb_allocated(void) > +{ > + return !!io_tlb_default_mem.nslabs; Nit: no need for the !!, we can rely on the implicit promotion to bool. But with the suggestion above the need for this helper should go away anyway. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel