Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1638078pxa; Thu, 20 Aug 2020 17:00:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwpa3ltwg5kFux4Xz2xKqwyyF9aQYtXTUoDAtwDX0PFdrKNpWXJvXMUjlEpkyhWYHhmotdB X-Received: by 2002:a17:906:a3d0:: with SMTP id ca16mr402547ejb.36.1597968043858; Thu, 20 Aug 2020 17:00:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597968043; cv=none; d=google.com; s=arc-20160816; b=LW3Z/FkEYiQWuh/6nqgPn1Gny0dfTdFWO9Z9KPq2UdD10eUIaU4S9a810Z5CnmVCif N5ZLi76WBDnCRKecAlqWI+aKp7McA8rhfU15JJ/hizFx0eIqGU+O6muCGsmf+nKV9WyU QShnGwUy7GG3iFWdRb1Py/waOrRseyOAf91An1Adc1xTUfWQd411tvw7V9rIMwmJ5ykt SuxJybdlqqjRAa4p/syI9XjsihEuyQqPz5gm5aBZXUucl3C3BAsjaZYOR5FstWUcQTrX YEjLminRwOGjBGZa3Hu+SjinCHV09DmU6K2v9rAHANc35In+mzJc9pfnA3r1AzVtMNHk mhVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:message-id:subject:cc:to:from:date:dkim-signature; bh=hN9p6nXKag7BMZtHIE69GqoVor/iSJThJHPSp7VDR1w=; b=zGAUXXGdtu8gMxVCwCRPEOOwRSr4ocOlo9vDXQ0oL84O7zwpbmwJkLUlHudYIJkjtR If9RqjeNJ9ukwO35ATNzkkgzwF8L3nqUHXjO01ZfkCzocNMd+4VQqDWXRMu9Ej2VQ14w T2Nw1bUJBNIlxYOLo4ptgvvAKlTlT8cS0esLU+LyknssLVjTpsW9MWWSsnyfQzdEWapM zYPsXbcD1AxAaaBm6JORa6KbuNqW3L8ZJ39KDE0hoGkKK8vfEvLHyTwIRpjtlR7R7m4m l8sm38+BKlY4SLRppeOSWVudpQ/AvsnzZJjq3tHQx4wXh35aV4REAq6zBxPGEfC3JdF2 6hVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=1XKDiQcw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m7si61397edq.500.2020.08.20.17.00.15; Thu, 20 Aug 2020 17:00:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=1XKDiQcw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728295AbgHTVzz (ORCPT + 99 others); Thu, 20 Aug 2020 17:55:55 -0400 Received: from mail.kernel.org ([198.145.29.99]:46586 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726899AbgHTVzw (ORCPT ); Thu, 20 Aug 2020 17:55:52 -0400 Received: from localhost (104.sub-72-107-126.myvzw.com [72.107.126.104]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 17417204FD; Thu, 20 Aug 2020 21:55:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597960551; bh=5ULzVEcGtTnweVu+hyjjAnP9S4wCcq1qytib5KiiV2w=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=1XKDiQcwbYSrv8Z4WVaOtJLooY4nfviEtxoPo0Y2NitTUuU8LYIu2bSKyRd8WQr0L aN+ZWgAz5Hc65TmNcYJVWDD/yr5T+tCdq/45aqqethpzi9q7hBrkKKy8P8WzFsEOnq NIWuz91tc4hJtRfSZd1UAfb3iDvkP5BRBg2NWEaU= Date: Thu, 20 Aug 2020 16:55:49 -0500 From: Bjorn Helgaas To: George Cherian Cc: linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, linux-pci@vger.kernel.org, bhelgaas@google.com, arnd@arndb.de, "Michael S. Tsirkin" Subject: Re: [PATCHv2] PCI: Add pci_iounmap Message-ID: <20200820215549.GA1569713@bjorn-Precision-5520> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200820050306.2015009-1-george.cherian@marvell.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [+cc Michael, author of 66eab4df288a ("lib: add GENERIC_PCI_IOMAP")] On Thu, Aug 20, 2020 at 10:33:06AM +0530, George Cherian wrote: > In case if any architecture selects CONFIG_GENERIC_PCI_IOMAP and not > CONFIG_GENERIC_IOMAP, then the pci_iounmap function is reduced to a NULL > function. Due to this the managed release variants or even the explicit > pci_iounmap calls doesn't really remove the mappings. > > This issue is seen on an arm64 based system. arm64 by default selects > only CONFIG_GENERIC_PCI_IOMAP and not CONFIG_GENERIC_IOMAP from this > 'commit cb61f6769b88 ("ARM64: use GENERIC_PCI_IOMAP")' > > Simple bind/unbind test of any pci driver using pcim_iomap/pci_iomap, > would lead to the following error message after long hour tests > > "allocation failed: out of vmalloc space - use vmalloc= to > increase size." > > Signed-off-by: George Cherian > --- > * Changes from v1 > - Fix the 0-day compilation error. > - Mark the lib/iomap pci_iounmap call as weak incase > if any architecture have there own implementation. > > include/asm-generic/io.h | 4 ++++ > lib/pci_iomap.c | 10 ++++++++++ > 2 files changed, 14 insertions(+) > > diff --git a/include/asm-generic/io.h b/include/asm-generic/io.h > index dabf8cb7203b..5986b37226b7 100644 > --- a/include/asm-generic/io.h > +++ b/include/asm-generic/io.h > @@ -915,12 +915,16 @@ static inline void iowrite64_rep(volatile void __iomem *addr, > struct pci_dev; > extern void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long max); > > +#ifdef CONFIG_GENERIC_PCI_IOMAP > +extern void pci_iounmap(struct pci_dev *dev, void __iomem *p); > +#else > #ifndef pci_iounmap > #define pci_iounmap pci_iounmap > static inline void pci_iounmap(struct pci_dev *dev, void __iomem *p) > { > } > #endif > +#endif /* CONFIG_GENERIC_PCI_IOMAP */ > #endif /* CONFIG_GENERIC_IOMAP */ > > /* > diff --git a/lib/pci_iomap.c b/lib/pci_iomap.c > index 2d3eb1cb73b8..ecd1eb3f6c25 100644 > --- a/lib/pci_iomap.c > +++ b/lib/pci_iomap.c > @@ -134,4 +134,14 @@ void __iomem *pci_iomap_wc(struct pci_dev *dev, int bar, unsigned long maxlen) > return pci_iomap_wc_range(dev, bar, 0, maxlen); > } > EXPORT_SYMBOL_GPL(pci_iomap_wc); > + > +#ifndef CONFIG_GENERIC_IOMAP > +#define pci_iounmap pci_iounmap > +void __weak pci_iounmap(struct pci_dev *dev, void __iomem *addr); > +void __weak pci_iounmap(struct pci_dev *dev, void __iomem *addr) > +{ > + iounmap(addr); > +} > +EXPORT_SYMBOL(pci_iounmap); > +#endif I completely agree that this looks like a leak that needs to be fixed. But my head hurts after trying to understand pci_iomap() and pci_iounmap(). I hate to add even more #ifdefs here. Can't we somehow rationalize this and put pci_iounmap() next to pci_iomap()? 66eab4df288a ("lib: add GENERIC_PCI_IOMAP") moved pci_iomap() from lib/iomap.c to lib/pci_iomap.c, but left pci_iounmap() in lib/iomap.c. There must be some good reason why they're separated, but I don't know what it is. > #endif /* CONFIG_PCI */ > -- > 2.25.1 >