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 5A641C433E2 for ; Wed, 16 Sep 2020 14:53:07 +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 D9F5F21941 for ; Wed, 16 Sep 2020 14:53:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="z3S4jP5a" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D9F5F21941 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=zp8A/QheHcZ8/0vW8MmvLA+boMOP+C2jZF43ydThwUA=; b=z3S4jP5ah/HIwABoDse6LdCVQ t6o6f6o4KcorCvRmYoP+CpEfi7pwgW08bNHfxbkWHT0D3VHVx6dLt6J9nQx2cpHVjbi4GIeo2Gh6x 4CtrIcnl/fyrLgcq3NxQT3Tc5gJ5yp50m/cKf40SHxb75rggXmqURI6mN1dnNj4GC/373MxbHLvVA FFC6T21HRZiyn57rU6/EwpteuqYPyvGGiNF492gV4yn/PHTRcYJXg7cA4S7QYnU35hkxJ83nlQhNm aSH9sYcJEacq4nlFWOVWkFoMDak/i2z+gVs0k1Bg6MJKru4U+KADNpjFRlYNn5jhaEz85//wlROT9 W8RBqTwvA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kIYmG-0000pv-89; Wed, 16 Sep 2020 14:51:20 +0000 Received: from mail.kernel.org ([198.145.29.99]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kIYmC-0000p4-Su for linux-arm-kernel@lists.infradead.org; Wed, 16 Sep 2020 14:51:17 +0000 Received: from gaia (unknown [46.69.195.48]) (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 3CE28206A2; Wed, 16 Sep 2020 14:51:14 +0000 (UTC) Date: Wed, 16 Sep 2020 15:51:11 +0100 From: Catalin Marinas To: Lorenzo Pieralisi Subject: Re: [PATCH v2 3/3] asm-generic/io.h: Fix !CONFIG_GENERIC_IOMAP pci_iounmap() implementation Message-ID: <20200916145111.GB3122@gaia> References: <20200915093203.16934-1-lorenzo.pieralisi@arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200916_105116_988310_91AE9C6C X-CRM114-Status: GOOD ( 18.12 ) 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 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. Either way: Reviewed-by: Catalin Marinas _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel