Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp273344pxk; Thu, 17 Sep 2020 02:42:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxEtZaQRnEEj4fhgQcM0mp1OjYrA3QY1lhIM55JFOacmggO2L2DN3PKUvdcWILxHXb0+m0B X-Received: by 2002:a17:906:91d3:: with SMTP id b19mr30750494ejx.235.1600335740480; Thu, 17 Sep 2020 02:42:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600335740; cv=none; d=google.com; s=arc-20160816; b=lvVFTHLraPQCHAq/iQNWF9w4BJiOEEeJf7HrGFyjUC4Ri791oD8PLe70dR2m1Q9GwT lRGShhTGvM4YhqgeIzApQn6BjpkDD6Jb8u7XekwRK1Lqg+1W3q1cTQl30V5nfFD0MY9w XmOVzHG4vZ6QenwrUPhdsbkG1EcEzQwj3j/YrNVG5AUs0bCXHMXQ+lPZiPpb+14WyhOe cPcrWkYgCOMaJ2HTFWyiLatS/B+cYWucxyjlc2sjtKOx2rEfd2Z+Tmeehu6hnO5kWyBm RrelQDt3wqDCicM/VkgyNvsfZ38VrvjpklyjlLHfV43l+/4t8OXyfPEavoAT+qsxzBdb 5Mdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=qNmb2Y6kJ+MKlS9aHr4J3hmF8upg/AI2KGs8N8n4ftg=; b=n2l1MrXW/FYQW6xGoQqdk8DBUYehscsat+cC+amFLkx9ZRONf1pENQKcVAdmFFKKOw QlFGt2BNxrK3xgSNaJ9ZGsdbAeOF/tDhtppYqYKF7noUym0qkIedMciire35tC8LHC8X n+v8PSSDPynE+7WYfGNFBql1q0Iw9ygz3Q8/I3pyk0wc5rY3irtuu7xpmaIvNlakt/pW vdEICb/PVcB+NJ6x09fEaIDY4+3q8Eg41CPHbOnSV3VhWKgtFh5gL1UVtsSb3FJj3Leb oPZOQ1ENAx80I4+pWL8acr58Z3pkWLk2PnNHcoDTxW1cNgwxDGrNvvz5wVtiR8MyEqHf iX2g== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y3si13206262ejm.396.2020.09.17.02.41.27; Thu, 17 Sep 2020 02:42:20 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726298AbgIQJkV (ORCPT + 99 others); Thu, 17 Sep 2020 05:40:21 -0400 Received: from foss.arm.com ([217.140.110.172]:43330 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726180AbgIQJkU (ORCPT ); Thu, 17 Sep 2020 05:40:20 -0400 X-Greylist: delayed 633 seconds by postgrey-1.27 at vger.kernel.org; Thu, 17 Sep 2020 05:40:19 EDT Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 4F40A101E; Thu, 17 Sep 2020 02:29:46 -0700 (PDT) Received: from e121166-lin.cambridge.arm.com (e121166-lin.cambridge.arm.com [10.1.196.255]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id D7C733F718; Thu, 17 Sep 2020 02:29:44 -0700 (PDT) Date: Thu, 17 Sep 2020 10:29:39 +0100 From: Lorenzo Pieralisi To: Catalin Marinas Cc: linux-kernel@vger.kernel.org, George Cherian , Arnd Bergmann , Will Deacon , Bjorn Helgaas , Yang Yingliang , linux-pci@vger.kernel.org, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, "David S. Miller" Subject: Re: [PATCH v2 3/3] asm-generic/io.h: Fix !CONFIG_GENERIC_IOMAP pci_iounmap() implementation Message-ID: <20200917092939.GA1629@e121166-lin.cambridge.arm.com> References: <20200915093203.16934-1-lorenzo.pieralisi@arm.com> <20200916145111.GB3122@gaia> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200916145111.GB3122@gaia> User-Agent: Mutt/1.9.4 (2018-02-28) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Sep 16, 2020 at 03:51:11PM +0100, Catalin Marinas wrote: > On Wed, Sep 16, 2020 at 12:06:58PM +0100, Lorenzo Pieralisi wrote: > > For arches that do not select CONFIG_GENERIC_IOMAP, the current > > pci_iounmap() function does nothing causing obvious memory leaks > > for mapped regions that are backed by MMIO physical space. > > > > In order to detect if a mapped pointer is IO vs MMIO, a check must made > > available to the pci_iounmap() function so that it can actually detect > > whether the pointer has to be unmapped. > > > > In configurations where CONFIG_HAS_IOPORT_MAP && !CONFIG_GENERIC_IOMAP, > > a mapped port is detected using an ioport_map() stub defined in > > asm-generic/io.h. > > > > Use the same logic to implement a stub (ie __pci_ioport_unmap()) that > > detects if the passed in pointer in pci_iounmap() is IO vs MMIO to > > iounmap conditionally and call it in pci_iounmap() fixing the issue. > > > > Leave __pci_ioport_unmap() as a NOP for all other config options. > > > > Reported-by: George Cherian > > Link: https://lore.kernel.org/lkml/20200905024811.74701-1-yangyingliang@huawei.com > > Link: https://lore.kernel.org/lkml/20200824132046.3114383-1-george.cherian@marvell.com > > Signed-off-by: Lorenzo Pieralisi > > Cc: Arnd Bergmann > > Cc: George Cherian > > Cc: Will Deacon > > Cc: Bjorn Helgaas > > Cc: Catalin Marinas > > Cc: Yang Yingliang > > --- > > include/asm-generic/io.h | 39 +++++++++++++++++++++++++++------------ > > 1 file changed, 27 insertions(+), 12 deletions(-) > > This works for me. The only question I have is whether pci_iomap.h is > better than io.h for __pci_ioport_unmap(). These headers are really > confusing. Yes they are, in total honesty there is much more to do to make them sane, this patch is just a band-aid. I thought about moving this stuff into pci_iomap.h, though that file is included _independently_ from io.h from some arches so I tried to keep everything in io.h to minimize disruption. We can merge this patch - since it is a fix after all - and then I can try to improve the whole pci_iounmap() includes. > Either way: > > Reviewed-by: Catalin Marinas Thanks a lot. I'd appreciate a tested-by from the George as he is the one who reported the problem. Lorenzo