Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp671294pxk; Wed, 16 Sep 2020 14:00:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxxK6KmJWyog6USjb0gPBPCqZdPZvA+bVEGkqYIwMafHhgXepwHPgfAQUJeepfoquzR57bR X-Received: by 2002:a17:906:f897:: with SMTP id lg23mr29055757ejb.89.1600290049501; Wed, 16 Sep 2020 14:00:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600290049; cv=none; d=google.com; s=arc-20160816; b=okVaEbHWWfZRRHJdVIXJF9M+SlIggm9/qfHg8qwAaHcEw9ShuKMYcx1iAbRzgVTdf+ Hp6Ue8w8GdjDXBzQ7TwW132iWBVWK2d0EHBP+HMg8hdo+t/QO/LAWFSp/DEZJI5HNpN0 DF4LZLA44r/GWij6ON+zgwd9/OieqWRwlOAcJVyi0d36kGZBiYzLHDKdqE3xzNglMm+W dSVjVBBhEfNbeaWOQqgEUMAFdSqbbTv0DXLcYTInSHTswWcEt3qgHUNJEtCUwgxbsMgX eZXm6wPRDc3BYN1+G5lwaFY0Z7GLgW4diQaNDDRc9k4RV9Yjj+AIqpvWzhQiwr9OpQ0c 3JfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=bKUWnaSuPrmQj3/e9MmWUuLn1HwFhppqw7wNlE6g9EE=; b=Es1//q4N0uhgmlRRXzJpBBEdWeNUJJRAwDKl43Wk2pssFbpi1o89h1oRUu8c3LCoqO F6qlS+Cylnn9rUhfGCsN85nJUiiA/EgAupFxzCHzzI3wX/SB9nLHAPZ1dHvfFII4vAi9 +8/4XxNlDCnXmx+UYP27MPTawXxogiiNt+phsL7CKHkJCcwt1lNL5iJrvd951+giDq9T vMyZBSdb3NmNPjz+DO1T+HmJMfxHB5xQAM7glcAx6B+r6QwWwgYj57PqltWa9BTw/Knt YoP2k0Duqf1b0SS9hpKUyj10Ep5GvJGSvPjUjkBTlRnNaU/logxRyOGzorr6AKHZ7+g3 Fb/A== 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 a16si12960553eje.544.2020.09.16.14.00.25; Wed, 16 Sep 2020 14:00:49 -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 S1726721AbgIPU7W (ORCPT + 99 others); Wed, 16 Sep 2020 16:59:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:44226 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726236AbgIPQbe (ORCPT ); Wed, 16 Sep 2020 12:31:34 -0400 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 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: <20200916145111.GB3122@gaia> References: <20200915093203.16934-1-lorenzo.pieralisi@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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