From patchwork Wed Sep 16 11:06:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Pieralisi X-Patchwork-Id: 11779569 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 674CA14F6 for ; Wed, 16 Sep 2020 11:07:26 +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 1BCD220838 for ; Wed, 16 Sep 2020 11:07:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="oDjoTqUQ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1BCD220838 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+patchwork-linux-arm=patchwork.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:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=COMbKWyVNYn5yBFeZUbbU/lop4w7xrPC43VjsJqw8PU=; b=oDjoTqUQWzDSXpnVsGv/jETCn ftak56jLO1GBp1HtTp1PaGvAzAoBPoFh3eoUSe2X+3JSRNZFKi3D8B2FSSEHf1dpUh++tWMOWuZDb aKdMfNDWJfNAVujXTNsg13F7zdyRRjV3DXp74WLqn6zCbS0zlmW7GWwUB4NFp+GLgezNCSWWzWQ4m ZFqWa8zH35azMswmkl5Wk8I03AblIQWB0tb0C5hQ4fc3NtUPJ4ghk2IG8MidODfXyCO0Ljj3dBI/j wKOMCmxfbGAumhYAC6o02/coIVgllXhT/65/X/7q/s5UC9l5xL9vBCojFqfDjAnzR8GGJjm9n2+JR ZaIwmLIZA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kIVHO-0003DP-Td; Wed, 16 Sep 2020 11:07:14 +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 1kIVHJ-0003CO-J4 for linux-arm-kernel@lists.infradead.org; Wed, 16 Sep 2020 11:07:10 +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 2511D1435; Wed, 16 Sep 2020 04:07:09 -0700 (PDT) Received: from red-moon.arm.com (unknown [10.57.6.237]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 5A2C23F68F; Wed, 16 Sep 2020 04:07:06 -0700 (PDT) From: Lorenzo Pieralisi To: linux-kernel@vger.kernel.org Subject: [PATCH v2 1/3] sparc32: Remove useless io_32.h __KERNEL__ preprocessor guard Date: Wed, 16 Sep 2020 12:06:56 +0100 Message-Id: <084753d3064fe946ff1963eda2eb425cfd7daa7b.1600254147.git.lorenzo.pieralisi@arm.com> X-Mailer: git-send-email 2.26.1 In-Reply-To: References: <20200915093203.16934-1-lorenzo.pieralisi@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200916_070709_708713_41B3B5F5 X-CRM114-Status: GOOD ( 11.60 ) X-Spam-Score: -2.3 (--) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-2.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [217.140.110.172 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record 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, Lorenzo Pieralisi , George Cherian , Arnd Bergmann , linux-pci@vger.kernel.org, Yang Yingliang , Catalin Marinas , Bjorn Helgaas , Will Deacon , "David S . Miller" , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org The __KERNEL_ preprocessor guard is useless in non-uapi headers. Remove it. Signed-off-by: Lorenzo Pieralisi Cc: David S. Miller --- arch/sparc/include/asm/io_32.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/arch/sparc/include/asm/io_32.h b/arch/sparc/include/asm/io_32.h index 9a52d9506f80..8179958e3ce1 100644 --- a/arch/sparc/include/asm/io_32.h +++ b/arch/sparc/include/asm/io_32.h @@ -121,8 +121,6 @@ static inline void sbus_memcpy_toio(volatile void __iomem *dst, } } -#ifdef __KERNEL__ - /* * Bus number may be embedded in the higher bits of the physical address. * This is why we have no bus number argument to ioremap(). @@ -148,8 +146,6 @@ static inline int sbus_can_burst64(void) struct device; void sbus_set_sbus64(struct device *, int); -#endif - #define __ARCH_HAS_NO_PAGE_ZERO_MAPPED 1 From patchwork Wed Sep 16 11:06:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Pieralisi X-Patchwork-Id: 11779571 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2054459D for ; Wed, 16 Sep 2020 11:07:33 +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 B0ACF208E4 for ; Wed, 16 Sep 2020 11:07:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="S3Gyfap5" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B0ACF208E4 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+patchwork-linux-arm=patchwork.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:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=Gv/c8HLvXqiiN2edqwmg8Eep39VgsQFU5CWSOqIRHkY=; b=S3Gyfap5OX8VAN/OGHK37Uu5k sl13MArssLrYl5SPi4owVHBSazsqgc3UqFNR5UpKPR+TxylWb4p+WJUjhOOZZkxtF61pDZSoQklz6 QS7Cql4lmpr4cNYhtBfrLRs5Stx9O+KnU2or6hmKK1FAEMwHUEJ82OFmWa/12GxwnmPPH4z69hLbz HMKrFgVIwCqVNf6y3sK53nnWzxvVzhtGKdyX3UiKnDnR+WNKlelpOICkO2K0xcuOut3vfJb4fT+zX n4I2yyNcQ92Q95N4guweyLsJUiuUArW+lk3yeUYmANowWf9ZsRY9nVtXsfCIPjzP/evVPlT3javQQ VteZe6dVw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kIVHV-0003FD-BT; Wed, 16 Sep 2020 11:07:21 +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 1kIVHM-0003D7-NV for linux-arm-kernel@lists.infradead.org; Wed, 16 Sep 2020 11:07:13 +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 22A711476; Wed, 16 Sep 2020 04:07:12 -0700 (PDT) Received: from red-moon.arm.com (unknown [10.57.6.237]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 850D53F68F; Wed, 16 Sep 2020 04:07:09 -0700 (PDT) From: Lorenzo Pieralisi To: linux-kernel@vger.kernel.org Subject: [PATCH v2 2/3] sparc32: Move ioremap/iounmap declaration before asm-generic/io.h include Date: Wed, 16 Sep 2020 12:06:57 +0100 Message-Id: <93e2f23cda474a92a4708d4c50c9c359426a2162.1600254147.git.lorenzo.pieralisi@arm.com> X-Mailer: git-send-email 2.26.1 In-Reply-To: References: <20200915093203.16934-1-lorenzo.pieralisi@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200916_070712_858343_751AAA3F X-CRM114-Status: GOOD ( 13.58 ) X-Spam-Score: -2.3 (--) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-2.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [217.140.110.172 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record 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, Lorenzo Pieralisi , George Cherian , Arnd Bergmann , linux-pci@vger.kernel.org, Yang Yingliang , Catalin Marinas , Bjorn Helgaas , Will Deacon , "David S. Miller" , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Move the ioremap/iounmap declaration before asm-generic/io.h is included so that it is visible within it. Signed-off-by: Lorenzo Pieralisi Cc: "David S. Miller" --- arch/sparc/include/asm/io_32.h | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/arch/sparc/include/asm/io_32.h b/arch/sparc/include/asm/io_32.h index 8179958e3ce1..549f0a72280d 100644 --- a/arch/sparc/include/asm/io_32.h +++ b/arch/sparc/include/asm/io_32.h @@ -11,6 +11,13 @@ #define memcpy_fromio(d,s,sz) _memcpy_fromio(d,s,sz) #define memcpy_toio(d,s,sz) _memcpy_toio(d,s,sz) +/* + * Bus number may be embedded in the higher bits of the physical address. + * This is why we have no bus number argument to ioremap(). + */ +void __iomem *ioremap(phys_addr_t offset, size_t size); +void iounmap(volatile void __iomem *addr); + #include static inline void _memset_io(volatile void __iomem *dst, @@ -121,12 +128,6 @@ static inline void sbus_memcpy_toio(volatile void __iomem *dst, } } -/* - * Bus number may be embedded in the higher bits of the physical address. - * This is why we have no bus number argument to ioremap(). - */ -void __iomem *ioremap(phys_addr_t offset, size_t size); -void iounmap(volatile void __iomem *addr); /* Create a virtual mapping cookie for an IO port range */ void __iomem *ioport_map(unsigned long port, unsigned int nr); void ioport_unmap(void __iomem *); From patchwork Wed Sep 16 11:06:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Pieralisi X-Patchwork-Id: 11779573 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id ED117746 for ; Wed, 16 Sep 2020 11:08:44 +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 B8BE121655 for ; Wed, 16 Sep 2020 11:08:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Zou69u9S" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B8BE121655 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+patchwork-linux-arm=patchwork.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:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=GyX4B8XuzRsc4i/kgYSFKrEhKltC/PxWy82D+JRHw30=; b=Zou69u9Sy/qBXkEAO3EKCbk1Z N0roAuD07Np4WB7vQMQsAVt2CiU0EoJmuCSV+bfZVhlSz/z/Xt2XZOmO27RTeRwXQEmoo1gZ+2z2+ Td7ZKnMD5sgQH6M5Ki9dXsf7e9ho1xJUbueljh3PfE0fT6qSE3a7yIY4/rc50SHH6fyAjZZUpbNlc zP1CewDO3OUCdeJs2DJdi851AiRqWLidFOMOkhTn6kVcPemdsnopmVDPJnRiZzArazE4gW9gxExMs 0F8odQb9cNx7p16rVq12gLG8RtzyISgXaoQtlYS4IVCnASPJgAMzqE6Z0Se+ac2+hrDi6H+x8k6He eQFf50YXw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kIVHZ-0003Fw-AF; Wed, 16 Sep 2020 11:07:25 +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 1kIVHP-0003Dm-TZ for linux-arm-kernel@lists.infradead.org; Wed, 16 Sep 2020 11:07:17 +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 DAC7E1477; Wed, 16 Sep 2020 04:07:14 -0700 (PDT) Received: from red-moon.arm.com (unknown [10.57.6.237]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 646A23F68F; Wed, 16 Sep 2020 04:07:12 -0700 (PDT) From: Lorenzo Pieralisi To: linux-kernel@vger.kernel.org Subject: [PATCH v2 3/3] asm-generic/io.h: Fix !CONFIG_GENERIC_IOMAP pci_iounmap() implementation Date: Wed, 16 Sep 2020 12:06:58 +0100 Message-Id: X-Mailer: git-send-email 2.26.1 In-Reply-To: References: <20200915093203.16934-1-lorenzo.pieralisi@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200916_070716_076938_A279E27D X-CRM114-Status: GOOD ( 16.95 ) X-Spam-Score: -2.3 (--) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-2.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [217.140.110.172 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record 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, Lorenzo Pieralisi , George Cherian , Arnd Bergmann , Catalin Marinas , linux-pci@vger.kernel.org, Yang Yingliang , Bjorn Helgaas , Will Deacon , "David S. Miller" , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org 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 Reviewed-by: Catalin Marinas --- include/asm-generic/io.h | 39 +++++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/include/asm-generic/io.h b/include/asm-generic/io.h index dabf8cb7203b..9ea83d80eb6f 100644 --- a/include/asm-generic/io.h +++ b/include/asm-generic/io.h @@ -911,18 +911,6 @@ static inline void iowrite64_rep(volatile void __iomem *addr, #include #define __io_virt(x) ((void __force *)(x)) -#ifndef CONFIG_GENERIC_IOMAP -struct pci_dev; -extern void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long max); - -#ifndef pci_iounmap -#define pci_iounmap pci_iounmap -static inline void pci_iounmap(struct pci_dev *dev, void __iomem *p) -{ -} -#endif -#endif /* CONFIG_GENERIC_IOMAP */ - /* * Change virtual addresses to physical addresses and vv. * These are pretty trivial @@ -1016,6 +1004,16 @@ static inline void __iomem *ioport_map(unsigned long port, unsigned int nr) port &= IO_SPACE_LIMIT; return (port > MMIO_UPPER_LIMIT) ? NULL : PCI_IOBASE + port; } +#define __pci_ioport_unmap __pci_ioport_unmap +static inline void __pci_ioport_unmap(void __iomem *p) +{ + uintptr_t start = (uintptr_t) PCI_IOBASE; + uintptr_t addr = (uintptr_t) p; + + if (addr >= start && addr < start + IO_SPACE_LIMIT) + return; + iounmap(p); +} #endif #ifndef ioport_unmap @@ -1030,6 +1028,23 @@ extern void ioport_unmap(void __iomem *p); #endif /* CONFIG_GENERIC_IOMAP */ #endif /* CONFIG_HAS_IOPORT_MAP */ +#ifndef CONFIG_GENERIC_IOMAP +struct pci_dev; +extern void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long max); + +#ifndef __pci_ioport_unmap +static inline void __pci_ioport_unmap(void __iomem *p) {} +#endif + +#ifndef pci_iounmap +#define pci_iounmap pci_iounmap +static inline void pci_iounmap(struct pci_dev *dev, void __iomem *p) +{ + __pci_ioport_unmap(p); +} +#endif +#endif /* CONFIG_GENERIC_IOMAP */ + /* * Convert a virtual cached pointer to an uncached pointer */