From patchwork Wed Mar 1 03:42:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13155566 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 1D06CC64EC7 for ; Wed, 1 Mar 2023 03:43:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 804E86B0074; Tue, 28 Feb 2023 22:43:11 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7B4FA6B0075; Tue, 28 Feb 2023 22:43:11 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 656F06B007B; Tue, 28 Feb 2023 22:43:11 -0500 (EST) 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 5725E6B0074 for ; Tue, 28 Feb 2023 22:43:11 -0500 (EST) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 1EE6CC0FF3 for ; Wed, 1 Mar 2023 03:43:11 +0000 (UTC) X-FDA: 80518933782.08.A211DD6 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf30.hostedemail.com (Postfix) with ESMTP id 5892980006 for ; Wed, 1 Mar 2023 03:43:08 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Z+GDQqwA; spf=pass (imf30.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=1677642188; 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=vvld3gbtJ1BE6x3nj+J2K9CX8W70047HmTxzv/gpds8=; b=ZlM07SAq8AI0FEIgHGIyWpKp2JQv2dHoTpuuaFPWjtCfa5h+J4ZZL/u972gH84jtVZWrMh pDiTYDiotDF7bhiPY8uAowkUZhHYGJlJEBotLe2EMoIbydG4BpE8d7S+feOPVjgKpjvA1i AOhhlNNCHXs50k0FMDKygO8uyIq/p98= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Z+GDQqwA; spf=pass (imf30.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=1677642188; a=rsa-sha256; cv=none; b=tQwFdVITAkSZmdEoLfAHH6PZmjPGOVwHKrbg2pDaeeh5ggLYndQ2pa75Xw6md04m/pyY1w yuPm67yxXTe0UmR8tlxiOM1kJ1zUvo0cpRziRYbmbrOxZTym9ELxgju1oSU09KLEa+a03D mNREDUjIPkHMQZH+OJaGUKjkC0l4Wq8= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677642187; 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=vvld3gbtJ1BE6x3nj+J2K9CX8W70047HmTxzv/gpds8=; b=Z+GDQqwAYAHFxi3mnf7Q/GdJVFicQvuZGBNr/Wk3/po3/Mohat3e+lrNiJ7Dlee2QSW0Z8 wQEaLpzrJ+Zw6jIojKzHRcGx1ivnUIcUtdXmbN/oB73VeovvxIG7ZF8ZIH6EDxk0I6wB+w iqUXhlO7lDErgFueFH5o5NSIJb5roeA= 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-657-m7PYgUh5M7mj4QuzIlwzKg-1; Tue, 28 Feb 2023 22:43:04 -0500 X-MC-Unique: m7PYgUh5M7mj4QuzIlwzKg-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2C5B2864765; Wed, 1 Mar 2023 03:43:03 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-13-180.pek2.redhat.com [10.72.13.180]) by smtp.corp.redhat.com (Postfix) with ESMTP id 44E9BC15BAD; Wed, 1 Mar 2023 03:42:55 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-arch@vger.kernel.org, linux-mm@kvack.org, arnd@arndb.de, christophe.leroy@csgroup.eu, hch@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, David.Laight@ACULAB.COM, shorne@gmail.com, willy@infradead.org, Baoquan He , loongarch@lists.linux.dev, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, x86@kernel.org, netdev@vger.kernel.org Subject: [PATCH v5 01/17] asm-generic/iomap.h: remove ARCH_HAS_IOREMAP_xx macros Date: Wed, 1 Mar 2023 11:42:31 +0800 Message-Id: <20230301034247.136007-2-bhe@redhat.com> In-Reply-To: <20230301034247.136007-1-bhe@redhat.com> References: <20230301034247.136007-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 5892980006 X-Stat-Signature: t4ei11uu37bd3fh4wzbkkw3pmda6gwts X-HE-Tag: 1677642188-382364 X-HE-Meta: U2FsdGVkX1+FwTLCcAi1SFQ9TcT3I9Uonkom+pjIpkhTBCDiKAknvYWhUTZ1ljf1zufy2bo2qLA7fKfJ9ZkyBm5w+yoWw+rCCKJWch7oNyjEpdHVVCcMj7+fgeDEgH8u3ytwhWew32ZUW27mk0vbvI3aiXtGIV+86VsZCgQPkKQ2znGl6JPk5Vaa/HuVYZLE6y0tGhPuGt3rc1uobvWiLrWWDkISTeErOboyr7coTD6J9GvY7JUMSs8B5DwVjnLvjZ5Fm3/redREVivEIU+rhGneZYm/H/1XyLE8gVTNOaqsRgg2WkOuLI5agAb36Hqm8WRnsuacfHTD5cHxV82vqJfH2+Ofy9sRCuvPyeI0wbdFDVpaXgekoVKkEEVkOxBxD5qBqdxQRbCWgmpQTZk2LT/J4ylUHZSRiaSzoexyqEruZm8QvHi1SK0kS6Fa6ccSiYEUSTlSpv59zcZiv3TlU+YHyBm00Wk3xH1QQ0dXPzkfUlU0AHn3JMvS5SZIT10gUgFAeLj077cM95Ke+j9uV8rLEiyhaAcHqCWUE/Q8NooL76RumnJBoHeC8zeG0zw5JyrTWjLCOn/EAp/db/z03NCfeRB3FSUeUI+x+X8ExiuXaEVuzDt3h5B/7ACrNFezkZZj4JUqF3XLHQWP4Z41myQ/cFSIUBIkeeraBgGsUZgxi64Qso+MK6fTEAZBAqtaOeMIp5BI0qmToZn2gA1Q8qPkB8kdFpSwlcjEOZ8pTUgcO7H1VV8hJF2Cgf1ItsZ1hQqvfJTy4UGIW2vAxZr6F9Tv06I7tpGnT01dexm+SO3ZnutYyVoWasvqHfZZp9tVYL88TPR6V8tNG/ASC1GY95NXM/BLsiYoTA4ZQfd26hesmnyOlw7Cz5bzOrfPRvbHO3iweqdZC+Kcgtvsu62fEer0Tfm0Ene7a4vEYfMxb+58P3IeOMLTfSf+tXU8VlILVsmH9jrHuwm3qs35dEE 3c2AREo0 aC9z6s5TKY9J1cbESx6JbXy7fpd1miE1n/O0gEjVWbpouRVJ2ARQDKL3DN53qmnjZ7ckq10Ob8VwCTr1daYGCtmQtDoNCUnoaBW7zkJWr8oOJoR3HVfBttD9kS0MwnHl3Ks0l7OjhNYpJq2+gqsN2h2TdkNAB5CusAnI1yMWCQmNIvtNiz7P018BOOCmkESmO/VBdKujLCIo77A6/V9+QjPDLdJZCbu58iXU9Tsh7fF+cDLq7uG8BzaTv65vByFwZf6yPdrjpf/MXcXmuteRThPCqS/RAD+HWglpvSlqSLZIHKM0ON2gzMYDYt4nHGLG0lLDnY+70mJmChm0el2nbCBvB9AVil6ZjKxW3UaUS1f59Ee1x4WpX4CF4AYV3fRzf1jnYknZHe6eTfsYaA0vJSTiBFIHR0aY4EJ1saREjllSUHqrjw+SRuDaWC5BAn54LQor3LeJNftCfxV8Ro3J2DZfrp67PbNbuTlyI 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. For architectures defined ARCH_HAS_IOREMAP_xx macros in , 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, so 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 at the middle of . Let's rely on . This is a preparation patch so that Later patch don't need to add ARCH_HAS_IOREMAP_xx macro. Signed-off-by: Baoquan He Cc: loongarch@lists.linux.dev Cc: linux-m68k@lists.linux-m68k.org Cc: linux-mips@vger.kernel.org Cc: linuxppc-dev@lists.ozlabs.org Cc: x86@kernel.org Cc: netdev@vger.kernel.org Cc: linux-arch@vger.kernel.org --- 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 402a7d9e3a53..505e3b583463 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 e6d5ccaa309e..cec8347f0b85 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) || defined(CONFIG_CPU_LOONGSON64) #define war_io_reorder_wmb() wmb() #else diff --git a/arch/powerpc/include/asm/io.h b/arch/powerpc/include/asm/io.h index fc112a91d0c2..7a82e6f70ced 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 - /* */ @@ -695,9 +690,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 Wed Mar 1 03:42:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13155567 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 ACAC4C64EC7 for ; Wed, 1 Mar 2023 03:43:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 175AE6B007B; Tue, 28 Feb 2023 22:43:16 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 125C56B007D; Tue, 28 Feb 2023 22:43:16 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F097F6B007E; Tue, 28 Feb 2023 22:43:15 -0500 (EST) 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 DDFDB6B007B for ; Tue, 28 Feb 2023 22:43:15 -0500 (EST) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id A7B33A5024 for ; Wed, 1 Mar 2023 03:43:15 +0000 (UTC) X-FDA: 80518933950.26.9E29CB0 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf21.hostedemail.com (Postfix) with ESMTP id F06581C0008 for ; Wed, 1 Mar 2023 03:43:13 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=g1BzdCKI; spf=pass (imf21.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=1677642194; 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=v0nZZRtgRBEjd1TuZoUTX3TC1k0a64a2n3jlsJishp4=; b=JJzB4NcS4Ac3nXOxPw2OZfS00XYy0NV9wsrnMXIby/LHfsxHCWJyH8rNNAbccL2b+n5vKQ HO9hrLzH+BEsjoNCNMl1QYxR7vQxynU+0RZdywY4tsWkxHOsQpOWI/jw+bVHs0HC7yR98x WAISSK4vJielgw+DiDoGNEy0k69c4vs= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=g1BzdCKI; spf=pass (imf21.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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1677642194; a=rsa-sha256; cv=none; b=HalJqcEZF8pvhpaY78VrmPuQQE9ej0IPc2IaSqhGKvalHm25z/axMlmzzpm8zjl9Sw+QsC 4P6B8MV1wRpcwvWIb9H6j8pHUamqnuIUkCKmWASH5sWHvY0dxDc8ussHAAsPZMEVoq5+PA mqowZqpcrvbY+Cx6jSYoS7DyZHUIbV4= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677642193; 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=v0nZZRtgRBEjd1TuZoUTX3TC1k0a64a2n3jlsJishp4=; b=g1BzdCKIgX3GGHsiepcc4Mq15oWf1w/s4D7aBVtiRW05kJDdFt5ucRRvp/wgjo4ZBOLdRj 1ejVzMMpFUktaYjq79AOPJmdC2+cQLprfQqABtdy+U/aMrj9KwPKVz1BKoXHWC4PJL6kvE 6nl1WvD7k+hTp1QNPKDg4uvbSi25Va4= 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-378-8HJrqEIPOV2v1sZuDYwixw-1; Tue, 28 Feb 2023 22:43:09 -0500 X-MC-Unique: 8HJrqEIPOV2v1sZuDYwixw-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E665D87B2A0; Wed, 1 Mar 2023 03:43:08 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-13-180.pek2.redhat.com [10.72.13.180]) by smtp.corp.redhat.com (Postfix) with ESMTP id BDA3EC15BAE; Wed, 1 Mar 2023 03:43:03 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-arch@vger.kernel.org, linux-mm@kvack.org, arnd@arndb.de, christophe.leroy@csgroup.eu, hch@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, David.Laight@ACULAB.COM, shorne@gmail.com, willy@infradead.org, Baoquan He , Brian Cain , linux-hexagon@vger.kernel.org Subject: [PATCH v5 02/17] hexagon: mm: Convert to GENERIC_IOREMAP Date: Wed, 1 Mar 2023 11:42:32 +0800 Message-Id: <20230301034247.136007-3-bhe@redhat.com> In-Reply-To: <20230301034247.136007-1-bhe@redhat.com> References: <20230301034247.136007-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Stat-Signature: 4ajucscxu6tt1q1s7k5tmbcxs1okybuk X-Rspam-User: X-Rspamd-Queue-Id: F06581C0008 X-Rspamd-Server: rspam06 X-HE-Tag: 1677642193-532049 X-HE-Meta: U2FsdGVkX1/uiVI1Obc1yFBFsyGYw757zPWkuZ6+4i8HMBtw1G403FOun6lCl1NdwMItI09hd98ZVWrh11P5p+iEQXY4txqFsxwWEldAI9w0w897915P+NSVybkiCKj6ikvICJgkvCmfMGMl1rD+2FLI4ABqTvU3ma6O16+FgVrlxJk1zSEz3JtAl2COYOD8VP1IUY6mDy6iDWTas9SJAgZnAlzrQvpWTucLd7IzxIzzOkki1R3ahFIyJOQPasMrMfeDmSLT2LsZdPvmneRcaLYZ1+YN7aSMqEhX3rgDrRFeIlZSyEhjTzItq0yX4fl3rl6ua/QrQg5twktTmRuf0D1Hsv4YAiPdGt4PrJOcNBNRrZFNKja4eUXJ/SSBa6UHmhjB9wmcBb8yu3+tx1twy6FcQAfzYtIOuxGYFbt32JZyvfyemspFrg0D9GYjJLxhsEzR2W9w+ZD7yN+Eesnp8qAsLSTLg7gdi0P/B5MPVjPbjdh15RWf9tnopx8J1jqBQ0BIyiO76Ccb4gMGXU+4ZQQwpQKTDqHyXJFC+dxRCRBrdkYG3XrzRMQat8XfTnh/1B5MRK34ibu7Dm7e1jtCIuudjygKwL6xcA0AnrWw4i2qes7WXMbBhFJkCc+YMiK7g5L8nSxNnSbOfr0f1qComLN2+FOUGkviB4/mZACdAowxu2wb7vm4G94tVl5gwvr4Sdd2saZPgNAjxeQeR1lpo7dV2Xrtdym7JvthGEJu1VRyb2QU1pFLBGaoWMoP8/5vVNOQSLL2mPoHR+J9LFjg2gQOq+qMekr6RTQJkXA0XiATseOzf+sxqsnbsgV2fN1PAmBrMk3fKG0DTz7hjBiS31jwGcWpfaXEGopiue86IIRhQHlGZjtA6OI78xx6v6SXiB5YCDT9TjqROLTvQWodq7H+Cr5OiXXJ5ZdarCU2E3E8ofVrxDxX43hU3UMLwxrmreegOx1rp1AsDpNCmqF Iqfd4ogp /uHuemqCPtsq1+5wzIp44IOahIUuBW5AkYsFsF7pAXSZliQLuoeq9QbYbzX1AOexmmsNhCYAhMVrv68HhVhdPBZdFaT/g0eFqcHFG59zg4dDS8FxFQfn0viGqXnQtWgtS4RCHDjg5HkmBNH70eb1rPepKg9YTUWhY+gaEvQwOxLYj53k5+L1yYOJcrOJzs4/LZhNZUIOb4cbcl0XEu3ev8unRzwU2KYGntHMY5Oy7Gri4Els5BSlKeDPg35bZUQNTZZxuPdZLpmgy7qU4D4VrjiuvNOod3MRnLgd0Y74VGYTq9N0o+bZ7/0N3DWiLALlJucTH5SI0GswNGTFlMSmC7MEgP51WApdwPv0MnaXV2ufVV3Q= 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 codes 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 --- arch/hexagon/Kconfig | 1 + arch/hexagon/include/asm/io.h | 9 +++++-- arch/hexagon/mm/ioremap.c | 44 ----------------------------------- 3 files changed, 8 insertions(+), 46 deletions(-) delete mode 100644 arch/hexagon/mm/ioremap.c diff --git a/arch/hexagon/Kconfig b/arch/hexagon/Kconfig index 54eadf265178..17afffde1a7f 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..dcd9cbbf5934 100644 --- a/arch/hexagon/include/asm/io.h +++ b/arch/hexagon/include/asm/io.h @@ -170,8 +170,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/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 Wed Mar 1 03:42:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13155568 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 18896C64EC7 for ; Wed, 1 Mar 2023 03:43:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4D0456B007D; Tue, 28 Feb 2023 22:43:25 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 480C86B007E; Tue, 28 Feb 2023 22:43:25 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 322546B0080; Tue, 28 Feb 2023 22:43:25 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 236476B007D for ; Tue, 28 Feb 2023 22:43:25 -0500 (EST) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id E49CCA7A74 for ; Wed, 1 Mar 2023 03:43:24 +0000 (UTC) X-FDA: 80518934328.12.3B035FF Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf30.hostedemail.com (Postfix) with ESMTP id 2A03280004 for ; Wed, 1 Mar 2023 03:43:23 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=MkdhfAbx; spf=pass (imf30.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=1677642203; 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=jHZa8mu+sMxKIWEAwvYcXi8mFXnonAyjIbMLTnXCGN4=; b=C53dZ5Ckb0NlQfjOEXiIu9kmcwSrGVOehPPWWcsXE72UdThzXNLrMHtoVPO/GhpTXIjcuM cp4O8pxjN6oRqKhkiqNHoNuWI7Aeg6fmdN/9zmLA4mTozwzUx/gahxncWz+l3vfdsG7PTu JPU2XSfWQKVnrKDvCs+GjvPpV8GPQ5w= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=MkdhfAbx; spf=pass (imf30.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=1677642203; a=rsa-sha256; cv=none; b=GchHvzOc0l6Z2mbc+nj1wqg/Es2pxrvo1d6sZ3TkuLuinC21rM83ZNvFeYvBr3qZ8W48dJ es3D4UeET6geiCbZXhUet41/ZTm8irH49Ig48oq7zpRVnjoEpv4P95iVEsYVP5mGwEUrq3 GfXHTmRNc2OnvUzxqXowmaeIjEOuCYM= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677642202; 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=jHZa8mu+sMxKIWEAwvYcXi8mFXnonAyjIbMLTnXCGN4=; b=MkdhfAbxR77T+k261WV9wcKclA8bUSw00Dl7hu4Ma6cHfVr3tRTQGtGZksDX5hDNjUVOwj t48pear7/ZG5mrvwEj4KghhcMVg3mo+JP1LAv6eEskpaOgP1Nq89gswWWyJRzIQKSorjkM YpJ4gU4KYsVU/ZWByQApO1ykPlYBB9M= 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-121-2Bn0SQvWNcO1qQlKWwiWUQ-1; Tue, 28 Feb 2023 22:43:18 -0500 X-MC-Unique: 2Bn0SQvWNcO1qQlKWwiWUQ-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0D0112823802; Wed, 1 Mar 2023 03:43:18 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-13-180.pek2.redhat.com [10.72.13.180]) by smtp.corp.redhat.com (Postfix) with ESMTP id 868B6C15BAD; Wed, 1 Mar 2023 03:43:09 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-arch@vger.kernel.org, linux-mm@kvack.org, arnd@arndb.de, christophe.leroy@csgroup.eu, hch@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, David.Laight@ACULAB.COM, shorne@gmail.com, willy@infradead.org, Baoquan He , Jonas Bonn , Stefan Kristiansson , openrisc@lists.librecores.org Subject: [PATCH v5 03/17] openrisc: mm: remove unneeded early ioremap code Date: Wed, 1 Mar 2023 11:42:33 +0800 Message-Id: <20230301034247.136007-4-bhe@redhat.com> In-Reply-To: <20230301034247.136007-1-bhe@redhat.com> References: <20230301034247.136007-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 2A03280004 X-Rspam-User: X-Stat-Signature: oqhdw774jgtn3pmhu5jyajgj4kzm73yk X-HE-Tag: 1677642202-551917 X-HE-Meta: U2FsdGVkX18PYdOQON8PTAgEEcDXJ7cyxERiaXWoWNwuQOlo5bX3BqVq55C6uhDw5SZw0KXZaPILEFgFCz46MacQe/ssV+NVKphfJn/DpWpWxwK9ZbAx4nQD+JFFtIPt+JcwJWTh5Mlxcls4CznhAeag23v0tj18Ey38ck54vEzKsoUGnviOOucw/QpnD1KmnRk1lOYoPcQN6wD4ECxErBJCMr+XeL2mXPilzYVlCtQPJiIiL6EB0rXFvFYfnL4bIsQuHepTvrsqi8j5p49QxxbbLa1xXwz2zknjIbBr5hrtsnswPT1tpzG2fzj9cwv9aiYS9dTv3Gqw7Gd3vW9TWPQt324TMMm44V8JOVd6UGHwujeBElZPUMNYOPo3pEay/HAK+z19rNx1STICZIqwTqUqHeemg+mK9K9Z1EFKK3TWX2JAk/Ok8fhi74vBc/0iwhsHzQOQviBEMKctuJ2GArrpDZAlVh7jRlmzPRcmSTl4vij1c+CxbGKouvpFeJOPNsLBFvzT8TtzSySsz+qqwGapYBlBmCa/VOH55RFzOUqtN96LtVYNrVptu1iTaA8uL/hNtBdbtHbqAutq62bje6gdo4aIXlAKmNCeRjwT930mlp3c85+zNjKW0DG40MRHn1lPCx21GJMUhEN2aj+El28XiR9o+SrpL9zFGaWE8ZPrW5Xpx6uaK8qFS2rnra9tNURxw2/7A+W/cc8jkiEtsuv1ggj05XXJZjDvxrJDwUbOlhPYABUyZe+xbzZ/PoCz7PL68Hu3PZrx5Jz7tisxBW7ZScGNluDK6+L7UGdVg+10KdJ2PI9dlGOYIWpiLdAAjUiB/uCavN+0u9BSUxbcI/8OOP8LyQx4tjqOwGA6G/0WGUnhjRHT6/0ke+wg2gdoRkm0K69szWtBKbGcJJ81ly5+LXl4TVMYzU0NqlutJRCW45GGK3XcwIOD/0zk5UpdZPYvukZcHBqR0L3Omnw VmdxhNID 6tVhQ8ZAkPFBT8GfDEGPjfMz4dauJEwTu8v3XyChMdFPjfohx5CZKNAqbrf7tyAUrCpnmF9wvSGZ/AhT2akxIVfBqJQO01IUVXTKUqf2PwD+hTT+yiA6xoEicGb99/tQYzrxbWldeGEnLE45xFWbvmtoiRZfyAoQFl+hYzZtkLG59bxxXzFOro5z/rNsVpW7SyVtuLKfCmrAdEwcrMblRrlW9bxy6Ezk5K+e1kqtmUUHaBnM3EqEgN+JeLek5Rywa/RRFOEKFQaF5Zk5Njd5rcQZgHD1n9eTuYKotzLKkBUinuAJdFPDdeo/X8LRflfKbid+ELtuoVnSocH8= 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. Link: https://lore.kernel.org/linux-mm/YwxfxKrTUtAuejKQ@oscomms1/ Signed-off-by: Baoquan He Acked-by: Stafford Horne Cc: Jonas Bonn Cc: Stefan Kristiansson Cc: Stafford Horne Cc: openrisc@lists.librecores.org --- arch/openrisc/mm/ioremap.c | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/arch/openrisc/mm/ioremap.c b/arch/openrisc/mm/ioremap.c index 8ec0dafecf25..90b59bc53c8c 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; } From patchwork Wed Mar 1 03:42:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13155569 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 E1D68C7EE23 for ; Wed, 1 Mar 2023 03:43:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 804476B0080; Tue, 28 Feb 2023 22:43:28 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7B5526B0081; Tue, 28 Feb 2023 22:43:28 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 67D956B0082; Tue, 28 Feb 2023 22:43:28 -0500 (EST) 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 574E16B0080 for ; Tue, 28 Feb 2023 22:43:28 -0500 (EST) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 40993A9A1D for ; Wed, 1 Mar 2023 03:43:28 +0000 (UTC) X-FDA: 80518934496.29.59D839C Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf30.hostedemail.com (Postfix) with ESMTP id 93BEB80004 for ; Wed, 1 Mar 2023 03:43:26 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=FhtNHpRH; spf=pass (imf30.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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1677642206; a=rsa-sha256; cv=none; b=T3c48SMceu/MPjvOoCWgIpYgKoYxxMXBx443FR4StaHViHWEsCXzDHEc8lc8JcLigN7Zoe u5Mm8SMvZXOsPQ3CXph67RJTzSoblEVnU9QJyhpWnIajiDJlaPPAjou6wSDu8pskbbsys4 Vx0t/hFmwUiXgoX2EGr+CDy/k/Meygw= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=FhtNHpRH; spf=pass (imf30.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=1677642206; 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=wmaPlT6qa/hIBp/Pd8+V5Z2lcUnUfL5T/RFM1vmlHuE=; b=oxRkqDMlGQDrgzSr0eOURphBo74o6QYDFvLINaeBE+/9Wwf+fL0sQ9UvlR6Epok/UIAeeX 4cG7VEKPfq8gpmbj29JHuz8h/rbut6s3OeHJtKw1aemX+rk0jHcjdKKP+9WSb4fFOEpPqD 2w1jvZqM50LjaD/iYRGGMMqWjr8WeIs= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677642205; 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=wmaPlT6qa/hIBp/Pd8+V5Z2lcUnUfL5T/RFM1vmlHuE=; b=FhtNHpRHIH4YCbhXwEImzM17vZs9gLR0l5HbXMXwt6jhAiICp7tx+BoGltLnKAV6RueY/u 8T7uYUE549AiZsU4Dy7gVl30fipEB6vzzSV57noXyN+UkJJ9WRbhWI9r3UVnmdlbWv+za2 cu2/b6qyZe6xLwP0Xhn+VggSt3lR1mQ= 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-14-OuyqYOYqMTWa64-MIQw-oA-1; Tue, 28 Feb 2023 22:43:23 -0500 X-MC-Unique: OuyqYOYqMTWa64-MIQw-oA-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2BCAC101A52E; Wed, 1 Mar 2023 03:43:23 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-13-180.pek2.redhat.com [10.72.13.180]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9EC34C15BAD; Wed, 1 Mar 2023 03:43:18 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-arch@vger.kernel.org, linux-mm@kvack.org, arnd@arndb.de, christophe.leroy@csgroup.eu, hch@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, David.Laight@ACULAB.COM, shorne@gmail.com, willy@infradead.org, Baoquan He Subject: [PATCH v5 04/17] mm/ioremap: Define generic_ioremap_prot() and generic_iounmap() Date: Wed, 1 Mar 2023 11:42:34 +0800 Message-Id: <20230301034247.136007-5-bhe@redhat.com> In-Reply-To: <20230301034247.136007-1-bhe@redhat.com> References: <20230301034247.136007-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Rspam-User: X-Rspamd-Queue-Id: 93BEB80004 X-Rspamd-Server: rspam01 X-Stat-Signature: 5ptyykystji8f635uw7yanbp6eh1pad9 X-HE-Tag: 1677642206-897662 X-HE-Meta: U2FsdGVkX1+RthsYKz2gFCEwFsVu4V5C2Ki4DcTLrOgFnFdrZaMSdCtF+vkPkqr7FbGu+OazDG13pJ4OZn+8V9OabrtpVAdv8p4l88dHj1lLJXTbv1zafVGmKsXI697DYUDsCdlXsHjwDuH1xkQjp4uNmu7tKk0eAK4PsW9i3/eAhC5KSaCdCJMscfLqtPbiX6gn53gPvk0eT/8LAodJrot0oFh3Cd0RCB6ATMmEw2+0pv0UWtN+bizg6S85enfZidHxvxN6MAFeLvirX2sqyu3KV+7pIA1kx3ABiNbgIPt9j0xs6jz1OfoTjU9k6+T7TSSPZPKfolJ+avHW/Fvl3Z7tR3hOV9w+vzbeZWyvyBj4KOiEJiqPkjgDjv6zTubtE6dvAeM/vomS0GCJA9c9cdTzFUZ3x5dUoGkm8il4x80Z6/32IVtq9HZT90QlfJl6BqjXUchLarBOV9n9nmEvpcoslMzYwPZTWiblFThI4EFGV3ITioHMT7sX2KM9ED5jShacLBOVbzDzJ0EcRHBspDfeWg4meqRl6yXn5xoUZyaIXFNmcKHH4teK2GzHuKeJUA+/11EyXW13Eb4mn67l3D2EV5rzn50mfQpzO9lOKqEcjTHoNxY78ymQ0JHFsxuM9Ewx17nAezAX0jSp6v/SEWdTaXzcggNG6D1WLS3J97KyJwdpHSmVEv4AbCWmcBYGY/jzN4JDdsurzLFzsf/mYoWo9Lqj7AxVeg5faIqiqrNCYfe6Oeqts9ntakA1M7F7PTpS1WnbAsmMWYkaKlMH3w2GJT/Kud3iuxWYuKcHxQXBdLV95IPcE28rFE+4la5mYVIAnOc0m6oaDR6F7migcPORgpEypmaUcaiwKZ/nnZsKRvMnWo1iL91UVSQ2Xi5Ss9MnwVeLSx8UyZKpJ98/EQdmYnnbpSyc27BYBmFih7GRmfP1IIMPXm54vj8Le5ThXHB2G6ijqCHW7eeQ256 LZcmshaN hM98lIXSO1SKYCCEn0fVPHTKBZaM+uc073a1ouPcKMKUSLdx6uik9pM+lWvu+6RFH74aYnemdFMA+IMGHqGLrVfEusACUdAYRxBLIXtlRAIwMvb4H0+Row2y1zpa2WXqyvyD4gNeHivYaRGnsRXXQoYmaG/QMtKB5VUOEKtWjk/L3iqpUQ7TI/p0GJvZ+Wruxzt5UxswYPnmpScc4o/Pyho9K4vRpMAhyf4s0PC8zHSrSttCs5IDqqwIXesGdr8pZubnIDfHiprcGHMWnPEU+z9yfHDFi4JvSCr1D/KQmNw/QpE8= 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 --- 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 4c44a29b5e8e..5a9cf16ee0c2 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 Wed Mar 1 03:42:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13155570 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 624C6C64EC7 for ; Wed, 1 Mar 2023 03:43:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 015036B0073; Tue, 28 Feb 2023 22:43:34 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id F074C6B0081; Tue, 28 Feb 2023 22:43:33 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DD1A26B0082; Tue, 28 Feb 2023 22:43:33 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id CE2F56B0073 for ; Tue, 28 Feb 2023 22:43:33 -0500 (EST) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id B1843160D6C for ; Wed, 1 Mar 2023 03:43:33 +0000 (UTC) X-FDA: 80518934706.13.7E8C194 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 F322B14000E for ; Wed, 1 Mar 2023 03:43:31 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=ekTjSgrf; 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=1677642212; a=rsa-sha256; cv=none; b=7ubcz5dmHXNfAqp72JXv52m3n3DKeFDtlraR0R3cjl3uPZKam+IJSD191K+ePA4f8Vyw3e VeVNU70ZnAQXh0t2IX1VcHo/MdYfXZBKUIz5jzr4m+Cd/t4iO8tMtRK1SAWRhyRC/a0Mqm p3lT4VobVlsviJw0J9FzP8YQREGNjbg= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=ekTjSgrf; 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=1677642212; 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=KvHGJst0IkvQ0Vuf5Tj32ZIlvLsLevbPi0IYfAk1ZKA=; b=IHRpCntCvv9H0vO4iA3qGRBPNKgBLww/83zsMs9lN7/NMy/ynslrsA+EFOMOAaJNvQT+AI 6qJtdyQLH5DrRZHJEUe0B4Mlz/xbbzT4CwT+rf+4a7joBOqB4S/vKipEu9PhVKntcW16j/ l7lTrn+mlorDkkvJihZHStc+lrie0Q8= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677642211; 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=KvHGJst0IkvQ0Vuf5Tj32ZIlvLsLevbPi0IYfAk1ZKA=; b=ekTjSgrfQOn2g5oJOIU5qH3583lMLw+cjkZ+huTGKfnl+KcZqxguYSPilXd8SCAZE4oDIZ qC2vcuOm5JAX0TTJJMrel0GEqpFlfVdnCDu+s4nMND4IxrelTr6kfaA8bIOOMEPxpjiGJk YRYe/6ytvN9AZHOru+BjOT9bdUTVwtw= 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-423-zqkofzQROHm8mYaPK5jd-A-1; Tue, 28 Feb 2023 22:43:29 -0500 X-MC-Unique: zqkofzQROHm8mYaPK5jd-A-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 46E2E87B2A2; Wed, 1 Mar 2023 03:43:28 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-13-180.pek2.redhat.com [10.72.13.180]) by smtp.corp.redhat.com (Postfix) with ESMTP id BD46CC15BAD; Wed, 1 Mar 2023 03:43:23 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-arch@vger.kernel.org, linux-mm@kvack.org, arnd@arndb.de, christophe.leroy@csgroup.eu, hch@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, David.Laight@ACULAB.COM, shorne@gmail.com, willy@infradead.org, Baoquan He Subject: [PATCH v5 05/17] mm: ioremap: allow ARCH to have its own ioremap method definition Date: Wed, 1 Mar 2023 11:42:35 +0800 Message-Id: <20230301034247.136007-6-bhe@redhat.com> In-Reply-To: <20230301034247.136007-1-bhe@redhat.com> References: <20230301034247.136007-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Rspam-User: X-Rspamd-Queue-Id: F322B14000E X-Rspamd-Server: rspam01 X-Stat-Signature: yqf4o6nbg4cxxy3j555m4j9a77rnjdfu X-HE-Tag: 1677642211-722259 X-HE-Meta: U2FsdGVkX187fInf+dGRV0Px5HbOpMJCSA02nPWOs2rb1fiK4hWvD4TDS8NTHRHL6lWCBz0eOgS+IMYau5mlwwHyRRpAJhKdo4n1PsBsvH7EMVshqQr2vJIEL6jy4FcPiDI1PGDQzfait1Z8kaGNhVB+TrRgHE39D60+GRtquNc4IjBSyGO0GPu/FL+PYGwwrRwisYEF6GLf9ffB1ZHu8BlKiX0DXVPM8N1b/WRIZpXTVEBuqsLhwgB0/uYWJA5YLBjpu84dnw+kvs0lPynsv6SCq1yZwcT/8lhpP81RHv9hmZd1mS2MHBp2UZcTYDhTD74Y/Yh0zR0MuLxVj+wmnol06fyxFYijDgDJ3+6QUuf9vK4LKVtW0jmL1Qm8G+lGMZgxJ+y5y7idzllmieF7W55xsUQ9v+iWgx75VTZH4GyRQ3sbdVOY/47VXyve6YJ517hdpRm2ApTnH3ijHPJji8uNYV25QPexjn0Dvq81XPrT12NL2iybNNkWzBUhC0cuvTI68xgo0C9oKO9Iz/orn7LXO11w4uujsnZjrx3haMTfSdF6a6NVc/Zuj+65O3Hb4hO568uVmW7v4tAif7R8ukATDCvTl4rESMq5D2qHLbx9LbC7GGkkVsroKJ1e5w2XVMSwQwZEkMopKcqOWzv768w0rZighe3vC8voktBOc0dMmcidPIxy40rghvPxVkShmJSEirJVuSbbvDPqHMEYRp8jjFt+OYA23ZLSWhoPFCDOK4gBHDb/egnPewUQMtvsXvRgMN0BMlD+PKnnaW5Inm/IfOi1rVB7RA/aIiIZC8WMK0g4ARxGUvNzz2EOdeopYPOYYmT9uEEqFFBEiPGoZ3nRKZtJ0RWbFvy2L6BPRvrhcNBAttQN55VRwwDSJmvkSsGWm2tBuRWhU9zGKw5FGZM2cXB+fmSY/3PFmKTkW96euSyoppzSBMyt2UMNb5lDjQwQPVhTXuDct2U+gVl 8mi3x9MO HflWFcUyDkdizFv89fU/aRUbusMRdi99/kKcsrZFXr3BJF+aPaKkwZq7ZMayRRQ7JeMpn3gi9cuerektub+4YluB9gKLw2OX10J3PLAILbPdIONaBl4vgC1khrKSLzq3zFa7zLJJpOjrFijgeENjD+/9g0IWWlbvQmKWnd5DAusV6GR0Y3omFa8mkjnxK9nFRhmB3VMBUI2WyU/Q2yGIwqQyfDhStzmGvFtXG9ofOT8atqtH0Y2MscT6h7DegetN/xHKLAgdiRoTjYPOIc08zNHrmAA== 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 Cc: linux-arch@vger.kernel.org Cc: Kefeng Wang --- 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 5a9cf16ee0c2..29ee791164ac 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 Wed Mar 1 03:42:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13155572 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 90207C7EE23 for ; Wed, 1 Mar 2023 03:43:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CE7FE6B0082; Tue, 28 Feb 2023 22:43:44 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C96EB6B0083; Tue, 28 Feb 2023 22:43:44 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B115F6B0085; Tue, 28 Feb 2023 22:43:44 -0500 (EST) 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 912136B0083 for ; Tue, 28 Feb 2023 22:43:44 -0500 (EST) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 497B3C0FED for ; Wed, 1 Mar 2023 03:43:44 +0000 (UTC) X-FDA: 80518935168.24.879739B Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf13.hostedemail.com (Postfix) with ESMTP id 7F7F420002 for ; Wed, 1 Mar 2023 03:43:42 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=NS2w9Xrw; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf13.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=1677642222; 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=b04gx2CEsZva7MKdHssokOo8Q5KwYfP6QKwltziak5c=; b=GWyAH3w7vV9PIjJGxq9nIlOoABeU4Oe46UfgcwCgItNSZXRWWD8EwxYBJ51YeldZut0TC3 dkb8dmLTk2OxBbYPhdPfUQ7u/wmdPyZyilODlugq9PdfD7yM3wXjRIk1LFe908VDim9us7 lHQqRm5CNf1tVCAawkx4Y05u7p8cDKI= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=NS2w9Xrw; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf13.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=1677642222; a=rsa-sha256; cv=none; b=Z3AWEQp180SXNpeG3gGmvNFVMVNyXsuMPgyk1zDZKNXvP3274KrfH51+zgpl32IhfpvKNY KN8oTQBCLLL8Ov4vbVYr+L310/lxeKH4hJeJr3AoAMUltTCGGAV3LaEL5WBzrmHWv7ldPI fo7Ma8bu8GG5gAs/l5iQHSmSEzBwELo= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677642221; 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=b04gx2CEsZva7MKdHssokOo8Q5KwYfP6QKwltziak5c=; b=NS2w9Xrw/Q68vAsiqWOEQ+oFv0e800p3rZ8WfciuaVXjlEBO5rn7AjaaPFK04csVMpdYbr 0nRtlqOTj7kIMFFhh+GKe8kmukr1IRJwYdPmDtQerIzxX3qSeMsW2SIrnSckJ2sA1cNYNX qPn7hX7deJ/SVHIVi7jN5mW0GN9wwi4= 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-434-8Y9zFz3EOyOEh-jq97Zmzw-1; Tue, 28 Feb 2023 22:43:34 -0500 X-MC-Unique: 8Y9zFz3EOyOEh-jq97Zmzw-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 61920811E6E; Wed, 1 Mar 2023 03:43:33 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-13-180.pek2.redhat.com [10.72.13.180]) by smtp.corp.redhat.com (Postfix) with ESMTP id D76C3C15BAD; Wed, 1 Mar 2023 03:43:28 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-arch@vger.kernel.org, linux-mm@kvack.org, arnd@arndb.de, christophe.leroy@csgroup.eu, hch@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, David.Laight@ACULAB.COM, shorne@gmail.com, willy@infradead.org, Baoquan He Subject: [PATCH v5 06/17] mm/ioremap: add slab availability checking in ioremap_prot Date: Wed, 1 Mar 2023 11:42:36 +0800 Message-Id: <20230301034247.136007-7-bhe@redhat.com> In-Reply-To: <20230301034247.136007-1-bhe@redhat.com> References: <20230301034247.136007-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Rspamd-Queue-Id: 7F7F420002 X-Rspamd-Server: rspam09 X-Rspam-User: X-Stat-Signature: h9yc3mc7pu9mmyqstpyi5ceegomuoimo X-HE-Tag: 1677642222-551969 X-HE-Meta: U2FsdGVkX1+oyz4vFba281h64P8/SzSg/SiaiJX9CabvdiZ1+FvGzM/QGnJT0TeX8CF96ybPbzbHrxRHq50GBBhsoNCo1OI0NS5ojpDGRpCPetiG0bC0wyE8DHW7qKgWs0+ORpRW1dIO/Cxo1y9R8EfLMNV3Qw1NuLlaozRk3DPN3xhKThWqJyo0cBQAjP1Y9fC549KsCvYEQ2pP7mFX/jJzfZ3cbv9t5acje18oGoQm6GELCrSe1vIcpSuRzpiBihz50LkoPjDYMdGtEmDEe8WgLZInfUGWadenn47ylpHTdmyBopcXKGdQ+SHPSIcGdWqDO/dpao94BMYqk93F3638lAS59kvLuq2+SNPzvZe7q3KiXeas1W1HCWVe8q3ZxNYJV8D8d1gqnEN4fjcYf8zELvn+C239zV+OyjbEQRyNFzeC9BRFoF+Do+0sQ2aNKTGVdGak3P92q7knrtRcDJSi547YiaTrCJLQ1gtjOGxF1KHm8rZkCcv4nsm5mnNxDBTYD2QplQUTOsr3/tGTtB9H/XWiHuOnbxsjoNh5oINzmiyIXaMr1FBIQ09lI0/8IDpw45S04sxTDkVWruK2XPOmOb0g73saZ+0W/Rhyq2b6xeV41xIri7Bj2gu5SwRZdyUquxRqsecAgqGSGrF1uWbqq4PoyudiBv1YLD3+Ex8VunjSOTRj/h0dYKkZTBZRRUWuagOj1GSbMkHIc7R+U3FP7uYmbGhDd44M/rKIQPdpPaImexXO0EZQ7Q4Io0Ek/yi4TVNbhEqQTVUen8r72DX6hC4ujjfsNTJTgArkntTSdn1DQl1BdrvOZwyIaPRSs6PPWyVYXzDkKZmE/m+neOPDUXPlY56fvdIPh1DVWLDA0egiYrxLZP5cmE2uHLmkWzrRHWvQugQbomL8h39FcBR6iFqWsG/KBB9kAZhyUQ6SkP+t2o4SGbccQV233ZVBC8vvms2fOYHccoMFEBo mUK7exLS YfDOg8m2u8G0WyfPGMk0N+2m3Cj80R3imuLPZiuvsbFl/pbRqUES42NQNE86lzFUkEknN63HY4hELxb8ZHN5NIkM9Hyj3wm0mvS6lDp5avDNACeCJCAS2ln7PVB6nfrx1hXa8dNpHKXM3AGO6twT3ISX8S68+h/ruBSQiMAWV7D6Zt3qG4xF+LmaGO7iN+vua8WNs6I7XzL+2nguTLqfay63jfJu5Z5NmCqNyOsw7/fCRw+wjuz6+MlgS+jENZIeC9tdiBMRqPOAWP2XjOZ4IRH/AcFcsNumbrbKstEZllRmmjzo= 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 --- mm/ioremap.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mm/ioremap.c b/mm/ioremap.c index 9f34a8f90b58..2fbe6b9bc50e 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 (!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 Wed Mar 1 03:42:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13155571 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 EA77DC64EC7 for ; Wed, 1 Mar 2023 03:43:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 853996B0081; Tue, 28 Feb 2023 22:43:44 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 803386B0082; Tue, 28 Feb 2023 22:43:44 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6A4926B0083; Tue, 28 Feb 2023 22:43:44 -0500 (EST) 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 5BD226B0081 for ; Tue, 28 Feb 2023 22:43:44 -0500 (EST) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 2BC1A120FF0 for ; Wed, 1 Mar 2023 03:43:44 +0000 (UTC) X-FDA: 80518935168.27.B56FFBB Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf21.hostedemail.com (Postfix) with ESMTP id 64B9F1C0006 for ; Wed, 1 Mar 2023 03:43:42 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=S808jwD1; spf=pass (imf21.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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1677642222; a=rsa-sha256; cv=none; b=mAgghscg3oYxLTibGN8ZjAKMZxAJZrFozXR3CJVYDPl7Sg6A7t+Msw9xi9Vd21X7tOkkZ6 xE9/IjpSO8eWJok+zoypB/o+W0UYXloTr1wdKTqjvABhZw74JYEpSAQxbiFizCh0QbF9ML pg7hSncpDVkGpaj7Y/AD1W2kjqCGC78= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=S808jwD1; spf=pass (imf21.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=1677642222; 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=+bd+DCGSFM6KdGYU7Bq43cbBBnA6se/fZx2Wohwr544=; b=meS1he6U8+Pb2J9KdJRGUqp5PuK0TeAQ/wg579u7Z4otxwGqRBdcD16S/5PuqzA9wtOb38 G9ygVWQqVBAQDRcTPtpDrb5P+swehvL4NHECVG5NZ9UygDnxtHDmbmu2ZTiLye8W0J8mq3 HFEluBzvr7n+aNF/N7FCy/h8WCMeW+E= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677642221; 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=+bd+DCGSFM6KdGYU7Bq43cbBBnA6se/fZx2Wohwr544=; b=S808jwD1UA347TTq5AEBG+7MgKBWsnVMLTlIlR8m04J8pSQSqTvsr0gDJbvjkpgwOsZnvD 6kqpioj7MLloMOIavYJLrTmphujZYEADrPrD1t4ywEtPLPE1Y4MdCQleOoCepvzSpobc4R EiGX6eFJLlWOBMcBkac5XgICNQtk7G0= 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-204-_J-V87EkPD62G46zbmOcsw-1; Tue, 28 Feb 2023 22:43:40 -0500 X-MC-Unique: _J-V87EkPD62G46zbmOcsw-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 937CB381458A; Wed, 1 Mar 2023 03:43:39 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-13-180.pek2.redhat.com [10.72.13.180]) by smtp.corp.redhat.com (Postfix) with ESMTP id 061D9C15BAD; Wed, 1 Mar 2023 03:43:33 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-arch@vger.kernel.org, linux-mm@kvack.org, arnd@arndb.de, christophe.leroy@csgroup.eu, hch@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, David.Laight@ACULAB.COM, shorne@gmail.com, willy@infradead.org, Baoquan He , Vineet Gupta , linux-snps-arc@lists.infradead.org Subject: [PATCH v5 07/17] arc: mm: Convert to GENERIC_IOREMAP Date: Wed, 1 Mar 2023 11:42:37 +0800 Message-Id: <20230301034247.136007-8-bhe@redhat.com> In-Reply-To: <20230301034247.136007-1-bhe@redhat.com> References: <20230301034247.136007-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Rspam-User: X-Rspamd-Queue-Id: 64B9F1C0006 X-Rspamd-Server: rspam01 X-Stat-Signature: 3zta5i6pnhnb43xob8ygdtwpzcsgbdw3 X-HE-Tag: 1677642222-37094 X-HE-Meta: U2FsdGVkX19AHBSJCBjukpOVdRIMWVwh2FGfRq8kDSLGxXniUgXiBqc1dxMMQiekK+p/jhNfPs3rm9TX5q/ewpsYBNiSC9POOWDUlzv6KnXf/7x44Ta+razUoErMnNGn3bb+63iWQy6fvRC5+s9/KbYn7eTCywZgTBZCtYET3sX1ez5LfdGbDflVQrsz0W4qt+2B0Kz9w6digHBeOb/12nuN0ZhfyEqpivlZ6zDp409objETCI08sXjO2vjgmTOVjF5SL5e8YbZln7DL0gOfM66RZmKxdVD1okurTW6faSggDEh9xD4y4/ys9JDCtiJb/Lez9jnyISZIMnnuw/7bHjVNL5l3+s9VZkH6krrf/56Ys2Jqg2oUKdWGYKQB4uPVDRH682nYABjMhjlmtqesuvNYk/arYOukzvjYHsqhs/6kRH2N9ipiYB4ACXX+4CdOGiljPPjOocawLhUP2ZRe8Q0lENH7Zkw1mJxDBTiX4xzfa8eFZVtq+9ptR+WrSHp/04+Kzx0AwYvGRsMv27Gnr22tP2tMXbwYcSE0TTCuyfVZGKWGh33WAAi62DclSKxzf3GbjUi9S4+HReh6tV+bap/+vWmjby2dKw3qbJYsEc1sx8hqWyhfGeWu6kBdC3Y3HrHPzW7/gxNRMmas955eFN5JSMWT1iP4Ofh71EhyZAxLSQmj+WgcVimkTw2OqodM6CZMphMgpmuyVCqEMpLeGBWzH0PIAQO9t2I4j4czrJrw/3j9KRgd7Mgz6ajuU4w0ucEBjdLtpv39sA+qd1X+PTj1ZCGF17D+0s8VXVjzQF4w0CQ3bnrzAd+KGLy+P36ScoRxda/gv+txFEsSLtu63n033IaVyRqd+/Anf3BW7Bu7oCiSaHZ8WsqJAKbQYffjwMFI2zQQubggSxXsLVY3XplxBqJcryO7hsMMjPcEomZs7c3gpm8g2t3TpA58sDzPzRFztdxyS5td3sYjPQZ qxOyXiut rHaz/1A/F7rJTIwLYbKNwMbIs5OtCBTZORrYFvWbG9/GhZtdg8fREIkRLozTtqSN+45JDocOhkhMTUR9F5GfcHkIkBXKYLaOnjB9OZYWyl+3JppUnqdtrtxOIrAa8rfYNWEOvyNvtIz4G+koTFOGR17EX7gF0vNf/eDU6bXb0+dHvfe5so0wBj/biC3hvUH0kijkWPGBaFEO4nBJK12A2s55/4kUqFlVe9Y4a2ZY8MZS+/Lq8XQ0GcR2w2C2bAs6y0aCzeeoX0RIWpMOcral/b7UiIl0hND1GIEH+yE5R0a8k8TO9NJB72xn5f6F8VYbyfehYXjnT6UwvAbtEtoiLIxT6sD6/9+A6jvZEfjhNH/kZLXo= 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 codes 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 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 d9a13ccf89a3..37da34ac7abf 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 Wed Mar 1 03:42:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13155573 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 A39DBC7EE23 for ; Wed, 1 Mar 2023 03:43:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3E5116B0085; Tue, 28 Feb 2023 22:43:53 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 394F36B0083; Tue, 28 Feb 2023 22:43:53 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 237066B0085; Tue, 28 Feb 2023 22:43:53 -0500 (EST) 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 1220A6B0073 for ; Tue, 28 Feb 2023 22:43:53 -0500 (EST) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id E7AC4AB34B for ; Wed, 1 Mar 2023 03:43:52 +0000 (UTC) X-FDA: 80518935504.21.D10815B Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf21.hostedemail.com (Postfix) with ESMTP id 1E5F11C0002 for ; Wed, 1 Mar 2023 03:43:50 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=gurth9Zj; spf=pass (imf21.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=1677642231; 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=JSBskRH3zN0SXR915sPzY9L3Zw+2FPOJn9W+BKcVjBU=; b=kt98439zTSCgdvrQ7dkbSFffb7JlP75Z7hYtkJJtCFICEVVjFib9vkSUX11K0BixvKv+tt 5XU9I7x8WoxtR46OJUs4UkSdRgSuWaUMVBcLRdnspI/3OZ7CmfNu4LpeJ528nICDf03Lpq VYjCktCvQuvv0f50ZM7wcBQNpRKRtVY= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=gurth9Zj; spf=pass (imf21.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=1677642231; a=rsa-sha256; cv=none; b=AkA2Bo/ert0itTQfSoKZKR2oFx5zQNf5S8ZthhHSDZOBa9KZ0xYZPdiGu+flmgz/tJCbSO YaVpg9/ThkqKt64XadbI/VIEyxaA2BAWkjjtSA//MscTIV2kbymsTZXIPrAsrlqkn8krBI V5pbgXoCOVkFe3/acumxX4kb9SAFL3Q= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677642230; 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=JSBskRH3zN0SXR915sPzY9L3Zw+2FPOJn9W+BKcVjBU=; b=gurth9Zj/whr3kmGRUnGgNagE9hgFlg42t2J9JCXLpBAJpqb0xCr81tHarLoZuos92vjA/ fJzwPQmt9MC9gsz4jvxlRDXkSRsz0dI2jFyrd5IdnNrfEkjW0KFyRGfnjuCZo8UmOZtnbS gUzcDLTEOEAPGcaVPWtcLHVIol6cad0= 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-647-BotlniHDOQCs-0dgE9B3-w-1; Tue, 28 Feb 2023 22:43:46 -0500 X-MC-Unique: BotlniHDOQCs-0dgE9B3-w-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6B68B18A6463; Wed, 1 Mar 2023 03:43:45 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-13-180.pek2.redhat.com [10.72.13.180]) by smtp.corp.redhat.com (Postfix) with ESMTP id 39504C15BAD; Wed, 1 Mar 2023 03:43:39 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-arch@vger.kernel.org, linux-mm@kvack.org, arnd@arndb.de, christophe.leroy@csgroup.eu, hch@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, David.Laight@ACULAB.COM, shorne@gmail.com, willy@infradead.org, Baoquan He , linux-ia64@vger.kernel.org Subject: [PATCH v5 08/17] ia64: mm: Convert to GENERIC_IOREMAP Date: Wed, 1 Mar 2023 11:42:38 +0800 Message-Id: <20230301034247.136007-9-bhe@redhat.com> In-Reply-To: <20230301034247.136007-1-bhe@redhat.com> References: <20230301034247.136007-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 1E5F11C0002 X-Stat-Signature: fnn4m41rb1j5xr6bmgaof96guf59ttrf X-HE-Tag: 1677642230-464283 X-HE-Meta: U2FsdGVkX18UmFRIR9n6hXy5x7UEKpTXygXVR5P4TMGXyBBiZ/gJjoPtOhNOmwMWTWGMECMn/fHWIzdDHagrA5dfL5wpIIwp3LPWDLryWXn6o/U4pp8m/SIQ/cJf3YFG5ce+lQV39YhLxtCuV7pKz1SSfkWqWL+WOjTObeSrspe+Wiws/De0RwBBOpXLyRPyssXzg5EGlObj6XghdOiO+Xu3Bpzr/OKojLZzjY+Qnyp1vJ4vwn/wgrBtFv59tsmI0yAFvgtr9qYQEZ91q5Coq+gtrvjLoXjYjBo3NkamdrWdadWnzCOcgXlhcsXtSi8YtRcoFhQTpN7SK4iKWtjmQ7NPXInbJAZxdxfx8BcCx6daObsQyGxGLGSzd8S4kqPcAdy0pufvhFXa5584qqoqNQOyFC6SaTpQ0jl+naYRQvbmkhwfQJOwaY+7FNzo7l3nkq6OykSBwmzP6GfNxoxAr/ScwlbEfetb4NHfq25OhNroJhgGFhrUUo7ahQcG6/XRnIOKD+NhyU7m72coT+ZjTa5olOYKLD9kP/gEABzO7J9j54IFHI9VorsZ7vuwxUB64vl/CimoHXvtGu8o2XAzqTcyQKQhdfP9cCV5Uqrum57XQVi9fVmLujV1NxgUR78YHWbNqmxqTfPWcildgUtAHpEHPH1P9bIcglB0R/lwqhHJtNLWng+Z4wMn0auFGgTt83EPQ6snwavK065tWWFnGWRbg1gJyXA5rK6L6M+L82lJUBnt6UZ2J54uguBbWvhP0FHC5yvA1aNy3JhpOtOuUQCPsgfcerZS+lEHfBdnFoN+NlSfAhx+SbU1FgrTNkL2JovoZGqdrYlB/UQu/NljcI+vcrb1vUyuaoz7icd3tXETJ6cnfAmwaWWrLmVd/hQdkZWpzDAtZaWpVs8nYn0yPX7jegH8rPqW0GZNN4meqnZkZvLZuvNETSLq4X4ufue8uvfOjMAqyivw8eLeeGO H38RtuLq CWz2jnDmUt+jjx5D/Q0hS+klgXlUX1jhY09GCf/gUPkauM4zqfN2jguIBrklqZaRnTQZ2BRO255o6bls+inRjmziEvWeWwMm+GHDd3Vd4TmiWWHR8+6LPHlCeroa/SSvi6eFtG5F4u6TDoi/CGr/1fPBUp5AWB9guOIignPRE3HHUDjlK6Qe1wdsKjsDxrYY6ulnVPBHXGxTxX1HoG/TvTV7QKgdaYoI6OanZ+tkV6xZrXTn0/cvMWvkTpGOLJKxaalCnHrctZClNSZo+6hNM5D39yuUUpxDmS+6pS2MyvH6zpfM= 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 codes 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 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 d7e4a24e8644..74568cb73d87 100644 --- a/arch/ia64/Kconfig +++ b/arch/ia64/Kconfig @@ -45,6 +45,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 55fd3eb753ff..35e75e9c878b 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 Wed Mar 1 03:42:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13155574 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 97BB2C7EE23 for ; Wed, 1 Mar 2023 03:43:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 34A5F6B0073; Tue, 28 Feb 2023 22:43:59 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 2F9326B0081; Tue, 28 Feb 2023 22:43:59 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 19A8F6B0083; Tue, 28 Feb 2023 22:43:59 -0500 (EST) 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 080D36B0073 for ; Tue, 28 Feb 2023 22:43:59 -0500 (EST) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id C73BA160FC4 for ; Wed, 1 Mar 2023 03:43:58 +0000 (UTC) X-FDA: 80518935756.20.A3335EA 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 12E0E40004 for ; Wed, 1 Mar 2023 03:43:56 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=PF0ETX4M; spf=pass (imf17.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=1677642237; 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=K1VrnQks8P5H4lhuQHdk0PEcxF0GSibhsi/oBTknLWs=; b=P6/E/dJjw072Q36qYumwBTS5o6IV1NtYcDVzQFOyNCojv42IRRhvTKooD5hHYAmdTy80n8 aUIcISI9A/T/qbkHz2Rdg+o7jYNScmmsFB/ta2NVMPgVf1bWthW/1wWHe02mIjFG7WE5Vu 4rLNzhcm4jHDbR44mKk2k2OaYBTQOYQ= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=PF0ETX4M; spf=pass (imf17.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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1677642237; a=rsa-sha256; cv=none; b=T64NROtEmQU9c5URW2NKEj4oOHs4U1HEebWW6XtU2JC64FZjdtdxX+9q8+mYVzD9LEtSUj YNjwEGpOUzLaaZMCFQ5JhvB9+P7509WfR1OL7HQ/TFRqzRI4GSc6MEIoBbCT5twUa7RZIl FW9/tRQseEPQDrKyD3bZ30GYoNaAT3I= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677642236; 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=K1VrnQks8P5H4lhuQHdk0PEcxF0GSibhsi/oBTknLWs=; b=PF0ETX4Mm+bFzVG2Zcmi50Msj8A4uod/wN4EegxZQAUwZif1h6U2t4ZiXxZ9lDQJSoqCEE 1YYOb3AQObNtBG088BNfYVHoFfoVwmxoJD9H1VclrZxIm305SjKSocy3f+1z0IPWHx3uuD /5N194ofUliMHo3SB517evtI4oQ1Z2w= 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-170-EoxYF9wcOPaWWVVcEoz6SA-1; Tue, 28 Feb 2023 22:43:53 -0500 X-MC-Unique: EoxYF9wcOPaWWVVcEoz6SA-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3E20B185A794; Wed, 1 Mar 2023 03:43:52 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-13-180.pek2.redhat.com [10.72.13.180]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1E76AC15BAD; Wed, 1 Mar 2023 03:43:45 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-arch@vger.kernel.org, linux-mm@kvack.org, arnd@arndb.de, christophe.leroy@csgroup.eu, hch@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, David.Laight@ACULAB.COM, shorne@gmail.com, willy@infradead.org, Baoquan He , Jonas Bonn , Stefan Kristiansson , openrisc@lists.librecores.org Subject: [PATCH v5 09/17] openrisc: mm: Convert to GENERIC_IOREMAP Date: Wed, 1 Mar 2023 11:42:39 +0800 Message-Id: <20230301034247.136007-10-bhe@redhat.com> In-Reply-To: <20230301034247.136007-1-bhe@redhat.com> References: <20230301034247.136007-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Rspamd-Queue-Id: 12E0E40004 X-Stat-Signature: 9ijyhm656gjhznzgqfyfwe5ejz6bh71n X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1677642236-744384 X-HE-Meta: U2FsdGVkX19guaweHgGnqx22h1MLokM18FmlSCtr58IhBBcttweXrdST1JiScXpB/MLHFyKtprDGUqtbSFZrD5B9sO2AeQuGh9QYfYIJhnFh/0xdWA52HSBAWP/ntF3VN13UkBRWQsMNmBFdTC3UDQ3gZtnNl8jT5+tI5byXPGAZAsFkzSUcO1ey/n0QjJphKS3mfmMSjXNxBfcmRx6zHmDWa4Dd23/VtE9bDJPXVXTiVhmTSCIUFLvzyILmtPxsjAdKXbM28wu6vDRswwamGyBc7+fGydn/Opo3+6XgHDEWjWkEg23PUnU97I48ecavQbcHnZK5LGvend3bCUWBiSVz0W2sB8A0W06rYt/AFur4wSAVomYGa7+xvuuTJ0HDzKJ36ibUKZ/17V28AGup4+lWM8xeSMU2pX5r628RUey7YkOXH4VJa1FrRYMuVlTsYF781UHyDP94hq/RXP7J0oWoDUNKl9iO6korprDf6B3gPhClOcu9cHidHSsJPeKi0YbCtj5Y1GxsI7eVPb+uRPsMoer7bt4qHdiGOCHftIBNibLFpcySDrrfF9fq0I7kwZ0ur+k2YznKpSIN7z231h/8jMmiRpGT6uTlZDjOktmZ09w2jxdOuJB7lwrmgXx0m4zwvDlPECt1yL5dhl9TAJK3UV31tqBU2lI4lRSRtt9vk8q2HlH3fJ4PPghXS/32FmEGg+bDI6NVFX2wNp1Li5MhhqUn1hMUJLh5GcUBe9zbEfrQvL9j+9J9Fun4nkaeEUBoSlABgU29tOF9hiu4NTnR9FHIHU7WFt9TLVGG91pC78bfF+HvabtAHVN5hqm2ZdFcJ6+MVBM6cLJlwtB2IQY8hpZShWhkvcFEaeCm5i9AWkt/t70HTg9gB+Zxe+edNGWsL71IOlF4AAafCtQ4NgE0UoWqhLWWGYSlh6Y5TJ+ClusirpiKbVfMFaBydmuW4Ssbow6er1aBxIkV0jV x56xF3JL xwWWgRY/lFUO3GASRN80l9gL8KmKRVEcK0MKty4me2MR4PItqHFHnhQC8FVycKNFARS/bOkEYK5FPuyvjFrVeF6eCTvxNIFJN1uN5kmjXul0L3VJdm0f0g7SA3aocV8/GsIFRq6WOOHKPmu5xxq+22EZmucQ4HwXRKqNS8kneKFdNwtIUabwQlnL1TQvHXzgOegG+PUBB31e/rf7jNp1bbeUvD5h4ozsbI/jnoVNtRbLLpfKwGcEBp7j4Tb14wFK1chGDMJDGHSRvf2lDqOvYJofBXtDGXF1SGiOuOVJ7K3Hk8ukCtEtLxDBvEEvlqhSEyW8C 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 codes with generic_ioremap_prot() and generic_iounmap(), and has the equivalent functioality as before. Here, add wrapper function iounmap() for openrisc's special operation when iounmap(). Signed-off-by: Baoquan He 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 | 46 +--------------------------------- 3 files changed, 9 insertions(+), 49 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..e640960c26c2 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,12 @@ #define PIO_OFFSET 0 #define PIO_MASK 0 -#define ioremap ioremap -void __iomem *ioremap(phys_addr_t offset, unsigned long size); - +/* + * I/O memory mapping functions. + */ #define iounmap iounmap -extern void iounmap(volatile void __iomem *addr); + +#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 90b59bc53c8c..9f9941df7d4c 100644 --- a/arch/openrisc/mm/ioremap.c +++ b/arch/openrisc/mm/ioremap.c @@ -22,49 +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) { /* If the page is from the fixmap pool then we just clear out @@ -88,9 +45,8 @@ void iounmap(volatile void __iomem *addr) return; } - return vfree((void *)(PAGE_MASK & (unsigned long)addr)); + generic_iounmap(addr); } -EXPORT_SYMBOL(iounmap); /** * OK, this one's a bit tricky... ioremap can get called before memory is From patchwork Wed Mar 1 03:42:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13155576 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 111ECC64EC7 for ; Wed, 1 Mar 2023 03:44:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9D8C06B0081; Tue, 28 Feb 2023 22:44:08 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 989046B0083; Tue, 28 Feb 2023 22:44:08 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 82B5E6B0087; Tue, 28 Feb 2023 22:44:08 -0500 (EST) 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 706646B0081 for ; Tue, 28 Feb 2023 22:44:08 -0500 (EST) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 4E4EAC0FFA for ; Wed, 1 Mar 2023 03:44:08 +0000 (UTC) X-FDA: 80518936176.14.3BFD420 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf05.hostedemail.com (Postfix) with ESMTP id 8C164100002 for ; Wed, 1 Mar 2023 03:44:06 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=PpHcGE3E; spf=pass (imf05.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=1677642246; 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=/FLgE8Yk+wfwjzfdnog8eI5cWxzgyrtvGgGFFqIapZE=; b=cSGgpRPjH42IVRS30V1d9nGySn9Dd+6nLb9USH3fNvdI6vpT8fd7lgkQbTOoN3dZ9QLIci mFaxY4FD+l6kQeLg6/Ib0V93i7t576k3KlPRpbgKEz22gJ7N5AxBl6J2kGiX9ExPBU+vx4 D0omfcJMIxcehL9uZtzRfwMZsx8KL9s= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=PpHcGE3E; spf=pass (imf05.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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1677642246; a=rsa-sha256; cv=none; b=O9PnxIpbNRgPBszr7BNd7dUkOvgz0D1OGi7u6gLvqHOMLdkuOHmHhvLZJvWL2MhOKU2Sh8 OGozUXvx7Ci4blw2rOUk1mTOz9e17UVeOE98Ym5JwGeL00NnvH2u2H5l7Tw4YAt78g3kVr /X+/yNNbu22fiDNQ3vDNpXmHZee8h1E= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677642245; 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=/FLgE8Yk+wfwjzfdnog8eI5cWxzgyrtvGgGFFqIapZE=; b=PpHcGE3Eh9wkidgAjxTDxkuRdBDr0ebyhrmOyLoGv910seoPwconxLqfXwqXeS7Z49q6Z8 9w6JAQO/AejBR1WctGjUGJH8k9ZsQCTAEu7gkAIefqRJIYiT9f1Y2G6UM26tEpCF5db0AL YfAoBCPjPeqBQOyXG32mqHlMB6aNTks= 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-656-nXdLbipDP7WqmKZxoBkyKg-1; Tue, 28 Feb 2023 22:44:00 -0500 X-MC-Unique: nXdLbipDP7WqmKZxoBkyKg-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 90C2285A588; Wed, 1 Mar 2023 03:43:59 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-13-180.pek2.redhat.com [10.72.13.180]) by smtp.corp.redhat.com (Postfix) with ESMTP id D5FDAC15BAD; Wed, 1 Mar 2023 03:43:52 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-arch@vger.kernel.org, linux-mm@kvack.org, arnd@arndb.de, christophe.leroy@csgroup.eu, hch@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, David.Laight@ACULAB.COM, shorne@gmail.com, willy@infradead.org, Baoquan He , Gerald Schaefer , Heiko Carstens , Vasily Gorbik , Christian Borntraeger , Sven Schnelle , linux-s390@vger.kernel.org Subject: [PATCH v5 10/17] s390: mm: Convert to GENERIC_IOREMAP Date: Wed, 1 Mar 2023 11:42:40 +0800 Message-Id: <20230301034247.136007-11-bhe@redhat.com> In-Reply-To: <20230301034247.136007-1-bhe@redhat.com> References: <20230301034247.136007-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 8C164100002 X-Stat-Signature: rxxuapnnu7kkdopk9187suzy7o4j7ks7 X-HE-Tag: 1677642246-752915 X-HE-Meta: U2FsdGVkX19niR9kSULR1Bt0t7GC63xdudcXJ28w7rxcEDQj69PaHinWns5ImijFsPXzi+u0AdkBDg4yyFhgd8lSES5x8n7/683Ol1chNCHzIBNPvVFULVGLnKvPGbQxGeWOge8yQU0kas3en88m3ba8/4wqh4ujyLqv2CITizxgHez4dllT6Ge1ltzmq9jYQKZd4DSm2qtl9wHeAunBv+hpLmlFWD85jHqXuQXf3DNdQyA5K6fVQfoApzH5Qm26mzTKA3+fjI8IkPSTTtCPVaiAVNqp75T4VNKpCZAHzQ5enJXVbEeVuHaCD5d53bVYAbItQU2qOd1ZiL58AMSg4kcQk94T75Ym6w7E33PYNJc0m31b/z+No4C9z/3Vto96WncVW5jj/HXO6HQZ23XTE7al6uN5HKGCzrtQdFevppLFFk4SiGDmKbMmI0lyDR3HmBB1jv9HraFTyNmmlCrXMNcxeqU8G8RsRFN8SCEAKgIQlFaWvKH3uHecgSW/Q1z0OUF6+BRr7GtjjgIOjeocuA2s4Nn99goXQnbBVpAARDa/rRAJCQOt+mg0QdJVw1oJuMnxdeITd8CP372yIvcMc8ATKvqlEAgZ/DRTrEzOMUV7zsQ9ey3oMih9UEb0DpiwBoIxAk707tNPQv0xQGyOyK1R3qhM8tYxGTfB4+bAMbIQvJtlMVyJltZYLUdod9PWwDAznVm5TWzOuodrFFcQtmw5/gy2bFiuVdc3WILuoeNSCFAgZT8SftpTH0nHUHjkzah4Oy1Sqd3Tb+pPA19HAMWPJHVYT4wVYw+9x5ESvgqnFEiJd5SYOZdQC696GZqSI2GVzxFnu94BqWwx9i9UZkABLD3sXw4yIAIfYReGmdbm0OyeBKUP0F3lbzw13CsBOvYbt5tDd0gw54YkWD/UEOBkBsXrG7mEkWUVXA8Qvowi9knsfC9vUsAEZgipW1RQDsFdDxJYu05+btqWgbk Sm7wS84Y onwxOhV7GZ804jRvZxW9n9Wv5D9aZTbZoJSw3/ScC65OnqZx98m9stNjiKWYdxxoHbGoCljlv9J5VQPf1faFTd+cBrfIxI4qITOM/BrMIwuDGYoFTwamyobRgJo3Bp+6XBEoAgi4d1MQTXCuRLCN6Zm1pfPAZ94SxwLzqaWiJP62PkvFCUH7QkHSpEfEJESqtjIsyk18YZ5QfdbS+tGNNmPvcuObZp7aQRnnih+lvyhHxfA+9yZyQLfriTdBmeOXl2MBqyafgO0xkloGmksYaLltsIwvIYhTxdksqvtVlxQVNm2RZlfU+nOM4SIyQhidJJuiH 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 codes 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(). Signed-off-by: Baoquan He Reviewed-by: Niklas Schnelle Tested-by: Niklas Schnelle 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/pci/pci.c | 57 +++++++------------------------------- 3 files changed, 23 insertions(+), 56 deletions(-) diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig index 078cd1a773a3..74505a5de3ba 100644 --- a/arch/s390/Kconfig +++ b/arch/s390/Kconfig @@ -141,6 +141,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/pci/pci.c b/arch/s390/pci/pci.c index ef38b1514c77..9590bf2c0d88 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 Wed Mar 1 03:42:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13155577 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 08A63C7EE23 for ; Wed, 1 Mar 2023 03:44:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8514A6B0073; Tue, 28 Feb 2023 22:44:16 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 801C46B0080; Tue, 28 Feb 2023 22:44:16 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 67CA46B0083; Tue, 28 Feb 2023 22:44:16 -0500 (EST) 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 5729D6B0073 for ; Tue, 28 Feb 2023 22:44:16 -0500 (EST) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 3171DC0FEF for ; Wed, 1 Mar 2023 03:44:16 +0000 (UTC) X-FDA: 80518936512.06.7CBA438 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf28.hostedemail.com (Postfix) with ESMTP id 713F5C000E for ; Wed, 1 Mar 2023 03:44:14 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=fAlisy9b; spf=pass (imf28.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=1677642254; 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=QVTDIuzGqj+0AznPZIdOL0y+dZAfOPA4Q2ivFIOFZp8=; b=WnufZBZT5NbcJRmwWf5IA3tdjbVN4xWjoRWyrXQf4MoRfSm8ULfSVVkdogLwKsnQCSKHAs e7/CKCHK5Bi9mPP+oafhRU6fDYSZz5MqUj1hGBx6cY+mkRWmBRiVvfUqosEr3/3/pTa/R6 vN3ujk1qY0A6FFvaVxHgNxaTaKplnJw= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=fAlisy9b; spf=pass (imf28.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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1677642254; a=rsa-sha256; cv=none; b=3e+Wd00UtzaNZnLY/dxmhU6hwZdB051V2B/q/LGzlt/3uJjwlWc298lK7MsMhZ8un6Uhzk tj91j6bTPo+F4+DhEDmIkXwugK6jN3tIVWqmNv6JGCpLvVtBYSZYCxIx9TIfsU0GhStNmD rVpA5yfvfxZ9JdQprDvci5aozGBRLKQ= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677642253; 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=QVTDIuzGqj+0AznPZIdOL0y+dZAfOPA4Q2ivFIOFZp8=; b=fAlisy9boAGkMWljUcGTalJ4SmUq+IIyCUN/DSs/vmVVOhB68Ofejt4D4bWdWJv2DbMDEV YliCGua2Tz4MM7mcO/ZPsEBCpEwXD9ThXrBgUSxsDo8QI29fPHsN/mSu/3s1J5gy0LnNsb HQIu2k9b71DC3oRBtSojq3O0/9UPzNc= 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-626-OtzYJ80dMqmsQV3f-Zk21g-1; Tue, 28 Feb 2023 22:44:10 -0500 X-MC-Unique: OtzYJ80dMqmsQV3f-Zk21g-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8A72F101A521; Wed, 1 Mar 2023 03:44:09 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-13-180.pek2.redhat.com [10.72.13.180]) by smtp.corp.redhat.com (Postfix) with ESMTP id 364D3C15BAD; Wed, 1 Mar 2023 03:43:59 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-arch@vger.kernel.org, linux-mm@kvack.org, arnd@arndb.de, christophe.leroy@csgroup.eu, hch@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, David.Laight@ACULAB.COM, shorne@gmail.com, willy@infradead.org, Baoquan He , Yoshinori Sato , Rich Felker , linux-sh@vger.kernel.org Subject: [PATCH v5 11/17] sh: mm: Convert to GENERIC_IOREMAP Date: Wed, 1 Mar 2023 11:42:41 +0800 Message-Id: <20230301034247.136007-12-bhe@redhat.com> In-Reply-To: <20230301034247.136007-1-bhe@redhat.com> References: <20230301034247.136007-1-bhe@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 713F5C000E X-Rspam-User: X-Stat-Signature: w8kqieedqktq7aaqxui6e3d6ztb9ehck X-HE-Tag: 1677642254-600733 X-HE-Meta: U2FsdGVkX1+ubJXLxsWdIh+40FCqWTb1qbTCoyfA+LTO/pSHc1x+NxCMEyOx8V4AFkpVtEHL7B66AyMI4RQ/NNCC92kdmYzLZl1P27OdeJtJNSKBHMBiXIjmz91AiJNZcwu9uUnhTY83ib7wz/A7P3GkC4hSNcpUsZN3aRZNlQcM2Gj6Sg9Y9DtqQ8GIiyiK/LGaw5gPttU2aZIbcFo0OyN0vN/zaJ33Otg6V7NtSxaW/1enYVGwtrslE4VFZ+nLxdQg0jA2GppkfIpuBG8D3UP1VETJ6NcNhYy4uskqumoznpUR6KgpkuoVrbuSBuC1dtUzJEDCQuSIDuRNgc2lMRSPkR3eze17gJ9JNnT+gxae0hJz4aT6mlQlS1S13wlpGYf9V6qX1bYxvUETGrJxyRUXEkaugRVlpCYFiXZMflhiKKRNuXROZTyzfJ4mlq3/Qt1Z3S9cZGStyFEJ2IhHZzU1J1Fy9DwJ+tNuPBPReIQswYouOgilipneyBmUmOad5sqv/swQ0gE6IC4Eqo0Vmd6qYJlrBJJTDONJHRTje/vyxZ85g/Iu36upPBV9Z8ChZBruUpaH+Ot+NIdUXCU2NCzHmXrOxXo1FuWaVxGcMy9ZqwZI6ek33pN6tzMzBYblGsezMYpuTPqN/03yXZp/Z3atpuuWhpJ77HIsk6OnULEfYkZea4izndGTICJSOD8DGBBTrZbkyzG4B3WutwuCeQaGpySwnYaJzaCglWgnVbmW/Kh0S0NJHNAGtmJjVeVF3i9/MMqNNM3iVIMpf/XTO3gNtHm0kXWeMp8Np7ZNuu0RzW+0V9Ny2i2V+ybgmpyAAvYiEuPzD28BJU74Xbgdv+sXUWWb6VwtYG5xAwkhdLTTMR+PkDtEQONbXvgMTaA55RPIrrjZNc7Xd114QZG6o+biVqMo19Kg1QXfh3LlcTWEkac+Z8OtSMAeHePXLahjAQcQL02mVBsERzyAe9M HI+PP+pE jo3KaVGCuqczHTw1EekglSWqTzt+wOSnv769Z9lb19fDb8FlCrngMLohuqo8vDFP3ZaXwCmA6HbG7IncGz3c3lfTVz9psvEJmoy3ogCNLvZm+67mmCVNr9U6mUKaCU3Pcw67J4bexG6xo3+tAVqoFPw5+CgjyCZ3iYXwKgoevnauDsM3chRoNTNPAVkQRVkEYI2FEWglOBpsGJg7cMM3z5ykTe/ZqRvTJLcnJxbCt1qytLXlNSIsm3z3C0wl1IamYk43ICSi2QIfPxi7ijH/xlqTLatZEOWMC2FwBOcMGP1wSlNdAIP2+LSYMKZ4PXP1gTc12+WQ/OPsKC28il3ANcYMn43zx/k6NGsaYamxnSuIxrUT/yBuKENATKQ== 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 codes 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(). Meanwhile, add macro definitions for port|mm io functions since SuperH has its own implementation in arch/sh/kernel/iomap.c and arch/sh/include/asm/io_noioport.h. These will conflict with the port|mm io function definitions in include/asm-generic/io.h to cause compiling errors like below: ==== CC arch/sh/kernel/asm-offsets.s In file included from ./arch/sh/include/asm/io.h:294, from ./include/linux/io.h:13, ...... from arch/sh/kernel/asm-offsets.c:16: ./include/asm-generic/io.h:792:17: error: conflicting types for ‘ioread8’ 792 | #define ioread8 ioread8 | ^~~~~~~ ./include/asm-generic/io.h:793:18: note: in expansion of macro ‘ioread8’ 793 | static inline u8 ioread8(const volatile void __iomem *addr) | ^~~~~~~ In file included from ./arch/sh/include/asm/io.h:22, from ./include/linux/io.h:13, ...... from arch/sh/kernel/asm-offsets.c:16: ./include/asm-generic/iomap.h:29:21: note: previous declaration of ‘ioread8’ was here 29 | extern unsigned int ioread8(const void __iomem *); ==== Signed-off-by: Baoquan He Cc: Yoshinori Sato Cc: Rich Felker Cc: linux-sh@vger.kernel.org --- arch/sh/Kconfig | 1 + arch/sh/include/asm/io.h | 65 ++++++++++++++++--------------- arch/sh/include/asm/io_noioport.h | 7 ++++ arch/sh/mm/ioremap.c | 65 ++++++------------------------- 4 files changed, 52 insertions(+), 86 deletions(-) diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig index 0665ac0add0b..9ab627f97c4a 100644 --- a/arch/sh/Kconfig +++ b/arch/sh/Kconfig @@ -25,6 +25,7 @@ config SUPERH select GENERIC_SCHED_CLOCK select GENERIC_SMP_IDLE_THREAD select GUP_GET_PXX_LOW_HIGH if X2TLB + 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 fba90e670ed4..b3a26b405c8d 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); @@ -243,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 @@ -287,6 +286,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(); 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 Wed Mar 1 03:42:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13155578 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 35490C7EE23 for ; Wed, 1 Mar 2023 03:44:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C49B26B007B; Tue, 28 Feb 2023 22:44:22 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id BF9626B0080; Tue, 28 Feb 2023 22:44:22 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AC2916B0083; Tue, 28 Feb 2023 22:44:22 -0500 (EST) 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 9CABB6B007B for ; Tue, 28 Feb 2023 22:44:22 -0500 (EST) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 775FCA0F67 for ; Wed, 1 Mar 2023 03:44:22 +0000 (UTC) X-FDA: 80518936764.05.D0DFEF9 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf25.hostedemail.com (Postfix) with ESMTP id B7D97A0003 for ; Wed, 1 Mar 2023 03:44:20 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="ERa/GmnD"; spf=pass (imf25.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=1677642260; 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=9whDoNwe8yovUO5v26C7zBzC5y2FxPUW+aeJ84UAlAo=; b=2pwTezYUxfpZFDIhCZb2bP2Yx6pyTr6Cu1xgwMLtPJiS+xmM5jF/Sfls9nlfwhrSDEAhge nOYVsavA4J5bbeVRD0BBu+3K6MNxwdy2l+xaaoasbr8N2PDdQzehO07zIeCNKjHZl1BsxB 6h98AoNOToTZaFX09gW1sCzXyGDHjTI= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="ERa/GmnD"; spf=pass (imf25.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=1677642260; a=rsa-sha256; cv=none; b=TKaYyCpOupfsofPes3JGwbqg+kNt+gM48aak1P6YqNkCAMSXkOYpsov32fnZHj1aiKSbW5 k50ZC7O/0F6pR7QEUhX8adz4MKx75ON+4v5GT/Vg4M/tKlqAijD9YShRdUsym/B6d0lkHN SK1aIBDP4Wst61qBIZFeyOXMLWRwnmw= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677642260; 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=9whDoNwe8yovUO5v26C7zBzC5y2FxPUW+aeJ84UAlAo=; b=ERa/GmnD12OcKkdDlUerUir5oQnlrSXTuXKZMoyDT73hAU5wRfka0O7/zpQNjp3jvvUi89 CJWuJ4bQ0JoRR9wWNba2aPSRQB/cKQiFvtBRAVfzpBJ+MQ7u5ow1dZ5u7vNP/D0GfQic6B wJ4JYnCp3hHOEqq1+2D2puWutjhsESs= 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-133-2dc4BHpnPxaMFbTsR4-azA-1; Tue, 28 Feb 2023 22:44:15 -0500 X-MC-Unique: 2dc4BHpnPxaMFbTsR4-azA-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B38403814589; Wed, 1 Mar 2023 03:44:14 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-13-180.pek2.redhat.com [10.72.13.180]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2B5DEC15BAD; Wed, 1 Mar 2023 03:44:09 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-arch@vger.kernel.org, linux-mm@kvack.org, arnd@arndb.de, christophe.leroy@csgroup.eu, hch@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, David.Laight@ACULAB.COM, shorne@gmail.com, willy@infradead.org, Baoquan He Subject: [PATCH v5 12/17] xtensa: mm: Convert to GENERIC_IOREMAP Date: Wed, 1 Mar 2023 11:42:42 +0800 Message-Id: <20230301034247.136007-13-bhe@redhat.com> In-Reply-To: <20230301034247.136007-1-bhe@redhat.com> References: <20230301034247.136007-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Rspam-User: X-Rspamd-Server: rspam03 X-Stat-Signature: rcwo11kdeu73de17z81u6o4sct585mb9 X-Rspamd-Queue-Id: B7D97A0003 X-HE-Tag: 1677642260-98640 X-HE-Meta: U2FsdGVkX18tr0bU9H3flMWNK49vhXtXN1pKimJNwF/oJs5Hu/kXzCyub43Yv6NEZQ3XWzAxa6KYM2XGOmT2QgWBN0aK2vdGR8VOJKSSk1H3673kQSV+aPW7sTV5WdV+O94gsFadsERkCeL4w8yzMwWsFdIBhwv5QaLV79uFqQ/MBttoTS5hyc7k9yqvG9P9D+OBdU13crTKEgxA6zzNdTRuvxcFEC43MtzxsjKGCjzRMMYkzCJM2B5l5dWnEsamBEb/GI6pUOGn/ii6MjhrUfs/DQkgU6H+SQG25Y8RqGicTnh+wgrYZ2SvR2w8zVo/bOAO1gwo95iqvWGhhbl/kfezduPUWMhp4DzpmbsXwfYce0idO3WergKICORgVaHD0gs9zk5CfpKoLEMSA0UcJKfEbXQCJD9sWusLM90PYsYFIaCCGme54xYSaKNt/fecK1+hsfO1qfWsvGqkHuqJ1sv5nV/Bhvumua+Slw12zpoYIC9OHVNk4MMCQ4V46MCORw4EYjDgYpF3scm1xhHxQAqDHCxoKsm/4CwAjPFe2BV6grT1+fW2uqH2jrE7k4yKJl5uRkyvVz3bo2Cm15DDGbdAgiws3MRzZV1qpPfLJINpGSBlKgIjsM2+ILZVo20gjT5Y5mZjNy3Jz34WAvGkFc9qk1IMnPpu6Mv2WGLp9d0zu67o44CCgv/ldB87piwrT2FxRLOqjgaswEUgAuxQYXRFuxhNlJp33q1+DbRToUrs6OZV5yUlaDA8SkQ/WeWJR8T+YM7+vav99fY3jKc9YS0E9h5brCsYalwjTJQT/brfIVM3IdqxzBrd3D8Ed3KDBI5G299STmiSKdgkKXZZmN3WF0VDtoAL3n5CmaE9UHcBZ5+TmFdJp042fqlKBlZWA2+MTwj+gKIwjOZ5xnWfdCQcOsZOc4ZOjwwDlZgX+dHNbZl4EaTaLmlmNoEGz2IJpZwA9+h7cpH7US2vvoa j+BV381o BZFDVj9bgqnNEoU3V6gKw+triy2Z7NMau64jQeuUIm6wm/tJlT2eO07LOuzriO6Mzot2EfjRL5PL38IRtJUNbveuyyUyBTo8ELubsF/d3cvQFF8SqvirXtlpCC1H6snP7pE3A/bsilmEZdruXOAlFeNpIJOM9HPyr4QioMJ/2GjI3knzHgFK2JKo6nzOfqb4QMGglZCYFcRcC2NDEar+rOkJsq3+jQY79bB26NbLeHtsUFNA= 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 codes 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 --- 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 bcb0c5d2abc2..465d5981082a 100644 --- a/arch/xtensa/Kconfig +++ b/arch/xtensa/Kconfig @@ -29,6 +29,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 Wed Mar 1 03:42:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13155579 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 74510C7EE23 for ; Wed, 1 Mar 2023 03:44:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0FF016B0073; Tue, 28 Feb 2023 22:44:31 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 0B0996B0083; Tue, 28 Feb 2023 22:44:31 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E92BF6B0087; Tue, 28 Feb 2023 22:44:30 -0500 (EST) 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 DA6CB6B0073 for ; Tue, 28 Feb 2023 22:44:30 -0500 (EST) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id B4CFF4101E for ; Wed, 1 Mar 2023 03:44:30 +0000 (UTC) X-FDA: 80518937100.06.99915CB Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf16.hostedemail.com (Postfix) with ESMTP id ECB35180004 for ; Wed, 1 Mar 2023 03:44:26 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=jAEA39Yb; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf16.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=1677642267; 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=99eazzzTFBToyKXpL3t6V+dSWN05gSUQFL5P6G3WrHg=; b=lfRf225+dQg1Y/FgMfMFGcG2iRtVNODXNV9sVwkD0Ub4ZMtOcw6lpVJS8HrmKm1D4+leyy Vji8U+PtBGkIW1PkZr9p3xA0omS7ur2T/QIAjIpmOiW9qCwSMdWHziGD975Cwdzig1Xmji RvtnXqQn6TkH6961N0Ry797XMZFQ0vk= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=jAEA39Yb; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf16.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=1677642267; a=rsa-sha256; cv=none; b=n76QxM5/XDXSsai0eFO70KTo/hiB1DKR5bJEfYGk2pH7mfO5k4uYoK4dUhpT/0uFYkR6lE U6Vph7sXwICI8yr0wSU9BvJlMjBh9m0vkhlXn/5b15l0MoezAjkQG+yZx80k+tz2/BYTat zUbu2tcVOXBzBCCixfVEo1HwhETRSu0= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677642266; 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=99eazzzTFBToyKXpL3t6V+dSWN05gSUQFL5P6G3WrHg=; b=jAEA39YbEXUG+7JXR8157Cr2ftknX6XcvMXopBoeaxvRsx8fnqI0OXEaTtYfEZJ8PY3JQW zVvrykPrJT3wgErBrWY2cnl3Gz6vQZJUdI3oG1HYsEKB9UVv408Cx2QBmRkP30E6I+ilst C3OHUeJQAaaHppvt65idDUCQpmXv0Ks= 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-19-6sAzv9xMOeutBMapOHumyA-1; Tue, 28 Feb 2023 22:44:21 -0500 X-MC-Unique: 6sAzv9xMOeutBMapOHumyA-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id CE48E811E6E; Wed, 1 Mar 2023 03:44:20 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-13-180.pek2.redhat.com [10.72.13.180]) by smtp.corp.redhat.com (Postfix) with ESMTP id 51C3FC15BAD; Wed, 1 Mar 2023 03:44:15 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-arch@vger.kernel.org, linux-mm@kvack.org, arnd@arndb.de, christophe.leroy@csgroup.eu, hch@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, David.Laight@ACULAB.COM, shorne@gmail.com, willy@infradead.org, Baoquan He , "James E.J. Bottomley" , Helge Deller , linux-parisc@vger.kernel.org Subject: [PATCH v5 13/17] parisc: mm: Convert to GENERIC_IOREMAP Date: Wed, 1 Mar 2023 11:42:43 +0800 Message-Id: <20230301034247.136007-14-bhe@redhat.com> In-Reply-To: <20230301034247.136007-1-bhe@redhat.com> References: <20230301034247.136007-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Rspamd-Queue-Id: ECB35180004 X-Rspamd-Server: rspam09 X-Rspam-User: X-Stat-Signature: rjdmosaa4gdmwo53wr1sio54g3etzgad X-HE-Tag: 1677642266-960479 X-HE-Meta: U2FsdGVkX1+kMBBn9GbNsN6/7TMBzVdlmLc4YAx6cxDyTrsMLhoo+tZ4I1iqSMcN8EGKiy5WCUwt1Pz+A2NyfHqek01S0F8MK1rGTAWoHD79+WXt9wkfS2Wr932S0GXaSMpJHv8pFDlGkvMmUwx0p/j9+8fZEeOhHULS0v/FNZtEZzeIam+/tu4c5NjwwddqTOc3sr1gZDWKgITMTyNa/NUSSzzNGAKhIOfkxTgb/nr4V5arGJ16GzEUCi1qOj7NtwK5geRdHWag/scQ46KxHeYtPPWrk5g7ZZ2NLySmH3kJr79dSNiYv214WXDSKgz44Nslem9PG36/72pYpKop3EF8XHdgYdICNbyI87Nh6xeu47tKfnhNT40DLbPfOZLRn9Rr/etjkuBidQWdsqrphfYfXsM5UqBdeesIiKYY6gqg3YDvoJacGeugMo0QtEC8G5fJVX738nQj6erfbaqk9RMEpK0gRoxeIy8Eo+iO1+Ye+NurRCq8SUUc41JfbmItGSJkGEB7CBAclswzBbZ0LTBUHolZIhwSIIlgG1a7jmDwjg0GvxbqcwXHJ0Q6tN/qqH6k2Zx8iaLORwRxuXstTW/ir/ruIanCfgPeQ42TcqRgUlcwwY4k1cBEvL3IKGT/sTwk2wTRxNbqEE1kZBmUPLG/gd5GPW/HNd+aUmsPceg3JnSLbRDqG0r1K37IA3WYXL65Pg8rAr/CkDHDZeSExT/lY7CG4IA47EmiRubW5sOcNqkT+KlpIFQnMDsEbgFDa73lvVy1jW7HbP1Fc7bJ/CjAowvv4sNE9yKz6+b11E5B4rZTmzm0p/wCGaWwKmnHzaM165tk+i+6WgJTh1NmD8feAAmL3KozZjpSmuCofBCpE2zGAtW6QdIWAZa3Ycn2ec708qmz/V8Uo66V87Ovv3D7TIa3aLYhBGM6pDUjNkDygPM3SqNJNNr2QICfdQL3Npcb7R1GEwXxiHKSd/j XgcQG9yZ +b2U+2Q6vSPTYqVWEBwIeSSlY+i9SmXbX1GfXNdZxVdTQMvoTsd3vibfCetd+8CEulnHf9wth/1on4dldKvWy2NxawuXEhyWtGfPyoK6Q/nDD7RoaKGXu3rcfNWaqAar+a0MEZrl70QuIGzwDOqex5OOW3sgjeATuWClr2AYU+NL+dfZZiOIRVl0KHn4NGuLpItOzRqoxqFmdWXzgPVao1NJKSv2NLQoqgRj/EZ43dmQLhGB29D2N6lkkc7e28CabAWfOyXH82BXCwQa1EXDjDaAkKlnq6QLpGr1uO0cr9JRAq2yYN2RE5RW9ot4oSPSU7m0sf0RkrEz12szlVunqUKb7BITgRKpxxloLsq/lHTpsnC8= 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 codes 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 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 a98940e64243..0ed18e673aba 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 Wed Mar 1 03:42:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13155580 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 D43F9C64EC7 for ; Wed, 1 Mar 2023 03:44:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 718CB6B0087; Tue, 28 Feb 2023 22:44:34 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 6C8D66B0088; Tue, 28 Feb 2023 22:44:34 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 591D96B0089; Tue, 28 Feb 2023 22:44:34 -0500 (EST) 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 483246B0087 for ; Tue, 28 Feb 2023 22:44:34 -0500 (EST) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 2A58780FE1 for ; Wed, 1 Mar 2023 03:44:34 +0000 (UTC) X-FDA: 80518937268.20.D3F7A65 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf08.hostedemail.com (Postfix) with ESMTP id 69ECF160003 for ; Wed, 1 Mar 2023 03:44:32 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=auYpdm4U; spf=pass (imf08.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=1677642272; 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=Uaseq8uUQQ6QMQSRfFux0A76lTwwiGZ3GmLj5/5Y0lk=; b=ReeVEa/NbE9BvCgsgvVUJ33WgpiDhWZ+yMAS+JcBLlUPogHeJ0AvdtSRN9AvtO65aI/xKb vmcoGjr+OJrXleQ6HdV5Dhwf1NPg9Zt9XzYL8H8UtGRVhgeRf5avuurRTDEG6rgQi3zJ9y HuQ8oygB4nahGUrwg3JZvuWCG2rZgGs= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=auYpdm4U; spf=pass (imf08.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=1677642272; a=rsa-sha256; cv=none; b=55PdN3h9N34CoVkcL2ZPS/dDuZRLqmR4dvgt2iA60Jd2tS75nX3yzNgkZhmQp9RP5sg11r r5JwFi2Z6c8r43HFEU+Jb9YfkHfMQlIdCqcNCLQ/+twYOxAcYOPF6v0Tl4xDY7k7OiCL6c gVLFRN2q1hJjd0DPVeqwJHq1HL0Cwpo= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677642271; 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=Uaseq8uUQQ6QMQSRfFux0A76lTwwiGZ3GmLj5/5Y0lk=; b=auYpdm4UMZe/BA+PT7/0aA1FAxcDeVb4tINrgO6AccM2vsDvygI/ts1yvduYBr7I0LWlfz VtFav56VP8okbxepkdfMVg5dod7JnvDgk/udmu5/H8j2iWsQiOK8vY1lF/CXa/LmoSRrdY OjnyKyDRaFe8PX379SsL6ejXTVFgh6o= 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-361-Nku5RR7JO3SsoRvpup12WQ-1; Tue, 28 Feb 2023 22:44:28 -0500 X-MC-Unique: Nku5RR7JO3SsoRvpup12WQ-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C97973C0DDB2; Wed, 1 Mar 2023 03:44:27 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-13-180.pek2.redhat.com [10.72.13.180]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6933CC15BAE; Wed, 1 Mar 2023 03:44:21 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-arch@vger.kernel.org, linux-mm@kvack.org, arnd@arndb.de, christophe.leroy@csgroup.eu, hch@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, David.Laight@ACULAB.COM, shorne@gmail.com, willy@infradead.org, Baoquan He Subject: [PATCH v5 14/17] mm/ioremap: Consider IOREMAP space in generic ioremap Date: Wed, 1 Mar 2023 11:42:44 +0800 Message-Id: <20230301034247.136007-15-bhe@redhat.com> In-Reply-To: <20230301034247.136007-1-bhe@redhat.com> References: <20230301034247.136007-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 69ECF160003 X-Stat-Signature: tptc3ndsn7wpgax3pd6783m1nnr7nmfo X-HE-Tag: 1677642272-520230 X-HE-Meta: U2FsdGVkX1/aO7kItzebAm7Ecu6GA6OWbEX9aEBStNQ+X73LanayFShU5VA4IafL0WVVEqWV6Y0K24s0TSTMzJ7SYZxWNMBjjjEnYT6BX+1D2LVI6bvQjMbazYUoLRt8H3xXQDUdnsyCrd5eaUmlJJxoprKRFb3zoseiv0Qx0YzdsC41/f/mLjY1Rw7Dqd3x6EzQ0uIAOoKilmNFWFVPK0n15HpQTmILz3iuWnAhCNwanSoyzUIjK+wS0/bn5T4orJunG1+hYkbFqN+FIcRiWQgZwLQLqhaORmN3/WWMvPsdnApMZpSo67EJi7m2RVm9aBtMjf5SKkBjoU+zE/KzzaSmmRd+YKKydbye5xviDM7d+XVQ8Be9ZHx4bHcxHqHsA9CGhjfrWaeYedoOFlWxYdriiVBHZFBgE4+rdQ8RMvJ09V1gDpP8Km10YYk9L+T4LSuWg4Nbjcl14Of/W3Ao9qGdhywrlpoyecHywn91EivKJB9E/IVQNiUkzQX4xbpmd8Vg54e4BdWvnURBXI8JqaX4hBgyCswrhbRXo8xwpRt/GU103oyefMKSbiUb27K8VJ+f92A1+e1+TPRkk+QQPR9/35l8rkBvFvaGpSzS9D/GX5xNVwtXvCbcG+DPDQY0sOVcOEjDKRHtYjVvZ9hoJYv1v6iGkuCWmfJt6537T26Y+AoKWBauzXvxAvBPkqdq4obf/RYdoM+ydMIQao68NXl58k7ssFkeLSgKViJIlPhh+ZFrCYCcQzlZYBCwkzrqSZJOLLul3qDvuCkRtoldrSHnYMSbADaDgF+CZ9oapAyBzsBEc53ldfaToyu2N2JurA1H3stQQ5bHf5T/J8f0/4x1NhIeC1UyZZSVITcRHLVQkO7w4GSqOz1IKexHTOphR+mNB41C1/IGL3jQsMey9mAKbadBUOZNhQyDlA2/sexBEB9DMd+cxjxIGCxU3Gg6ed0WbSPfawm+yGhGq6O n8NltDyN E0D7aZzd2SQsabv+H/dyUWa2wCXSLFin2mA85khSLXtoiy6R2jKZSiOGns9nnvX4aMtsq7Shi8RrEwcvymmoVG2QFf496I3ZwIrgdh0iwf0uU2DRr8M2TwmBhgM3bgc/SGX+9u1t5GNUMJne8k2/NSSjm+2C+WHZIcJsLygeIwJ8/z752qXCLK4xN3hFsthOi23fsrauCrQ6ShTKtgwklQKNEfUwpyGDThMetX9farHGoFwiC3+43kHejpw== 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_pro(). Signed-off-by: Christophe Leroy Signed-off-by: Baoquan He --- mm/ioremap.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/mm/ioremap.c b/mm/ioremap.c index 2fbe6b9bc50e..4a7749d85044 100644 --- a/mm/ioremap.c +++ b/mm/ioremap.c @@ -35,8 +35,13 @@ void __iomem *generic_ioremap_prot(phys_addr_t phys_addr, size_t size, if (!ioremap_allowed(phys_addr, size, pgprot_val(prot))) return NULL; +#ifdef IOREMAP_START + area = __get_vm_area_caller(size, VM_IOREMAP, IOREMAP_START, + IOREMAP_END, __builtin_return_address(0)); +#else area = get_vm_area_caller(size, VM_IOREMAP, __builtin_return_address(0)); +#endif if (!area) return NULL; vaddr = (unsigned long)area->addr; @@ -66,7 +71,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 Wed Mar 1 03:42:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13155581 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 7CF48C7EE31 for ; Wed, 1 Mar 2023 03:44:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 210596B0089; Tue, 28 Feb 2023 22:44:40 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 1C0296B008A; Tue, 28 Feb 2023 22:44:40 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 063246B008C; Tue, 28 Feb 2023 22:44:40 -0500 (EST) 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 EA60E6B0089 for ; Tue, 28 Feb 2023 22:44:39 -0500 (EST) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 537B180FD3 for ; Wed, 1 Mar 2023 03:44:39 +0000 (UTC) X-FDA: 80518937478.22.3480B6A Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf06.hostedemail.com (Postfix) with ESMTP id 98756180011 for ; Wed, 1 Mar 2023 03:44:37 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=LM9S3Jmd; spf=pass (imf06.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=1677642277; 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=YI6zAsqfV4tytLdyXd5+o3PHSfOJhEqLGshxqkD2D90=; b=fJYx0NPsgFjdbtxSpW35y6SZFywAPU3IFhr4+d/md+HpM3O7i7J29/Py02E8xfW5VP288p gpmQ563W+grbLaMReKUI9lBXZothAYwwCQ7d1B8MhtSSVfR7dNR6lsI6jySmKXvJTQxusV EnEh5xR7yx41RDuk239841k42lVUQRg= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=LM9S3Jmd; spf=pass (imf06.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=1677642277; a=rsa-sha256; cv=none; b=eW3ojALIGEZlkH6f3WcZ7kQQmJOS9K6RSNhJsedsa7RugCIRkBr7wRvANpa/KpdZKLTX7/ XhoLAAUIaCMzhdapme/h2SKfPxmnndFLfCziuZGe4SXWFworjWW5lEQd3J4GRfYgMa8xV6 ehr6JSL6m6ECWHAy26eMmL0aVwBmv8I= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677642277; 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=YI6zAsqfV4tytLdyXd5+o3PHSfOJhEqLGshxqkD2D90=; b=LM9S3Jmdz5cw1PC+Q/EpC91W9I9IK4U6QSPKBTcqPGEKuiZpiX0KMDDwPHP7M6ht5InQCM l92hYUx6Adw6fLgk9kdQignOoNUPaUDgwwattQcrZYZovGHrtcxTuh1+VvkmWfE3h4KkwO zWNdt0gWOOf73XvZ3SHOFfvpyIX3jvM= 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-391-zIUurNcQMHuSTAQ4hoLoWw-1; Tue, 28 Feb 2023 22:44:33 -0500 X-MC-Unique: zIUurNcQMHuSTAQ4hoLoWw-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E60BD87A9E0; Wed, 1 Mar 2023 03:44:32 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-13-180.pek2.redhat.com [10.72.13.180]) by smtp.corp.redhat.com (Postfix) with ESMTP id 65CE7C15BAD; Wed, 1 Mar 2023 03:44:28 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-arch@vger.kernel.org, linux-mm@kvack.org, arnd@arndb.de, christophe.leroy@csgroup.eu, hch@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, David.Laight@ACULAB.COM, shorne@gmail.com, willy@infradead.org, Baoquan He Subject: [PATCH v5 15/17] powerpc: mm: Convert to GENERIC_IOREMAP Date: Wed, 1 Mar 2023 11:42:45 +0800 Message-Id: <20230301034247.136007-16-bhe@redhat.com> In-Reply-To: <20230301034247.136007-1-bhe@redhat.com> References: <20230301034247.136007-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Stat-Signature: rqyk67yyqy8biwixknd67awrsyjzzdcb X-Rspam-User: X-Rspamd-Queue-Id: 98756180011 X-Rspamd-Server: rspam06 X-HE-Tag: 1677642277-791591 X-HE-Meta: U2FsdGVkX1+UGfmCBMzOquETo5vNb92DrYd6tuqplrTGlu9nvYF1ZFNrsmNysHWOjTRGYbYnK0hmSnSpcVHhi17TlCGVXK4pm2ZCa5xXfarV2HkMo4p06aa+ydEKgKrNfCGo9uWkmaqE9Zjb2B7Iwnc+rDN+dU+VNC6VEsvnQdz2Hsf4l3DRqtACwW52QLjsvT2EqA8vu0MDrxBK6uyKpAMQrVUXdtnE1HUipkkbdnJilW6VI1Aa76weXHjZTzkhgdz8Fj/bUBkNFdFGRs+dWQda8faAg5pLHiZ0nNpgmL4ABa3tvT8vUNIcnkzc2sl2vI9LnZrAPJkNqS+Agy72p/H636nDTDM0bZKkchsfHazYMEG+emgKvNB+ZSCDwr2BXET+gQ5vdQns/t8a5i5CkunRvPH/SSIwA8YBTCpvsrJYLfDC9xYrfY5xUfhcYiT5x0gcuFbZuOBmfqYf21KV747L6fDcB+k+pDmYeJP2sgVs8/7DBItnEeXMLMizWa3B0psMlUanfD2/4XrWlIRIoGYz+nwkTwlR9kfwESwUdrny+oEhwTEE7BUQzzs1y2sSnOA/8DKaNYdgHl/aPcbX5Ktocqiwm43KnjJaBnzS+dSfSw0lW9wcipPS/KGgFPma3VNSmHNDgF65I1HJMeAHSuHp6FZQtejTqBY4aUckqxJh2JxrmqhpA2vvtfYoCzZl47sxkghTDndemaGqdaksq5yuikf4BlSn+XvPP6ct1GLfF5ZPleozyrISsJQRGNC7sHpDfGLrhl3nfM4TmuCQq4iOtPWzbfpXihIZt2OEK7Vf9JHfx2Dfwzff/1hemVIe6Ak/lgdjs8A2kDuqd6BALdcRcl6w2GMOlDpdpOZz05U3XXw9/IdU8Sln+z1ytcRuj5IsjSY/gqnBlKSgJZi+1n7+abg2MgrRi3OeAc3877PFHzvPKC193Omvu7UUspdpBi1KuwxpsPeCWQJED66 bRTXchAw xaoOTsWPmSL2AtVd8nNEN3T8zIe7T0R++Lh2dWtshFj1bl6GirRANDfOPsPrrYmFemgHOAyML9mHhxe+Y4IV+SSd7xMIRUDZf/IxmbKHLhhslAe9TcwA3/w75Z69FXo8IfgwE1aR8tXBJx+3A1i62z6N2ydulFkdjRzEgmY1OqHdfpBw9Ox/q1uYXzNUm8HhbUpcDaexByK9XWMJtaZfxk8xZve+cLkSMdK8ljLoABqtX/0IeN8wUwStuiyprYnbepxwIE5Cv8+UMkAx9/bOCHQdmrQl/FD/H+F9+PmGWLefC3gE= 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 codes 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 --- 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 2c9cdf1d8761..7441295b718e 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig @@ -181,6 +181,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 7a82e6f70ced..978d687edf32 100644 --- a/arch/powerpc/include/asm/io.h +++ b/arch/powerpc/include/asm/io.h @@ -852,8 +852,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 @@ -867,14 +867,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 Wed Mar 1 03:42:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13155582 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 2D3BCC7EE23 for ; Wed, 1 Mar 2023 03:44:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C486A6B0082; Tue, 28 Feb 2023 22:44:47 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id BF9786B008A; Tue, 28 Feb 2023 22:44:47 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AC1C86B008C; Tue, 28 Feb 2023 22:44:47 -0500 (EST) 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 9D14C6B0082 for ; Tue, 28 Feb 2023 22:44:47 -0500 (EST) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 6FE7A1A1057 for ; Wed, 1 Mar 2023 03:44:47 +0000 (UTC) X-FDA: 80518937814.21.6D86393 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 A34CD140006 for ; Wed, 1 Mar 2023 03:44:45 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="Y4/kjR8b"; spf=pass (imf26.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=1677642285; 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=C0imqrk1PbsNJjpK8uE3mThxpzCeMekX1fy8wvbYCaE=; b=a5/nDOrc5bGbXlxiBFF+g7XtOWJI3D8cUjfB0iWStDazfatoHwVSKHH4jRin607tfGKCCZ pQByS3RqUDxwgUtfHBsmPiRnMMwNciczx7aU89rx/ZC36+2mp98XfhyWMXpDM00oBLv9z0 qMZzAfL3IdZ/r1dlcrY3qpqCxIeijLM= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="Y4/kjR8b"; spf=pass (imf26.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=1677642285; a=rsa-sha256; cv=none; b=KHI0w/9gACbpSQ9oXHJMjrR5hn69xqxNhN/VM/0JafkyJ/RpFY/7EV5roZSvUO905ZuRVj mlvdi6X56qvt48m9Ioku2gDMf61uncG1y5NyBql0Ew4pMtG68GsP5srYvtLsaYrPUI5kBq emByKjivHsAZEXTw+YNnQOsOLzy+rlM= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677642285; 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=C0imqrk1PbsNJjpK8uE3mThxpzCeMekX1fy8wvbYCaE=; b=Y4/kjR8bXhLlHtjaaZENWjR9P+IoT++Ie0mSn7uSb/EtV6XZSiN2mAfyFz/d9f5/Qrjowt P3NB4PxtXHGKX9RzDD66x0x9ONN+R6CZwQsOOkGJ0kOsp9vs5u6qDMIghp6g4KGE5e8CRo hDEgnMkTmdmgo2zcT864Djoy/NhQwVE= 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-659-JOcyBac7NuC_mde3DG7Gxg-1; Tue, 28 Feb 2023 22:44:38 -0500 X-MC-Unique: JOcyBac7NuC_mde3DG7Gxg-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0ECDE3C0DDB2; Wed, 1 Mar 2023 03:44:38 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-13-180.pek2.redhat.com [10.72.13.180]) by smtp.corp.redhat.com (Postfix) with ESMTP id 83B9EC15BAD; Wed, 1 Mar 2023 03:44:33 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-arch@vger.kernel.org, linux-mm@kvack.org, arnd@arndb.de, christophe.leroy@csgroup.eu, hch@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, David.Laight@ACULAB.COM, shorne@gmail.com, willy@infradead.org, Baoquan He Subject: [PATCH v5 16/17] arm64 : mm: add wrapper function ioremap_prot() Date: Wed, 1 Mar 2023 11:42:46 +0800 Message-Id: <20230301034247.136007-17-bhe@redhat.com> In-Reply-To: <20230301034247.136007-1-bhe@redhat.com> References: <20230301034247.136007-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: A34CD140006 X-Rspam-User: X-Stat-Signature: 6gm1zpn4c3xsgyxr39ucjkkr7uhy9wox X-HE-Tag: 1677642285-516515 X-HE-Meta: U2FsdGVkX19H+ftGJN1vcpq5KQqzuVrfveuT+6/HUjwtQuSn/cvp2aQrOqcHdbw9da4rGgMDGv9/q6MWm1ASjHLpYJ/DWXwlrUEi+wAwrleC3fezAYAetC7SUAq2ruL74os2aa1396WvY6bhQ8VUqMIeZqGIUw+dKHzvyUlelaeHASjIjAt/j0FiCep3zeyUE9ys6T2Nj6AkK8qMX6dBwzaCBSw+k7poHfMmS6deT/piZM5zqD2KJ8bHwk7c83lUxIeRMVHJxR7HCmKF2r1HFUR4jAq6bGRuw2wSCaJHbQiR0fyNcQ7ySoaF7UD/gIMBDa1FtQYYbAXWQeDJhD1kzcvLKnpEvyRkJyqQdA7cs4Ay3J/1X3fWJYyEG9DmU4sLgl/gGLpM24pnCctKcIU2pb7NB/O2RArJzcZ0cGu1jYjSr7YwIB0R2nqTKtDBrPAYA2z8/ts6eMMqSZwW3vFhyjX0sEKvT/U2yfR38X4orbka7UtFL/NJFVtdT4OIIBELPzCsaSz7EWoaI6cFwmMPS1Cx+BkAjhPD+tlyaxyPXuWhZYMh5NJnu0DidY/KzgIWjzaPEb4vLzrnVSbLbRadwUM+fowE/p6vNFLI+LXYq44jk4CEabTJ2rYOWi6dghKEaVkNYJPaos1Nkd88PEpoYZe/CYDrbAOuBkqAy3Ug4drfcdv5PpECqmJN2jfHoW8DlF5a/VQHZsLCwXg2QYufmdXBzm23UXjglLZ0o1EGrSAgYKwB3NOEwnLvgA6A9raQI4XlcsnMiRWfnoLMasdDjoyl2VyxCCLAMwY/2PWVxgnlUNXsLnJSveiQYroIvghv1M4bn65sPHfsug5DY99sVOivb9H0Zqp/NH0ca4eFV9p7pgRFWXcKw8oX1wLbdJFPthvb3MiNFJF2iRReleEPvWq7x08w8QDk9NjVUYjbQAScqarcXbZbmkW0yp9HRP5t9tIGT4CMSMOKgbaOuhu iKNBeYgm TicOj8p++OtfuMbcNpEW5CTUryfRFX00erUkIn2leBejnBJUBFIy7UH24NL0HSgOYpWJwlYvwd+t3pWqdls7Ue+aouyLFrDsbnAvLk/cKiAhNe54pxbk6MnJ7oNMt94aAOX2L84hezJU0wNewoZLHxWwjdgJMyhF17ykIJGgo2BxCx8G8rqkSf3L7t3f7xKsuYw45iKIhAx4MT8RNHfIf/y8kW+n61IaLxs/rgj9TzYonpVQ= 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 --- 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 877495a0fd0c..97dd4ff1253b 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 Wed Mar 1 03:42:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13155583 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 2E577C64EC7 for ; Wed, 1 Mar 2023 03:44:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C21FC6B008A; Tue, 28 Feb 2023 22:44:51 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id BD22C6B008C; Tue, 28 Feb 2023 22:44:51 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A9B0A280001; Tue, 28 Feb 2023 22:44:51 -0500 (EST) 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 9B0C16B008A for ; Tue, 28 Feb 2023 22:44:51 -0500 (EST) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 7ADD0141072 for ; Wed, 1 Mar 2023 03:44:51 +0000 (UTC) X-FDA: 80518937982.02.6614C10 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 B77E740009 for ; Wed, 1 Mar 2023 03:44:49 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="XXha/xgJ"; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf12.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=1677642289; 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=sZjhNHfCq0k8rI1ELCJTN8u4w8f61XUm94YTHptLe20=; b=RBjjpV/ErJL00lwsnvzGICSOaC6Kvbluv/CnnsUESMIQMUAgDBFvHdru3EfFIRWyLGPkeu CYokVWLUki4ykPa+1fVF9fpLMbYFBv8I6rQDZfKqLmrcTZtY95RL63CTnPi5aKBlTxC7lm C59TN+pE2CGdFqLnTjrFguDiERGaN7U= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="XXha/xgJ"; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf12.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=1677642289; a=rsa-sha256; cv=none; b=oGu6xC9Ph0ZLsZl5WYu+1ZhKQ15wJwbBO2pu2BQeIhfs4JJEj+6gT6gatUvRbMo2cRqPbw zgKKxPp2SjgrSLossfVdbBYcOQf+OUUph/5xtkIk/fsZWQD22NXDEOX8H34VD3ZPFpq2g8 MHorJbNPeysY8fVNmpu9td+Wtrlqxxs= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677642289; 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=sZjhNHfCq0k8rI1ELCJTN8u4w8f61XUm94YTHptLe20=; b=XXha/xgJn7rNDJveHy3iMk0u/MIKCYaj1UQfGgsgoPuz8zsJDq4j6Cxd71HYfi1IZqcI/9 A4DHOOuPMbkbasB5Ev3G12i3CGP5Sn1Ii08oXU8saYUzFM4SY1wtF0l9XHQB401xgF5wwD Mra/Rff0hLxI0YWcne5IzmT4bXoRLUw= 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-596-L7cYu-UcO7uMwCSPp8Rblg-1; Tue, 28 Feb 2023 22:44:43 -0500 X-MC-Unique: L7cYu-UcO7uMwCSPp8Rblg-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 451DC87B2A2; Wed, 1 Mar 2023 03:44:43 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-13-180.pek2.redhat.com [10.72.13.180]) by smtp.corp.redhat.com (Postfix) with ESMTP id A2A5DC15BAD; Wed, 1 Mar 2023 03:44:38 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-arch@vger.kernel.org, linux-mm@kvack.org, arnd@arndb.de, christophe.leroy@csgroup.eu, hch@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, David.Laight@ACULAB.COM, shorne@gmail.com, willy@infradead.org, Baoquan He Subject: [PATCH v5 17/17] mm: ioremap: remove unneeded ioremap_allowed and iounmap_allowed Date: Wed, 1 Mar 2023 11:42:47 +0800 Message-Id: <20230301034247.136007-18-bhe@redhat.com> In-Reply-To: <20230301034247.136007-1-bhe@redhat.com> References: <20230301034247.136007-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Rspamd-Queue-Id: B77E740009 X-Rspamd-Server: rspam09 X-Rspam-User: X-Stat-Signature: ykngcirfd5hdtyepykfu4tj843i3pedo X-HE-Tag: 1677642289-187874 X-HE-Meta: U2FsdGVkX19cBcKIKgxt3Iqs+VRG4tILr9zaznivFQEw9NNobeIBR/0vFMrITrMDrpo6dRRu2feBgF8C6A0z8ALitdHhu+mRXWkPp+qGFRTSkwNjNC/sYijnkiECm/Frg/vI1Rulbj8TCNgO0eFHRyULcPjZDqrp7w4k1IqeIJNeVpuYe0dj7ktoSj3kDpptZnkARpdG2FOahoupaWu+boYQavl6/BsievyTXr64cq0/EncTjwY8FwgLf7IwnTH/4XPtmyrs/nWgInByd7vrF/fE18Kj0PSMsMRr5UDdBzHKedYK+NEXvxbyIsHVMHOFumwVqLna+euNmTrJlr5+PIo0ksb0VTk4jKR/PEwyLE+PblBNM9454wqXIuvAjVAe7wVdGEzOakr2Z1EZnjIHqg70tOJCFrkUktX782ztZbT3XYnNXonSBGq2t6dG5oZxDvg7Gd2qoyPpFdJdoXtm2WiU6Vixr1jD2Y3we08lCsG99wcp2Y8Z6aosyMXmx+Sqqye+Ohfk2+cgv4Nye9QzCShoN/JtACZtpasOMHBbhYHcd0vd5mhEWqi/lNODM5zNbeaS1LAW2CykH/LMsCRTW+cJqXh+cVUhej8142KZkNp+JuRqIwnUSdpuFDTeFZPnqKp7eyzXTFEDlSq2aeAnZfVC8rOUHMbldxGzSZBe9orgRZU6zwJqa0ff3QXhmbcSngbvEwKGGhQ+cffUMH/Gmmu64kzoQfz8yIj46cVmREMDmjrnFAxeQbfTwM7+Lus6ECibgMvQKkUZTYR7t+qy+ZVErbbxWmkgQD+utJaT9mjOMwm422/n7kDNdxM4zoYgr+LJY6u17ZihkWEI4dEChXgZyLiEmi2rc/7QXIPanR4Z7dGBvqJPXLOvD3pZfL0PM5NafranAinjRNmiHG2Y5MSu71HPwiYgJhy3c50hMINkZpxV2YcN1o0W6LPoTYezhUjtHGWZu6OriUl35pD dJHYYAMW YF1sGoYAakY9u6qs6NA6neeG5ADfZsV3W1o5rxWfq55RS8zCFJJ8E/BR3oK3oSbr3U3jNZVlaJAmrrXQtXoK+vbOvNN2VIo+Gvsz3LinZd5X9qT+/J2UCJI0i7eTG7QyQeEU4fViuJQBnfuAzwNQxHUGlmEE2WzTtCmUJCGbQ6qSNpxu7WwFMIZHQg8Mwr1qrLSUtEKoEU7atf0V99UHN2bRXICKDJJziKhqwo2ZJGI29aMA= 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 --- 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 29ee791164ac..c13109d17dcb 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 4a7749d85044..8cb337446bba 100644 --- a/mm/ioremap.c +++ b/mm/ioremap.c @@ -32,9 +32,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; - #ifdef IOREMAP_START area = __get_vm_area_caller(size, VM_IOREMAP, IOREMAP_START, IOREMAP_END, __builtin_return_address(0)); @@ -68,9 +65,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); }