From patchwork Thu Jul 6 15:45:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13303955 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 43F31EB64DC for ; Thu, 6 Jul 2023 15:45:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BCB6B6B007B; Thu, 6 Jul 2023 11:45:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BA1136B0078; Thu, 6 Jul 2023 11:45:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A68B58D0001; Thu, 6 Jul 2023 11:45:51 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 98ADE6B0075 for ; Thu, 6 Jul 2023 11:45:51 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id C431F80781 for ; Thu, 6 Jul 2023 15:45:50 +0000 (UTC) X-FDA: 80981612460.09.6C7B077 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf23.hostedemail.com (Postfix) with ESMTP id 2B56914001C for ; Thu, 6 Jul 2023 15:45:47 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Tx72DfKn; spf=pass (imf23.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1688658348; a=rsa-sha256; cv=none; b=gZXS28luJR01G2wuMRsi8TwLCjS4C4tEoHVhQHeoutcp6f4QUDRmwoihWgp7pdqY1i6VRY IzqrxM6lKhQD2CPymNLn0c3ZzsdsINKyoLXJcq+4v0TZqHB4goqW6dB1OH5P/0aiBRLIlU Rlf5xEA0LjOgH4dqr19pQ/+203Q9oDU= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Tx72DfKn; spf=pass (imf23.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1688658348; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=7XRRsQjlYVMO5pNlJJ0iFpIW4AR7WspRmqGO3azs4IQ=; b=uB0aUvhA8Yj9rrL1PLGB0Y138/9Jgd0gYmg78daFRyJ+vd+TL2TAEn5NKgfi1OKZvZAxHX fEbWjd9LylSf7iSikxBdK71sqIx93XHjIhQ+WnrVsQony3+HDxENNHjgkbM6RwpDXtJG9N 6HAPq8Fi7C6uLwfuPxzKBLHIJDdoUFg= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1688658347; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7XRRsQjlYVMO5pNlJJ0iFpIW4AR7WspRmqGO3azs4IQ=; b=Tx72DfKn+ckLjsoQdPWOZZQhdUe68J0mdSkIDTjKdC+DIcioZmaCAes9ALU42fLqAqFBWy cjQU80N0H6eM35jsdy3L/Ga0KBzKSGB7vOmyq852HdZjZNC0QJKVKb47iS+7UZd+9ZxnMG GU1EmxClv7eknokf4epaEETu9SnvYfg= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-247-rDwJ6E9hNMKvwMZGj3GkyQ-1; Thu, 06 Jul 2023 11:45:42 -0400 X-MC-Unique: rDwJ6E9hNMKvwMZGj3GkyQ-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 409CF858EED; Thu, 6 Jul 2023 15:45:41 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-39.pek2.redhat.com [10.72.12.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4EE0EF6431; Thu, 6 Jul 2023 15:45:32 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: akpm@linux-foundation.org, linux-mm@kvack.org, arnd@arndb.de, hch@lst.de, christophe.leroy@csgroup.eu, rppt@kernel.org, willy@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, shorne@gmail.com, David.Laight@ACULAB.COM, deller@gmx.de, nathan@kernel.org, glaubitz@physik.fu-berlin.de, Baoquan He , Geert Uytterhoeven Subject: [PATCH v8 01/19] asm-generic/iomap.h: remove ARCH_HAS_IOREMAP_xx macros Date: Thu, 6 Jul 2023 23:45:02 +0800 Message-Id: <20230706154520.11257-2-bhe@redhat.com> In-Reply-To: <20230706154520.11257-1-bhe@redhat.com> References: <20230706154520.11257-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 2B56914001C X-Stat-Signature: jt3tnh1e139w5gqsj95nw3bkqbr8tqw9 X-Rspam-User: X-HE-Tag: 1688658347-695910 X-HE-Meta: U2FsdGVkX19pm0LWjbb7zFpOTy0wSA2BgYL7BX0656QHW5cvbVYFEs63f5HKWMmH6img/A6I/CymzZb19HBeSHWR1BlTykO2599XywXqRyE6Rit/iFW190PXofBwJXk3QbEqFNX7obMJSFU94s9tuOlLmgkhlAgBe9T/0ubMOH96PWdS2ccUiBhC2xEdLBv8ZoOpEVaqiio1bjaG5s257+OHvboU0pJ2gDgTeX9si+f0GwG5TrCZf8uirC4hLg5LZeMEOZ7rcDaPGgLLK5K18kyhmPaqnRTwXBPal1w1w+4J71nDicSZulaPvv/1gvwqNBc6l686k9XdfpDyOM83eoO1Xr5uobogNJiWVOo4QVK41TmIPt4ZHrhT9EUD3sKWaKwS3pb0WKdAbFRXF/MfhJcQAUxXaAXkykXmdECxm4xLi1AVFITZDpPScP4/Cwj0IyW86rdPYviCJrdIfbuUmCZPvrmQTQzYkkxhwjBo2knMPYVl9jF6kxSrG7oO/B3k3mf/+rdfDDO5d8/hqHB/ocFJ4jp/b21dN0G6napaUx/g0E5sNbBxiL4RyLeA1pe3EsZprfyhEp1u5+R8g49Uycelupz6b2n0N2Qy+1/pzBC/MAIP1qWHBCpvrqgwf5fB7WaOPYUHSHpoQTnRvEMh9c6OWYEc6q3qwMZ7vhR+3xFfcStJFKdvoyfpCod+3hrwDhiZ7d1UGHjhL+x+rgpbkRAxEUZZAW1Iz5BKbW9qnfrbazQIz97W0kbbLKnopBc/YJMZY0psVPfhUmScdPDoP77YjPohYXOiowqfoXMZl5oSkQwjV8M65vblhU94hmqd2w8dNO9/zbUjv2e9KxCQlRNOsN6gXpyPTBOWv3EjXy6hJzi/yLmyDisHIr3lJbbJ8FpstkRlGNUSbwhIL3JmBRGKr9pI/i9EbNQObomVKw+bSaXDXBG7rHKWQDRXDl8ESt9+DPgoFUGzP7wNG3R vgyJyEWc FhtjooHDl/jQXFhMe96VnRqwDkaIkXlzJsKfgNduxTf0MgsJTAID5OUPCcwvrsYHJR9fJFmuaJMjyVEyoMgcmQE1saXq2pXX09pcb8rs8A5m5VqXm+lqLNuAaxLZ2VID+siV7piLwTXvsbHEstEZOeR+uqYkKyqOnKdjFRTR0ctYZFO/PM2b18HA17pFZ1jpQCLYSs3bHBcpYkV8XxSXahrEdgc2SC9PfcL4QidnFzV6Q6V19ynXk7eDeQx2oeAPwR+FG5Ta+4AnfCGDeHFjxVeqTesCBpEJi2foeDA8FPx9ryj3MZl5BzG1UFyE8raIDEXS7mlA7VX9uqOYbwBjfft//Ry82jhKmOaA6Rp7fN5JDy7xa9xh/u/OrRTI8UfkI5rkqKIj+W9Cc9Q5L89wOgEAEww== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Let's use '#define ioremap_xx' and "#ifdef ioremap_xx" instead. To remove defined ARCH_HAS_IOREMAP_xx macros in of each ARCH, the ARCH's own ioremap_wc|wt|np definition need be above "#include . Otherwise the redefinition error would be seen during compiling. So the relevant adjustments are made to avoid compiling error: loongarch: - doesn't include , defining ARCH_HAS_IOREMAP_WC is redundant, so simply remove it. m68k: - selected GENERIC_IOMAP, has been added in , and is included above , so simply remove ARCH_HAS_IOREMAP_WT defining. mips: - move "#include " below ioremap_wc definition in powerpc: - remove "#include " in because it's duplicated with the one in , let's rely on the latter. x86: - selected GENERIC_IOMAP, remove #include in the middle of . Let's rely on . Signed-off-by: Baoquan He Acked-by: Geert Uytterhoeven Reviewed-by: Mike Rapoport (IBM) Reviewed-by: Christoph Hellwig --- arch/loongarch/include/asm/io.h | 2 -- arch/m68k/include/asm/io_mm.h | 2 -- arch/m68k/include/asm/kmap.h | 2 -- arch/mips/include/asm/io.h | 5 ++--- arch/powerpc/include/asm/io.h | 9 +-------- arch/x86/include/asm/io.h | 5 ----- drivers/net/ethernet/sfc/io.h | 2 +- drivers/net/ethernet/sfc/siena/io.h | 2 +- include/asm-generic/iomap.h | 6 +++--- 9 files changed, 8 insertions(+), 27 deletions(-) diff --git a/arch/loongarch/include/asm/io.h b/arch/loongarch/include/asm/io.h index 1c9410220040..0dcb36b32cb2 100644 --- a/arch/loongarch/include/asm/io.h +++ b/arch/loongarch/include/asm/io.h @@ -5,8 +5,6 @@ #ifndef _ASM_IO_H #define _ASM_IO_H -#define ARCH_HAS_IOREMAP_WC - #include #include diff --git a/arch/m68k/include/asm/io_mm.h b/arch/m68k/include/asm/io_mm.h index d41fa488453b..6a0abd4846c6 100644 --- a/arch/m68k/include/asm/io_mm.h +++ b/arch/m68k/include/asm/io_mm.h @@ -26,8 +26,6 @@ #include #include -#include - #ifdef CONFIG_ATARI #define atari_readb raw_inb #define atari_writeb raw_outb diff --git a/arch/m68k/include/asm/kmap.h b/arch/m68k/include/asm/kmap.h index dec05743d426..4efb3efa593a 100644 --- a/arch/m68k/include/asm/kmap.h +++ b/arch/m68k/include/asm/kmap.h @@ -4,8 +4,6 @@ #ifdef CONFIG_MMU -#define ARCH_HAS_IOREMAP_WT - /* Values for nocacheflag and cmode */ #define IOMAP_FULL_CACHING 0 #define IOMAP_NOCACHE_SER 1 diff --git a/arch/mips/include/asm/io.h b/arch/mips/include/asm/io.h index affd21e9c20b..062dd4e6b954 100644 --- a/arch/mips/include/asm/io.h +++ b/arch/mips/include/asm/io.h @@ -12,8 +12,6 @@ #ifndef _ASM_IO_H #define _ASM_IO_H -#define ARCH_HAS_IOREMAP_WC - #include #include #include @@ -25,7 +23,6 @@ #include #include #include -#include #include #include #include @@ -210,6 +207,8 @@ void iounmap(const volatile void __iomem *addr); #define ioremap_wc(offset, size) \ ioremap_prot((offset), (size), boot_cpu_data.writecombine) +#include + #if defined(CONFIG_CPU_CAVIUM_OCTEON) #define war_io_reorder_wmb() wmb() #else diff --git a/arch/powerpc/include/asm/io.h b/arch/powerpc/include/asm/io.h index f1e657c9bbe8..67a3fb6de498 100644 --- a/arch/powerpc/include/asm/io.h +++ b/arch/powerpc/include/asm/io.h @@ -3,11 +3,6 @@ #define _ASM_POWERPC_IO_H #ifdef __KERNEL__ -#define ARCH_HAS_IOREMAP_WC -#ifdef CONFIG_PPC32 -#define ARCH_HAS_IOREMAP_WT -#endif - /* */ @@ -732,9 +727,7 @@ static inline void name at \ #define writel_relaxed(v, addr) writel(v, addr) #define writeq_relaxed(v, addr) writeq(v, addr) -#ifdef CONFIG_GENERIC_IOMAP -#include -#else +#ifndef CONFIG_GENERIC_IOMAP /* * Here comes the implementation of the IOMAP interfaces. */ diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h index e9025640f634..76238842406a 100644 --- a/arch/x86/include/asm/io.h +++ b/arch/x86/include/asm/io.h @@ -35,9 +35,6 @@ * - Arnaldo Carvalho de Melo */ -#define ARCH_HAS_IOREMAP_WC -#define ARCH_HAS_IOREMAP_WT - #include #include #include @@ -212,8 +209,6 @@ void memset_io(volatile void __iomem *, int, size_t); #define memcpy_toio memcpy_toio #define memset_io memset_io -#include - /* * ISA space is 'always mapped' on a typical x86 system, no need to * explicitly ioremap() it. The fact that the ISA IO space is mapped diff --git a/drivers/net/ethernet/sfc/io.h b/drivers/net/ethernet/sfc/io.h index 30439cc83a89..07f99ad14bf3 100644 --- a/drivers/net/ethernet/sfc/io.h +++ b/drivers/net/ethernet/sfc/io.h @@ -70,7 +70,7 @@ */ #ifdef CONFIG_X86_64 /* PIO is a win only if write-combining is possible */ -#ifdef ARCH_HAS_IOREMAP_WC +#ifdef ioremap_wc #define EFX_USE_PIO 1 #endif #endif diff --git a/drivers/net/ethernet/sfc/siena/io.h b/drivers/net/ethernet/sfc/siena/io.h index 30439cc83a89..07f99ad14bf3 100644 --- a/drivers/net/ethernet/sfc/siena/io.h +++ b/drivers/net/ethernet/sfc/siena/io.h @@ -70,7 +70,7 @@ */ #ifdef CONFIG_X86_64 /* PIO is a win only if write-combining is possible */ -#ifdef ARCH_HAS_IOREMAP_WC +#ifdef ioremap_wc #define EFX_USE_PIO 1 #endif #endif diff --git a/include/asm-generic/iomap.h b/include/asm-generic/iomap.h index 08237ae8b840..196087a8126e 100644 --- a/include/asm-generic/iomap.h +++ b/include/asm-generic/iomap.h @@ -93,15 +93,15 @@ extern void __iomem *ioport_map(unsigned long port, unsigned int nr); extern void ioport_unmap(void __iomem *); #endif -#ifndef ARCH_HAS_IOREMAP_WC +#ifndef ioremap_wc #define ioremap_wc ioremap #endif -#ifndef ARCH_HAS_IOREMAP_WT +#ifndef ioremap_wt #define ioremap_wt ioremap #endif -#ifndef ARCH_HAS_IOREMAP_NP +#ifndef ioremap_np /* See the comment in asm-generic/io.h about ioremap_np(). */ #define ioremap_np ioremap_np static inline void __iomem *ioremap_np(phys_addr_t offset, size_t size) From patchwork Thu Jul 6 15:45:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13303956 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 19545EB64D9 for ; Thu, 6 Jul 2023 15:46:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AB8566B0075; Thu, 6 Jul 2023 11:46:04 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A681A6B0078; Thu, 6 Jul 2023 11:46:04 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 930378D0001; Thu, 6 Jul 2023 11:46:04 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 8216D6B0075 for ; Thu, 6 Jul 2023 11:46:04 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 84313804C5 for ; Thu, 6 Jul 2023 15:46:03 +0000 (UTC) X-FDA: 80981613006.21.C80A842 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf12.hostedemail.com (Postfix) with ESMTP id 712A54000E for ; Thu, 6 Jul 2023 15:45:59 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=DIa+yfdR; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf12.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1688658359; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=mrpD6SwU7RX+eLIqGEOviqMeuTumyLFYQ/9zvaQiSxE=; b=M1N1eH6RQW17PRTaeSs7MH2J42OfDmJtP2z60TiVTy3Or/KBZ1sLDTy5Jg/BDvGNEd/J16 /kSZ0vk+MQ3zIXpSvIe86bEufPIdicK4uv+Id66mgTLiKaM/LrvURv5uXJC4tbKq3x/sMB CaUebHjJBIm9WrIvazkzxcmc4L0WCI0= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=DIa+yfdR; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf12.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1688658359; a=rsa-sha256; cv=none; b=yHjZMsQ5mJU/K8kUcXRtMyY23HOkHlb5f+QN9CiIyXP0HG0Ce3BSiSpaqu+bq9vpdG0z0v 3+iCAdVSnbAcy1C3kO7T5Jr+0Se55iWeaSXNWA0dDhiZmWRAwDl5Qo7LAjPqhUY0UcXZbg 0/XFCveQr1+1Dc+ObfYxB2P1OfgCNbY= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1688658358; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mrpD6SwU7RX+eLIqGEOviqMeuTumyLFYQ/9zvaQiSxE=; b=DIa+yfdR9rmO5hx2gvA13QfpDo+mN0fYIMug7KUDSviu2cxCLfqC5qbSxlY7otxnv9fo+G nlUHvld826owkjS7GksnRunyRxjfV2b8+AuHGPrsSNcfhM/OfJ4OgddFmQOtawBthxy1+p IjiBsD3/qJ1zo2PzZqZcXz5WuDVSKNI= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-601-mre9K1UsPoOt1IOmZqTezw-1; Thu, 06 Jul 2023 11:45:51 -0400 X-MC-Unique: mre9K1UsPoOt1IOmZqTezw-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5318B3C0D845; Thu, 6 Jul 2023 15:45:50 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-39.pek2.redhat.com [10.72.12.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id 067C9F5CF0; Thu, 6 Jul 2023 15:45:41 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: akpm@linux-foundation.org, linux-mm@kvack.org, arnd@arndb.de, hch@lst.de, christophe.leroy@csgroup.eu, rppt@kernel.org, willy@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, shorne@gmail.com, David.Laight@ACULAB.COM, deller@gmx.de, nathan@kernel.org, glaubitz@physik.fu-berlin.de, Baoquan He , Brian Cain , linux-hexagon@vger.kernel.org Subject: [PATCH v8 02/19] hexagon: mm: Convert to GENERIC_IOREMAP Date: Thu, 6 Jul 2023 23:45:03 +0800 Message-Id: <20230706154520.11257-3-bhe@redhat.com> In-Reply-To: <20230706154520.11257-1-bhe@redhat.com> References: <20230706154520.11257-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Rspamd-Queue-Id: 712A54000E X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: pnnfzezr39ojf5czpnijfcik4hdo5fnh X-HE-Tag: 1688658359-289462 X-HE-Meta: U2FsdGVkX18HZwz8Qe0VnykIl96IH7TvjSnImpKu3sKrSFEp0Nr0lo50RBEIjZZn9zXVrBOUNvk8r4ISitMdWXPpU1c6W9kcQp6E9UP7/E50lVd/4XZKkFtPEbaUuT1vOTzTmgsUYD5ObwCP2B9HSZWiiFU/Z7HpEQxzeFwnZOJx48Mum/y0a2lDZ25Z2IPS0uFye9VkEgq9szGSU0rws/aISlkstiIOl2mV/0Jqp/HfokaEDFH7Ka9VkS4N0xA3iFoxEh4jfeDdZUPTBaQ0KPJqYBAVWLaSY+McOcxiYZPuKl3/L8DpK+cQ8egEu7i+LGz9Q0fUQEUhoVQ28PK05/gNuxLe8o2OyLyg0yOK9KI/kVs6r8SHCI94R6Soo5tVWkyfWEfc2Fv5fSmoOJPVGyujc6tru6wMUSBmEDZU2XXA8jjVudIrDjVXElVwdc5+Qn8/BBau2qNXR6vnS4vEmNEVnw/joGYS9fAWY6r+W0efubW9IgvHErdnbjNjPb0G2utRgTcqTsgNbQ53Ogu5odW+bwKyeZNxRgVio+MRgw4kDC/iqLL69mbtL3Av2i1pGVAxxuRmehX5w7RBbir+EcNunTB7LCXcbXLqcMYKhRGdSfs1IVyHrEXvV6IATbaHFSo4TbD5yxHZFjc7dja5bbCmKD/rADwpXo4Ke6VMCXFjLXRqhsaSv8GugVhl8JF2rkLbW1oUXz5ib+NBXI+eLzESvUrFiSchpUyk2U7pkcI9JDXgPZf5GEw+fLyh3Z9cm3PPLDSync5Wx3sN6aG0aNWx02xt2mXplj6pEZzpOmL+Fu+n6hb4lKi+j7kOd949QETg/xod87gxaoAm5gVZwadeWD2iQ8+5ObYXhvfjOZhMs33BIwGyRrkZ+UclosphZ/1pzblqR/xzgzAvzOvGBnQ5xIbK9oDpBpvY/o85Z/5FIEKihPRIaldKeITzDTvaP+AWzCVzptwAFYdsnDC 7tZg9ibN TIaghd0m1fG26GRkxaGH+62E20/hJIxC34+ZdBKWR66XjquTU2g791lD+THDDaCph9BycmAkByENSiCKkR0lc1Bp1Ds07VN41wawJ19UAlbTnm9jSixB+piT1jqPm7c6jRqipzXMvZr4JMk7nBZQQ+RDlckMK69myiavt13HowJn6gzn+tPTyoT7B23e7uZYxPT4OEq62jBwfvWyTQHJmkS4Vv1RZST4GjeynsSALu5IgUwhDbrtb+RMF9020XaRwveL0WK5hl7QxdtvXZaNwb8wPguEhzbQNG53zB31hZES8TjmGlAx7/uz5sVlwVbRUFWfZfeEe9ZMxaaA2xEPvYlq0gA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: By taking GENERIC_IOREMAP method, the generic ioremap_prot() and iounmap() are visible and available to arch. This change will simplify implementation by removing duplicated code with generic ioremap_prot() and iounmap(), and has the equivalent functioality. For hexagon, the current ioremap() and iounmap() are the same as generic version. After taking GENERIC_IOREMAP way, the old ioremap() and iounmap() can be completely removed. Signed-off-by: Baoquan He Cc: Brian Cain Cc: linux-hexagon@vger.kernel.org Reviewed-by: Christoph Hellwig --- v7->v8: Fix the error reported by lkp test robot on patch. Thanks to Nathan for providing the code fix after reproducing. arch/hexagon/Kconfig | 1 + arch/hexagon/include/asm/io.h | 11 +++++--- arch/hexagon/kernel/hexagon_ksyms.c | 2 -- arch/hexagon/mm/Makefile | 2 +- arch/hexagon/mm/ioremap.c | 44 ----------------------------- 5 files changed, 9 insertions(+), 51 deletions(-) delete mode 100644 arch/hexagon/mm/ioremap.c diff --git a/arch/hexagon/Kconfig b/arch/hexagon/Kconfig index 6726f4941015..a880ee067d2e 100644 --- a/arch/hexagon/Kconfig +++ b/arch/hexagon/Kconfig @@ -25,6 +25,7 @@ config HEXAGON select NEED_SG_DMA_LENGTH select NO_IOPORT_MAP select GENERIC_IOMAP + select GENERIC_IOREMAP select GENERIC_SMP_IDLE_THREAD select STACKTRACE_SUPPORT select GENERIC_CLOCKEVENTS_BROADCAST diff --git a/arch/hexagon/include/asm/io.h b/arch/hexagon/include/asm/io.h index 46a099de85b7..e2b308e32a37 100644 --- a/arch/hexagon/include/asm/io.h +++ b/arch/hexagon/include/asm/io.h @@ -27,8 +27,6 @@ extern int remap_area_pages(unsigned long start, unsigned long phys_addr, unsigned long end, unsigned long flags); -extern void iounmap(const volatile void __iomem *addr); - /* Defined in lib/io.c, needed for smc91x driver. */ extern void __raw_readsw(const void __iomem *addr, void *data, int wordlen); extern void __raw_writesw(void __iomem *addr, const void *data, int wordlen); @@ -170,8 +168,13 @@ static inline void writel(u32 data, volatile void __iomem *addr) #define writew_relaxed __raw_writew #define writel_relaxed __raw_writel -void __iomem *ioremap(unsigned long phys_addr, unsigned long size); -#define ioremap_uc(X, Y) ioremap((X), (Y)) +/* + * I/O memory mapping functions. + */ +#define _PAGE_IOREMAP (_PAGE_PRESENT | _PAGE_READ | _PAGE_WRITE | \ + (__HEXAGON_C_DEV << 6)) + +#define ioremap_uc(addr, size) ioremap((addr), (size)) #define __raw_writel writel diff --git a/arch/hexagon/kernel/hexagon_ksyms.c b/arch/hexagon/kernel/hexagon_ksyms.c index ec56ce2d92a2..36a80e31d187 100644 --- a/arch/hexagon/kernel/hexagon_ksyms.c +++ b/arch/hexagon/kernel/hexagon_ksyms.c @@ -14,12 +14,10 @@ EXPORT_SYMBOL(__clear_user_hexagon); EXPORT_SYMBOL(raw_copy_from_user); EXPORT_SYMBOL(raw_copy_to_user); -EXPORT_SYMBOL(iounmap); EXPORT_SYMBOL(__vmgetie); EXPORT_SYMBOL(__vmsetie); EXPORT_SYMBOL(__vmyield); EXPORT_SYMBOL(empty_zero_page); -EXPORT_SYMBOL(ioremap); EXPORT_SYMBOL(memcpy); EXPORT_SYMBOL(memset); diff --git a/arch/hexagon/mm/Makefile b/arch/hexagon/mm/Makefile index 49911a906fd0..ba4b04d962d6 100644 --- a/arch/hexagon/mm/Makefile +++ b/arch/hexagon/mm/Makefile @@ -3,5 +3,5 @@ # Makefile for Hexagon memory management subsystem # -obj-y := init.o ioremap.o uaccess.o vm_fault.o cache.o +obj-y := init.o uaccess.o vm_fault.o cache.o obj-y += copy_to_user.o copy_from_user.o vm_tlb.o diff --git a/arch/hexagon/mm/ioremap.c b/arch/hexagon/mm/ioremap.c deleted file mode 100644 index 255c5b1ee1a7..000000000000 --- a/arch/hexagon/mm/ioremap.c +++ /dev/null @@ -1,44 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-only -/* - * I/O remap functions for Hexagon - * - * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved. - */ - -#include -#include -#include - -void __iomem *ioremap(unsigned long phys_addr, unsigned long size) -{ - unsigned long last_addr, addr; - unsigned long offset = phys_addr & ~PAGE_MASK; - struct vm_struct *area; - - pgprot_t prot = __pgprot(_PAGE_PRESENT|_PAGE_READ|_PAGE_WRITE - |(__HEXAGON_C_DEV << 6)); - - last_addr = phys_addr + size - 1; - - /* Wrapping not allowed */ - if (!size || (last_addr < phys_addr)) - return NULL; - - /* Rounds up to next page size, including whole-page offset */ - size = PAGE_ALIGN(offset + size); - - area = get_vm_area(size, VM_IOREMAP); - addr = (unsigned long)area->addr; - - if (ioremap_page_range(addr, addr+size, phys_addr, prot)) { - vunmap((void *)addr); - return NULL; - } - - return (void __iomem *) (offset + addr); -} - -void iounmap(const volatile void __iomem *addr) -{ - vunmap((void *) ((unsigned long) addr & PAGE_MASK)); -} From patchwork Thu Jul 6 15:45:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13303957 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 45C91EB64D9 for ; Thu, 6 Jul 2023 15:46:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9F4D66B007D; Thu, 6 Jul 2023 11:46:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9A48C6B007E; Thu, 6 Jul 2023 11:46:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 847246B0080; Thu, 6 Jul 2023 11:46:10 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 7342B6B007D for ; Thu, 6 Jul 2023 11:46:10 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 01AE6A04FF for ; Thu, 6 Jul 2023 15:46:09 +0000 (UTC) X-FDA: 80981613300.01.81E3642 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf09.hostedemail.com (Postfix) with ESMTP id D5361140020 for ; Thu, 6 Jul 2023 15:46:06 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=CFWen3+B; spf=pass (imf09.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1688658366; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=pQumlSibFcTmcmpj3o91A5K5Zwuz/UGXp5mnVQ2pvKA=; b=FhcUF4roxWaimnhcArPmZ8Kc5mr3a5O0VKpzjJcrw6YpCJV56Lf/q0237PyzIFImmIb+sU /RocuGhyQ4fyTmIc3a0STLKhdSQ09e6lulKh/W8+i7FYV3sKGEmxBOsV7WMojpJv1G0Nqy /MTs5Q3qsuBpOakjl/eaoJ/6JBhZYHc= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1688658366; a=rsa-sha256; cv=none; b=XJdFSg1h2aFJJsWxv5IbquC/EcrUU07pLXln+mZK+grZCvdkxDP+FqfVrSm/p4XFRq8tkX 6WcyV2SVhK2C/l50bWBFw+KrKcucm7MW/CBK0QUSvUc8EQ2uNqGb3Pg0kF0h7dZJRLFyph rnxYSm7ob9y7IyJw0pjTLftB9h1h/ZY= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=CFWen3+B; spf=pass (imf09.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1688658365; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=pQumlSibFcTmcmpj3o91A5K5Zwuz/UGXp5mnVQ2pvKA=; b=CFWen3+BhzJlvJOGQHi0G5J6x8PURDbx2VosF8ANJEAbAoHk+GpMbx0sz2tbH82A71V5lS c2CiG+Ci1cq/SiMu0ea3sKKG/qLlngRqIrLXcU2+axyKW8CUujJWJfNpgWU6PEV564LJLf ImGj/GiE6ckaI0HPZjEhMhvEzxGNbRc= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-441-pVjnAUWyOpa14DMQOD0ttQ-1; Thu, 06 Jul 2023 11:46:02 -0400 X-MC-Unique: pVjnAUWyOpa14DMQOD0ttQ-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 55F7B101A528; Thu, 6 Jul 2023 15:46:00 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-39.pek2.redhat.com [10.72.12.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id 22C8FF5CF0; Thu, 6 Jul 2023 15:45:50 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: akpm@linux-foundation.org, linux-mm@kvack.org, arnd@arndb.de, hch@lst.de, christophe.leroy@csgroup.eu, rppt@kernel.org, willy@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, shorne@gmail.com, David.Laight@ACULAB.COM, deller@gmx.de, nathan@kernel.org, glaubitz@physik.fu-berlin.de, Baoquan He , Jonas Bonn , Stefan Kristiansson , openrisc@lists.librecores.org Subject: [PATCH v8 03/19] openrisc: mm: remove unneeded early ioremap code Date: Thu, 6 Jul 2023 23:45:04 +0800 Message-Id: <20230706154520.11257-4-bhe@redhat.com> In-Reply-To: <20230706154520.11257-1-bhe@redhat.com> References: <20230706154520.11257-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Rspamd-Queue-Id: D5361140020 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: r544u6z7a58jbjh73ydh14n517rrk6w6 X-HE-Tag: 1688658366-437710 X-HE-Meta: U2FsdGVkX1+L1WUOei+dv/LvSRWgpsSp0iOEFANdu2FxLHFEIuSLBieOWivQNvpV8FxLPuzQpKPzCHMH5WF0QFL92EPXRhjqODS/qWHANULrHWRlfGsSRRwlo0+XZyO8RVEAhTXSkz5z6HuuKCS4rZ8spWCjvVN9rh2Q0p0S6pkun5C3oh6JzjP7PGycBjRaiLpTxUy3MyheoDnaIoZhX1Id2EOhZhy6EW9lt76iGey9LZ3y5zlUh7w5SZ4DPU+aoMjDdkdgvsKKs9FYH9SjYTi+tbxTHVXnGmP5oo0zhRY2jClXASpyAL6oMFb/D1kwQuYWIF+kRUv6lKDPFedwWWDRtxaYrcEPL5cTBpXFZ+vUkqrpCZtnxWFx/RthWfdUpI23aHux24H1y4KHMfokJSvVJckhH/Bgeqbu5Ks0TI2bnEPlw4IR3UgAfcwmlnTKpf4AviplRAI/SAVytgBEUSx/TmpWH8YmbFt+dCEjJbcVz+YYTnTVIcDRccQ3WvkLAy7Vrfm/qMCLZDNdiLGy246g1uNBJIl8tud59R4ERLy9h+DA+ILHaqSS2cog3YGLnUKEQF74rTsaU/tcZ/QFR2lj2vGWasEUTY0crSAF4LoSBIp/DoCtuUMftR5MElXqREOqZNZ5OP3ejtF7/IOLi3WUOH1/KtbUZRcIVUrXNcUV1j3Xts1PPtYCuinaX0SGvIKVKZhwWE37SAk3lpYleu4ALrxRahvFIodlR+e/vRMjrg7pjNBUHC3aZElvhZbLeoMylPbovcrVShytyO6sExfcDC/UjbwYBCPjOo1ybY+KR8TzjxmlFLTh6a2S7/0GcTJ3Ln5vx/wlHijLibvo40Lrr7ZHr1EwlwwYmpo4KNOtH+xoLDVIfhEVL5db0QTFHd1tGxsRhDrO6R/z/qjjQflmLYCxBddsch0gVllmijWnpJFuZOAnCgwBP8TM4qiCxIY9rhBUG9QwTgY08zK 9iPvK4Bq xFfHOVr1s2pTlolHT9V0+PUJbyrytKCEG/UrUuZK99b4OXB+TAvgrWrBXuiiwgpuCMcTzHpcSVzSt54YMckkQgqG9y+khDZ/6NmUEV6kSqCBPXrIoBaxd5Gu89o0B73d2qUIQsuFmY6cBbY1UM1sB+Z9DcM0FO4sCnXAvM7OdnP5G4cby9M6IzbdjRyxHOPKyD9wMt0zrsAyFksSXVBu7F/W+qQwI1hVPphiuywBNSYGU726uJjU+OSNd26ZebSFaCE8UTOw7SGNyd6sGXGS6x4haYCux/7eGdhoam+0HHRbtwgN2EeS/bR6R+ZNnKyb06X6P X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Under arch/openrisc, there isn't any place where ioremap() is called. It means that there isn't early ioremap handling needed in openrisc, So the early ioremap handling code in ioremap() of arch/openrisc/mm/ioremap.c is unnecessary and can be removed. And also remove the special handling in iounmap() since no page is got from fixmap pool along with early ioremap code removing in ioremap(). Link: https://lore.kernel.org/linux-mm/YwxfxKrTUtAuejKQ@oscomms1/ Signed-off-by: Baoquan He Acked-by: Stafford Horne Reviewed-by: Christoph Hellwig Reviewed-by: Mike Rapoport (IBM) Cc: Jonas Bonn Cc: Stefan Kristiansson Cc: Stafford Horne Cc: openrisc@lists.librecores.org --- arch/openrisc/mm/ioremap.c | 43 +++++--------------------------------- 1 file changed, 5 insertions(+), 38 deletions(-) diff --git a/arch/openrisc/mm/ioremap.c b/arch/openrisc/mm/ioremap.c index 8ec0dafecf25..cdbcc7e73684 100644 --- a/arch/openrisc/mm/ioremap.c +++ b/arch/openrisc/mm/ioremap.c @@ -22,8 +22,6 @@ extern int mem_init_done; -static unsigned int fixmaps_used __initdata; - /* * Remap an arbitrary physical address space into the kernel virtual * address space. Needed when the kernel wants to access high addresses @@ -52,24 +50,14 @@ void __iomem *__ref ioremap(phys_addr_t addr, unsigned long size) p = addr & PAGE_MASK; size = PAGE_ALIGN(last_addr + 1) - p; - if (likely(mem_init_done)) { - area = get_vm_area(size, VM_IOREMAP); - if (!area) - return NULL; - v = (unsigned long)area->addr; - } else { - if ((fixmaps_used + (size >> PAGE_SHIFT)) > FIX_N_IOREMAPS) - return NULL; - v = fix_to_virt(FIX_IOREMAP_BEGIN + fixmaps_used); - fixmaps_used += (size >> PAGE_SHIFT); - } + area = get_vm_area(size, VM_IOREMAP); + if (!area) + return NULL; + v = (unsigned long)area->addr; if (ioremap_page_range(v, v + size, p, __pgprot(pgprot_val(PAGE_KERNEL) | _PAGE_CI))) { - if (likely(mem_init_done)) - vfree(area->addr); - else - fixmaps_used -= (size >> PAGE_SHIFT); + vfree(area->addr); return NULL; } @@ -79,27 +67,6 @@ EXPORT_SYMBOL(ioremap); void iounmap(volatile void __iomem *addr) { - /* If the page is from the fixmap pool then we just clear out - * the fixmap mapping. - */ - if (unlikely((unsigned long)addr > FIXADDR_START)) { - /* This is a bit broken... we don't really know - * how big the area is so it's difficult to know - * how many fixed pages to invalidate... - * just flush tlb and hope for the best... - * consider this a FIXME - * - * Really we should be clearing out one or more page - * table entries for these virtual addresses so that - * future references cause a page fault... for now, we - * rely on two things: - * i) this code never gets called on known boards - * ii) invalid accesses to the freed areas aren't made - */ - flush_tlb_all(); - return; - } - return vfree((void *)(PAGE_MASK & (unsigned long)addr)); } EXPORT_SYMBOL(iounmap); From patchwork Thu Jul 6 15:45:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13303962 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 23759EB64D9 for ; Thu, 6 Jul 2023 15:46:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8BD306B007E; Thu, 6 Jul 2023 11:46:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 86C946B0080; Thu, 6 Jul 2023 11:46:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 734DC8D0001; Thu, 6 Jul 2023 11:46:18 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 61AEB6B007E for ; Thu, 6 Jul 2023 11:46:18 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 359BB403B7 for ; Thu, 6 Jul 2023 15:46:18 +0000 (UTC) X-FDA: 80981613636.09.7C7DC2F Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf17.hostedemail.com (Postfix) with ESMTP id 28C6840023 for ; Thu, 6 Jul 2023 15:46:15 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=IF8fGozy; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf17.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1688658376; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=X3bCqAOghUMsrFt01sdBss+0xjEFSAaHuAsd0sFdmyw=; b=6X+cTdwgFU0pWJ14X5+0dObo3eF1TJFUtZQ6A3F1qVMXUgET0ANMAh9i5kRe3y7gfvWhKf dAGpo3rMjtMEPDQZ6VhK6g3TO7wcjhbgbr/56wlDQk5EXi32iTpk3muDmENlxvo1BMsxmt Jd5bD2oqrfvkU+ucSG3IyAzkVObQaic= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=IF8fGozy; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf17.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1688658376; a=rsa-sha256; cv=none; b=h2HpgySKQW2+NM/AusVtfcvsBqgJAg9yk5xJDmvJoAyZ0hKxnqYJTTB7I/EJ3exJcTW2dG 50wVtN3SsBfONsRosy6UL6Gclo1208DTgaVUiffS7bvs+hyi8jbL7hXpRa0Of+6PBaq8/s B/7DFz1lpYMEEi4f2cHFcbm6uuJJxDA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1688658375; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=X3bCqAOghUMsrFt01sdBss+0xjEFSAaHuAsd0sFdmyw=; b=IF8fGozyH5BdhjFxzK679BBw/9Vjxcr92sKiIfGmtl0lb1z2ND3p3nw7u8zP60y/6b6t5H XF0ZR+nPuKwVR9NCJWzEsB7Am+lui6QbiJ5o9YuxeI5FVi7cAFLi76ZEwbj0kBcv+mYPaE v8i8fgkSGS04+aGinf+iFgKFYO2tXuQ= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-556-7eAVe7wZPSC4sGD6Lhz-8w-1; Thu, 06 Jul 2023 11:46:10 -0400 X-MC-Unique: 7eAVe7wZPSC4sGD6Lhz-8w-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id EC4E6185A792; Thu, 6 Jul 2023 15:46:08 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-39.pek2.redhat.com [10.72.12.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2D76AF5CF0; Thu, 6 Jul 2023 15:46:00 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: akpm@linux-foundation.org, linux-mm@kvack.org, arnd@arndb.de, hch@lst.de, christophe.leroy@csgroup.eu, rppt@kernel.org, willy@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, shorne@gmail.com, David.Laight@ACULAB.COM, deller@gmx.de, nathan@kernel.org, glaubitz@physik.fu-berlin.de, Baoquan He Subject: [PATCH v8 04/19] mm/ioremap: Define generic_ioremap_prot() and generic_iounmap() Date: Thu, 6 Jul 2023 23:45:05 +0800 Message-Id: <20230706154520.11257-5-bhe@redhat.com> In-Reply-To: <20230706154520.11257-1-bhe@redhat.com> References: <20230706154520.11257-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 28C6840023 X-Stat-Signature: 7ztysdu9gnibhyfri9g6aa3yrt7akrad X-Rspam-User: X-HE-Tag: 1688658375-868226 X-HE-Meta: U2FsdGVkX19E3x1rlOX7AjIzBz3ytuNaNlJ5Dj0n+xXyVZwwNGaOIO26wxPb5zxdTZhztzBN09zLRZi5y6wjYKIt5rHV4SHn0FOmdQiMZZSJLoVvrXl0PbbrtKZMAAETTYBR9sjNKWbhU8o7UpKWp/XUrQGuoF53AkcXVQXcpZ7NrwfZxUuFzq/i1SLoqMx2cmI04YiXnjWx3KvfAbuhZDGYg7F6TSWi4dv/KngVFsHkv+sJ4K09pM1du4AuyR6skdgqU+SqjZA5HldU7yV/FiTb0nXey4XITnpVE5IdX3vd2Briy1ez/uKD8+S9lydmB4IywgRbGb4cIVTx659H4HBPR9DAEifXJ9X3rm8FMd/hfnxwD3lA9YVM4lZHxwUgdM4lv393xwxi2m/AjZRsitDOa+CivkwdRkne52qYXjrA7tQWc5xIB8y4yeUgInHMieD8M3OVDUt1IEIfE6VmIAW3z4XdTPWj4k/4ukg84ie1UDhOfT15fKzwE7ToAtvljrMer3lV1dO0yGjTxf1ODtx3SAs43mPK5Sj4/bc2YA3va2YlcMHh05afm+siwPTJr7p+CoicH8haGIYMrJiH6rM0lnTDvrSldYckIFH7n0+MK544xylzblvPi5Web0UC24kylB5Ipa+17aY3KzJmoFm53avJbCnlN1ECmm3Dn3xN7zSTX2LrSaYGbIYhzj1XZJvg4VV4aGEeHOY6Q8wQnhBN+GOwKHk7v+jhu+Kqr+0+yxibgb1lgpsvLxH0mGv9ewLi4Pk+t8/M57F9u4GyUJy2IGlb2dlpoEcpKLQ3KhWbFcti/7dZ8hkbihyLNRU+Ix0KbIK29Yd2Z0vQk3P+VZARIkXN0W7X/KSKYOVqA/yHx3Rz621AJ6ejRhXj5OC0LA5luquHi115gVBz9BBJShwo/aFQkSAJLy06iDadqkHXgFXvYCYlHb84rNj1s73miohVGx+g9FMeG3DO/8D uuxfSw77 kz0PRf+swKbsToxjtgeVcHL+iDUixGOPY2jm5IBJc0DfmekAq0/8w7/pmLA/VFPTgCECEIfNeKwshi63MXGX1/emdTmpN4f6/CE2noLKxVi8PhWiUKcVIcHyVVUu0tpR1XqAdU9rYh+XXMid3BK7IGLCpyBhiC/TVS0ywLjHKqBBgnfKRwIUI+FZv3U9B1f4J9FQhsa5ko8Kt2JsQtmUE2+JFqNnDzpF4xbqedI5RRPqwfOzfmT5ShhZ6aisYJXBlHLBrjv8UleKyOU3ldZ631E9rRFBXskyEOq8PTH6Zt+A2Ifnwomp+IRR8Ae/d8OrTuojGrEvCT92s1btz8FmjQSKLAIIlEannLQHMpsL9lTyPlAc= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Christophe Leroy Define a generic version of ioremap_prot() and iounmap() that architectures can call after they have performed the necessary alteration to parameters and/or necessary verifications. Signed-off-by: Christophe Leroy Signed-off-by: Baoquan He Reviewed-by: Christoph Hellwig Reviewed-by: Kefeng Wang Reviewed-by: Mike Rapoport (IBM) --- include/asm-generic/io.h | 4 ++++ mm/ioremap.c | 22 ++++++++++++++++------ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/include/asm-generic/io.h b/include/asm-generic/io.h index 587e7e9b9a37..a7ca2099ba19 100644 --- a/include/asm-generic/io.h +++ b/include/asm-generic/io.h @@ -1073,9 +1073,13 @@ static inline bool iounmap_allowed(void *addr) } #endif +void __iomem *generic_ioremap_prot(phys_addr_t phys_addr, size_t size, + pgprot_t prot); + void __iomem *ioremap_prot(phys_addr_t phys_addr, size_t size, unsigned long prot); void iounmap(volatile void __iomem *addr); +void generic_iounmap(volatile void __iomem *addr); static inline void __iomem *ioremap(phys_addr_t addr, size_t size) { diff --git a/mm/ioremap.c b/mm/ioremap.c index 8652426282cc..db6234b9db59 100644 --- a/mm/ioremap.c +++ b/mm/ioremap.c @@ -11,8 +11,8 @@ #include #include -void __iomem *ioremap_prot(phys_addr_t phys_addr, size_t size, - unsigned long prot) +void __iomem *generic_ioremap_prot(phys_addr_t phys_addr, size_t size, + pgprot_t prot) { unsigned long offset, vaddr; phys_addr_t last_addr; @@ -28,7 +28,7 @@ void __iomem *ioremap_prot(phys_addr_t phys_addr, size_t size, phys_addr -= offset; size = PAGE_ALIGN(size + offset); - if (!ioremap_allowed(phys_addr, size, prot)) + if (!ioremap_allowed(phys_addr, size, pgprot_val(prot))) return NULL; area = get_vm_area_caller(size, VM_IOREMAP, @@ -38,17 +38,22 @@ void __iomem *ioremap_prot(phys_addr_t phys_addr, size_t size, vaddr = (unsigned long)area->addr; area->phys_addr = phys_addr; - if (ioremap_page_range(vaddr, vaddr + size, phys_addr, - __pgprot(prot))) { + if (ioremap_page_range(vaddr, vaddr + size, phys_addr, prot)) { free_vm_area(area); return NULL; } return (void __iomem *)(vaddr + offset); } + +void __iomem *ioremap_prot(phys_addr_t phys_addr, size_t size, + unsigned long prot) +{ + return generic_ioremap_prot(phys_addr, size, __pgprot(prot)); +} EXPORT_SYMBOL(ioremap_prot); -void iounmap(volatile void __iomem *addr) +void generic_iounmap(volatile void __iomem *addr) { void *vaddr = (void *)((unsigned long)addr & PAGE_MASK); @@ -58,4 +63,9 @@ void iounmap(volatile void __iomem *addr) if (is_vmalloc_addr(vaddr)) vunmap(vaddr); } + +void iounmap(volatile void __iomem *addr) +{ + generic_iounmap(addr); +} EXPORT_SYMBOL(iounmap); From patchwork Thu Jul 6 15:45:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13303963 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 91B75EB64DC for ; Thu, 6 Jul 2023 15:46:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 316E66B0080; Thu, 6 Jul 2023 11:46:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2C7326B0081; Thu, 6 Jul 2023 11:46:27 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 18EEF8D0001; Thu, 6 Jul 2023 11:46:27 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 07D276B0080 for ; Thu, 6 Jul 2023 11:46:27 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id CC344A0227 for ; Thu, 6 Jul 2023 15:46:26 +0000 (UTC) X-FDA: 80981613972.04.FB39815 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf23.hostedemail.com (Postfix) with ESMTP id 9199514000F for ; Thu, 6 Jul 2023 15:46:24 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="id4xF/bh"; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf23.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1688658384; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=7Tl0uNK3iTFKABiIz7zb0nAC1GuwS9Iddx7rewdSaxU=; b=Cf9XLhSD6pRl4LoYuU+H04b9NYlZw5TYUEl0NIRXRq7GWm5e/7j8SWNBJwlboe6gVzFyTw Cu2OSQL88d5DTjIywrGFer4tM6q6ockwQHLBVwj9a/lCuSrAQXwuKVf7Z/UGpyjH0QuaUP JMa9bh/NnFF2TXCMG5y7uomTqo0hhzc= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="id4xF/bh"; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf23.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1688658384; a=rsa-sha256; cv=none; b=YUw3Y8Zb897wVHZvDvrfJIR3H9BIFkgqfHj2yh2k2hRtdTD5RcFm5gCSNoNK7L9qZnAIn9 OXIAAZJxkepUhDupAuyktno37cqjWm2jX92m/JLAwSECA0Rn5fa5UQfymFLvoDuM676aVc OcySuifK4mYMCpV4jC2615cKaAAXz4g= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1688658383; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7Tl0uNK3iTFKABiIz7zb0nAC1GuwS9Iddx7rewdSaxU=; b=id4xF/bh78XW3hiVTW+ySmOG21s1S1ll5bzzzmhDt6kRywg4o1jWGat+aU6SRFgUz0AgO5 XhK++3a1WVVForMncN9YTBmocpTaM8h3ImxWRToH3XQfFNcYNYi+7fKbhnI3tbdo5DTop7 vqUW3PhrZTgEtEzAJ1wBovS1JUBT/XU= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-113-ySB3notAN_2JJ180Qz1p8g-1; Thu, 06 Jul 2023 11:46:19 -0400 X-MC-Unique: ySB3notAN_2JJ180Qz1p8g-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7F2CF858F1E; Thu, 6 Jul 2023 15:46:18 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-39.pek2.redhat.com [10.72.12.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id BE6B8F5CF0; Thu, 6 Jul 2023 15:46:09 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: akpm@linux-foundation.org, linux-mm@kvack.org, arnd@arndb.de, hch@lst.de, christophe.leroy@csgroup.eu, rppt@kernel.org, willy@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, shorne@gmail.com, David.Laight@ACULAB.COM, deller@gmx.de, nathan@kernel.org, glaubitz@physik.fu-berlin.de, Baoquan He , linux-arch@vger.kernel.org Subject: [PATCH v8 05/19] mm: ioremap: allow ARCH to have its own ioremap method definition Date: Thu, 6 Jul 2023 23:45:06 +0800 Message-Id: <20230706154520.11257-6-bhe@redhat.com> In-Reply-To: <20230706154520.11257-1-bhe@redhat.com> References: <20230706154520.11257-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Rspamd-Queue-Id: 9199514000F X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: kyaggxixr13seg5dkffr377ay54fyqiy X-HE-Tag: 1688658384-374848 X-HE-Meta: U2FsdGVkX182fb1SSMF6KfDNDUIr+0zsWuSTsiHcOr65ZhRwGiGS0z/e6KkGDo9FLvuLRX0IjpQUKyundqP9XOnlPLhCb6iEoKOZLXu0bE0e3gnftcDImy6aJsT47fwQS2dCfDZAlTnV9w6Uh2pSwdUl+PKQSgvfsQo5JHwB20JO2g0+seEHY3tO+nCIaKklBZXzeSbUzChLm3e8Gb1fJkA7c06RaqoxmQcyuVFLsrgm7qjVKWbuUZx5elAJrZfejHUpsK/rIAmbauUeiLj06jLNWuLFkNNOZd1g2I4az6ZM8bxcq+PykxA7PSs8tRBz6BTS6zPdDO3YLaZQB2QmP1K4GUyjD3YaICeCPkhk8DLblS7jexgbab49T4mm4jHTtgprnxUid0tiS72h5JBkexOXBnK6mCLmRN6sLyXkssMJAcK496BZuoceOt+Hb/RMTwgfeBl7mywZQAyXP5CGvIXVgvhD5vl/0u2548X7zW8NnVD+NJZSIqrFrbfkyTna4bhsmKZG22HLsdSYxtztD1gdBp5BMTcURtiHM9TFyjpkibZBq9BU5TdyGoJBoiZnD0TZz+GI9K+WXUpl0c5eajINicj6/MsKqyZZtg3catDaDLY3yhhzoYVMUDuFFt3UcgmHXMDgBJapXXVdk4dO9EX2NJD3bZpTKFacpiQyDsmMChdYZgbbUaoEWLX+11EPY006s6dVfCyeTSw95KMKA1FlR4v8/VlwLE4SOWsqf9yv9Mmwd/qF26R6JvNr1JrF0kbLDku7WhpCi65zaQ1xsx6OR22ajGCdEltBRYxDOZaTuOLDaCsMwCfEtER2VajXWKG9mAYGNJK/JWWJgpTRLVuib7/AiT5oxkGFbrJnaWa6rjW27LrDRI0kq/nq4KsC9u27+AGeWNVReLmXII50IF7+6M+k+SWjx89NBnA9FjZpXG8Cj/uDzeo0juIN5oEorFdHkBzeI1+MFZ2lysu XyVZ+6OC xeRW1ZP4lt8KOyesU9n8CPi0wE9vWVRtv2gF9hRN0QtDkts0j7ycjRA9Q7Buwpi+xKa4waNM3yp1GQtojkqwirwpGsB75AQODJ8uKIp8tp63dsinhbdR2AG9pwAM1nYleAJg9yvhvO1+Sv2J8H02MxMVt4Uai2YzYhYLM6MD4fTZfgtm0jNErvt/AVEZZAvhfbqUo7ary+1BO4/RBu5dZ+8PBSnCpXwdNYYlaGlmB6Vl9J4OUj2jKrXz8c1CjD4NrOAF+ X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Architectures can be converted to GENERIC_IOREMAP, to take standard ioremap_xxx() and iounmap() way. But some ARCH-es could have specific handling for ioremap_prot(), ioremap() and iounmap(), than standard methods. In oder to convert these ARCH-es to take GENERIC_IOREMAP method, allow these architecutres to have their own ioremap_prot(), ioremap() and iounmap() definitions. Signed-off-by: Baoquan He Acked-by: Arnd Bergmann Reviewed-by: Christoph Hellwig Reviewed-by: Kefeng Wang Reviewed-by: Mike Rapoport (IBM) Cc: linux-arch@vger.kernel.org --- include/asm-generic/io.h | 3 +++ mm/ioremap.c | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/include/asm-generic/io.h b/include/asm-generic/io.h index a7ca2099ba19..39244c3ee797 100644 --- a/include/asm-generic/io.h +++ b/include/asm-generic/io.h @@ -1081,11 +1081,14 @@ void __iomem *ioremap_prot(phys_addr_t phys_addr, size_t size, void iounmap(volatile void __iomem *addr); void generic_iounmap(volatile void __iomem *addr); +#ifndef ioremap +#define ioremap ioremap static inline void __iomem *ioremap(phys_addr_t addr, size_t size) { /* _PAGE_IOREMAP needs to be supplied by the architecture */ return ioremap_prot(addr, size, _PAGE_IOREMAP); } +#endif #endif /* !CONFIG_MMU || CONFIG_GENERIC_IOREMAP */ #ifndef ioremap_wc diff --git a/mm/ioremap.c b/mm/ioremap.c index db6234b9db59..9f34a8f90b58 100644 --- a/mm/ioremap.c +++ b/mm/ioremap.c @@ -46,12 +46,14 @@ void __iomem *generic_ioremap_prot(phys_addr_t phys_addr, size_t size, return (void __iomem *)(vaddr + offset); } +#ifndef ioremap_prot void __iomem *ioremap_prot(phys_addr_t phys_addr, size_t size, unsigned long prot) { return generic_ioremap_prot(phys_addr, size, __pgprot(prot)); } EXPORT_SYMBOL(ioremap_prot); +#endif void generic_iounmap(volatile void __iomem *addr) { @@ -64,8 +66,10 @@ void generic_iounmap(volatile void __iomem *addr) vunmap(vaddr); } +#ifndef iounmap void iounmap(volatile void __iomem *addr) { generic_iounmap(addr); } EXPORT_SYMBOL(iounmap); +#endif From patchwork Thu Jul 6 15:45:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13303964 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0B852EB64DC for ; Thu, 6 Jul 2023 15:46:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9A68A6B0081; Thu, 6 Jul 2023 11:46:34 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 956B78D0001; Thu, 6 Jul 2023 11:46:34 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 81F9A6B0083; Thu, 6 Jul 2023 11:46:34 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 6FA306B0081 for ; Thu, 6 Jul 2023 11:46:34 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 1FECAA0666 for ; Thu, 6 Jul 2023 15:46:34 +0000 (UTC) X-FDA: 80981614308.24.6B6E410 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf26.hostedemail.com (Postfix) with ESMTP id 3013514002C for ; Thu, 6 Jul 2023 15:46:31 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=ENREJSos; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf26.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1688658392; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=w2IfnXMZqwx1Jn18is50whUi5yxeZ3Kn4EXboxrstks=; b=hqUS53NT8IZinL4ROVvrKIzQwht9Sg4I2LAvJRxHqOsEcMjI+MshPYDfLhNe6q0fC/tAXt StrPR/ll15yClYGsBXkh9A4ZjCh2gRk/kh72hKfsXkKR0Csueho5sT1rVqFLGxJRB16abR Hvx02Qp1w2CRU05vrLwCSJc+Cwoo9hA= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=ENREJSos; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf26.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1688658392; a=rsa-sha256; cv=none; b=viT1/1+IVPsbQx9mYx2P0OCuK5wPfQ9JOiui6L/zmOMuu747t3gaQcqolt2wbkgdjzQkwQ 3ysLk8kSTEmDETBnHl7AvUrHDWv6vfmFitenYnlu5lSqeg5xUvLwJh2YuS7y04S3TU11jT iT78OyhaMKpOaLkxllqiAiBjBsP/VHQ= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1688658391; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=w2IfnXMZqwx1Jn18is50whUi5yxeZ3Kn4EXboxrstks=; b=ENREJSosXoQL59kmxBwlE3/L+OLhRqB0LEXmuxLM+EghDV65gds2IeygNqB0Ilk/79Q95V gj1ix/tRL6VnE2tXilLKOdAwGABdoJaZqKaTeNferB0IAsCLXKBWTGtyfdg8jqtijW9RlY eZ7g+ajhi6v8a9V1LzKbvks1Upw0Vck= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-49-RU_tALYvP5a7WTS2Ws1CNg-1; Thu, 06 Jul 2023 11:46:27 -0400 X-MC-Unique: RU_tALYvP5a7WTS2Ws1CNg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id DAE023815EF8; Thu, 6 Jul 2023 15:46:26 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-39.pek2.redhat.com [10.72.12.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id 47CFFF5CF0; Thu, 6 Jul 2023 15:46:18 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: akpm@linux-foundation.org, linux-mm@kvack.org, arnd@arndb.de, hch@lst.de, christophe.leroy@csgroup.eu, rppt@kernel.org, willy@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, shorne@gmail.com, David.Laight@ACULAB.COM, deller@gmx.de, nathan@kernel.org, glaubitz@physik.fu-berlin.de, Baoquan He Subject: [PATCH v8 06/19] mm/ioremap: add slab availability checking in ioremap_prot Date: Thu, 6 Jul 2023 23:45:07 +0800 Message-Id: <20230706154520.11257-7-bhe@redhat.com> In-Reply-To: <20230706154520.11257-1-bhe@redhat.com> References: <20230706154520.11257-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Rspamd-Queue-Id: 3013514002C X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: eefu3okctt8fsxgjxci6q7rc3wqhiwtz X-HE-Tag: 1688658391-622136 X-HE-Meta: U2FsdGVkX18J8eyD5SU1y42JgIn6xUYvtTyA7e9PLRJczs5JSn6u15MaUyQGLpwwt6zG71PQLkgfd0moBZwv/wYqRtuZqjb7xiS5dhtMGaEsujxcwRY0cw4Qj6sBL1yKHkoxQs6Za4iVCwxP2g0sLoKgdZhu30CllJvFhqQjymH71qKkMTkccM5OddBRKLHpR/VhIv1tNhHb8aNZP0IeRaVfWw9pfLDu2gOrnowQGYgbeYQKlrCAHxM4R//aPpXDLe9dCjE5cYGohTLVACguqBNnkGMSosG8ERaqfmT+uDFFF1iHoFinNzcV2zB9moRcFBbPAeqsocDoT/or6wm3m95o6v78oSt4kv5zwOz9119uJqYh0JA9nYxWtqWnsFTLAiT+GSQZFvbOERWuyUUni/Yn6ojddx/zmUrC2z7nOSQDx96GcOSwLEKDuNASI3/IrNVM9PeF8LgE+IostYzxD/kdobOVh4Nfs4mEUIMFkLXznDH7QTA/MucimxhOzQ7VkF03UD2njpWFMlXQQDnd6toPO3lKl41/5sM7UxDtWdhL6zSJcpn+0OM28MzNRgXuBZD7hcu3gaD7QaG8FucSqhNiJ3rSNemk7qKA6DVEVc8wPixbTtw4YkizIkaYXlhiDvscsdqmdQijF4CrCxjcFxTjf1bR2I/3BtLWOJMUh4+CAU7jTA4XUqWQZeS6D8HAS96hL/rLJuHpd3VxcIq+GLK1nH6fMARmIs6iX4Ge9KjHeliKQytjkr98bRyE1g6zwCPQUNnbc4ZnczP3K7buci81aMtNbSRi7+dktmC0a9QimcehCfw9h931p+3TIzBBDXKukPJnmpGS0xYq2fxCABnRnBzKjSzFOvgZMrssE+Bd3uD8vAGX1bKrqXoH/uCUpL8sXeJYr5DopI6Azpl45ElOsjwCEgBzilcBzzoLFIo1lfslshKhg7HgliddKbb9LUrDUciSoNqFDlqo/Dg piXw/Ebz cmjoG7hCpxmAApBxYWVKzxAFvEy9F1bjuFEzvlXuKp6kb+qB/mSXgVue7e8nUwklX9+Yb8NoDVypVJAugy+UEpLXWumYi+L5kY1XqFHxDwVf6pdctlhfVsJaEu28y9r+hj6/TIAtIaUi2CxP8NRBAexVN3k3r9IUH3zcGIujfNoqkt40XGgB2ElM3uvDZTaomlawZs0BvUOUFsy8vKAwoGHnA+w0zHRJhkG0OQcpVWi50D6yYuHe/BhnRqfGySC5zP1m4nCVmnnQ1HUbKH23j1Wij7rDK0/a/Psri6CLzwB7AUYCxqXGZO8gp6UrMqde4ZdQgE3iLt9KngAAeD8vF+Ea/8Le4bH6YvkxIYW5VZBF8GwE= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Several architectures has done checking if slab if available in ioremap_prot(). In fact it should be done in generic ioremap_prot() since on any architecutre, slab allocator must be available before get_vm_area_caller() and vunmap() are used. Add the checking into generic_ioremap_prot(). Suggested-by: Christophe Leroy Signed-off-by: Baoquan He Reviewed-by: Christoph Hellwig Reviewed-by: Kefeng Wang Reviewed-by: Mike Rapoport (IBM) --- mm/ioremap.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mm/ioremap.c b/mm/ioremap.c index 9f34a8f90b58..86b82ec27d2b 100644 --- a/mm/ioremap.c +++ b/mm/ioremap.c @@ -18,6 +18,10 @@ void __iomem *generic_ioremap_prot(phys_addr_t phys_addr, size_t size, phys_addr_t last_addr; struct vm_struct *area; + /* An early platform driver might end up here */ + if (WARN_ON_ONCE(!slab_is_available())) + return NULL; + /* Disallow wrap-around or zero size */ last_addr = phys_addr + size - 1; if (!size || last_addr < phys_addr) From patchwork Thu Jul 6 15:45:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13303965 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id B87EBEB64DC for ; Thu, 6 Jul 2023 15:46:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 560826B0080; Thu, 6 Jul 2023 11:46:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 510516B0082; Thu, 6 Jul 2023 11:46:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3D8886B0083; Thu, 6 Jul 2023 11:46:50 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 2F61C6B0080 for ; Thu, 6 Jul 2023 11:46:50 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id E3ACB1A0504 for ; Thu, 6 Jul 2023 15:46:49 +0000 (UTC) X-FDA: 80981614938.08.239A76C Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf02.hostedemail.com (Postfix) with ESMTP id B18AE80044 for ; Thu, 6 Jul 2023 15:46:43 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=JTy9Flo8; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf02.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1688658403; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=lPVj8rhXKvQORbztn0NrK5wvOXfvzxv4+nZiwBKh1i0=; b=FYD134Xq9QNnOyirtbMmGeI2Xu0hg6yTzJeCQewvzR1PUgXIeX3ONFapIq80tngTgU5Idw Yb6h/E8eOLY5JnjekLDbGqxI43f8NOXRBCtBGpcJgQUUvmTJdkryfic64Om/0KWMI4Ufqw mu1IHh82WGktIy6bzvczM25RYBKnQw0= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=JTy9Flo8; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf02.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1688658403; a=rsa-sha256; cv=none; b=kfHEj/7EhTZF0MZCdLZpZnnnh4CcwFli4goJjXXQWi7Q6eYMiHH0yRrPcMK6HptGyr2yVh /6iS352eBzZYnVAbGH9hh+oYbfaVcSZUm3xCVPotmFyZcb/D5SevW4MKQKOD4s4ahL1aJ9 UMnq/eQii75GPGLihoMCU+0qYNs02lQ= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1688658402; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lPVj8rhXKvQORbztn0NrK5wvOXfvzxv4+nZiwBKh1i0=; b=JTy9Flo8Wi5R4oq/hMbGSJz3UezJ8svbV+TmFmDC+4DCekPNUSSVNnjCt5PW7Qg6DiWC1p /wfxjbYuaCtmZo4vy+kwQqsXkqBIH7uSLKdR9lqy1pw4xGu4J6UTnqr3plaiUypYLw8Oh/ nAQ1BxbPFXV9XjfaZlaqN9j167xRhtk= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-164-CpM4hTDcNbKu62ox369UOA-1; Thu, 06 Jul 2023 11:46:38 -0400 X-MC-Unique: CpM4hTDcNbKu62ox369UOA-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 38F081C06ECD; Thu, 6 Jul 2023 15:46:37 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-39.pek2.redhat.com [10.72.12.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id AEA98F5CF0; Thu, 6 Jul 2023 15:46:27 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: akpm@linux-foundation.org, linux-mm@kvack.org, arnd@arndb.de, hch@lst.de, christophe.leroy@csgroup.eu, rppt@kernel.org, willy@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, shorne@gmail.com, David.Laight@ACULAB.COM, deller@gmx.de, nathan@kernel.org, glaubitz@physik.fu-berlin.de, Baoquan He , Vineet Gupta , linux-snps-arc@lists.infradead.org Subject: [PATCH v8 07/19] arc: mm: Convert to GENERIC_IOREMAP Date: Thu, 6 Jul 2023 23:45:08 +0800 Message-Id: <20230706154520.11257-8-bhe@redhat.com> In-Reply-To: <20230706154520.11257-1-bhe@redhat.com> References: <20230706154520.11257-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Rspamd-Queue-Id: B18AE80044 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: d9ze38bes96qx4h88jjjie567f4bkzde X-HE-Tag: 1688658403-500704 X-HE-Meta: U2FsdGVkX1+xmxEl+MlgFI3kVxaQirK0af4BaWw9464ki/Y0kwOnqIJ0A2ZNl5d9qy1bg22cWOrQZd37Q1sE2nNyWPHeoXwmctw1zQvDjz4F87Rck/ul9iHYSoPYhWv9crob3JZD/nB/uCtkml00fFjNcXuqEbzbpA5JA2rfl0BO/IHC+kFCfCUf5szSsHFCJtgskutcoEx7w12NIBlBAbqBpQsefmi9K1eg+7veCPzOrwuJ+dydMNqxRyqeeyciDsEhCbgROZGLQqY2vxgG/3lad7RpuSVIMwiiuOW/E1DYWtw7PrdA7xfGjudjPTtJs0zz/sxsaKeYpmbChL3mzuhNiSsrnxzVWkrh8igfXuLNPvoiqJUpQUyGT2sYTtMLrpfJgIM+IF6h/zode4Y3ZvygusAXUJpmTbdqqCLUIGRYMfpHOb8JHFZX71HhqcmF8BzKxv0UzsGHYfW0xyaYkAv1Jxgj3RFRcxMCJl6D76qPAhGBIP6TEq0L+S1n3KaBBfNXYrZLxQuGsdlHPpKagUBjZFth5Uqn4+VlXVRxWIyf8qhMh0+/qkxEoHbwNWN+QOcJy6BdXFl+ZyRHHRCc0RCegJAU6ZTzTz2b8Dic6A07h0lTPEDzr6wBJqEz5y11C4CO4VjQaf+uFDnkUORHKNWoAGZSjnyb3w1XzW6Bge8fvR6jmoDhrJaVCi+B+Cp7bphi8SAQJg1pMW0SPMAlkUehx20xHWvZ57k7KNn0E1a8CHek31AxwjfPd4D3emMeg7P7GjERBi96EyseRCf0j98VIq3qoVRsdbiYhu60HXrcu4rkT2FzPX7Cne3XqR6mmNBfNTE8iSKfKqUJpZO1rHj3C2jhuB2zV7bfolFGm10Fmasls1D2ut1Jnqt02gqGXYz9GsEsAo73jfnChq5GtDWNTJXs1JIxwM/WPNnI3JuDZXt7AixyBAaBkH1qbkJYyApBmv6f4IMypinnkfD cs2QNiMb rSMJAbDOXmgGOd0cJUVnWDJzgLElI6KBKuaFtSKujVrFKPnT+u5YvsBqlrqxqMdZalVYNQLc7SFkad+iFbJ3Be4nXTVsP1VKeOiz6ESv8YodDquwSMUCyZmmhvGsngoA4RHwgpo7ZlzxQdxMopp957lgJQ5xVMS4LBWqMeV6UfX14g6zdZ4UWwkkICKIpMOqdKej0d3UwfPOov/I6cZIL0O8HHrQfQBjYQ/g+TMrPc1MbFvqb11hX8a9X7tnVpvJDDKcC5S8CuznJksRhA98pMpJbapeH+xDMFO1qWYiBPC5ZBo2LB5F6te+ng1AgRReJl/3qGhs3vg8WfB0ovMQKKcJnWg== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: By taking GENERIC_IOREMAP method, the generic generic_ioremap_prot(), generic_iounmap(), and their generic wrapper ioremap_prot(), ioremap() and iounmap() are all visible and available to arch. Arch needs to provide wrapper functions to override the generic versions if there's arch specific handling in its ioremap_prot(), ioremap() or iounmap(). This change will simplify implementation by removing duplicated code with generic_ioremap_prot() and generic_iounmap(), and has the equivalent functioality as before. Here, add wrapper functions ioremap_prot() and iounmap() for arc's special operation when ioremap_prot() and iounmap(). Signed-off-by: Baoquan He Reviewed-by: Christoph Hellwig Reviewed-by: Mike Rapoport (IBM) Cc: Vineet Gupta Cc: linux-snps-arc@lists.infradead.org --- arch/arc/Kconfig | 1 + arch/arc/include/asm/io.h | 7 +++--- arch/arc/mm/ioremap.c | 49 ++++----------------------------------- 3 files changed, 8 insertions(+), 49 deletions(-) diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig index 96cf8720bb93..6f4995ad9873 100644 --- a/arch/arc/Kconfig +++ b/arch/arc/Kconfig @@ -26,6 +26,7 @@ config ARC select GENERIC_PENDING_IRQ if SMP select GENERIC_SCHED_CLOCK select GENERIC_SMP_IDLE_THREAD + select GENERIC_IOREMAP select HAVE_ARCH_KGDB select HAVE_ARCH_TRACEHOOK select HAVE_ARCH_TRANSPARENT_HUGEPAGE if ARC_MMU_V4 diff --git a/arch/arc/include/asm/io.h b/arch/arc/include/asm/io.h index 80347382a380..4fdb7350636c 100644 --- a/arch/arc/include/asm/io.h +++ b/arch/arc/include/asm/io.h @@ -21,8 +21,9 @@ #endif extern void __iomem *ioremap(phys_addr_t paddr, unsigned long size); -extern void __iomem *ioremap_prot(phys_addr_t paddr, unsigned long size, - unsigned long flags); +#define ioremap ioremap +#define ioremap_prot ioremap_prot +#define iounmap iounmap static inline void __iomem *ioport_map(unsigned long port, unsigned int nr) { return (void __iomem *)port; @@ -32,8 +33,6 @@ static inline void ioport_unmap(void __iomem *addr) { } -extern void iounmap(const volatile void __iomem *addr); - /* * io{read,write}{16,32}be() macros */ diff --git a/arch/arc/mm/ioremap.c b/arch/arc/mm/ioremap.c index 712c2311daef..b07004d53267 100644 --- a/arch/arc/mm/ioremap.c +++ b/arch/arc/mm/ioremap.c @@ -8,7 +8,6 @@ #include #include #include -#include #include static inline bool arc_uncached_addr_space(phys_addr_t paddr) @@ -25,13 +24,6 @@ static inline bool arc_uncached_addr_space(phys_addr_t paddr) void __iomem *ioremap(phys_addr_t paddr, unsigned long size) { - phys_addr_t end; - - /* Don't allow wraparound or zero size */ - end = paddr + size - 1; - if (!size || (end < paddr)) - return NULL; - /* * If the region is h/w uncached, MMU mapping can be elided as optim * The cast to u32 is fine as this region can only be inside 4GB @@ -51,55 +43,22 @@ EXPORT_SYMBOL(ioremap); * ARC hardware uncached region, this one still goes thru the MMU as caller * might need finer access control (R/W/X) */ -void __iomem *ioremap_prot(phys_addr_t paddr, unsigned long size, +void __iomem *ioremap_prot(phys_addr_t paddr, size_t size, unsigned long flags) { - unsigned int off; - unsigned long vaddr; - struct vm_struct *area; - phys_addr_t end; pgprot_t prot = __pgprot(flags); - /* Don't allow wraparound, zero size */ - end = paddr + size - 1; - if ((!size) || (end < paddr)) - return NULL; - - /* An early platform driver might end up here */ - if (!slab_is_available()) - return NULL; - /* force uncached */ - prot = pgprot_noncached(prot); - - /* Mappings have to be page-aligned */ - off = paddr & ~PAGE_MASK; - paddr &= PAGE_MASK_PHYS; - size = PAGE_ALIGN(end + 1) - paddr; - - /* - * Ok, go for it.. - */ - area = get_vm_area(size, VM_IOREMAP); - if (!area) - return NULL; - area->phys_addr = paddr; - vaddr = (unsigned long)area->addr; - if (ioremap_page_range(vaddr, vaddr + size, paddr, prot)) { - vunmap((void __force *)vaddr); - return NULL; - } - return (void __iomem *)(off + (char __iomem *)vaddr); + return generic_ioremap_prot(paddr, size, pgprot_noncached(prot)); } EXPORT_SYMBOL(ioremap_prot); - -void iounmap(const volatile void __iomem *addr) +void iounmap(volatile void __iomem *addr) { /* weird double cast to handle phys_addr_t > 32 bits */ if (arc_uncached_addr_space((phys_addr_t)(u32)addr)) return; - vfree((void *)(PAGE_MASK & (unsigned long __force)addr)); + generic_iounmap(addr); } EXPORT_SYMBOL(iounmap); From patchwork Thu Jul 6 15:45:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13303966 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 05A13EB64D9 for ; Thu, 6 Jul 2023 15:46:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9CD5F6B0081; Thu, 6 Jul 2023 11:46:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 97D9B6B0082; Thu, 6 Jul 2023 11:46:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 845728D0001; Thu, 6 Jul 2023 11:46:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 732CF6B0081 for ; Thu, 6 Jul 2023 11:46:55 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 2E0EB1206FB for ; Thu, 6 Jul 2023 15:46:55 +0000 (UTC) X-FDA: 80981615190.04.A2EF9F3 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf28.hostedemail.com (Postfix) with ESMTP id BD3D5C0012 for ; Thu, 6 Jul 2023 15:46:52 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="Ff/sHDBj"; spf=pass (imf28.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1688658412; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=HouZTQm+V70h+gsiEupRVBEwB3PeE/r1+sDrBkNv3ls=; b=bc755zchkO5SXIllwzkXX1Bja60u1ob/GlydVcplMLNDv0m0wZ0vkXbPE//deXZifoLXwd nOr7G/RCvohhuVj2v5Qsjil39b6I9UqatD2aSzB+0f4YonDmh12Ks5xTUYDonLcNdiK8qG WukMHx/nvvRz949OgGmKfknRnt47ba4= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1688658412; a=rsa-sha256; cv=none; b=j5H+7qgsVrxz5SAuMRWw6wLkEz4OJ0hKWsOed3W1Yprh1rlgDis/VAl+JpCWhof9AXHX3o 4XoEE3R6vojA8UvgPvNGDD5+yJmK3pPXWKo2yqwoVclELeQ0ChT8viKx44yaURqhDfy5g0 wbwKKgGD9RV3GNk+tUTZyVYQsleZdX8= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="Ff/sHDBj"; spf=pass (imf28.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1688658412; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HouZTQm+V70h+gsiEupRVBEwB3PeE/r1+sDrBkNv3ls=; b=Ff/sHDBjtmKM+P+ehogh/LvQTk8F4RlduGAtjH5Uy269oXHvFmnCBxQsqr2ttMJYKIUn+u ZAh7bxCzfNOiD+5IxU8muHlk0N6yhLpFVtt6ByF9wPsfgSin7Qo5hWnXtVgqnRgrez+ATX Ah0IxDXswV6KyDT2X/FpP753JaUGM5E= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-199-zStYdrw0PYmzXl3bYNKOLg-1; Thu, 06 Jul 2023 11:46:47 -0400 X-MC-Unique: zStYdrw0PYmzXl3bYNKOLg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id EFD23185A794; Thu, 6 Jul 2023 15:46:46 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-39.pek2.redhat.com [10.72.12.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0F6DCF6431; Thu, 6 Jul 2023 15:46:37 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: akpm@linux-foundation.org, linux-mm@kvack.org, arnd@arndb.de, hch@lst.de, christophe.leroy@csgroup.eu, rppt@kernel.org, willy@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, shorne@gmail.com, David.Laight@ACULAB.COM, deller@gmx.de, nathan@kernel.org, glaubitz@physik.fu-berlin.de, Baoquan He , linux-ia64@vger.kernel.org Subject: [PATCH v8 08/19] ia64: mm: Convert to GENERIC_IOREMAP Date: Thu, 6 Jul 2023 23:45:09 +0800 Message-Id: <20230706154520.11257-9-bhe@redhat.com> In-Reply-To: <20230706154520.11257-1-bhe@redhat.com> References: <20230706154520.11257-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Rspamd-Queue-Id: BD3D5C0012 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: mre9nzgqy6qg9j6s8ecacfcj5renjjq6 X-HE-Tag: 1688658412-676630 X-HE-Meta: U2FsdGVkX1/jB+t50w32qEQItL2NHrg98tQaPVS1ty2lJJ4aoSq04LL66ofmssqjdtDNiW1Kh0TuTY8q3sguBKqaR4nUJft5UOJJIIOlD0QN+gXSN5zkVaaCZoGJHbqe849eonzfUS7JEbi5tkABAkU/HH+rfzg78MmiW7x7DLeAot5KEQzD2koXneNPzitt7Nua3EleZ+w2c6saDX9lKeEguw40PWTaopMvhGLwgOXctJ/i6dGkGfEMrqlz3jz7JCWiq5HocWhybASe7aLt8twH8fHGg18K1HacpuQxjUr4jiFGql6+YAeIt79dF5pw+ydrA+uRkNOUsAWG0wpgS2A6NQ8b9Y2XOaruZxkch6yvJ+sgBTXQWYzbrZvfiCZICTy5a6ilyBdk5FAtb3vtP1wOXjsYYTynS0rX22ibkjpTuDMq13l6hkdKMLDDDbw/HQfRUhmlUOqpfbx4mpllUjQHiwk7nWkatSrcp/QdAUxquXcIEpY8J6tgE8D6nWSWvLJrD/O6zXIINyvBtARCDk2cPiPMMZzbpmSsOSaZLCq7flyOpzDUX/8N+2Z58fg9ffIOwWAavzFtVYb2ph7YktfAH2gI1T5VXSA9l7AUYk1wP7Aac0nKQkiSFe15BmXs0kecKns72DNh1+nHaWJCwshbefRH0tctaKnGAcukzn83dxY/KZdsZsipDPOQjR/9bdDql3myEI7fMpjS5Q5C/RrHdfp9B8WDpx/UNtum0u20G4BEnyb5Eu4uf9z8M8wwU4djJ4nF9wTuUceuPg+jwX0mH4MMx8si2WK5wmh9Nd2eO9G1NT8SfyRQdAPVSCJc536cGfNmDFhKBUEBMlprTKqqrMqDXc1HVNhws4mBMtXUQxW1Kjor6EXU0wweQ/WGt3XlYBTifNjNhUdw+jPNFNLE3pV+ecVO/bpVVA97xH1XZCck/HIsOA9+EfvgW6PqBfkwFQOC7814bcEvJ1j H9GLKSiF UmnUefLMJO6KTqqG5i0olFyGntoXI5FVlsV1MwZeUIeZXrMbunVz65cixMRriMgfmfvpqtkGw3vg6RHCRrhghKVptQXAuUlqfIbKlFTmmY8kYpUNVN1WEK+LDnazpfR9E0D1ixTw/Q4Lo6JUVWBqWP1HOoK/7eRNOaz1dYYthBcGjF7z0kDdDgxewlKEuPWbYaHzUCnjCq01UejmZtH1MIy7iGj1xo7owG/6nHFJcORwe27oQnwFKiwcu/Umf1FjnE2z7s6fLawhb+ZGGB10rXaFHYQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: By taking GENERIC_IOREMAP method, the generic generic_ioremap_prot(), generic_iounmap(), and their generic wrapper ioremap_prot(), ioremap() and iounmap() are all visible and available to arch. Arch needs to provide wrapper functions to override the generic versions if there's arch specific handling in its ioremap_prot(), ioremap() or iounmap(). This change will simplify implementation by removing duplicated code with generic_ioremap_prot() and generic_iounmap(), and has the equivalent functioality as before. Here, add wrapper functions ioremap_prot() and iounmap() for ia64's special operation when ioremap() and iounmap(). Signed-off-by: Baoquan He Reviewed-by: Christoph Hellwig Reviewed-by: Mike Rapoport (IBM) Cc: linux-ia64@vger.kernel.org --- arch/ia64/Kconfig | 1 + arch/ia64/include/asm/io.h | 13 +++++------- arch/ia64/mm/ioremap.c | 41 ++++++-------------------------------- 3 files changed, 12 insertions(+), 43 deletions(-) diff --git a/arch/ia64/Kconfig b/arch/ia64/Kconfig index 2cd93e6bf0fe..3ab75f36c037 100644 --- a/arch/ia64/Kconfig +++ b/arch/ia64/Kconfig @@ -47,6 +47,7 @@ config IA64 select GENERIC_IRQ_LEGACY select ARCH_HAVE_NMI_SAFE_CMPXCHG select GENERIC_IOMAP + select GENERIC_IOREMAP select GENERIC_SMP_IDLE_THREAD select ARCH_TASK_STRUCT_ON_STACK select ARCH_TASK_STRUCT_ALLOCATOR diff --git a/arch/ia64/include/asm/io.h b/arch/ia64/include/asm/io.h index 83a492c8d298..eedc0afa8cad 100644 --- a/arch/ia64/include/asm/io.h +++ b/arch/ia64/include/asm/io.h @@ -243,15 +243,12 @@ static inline void outsl(unsigned long port, const void *src, # ifdef __KERNEL__ -extern void __iomem * ioremap(unsigned long offset, unsigned long size); +#define _PAGE_IOREMAP pgprot_val(PAGE_KERNEL) + extern void __iomem * ioremap_uc(unsigned long offset, unsigned long size); -extern void iounmap (volatile void __iomem *addr); -static inline void __iomem * ioremap_cache (unsigned long phys_addr, unsigned long size) -{ - return ioremap(phys_addr, size); -} -#define ioremap ioremap -#define ioremap_cache ioremap_cache + +#define ioremap_prot ioremap_prot +#define ioremap_cache ioremap #define ioremap_uc ioremap_uc #define iounmap iounmap diff --git a/arch/ia64/mm/ioremap.c b/arch/ia64/mm/ioremap.c index 92b81bc91397..711b6abc822e 100644 --- a/arch/ia64/mm/ioremap.c +++ b/arch/ia64/mm/ioremap.c @@ -29,13 +29,9 @@ early_ioremap (unsigned long phys_addr, unsigned long size) return __ioremap_uc(phys_addr); } -void __iomem * -ioremap (unsigned long phys_addr, unsigned long size) +void __iomem *ioremap_prot(phys_addr_t phys_addr, size_t size, + unsigned long flags) { - void __iomem *addr; - struct vm_struct *area; - unsigned long offset; - pgprot_t prot; u64 attr; unsigned long gran_base, gran_size; unsigned long page_base; @@ -68,36 +64,12 @@ ioremap (unsigned long phys_addr, unsigned long size) */ page_base = phys_addr & PAGE_MASK; size = PAGE_ALIGN(phys_addr + size) - page_base; - if (efi_mem_attribute(page_base, size) & EFI_MEMORY_WB) { - prot = PAGE_KERNEL; - - /* - * Mappings have to be page-aligned - */ - offset = phys_addr & ~PAGE_MASK; - phys_addr &= PAGE_MASK; - - /* - * Ok, go for it.. - */ - area = get_vm_area(size, VM_IOREMAP); - if (!area) - return NULL; - - area->phys_addr = phys_addr; - addr = (void __iomem *) area->addr; - if (ioremap_page_range((unsigned long) addr, - (unsigned long) addr + size, phys_addr, prot)) { - vunmap((void __force *) addr); - return NULL; - } - - return (void __iomem *) (offset + (char __iomem *)addr); - } + if (efi_mem_attribute(page_base, size) & EFI_MEMORY_WB) + return generic_ioremap_prot(phys_addr, size, __pgprot(flags)); return __ioremap_uc(phys_addr); } -EXPORT_SYMBOL(ioremap); +EXPORT_SYMBOL(ioremap_prot); void __iomem * ioremap_uc(unsigned long phys_addr, unsigned long size) @@ -114,8 +86,7 @@ early_iounmap (volatile void __iomem *addr, unsigned long size) { } -void -iounmap (volatile void __iomem *addr) +void iounmap(volatile void __iomem *addr) { if (REGION_NUMBER(addr) == RGN_GATE) vunmap((void *) ((unsigned long) addr & PAGE_MASK)); From patchwork Thu Jul 6 15:45:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13303967 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6D2E6EB64DC for ; Thu, 6 Jul 2023 15:47:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0CCB26B0082; Thu, 6 Jul 2023 11:47:07 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 07E1B8D0001; Thu, 6 Jul 2023 11:47:07 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E60116B0085; Thu, 6 Jul 2023 11:47:06 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id D60006B0082 for ; Thu, 6 Jul 2023 11:47:06 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 316B58058B for ; Thu, 6 Jul 2023 15:47:06 +0000 (UTC) X-FDA: 80981615652.20.A2F0AE2 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf02.hostedemail.com (Postfix) with ESMTP id 72FC88001C for ; Thu, 6 Jul 2023 15:47:03 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=IHnoBGuh; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf02.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1688658423; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=MfP/dV90ghXNs4nny37p+AmeMzpGP5gepSHR9mCOjb8=; b=sjJSVlThHFFJlw45i5eCsh4Dq6W8MSKEcc+CWRO+l9bEOisdg0LOcNvOM0/IGagTPEZ7sz L8KdmvcQ3OTHD85PZpJtCffBiIQIFIRbKp3VyqcYyX7zbdz1sYp/kp2qpJ9Yta1/kHMMVA BCaFCLYWGrk70qPuBnQfAyw8wii2M78= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=IHnoBGuh; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf02.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1688658423; a=rsa-sha256; cv=none; b=LL5ra9BY4aFRN6Xc+ob2KGmJdPHmyt38QP2qPRpvNyANyGsWtmmWK1fUU8PWlEyok+M4PR m8PKsqwkMkbrxBfoHhLOF3lTlhNuYqRvuPELkuWt9XtYNzn1ke4vPsuG5CgsygD1SnEwis XvkQs5I0gnEFUTCo2r6/JscL1xjiRT0= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1688658422; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=MfP/dV90ghXNs4nny37p+AmeMzpGP5gepSHR9mCOjb8=; b=IHnoBGuhg0CQk0aFf3GG0mjUFApGcsUuRuWoXLuWSdX6/XArF3iV5OoVh7j4YS12h/gGiS nvHYw2XkwDmbUSsEpOu4SKLgLlLXQTwJoKCKGoESH2hdjoNK5Kwid0oxuj6EiTcACipgZ8 jxxPljW2tyvBU2g9oolomLml1eww2Tk= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-266-Mw8JIk7-MdGKjVVBaMzICg-1; Thu, 06 Jul 2023 11:46:57 -0400 X-MC-Unique: Mw8JIk7-MdGKjVVBaMzICg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 757ED3815EF3; Thu, 6 Jul 2023 15:46:56 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-39.pek2.redhat.com [10.72.12.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id C0792F6403; Thu, 6 Jul 2023 15:46:47 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: akpm@linux-foundation.org, linux-mm@kvack.org, arnd@arndb.de, hch@lst.de, christophe.leroy@csgroup.eu, rppt@kernel.org, willy@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, shorne@gmail.com, David.Laight@ACULAB.COM, deller@gmx.de, nathan@kernel.org, glaubitz@physik.fu-berlin.de, Baoquan He , Jonas Bonn , Stefan Kristiansson , openrisc@lists.librecores.org Subject: [PATCH v8 09/19] openrisc: mm: Convert to GENERIC_IOREMAP Date: Thu, 6 Jul 2023 23:45:10 +0800 Message-Id: <20230706154520.11257-10-bhe@redhat.com> In-Reply-To: <20230706154520.11257-1-bhe@redhat.com> References: <20230706154520.11257-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Rspam-User: X-Stat-Signature: cacckeqefz3ffzqgifqimfqrfhtohugy X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 72FC88001C X-HE-Tag: 1688658423-240044 X-HE-Meta: U2FsdGVkX1+V9YCor6r7eThRp8tZSFjlvUGepA71npgRlIRrz0TdBjjfro+ZSBaHuyDCj4BRLTETDumEgZUlkudoFSMBcGUCD3A6Pkkzrx/JPKBHA5sEDeTWNIR9UCCoK/G0aSiaXZG9w2jODVglq2IyICkmFjsAn4rvY6+50OKd94ygj+oi1USRZtaOWmIlzJ0r2k0OYEE6yS1Ii9QlaWhQY22DN4lLezoD+352wp9Np5fekwGJpjA+gfQFTmM9QEdR9w9TOG/eMzxVhbIGmBKjWfDerWgJqsyxee+QU9GhtQHUOQumAypxO/rKGNEoJYwLRsmnLHf9MAXG2x2jbn+qavVnIl8YxZxft4l4wnFYPtK0D/9zIYMqifpQofWwiPSBHl1K1lyHHvyD6+OB+79X8BPd/HpM2tR/WAl3MRQovKeKKb+tsp1s4hklLx9UPzbBtASbWQwTgrWGgV7ZjDT1qNPmXB6wmS/1X1k/JoNSq4lKhfSPtBTPYsVhmwOZQyyqEF3vO66e1km5LLLB95opiFr5dDRKtY0P3kMTepzU79QTlGRPv4iwSR5iTG8n5OedwE/WXnxcjpiLFTy1ZcX+SEYJd0PYsUCn5U/JfAk35YwHAGSfdYCDBDfrVFGZPE9M4mIBQduF0Mo3PjGKN2tw+cbJFyEsrq8fd/fhH4MDmu/GZsmk9L0MOQHa+j9G5xDqWdT61zqUrlgxHaTiUOw1OU61S1Pk2kof+SyUuYR+2NVRd8fDeQ7ZheufQyCClaQm7T3LbzfZXlKBf27iH3FzWb5cfXTuH5QBayoT9FzSTHHJVWxWdvwv4lqpNSsaTzgCsQUymmmw7fiQ1mIXT86oh+3+RkoK1kNlucnCjjknQB1TWJQT1eDwvJB1uhij+Fz+EdhgSYJLLV3w17SG1OBH9Z72r9RYw32bT3DQg0uZIav9Snpmb3SUY3ezgaGqKOVcQU1L7BXFtVvwhhm /pYG6l0m eeQXSbNdsyPu7J8VfAkOKvFZVIiqxNebUOkj1WT2ZmxYCE8hSSyQZEGDrhQIArxcXKdtQ8Lc6/TEavEJsPA2qiMHXUj6n04us6ylT5qi5/wmBWoCKds88V/C89jDvjTpCVyfhBUewDBAVk63k3hURkY49krVXezITKQnrGeb9cJB24HOLLxPGT+gA+QCQHUGfHnJzu2p5lH1vikUzMX39O3AgcyST1GFZascLlX7RTFayUk55tHGsc5vn+Tv0N2Nxu2dcym1pyBX+TbNaoI1+xKi3jEaHFBKBIywukTRJBxgifiml1BJIC7rJxiwq7SDCylxR+6ZsT/SY6S5q9O18jD8va2LdBwCLzv8RdtdP5C/LKuQ= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: By taking GENERIC_IOREMAP method, the generic generic_ioremap_prot(), generic_iounmap(), and their generic wrapper ioremap_prot(), ioremap() and iounmap() are all visible and available to arch. Arch needs to provide wrapper functions to override the generic versions if there's arch specific handling in its ioremap_prot(), ioremap() or iounmap(). This change will simplify implementation by removing duplicated code with generic_ioremap_prot() and generic_iounmap(), and has the equivalent functioality as before. For openrisc, the current ioremap() and iounmap() are the same as generic version. After taking GENERIC_IOREMAP way, the old ioremap() and iounmap() can be completely removed. Signed-off-by: Baoquan He Reviewed-by: Christoph Hellwig Reviewed-by: Mike Rapoport (IBM) Cc: Stafford Horne Cc: Jonas Bonn Cc: Stefan Kristiansson Cc: openrisc@lists.librecores.org --- arch/openrisc/Kconfig | 1 + arch/openrisc/include/asm/io.h | 11 ++++---- arch/openrisc/mm/ioremap.c | 49 ---------------------------------- 3 files changed, 7 insertions(+), 54 deletions(-) diff --git a/arch/openrisc/Kconfig b/arch/openrisc/Kconfig index c7f282f60f64..fd9bb76a610b 100644 --- a/arch/openrisc/Kconfig +++ b/arch/openrisc/Kconfig @@ -21,6 +21,7 @@ config OPENRISC select GENERIC_IRQ_PROBE select GENERIC_IRQ_SHOW select GENERIC_PCI_IOMAP + select GENERIC_IOREMAP select GENERIC_CPU_DEVICES select HAVE_PCI select HAVE_UID16 diff --git a/arch/openrisc/include/asm/io.h b/arch/openrisc/include/asm/io.h index ee6043a03173..5a6f0f16a5ce 100644 --- a/arch/openrisc/include/asm/io.h +++ b/arch/openrisc/include/asm/io.h @@ -15,6 +15,8 @@ #define __ASM_OPENRISC_IO_H #include +#include +#include /* * PCI: We do not use IO ports in OpenRISC @@ -27,11 +29,10 @@ #define PIO_OFFSET 0 #define PIO_MASK 0 -#define ioremap ioremap -void __iomem *ioremap(phys_addr_t offset, unsigned long size); - -#define iounmap iounmap -extern void iounmap(volatile void __iomem *addr); +/* + * I/O memory mapping functions. + */ +#define _PAGE_IOREMAP (pgprot_val(PAGE_KERNEL) | _PAGE_CI) #include diff --git a/arch/openrisc/mm/ioremap.c b/arch/openrisc/mm/ioremap.c index cdbcc7e73684..91c8259d4b7e 100644 --- a/arch/openrisc/mm/ioremap.c +++ b/arch/openrisc/mm/ioremap.c @@ -22,55 +22,6 @@ extern int mem_init_done; -/* - * Remap an arbitrary physical address space into the kernel virtual - * address space. Needed when the kernel wants to access high addresses - * directly. - * - * NOTE! We need to allow non-page-aligned mappings too: we will obviously - * have to convert them into an offset in a page-aligned mapping, but the - * caller shouldn't need to know that small detail. - */ -void __iomem *__ref ioremap(phys_addr_t addr, unsigned long size) -{ - phys_addr_t p; - unsigned long v; - unsigned long offset, last_addr; - struct vm_struct *area = NULL; - - /* Don't allow wraparound or zero size */ - last_addr = addr + size - 1; - if (!size || last_addr < addr) - return NULL; - - /* - * Mappings have to be page-aligned - */ - offset = addr & ~PAGE_MASK; - p = addr & PAGE_MASK; - size = PAGE_ALIGN(last_addr + 1) - p; - - area = get_vm_area(size, VM_IOREMAP); - if (!area) - return NULL; - v = (unsigned long)area->addr; - - if (ioremap_page_range(v, v + size, p, - __pgprot(pgprot_val(PAGE_KERNEL) | _PAGE_CI))) { - vfree(area->addr); - return NULL; - } - - return (void __iomem *)(offset + (char *)v); -} -EXPORT_SYMBOL(ioremap); - -void iounmap(volatile void __iomem *addr) -{ - return vfree((void *)(PAGE_MASK & (unsigned long)addr)); -} -EXPORT_SYMBOL(iounmap); - /** * OK, this one's a bit tricky... ioremap can get called before memory is * initialized (early serial console does this) and will want to alloc a page From patchwork Thu Jul 6 15:45:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13303968 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id C01D7EB64D9 for ; Thu, 6 Jul 2023 15:47:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 588478D0002; Thu, 6 Jul 2023 11:47:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 55F018D0001; Thu, 6 Jul 2023 11:47:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 426918D0002; Thu, 6 Jul 2023 11:47:19 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 32FAA8D0001 for ; Thu, 6 Jul 2023 11:47:19 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id F2F75B0701 for ; Thu, 6 Jul 2023 15:47:18 +0000 (UTC) X-FDA: 80981616156.26.21E580F Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf17.hostedemail.com (Postfix) with ESMTP id 23FB740002 for ; Thu, 6 Jul 2023 15:47:14 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=KG8haOi3; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf17.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1688658435; a=rsa-sha256; cv=none; b=LLG0oPXJWdrtUhYGqOnz/8LcyPi14bDrdf9M9Wb1fuz8NQmLIIbHHysLauQI92Mn0Mv5GF 45pnPPrPVptTylaUMkrdUHL6WEfLX5hWKNJEJEec89dq4MP5cjzZnRwPTOY0/E5dJbhWzk mQcHeEIGMxvAHO9KudgKyMNkNt/OMyc= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=KG8haOi3; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf17.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1688658435; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=fXmRLKyZhjK8lZnEN6ZgBD7TdWtmJLX0PHcxqK6st5o=; b=WW2UJCQesECb4G2Or6GJa/tzY8RrnGyVBKbX9JQnrtQo4IiGc4HB9cKnAyYZczkxGPEOzn IF56Fhpzr7OYdzbeB5bcGXRneE2sW74H2vkf7qGTDxS0ogNAdm7hswqp28fllyKV804tWz +NUFslWlmdOT3YnYggvvWGf4Wbc+BF0= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1688658434; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fXmRLKyZhjK8lZnEN6ZgBD7TdWtmJLX0PHcxqK6st5o=; b=KG8haOi3rDn3ImhBxO+wmTEVlj32i8v6WdZFs+f+u66FZInpeMtdRzd5T0aVYr6FgEWvEi EClF2Dj/+Ni6ywPmbLWGwyIaaUz5GwsXIUZhjE28bV1AOBtZtsCBSFwo2S2IhC+Kq7D5ol a4c3DIhTVAOVIkwJLvCIlTX6Dq5/tUI= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-627-40rembCSN4-mVvgWCYJEdg-1; Thu, 06 Jul 2023 11:47:10 -0400 X-MC-Unique: 40rembCSN4-mVvgWCYJEdg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 183C081D9EC; Thu, 6 Jul 2023 15:47:09 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-39.pek2.redhat.com [10.72.12.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id 487C1F6401; Thu, 6 Jul 2023 15:46:56 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: akpm@linux-foundation.org, linux-mm@kvack.org, arnd@arndb.de, hch@lst.de, christophe.leroy@csgroup.eu, rppt@kernel.org, willy@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, shorne@gmail.com, David.Laight@ACULAB.COM, deller@gmx.de, nathan@kernel.org, glaubitz@physik.fu-berlin.de, Baoquan He , Gerald Schaefer , Heiko Carstens , Vasily Gorbik , Christian Borntraeger , Sven Schnelle , linux-s390@vger.kernel.org Subject: [PATCH v8 10/19] s390: mm: Convert to GENERIC_IOREMAP Date: Thu, 6 Jul 2023 23:45:11 +0800 Message-Id: <20230706154520.11257-11-bhe@redhat.com> In-Reply-To: <20230706154520.11257-1-bhe@redhat.com> References: <20230706154520.11257-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 23FB740002 X-Stat-Signature: 8cp3wdqutna5se7armknwofr8p3ncn4y X-HE-Tag: 1688658434-157582 X-HE-Meta: U2FsdGVkX1/GwYL2biTqufDfzlnQC2BNLYlq85XSjm3gz4aoyPIpSo/gwxwtqS+Akw1xCBvbEZWGcxv3SZm+Oh57KxGJidd5gmxeen/A/TCEQY22opZSUn+pKfaNsqBqimoQdX1YMVbcKQRKkp0cOQOvFBbvaXxL73vOEwyDMKgb7p2TdeKcvaBIZHTgDnk2WU3JaQB4k7PZw3+/80uaeXdH4CPfXfPekf/KOeWaStfIildgdKdTG+SE5E6DjNfZEZ+T7599AlEUg7hPeB43bnU38K3q6BrSMIPBUFfltZE0FCQBymbcsWJcCrTXMdF116xWZ9GsNtNQqh2P01kAgp1Grh5gAf5zkI616/zqFSp5HAkKqori/5SRZJHfHZeGSQ4DQ5gFbM/QelWECdF/Wf4YjzXBxvTcTCxxUeGtsPAD8hTxDmbxfW+Aesyp726cvAc25y5kkuelaIz2lCtaDUzOvpIT0C40fNNYjLd2m+KTg6T850v0IJbMlYsvGy4gQmd8pxu69r1/Yvn1EwJwI7aYzhREGGYCYYYBH2TjaySlvlqzsHLr3JEdRhJDogRLOHJQnCs2A+XQLEWmtR7OlCA7O/EaQzY7+qBWc4h/w0DwPsOO+n+vWcrwYDjDYG3U6+ufnAkI0O/OcA2zKbqIrqfKBTBEF7qyQp9NhnmC6pghNl7d5mOaqdZTB9oGbmF7IMgogljewOIN90UQpzhhqDsuPSh9XlS0P0nCHo2MU2yQT85QV0+T81ONwIlxXPqeINLbYiXezLdgPsKi2aZsz3RKji9SZomlm7HLM8Kfp0hXB4URRFItqSwmlDQofTMAc3jHcssEGw2iEV6KRb6RnCKIKyypph6pD79gnPEgoZZz6aM+3Xygi9W9EvRWatWbXXPzRNSBr5aqEz6rWMXQ3xOPMqLn5T1X0Y85H8VtPCS76xTNkzeQffphshnPnJIA2RQyDNLZ3EjZ95bNRTO Jf5T0Ul6 oi2CYfEhILzgLkCsrnJbBJH6oKXbBugJVrSewQAf0NPKFcE5MZBVj5nzIiN+SrbI7flAvILH8ofnUTJK9JMCO3VRaPgQBdWU9GWg5GBqjRCKpTbFkk8R7iICB/YXOPGSzAK+h/etqAvyyOSdVNhzvWhm6vHEeKkkqMlg7/8cYq5Z6D4sxL3iD2EWmCmnLqpKlwsyxR9cH1/IvtRvZIK51Ohjle8EhKbeKOP0mZi9TpQ5YNFNiuTHK/O3vY3J41LbyxgGYlxmkA3exyMOew5srIHTWSTVZ/3UY2pPSR5jIqPYgmFBbgP20gMJChw== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: By taking GENERIC_IOREMAP method, the generic generic_ioremap_prot(), generic_iounmap(), and their generic wrapper ioremap_prot(), ioremap() and iounmap() are all visible and available to arch. Arch needs to provide wrapper functions to override the generic versions if there's arch specific handling in its ioremap_prot(), ioremap() or iounmap(). This change will simplify implementation by removing duplicated code with generic_ioremap_prot() and generic_iounmap(), and has the equivalent functioality as before. Here, add wrapper functions ioremap_prot() and iounmap() for s390's special operation when ioremap() and iounmap(). And also replace including with in arch/s390/kernel/perf_cpum_sf.c, otherwise building error will be seen because macro defined in can't be seen in perf_cpum_sf.c. Signed-off-by: Baoquan He Reviewed-by: Niklas Schnelle Tested-by: Niklas Schnelle Reviewed-by: Christoph Hellwig Reviewed-by: Mike Rapoport (IBM) Cc: Gerald Schaefer Cc: Heiko Carstens Cc: Vasily Gorbik Cc: Alexander Gordeev Cc: Christian Borntraeger Cc: Sven Schnelle Cc: linux-s390@vger.kernel.org --- arch/s390/Kconfig | 1 + arch/s390/include/asm/io.h | 21 ++++++------ arch/s390/kernel/perf_cpum_sf.c | 2 +- arch/s390/pci/pci.c | 57 ++++++--------------------------- 4 files changed, 24 insertions(+), 57 deletions(-) diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig index 5b39918b7042..290b6f93b816 100644 --- a/arch/s390/Kconfig +++ b/arch/s390/Kconfig @@ -143,6 +143,7 @@ config S390 select GENERIC_SMP_IDLE_THREAD select GENERIC_TIME_VSYSCALL select GENERIC_VDSO_TIME_NS + select GENERIC_IOREMAP if PCI select HAVE_ALIGNED_STRUCT_PAGE if SLUB select HAVE_ARCH_AUDITSYSCALL select HAVE_ARCH_JUMP_LABEL diff --git a/arch/s390/include/asm/io.h b/arch/s390/include/asm/io.h index e3882b012bfa..4453ad7c11ac 100644 --- a/arch/s390/include/asm/io.h +++ b/arch/s390/include/asm/io.h @@ -22,11 +22,18 @@ void unxlate_dev_mem_ptr(phys_addr_t phys, void *addr); #define IO_SPACE_LIMIT 0 -void __iomem *ioremap_prot(phys_addr_t addr, size_t size, unsigned long prot); -void __iomem *ioremap(phys_addr_t addr, size_t size); -void __iomem *ioremap_wc(phys_addr_t addr, size_t size); -void __iomem *ioremap_wt(phys_addr_t addr, size_t size); -void iounmap(volatile void __iomem *addr); +/* + * I/O memory mapping functions. + */ +#define ioremap_prot ioremap_prot +#define iounmap iounmap + +#define _PAGE_IOREMAP pgprot_val(PAGE_KERNEL) + +#define ioremap_wc(addr, size) \ + ioremap_prot((addr), (size), pgprot_val(pgprot_writecombine(PAGE_KERNEL))) +#define ioremap_wt(addr, size) \ + ioremap_prot((addr), (size), pgprot_val(pgprot_writethrough(PAGE_KERNEL))) static inline void __iomem *ioport_map(unsigned long port, unsigned int nr) { @@ -51,10 +58,6 @@ static inline void ioport_unmap(void __iomem *p) #define pci_iomap_wc pci_iomap_wc #define pci_iomap_wc_range pci_iomap_wc_range -#define ioremap ioremap -#define ioremap_wt ioremap_wt -#define ioremap_wc ioremap_wc - #define memcpy_fromio(dst, src, count) zpci_memcpy_fromio(dst, src, count) #define memcpy_toio(dst, src, count) zpci_memcpy_toio(dst, src, count) #define memset_io(dst, val, count) zpci_memset_io(dst, val, count) diff --git a/arch/s390/kernel/perf_cpum_sf.c b/arch/s390/kernel/perf_cpum_sf.c index 8ecfbce4ac92..dc6afc2221b4 100644 --- a/arch/s390/kernel/perf_cpum_sf.c +++ b/arch/s390/kernel/perf_cpum_sf.c @@ -22,7 +22,7 @@ #include #include #include -#include +#include /* Minimum number of sample-data-block-tables: * At least one table is required for the sampling buffer structure. diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c index afc3f33788da..d34d5813d006 100644 --- a/arch/s390/pci/pci.c +++ b/arch/s390/pci/pci.c @@ -244,62 +244,25 @@ void __iowrite64_copy(void __iomem *to, const void *from, size_t count) zpci_memcpy_toio(to, from, count); } -static void __iomem *__ioremap(phys_addr_t addr, size_t size, pgprot_t prot) +void __iomem *ioremap_prot(phys_addr_t phys_addr, size_t size, + unsigned long prot) { - unsigned long offset, vaddr; - struct vm_struct *area; - phys_addr_t last_addr; - - last_addr = addr + size - 1; - if (!size || last_addr < addr) - return NULL; - + /* + * When PCI MIO instructions are unavailable the "physical" address + * encodes a hint for accessing the PCI memory space it represents. + * Just pass it unchanged such that ioread/iowrite can decode it. + */ if (!static_branch_unlikely(&have_mio)) - return (void __iomem *) addr; + return (void __iomem *)phys_addr; - offset = addr & ~PAGE_MASK; - addr &= PAGE_MASK; - size = PAGE_ALIGN(size + offset); - area = get_vm_area(size, VM_IOREMAP); - if (!area) - return NULL; - - vaddr = (unsigned long) area->addr; - if (ioremap_page_range(vaddr, vaddr + size, addr, prot)) { - free_vm_area(area); - return NULL; - } - return (void __iomem *) ((unsigned long) area->addr + offset); -} - -void __iomem *ioremap_prot(phys_addr_t addr, size_t size, unsigned long prot) -{ - return __ioremap(addr, size, __pgprot(prot)); + return generic_ioremap_prot(phys_addr, size, __pgprot(prot)); } EXPORT_SYMBOL(ioremap_prot); -void __iomem *ioremap(phys_addr_t addr, size_t size) -{ - return __ioremap(addr, size, PAGE_KERNEL); -} -EXPORT_SYMBOL(ioremap); - -void __iomem *ioremap_wc(phys_addr_t addr, size_t size) -{ - return __ioremap(addr, size, pgprot_writecombine(PAGE_KERNEL)); -} -EXPORT_SYMBOL(ioremap_wc); - -void __iomem *ioremap_wt(phys_addr_t addr, size_t size) -{ - return __ioremap(addr, size, pgprot_writethrough(PAGE_KERNEL)); -} -EXPORT_SYMBOL(ioremap_wt); - void iounmap(volatile void __iomem *addr) { if (static_branch_likely(&have_mio)) - vunmap((__force void *) ((unsigned long) addr & PAGE_MASK)); + generic_iounmap(addr); } EXPORT_SYMBOL(iounmap); From patchwork Thu Jul 6 15:45:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13303969 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 839A1EB64DC for ; Thu, 6 Jul 2023 15:47:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2050F8D0003; Thu, 6 Jul 2023 11:47:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1B57E8D0001; Thu, 6 Jul 2023 11:47:27 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0A4188D0003; Thu, 6 Jul 2023 11:47:27 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id ED9618D0001 for ; Thu, 6 Jul 2023 11:47:26 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id C2164C01DE for ; Thu, 6 Jul 2023 15:47:26 +0000 (UTC) X-FDA: 80981616492.25.16639F6 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf17.hostedemail.com (Postfix) with ESMTP id 89B7C4001D for ; Thu, 6 Jul 2023 15:47:23 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=TU028Pu0; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf17.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1688658443; a=rsa-sha256; cv=none; b=DQBZ5zseP5QNWTDc2FLbjFvqpgnrZ0E8dPzq4MazQ8uuP/J4/qmh11jPEWDSaVnE6vjT6o Yo6H7PtRUB8w3e0MgtHjUqdlxnPU0gA3aNIiwLCJiOQyg4SVDQpnsO26rbHlacIMjoOzGP I071kpbdlqC7v+XkCk3R0P+xY/z/e+k= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=TU028Pu0; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf17.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1688658443; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=tzZiG+lU/mpwC2M6do1wPfvjsF6WIZJJprfTB9qP0II=; b=QU+49nXZKII8/k/oUAM3hd9YYZi7X4t2DFPCIEAAbvZTY5hayxcXpnrYLJZFWvnB4+ZygD JA3dqcyKZEMrDCGCPyvJ1I06Ew7rZBt3tsDBlU3sFO0sKG2wTv00vZGpzQmlB4ghttgLKz PxKskeEZ4/5dg8DMEaYFJ7gRXTIQ8oI= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1688658442; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tzZiG+lU/mpwC2M6do1wPfvjsF6WIZJJprfTB9qP0II=; b=TU028Pu0On2CRLRtkQKap4CegHgqgHPeEkr2SK3hK3mUhqpxu/DH7B8Ceyy138R1hmNCwG pSijse9KSPJgFOiAR+ozPJykN8s5YdnKcXY4CsAQwMpti1RpRYmceCc4zDq8QdDCzhxg3X 3xPg28X7NX9dOY38knNWuXk/OHs49g0= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-672-0iqGGaRmOUaijaM3Mod1VQ-1; Thu, 06 Jul 2023 11:47:20 -0400 X-MC-Unique: 0iqGGaRmOUaijaM3Mod1VQ-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E391B800CB3; Thu, 6 Jul 2023 15:47:18 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-39.pek2.redhat.com [10.72.12.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id F1BA3F5CF0; Thu, 6 Jul 2023 15:47:09 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: akpm@linux-foundation.org, linux-mm@kvack.org, arnd@arndb.de, hch@lst.de, christophe.leroy@csgroup.eu, rppt@kernel.org, willy@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, shorne@gmail.com, David.Laight@ACULAB.COM, deller@gmx.de, nathan@kernel.org, glaubitz@physik.fu-berlin.de, Baoquan He , Yoshinori Sato , Rich Felker , linux-sh@vger.kernel.org Subject: [PATCH v8 11/19] sh: add including Date: Thu, 6 Jul 2023 23:45:12 +0800 Message-Id: <20230706154520.11257-12-bhe@redhat.com> In-Reply-To: <20230706154520.11257-1-bhe@redhat.com> References: <20230706154520.11257-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 89B7C4001D X-Stat-Signature: xs3rt7uoo7pshmo7mhdj4c3rzqb4u6af X-HE-Tag: 1688658443-467798 X-HE-Meta: U2FsdGVkX19kB+Xhe6BdKNm4WQckYCGv5t9Bw9cfNyoFHnhsumBl6Jv2Q/xtl2lT+X70Vc7G8W+ofVd84U4aklNP9u5wkjNlUvt5jAUc+8njgMOfZfImUctRnhl/numPbLbEGB25pWqZCC0H6hfOrVbVGBh2spcUNv03ySD9TYOtTWz5pE8G/OsGFkMBrmqN1IaK8sCpu6rBAa5+Ix9XVn+W6pGhnqrZJ/RzGZpo9hfaqvERZyq86iuF3DBDUETH3YucLHaQkex4rsoWBHgr4E8i6o3zNAhfn2aVv6MCA9vvAP5OaR8wZL6nHegaLTU8k0PX83IL2DL96G+2e1zDHR4Rmibdw/GeqTwT9SN5mN9euyN41nXYO4gMeBhKZhGl+IvPITaV++8XIrxuyyVhKVxNpANVsJfKzb84VR7JCG0k+MHylCZcSCXR+xdcJ2CiSjgn5WoK88Y3SIrK8dlMGb4j4m85rM1m6th62ZGiz/zn2eJFbA/uzliftys8qsLorxsR7G6OX2SA7LlPiV/cAf6KsYt9SW7o8Ki29Fyu3hylzCBzZcmBBE0vMzkpJc+eN2RG+/9HDIr2MQIzsD8jLLrDXtihVsdBOZLPUUcD6nmQOE7L0j87c1oyeqc35qNl3ILVNjKzo9u3mKseY+sNtYKf4dznNomknPn3IZtc1pyF7GM+2OMlmySVnwXdoV24TIqeTdyEmYyWribpVSX/Bjy2Q1IC+CdPAUoT/mwqBIi33qtBmcQPlzDnL9QtMPcK0e2vueU2fRHl0r1ZBT5a4AVHyyGXvb7GrARhkSF9gUmjbc0n4juyyGQhOAKQPkb9mK1PiObrcBLLp9nG6GkTIidP+0GfjjAzEndhH3N81eZERa2/HypuSsJSDWQccxHqG5ALQT6lwJHQjjuVtLOJyXkKnFeqle0BWVXX9OrYUPF3r4eCXEE1TpiOcqJqj5xFcjNlAeDjC4yg9kpwbav dGmKzrLq BKG+0Y9U3Fp3oOvQ4iLvkUqhMtYYxziwcVzA3U/+KROle3QqNv2ztZUI+Qk0OnCye9PbwuQkSjg8eVk+YAykUwxnvK0qyMwA6hFtWmHhZ9ObZMt3citceERSTZ71R70NL0DEawy0uP+Hb786m1jCFkQcQ33sqBYo4RNjgz4adPJ/v0M4S0bziuRL4Y7fqfQuyX47X0FWbsoLrdmrS1JF5YPq1rEMzvdirjZBHgqllz+/tvGLlT1REExho3SyNdor6GJmM9AJ3x7psOmaxaKFJp80uvoXiLKeDDoRdfM40FgIN0Rg= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: In , it provides a generic implementation of all I/O accessors. For some port|mm io functions, SuperH has its own implementation in arch/sh/kernel/iomap.c and arch/sh/include/asm/io_noioport.h. These will conflict with those in and cause compiling error. Hence add macro definitions to ensure that the SuperH version of them will override the generic version. Signed-off-by: Baoquan He Cc: John Paul Adrian Glaubitz Cc: Yoshinori Sato Cc: Rich Felker Cc: linux-sh@vger.kernel.org Acked-by: John Paul Adrian Glaubitz --- arch/sh/include/asm/io.h | 25 +++++++++++++++++++++++++ arch/sh/include/asm/io_noioport.h | 7 +++++++ 2 files changed, 32 insertions(+) diff --git a/arch/sh/include/asm/io.h b/arch/sh/include/asm/io.h index fba90e670ed4..270e7952950c 100644 --- a/arch/sh/include/asm/io.h +++ b/arch/sh/include/asm/io.h @@ -119,6 +119,26 @@ void __raw_readsl(const void __iomem *addr, void *data, int longlen); __BUILD_MEMORY_STRING(__raw_, q, u64) +#define ioread8 ioread8 +#define ioread16 ioread16 +#define ioread16be ioread16be +#define ioread32 ioread32 +#define ioread32be ioread32be + +#define iowrite8 iowrite8 +#define iowrite16 iowrite16 +#define iowrite16be iowrite16be +#define iowrite32 iowrite32 +#define iowrite32be iowrite32be + +#define ioread8_rep ioread8_rep +#define ioread16_rep ioread16_rep +#define ioread32_rep ioread32_rep + +#define iowrite8_rep iowrite8_rep +#define iowrite16_rep iowrite16_rep +#define iowrite32_rep iowrite32_rep + #ifdef CONFIG_HAS_IOPORT_MAP /* @@ -225,6 +245,9 @@ __BUILD_IOPORT_STRING(q, u64) #define IO_SPACE_LIMIT 0xffffffff /* We really want to try and get these to memcpy etc */ +#define memset_io memset_io +#define memcpy_fromio memcpy_fromio +#define memcpy_toio memcpy_toio void memcpy_fromio(void *, const volatile void __iomem *, unsigned long); void memcpy_toio(volatile void __iomem *, const void *, unsigned long); void memset_io(volatile void __iomem *, int, unsigned long); @@ -287,6 +310,8 @@ static inline void iounmap(volatile void __iomem *addr) { } */ #define xlate_dev_mem_ptr(p) __va(p) +#include + #define ARCH_HAS_VALID_PHYS_ADDR_RANGE int valid_phys_addr_range(phys_addr_t addr, size_t size); int valid_mmap_phys_addr_range(unsigned long pfn, size_t size); diff --git a/arch/sh/include/asm/io_noioport.h b/arch/sh/include/asm/io_noioport.h index f7938fe0f911..5ba4116b4265 100644 --- a/arch/sh/include/asm/io_noioport.h +++ b/arch/sh/include/asm/io_noioport.h @@ -53,6 +53,13 @@ static inline void ioport_unmap(void __iomem *addr) #define outw_p(x, addr) outw((x), (addr)) #define outl_p(x, addr) outl((x), (addr)) +#define insb insb +#define insw insw +#define insl insl +#define outsb outsb +#define outsw outsw +#define outsl outsl + static inline void insb(unsigned long port, void *dst, unsigned long count) { BUG(); From patchwork Thu Jul 6 15:45:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13303970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 53078EB64DD for ; Thu, 6 Jul 2023 15:47:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E61388D0005; Thu, 6 Jul 2023 11:47:35 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E10A48D0001; Thu, 6 Jul 2023 11:47:35 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D00378D0005; Thu, 6 Jul 2023 11:47:35 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id BE4408D0001 for ; Thu, 6 Jul 2023 11:47:35 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 5CAEE1C774A for ; Thu, 6 Jul 2023 15:47:35 +0000 (UTC) X-FDA: 80981616870.22.AE6E888 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf26.hostedemail.com (Postfix) with ESMTP id BB44414002D for ; Thu, 6 Jul 2023 15:47:32 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=gs9cmct3; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf26.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1688658452; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=oemqTF5zxWGJe7eTucw4w0j0Azve239hRRVpg02qoms=; b=PnRsK67UK8Wm6QRUxkxYhc88cuelmgchFA+zHIy6Z43YpDAZw7yKv1BI5pv6KqbHPHtdwS +7BkAEvmJ41zIadyvwGVWVCIfYrI+Uakzk7uciGtYUJS5Iz9z3/eQwDGgqrPPTJCFQihgp PIo/+I02CZVTJl40YhXRSSWHDh4+dBc= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=gs9cmct3; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf26.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1688658452; a=rsa-sha256; cv=none; b=8mFTprSmadoc8OOuFl4E4y5KC0bxblDwDVx3Rthz2OjOHvRyQOhCGLqNoWtVTSNnZVezuY KEueKNaSeRUuEYMwXNWP58s+ausPdQNWb3StehSStIteGl//owpXn7L0CCH9lbNO6jE1v+ pjmMar0bWtduvZjQg+uMqlVw8Gi6rqc= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1688658451; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=oemqTF5zxWGJe7eTucw4w0j0Azve239hRRVpg02qoms=; b=gs9cmct3EDMynGHecfLOuhyFBlGT6mhOf9eelAd1NqcGtn2pSwAIUl5ZX7m4JKTW8AMTnB yzWhfK67Qa5nu3NdbGqPZHUdHlK9jjHKmijhKxy2IazqORboSa96CyFD/gSYVX8TEgCVbP 4UbZx6pgRPjUEoOEp99GZE0aFCMBB8k= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-457-zWaEbkE9Msm1q8C2Gnjlpw-1; Thu, 06 Jul 2023 11:47:30 -0400 X-MC-Unique: zWaEbkE9Msm1q8C2Gnjlpw-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B64CB803FDF; Thu, 6 Jul 2023 15:47:28 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-39.pek2.redhat.com [10.72.12.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id 884B9F5CFB; Thu, 6 Jul 2023 15:47:19 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: akpm@linux-foundation.org, linux-mm@kvack.org, arnd@arndb.de, hch@lst.de, christophe.leroy@csgroup.eu, rppt@kernel.org, willy@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, shorne@gmail.com, David.Laight@ACULAB.COM, deller@gmx.de, nathan@kernel.org, glaubitz@physik.fu-berlin.de, Baoquan He , Yoshinori Sato , Rich Felker , linux-sh@vger.kernel.org Subject: [PATCH v8 12/19] sh: mm: Convert to GENERIC_IOREMAP Date: Thu, 6 Jul 2023 23:45:13 +0800 Message-Id: <20230706154520.11257-13-bhe@redhat.com> In-Reply-To: <20230706154520.11257-1-bhe@redhat.com> References: <20230706154520.11257-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: BB44414002D X-Stat-Signature: qbz8oassr8r33ziy8r7zhd9ik4rfu6xx X-Rspam-User: X-HE-Tag: 1688658452-352866 X-HE-Meta: U2FsdGVkX18Z5VQ1M/7YTQ3v3qFsUap1a/6vrlsw2/TqK/K7sRwgBZPHA2XjPtfQN3dSjlFIHwcfhjRnj5tRTeYl75czPJISzj01TfFwktUZqieBHX8bvVSbXaP8P5UR65E3takARSnYtKAnf1zyWDceANsi2ZDswBkgqz6GyImOpnJPKIvacsRSGWB1arPOXdKAiJATseev9efPhqEMVDQ8/7N0TFcgSIRAXHFBg77Eeevpzoc9Au5psGES0h4rJYZVcuu01r+3PyhUxk4R/ZnxzPKS/DTUu7KdYVTul4P7Q8MA8ygDWMpvVBxJFR6tOnxnHK+Tql9hNywoy9fLOgAc4IMc26HN01b9iMusTf44CzPBreUGEfLxaJegmKY3Z3rsT5wSOzGjMPgeinQ5GP3yAdacmDTOUit5VWv5FxqVR0VTL+B1q/ZE0nNEp/n8/eFCnzGSo/5Cs82xGC97Pa7foDt8QBCtB8zG5c7POsnvNV7cv+9LUDZj9R2bPBHHhF7i/RBOu/nuPkE+ykMJ1+abLK6vf6qJO4tM3ZoN4UoxjHN92T0RoJmhfSWMvE8c+8NtaSLZMYtIZmYhO/5g91h1dyc2WN36xoC3xy6lh5wOoLG4Tvq/N1HTDhcj04aglrzJO6U5D6gxFjV2i8+GQQs0nphH7OZCYnffuVFopqd+Lg6aruNUx7ybNbcKmseRzfeRuI9oAa70K7aBPuiAVQEL4FcSMVD8nR2Yi8jKxzYO4koj/NEiUhLdQWcs6vo4zmNh+DNIIgcZHK4XY81X9XDh/FzftHzO502FG7hRDCC9Ll/EgA5DETcbvg807JLB6VkxnGmeBU274ksEcFbbPTeK4Yfso5+MUlQghQYAZO5Wt3Nepfi85tB2g1ZoLtkBv3gu8Xqd0WkMkBK609/ixHiVkPNiCkYR8VVgaoEgdJgLBTwLQnxwC46vFCQUAXoH0AMDsK/r0q6JwuY4bZj VC/OrRGf 07UtXJh4OaXkFFpZM2N3tdRINtOoeFrdkjez77WWufVTWdy4Di3hySKCM5A5JWCAEIl7q8HclqNry81nBF1wO9M+YPU4CAwU6Q30s2S4eS3ZcNLjU8MiHEzBj450Ve7BlUFXzCoOBZf+BC9H7Q4Tt+tDNCTjd5++QndJ87m8EJ7ky0nU++ozZXYlXiWH+xX5J78wt+03o6KK4u5Sw1ItYd6A89A0b2BpaS/25oyjNTesfno0MdhNO4C4ztFjs0yFnB430ruj4Py6Rp/vemWRwi6bAhpJzNLcENIADLUyaLJfN90PSADnbo8GbSMEDZYJSYWuwAXA+YUae0n3ncH9WCJ//Hw== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: By taking GENERIC_IOREMAP method, the generic generic_ioremap_prot(), generic_iounmap(), and their generic wrapper ioremap_prot(), ioremap() and iounmap() are all visible and available to arch. Arch needs to provide wrapper functions to override the generic versions if there's arch specific handling in its ioremap_prot(), ioremap() or iounmap(). This change will simplify implementation by removing duplicated code with generic_ioremap_prot() and generic_iounmap(), and has the equivalent functioality as before. Here, add wrapper functions ioremap_prot() and iounmap() for SuperH's special operation when ioremap() and iounmap(). Signed-off-by: Baoquan He Cc: John Paul Adrian Glaubitz Cc: Yoshinori Sato Cc: Rich Felker Cc: linux-sh@vger.kernel.org --- arch/sh/Kconfig | 1 + arch/sh/include/asm/io.h | 40 +++++-------------------- arch/sh/mm/ioremap.c | 65 +++++++--------------------------------- 3 files changed, 20 insertions(+), 86 deletions(-) diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig index 2b3ce4fd3956..6be32254211c 100644 --- a/arch/sh/Kconfig +++ b/arch/sh/Kconfig @@ -29,6 +29,7 @@ config SUPERH select GENERIC_SMP_IDLE_THREAD select GUP_GET_PXX_LOW_HIGH if X2TLB select HAS_IOPORT if HAS_IOPORT_MAP + select GENERIC_IOREMAP if MMU select HAVE_ARCH_AUDITSYSCALL select HAVE_ARCH_KGDB select HAVE_ARCH_SECCOMP_FILTER diff --git a/arch/sh/include/asm/io.h b/arch/sh/include/asm/io.h index 270e7952950c..b3a26b405c8d 100644 --- a/arch/sh/include/asm/io.h +++ b/arch/sh/include/asm/io.h @@ -266,40 +266,16 @@ unsigned long long poke_real_address_q(unsigned long long addr, #endif #ifdef CONFIG_MMU -void iounmap(void __iomem *addr); -void __iomem *__ioremap_caller(phys_addr_t offset, unsigned long size, - pgprot_t prot, void *caller); - -static inline void __iomem *ioremap(phys_addr_t offset, unsigned long size) -{ - return __ioremap_caller(offset, size, PAGE_KERNEL_NOCACHE, - __builtin_return_address(0)); -} - -static inline void __iomem * -ioremap_cache(phys_addr_t offset, unsigned long size) -{ - return __ioremap_caller(offset, size, PAGE_KERNEL, - __builtin_return_address(0)); -} -#define ioremap_cache ioremap_cache - -#ifdef CONFIG_HAVE_IOREMAP_PROT -static inline void __iomem *ioremap_prot(phys_addr_t offset, unsigned long size, - unsigned long flags) -{ - return __ioremap_caller(offset, size, __pgprot(flags), - __builtin_return_address(0)); -} -#endif /* CONFIG_HAVE_IOREMAP_PROT */ +/* + * I/O memory mapping functions. + */ +#define ioremap_prot ioremap_prot +#define iounmap iounmap -#else /* CONFIG_MMU */ -static inline void __iomem *ioremap(phys_addr_t offset, size_t size) -{ - return (void __iomem *)(unsigned long)offset; -} +#define _PAGE_IOREMAP pgprot_val(PAGE_KERNEL_NOCACHE) -static inline void iounmap(volatile void __iomem *addr) { } +#define ioremap_cache(addr, size) \ + ioremap_prot((addr), (size), pgprot_val(PAGE_KERNEL)) #endif /* CONFIG_MMU */ #define ioremap_uc ioremap diff --git a/arch/sh/mm/ioremap.c b/arch/sh/mm/ioremap.c index 21342581144d..c33b3daa4ad1 100644 --- a/arch/sh/mm/ioremap.c +++ b/arch/sh/mm/ioremap.c @@ -72,22 +72,11 @@ __ioremap_29bit(phys_addr_t offset, unsigned long size, pgprot_t prot) #define __ioremap_29bit(offset, size, prot) NULL #endif /* CONFIG_29BIT */ -/* - * Remap an arbitrary physical address space into the kernel virtual - * address space. Needed when the kernel wants to access high addresses - * directly. - * - * NOTE! We need to allow non-page-aligned mappings too: we will obviously - * have to convert them into an offset in a page-aligned mapping, but the - * caller shouldn't need to know that small detail. - */ -void __iomem * __ref -__ioremap_caller(phys_addr_t phys_addr, unsigned long size, - pgprot_t pgprot, void *caller) +void __iomem *ioremap_prot(phys_addr_t phys_addr, size_t size, + unsigned long prot) { - struct vm_struct *area; - unsigned long offset, last_addr, addr, orig_addr; void __iomem *mapped; + pgprot_t pgprot = __pgprot(prot); mapped = __ioremap_trapped(phys_addr, size); if (mapped) @@ -97,11 +86,6 @@ __ioremap_caller(phys_addr_t phys_addr, unsigned long size, if (mapped) return mapped; - /* Don't allow wraparound or zero size */ - last_addr = phys_addr + size - 1; - if (!size || last_addr < phys_addr) - return NULL; - /* * If we can't yet use the regular approach, go the fixmap route. */ @@ -112,34 +96,14 @@ __ioremap_caller(phys_addr_t phys_addr, unsigned long size, * First try to remap through the PMB. * PMB entries are all pre-faulted. */ - mapped = pmb_remap_caller(phys_addr, size, pgprot, caller); + mapped = pmb_remap_caller(phys_addr, size, pgprot, + __builtin_return_address(0)); if (mapped && !IS_ERR(mapped)) return mapped; - /* - * Mappings have to be page-aligned - */ - offset = phys_addr & ~PAGE_MASK; - phys_addr &= PAGE_MASK; - size = PAGE_ALIGN(last_addr+1) - phys_addr; - - /* - * Ok, go for it.. - */ - area = get_vm_area_caller(size, VM_IOREMAP, caller); - if (!area) - return NULL; - area->phys_addr = phys_addr; - orig_addr = addr = (unsigned long)area->addr; - - if (ioremap_page_range(addr, addr + size, phys_addr, pgprot)) { - vunmap((void *)orig_addr); - return NULL; - } - - return (void __iomem *)(offset + (char *)orig_addr); + return generic_ioremap_prot(phys_addr, size, pgprot); } -EXPORT_SYMBOL(__ioremap_caller); +EXPORT_SYMBOL(ioremap_prot); /* * Simple checks for non-translatable mappings. @@ -158,10 +122,9 @@ static inline int iomapping_nontranslatable(unsigned long offset) return 0; } -void iounmap(void __iomem *addr) +void iounmap(volatile void __iomem *addr) { unsigned long vaddr = (unsigned long __force)addr; - struct vm_struct *p; /* * Nothing to do if there is no translatable mapping. @@ -172,21 +135,15 @@ void iounmap(void __iomem *addr) /* * There's no VMA if it's from an early fixed mapping. */ - if (iounmap_fixed(addr) == 0) + if (iounmap_fixed((void __iomem *)addr) == 0) return; /* * If the PMB handled it, there's nothing else to do. */ - if (pmb_unmap(addr) == 0) + if (pmb_unmap((void __iomem *)addr) == 0) return; - p = remove_vm_area((void *)(vaddr & PAGE_MASK)); - if (!p) { - printk(KERN_ERR "%s: bad address %p\n", __func__, addr); - return; - } - - kfree(p); + generic_iounmap(addr); } EXPORT_SYMBOL(iounmap); From patchwork Thu Jul 6 15:45:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13303971 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 472FAEB64D9 for ; Thu, 6 Jul 2023 15:47:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D77F28D0002; Thu, 6 Jul 2023 11:47:48 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D27098D0001; Thu, 6 Jul 2023 11:47:48 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BC7DE8D0002; Thu, 6 Jul 2023 11:47:48 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id AAA338D0001 for ; Thu, 6 Jul 2023 11:47:48 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 38E4F12072D for ; Thu, 6 Jul 2023 15:47:48 +0000 (UTC) X-FDA: 80981617416.30.B7AC6BB Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf18.hostedemail.com (Postfix) with ESMTP id 5F5A61C0023 for ; Thu, 6 Jul 2023 15:47:44 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=ASDpFI9q; spf=pass (imf18.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1688658465; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=oNtW2gZY5kTL8OZsi9xDDaXWO3ott7dJ82eWnmuGcO0=; b=oBzx5p5KRkixyS6WA9jx5+hKAMsizylBHw7qglte2VsHzk1C4bGEwuUi6u7RTbR9JYcO3X pq06dwqPZP8VP7cYXH7E0SmCCW+nkO2FTsP+7XN4Hl8SWvEzx8zrE34cJHhpnEfnSQgybl Wec93d5mL3o+84TuSk3hvrb0GN4QwyE= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1688658465; a=rsa-sha256; cv=none; b=sX44uSYhrv3WVBKmhqjWG2PE+bRwj1nSQrBynyPv0CZhfej0LQfNGCVBowQfXhxl4vqloq 2Ebr1pQ64vGK4Z/7Slp5951eB+0yPrnRQUXAZM3yuq75/muskzXuJIs6my7nRUWS5OKfKv XYhH5t2sTT/mdcL3Qj5ZRdJotHB0ub8= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=ASDpFI9q; spf=pass (imf18.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1688658464; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=oNtW2gZY5kTL8OZsi9xDDaXWO3ott7dJ82eWnmuGcO0=; b=ASDpFI9q6jSOX4hNboySjsZQkDJB7XOXEN22ivnbvmfITDaSmkWrRnA4tUknpT3uDY5dQQ KNh9c/oehCvR/fb+Mw77u8wjB+PLxL5F2OuUYO1Wgwywn/2frYrdyg6n2VrUypgLW10ijj g3T+ytngS78XrRV4smwe8ZmgqM2XRHM= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-147-nR317nlKPae4uls70wOO-Q-1; Thu, 06 Jul 2023 11:47:39 -0400 X-MC-Unique: nR317nlKPae4uls70wOO-Q-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5E01B185A792; Thu, 6 Jul 2023 15:47:38 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-39.pek2.redhat.com [10.72.12.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id 88F8FF5CF0; Thu, 6 Jul 2023 15:47:29 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: akpm@linux-foundation.org, linux-mm@kvack.org, arnd@arndb.de, hch@lst.de, christophe.leroy@csgroup.eu, rppt@kernel.org, willy@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, shorne@gmail.com, David.Laight@ACULAB.COM, deller@gmx.de, nathan@kernel.org, glaubitz@physik.fu-berlin.de, Baoquan He , Chris Zankel , Max Filippov Subject: [PATCH v8 13/19] xtensa: mm: Convert to GENERIC_IOREMAP Date: Thu, 6 Jul 2023 23:45:14 +0800 Message-Id: <20230706154520.11257-14-bhe@redhat.com> In-Reply-To: <20230706154520.11257-1-bhe@redhat.com> References: <20230706154520.11257-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Rspamd-Queue-Id: 5F5A61C0023 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: jxy7d4myxfm8tupjpphcdbf69c3ksxi1 X-HE-Tag: 1688658464-459593 X-HE-Meta: U2FsdGVkX1+3xvuCgcun/XCnQw6mysgPpODUPFG9OpTC33KCGIF8CkU0o/icnhO0VRqq5YqK8AFU5lcVyiyi16P/JK1OcpprDi5kmR77fTmz8xon1V0BjZI6Z81wlhA0xERj/iI+18RxDBkzFfWuVZM5ISSjGlSa7CXgIGy8nAC+j2wBRI3Wr1a7h4C0umu9WjGddU0K9jeVMHRDphMtWjqw6XYFBOxK+wuAIhaImOVzFAFb1C2p5VuhyefRuELTYyuZcKLwbuKjjbVgJbK7G/s2axRWc3GARGT9Sem61FzfSDmqjolri9QGD2PsjVHpp0JXvi0Uh7e4lgEQEvYdr/1CfLFQxZKkmAyI+DKDUfPBHRVxCrdxSLuB+4Ns2vy3QlWx1y0x0qdZD290VQxOMbAqjgyYzLDnJ0dVDokICgKARPZkw4QvelmtcgtNCAToG7TR8MCChM2fHJB0SaUiwHF0uaMQfvdhB4vOOEjrORAeUZ1vdvE8QLpc44mRopxY3sl2h90nULYF6Rl+Og4wt0+0iUQy05SQ9uBkxjr1A5OSnNF2Yz51iqiFwQFZbMziIgeLOUVeUrMQwWoI3snmmWJhwDGNe6Imy52MM2P4Tw5Ot957I4SVYejUv7J3qtxNV0BYaZbYJW3TJ7bW8xNeLcVXf2H82HQfQAO/0OOHIOStIFu7j7TWsriO+yCsLYpgLWN3TSiHuEVQWDNljTa6kN2y5Bfz0rsP58Gv9Z96uxaXVmqCy0qvYHmU7/60wGyQe0lAnrIEIFtBWMcKtBBz7vZpvtBHWTkSHyW+iYd6GbGseqAdVuS2sKFYQ5xA032kLapfFtqReNkut/iONrlsqNKhqaCNB2er5j9NCq8yBt3/bosFwUV+G+ok59MQjMKMq2+6OdP2+LyQJsxSdOJTkFa6b5dyDWbMbiZg6MqCnAInVpilOeCAx9/SZbwi/AMkOdPtuIfThkz9VXaRT4Z rsmYaPPP FZJU28zHQ/+Tsq+K3FlYCsaR2OEaCcdhoq8LROTBcpSAL1RMhoGkaq7qpbcY3rXc/VHUPWxLmygW1CLOIo0dcxPcBmDvCCbSnu1rzt3/afuO52uGOpxaKNnP23W1la9vi71kNDepeaDlmf56OafAtGggCRfbS8xHc+8xZ2ZcAFt4Ph9S4wskzYcCV1BvUaDrmmp+lXaGxiKNMxaudalBpyy2awEWRQGvAU3eK8EQakZCsmtkkdZVlVpmsLkK2LMF/+hoUQ/w98g7xqwjWCrsQ3C0Cxwkm/v0A7s3PBbKdE976bSxNLrcxTV+kX6YqR3KlHn+AR25VvkKj2xYzcXuImoMH3nwCTPEgteO+uQhKMb/pp+o= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: By taking GENERIC_IOREMAP method, the generic generic_ioremap_prot(), generic_iounmap(), and their generic wrapper ioremap_prot(), ioremap() and iounmap() are all visible and available to arch. Arch needs to provide wrapper functions to override the generic versions if there's arch specific handling in its ioremap_prot(), ioremap() or iounmap(). This change will simplify implementation by removing duplicated code with generic_ioremap_prot() and generic_iounmap(), and has the equivalent functioality as before. Here, add wrapper functions ioremap_prot(), ioremap() and iounmap() for xtensa's special operation when ioremap() and iounmap(). Signed-off-by: Baoquan He Reviewed-by: Christoph Hellwig Reviewed-by: Mike Rapoport (IBM) Cc: Chris Zankel Cc: Max Filippov --- arch/xtensa/Kconfig | 1 + arch/xtensa/include/asm/io.h | 32 ++++++++------------ arch/xtensa/mm/ioremap.c | 58 +++++++++--------------------------- 3 files changed, 27 insertions(+), 64 deletions(-) diff --git a/arch/xtensa/Kconfig b/arch/xtensa/Kconfig index 2a51a466779f..a5488cc40f58 100644 --- a/arch/xtensa/Kconfig +++ b/arch/xtensa/Kconfig @@ -28,6 +28,7 @@ config XTENSA select GENERIC_LIB_UCMPDI2 select GENERIC_PCI_IOMAP select GENERIC_SCHED_CLOCK + select GENERIC_IOREMAP if MMU select HAVE_ARCH_AUDITSYSCALL select HAVE_ARCH_JUMP_LABEL if !XIP_KERNEL select HAVE_ARCH_KASAN if MMU && !XIP_KERNEL diff --git a/arch/xtensa/include/asm/io.h b/arch/xtensa/include/asm/io.h index a5b707e1c0f4..934e58399c8c 100644 --- a/arch/xtensa/include/asm/io.h +++ b/arch/xtensa/include/asm/io.h @@ -16,6 +16,7 @@ #include #include #include +#include #include @@ -24,22 +25,24 @@ #define PCI_IOBASE ((void __iomem *)XCHAL_KIO_BYPASS_VADDR) #ifdef CONFIG_MMU - -void __iomem *xtensa_ioremap_nocache(unsigned long addr, unsigned long size); -void __iomem *xtensa_ioremap_cache(unsigned long addr, unsigned long size); -void xtensa_iounmap(volatile void __iomem *addr); - /* - * Return the virtual address for the specified bus memory. + * I/O memory mapping functions. */ +void __iomem *ioremap_prot(phys_addr_t phys_addr, size_t size, + unsigned long prot); +#define ioremap_prot ioremap_prot +#define iounmap iounmap + static inline void __iomem *ioremap(unsigned long offset, unsigned long size) { if (offset >= XCHAL_KIO_PADDR && offset - XCHAL_KIO_PADDR < XCHAL_KIO_SIZE) return (void*)(offset-XCHAL_KIO_PADDR+XCHAL_KIO_BYPASS_VADDR); else - return xtensa_ioremap_nocache(offset, size); + return ioremap_prot(offset, size, + pgprot_val(pgprot_noncached(PAGE_KERNEL))); } +#define ioremap ioremap static inline void __iomem *ioremap_cache(unsigned long offset, unsigned long size) @@ -48,21 +51,10 @@ static inline void __iomem *ioremap_cache(unsigned long offset, && offset - XCHAL_KIO_PADDR < XCHAL_KIO_SIZE) return (void*)(offset-XCHAL_KIO_PADDR+XCHAL_KIO_CACHED_VADDR); else - return xtensa_ioremap_cache(offset, size); -} -#define ioremap_cache ioremap_cache + return ioremap_prot(offset, size, pgprot_val(PAGE_KERNEL)); -static inline void iounmap(volatile void __iomem *addr) -{ - unsigned long va = (unsigned long) addr; - - if (!(va >= XCHAL_KIO_CACHED_VADDR && - va - XCHAL_KIO_CACHED_VADDR < XCHAL_KIO_SIZE) && - !(va >= XCHAL_KIO_BYPASS_VADDR && - va - XCHAL_KIO_BYPASS_VADDR < XCHAL_KIO_SIZE)) - xtensa_iounmap(addr); } - +#define ioremap_cache ioremap_cache #endif /* CONFIG_MMU */ #include diff --git a/arch/xtensa/mm/ioremap.c b/arch/xtensa/mm/ioremap.c index a400188c16b9..8ca660b7ab49 100644 --- a/arch/xtensa/mm/ioremap.c +++ b/arch/xtensa/mm/ioremap.c @@ -6,60 +6,30 @@ */ #include -#include #include #include #include -static void __iomem *xtensa_ioremap(unsigned long paddr, unsigned long size, - pgprot_t prot) +void __iomem *ioremap_prot(phys_addr_t phys_addr, size_t size, + unsigned long prot) { - unsigned long offset = paddr & ~PAGE_MASK; - unsigned long pfn = __phys_to_pfn(paddr); - struct vm_struct *area; - unsigned long vaddr; - int err; - - paddr &= PAGE_MASK; - + unsigned long pfn = __phys_to_pfn((phys_addr)); WARN_ON(pfn_valid(pfn)); - size = PAGE_ALIGN(offset + size); - - area = get_vm_area(size, VM_IOREMAP); - if (!area) - return NULL; - - vaddr = (unsigned long)area->addr; - area->phys_addr = paddr; - - err = ioremap_page_range(vaddr, vaddr + size, paddr, prot); - - if (err) { - vunmap((void *)vaddr); - return NULL; - } - - flush_cache_vmap(vaddr, vaddr + size); - return (void __iomem *)(offset + vaddr); -} - -void __iomem *xtensa_ioremap_nocache(unsigned long addr, unsigned long size) -{ - return xtensa_ioremap(addr, size, pgprot_noncached(PAGE_KERNEL)); + return generic_ioremap_prot(phys_addr, size, __pgprot(prot)); } -EXPORT_SYMBOL(xtensa_ioremap_nocache); +EXPORT_SYMBOL(ioremap_prot); -void __iomem *xtensa_ioremap_cache(unsigned long addr, unsigned long size) +void iounmap(volatile void __iomem *addr) { - return xtensa_ioremap(addr, size, PAGE_KERNEL); -} -EXPORT_SYMBOL(xtensa_ioremap_cache); + unsigned long va = (unsigned long) addr; -void xtensa_iounmap(volatile void __iomem *io_addr) -{ - void *addr = (void *)(PAGE_MASK & (unsigned long)io_addr); + if ((va >= XCHAL_KIO_CACHED_VADDR && + va - XCHAL_KIO_CACHED_VADDR < XCHAL_KIO_SIZE) || + (va >= XCHAL_KIO_BYPASS_VADDR && + va - XCHAL_KIO_BYPASS_VADDR < XCHAL_KIO_SIZE)) + return; - vunmap(addr); + generic_iounmap(addr); } -EXPORT_SYMBOL(xtensa_iounmap); +EXPORT_SYMBOL(iounmap); From patchwork Thu Jul 6 15:45:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13303972 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1EE39EB64DC for ; Thu, 6 Jul 2023 15:47:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id ADED28D0001; Thu, 6 Jul 2023 11:47:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A8E1C8D0006; Thu, 6 Jul 2023 11:47:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 987928D0001; Thu, 6 Jul 2023 11:47:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 897A98D0001 for ; Thu, 6 Jul 2023 11:47:55 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 0F5E6140399 for ; Thu, 6 Jul 2023 15:47:55 +0000 (UTC) X-FDA: 80981617710.14.DAE4CE2 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf22.hostedemail.com (Postfix) with ESMTP id A71D0C0023 for ; Thu, 6 Jul 2023 15:47:52 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=brHtsX+w; spf=pass (imf22.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1688658472; a=rsa-sha256; cv=none; b=wVfRtJL+IsmqcgW+VFCnN0W5rMlFS4aDV767wUNQjy0hDfFiqF6ep/MaR2yzPZxN7UK9J1 dUB3I3CyoZVU3oUAEUslKae0lRBvCGy+qlApj0S5zYEAAuH1uUeeZTdPw+MFukIXTIAdc/ S/3yTdmUNIF3O1BsMf+N/BeKBOB9MYY= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=brHtsX+w; spf=pass (imf22.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1688658472; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=xVd2B5yrvoTei1eaDY2CI77gTkjY32uajA6qRNEVzX8=; b=FMrIKlrG2p6tRvVkzoqeEV3ibEGdfErX8hhLdIuxvmXqLqT0daHqKaCOWGAbehe43S8bHV I2kt9x9f7EYaLC5wcvBlCIvkNuq0NQt91yQ6VOl2M5Su3u2F38DewaAvqFXah0+MftBInH MU2CxqaJU3/z/56EYFww7lHG/ysxHUs= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1688658471; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xVd2B5yrvoTei1eaDY2CI77gTkjY32uajA6qRNEVzX8=; b=brHtsX+w0IEhZUtC2X0XiKqx2Vvx2+ViuOW+oqEJiiPOeEnfE917Wq25Z3BPJpqFnHrlqp 96BMp4yUgH1XKgkW1qvnY8GHV71LAHAsGv/kBGJMK8zctBFc97HNUE/axQ+LVimAAgq9uX 6ai0xHbVmaWdG0/3kKR0ayDKQBa0qUs= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-45-UEVRCT9GNaiGMAVdytZG4g-1; Thu, 06 Jul 2023 11:47:49 -0400 X-MC-Unique: UEVRCT9GNaiGMAVdytZG4g-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id DC89085A58A; Thu, 6 Jul 2023 15:47:47 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-39.pek2.redhat.com [10.72.12.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id 42C56F5CFB; Thu, 6 Jul 2023 15:47:38 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: akpm@linux-foundation.org, linux-mm@kvack.org, arnd@arndb.de, hch@lst.de, christophe.leroy@csgroup.eu, rppt@kernel.org, willy@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, shorne@gmail.com, David.Laight@ACULAB.COM, deller@gmx.de, nathan@kernel.org, glaubitz@physik.fu-berlin.de, Baoquan He , "James E.J. Bottomley" , linux-parisc@vger.kernel.org Subject: [PATCH v8 14/19] parisc: mm: Convert to GENERIC_IOREMAP Date: Thu, 6 Jul 2023 23:45:15 +0800 Message-Id: <20230706154520.11257-15-bhe@redhat.com> In-Reply-To: <20230706154520.11257-1-bhe@redhat.com> References: <20230706154520.11257-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: A71D0C0023 X-Stat-Signature: 55ja4upzr7btzrju5gnesngajwrfy6gc X-Rspam-User: X-HE-Tag: 1688658472-110862 X-HE-Meta: U2FsdGVkX19ZtItBNloeNDXxaPuqFxmah0bxJIsIwkINFCTms1MyxcBP5WJ9uRDQAwq2EizancO7yO2IVktALTBJ7YFS/v6VHuVFiL/MbssUuQYJ/hFbKrS4cbtMctI6AoMhl0jYu0Os/uA4roD9w+xiMfDFwqNAXdDNoZcE2L4snCpvs8DCYTRBS4UwGN29/ZjBp1laBbjvVcz+cWPbM7CeXSOGjxXrAxViZPVZLJ/zwAyPK2tTdG9wWj5moYZNBz+gQ4bUJdhgv0ER6gIvjx+Vv1/4PLyeoF9t38hUylXHvSAgib9r0X0xSg6ui4SALQkTZPdbd81kRTd7t+txGmzYSrPf96BRt1oomx2tkdBx44nJwvOqs65RJHBipCUhIfq1WegrXcRtyEytFf7SRyla3Tc/kPMzlnUgiIqK+gOmXzBnGJszz8IiszXlS2rKLuQbTb1emR0bP5gcxVUGFF/a8m13gqG6nJqqgQmsLXFsO5cneUm9NqbSwu0v/OPCdK2sYaaGq9gPzlGHUBEwDCWeerfiRTJ+NfQNr1iuUN+HwaSygaH9w4xfJKinBWcNzAdT0pR6vWg2MbgiGR+KXhakFoguF2Ek+T61v349qqDwBlIETDy/jMv7FiH9HsK9nln9CDRFFiaTwVw6VbknVG1q8kD8wWLFCmbO69t5k0MuL+1EdzgmgDhyoDixhcfhsbItghZJZzkuhe2/TBI73dJaQ0YJ1Rn13UfcTzLSdL3r7rRsFRpFq9oMxay8XERRz+kRFYFL2hRHSO9GDR6orVgTpzQpYaoHtDoKsHJUaTmKwALksujHQ2o1mFB95nn72+/wNj/GO/IqAQearlWqXxLZMFhO0UKodSNDukg2yvCCUcn9Rc4yVbb/3zUTqOYLQw2LXpu4biAF7N3PVT+NVyxScnKsbGnzGXrxcfrafbAZ38krSTJmZcyQRt1dDrtGKsbrop6ubfbRbFWG5Vi JjzxFeCO PfJcGbcxAs4eXIic8Hk2Xsk0JrHZ6omTId9ihnLXJiLez9yqa0G4fxtQp39Tl/wPX9KnYA5h3Qv9AJjRzHcj+gcEuGE+kOi010Yr6xrd9rW6qNoHG9A7q49RrfRzQMF8MO/ztxQ15wkPMVoH3lsHj5CDezFn2/JmibUI9gcafPpalR0tcsoKGO//qkUx2KfEMVk/ofGB4Xf74QyJrXjFiwMS5eGwTSY0XShOsVMKGiLac6ituIQ8u9aIIRsowEcBrvwITVZALXzTVkfB4fwHPR0VckL8tSTSFRuExpHgP+fddyucUQeA9HvdilAvPYb7DGnjV/F7OQlOBZEcEfmDnKkiT8A== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: By taking GENERIC_IOREMAP method, the generic generic_ioremap_prot(), generic_iounmap(), and their generic wrapper ioremap_prot(), ioremap() and iounmap() are all visible and available to arch. Arch needs to provide wrapper functions to override the generic versions if there's arch specific handling in its ioremap_prot(), ioremap() or iounmap(). This change will simplify implementation by removing duplicated code with generic_ioremap_prot() and generic_iounmap(), and has the equivalent functioality as before. Here, add wrapper function ioremap_prot() for parisc's special operation when iounmap(). Signed-off-by: Baoquan He Reviewed-by: Christoph Hellwig Reviewed-by: Mike Rapoport (IBM) Acked-by: Helge Deller Cc: "James E.J. Bottomley" Cc: Helge Deller Cc: linux-parisc@vger.kernel.org --- arch/parisc/Kconfig | 1 + arch/parisc/include/asm/io.h | 15 ++++++--- arch/parisc/mm/ioremap.c | 62 +++--------------------------------- 3 files changed, 15 insertions(+), 63 deletions(-) diff --git a/arch/parisc/Kconfig b/arch/parisc/Kconfig index 4cb46d5c64a2..4cda9f0a3277 100644 --- a/arch/parisc/Kconfig +++ b/arch/parisc/Kconfig @@ -36,6 +36,7 @@ config PARISC select GENERIC_ATOMIC64 if !64BIT select GENERIC_IRQ_PROBE select GENERIC_PCI_IOMAP + select GENERIC_IOREMAP select ARCH_HAVE_NMI_SAFE_CMPXCHG select GENERIC_SMP_IDLE_THREAD select GENERIC_ARCH_TOPOLOGY if SMP diff --git a/arch/parisc/include/asm/io.h b/arch/parisc/include/asm/io.h index c05e781be2f5..366537042465 100644 --- a/arch/parisc/include/asm/io.h +++ b/arch/parisc/include/asm/io.h @@ -125,12 +125,17 @@ static inline void gsc_writeq(unsigned long long val, unsigned long addr) /* * The standard PCI ioremap interfaces */ -void __iomem *ioremap(unsigned long offset, unsigned long size); -#define ioremap_wc ioremap -#define ioremap_uc ioremap -#define pci_iounmap pci_iounmap +#define ioremap_prot ioremap_prot + +#define _PAGE_IOREMAP (_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | \ + _PAGE_ACCESSED | _PAGE_NO_CACHE) -extern void iounmap(const volatile void __iomem *addr); +#define ioremap_wc(addr, size) \ + ioremap_prot((addr), (size), _PAGE_IOREMAP) +#define ioremap_uc(addr, size) \ + ioremap_prot((addr), (size), _PAGE_IOREMAP) + +#define pci_iounmap pci_iounmap void memset_io(volatile void __iomem *addr, unsigned char val, int count); void memcpy_fromio(void *dst, const volatile void __iomem *src, int count); diff --git a/arch/parisc/mm/ioremap.c b/arch/parisc/mm/ioremap.c index 345ff0b66499..fd996472dfe7 100644 --- a/arch/parisc/mm/ioremap.c +++ b/arch/parisc/mm/ioremap.c @@ -13,25 +13,9 @@ #include #include -/* - * Generic mapping function (not visible outside): - */ - -/* - * Remap an arbitrary physical address space into the kernel virtual - * address space. - * - * NOTE! We need to allow non-page-aligned mappings too: we will obviously - * have to convert them into an offset in a page-aligned mapping, but the - * caller shouldn't need to know that small detail. - */ -void __iomem *ioremap(unsigned long phys_addr, unsigned long size) +void __iomem *ioremap_prot(phys_addr_t phys_addr, size_t size, + unsigned long prot) { - void __iomem *addr; - struct vm_struct *area; - unsigned long offset, last_addr; - pgprot_t pgprot; - #ifdef CONFIG_EISA unsigned long end = phys_addr + size - 1; /* Support EISA addresses */ @@ -40,11 +24,6 @@ void __iomem *ioremap(unsigned long phys_addr, unsigned long size) phys_addr |= F_EXTEND(0xfc000000); #endif - /* Don't allow wraparound or zero size */ - last_addr = phys_addr + size - 1; - if (!size || last_addr < phys_addr) - return NULL; - /* * Don't allow anybody to remap normal RAM that we're using.. */ @@ -62,39 +41,6 @@ void __iomem *ioremap(unsigned long phys_addr, unsigned long size) } } - pgprot = __pgprot(_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | - _PAGE_ACCESSED | _PAGE_NO_CACHE); - - /* - * Mappings have to be page-aligned - */ - offset = phys_addr & ~PAGE_MASK; - phys_addr &= PAGE_MASK; - size = PAGE_ALIGN(last_addr + 1) - phys_addr; - - /* - * Ok, go for it.. - */ - area = get_vm_area(size, VM_IOREMAP); - if (!area) - return NULL; - - addr = (void __iomem *) area->addr; - if (ioremap_page_range((unsigned long)addr, (unsigned long)addr + size, - phys_addr, pgprot)) { - vunmap(addr); - return NULL; - } - - return (void __iomem *) (offset + (char __iomem *)addr); -} -EXPORT_SYMBOL(ioremap); - -void iounmap(const volatile void __iomem *io_addr) -{ - unsigned long addr = (unsigned long)io_addr & PAGE_MASK; - - if (is_vmalloc_addr((void *)addr)) - vunmap((void *)addr); + return generic_ioremap_prot(phys_addr, size, __pgprot(prot)); } -EXPORT_SYMBOL(iounmap); +EXPORT_SYMBOL(ioremap_prot); From patchwork Thu Jul 6 15:45:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13303973 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id D94A0EB64D9 for ; Thu, 6 Jul 2023 15:48:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 734F68D0005; Thu, 6 Jul 2023 11:48:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6E4FC8D0003; Thu, 6 Jul 2023 11:48:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 585F78D0005; Thu, 6 Jul 2023 11:48:10 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 46F4D8D0003 for ; Thu, 6 Jul 2023 11:48:10 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 1FB0F140399 for ; Thu, 6 Jul 2023 15:48:10 +0000 (UTC) X-FDA: 80981618340.24.CA291DA Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf09.hostedemail.com (Postfix) with ESMTP id 7F7C714001A for ; Thu, 6 Jul 2023 15:48:03 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=IQidm1EC; spf=pass (imf09.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1688658483; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=SboB+Gem+bQaB39EZZBPE5ZHPttNaa4nwbopj4kdit4=; b=L2ly8RMbiKgwsuf8/oM+Ft0qzbBK9H2BSwholkBjqe/2+46YMZyicU3e5Co43nIIcCcHNG CW52pWmLu9Xx9CyYHs3opEy+1zjT7ld24A58oef7sVCd+2HonJy/ebpRnADpLANeyDEqYB iUw8ReFQGci1vK11UaPWLG93FaiKQi4= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1688658483; a=rsa-sha256; cv=none; b=PXbJKtXnKE4vxMRd4d5fGTRHykJHMhiuRdDzOHS5Wg0B7CtDev0ZIp5IhjDNk17PaxNjv/ GE1qnTqHkTqDyNSzOf/fPUrmPo8jqjZgw7CqxOA+ca0g76rVSbQmp9MjBQrqTNqENhA3wb zJWxNJxFoiFz+UNYgBPRzJQteEKaeeU= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=IQidm1EC; spf=pass (imf09.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1688658482; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SboB+Gem+bQaB39EZZBPE5ZHPttNaa4nwbopj4kdit4=; b=IQidm1EC58/vjDq6gQE+xUk7FunNqDhtYSJvhh4A3TjvCB/QeDtpdKGtArpqCuha6UPnFz N0vGco5yBHhv5yIAWvEuiggPXz7OuCYkxfafs5vsCbfH8T8ukZUHQ0E/1E1zR3F99nR7vz xUnbwtiJWaLD3DwG8yzas8cdvgwAX2I= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-102-Zgylzl54Oz6H0HNz3490IA-1; Thu, 06 Jul 2023 11:47:57 -0400 X-MC-Unique: Zgylzl54Oz6H0HNz3490IA-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 318981044591; Thu, 6 Jul 2023 15:47:56 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-39.pek2.redhat.com [10.72.12.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id C303DF5CF0; Thu, 6 Jul 2023 15:47:48 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: akpm@linux-foundation.org, linux-mm@kvack.org, arnd@arndb.de, hch@lst.de, christophe.leroy@csgroup.eu, rppt@kernel.org, willy@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, shorne@gmail.com, David.Laight@ACULAB.COM, deller@gmx.de, nathan@kernel.org, glaubitz@physik.fu-berlin.de, Baoquan He Subject: [PATCH v8 15/19] mm/ioremap: Consider IOREMAP space in generic ioremap Date: Thu, 6 Jul 2023 23:45:16 +0800 Message-Id: <20230706154520.11257-16-bhe@redhat.com> In-Reply-To: <20230706154520.11257-1-bhe@redhat.com> References: <20230706154520.11257-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Rspamd-Queue-Id: 7F7C714001A X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: yoqbm5ufrpi9tk6jgq1hg8ac5zouwuj9 X-HE-Tag: 1688658483-751055 X-HE-Meta: U2FsdGVkX18vHMpwxEXTmsAX9V1BM03BQtk3oeaGNiC6WMu31QH2yEg3Uv10o9fLK2PRBtffd7EqcsSurQW4N969AjlMlG5oC7EkyWm5owTF1sCa5BqRHPHiNEz1N7XwhchjeZwkstM38lh8/HC5Iyzjwl4wKgGIWxbwFb+N/G53FWakJSv0gudpHIJOl7bZI9OA1FPTU/Xtzz/7Hz/kGDOX8TMq3QHas2yMoPyULrGi9EFgvvLvNrkJGhJWsjnSNgVtfsF/S8Oko6xwbaAP+sUZxIW062DyOfTK/JBtuRrRNqiIHoligGlO2txB9ymxayqJ6Ac0bFqWiSDy5/Ty6WdBU/eo2LWzAt31XuEx88kJ2Cra2ksPI5vVaZbv2fz5eUQ9UP7iHfHnn4WmWGnMMziic7fdAipdQcRnRETRtgRN5UDm6iWXZEJhBkF1AXJ5NuNoK75SPr4aNP18R7ygho5yxJVTWT0kdVRL8NzHlR+98YD+/HRO/moC1mq7q8q4Lh089WKSxEpOsjRINzaMfFFQKRaZEt5wwMBMJWeVAyRGOJmY7mGyTvoHrJegePYdFjanF3MPMgIHGbD+VXRz3xnKeEp4pEUKg2hcIwyAtGKuU6LmeHDL4O+jFeZ0h27GwsokuwE+EB5tsuU/8JeFSfJlYHg51kHj7zMN7KUZIoj3k9kDDSmgaCPNfxRg8StUecjZ8vJFbxR+uRWzpZd1Ptc7iQY8bkFdVuF07v4Sb7HN48FntgWGpE5qZReO/DCeQkL0+JujhAMchY2Cq1+macA+gzEVdZ40dLqMUwpVR8qferdtaycaQvci4rSIx/jvgnAwEzrh/EduRHTlHif7ndR8YwGQ67YhjlAvHFSxP7kOgh3VaSY+CtT5Kf7gpTywdLo+1qw8ScWL6sZYd4kPtduN7nMR2bjNcVxvNs1+Avesa4Q00MohImp+6hYlTUC9IZF7UXmYfXOI5wDxl8a wC5zzmyP SQYL7siwUD6UCbr1eynkrQfq6fuxs+WaJp4AtbgalxTrTEyIYfevQikgP+6wUNmWdIniv+wnnKZMY9VmNWlk/cgZqMMnq03RY0JV+M/hLZVBJDnfifWvdOCwr6SLqe+k7x0aQ0Ebx+La2W2rEuvuN2VhYSsIxULSQsH/6r71Rxp2k6ULMhzJecAdG7GVJBlzIL+CwjpaWe3TAFNBH5uxMdEOSNvYnZG+DdbBYhy2HM/eJROg= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Christophe Leroy Architectures like powerpc have a dedicated space for IOREMAP mappings. If so, use it in generic_ioremap_prot(). Signed-off-by: Christophe Leroy Signed-off-by: Baoquan He Reviewed-by: Christoph Hellwig --- mm/ioremap.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/mm/ioremap.c b/mm/ioremap.c index 86b82ec27d2b..68d9895144ad 100644 --- a/mm/ioremap.c +++ b/mm/ioremap.c @@ -11,6 +11,15 @@ #include #include +/* + * Ioremap often, but not always uses the generic vmalloc area. E.g on + * Power ARCH, it could have different ioremap space. + */ +#ifndef IOREMAP_START +#define IOREMAP_START VMALLOC_START +#define IOREMAP_END VMALLOC_END +#endif + void __iomem *generic_ioremap_prot(phys_addr_t phys_addr, size_t size, pgprot_t prot) { @@ -35,8 +44,8 @@ void __iomem *generic_ioremap_prot(phys_addr_t phys_addr, size_t size, if (!ioremap_allowed(phys_addr, size, pgprot_val(prot))) return NULL; - area = get_vm_area_caller(size, VM_IOREMAP, - __builtin_return_address(0)); + area = __get_vm_area_caller(size, VM_IOREMAP, IOREMAP_START, + IOREMAP_END, __builtin_return_address(0)); if (!area) return NULL; vaddr = (unsigned long)area->addr; @@ -66,7 +75,7 @@ void generic_iounmap(volatile void __iomem *addr) if (!iounmap_allowed(vaddr)) return; - if (is_vmalloc_addr(vaddr)) + if (is_ioremap_addr(vaddr)) vunmap(vaddr); } From patchwork Thu Jul 6 15:45:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13303974 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id C3012EB64DD for ; Thu, 6 Jul 2023 15:48:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 53B7E8D0006; Thu, 6 Jul 2023 11:48:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 44F1A8D0003; Thu, 6 Jul 2023 11:48:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 33CAE8D0006; Thu, 6 Jul 2023 11:48:11 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 10ADB8D0003 for ; Thu, 6 Jul 2023 11:48:11 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id CEDE040432 for ; Thu, 6 Jul 2023 15:48:10 +0000 (UTC) X-FDA: 80981618340.15.11DEFE5 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf14.hostedemail.com (Postfix) with ESMTP id F1EAC100029 for ; Thu, 6 Jul 2023 15:48:07 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=RSD+4cit; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf14.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1688658488; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=OXVHYJC8bujxYB4NxHtHfdw+gECptwECGyaOXWJ60Bo=; b=UQU45uX8WCcaAaf5a9y7Icz6x2K3sPflgCTfLIi8wSPeTGWmJ5UYCQsHhJ2MDc9/ro04Zm F6qC4VPe5MnEivQgicUzRG9mnidsu2cG+BlbfUFnK94B+6BgRUo/DjbHiqUEgdcNqdwiKm DqSd+CAV68/gabnlqnwjm/jPpebAzW8= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=RSD+4cit; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf14.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1688658488; a=rsa-sha256; cv=none; b=MlotLN84lUuhCPZG+2rPyGNYNceL96VBV4w6onC417bSXzah/D0iItemyp/1XMDSm4a0cG qX/dUIKirGyn7i+Kuh5kX7/WxIKNwnn+SlRNzICLOs2N2FcaRiInYPA5ZHWt7srDdnIrzy cg86cmMZ5m77xfD5z64Iv9lpbgB9ih4= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1688658487; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=OXVHYJC8bujxYB4NxHtHfdw+gECptwECGyaOXWJ60Bo=; b=RSD+4citm7j/96P8L/qvZ1P7NDtEP070qST5zOk7OBBLLOsfsVpNm5cayqsKuTT1PT7E5y B/VIbvqlq3vN2EXhVVM2AuTvTucNFxZ663HPvM/mLh3rQFu8owBmh4TZEeo7jisRuaRQa9 4v0J+akIYRj0aABJEMsvd6PAy+V1Qtw= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-411-XuV2aqowPm2l_i_JZ1GQaw-1; Thu, 06 Jul 2023 11:48:05 -0400 X-MC-Unique: XuV2aqowPm2l_i_JZ1GQaw-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C64C52815E3D; Thu, 6 Jul 2023 15:48:04 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-39.pek2.redhat.com [10.72.12.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id F3DFEF5CF0; Thu, 6 Jul 2023 15:47:56 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: akpm@linux-foundation.org, linux-mm@kvack.org, arnd@arndb.de, hch@lst.de, christophe.leroy@csgroup.eu, rppt@kernel.org, willy@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, shorne@gmail.com, David.Laight@ACULAB.COM, deller@gmx.de, nathan@kernel.org, glaubitz@physik.fu-berlin.de, Baoquan He Subject: [PATCH v8 16/19] mm: move is_ioremap_addr() into new header file Date: Thu, 6 Jul 2023 23:45:17 +0800 Message-Id: <20230706154520.11257-17-bhe@redhat.com> In-Reply-To: <20230706154520.11257-1-bhe@redhat.com> References: <20230706154520.11257-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: F1EAC100029 X-Stat-Signature: 735z6yme48oowy7sawmu8qoh7nti8ebh X-Rspam-User: X-HE-Tag: 1688658487-215982 X-HE-Meta: U2FsdGVkX19Bt7Uml32xh9+cuBHv2R0cx2Y745lLHiUo5sweAhv/FBhKbrAV8aGIERts8iEHNeiWAXqfdvmkIRqc6BLftYuWeta+vAiJ8GZ1nSz0fY3uuazN0YkBq26uwb9/RIHrrIj4gWq0pmL1enoTPBCsI1YTJV9lwStXWpL08tCDSG+hjKydIiU39ipYe78o/+cRXqdWyOdGc8z7/LEnpKwaXrLFIoyQmihdw/HO7xO1RLG496Vlk/1zsUV8Q0gOwCbsZyFPBPMKZfONecq2ecBIquZTgKWNM/6K59Aj6rM32lhjJka7pN1qoY1t1QddQJBi1C4qcPZRbDepB9ayCIALe1GNgEsutmjW6UqGqP0+q6qV8w2ol52yYenR5bGRwJ0XNBybJhrb+V98rPtilcVO5MMGuidNC4nf8vjmceYPjwyFsTOPKr6uQqvrdF8ji9Mp0Z4l6zbeFnPFMW6ioRNubRdbGoIma3G4BhQpCEgtn2Hab4n6YQPZ0HOD1v9pe/xFBqIGZjzbx7d5w4q5PsbPc2vmYKUICnvS0h9gYvPQr5u1w6ItFSaPBqVx+cF7eiXlv+rC4GAhRTKM82KWVOEzlnuqbZ0LwBPv1CiS8hKTIwQ2KO8ddrMNjHCRTY+winEo7aLU208CjwFLDOEqsTjn9dPQ8N0cEjF6rNtgy2tQ3hev+44SGrnUYW71qHQzSFp0isuQBuE6zVljLgNtrAHN/iTUz/a2G8az5n3ghUfmv5p9K3THsoDiHEzTIPiNSUDId+4lSXmuIDb2SeW6MJXLE2uAaDPC9VAMYponIV+1qR6qWboStKPiLUwdasG6qS3bARRCXcfzb9bRU//oI73hp/EH5+NUflWLIOu4vu7eqbvK41U5O94KSnJV4d5Jgc5j/nibqjCz35nQknGcoRRGE9GHOabURRadt0m5xS2av1xM5soh+am4qyr9Jtcd9oN9SKYn2PcXL90 CiGwN90t NA0tVd/2oPdpmPhMyvIowAqqLsgDESa3DCvnRCtsBVQUTLSsbRkJQHGaj4CytNmS3I1rMix+jDlcv+Eav2R6EWcQjEONSsNF1oM4JF7hANGf8Z2fGAO06uxruJ6Yu3HtOOoqrQSTyHQFSoUaEVGo5ksk3H2CU/AlOCBBS24f0FtgGY6C7qVq6ox31ucljnZfJQPm8r8jfMV7Lvn2/6gEI1v4u6JxhF5jvKsrB X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Now is_ioremap_addr() is only used in kernel/iomem.c and gonna be used in mm/ioremap.c. Move it into its own new header file linux/ioremap.h. Suggested-by: Christoph Hellwig Signed-off-by: Baoquan He Reviewed-by: Christoph Hellwig --- v7->v8: Fix conflict when rebasing to the latest linus's tree, it's caused by commit ef104443bffa ("procfs: consolidate arch_report_meminfo declaration") in file arch/powerpc/include/asm/pgtable.h. arch/powerpc/include/asm/pgtable.h | 10 ---------- include/linux/ioremap.h | 30 ++++++++++++++++++++++++++++++ include/linux/mm.h | 5 ----- kernel/iomem.c | 1 + mm/ioremap.c | 10 +--------- 5 files changed, 32 insertions(+), 24 deletions(-) create mode 100644 include/linux/ioremap.h diff --git a/arch/powerpc/include/asm/pgtable.h b/arch/powerpc/include/asm/pgtable.h index 6a88bfdaa69b..445a22987aa3 100644 --- a/arch/powerpc/include/asm/pgtable.h +++ b/arch/powerpc/include/asm/pgtable.h @@ -157,16 +157,6 @@ static inline pgtable_t pmd_pgtable(pmd_t pmd) return (pgtable_t)pmd_page_vaddr(pmd); } -#ifdef CONFIG_PPC64 -#define is_ioremap_addr is_ioremap_addr -static inline bool is_ioremap_addr(const void *x) -{ - unsigned long addr = (unsigned long)x; - - return addr >= IOREMAP_BASE && addr < IOREMAP_END; -} -#endif /* CONFIG_PPC64 */ - #endif /* __ASSEMBLY__ */ #endif /* _ASM_POWERPC_PGTABLE_H */ diff --git a/include/linux/ioremap.h b/include/linux/ioremap.h new file mode 100644 index 000000000000..f0e99fc7dd8b --- /dev/null +++ b/include/linux/ioremap.h @@ -0,0 +1,30 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _LINUX_IOREMAP_H +#define _LINUX_IOREMAP_H + +#include +#include + +#if defined(CONFIG_HAS_IOMEM) || defined(CONFIG_GENERIC_IOREMAP) +/* + * Ioremap often, but not always uses the generic vmalloc area. E.g on + * Power ARCH, it could have different ioremap space. + */ +#ifndef IOREMAP_START +#define IOREMAP_START VMALLOC_START +#define IOREMAP_END VMALLOC_END +#endif +static inline bool is_ioremap_addr(const void *x) +{ + unsigned long addr = (unsigned long)kasan_reset_tag(x); + + return addr >= IOREMAP_START && addr < IOREMAP_END; +} +#else +static inline bool is_ioremap_addr(const void *x) +{ + return false; +} +#endif + +#endif /* _LINUX_IOREMAP_H */ diff --git a/include/linux/mm.h b/include/linux/mm.h index 2dd73e4f3d8e..2bac9ec3527e 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -1055,11 +1055,6 @@ unsigned long vmalloc_to_pfn(const void *addr); * On nommu, vmalloc/vfree wrap through kmalloc/kfree directly, so there * is no special casing required. */ - -#ifndef is_ioremap_addr -#define is_ioremap_addr(x) is_vmalloc_addr(x) -#endif - #ifdef CONFIG_MMU extern bool is_vmalloc_addr(const void *x); extern int is_vmalloc_or_module_addr(const void *x); diff --git a/kernel/iomem.c b/kernel/iomem.c index 62c92e43aa0d..9682471e6471 100644 --- a/kernel/iomem.c +++ b/kernel/iomem.c @@ -3,6 +3,7 @@ #include #include #include +#include #ifndef ioremap_cache /* temporary while we convert existing ioremap_cache users to memremap */ diff --git a/mm/ioremap.c b/mm/ioremap.c index 68d9895144ad..a21a6c9fa5ab 100644 --- a/mm/ioremap.c +++ b/mm/ioremap.c @@ -10,15 +10,7 @@ #include #include #include - -/* - * Ioremap often, but not always uses the generic vmalloc area. E.g on - * Power ARCH, it could have different ioremap space. - */ -#ifndef IOREMAP_START -#define IOREMAP_START VMALLOC_START -#define IOREMAP_END VMALLOC_END -#endif +#include void __iomem *generic_ioremap_prot(phys_addr_t phys_addr, size_t size, pgprot_t prot) From patchwork Thu Jul 6 15:45:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13303975 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id B8A17EB64DC for ; Thu, 6 Jul 2023 15:48:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 55F7F8D0007; Thu, 6 Jul 2023 11:48:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5107C8D0003; Thu, 6 Jul 2023 11:48:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3FF1C8D0007; Thu, 6 Jul 2023 11:48:31 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 3074A8D0003 for ; Thu, 6 Jul 2023 11:48:31 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 05972120434 for ; Thu, 6 Jul 2023 15:48:30 +0000 (UTC) X-FDA: 80981619222.02.CFCF896 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf24.hostedemail.com (Postfix) with ESMTP id AEB1518001F for ; Thu, 6 Jul 2023 15:48:27 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=NcMKb6vg; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf24.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1688658507; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=HWqxM4GZuS9Wh/EiDlklJiCP+B1QvwXEzK3M+6mNoD4=; b=4FLFCvn18ot2ZiqVxExGh3i678yff2yWonYb39YuWbHYrFXzppWqf84iNl5LWOrWOUuv8S p5iwGsVWR36bLHKAS7HnntlChGVWM9Q4gryvnDF7pu5uqmglogODjX871X0Mi11VALAWX/ Z6iA/xAMOfj03ZIU+jQJNpTn7jazN3o= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=NcMKb6vg; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf24.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1688658507; a=rsa-sha256; cv=none; b=LeO/V761Z1igDeT/Xdat87shUfbOD/iT9TbUxrZ9NpDp84pjyVMtgKWD24fn9cvDPY+DOp fQVD4vo3qnxQvWIG2eVJU9VQbZYIJ0zXnsSPRIULRpHQcXVxjEAhhsove7v5OnKjJq3Rfo nqhXo+s5VUCI1XtMjsTPTUQ8P+uvSA8= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1688658507; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HWqxM4GZuS9Wh/EiDlklJiCP+B1QvwXEzK3M+6mNoD4=; b=NcMKb6vg6rGTuRuAVqGtT/JNPWzwrfOPMCnR8O4c59UgCLIP6w3kvn07I7OHz9ffJUmBZ+ IlbHGQ7uUXerX9K6e6F0q2hq7/RgHSqMqhJh3SLCBNpr5rNrgBl0Qsok08oK5k+dK66Cjy DoKWbSKw0jP30aZfSgqM2ZkniFMYm3Q= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-132-UuzblcGlOgKAFhNrs83w1g-1; Thu, 06 Jul 2023 11:48:15 -0400 X-MC-Unique: UuzblcGlOgKAFhNrs83w1g-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C74BE2815E25; Thu, 6 Jul 2023 15:48:14 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-39.pek2.redhat.com [10.72.12.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9200EF6401; Thu, 6 Jul 2023 15:48:05 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: akpm@linux-foundation.org, linux-mm@kvack.org, arnd@arndb.de, hch@lst.de, christophe.leroy@csgroup.eu, rppt@kernel.org, willy@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, shorne@gmail.com, David.Laight@ACULAB.COM, deller@gmx.de, nathan@kernel.org, glaubitz@physik.fu-berlin.de, Baoquan He , Michael Ellerman , Nicholas Piggin , linuxppc-dev@lists.ozlabs.org Subject: [PATCH v8 17/19] powerpc: mm: Convert to GENERIC_IOREMAP Date: Thu, 6 Jul 2023 23:45:18 +0800 Message-Id: <20230706154520.11257-18-bhe@redhat.com> In-Reply-To: <20230706154520.11257-1-bhe@redhat.com> References: <20230706154520.11257-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: AEB1518001F X-Stat-Signature: e1f9qwazzbzitbhjurgwjsooq43j6tf6 X-HE-Tag: 1688658507-485999 X-HE-Meta: U2FsdGVkX1/FDJGEvHQvlngfGKQAhtigN/UZsccAS9z4jIjXL9xZKt2hsDo/JbCNBEENSyiu+H5rMKj9NkdjJ+kdC0w2t3wiuY1gQOWv6zR9JnE8IPAfwYgctd7wVjE4WstsngG5hAftL09x7QW7hndwNtxP2BI9HNJzs3NBTgnveYToDMVsoN5qOjZeeAAhF5Ut72WiUepV3FVWxXrLNlZjCbrFhYZCypHItWjFjBuIq3bj3lhnBmbm8hB+NA//hYZuJNoewAGIhtdeixxCylsgmNaC0jClgnAPp8uKzT9iU+ExQtqZBudkp7qteGmLi1I2xhGHh953fLCwsSw4SIVnMnJ6P6P3UWRxCLyKPyaRXSQEcjs2zHQGrvm77VNhoqYSrRxdo+GEpvmVEjmn98j1Pd8CAw5Mq3Dod2ttztM4VU6v72Q0YuABc3ewYA3tmVYYICEC6DX5BmwLR20CcN4s1Imqre6MDAUhkq0vbPURZxIHPeJq9EziEPgF/xsjbJOWxLI9/Jm4UdbwdVGNGRCjNuLi7INgphhkU5gTjGoPVrnjtvoTjrOIKiZCU6vNf9Xe28cy0omgw+MNpHp8QUecy+6skf96aQS7eweMG/sNIjUChzG7pgig1Sw1wnoeQE66sSmDcRzi7/rwQeOGxP8DebmjbUt7a/dJdAj/ZqJHcwG5L8i7OTBy2PHYC+LWK6g3t0X+OT5XWDkdeSHbdi3+/DEGFRL4opp8dL9xJXDoByMl9cymMhD058fU3vPtFHjGpMi7+390qPcjfknvfErbIuBilWwfpiP2OEIWapeRF7KDqa7X3GFr5oydq9oY7hK/tY/YO3xIFa/QybTFnatoXnn2qDK3RI17nL0M6tJJfNOO/TaYTL6IbuKZcDzwCFz4DL1BZkfc+YSCFVcGXeFMSDF5zlh2f/IW1fYGyQBgFSY8Tj0LIRei/4iVWTEzbmDuVf5ldq1tG63BJVZ Eg1frfCi hIZ6GF+Wo+hdI21leLXwAsX7Fqihj1WvY6pFEskiVojb8pWKJVl9qh7kjrmfVBMcprHkoJYAyRiRX2ibB4f4OLN6twfPL0Q6gVWASFnHtqbViITadGIHZdjdDuFl3qJ394Sz22LWZe6jcv9OWh5/oeniu/ErNjvxqhuTWh88EdH1vnXut3Yw//ap/cJ+tHdHT1Ms+2Gartq4HNePXo9OVQ4LjUT8fxseW4V4QIf4n0VZTVWbWoyhRlDVxjD5rpPtBDgWw/GH8OB2ZZaKewQm/NGk56zphnA+oObpA14G/l29SSR+uWKBiKnzRFrIZCphq19EunES5JJwBp1ZZqBidfZQl5vRIuYR5DRu7M40YsHJLG7ucxHx0OIYHWLBCtUUd9OcC0QPrPIJPQJdUEAOc5hCNsJ8PEwO5dhwp3/vsr0rAWGw= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Christophe Leroy By taking GENERIC_IOREMAP method, the generic generic_ioremap_prot(), generic_iounmap(), and their generic wrapper ioremap_prot(), ioremap() and iounmap() are all visible and available to arch. Arch needs to provide wrapper functions to override the generic versions if there's arch specific handling in its ioremap_prot(), ioremap() or iounmap(). This change will simplify implementation by removing duplicated code with generic_ioremap_prot() and generic_iounmap(), and has the equivalent functioality as before. Here, add wrapper functions ioremap_prot() and iounmap() for powerpc's special operation when ioremap() and iounmap(). Signed-off-by: Christophe Leroy Signed-off-by: Baoquan He Reviewed-by: Christoph Hellwig Reviewed-by: Mike Rapoport (IBM) Cc: Michael Ellerman Cc: Nicholas Piggin Cc: linuxppc-dev@lists.ozlabs.org --- arch/powerpc/Kconfig | 1 + arch/powerpc/include/asm/io.h | 8 +++----- arch/powerpc/mm/ioremap.c | 26 +------------------------- arch/powerpc/mm/ioremap_32.c | 19 +++++++++---------- arch/powerpc/mm/ioremap_64.c | 12 ++---------- 5 files changed, 16 insertions(+), 50 deletions(-) diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index 0b1172cbeccb..9222c138c457 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig @@ -193,6 +193,7 @@ config PPC select GENERIC_CPU_VULNERABILITIES if PPC_BARRIER_NOSPEC select GENERIC_EARLY_IOREMAP select GENERIC_GETTIMEOFDAY + select GENERIC_IOREMAP select GENERIC_IRQ_SHOW select GENERIC_IRQ_SHOW_LEVEL select GENERIC_PCI_IOMAP if PCI diff --git a/arch/powerpc/include/asm/io.h b/arch/powerpc/include/asm/io.h index 67a3fb6de498..0732b743e099 100644 --- a/arch/powerpc/include/asm/io.h +++ b/arch/powerpc/include/asm/io.h @@ -889,8 +889,8 @@ static inline void iosync(void) * */ extern void __iomem *ioremap(phys_addr_t address, unsigned long size); -extern void __iomem *ioremap_prot(phys_addr_t address, unsigned long size, - unsigned long flags); +#define ioremap ioremap +#define ioremap_prot ioremap_prot extern void __iomem *ioremap_wc(phys_addr_t address, unsigned long size); #define ioremap_wc ioremap_wc @@ -904,14 +904,12 @@ void __iomem *ioremap_coherent(phys_addr_t address, unsigned long size); #define ioremap_cache(addr, size) \ ioremap_prot((addr), (size), pgprot_val(PAGE_KERNEL)) -extern void iounmap(volatile void __iomem *addr); +#define iounmap iounmap void __iomem *ioremap_phb(phys_addr_t paddr, unsigned long size); int early_ioremap_range(unsigned long ea, phys_addr_t pa, unsigned long size, pgprot_t prot); -void __iomem *do_ioremap(phys_addr_t pa, phys_addr_t offset, unsigned long size, - pgprot_t prot, void *caller); extern void __iomem *__ioremap_caller(phys_addr_t, unsigned long size, pgprot_t prot, void *caller); diff --git a/arch/powerpc/mm/ioremap.c b/arch/powerpc/mm/ioremap.c index 4f12504fb405..705e8e8ffde4 100644 --- a/arch/powerpc/mm/ioremap.c +++ b/arch/powerpc/mm/ioremap.c @@ -41,7 +41,7 @@ void __iomem *ioremap_coherent(phys_addr_t addr, unsigned long size) return __ioremap_caller(addr, size, prot, caller); } -void __iomem *ioremap_prot(phys_addr_t addr, unsigned long size, unsigned long flags) +void __iomem *ioremap_prot(phys_addr_t addr, size_t size, unsigned long flags) { pte_t pte = __pte(flags); void *caller = __builtin_return_address(0); @@ -74,27 +74,3 @@ int early_ioremap_range(unsigned long ea, phys_addr_t pa, return 0; } - -void __iomem *do_ioremap(phys_addr_t pa, phys_addr_t offset, unsigned long size, - pgprot_t prot, void *caller) -{ - struct vm_struct *area; - int ret; - unsigned long va; - - area = __get_vm_area_caller(size, VM_IOREMAP, IOREMAP_START, IOREMAP_END, caller); - if (area == NULL) - return NULL; - - area->phys_addr = pa; - va = (unsigned long)area->addr; - - ret = ioremap_page_range(va, va + size, pa, prot); - if (!ret) - return (void __iomem *)area->addr + offset; - - vunmap_range(va, va + size); - free_vm_area(area); - - return NULL; -} diff --git a/arch/powerpc/mm/ioremap_32.c b/arch/powerpc/mm/ioremap_32.c index 9d13143b8be4..ca5bc6be3e6f 100644 --- a/arch/powerpc/mm/ioremap_32.c +++ b/arch/powerpc/mm/ioremap_32.c @@ -21,6 +21,13 @@ __ioremap_caller(phys_addr_t addr, unsigned long size, pgprot_t prot, void *call phys_addr_t p, offset; int err; + /* + * If the address lies within the first 16 MB, assume it's in ISA + * memory space + */ + if (addr < SZ_16M) + addr += _ISA_MEM_BASE; + /* * Choose an address to map it to. * Once the vmalloc system is running, we use it. @@ -31,13 +38,6 @@ __ioremap_caller(phys_addr_t addr, unsigned long size, pgprot_t prot, void *call offset = addr & ~PAGE_MASK; size = PAGE_ALIGN(addr + size) - p; - /* - * If the address lies within the first 16 MB, assume it's in ISA - * memory space - */ - if (p < 16 * 1024 * 1024) - p += _ISA_MEM_BASE; - #ifndef CONFIG_CRASH_DUMP /* * Don't allow anybody to remap normal RAM that we're using. @@ -63,7 +63,7 @@ __ioremap_caller(phys_addr_t addr, unsigned long size, pgprot_t prot, void *call return (void __iomem *)v + offset; if (slab_is_available()) - return do_ioremap(p, offset, size, prot, caller); + return generic_ioremap_prot(addr, size, prot); /* * Should check if it is a candidate for a BAT mapping @@ -87,7 +87,6 @@ void iounmap(volatile void __iomem *addr) if (v_block_mapped((unsigned long)addr)) return; - if (addr > high_memory && (unsigned long)addr < ioremap_bot) - vunmap((void *)(PAGE_MASK & (unsigned long)addr)); + generic_iounmap(addr); } EXPORT_SYMBOL(iounmap); diff --git a/arch/powerpc/mm/ioremap_64.c b/arch/powerpc/mm/ioremap_64.c index 3acece00b33e..d24e5f166723 100644 --- a/arch/powerpc/mm/ioremap_64.c +++ b/arch/powerpc/mm/ioremap_64.c @@ -29,7 +29,7 @@ void __iomem *__ioremap_caller(phys_addr_t addr, unsigned long size, return NULL; if (slab_is_available()) - return do_ioremap(paligned, offset, size, prot, caller); + return generic_ioremap_prot(addr, size, prot); pr_warn("ioremap() called early from %pS. Use early_ioremap() instead\n", caller); @@ -49,17 +49,9 @@ void __iomem *__ioremap_caller(phys_addr_t addr, unsigned long size, */ void iounmap(volatile void __iomem *token) { - void *addr; - if (!slab_is_available()) return; - addr = (void *)((unsigned long __force)PCI_FIX_ADDR(token) & PAGE_MASK); - - if ((unsigned long)addr < ioremap_bot) { - pr_warn("Attempt to iounmap early bolted mapping at 0x%p\n", addr); - return; - } - vunmap(addr); + generic_iounmap(PCI_FIX_ADDR(token)); } EXPORT_SYMBOL(iounmap); From patchwork Thu Jul 6 15:45:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13303977 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 376C3EB64DD for ; Thu, 6 Jul 2023 15:48:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2EF918D0003; Thu, 6 Jul 2023 11:48:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 29FCB8D0009; Thu, 6 Jul 2023 11:48:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0F1B08D0003; Thu, 6 Jul 2023 11:48:41 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id E9D158D0009 for ; Thu, 6 Jul 2023 11:48:40 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id A2ED180715 for ; Thu, 6 Jul 2023 15:48:40 +0000 (UTC) X-FDA: 80981619600.09.5704AD0 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf25.hostedemail.com (Postfix) with ESMTP id 187C4A0017 for ; Thu, 6 Jul 2023 15:48:36 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Sx4fWw8I; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf25.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1688658517; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=ufnbHw3CFVXR+TCLfdbzkgDAqTOwnZtETnnpIP+Ntq0=; b=nyN6ZlZ/6RuXfLpn6AwsT1bhV+k2njasaz4scxvHyNHyxzSx2Dk2x+1kHnfUPiShZ0pKxX ViTXJAhndz54ZeIy3T6MkosPvHi2MsLy2+M/sZ6Le8itTjMV25azoWHn5AH7k+Tgvq0p2c Fh5MUagjY0gkcwtz8bXWSoHdveEumgo= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Sx4fWw8I; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf25.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1688658517; a=rsa-sha256; cv=none; b=EKys2bXbIhGMyQZnnR4URSALe2KzClHoyKcfbokQzDa1noj0aSs6FrwXCB77gFpI/m7N1i SMmbliW75YkK2q1kerq5RJggmXRLVWLq3x7CVC4Lfauk186TzBuBwiRZ6PKl66V4wBcWUL 0ctnevdtMGEo7sKxw3uaTlTp0+gA2dg= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1688658516; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ufnbHw3CFVXR+TCLfdbzkgDAqTOwnZtETnnpIP+Ntq0=; b=Sx4fWw8InogqgIrPHmgml8GbaD5Sqki9xDAko3wm+eZ+1WmHUs8J5lZPaw4uF0IgdpBlSW pXBeLVTNEaimSnEygH4MY/68o/eNyJQR+q/QkbcmDPLUeAAqM9WbRWOEZ6tSVy0o9JEoaq nTHgbo8v/NcMTcDRr/iYMfqQXDNwajY= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-466--F65NclnMjCNxuCBTdT-Kg-1; Thu, 06 Jul 2023 11:48:25 -0400 X-MC-Unique: -F65NclnMjCNxuCBTdT-Kg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 723012815E3A; Thu, 6 Jul 2023 15:48:24 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-39.pek2.redhat.com [10.72.12.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id 99A41F5CF0; Thu, 6 Jul 2023 15:48:15 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: akpm@linux-foundation.org, linux-mm@kvack.org, arnd@arndb.de, hch@lst.de, christophe.leroy@csgroup.eu, rppt@kernel.org, willy@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, shorne@gmail.com, David.Laight@ACULAB.COM, deller@gmx.de, nathan@kernel.org, glaubitz@physik.fu-berlin.de, Baoquan He , Catalin Marinas , Will Deacon , linux-arm-kernel@lists.infradead.org Subject: [PATCH v8 18/19] arm64 : mm: add wrapper function ioremap_prot() Date: Thu, 6 Jul 2023 23:45:19 +0800 Message-Id: <20230706154520.11257-19-bhe@redhat.com> In-Reply-To: <20230706154520.11257-1-bhe@redhat.com> References: <20230706154520.11257-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Rspam-User: X-Stat-Signature: oww3hxtfgufwtnh8dh7reu4cr7b8kitb X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 187C4A0017 X-HE-Tag: 1688658516-228422 X-HE-Meta: U2FsdGVkX1/Ts5PANWxULiGc2G7D2RB563jtQMjQfiYvYUuysm0w0AzbCOvoCKZ4LT8p7ipnnhQN0CbmUC7xa3mMZZx7yf+PW1CAy3WToVSVCqzI0bsUg9GySilvUzX03icJnwbsgHxvwmqAHypKSL7w+gZh0q7Bke4xi+nh67zZ0cM241OKgmG4Rl6KCBWLg8/R+bh4lqc8O9Pv20p3VFOFfaoJbah0L0xxyT8txrIgTfyy0fEHDe7kgtqMKKi6hOYQHkLQ+X2l3nP1ulfNmHrIMfDbxEg7m5FbqLxkTR3HVBZLrz2t+ADiIgweVdFOn4Mk9bAfBJYSSonH+7SjZ7s5qVlMc4vcNCdDp+iYTklyPwuz+EVgQIT1UN5uAHXBpC81f4bY50TjzDAfcj+8AdToo84RFW3aAQs+D8SAuS82FQl6bpd+7WijWOeJC2Hk7jyaRlmYa+Sam1cTZUWhcgOATktDBSoiqRKNMIITAH1+AAI/zMVFxmZTvdBUdFxScHK2+PSkwjU63LCtw1eCuPRqIWPSU9W0lsSW4bNt9ztc2kb/Etekb8rhVrwWBov7hrzEpqgB1yMUelLVgWR4UI5CrBdI8oYY+8voGOv+QfU96Ryd55FjXDIMugeEc3cd4JEIohvrSS8oMnvQoSCOkTF5erTo1j9bJc/XYACjiJGPxhJFBsWK/zp+W1XEyZ9LFVYWQgunUBx+qy9c6KuR/MEjq63GJgpYWfjiMzRU6y0bM8CsRxHPkvSUn9BLvUysk/2EC5Jq8+OR0BaVBt/MZyTxFlDSruu2nGd0k7KbyQwaNNub/EFiFvVSfeGiJBNGliptCsGKZxBQd10gmSHUqvdHp54g2j/+cG4erg2+BIh8RBNB1Xp8l/m9TGvGeMy2g/SZBLAcRFRLsWyzOijxxUCTmQGbO8ocazMHWvR8jv51fKcpHBv6EUD0hHAgQ4kvRZdM3L8AmiKNdfgL0SJ A4sOM3Fg pMUKXzRXy9knBDsRjYnMxME42P5OijPxTJCPZ75Vnv9AGCp6RKXZTx8C9x8ZQA/bZ7PeCDmUBlUvl4fAH3a/ov4Z2UQQtoR/1jK5EQJdjYqE3Uj4z7yJKULsrWyo36ODTIdakEeikVfBRN9J6UyK44jZdGLguGtdZd0JiwFyiTeilMM0Au6XyKFhp62zbI7yF3C4pQCtgon21Ou0NZUorqtNj56ExbuisEgvpel6/ZLHI0a+4ln5hlHFw5hid0O5LGw9vsxvZqykpgj3XPPtnWY7lO3WFXmOL/pIoXHIeWoPb7WvX2UTUgF4EvNkjb6mwDKbnX/97Vqe/Q7yB/QbGEwNW2Ec6kBeAuO6tDG12464lKUnWJCvDde3DkBEOgOSF8Q/jhYK2tq2psReiJhgH2h5OKyPrUSd1EEYn4forwoc0LFM= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Since hook functions ioremap_allowed() and iounmap_allowed() will be obsoleted, add wrapper function ioremap_prot() to contain the the specific handling in addition to generic_ioremap_prot() invocation. Signed-off-by: Baoquan He Reviewed-by: Christoph Hellwig Reviewed-by: Kefeng Wang Reviewed-by: Mike Rapoport (IBM) Acked-by: Catalin Marinas Cc: Catalin Marinas Cc: Will Deacon Cc: linux-arm-kernel@lists.infradead.org --- arch/arm64/include/asm/io.h | 3 +-- arch/arm64/mm/ioremap.c | 10 ++++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/arch/arm64/include/asm/io.h b/arch/arm64/include/asm/io.h index 51d92abf945e..3b694511b98f 100644 --- a/arch/arm64/include/asm/io.h +++ b/arch/arm64/include/asm/io.h @@ -139,8 +139,7 @@ extern void __memset_io(volatile void __iomem *, int, size_t); * I/O memory mapping functions. */ -bool ioremap_allowed(phys_addr_t phys_addr, size_t size, unsigned long prot); -#define ioremap_allowed ioremap_allowed +#define ioremap_prot ioremap_prot #define _PAGE_IOREMAP PROT_DEVICE_nGnRE diff --git a/arch/arm64/mm/ioremap.c b/arch/arm64/mm/ioremap.c index c5af103d4ad4..269f2f63ab7d 100644 --- a/arch/arm64/mm/ioremap.c +++ b/arch/arm64/mm/ioremap.c @@ -3,20 +3,22 @@ #include #include -bool ioremap_allowed(phys_addr_t phys_addr, size_t size, unsigned long prot) +void __iomem *ioremap_prot(phys_addr_t phys_addr, size_t size, + unsigned long prot) { unsigned long last_addr = phys_addr + size - 1; /* Don't allow outside PHYS_MASK */ if (last_addr & ~PHYS_MASK) - return false; + return NULL; /* Don't allow RAM to be mapped. */ if (WARN_ON(pfn_is_map_memory(__phys_to_pfn(phys_addr)))) - return false; + return NULL; - return true; + return generic_ioremap_prot(phys_addr, size, __pgprot(prot)); } +EXPORT_SYMBOL(ioremap_prot); /* * Must be called after early_fixmap_init From patchwork Thu Jul 6 15:45:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13303976 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 489D5EB64D9 for ; Thu, 6 Jul 2023 15:48:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D4F408D0008; Thu, 6 Jul 2023 11:48:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CFED48D0003; Thu, 6 Jul 2023 11:48:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BC7428D0008; Thu, 6 Jul 2023 11:48:40 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id A94FD8D0003 for ; Thu, 6 Jul 2023 11:48:40 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 84082AF7D2 for ; Thu, 6 Jul 2023 15:48:40 +0000 (UTC) X-FDA: 80981619600.13.3E15770 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf12.hostedemail.com (Postfix) with ESMTP id 5341040020 for ; Thu, 6 Jul 2023 15:48:38 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="Kth/OuK7"; spf=pass (imf12.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1688658518; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=keQ78Mv/VCFMjxLJbgEgr2h/sjN0UpPUn6QsvR3JRNU=; b=xwwsi2Ab1vFmvrd0KPsPv5vXpQDlt5gFZUJZ1XLBwxBm7AhZ1AqI0rXrmgMsoggYmsFGUi 54tTSeQB7+iLX+kPihEarT/C2dI9OaVpvqCFvxS+nNHYW3X2+J7czqc4C0EC/jH8Ugn8zc BjW8L04Bw3mKMwbvzMwryGl5vPYuf+g= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1688658518; a=rsa-sha256; cv=none; b=bRO1CxoN2E7QXRzc5xIM3VQM3UIK5K+HWN7rRZihc+gV/ED4QtchJdKn5nDWuyfCeNUiTV 6fnM9dFAp+gNj/Stgcy6Lk7WJgeybtOJ9ARl3YtNLpVYY5H5tLbIAQuVGw3vSgfWIQPsvx Jo0hI4beNpIDFSva6B3JViK0+Agq0z8= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="Kth/OuK7"; spf=pass (imf12.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1688658517; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=keQ78Mv/VCFMjxLJbgEgr2h/sjN0UpPUn6QsvR3JRNU=; b=Kth/OuK78uGnurgU1c2bKZQ1fDCD0Q8atuGqGCb5Dba8YkuimcjONwVw8hYie6A2ifubyR 2heu5aKmPDbaqX+v/jEzocktOyzrmqFdKumUQ/aD49P2q2FfU/yvmBevV8JUruF2m49tOX fwQeO2gXGgBD9J2b3QywL69y1m5+n1I= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-592-vcwacN9DPj2Dhag0q5VkVA-1; Thu, 06 Jul 2023 11:48:34 -0400 X-MC-Unique: vcwacN9DPj2Dhag0q5VkVA-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0BBB9881B27; Thu, 6 Jul 2023 15:48:33 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-39.pek2.redhat.com [10.72.12.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id 42160F5CF0; Thu, 6 Jul 2023 15:48:24 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: akpm@linux-foundation.org, linux-mm@kvack.org, arnd@arndb.de, hch@lst.de, christophe.leroy@csgroup.eu, rppt@kernel.org, willy@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, shorne@gmail.com, David.Laight@ACULAB.COM, deller@gmx.de, nathan@kernel.org, glaubitz@physik.fu-berlin.de, Baoquan He Subject: [PATCH v8 19/19] mm: ioremap: remove unneeded ioremap_allowed and iounmap_allowed Date: Thu, 6 Jul 2023 23:45:20 +0800 Message-Id: <20230706154520.11257-20-bhe@redhat.com> In-Reply-To: <20230706154520.11257-1-bhe@redhat.com> References: <20230706154520.11257-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Stat-Signature: 7p1x1cjs38zs8sq795kcknatgxanzx86 X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 5341040020 X-Rspam-User: X-HE-Tag: 1688658518-167995 X-HE-Meta: U2FsdGVkX1/FwnbWMebsXCLT9tF898MAYCXGLRsEr9KZYXfdp7fSXZzm+2i4JPJ7bC+cmAt+gnnxfmfQZlFe2RBuHSqSA5H246cShOV41lMuDvD4vcQ1lLdxEHKRVehH/KCBX51jy5vSovVq2UcuB8aN/EF1Zvhff/PJdbUjACD/rxpjcxgYVHziBx3FWDAR16iv2yrzIiRfmJllN/TN5m6vF4jPOjV606yXT7tJpp4Bbl+PNe25+hU+WN2um5va1zrp8U0CTL5sCTPulZgv45P5nPMHCS7UQg6wv3CNh41DN7FjXoZGuQI9gDsyz78V8BqYRyKuiz4QOiGlujWwa+ml29bg36EZB63D8wqdtYHZEwGSglwcKic9E/d0WSi/2V0m+yh2qiAW0F3ObOoNbMcaCJpLFBJ0ZN4SzA0AlPZymtaSvfGgHqfl8hSjcTBKj9AJ3gQopex00up8A3KAySBxWoXSdX0Nu7uqpDGIL8G8D4DlgKHcc0frQJWVfJ/xnu1G6avl5JTD+xUUaqYtZ9+pPfxw6Z2mG9IZTxyqsvgwo92Up3UrheLkgaDyYKja+cjdvXckNdzENJGgEfiDKppfw3VQkBa6pYBYxQc2zPFFxbo0F2b891lhE0HTfLr8p9x4jMYbd9q5dAqdnWdVRMnSJG7Xm+WXHgTlfIVNxBXUeSFiBOjRX2wwvFrA7cWWgg7OaCycSTmOE4iH5210dhg+F8/5d/mcP6X//8w0gdpJoU0tw3UI471dJaEL21XH+y80nwa45exWKLCkfu0kUk8fpioXUn6LVIdRrEHP0vtkp2oviHSk7UUBEYwsk5eoFRxelUFQRZ2zhN+2iYmMiDRl8mR3WsbfGVVzMtRhYWTSW/p7Gz0CBc4dg9GnfzPCRqN05F2lhvCnmryWO/CkcV0UMT1xkQrwl9mM8Fjae8zZHsxzgx10XeoT9RNp5RS7moa7NSJe0ADjnZMMXLP FHID1i+n bCM+QaXCBEuj1sC/AYRn92NHPnm0xDIXxAQNE2cK+o0EiZZY6T8SLhPmJsN5XkX1vi8rY3pMSxSHAblsvGXjrrrrQ0qnLByI+ar3UPT9VMtDsVaL+RsAGZnfBnKM06+mJLmXKoJDkkCXc+TYPXOq/YOuLYqsaZ5UwF73+leDX0h0V40HDLukEffRzfu/lYIkQqQTHLZA2MhANZp7ZIz2LxqV+GFGAzJaAwmzqaIIJk8K133H+md4RGfP3bWsejOsH4R7NI2pLrhdeXDmMQ0mCgwyoZ47UlZzAm5Pqb6upquHcwjI= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Now there are no users of ioremap_allowed and iounmap_allowed, clean them up. Signed-off-by: Baoquan He Reviewed-by: Christoph Hellwig Reviewed-by: Kefeng Wang Reviewed-by: Mike Rapoport (IBM) --- include/asm-generic/io.h | 26 -------------------------- mm/ioremap.c | 6 ------ 2 files changed, 32 deletions(-) diff --git a/include/asm-generic/io.h b/include/asm-generic/io.h index 39244c3ee797..bac63e874c7b 100644 --- a/include/asm-generic/io.h +++ b/include/asm-generic/io.h @@ -1047,32 +1047,6 @@ static inline void iounmap(volatile void __iomem *addr) #elif defined(CONFIG_GENERIC_IOREMAP) #include -/* - * Arch code can implement the following two hooks when using GENERIC_IOREMAP - * ioremap_allowed() return a bool, - * - true means continue to remap - * - false means skip remap and return directly - * iounmap_allowed() return a bool, - * - true means continue to vunmap - * - false means skip vunmap and return directly - */ -#ifndef ioremap_allowed -#define ioremap_allowed ioremap_allowed -static inline bool ioremap_allowed(phys_addr_t phys_addr, size_t size, - unsigned long prot) -{ - return true; -} -#endif - -#ifndef iounmap_allowed -#define iounmap_allowed iounmap_allowed -static inline bool iounmap_allowed(void *addr) -{ - return true; -} -#endif - void __iomem *generic_ioremap_prot(phys_addr_t phys_addr, size_t size, pgprot_t prot); diff --git a/mm/ioremap.c b/mm/ioremap.c index a21a6c9fa5ab..3e049dfb28bd 100644 --- a/mm/ioremap.c +++ b/mm/ioremap.c @@ -33,9 +33,6 @@ void __iomem *generic_ioremap_prot(phys_addr_t phys_addr, size_t size, phys_addr -= offset; size = PAGE_ALIGN(size + offset); - if (!ioremap_allowed(phys_addr, size, pgprot_val(prot))) - return NULL; - area = __get_vm_area_caller(size, VM_IOREMAP, IOREMAP_START, IOREMAP_END, __builtin_return_address(0)); if (!area) @@ -64,9 +61,6 @@ void generic_iounmap(volatile void __iomem *addr) { void *vaddr = (void *)((unsigned long)addr & PAGE_MASK); - if (!iounmap_allowed(vaddr)) - return; - if (is_ioremap_addr(vaddr)) vunmap(vaddr); }