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 X-Spam-Level: X-Spam-Status: No, score=-11.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 258F9C433E2 for ; Thu, 17 Sep 2020 09:31:11 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 657A32074B for ; Thu, 17 Sep 2020 09:31:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="vcwQiTv7" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 657A32074B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject: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=cJILuSZ62pn6JDJMbubE6jkHcVWMGS0m3F/vxJ3/4Yk=; b=vcwQiTv7jNr1zLoNlsQVXyVHF N8j1eVELW0+Sa5NUx9HJn7ciJ2yPSZT1MGVRZlOz1dftInGPeAWXLawVePULPgP43VaU8NgelH8yM k+h03h2veFI9uJ0Z0BcmtLJsC1yPWmCISJcCKkUWXcl5sJ+07SKcOLdO+iUf0iHipIgWxcgIVzDL6 qUpqXtTzrdDzIFkRExIk+za9yI8G0/mfxUYwkYQ3m1Ri9jCyQZkZ7EkwN16NWI55wXqTLSWN6FjEf 1+nd2rRT+JCMpDpUcvfsJnWNXMMwHeM9kM86pSboR9AO0hfFmBCFRlHOVGtavef6U061Pn3KXAnKF cRFlbqU+g==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kIqEh-0001RC-RP; Thu, 17 Sep 2020 09:29:51 +0000 Received: from foss.arm.com ([217.140.110.172]) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kIqEe-0001QG-RR for linux-arm-kernel@lists.infradead.org; Thu, 17 Sep 2020 09:29:50 +0000 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 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-Disposition: inline In-Reply-To: <20200916145111.GB3122@gaia> User-Agent: Mutt/1.9.4 (2018-02-28) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200917_052948_964707_3CA005A3 X-CRM114-Status: GOOD ( 23.18 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arch@vger.kernel.org, George Cherian , Arnd Bergmann , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Yang Yingliang , Bjorn Helgaas , Will Deacon , "David S. Miller" , linux-arm-kernel@lists.infradead.org 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 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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel