Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1399395pxa; Sun, 23 Aug 2020 01:08:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxq09daHcPPbDcURG5Ou1DdJ4Ru/X9PquMXXOvn3lTzbLlfqFdg95c0tg9/QvEqIw39pRoW X-Received: by 2002:a05:6402:b67:: with SMTP id cb7mr484483edb.216.1598170127204; Sun, 23 Aug 2020 01:08:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598170127; cv=none; d=google.com; s=arc-20160816; b=sG+6Xn9g5FX9uDLpfNnEudM9J54KprJGHWOMk9RCauijs0vtJ1KcU0FWpGz2bgY0d5 Wp6+iFsP/wQY46rScVBGmycWvjFaEjRiEmpTy0NpMQdHCBS0MRYVsnCDgahFtwEf2tjl vOTtWA50HF8qNBwP4vfzY6h0jxDi7ZUAJUwI7WwA2XZbIA4rdJaBhnhz5QEy0ztlKsjT mpEkMgRf5/TXdG58AwsfqsWCnB/cFsE/hlvFwttaMD/MIMMWBuHopD+u32zxofkve7KA VfRcNiJcbBbarUkY88cRq7n/XbXVRuqU8yNgw73G5AcjuR/fJl7jlI26x8sr/nUCYVTJ KaNA== 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:references:message-id:subject:cc:to:from:date :dkim-signature; bh=t7dt9e12oNAHcRsrc3EfbIWsF++vZ65l9JEyoJZiO/4=; b=p2EA5fsRs+ECKI9xVguLzTogLU/iApreVV50BKQaN08YV225uyLO0AYEO3Y5J+Do0S d+ZyvPUE8CA+91ZlCavnJ6UwMQTZCFixGLIob69fqdpFs81KgtsS8DOHDFQisJEdnQrY 84+IK0NcrrFlCiC3PQ4XCMt2/YAksY0UkYts8fYasvuCcRAKDqGPTrxW4xJ8B8vBGz1c SYP8kp/bjZzEAW2XzMcPzGqCAL1yLqadV0AXj17IwgZV58ENYC8RDUO81uL4GmPPYFcE Wlhl/FiiRwmnNJb457RXypSQhqxmrEJu2s8l3urbemU0q41qn+dSMFKhs4tytUVfJRiH txZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=GdBkHYEq; 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e5si4415134eje.663.2020.08.23.01.08.23; Sun, 23 Aug 2020 01:08:47 -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=@redhat.com header.s=mimecast20190719 header.b=GdBkHYEq; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728254AbgHWIBT (ORCPT + 99 others); Sun, 23 Aug 2020 04:01:19 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:56683 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726635AbgHWIBR (ORCPT ); Sun, 23 Aug 2020 04:01:17 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1598169675; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=t7dt9e12oNAHcRsrc3EfbIWsF++vZ65l9JEyoJZiO/4=; b=GdBkHYEqF9wriKj26jmnG92VCK2CLbx6DI4XK8UBZFcbommMEW4wxWzMGhdWlQ2RDH2Ss0 h3ZJYVUQeZyZdwiwS33loIOG7qAWxo+OkcMC3yGpy9/MN2/FdlbNAIjE+dmhE7l3ll7abL E2oOmknQPWezhjlnLEewDz2F2l9DExc= Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-432-dZ9GIpIcPwWLIJ4a5MuNjA-1; Sun, 23 Aug 2020 04:01:13 -0400 X-MC-Unique: dZ9GIpIcPwWLIJ4a5MuNjA-1 Received: by mail-qv1-f69.google.com with SMTP id d1so4202582qvs.21 for ; Sun, 23 Aug 2020 01:01:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=t7dt9e12oNAHcRsrc3EfbIWsF++vZ65l9JEyoJZiO/4=; b=cWDUexOPjM9THkXcQnhq72l8FdmV8cqoNcg+nsVOmQwh7PzfPW4ZPKq8LTaV8ZJtYt hTAzEynnTlGb3CFGJVgHbS/44Jo/p2fyLd2ZJRW8l1jMPOG2KCnACIDOU7SWaNYImsOl casz1UEE9fKgf+f/daEXQ4gd7XYtLjghQTnweRI7Ll19o1snkvHer8bprKfxIpILhpM3 SHJ3YZlJQbz1jDGKvebPueY7ljnG6ecCFR/2GP8m7dvPW1uDyyrKzpotQGxqviWzBe/6 jDXOVeffSI3Y6ArCljyeyxKAcn9MjNSs8HU7vT0bXCNcaduhNHQo3kkAJV9/gZ44c9XQ ULIw== X-Gm-Message-State: AOAM5304HyqiJnGinSie9Kxu7MnACoX+jLcv6DaFey5MiVfWkA6LCn2Q TSA6BFmBpATvSNim57n4Ox0UkCy0wfkQwtWhlfzsNnxofrU/4mweJGorIzDxpsw3RkskLdLQx4k zAqYyN1KfKCPHlAk9r+ASo5fx X-Received: by 2002:ac8:6793:: with SMTP id b19mr277842qtp.333.1598169672361; Sun, 23 Aug 2020 01:01:12 -0700 (PDT) X-Received: by 2002:ac8:6793:: with SMTP id b19mr277830qtp.333.1598169672000; Sun, 23 Aug 2020 01:01:12 -0700 (PDT) Received: from redhat.com (bzq-109-67-40-161.red.bezeqint.net. [109.67.40.161]) by smtp.gmail.com with ESMTPSA id p202sm6489989qke.97.2020.08.23.01.01.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Aug 2020 01:01:10 -0700 (PDT) Date: Sun, 23 Aug 2020 04:01:06 -0400 From: "Michael S. Tsirkin" To: Bjorn Helgaas Cc: George Cherian , linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, linux-pci@vger.kernel.org, bhelgaas@google.com, arnd@arndb.de Subject: Re: [PATCHv2] PCI: Add pci_iounmap Message-ID: <20200823040008-mutt-send-email-mst@kernel.org> References: <20200820050306.2015009-1-george.cherian@marvell.com> <20200820215549.GA1569713@bjorn-Precision-5520> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200820215549.GA1569713@bjorn-Precision-5520> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Aug 20, 2020 at 04:55:49PM -0500, Bjorn Helgaas wrote: > [+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. My recollection is vaguely that map code was more or less the same across architectures, but unmap was often different, so I only moved map into the library. > > #endif /* CONFIG_PCI */ > > -- > > 2.25.1 > >