From patchwork Tue Jun 20 13:13: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: 13285827 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 1F520EB64D7 for ; Tue, 20 Jun 2023 13:14:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9C1EE8D0005; Tue, 20 Jun 2023 09:14:57 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 971278D0001; Tue, 20 Jun 2023 09:14:57 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7EB408D0005; Tue, 20 Jun 2023 09:14:57 -0400 (EDT) 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 6BCEF8D0001 for ; Tue, 20 Jun 2023 09:14:57 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 2EA8980EF7 for ; Tue, 20 Jun 2023 13:14:57 +0000 (UTC) X-FDA: 80923171434.16.B2672D4 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 B5EC91C0017 for ; Tue, 20 Jun 2023 13:14:53 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=TyHK79jd; 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=1687266893; a=rsa-sha256; cv=none; b=gzHtbhUp2CoEh/1v6XwvzE1RsLL9PttTkGsmQzFj+8tWHFmHVeXdBgR3s284rGeI1XGsFd oMIPDTN0116WvYJO+UbeRXNsFeC6aB4O6DlDtJ1AC75yHNk/MoKi3iUROGwrkfwwaShRt1 FXVgnwLADMHJhmBTrpCA6IJ3liu3N9o= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=TyHK79jd; 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=1687266893; 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=b4XJFulpmTS+bblieBNYOcNV6+2R6Ew6Cf1SgYEpLuE=; b=LZ0aWQ5Oz62sOgqF7fqYMBqdBvXmftut2/UwJNrq0CjVtaTXNet9COjmO3xcHSS50vPYVs xayCbj58tDrPMIWtAhU4COJD2pGHRhHBi7syExjEVeotJT41aG4fLh+XS0wV6wwPUtoGQJ e0feuVIY5R6kR1PqO924uox7+1MVfSo= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687266893; 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=b4XJFulpmTS+bblieBNYOcNV6+2R6Ew6Cf1SgYEpLuE=; b=TyHK79jddl/oDHhbOfFIAKY5Dsc0XV8PztUB9gPj2JMEM5JBpm1FMXY9lwsNF+d+CsjFLi giQrj5tiD/pbfk9wpdmOv98TLCbX4/hzr8Ta4CTsHS9C/e2Fe7OzDCpG2G4623nDunBz/8 BRdkGKTTlLmzQxJX3zam3r1K3D2pD24= 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-668-GG6MyXnuMMKE9JR0NGzIKQ-1; Tue, 20 Jun 2023 09:14:48 -0400 X-MC-Unique: GG6MyXnuMMKE9JR0NGzIKQ-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 5455080123E; Tue, 20 Jun 2023 13:14:17 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-166.pek2.redhat.com [10.72.12.166]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1EB80C1ED97; Tue, 20 Jun 2023 13:14:08 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-arch@vger.kernel.org, linux-mm@kvack.org, arnd@arndb.de, hch@lst.de, christophe.leroy@csgroup.eu, rppt@kernel.org, willy@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, David.Laight@ACULAB.COM, shorne@gmail.com, deller@gmx.de, nathan@kernel.org, glaubitz@physik.fu-berlin.de, Baoquan He , Geert Uytterhoeven Subject: [PATCH v7 01/19] asm-generic/iomap.h: remove ARCH_HAS_IOREMAP_xx macros Date: Tue, 20 Jun 2023 21:13:38 +0800 Message-Id: <20230620131356.25440-2-bhe@redhat.com> In-Reply-To: <20230620131356.25440-1-bhe@redhat.com> References: <20230620131356.25440-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: rspam08 X-Rspamd-Queue-Id: B5EC91C0017 X-Stat-Signature: 6ne34xp5q78ur31k1zyyf5wf89xygc3g X-Rspam-User: X-HE-Tag: 1687266893-592724 X-HE-Meta: U2FsdGVkX19LrX6hAPTFcPPMWmZf01oLzihzxSNN/KUrbaHDlO/RwFkMGROJtP+UEVeHgnP0yuz/CPRYlCJoIqCfxvNMeQD8e9Rqg4ta5A6OEfeTVsf0uEekaQSDVkOCau/PjpouhECZjg47rZ8GeymE4sSQ9IQdJA5WGGjr0dKWtVzqmIfSkP0/M7T9l0N+pmlqa9ultEaNWGd220q0+zsJ9XhrTHkI2BxIg2pJ5QOli/ygeLQZeSAImtugV7t6eDvdJpKoTeMwlBDE92H7KlEhOjcbJ00boLE2ccY8E5XJpQ1TWu3S05LM5G2NLt7OUXu1jmaYy6mA5rXd+bAHb+6lqNcwykusiXnd18hzqdyWY/W6T6YvGW5OF+YcTdHroVrlE6IQfQoOmGL3GJX472vYUE2yyew1nQ0+wPNQN6z+upGA71LSzTJTKGrgBpkI1muPDCPdncWEyYzjtBJl0xalZaQ3oB5mFGIbW2gkZl9pkk59sxwFdRpHKz1F1/SpLC72aTFtI9DygM/EJD/YGQBEuCaEIl7seodYF7MFvNB3gTs3Lj6rNCgRXzkRmdMMjeBlWx9k80mMNnrktgXIzo6QigOsVslc+mSwgWcEkQgz8vffO4f7XMEda2w03z167EiNx0BLEXBFdnTvFfsAggE7O5M59GtPkATwoU9R9Q08nCncor5t0SpriodF3OO2hhF6w9X715qPAswuCTCWQua1vBArBM2faNSvlrIhwSh6p2cWlK3kbXxCwKTyxOs2fzkD7OErH+gRIHTySyfY2LRPqsWt7kmlVeRGfnhXJ8UGOVmSKW/HkbivCNqG1KIO0GMjJx5Ii/uajrc6K5MBwUar+BiHgsHHMieWzpy3HO+8By2x9pLzHi36d4mPs2zD1SIZaEgqxSMMMNMu8ccaoe/WLlaY8vMxbTEkJODsl9BV8eBABC2bOxl6tQ9PkVR2ETf+asJ7qnoLykNrJLc DwLiqFPS cAJFGN/fYzM9+N2fFz86rFVHsuTR8Jub7r6X2YHwcZCFKZnmaOqaNuKlBwfOmN33OeJr/DMxTrEguebESFcIzpBIJLnAGH2A+IO4nf1ZFOH7n3UTqmwixPgreaE4MThd05yzMrP5YmE/gldjFvPbc0esR37CDx7in2/RwgAZRe1PuYW3xXElxu063rNtdgSErW0TJF3TovtmTupF6JQZVJuILC78RoyUkOC8QdgROwKVrWMKiAOMr4LMF2IsAgC89u4Zy4/3Zu8MAGg2NVopN2IBc4/9xkpn5EbLFOuZGmkyso9oJGhbPKS3pWtuxNhpOAFQ7gPGIawsQPJXN2m0CrvCffHL5W8L3ORQmf3sdtOdubv56u+nzaVtZ+ISJfkoUzKbt3ksQLxjvHlawWpXuL8HsNQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Let's use '#define ioremap_xx' and "#ifdef ioremap_xx" instead. To remove defined ARCH_HAS_IOREMAP_xx macros in of each ARCH, the ARCH's own ioremap_wc|wt|np definition need be above "#include . Otherwise the redefinition error would be seen during compiling. So the relevant adjustments are made to avoid compiling error: loongarch: - doesn't include , defining ARCH_HAS_IOREMAP_WC is redundant, so simply remove it. m68k: - selected GENERIC_IOMAP, has been added in , and is included above , so simply remove ARCH_HAS_IOREMAP_WT defining. mips: - move "#include " below ioremap_wc definition in powerpc: - remove "#include " in because it's duplicated with the one in , let's rely on the latter. x86: - selected GENERIC_IOMAP, remove #include in the middle of . Let's rely on . Signed-off-by: Baoquan He Acked-by: Geert Uytterhoeven Reviewed-by: Mike Rapoport (IBM) Reviewed-by: Christoph Hellwig --- arch/loongarch/include/asm/io.h | 2 -- arch/m68k/include/asm/io_mm.h | 2 -- arch/m68k/include/asm/kmap.h | 2 -- arch/mips/include/asm/io.h | 5 ++--- arch/powerpc/include/asm/io.h | 9 +-------- arch/x86/include/asm/io.h | 5 ----- drivers/net/ethernet/sfc/io.h | 2 +- drivers/net/ethernet/sfc/siena/io.h | 2 +- include/asm-generic/iomap.h | 6 +++--- 9 files changed, 8 insertions(+), 27 deletions(-) diff --git a/arch/loongarch/include/asm/io.h b/arch/loongarch/include/asm/io.h index 545e2708fbf7..5fef1246c6fb 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 cc28d207a061..477773328a06 100644 --- a/arch/mips/include/asm/io.h +++ b/arch/mips/include/asm/io.h @@ -12,8 +12,6 @@ #ifndef _ASM_IO_H #define _ASM_IO_H -#define ARCH_HAS_IOREMAP_WC - #include #include #include @@ -25,7 +23,6 @@ #include #include #include -#include #include #include #include @@ -210,6 +207,8 @@ void iounmap(const volatile void __iomem *addr); #define ioremap_wc(offset, size) \ ioremap_prot((offset), (size), boot_cpu_data.writecombine) +#include + #if defined(CONFIG_CPU_CAVIUM_OCTEON) #define war_io_reorder_wmb() wmb() #else diff --git a/arch/powerpc/include/asm/io.h b/arch/powerpc/include/asm/io.h index f1e657c9bbe8..67a3fb6de498 100644 --- a/arch/powerpc/include/asm/io.h +++ b/arch/powerpc/include/asm/io.h @@ -3,11 +3,6 @@ #define _ASM_POWERPC_IO_H #ifdef __KERNEL__ -#define ARCH_HAS_IOREMAP_WC -#ifdef CONFIG_PPC32 -#define ARCH_HAS_IOREMAP_WT -#endif - /* */ @@ -732,9 +727,7 @@ static inline void name at \ #define writel_relaxed(v, addr) writel(v, addr) #define writeq_relaxed(v, addr) writeq(v, addr) -#ifdef CONFIG_GENERIC_IOMAP -#include -#else +#ifndef CONFIG_GENERIC_IOMAP /* * Here comes the implementation of the IOMAP interfaces. */ diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h index e9025640f634..76238842406a 100644 --- a/arch/x86/include/asm/io.h +++ b/arch/x86/include/asm/io.h @@ -35,9 +35,6 @@ * - Arnaldo Carvalho de Melo */ -#define ARCH_HAS_IOREMAP_WC -#define ARCH_HAS_IOREMAP_WT - #include #include #include @@ -212,8 +209,6 @@ void memset_io(volatile void __iomem *, int, size_t); #define memcpy_toio memcpy_toio #define memset_io memset_io -#include - /* * ISA space is 'always mapped' on a typical x86 system, no need to * explicitly ioremap() it. The fact that the ISA IO space is mapped diff --git a/drivers/net/ethernet/sfc/io.h b/drivers/net/ethernet/sfc/io.h index 30439cc83a89..07f99ad14bf3 100644 --- a/drivers/net/ethernet/sfc/io.h +++ b/drivers/net/ethernet/sfc/io.h @@ -70,7 +70,7 @@ */ #ifdef CONFIG_X86_64 /* PIO is a win only if write-combining is possible */ -#ifdef ARCH_HAS_IOREMAP_WC +#ifdef ioremap_wc #define EFX_USE_PIO 1 #endif #endif diff --git a/drivers/net/ethernet/sfc/siena/io.h b/drivers/net/ethernet/sfc/siena/io.h index 30439cc83a89..07f99ad14bf3 100644 --- a/drivers/net/ethernet/sfc/siena/io.h +++ b/drivers/net/ethernet/sfc/siena/io.h @@ -70,7 +70,7 @@ */ #ifdef CONFIG_X86_64 /* PIO is a win only if write-combining is possible */ -#ifdef ARCH_HAS_IOREMAP_WC +#ifdef ioremap_wc #define EFX_USE_PIO 1 #endif #endif diff --git a/include/asm-generic/iomap.h b/include/asm-generic/iomap.h index 08237ae8b840..196087a8126e 100644 --- a/include/asm-generic/iomap.h +++ b/include/asm-generic/iomap.h @@ -93,15 +93,15 @@ extern void __iomem *ioport_map(unsigned long port, unsigned int nr); extern void ioport_unmap(void __iomem *); #endif -#ifndef ARCH_HAS_IOREMAP_WC +#ifndef ioremap_wc #define ioremap_wc ioremap #endif -#ifndef ARCH_HAS_IOREMAP_WT +#ifndef ioremap_wt #define ioremap_wt ioremap #endif -#ifndef ARCH_HAS_IOREMAP_NP +#ifndef ioremap_np /* See the comment in asm-generic/io.h about ioremap_np(). */ #define ioremap_np ioremap_np static inline void __iomem *ioremap_np(phys_addr_t offset, size_t size) From patchwork Tue Jun 20 13:13: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: 13285825 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 CBDA3EB64D7 for ; Tue, 20 Jun 2023 13:14:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 63E1A8D0002; Tue, 20 Jun 2023 09:14:48 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5EE218D0001; Tue, 20 Jun 2023 09:14:48 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4B6A78D0002; Tue, 20 Jun 2023 09:14:48 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 38C8E8D0001 for ; Tue, 20 Jun 2023 09:14:48 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id E8EE2160EF8 for ; Tue, 20 Jun 2023 13:14:47 +0000 (UTC) X-FDA: 80923171014.20.599CF9C Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf29.hostedemail.com (Postfix) with ESMTP id 60942120029 for ; Tue, 20 Jun 2023 13:14:44 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Qn2H1fNf; spf=pass (imf29.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=1687266884; 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=4y8XwGcIF2jz2W1CKgMhspALuMHaJJCUGdTHN9uXAgA=; b=wVZ9fSCLVCEKBuMWe8xDptz8NKPfb9L2ZigEIz2mL16PJTG1Ivow6NfRIcOfL90Q9rhDrB lX5fCD0XDpaXPAq+dk8fGL3IKC5mZeHUWiK55QTcDZ3r/AKxWh9yV2W1Y1ZdRp+xeYn5lq f9HK9/fPS1QiMGtgTlGosxrcwpdaJCg= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1687266884; a=rsa-sha256; cv=none; b=p5/kN+DB6S9kA8nMyCHOKOTsmkCTBtoYuVmeM/10UqfXa5VsAM02QR0E1qJGp4Q9HQ0Iwr yLlRf2o+1hty9f+TcSORXzDm5ZzppZlyVt5R6+iqf+EYToalQfIOq7gmrnCaJvIylcTljP fB8mcy/bfKF878Rv/P2h+7wZfdNtZW8= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Qn2H1fNf; spf=pass (imf29.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687266883; 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=4y8XwGcIF2jz2W1CKgMhspALuMHaJJCUGdTHN9uXAgA=; b=Qn2H1fNfE/soLfOfqNOC8YWMHhG0L+Tr/wLTxPGAsLdWGGoIwDUZKSj8Z3KwX6cd900Cow qMjiyegzjL1Be47Pt/NphV2hlVZSxkNFHavYFziKsE1qEAuVEuBrl3+WmwWb7leXpjD5Iw 7zUtzvkDnLdxDCwhHoY5c6/rWfeXo9k= 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-219-RSNRVfhJNTGDfKn-1uoIcw-1; Tue, 20 Jun 2023 09:14:40 -0400 X-MC-Unique: RSNRVfhJNTGDfKn-1uoIcw-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 8603488D0FD; Tue, 20 Jun 2023 13:14:26 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-166.pek2.redhat.com [10.72.12.166]) by smtp.corp.redhat.com (Postfix) with ESMTP id 21554C1ED96; Tue, 20 Jun 2023 13:14:17 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-arch@vger.kernel.org, linux-mm@kvack.org, arnd@arndb.de, hch@lst.de, christophe.leroy@csgroup.eu, rppt@kernel.org, willy@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, David.Laight@ACULAB.COM, shorne@gmail.com, deller@gmx.de, nathan@kernel.org, glaubitz@physik.fu-berlin.de, Baoquan He , Brian Cain , linux-hexagon@vger.kernel.org Subject: [PATCH v7 02/19] hexagon: mm: Convert to GENERIC_IOREMAP Date: Tue, 20 Jun 2023 21:13:39 +0800 Message-Id: <20230620131356.25440-3-bhe@redhat.com> In-Reply-To: <20230620131356.25440-1-bhe@redhat.com> References: <20230620131356.25440-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: wmor7ew16g4p717uj3ew6894br6d7r8o X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 60942120029 X-Rspam-User: X-HE-Tag: 1687266884-494882 X-HE-Meta: U2FsdGVkX18VZjoowu+OgG7Xjc2C2aFyyzbKm/UweErm/S6MKW3NvicBHSEz0lTstdW/8gsYenIG7M+PvyrHLHwCy5QcZo1jbUodrwXaHpni/iZspfcuRyfQpLKgmBkvEwR4XbSad7PUpfoqLOOuD72r6yUV4HvOZkLhkzeTsty9N4UaZMgK6Q8g+3dMC+4bULQ2OJTlf1bPocImfNSTwRWfQFguFwSrtB2n4EbVRbY6UQaxzYYMwjp1Duld1PA0+NVuPlL2TapJHKe1kM2HcFVpOAKPG0uSO7lWWNJb91pdGvJpEgPDj0duvQ5z3wTwMnH3jfqy3pVji218z7uGNJd8CgmAQb8fNaZAWnEIFLgFmSsq4TxMgDIm4pK6vCp+WgYYsNT8e6KaJO5jqujRVOxA6NK/T+kKLJMb4cNj8enf/LmIx47U5+0M4Emjx7AQq+X6lXY8qz0+Nx99Bm9RpqvjMoR/9jRYl3OwxXGuvh3ySXKZoP9fZKfmausKDc7x80mzaB7p7p+oo2bXVoLMi6siQcu2W+ueI1uBSZNScE+YgcQnM+0eLl8vfJymWrwCRKPAspNxhEWh96teeP6YxbQ8fcXN+i8nmMSnf6DdvoNv56wYkDKC343pBA9pYLqylSiNAzOPRe4lJEw2PgrrRsxx+GwS/ZuVXu/eTb1vXnGWonNoih7MwrUI2UAhbH7iRlGEjMi13fmG7Grf2yj287LOqXtPpLsc3HavYqMVTq/8kdpq4b6T5hPz9StBycpYtn0D+y8n1bUMDDJulMfspASDTN+w6iqaCtD0ue28uYbUExQYBRdN9n1T/0Z9UHSiqkA+CPibczy4w5/Apt7FmHnthylFC7hDMO7bxZ3K752gqBIsED9nqd5AeZVOxSmIV1s8BDeN61xCU3xOtZU+lauvJZ+reOvUByMgpYTqCMcODM4zr4u2j3L83/gFXNvKUPiixZvRvEhwDiDEWl1 5URje46Q gYNjCxkX9SUJB6JDjL3L6JY1LYgcS7R7X3sDbX6BfZ8sbs4m2SA/8C4I+yyvwSQB4RJQmpHCbnr9V2Hz2vEPHI16BM3bittT2zqfBa8Y1kMiPb2IzQYTTS/Q9Tsq6Ok81zaVqA1ERGYMTrdhW+SdechTILQDukZHrCjF5m8sVv2SNcn1h3Wuv/UnKd5FI6vdxUzIK4J/K/n3ywWQBgtVHn37E+tmYrvexcRdwJTN/w8mIFjSbL3VaNM8ep84asZRW1xQW87fIeu3baiOewV5dLNGAd82ufGk31l3kIP/0q4YjIyBjDp0I39qcN/+BJw0ObGTIWcOrSLl5CiSdPX4qtdKd2A== 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 Reviewed-by: Mike Rapoport (IBM) Reviewed-by: Christoph Hellwig Cc: Brian Cain Cc: linux-hexagon@vger.kernel.org --- v6->v7: - Fix building error reported by lkp test robot. Here I only fixed the redefinition of iounmap(), ignored the PCI_IOBASE warnings since Nathan kindly reminded me the warning is a generic issue, and Niklas is working on that within below patchset. https://lore.kernel.org/all/20230612160237.GA199007@dev-arch.thelio-3990X/T/#u arch/hexagon/Kconfig | 1 + arch/hexagon/include/asm/io.h | 11 +++++---- arch/hexagon/mm/ioremap.c | 44 ----------------------------------- 3 files changed, 8 insertions(+), 48 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..e2b308e32a37 100644 --- a/arch/hexagon/include/asm/io.h +++ b/arch/hexagon/include/asm/io.h @@ -27,8 +27,6 @@ extern int remap_area_pages(unsigned long start, unsigned long phys_addr, unsigned long end, unsigned long flags); -extern void iounmap(const volatile void __iomem *addr); - /* Defined in lib/io.c, needed for smc91x driver. */ extern void __raw_readsw(const void __iomem *addr, void *data, int wordlen); extern void __raw_writesw(void __iomem *addr, const void *data, int wordlen); @@ -170,8 +168,13 @@ static inline void writel(u32 data, volatile void __iomem *addr) #define writew_relaxed __raw_writew #define writel_relaxed __raw_writel -void __iomem *ioremap(unsigned long phys_addr, unsigned long size); -#define ioremap_uc(X, Y) ioremap((X), (Y)) +/* + * I/O memory mapping functions. + */ +#define _PAGE_IOREMAP (_PAGE_PRESENT | _PAGE_READ | _PAGE_WRITE | \ + (__HEXAGON_C_DEV << 6)) + +#define ioremap_uc(addr, size) ioremap((addr), (size)) #define __raw_writel writel diff --git a/arch/hexagon/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 Tue Jun 20 13:13: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: 13285829 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 4FB31EB64D7 for ; Tue, 20 Jun 2023 13:15:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E2D6B8D0008; Tue, 20 Jun 2023 09:15:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DDD7D8D0001; Tue, 20 Jun 2023 09:15:15 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CA5468D0008; Tue, 20 Jun 2023 09:15:15 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id BC5A78D0001 for ; Tue, 20 Jun 2023 09:15:15 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 879C0140EBD for ; Tue, 20 Jun 2023 13:15:15 +0000 (UTC) X-FDA: 80923172190.18.69A1E65 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf08.hostedemail.com (Postfix) with ESMTP id BD28C160021 for ; Tue, 20 Jun 2023 13:15:12 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=U0TqtwpJ; spf=pass (imf08.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=1687266912; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=pQumlSibFcTmcmpj3o91A5K5Zwuz/UGXp5mnVQ2pvKA=; b=qM74Sxj5di/PrJpxh5MVLl3uoi6r/ql4BTPmpSSnaKnmiUSdIHUz7EwsAPnL4YLu2KA0mm QWxMmjg8vZtuUSZjLSsmniXNLOW57ZVAlV5kb0Z/SvzgAh4MOJPLF2fr47aTtSrpBmM4CL q3TH68ygNNn4iTxW2QnaCjNEtp/5XKE= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=U0TqtwpJ; spf=pass (imf08.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=1687266912; a=rsa-sha256; cv=none; b=IGr3cxqurh1n/rxPwQbibdcI7RWgWdlf++k2tJfgOkjhDsGQHAhIzrwyaQK1zdJ9DaY9Xy EJbAvCNf6ABDcOH7XYKkgrWlJ1pzBXcbQRIzq6p01vyCnEzHHIeuMJ79lPMKfz1ORDBFfV 8K3beb4AOjkICn5AFp1gMLEDoSol9SQ= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687266911; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=pQumlSibFcTmcmpj3o91A5K5Zwuz/UGXp5mnVQ2pvKA=; b=U0TqtwpJjr3rxl3rGWCk81BzLDJGy0w79iQxnMTYIw0GR3293rZM7+sMENYySjNH58GNsq NiJFB8b6ZF6L05S2+8KeROBbRcTmi9BEvl7TcDl+90dtJ/zYJGForJNetda9pDGm1ZpGy2 Lj3DyUVvaL5j8pCFyo1hKiCvdg/Gfi4= 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-114-Yzzti3lQOj-KYN_CSpdMQw-1; Tue, 20 Jun 2023 09:15:06 -0400 X-MC-Unique: Yzzti3lQOj-KYN_CSpdMQw-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 303FF280BC4A; Tue, 20 Jun 2023 13:14:37 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-166.pek2.redhat.com [10.72.12.166]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5568AC478C6; Tue, 20 Jun 2023 13:14:26 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-arch@vger.kernel.org, linux-mm@kvack.org, arnd@arndb.de, hch@lst.de, christophe.leroy@csgroup.eu, rppt@kernel.org, willy@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, David.Laight@ACULAB.COM, shorne@gmail.com, deller@gmx.de, nathan@kernel.org, glaubitz@physik.fu-berlin.de, Baoquan He , Jonas Bonn , Stefan Kristiansson , openrisc@lists.librecores.org Subject: [PATCH v7 03/19] openrisc: mm: remove unneeded early ioremap code Date: Tue, 20 Jun 2023 21:13:40 +0800 Message-Id: <20230620131356.25440-4-bhe@redhat.com> In-Reply-To: <20230620131356.25440-1-bhe@redhat.com> References: <20230620131356.25440-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: BD28C160021 X-Rspam-User: X-Stat-Signature: yuua8xbbn49jaqkrtzu1fxjwcx3f4g9b X-Rspamd-Server: rspam01 X-HE-Tag: 1687266912-734020 X-HE-Meta: U2FsdGVkX1/Y50qchLeh0OeC4ZXxVLHuDn+9FTpjpOKD+nygBGXLm5vnaU3MzrakqGFyO/rHXhkTOXU3yGf5tI5j3fdn0YP5T5TcB1+0/GMD8lUbjcawemjccNl/Hft1Z5mki08hrHwBQh0x8X33/2XjmitYjOx/dxZ104NrhBwapxZFHTSp5B4L6VryC0hjnIiHBaFe1TWuWZ4CGsDM0upVO0lj4hFP00E1MC77on/a6vbN3Mm19RE2Eo/R1G1D6/Ne82aalhZ5d4uxdn4vLvkkFAgcEzEXHOFA48XU6ENPWYaWM1dW0wf2YJOrbV+t7Tx1e5iq0Mxp6ccfbRz/wM7VeG1rcQqmsMu394fjN9f6QW6kKa453hw9jEM2HO5nyHg/M8/uRmfSlSprfnuiOQYXgtxCJTk3Ghni8FP+0odB5ZYrGFK02JD07xMg1ZsEaSfSO6NyqkuORemPCasrp3cQO3MuypkeYgye34ZgTD4l1t6z5NG0cj4SCiE+Bx63mRpm2UjSqXunVPwgt8kGMD9gdrh0XdN6x8tnyvbVQPmId2t3QRVNC3Y+FsagCWh/C1tmvo0o2NYA9cn+FUJ8LxvHYYVc2XM9Rh9nBFwEUNLBVx6IMJCwu9ivJLcMvfnEzBXNYNqP5PIqQqbd8Gb7Jqklxfh/cWwn/1ccFBUMR6+GqpkVkd6mZywrL1VGtqIF5YFz9INcNXofgJ6fy1qumn4YgQihVhHSeTf0TdUA9s1iX0LQEYuaAHq9ITR40EJwDTk3GyLGUlKVco7ZXQwctkM82ZuFlk0xojyhZbqVJvGUG+x3Y0tvrXjkBlor4D7VBZpa/f0P5lAgNg5Wv5lmObbnASK/gAeHCGHCYh35aJPWSo6gqHPIygkTINoZh7dIcGCrdpC1VzWr8LVUpbLMUanWrEcfo2J5agzshDxGPSJMwVZdYD7Wht/KpTdAbOO+Mtoh4YEpMIi0N2v3jVo kVGV4mJg 3oh91Ua2i1MXyu6dAilggcytG1Oc5DU39l7+yrTWtPntDIjY6J9ckMibuGTQamrUUL5Us4uM22K67ZaQo8RAgozPxl1OPa8ICWs9TzcyeveheOxdvcNBEW+CTFEg6K4B/RlNC4OzvCCeu0RBVH/oMUAjPN4pv1vBgTmP7OOf43Q+81M/sopRXGFmXsHiNyfoFxYLxFGtj8h5MPH+k0hcpR4iexVSBCuj43jsYlnZffq5PgTeYqEZi4hmIIcZ9oV2Q/mJXnWqGFhGaer5PCqGfFHHyTVO5ifA1nmF40GR3vvgqOg55hDwb+L77qZiHts/WQHtL X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Under arch/openrisc, there isn't any place where ioremap() is called. It means that there isn't early ioremap handling needed in openrisc, So the early ioremap handling code in ioremap() of arch/openrisc/mm/ioremap.c is unnecessary and can be removed. And also remove the special handling in iounmap() since no page is got from fixmap pool along with early ioremap code removing in ioremap(). Link: https://lore.kernel.org/linux-mm/YwxfxKrTUtAuejKQ@oscomms1/ Signed-off-by: Baoquan He Acked-by: Stafford Horne Reviewed-by: Christoph Hellwig Reviewed-by: Mike Rapoport (IBM) Cc: Jonas Bonn Cc: Stefan Kristiansson Cc: Stafford Horne Cc: openrisc@lists.librecores.org --- arch/openrisc/mm/ioremap.c | 43 +++++--------------------------------- 1 file changed, 5 insertions(+), 38 deletions(-) diff --git a/arch/openrisc/mm/ioremap.c b/arch/openrisc/mm/ioremap.c index 8ec0dafecf25..cdbcc7e73684 100644 --- a/arch/openrisc/mm/ioremap.c +++ b/arch/openrisc/mm/ioremap.c @@ -22,8 +22,6 @@ extern int mem_init_done; -static unsigned int fixmaps_used __initdata; - /* * Remap an arbitrary physical address space into the kernel virtual * address space. Needed when the kernel wants to access high addresses @@ -52,24 +50,14 @@ void __iomem *__ref ioremap(phys_addr_t addr, unsigned long size) p = addr & PAGE_MASK; size = PAGE_ALIGN(last_addr + 1) - p; - if (likely(mem_init_done)) { - area = get_vm_area(size, VM_IOREMAP); - if (!area) - return NULL; - v = (unsigned long)area->addr; - } else { - if ((fixmaps_used + (size >> PAGE_SHIFT)) > FIX_N_IOREMAPS) - return NULL; - v = fix_to_virt(FIX_IOREMAP_BEGIN + fixmaps_used); - fixmaps_used += (size >> PAGE_SHIFT); - } + area = get_vm_area(size, VM_IOREMAP); + if (!area) + return NULL; + v = (unsigned long)area->addr; if (ioremap_page_range(v, v + size, p, __pgprot(pgprot_val(PAGE_KERNEL) | _PAGE_CI))) { - if (likely(mem_init_done)) - vfree(area->addr); - else - fixmaps_used -= (size >> PAGE_SHIFT); + vfree(area->addr); return NULL; } @@ -79,27 +67,6 @@ EXPORT_SYMBOL(ioremap); void iounmap(volatile void __iomem *addr) { - /* If the page is from the fixmap pool then we just clear out - * the fixmap mapping. - */ - if (unlikely((unsigned long)addr > FIXADDR_START)) { - /* This is a bit broken... we don't really know - * how big the area is so it's difficult to know - * how many fixed pages to invalidate... - * just flush tlb and hope for the best... - * consider this a FIXME - * - * Really we should be clearing out one or more page - * table entries for these virtual addresses so that - * future references cause a page fault... for now, we - * rely on two things: - * i) this code never gets called on known boards - * ii) invalid accesses to the freed areas aren't made - */ - flush_tlb_all(); - return; - } - return vfree((void *)(PAGE_MASK & (unsigned long)addr)); } EXPORT_SYMBOL(iounmap); From patchwork Tue Jun 20 13:13:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13285828 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 0DF08EB64D8 for ; Tue, 20 Jun 2023 13:15:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 94B448D0007; Tue, 20 Jun 2023 09:15:08 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8FBBC8D0001; Tue, 20 Jun 2023 09:15:08 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 79D2D8D0007; Tue, 20 Jun 2023 09:15:08 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 6D05D8D0001 for ; Tue, 20 Jun 2023 09:15:08 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 2022880F1F for ; Tue, 20 Jun 2023 13:15:08 +0000 (UTC) X-FDA: 80923171896.27.AE9B34D Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf24.hostedemail.com (Postfix) with ESMTP id 1A2A7180024 for ; Tue, 20 Jun 2023 13:15:05 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=fOIAtCqa; spf=pass (imf24.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=1687266906; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=X3bCqAOghUMsrFt01sdBss+0xjEFSAaHuAsd0sFdmyw=; b=a2A8b5Q8UkAuPp0o/nhyNCqf+BN+li+sgcJBzOeBCOh/p9LDuR6SspbWJg+On3QDgFzJSJ vFfHSSKF/rEZtZeXqHR4I1mN4NYqbmGhygYnTbOPzWyDljQgjj+DdYW+x+MVyQCirKInry KQKp5UHKf0iCq2BLoXsONfWeHcWgV64= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1687266906; a=rsa-sha256; cv=none; b=Of8j9oxuJrJfWMl6CZJAZ9+b5X2z0cZEGK9CgTO/sQ8eDsShAUZlrpvgjGcIuxtiTakjKF CC7gobB4VWC1k4lfqNHhEZbKf8cAor0YFq90xDvpa9cWs5Iav01FpDkIIcPkjWoqyM3PoF lqc5KQ4IW8pWCVPjofk45AxAHUluS24= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=fOIAtCqa; spf=pass (imf24.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687266905; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=X3bCqAOghUMsrFt01sdBss+0xjEFSAaHuAsd0sFdmyw=; b=fOIAtCqaabDvbGlJUKbk2booH1tpM19iwlaX47BZxsh5oTTkH933/Sqw9VTsIFVM2AwDHl K2qyRL7zP6LhRY0GRaR0VI/HeK5X9FvSz6ChEajvHU4pEja3dy3Red3ycUy5ePjN1zwHUX nER41E5EiPDKdKLHs8d8HOVVVxU7bhs= 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-482-epsWYn-1OK2OdZZzg18BLg-1; Tue, 20 Jun 2023 09:15:00 -0400 X-MC-Unique: epsWYn-1OK2OdZZzg18BLg-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 DD04C8631DB; Tue, 20 Jun 2023 13:14:45 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-166.pek2.redhat.com [10.72.12.166]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0019EC478C6; Tue, 20 Jun 2023 13:14:37 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-arch@vger.kernel.org, linux-mm@kvack.org, arnd@arndb.de, hch@lst.de, christophe.leroy@csgroup.eu, rppt@kernel.org, willy@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, David.Laight@ACULAB.COM, shorne@gmail.com, deller@gmx.de, nathan@kernel.org, glaubitz@physik.fu-berlin.de, Baoquan He Subject: [PATCH v7 04/19] mm/ioremap: Define generic_ioremap_prot() and generic_iounmap() Date: Tue, 20 Jun 2023 21:13:41 +0800 Message-Id: <20230620131356.25440-5-bhe@redhat.com> In-Reply-To: <20230620131356.25440-1-bhe@redhat.com> References: <20230620131356.25440-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: 1A2A7180024 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: mtoey3mqjz1jwwyyxc7itg5nfsmf433q X-HE-Tag: 1687266905-918578 X-HE-Meta: U2FsdGVkX19cNuwK9EqFKz7Zv3Sw0KBMDCWE8MLdR8DP/UmoD4J+V1dJimAiIYjptdlgwyrVSiNC3PEXBgtuuPSMr98Qz2XUp/KHGzKZKUBdH3rvua+4q23r91RgPNvNAoAsbClo63OZlHQLg5+Nyttiw+9Uc/rPgofhKnApBEZRtlxkCrLnwyuaoSEHyoGBF0yUxYIgk6Ne8MvVmlugTURjcHIfUvdfrxxOAdWXCG+wWBL8TDIaTqRziWxXm0bjBsxvAlHidPgYZ0ejUNej0+3toRdR0K68uVQQHJKpD1NbAMxitkc+sivSIc4Nt4JYRPmrVGZfMvDCcLE2vgfWu0qgWnJSKtXpRYbtBWh392E4ibpdpZt/IuXO9JXeTakB6//kEr5hivahHRHAFFDcZmn2WAZ4e7fFVc2a1kNtDCJskqZ4HCwc1o8joEzh1ZubYM8lBDNVboHsfZzsNCdk3qQEeJRv5UsSy+k6m2KMvmETWyX5BGmcpLg4LVCBYnNrVAX2tF075l8i4TCfzb7muF92IRHlhgC7kxwM3ZHd/ZJezijLp1rPMWETpIr/O58NkkxRkh9mI22r6CyYZIPU3AExUE/6O9yJ2NjpfWix3fRdrgQi2dmBdam904oyNJPNWaz/HHwkzzWLXt5fhng/rYyyW4Cy11n65Q77cPOxdINUdr3bBgbCSsIMG4jm6unBSrjKiy4r8J79kmr/to/FfkL+UpmzFBGbk266kFLbf8eiRh+4FMuSLVPDhYt03BWZf9nuWEGT7lI7G/Md4EiOVMPywINTuH/02jdGZgH6dd7CCztX4JKyUX2TUQMAReDmBZSfzMCmu9dnW7q7W9cOqQumGWIjdfSvZV0n1SjucamXXDfzTAWTM8pkPznRk90fpFQ3aphGmpq+7OR667LvMFdzA8RAg9MjvUEy9NZBNBcr9JKigdFG9vf5X8ToMa0GsPbJBnErCslcNy88308 b3O9mf43 9pj3raAI32GVi+gVz5h6w4wtjr1xLyy6ymHynwPhh/5mJauN6ffPZcB1ilREXD5DRjW48IN3M/Xi7jK7Yz4m2gZyrRRp+AAk0M/+ctni7W1u1ZOZZjvt8A60PkWNWvq+LAAgJCLDQMAZ2uvAnGUg00/0SctOHlF5s8YSOG+1/Xc6dMieEtlyIfbz/NEFkAGWdgfzQXgfKXuJrHK7KGjMiWNg5QzmgaCGC/smrnbW8KwRUIFQFKAnynQ9U+Sg8q8Y5kniKQpaCD2RvMAbu0R/iWhzV+HvQHkEKS8ovLYhMlSLcEkZM3PXTDo+bHhivhdcq+iPkzdzyLOS4xE/PnpsYB/v8DhQR7ydlfzRDQ2PHOUenMic= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Christophe Leroy Define a generic version of ioremap_prot() and iounmap() that architectures can call after they have performed the necessary alteration to parameters and/or necessary verifications. Signed-off-by: Christophe Leroy Signed-off-by: Baoquan He Reviewed-by: Christoph Hellwig Reviewed-by: Kefeng Wang Reviewed-by: Mike Rapoport (IBM) --- include/asm-generic/io.h | 4 ++++ mm/ioremap.c | 22 ++++++++++++++++------ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/include/asm-generic/io.h b/include/asm-generic/io.h index 587e7e9b9a37..a7ca2099ba19 100644 --- a/include/asm-generic/io.h +++ b/include/asm-generic/io.h @@ -1073,9 +1073,13 @@ static inline bool iounmap_allowed(void *addr) } #endif +void __iomem *generic_ioremap_prot(phys_addr_t phys_addr, size_t size, + pgprot_t prot); + void __iomem *ioremap_prot(phys_addr_t phys_addr, size_t size, unsigned long prot); void iounmap(volatile void __iomem *addr); +void generic_iounmap(volatile void __iomem *addr); static inline void __iomem *ioremap(phys_addr_t addr, size_t size) { diff --git a/mm/ioremap.c b/mm/ioremap.c index 8652426282cc..db6234b9db59 100644 --- a/mm/ioremap.c +++ b/mm/ioremap.c @@ -11,8 +11,8 @@ #include #include -void __iomem *ioremap_prot(phys_addr_t phys_addr, size_t size, - unsigned long prot) +void __iomem *generic_ioremap_prot(phys_addr_t phys_addr, size_t size, + pgprot_t prot) { unsigned long offset, vaddr; phys_addr_t last_addr; @@ -28,7 +28,7 @@ void __iomem *ioremap_prot(phys_addr_t phys_addr, size_t size, phys_addr -= offset; size = PAGE_ALIGN(size + offset); - if (!ioremap_allowed(phys_addr, size, prot)) + if (!ioremap_allowed(phys_addr, size, pgprot_val(prot))) return NULL; area = get_vm_area_caller(size, VM_IOREMAP, @@ -38,17 +38,22 @@ void __iomem *ioremap_prot(phys_addr_t phys_addr, size_t size, vaddr = (unsigned long)area->addr; area->phys_addr = phys_addr; - if (ioremap_page_range(vaddr, vaddr + size, phys_addr, - __pgprot(prot))) { + if (ioremap_page_range(vaddr, vaddr + size, phys_addr, prot)) { free_vm_area(area); return NULL; } return (void __iomem *)(vaddr + offset); } + +void __iomem *ioremap_prot(phys_addr_t phys_addr, size_t size, + unsigned long prot) +{ + return generic_ioremap_prot(phys_addr, size, __pgprot(prot)); +} EXPORT_SYMBOL(ioremap_prot); -void iounmap(volatile void __iomem *addr) +void generic_iounmap(volatile void __iomem *addr) { void *vaddr = (void *)((unsigned long)addr & PAGE_MASK); @@ -58,4 +63,9 @@ void iounmap(volatile void __iomem *addr) if (is_vmalloc_addr(vaddr)) vunmap(vaddr); } + +void iounmap(volatile void __iomem *addr) +{ + generic_iounmap(addr); +} EXPORT_SYMBOL(iounmap); From patchwork Tue Jun 20 13:13: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: 13285830 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 BCD6BEB64D7 for ; Tue, 20 Jun 2023 13:15:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5C8C18D0009; Tue, 20 Jun 2023 09:15:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 579548D0001; Tue, 20 Jun 2023 09:15:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 440E68D0009; Tue, 20 Jun 2023 09:15:24 -0400 (EDT) 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 360BD8D0001 for ; Tue, 20 Jun 2023 09:15:24 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 0F904B0B01 for ; Tue, 20 Jun 2023 13:15:24 +0000 (UTC) X-FDA: 80923172568.22.3E6A9B8 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf18.hostedemail.com (Postfix) with ESMTP id 1C2FA1C0022 for ; Tue, 20 Jun 2023 13:15:21 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=CFGlcfPe; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf18.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=1687266922; a=rsa-sha256; cv=none; b=QGQ6fFruUfUjj5prcYVMGxYiKnF+IFQsRzif+ef4ZZMfIYopK3w6xrzHgLRd2a/CRRtPDj ue64HTQzLPw0wbW+TqHI1iNP9ZxLTu45KW/H4ngihYLd6OIy31N4CcDNMCCFt1FU2QtNmE DsqeFIDbpCdmysmgecgFT8afLcSUYTI= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=CFGlcfPe; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf18.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=1687266922; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=7Tl0uNK3iTFKABiIz7zb0nAC1GuwS9Iddx7rewdSaxU=; b=oHuA4tiAiDFsbigjQWWnjSWv5405rpjGIAd0KxmoadJel00WhbJWFQrzoJ5v9OdWOP4o1b 1bmh+eDTnD4OD/WjQfTgTKl84v8q2uOBE1qdB+t4RM0DvN5xaAIWmVAaCfkS8MllbZVz1n T88hwGuoz5BzXt0BP24okZTYeACBmzk= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687266921; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7Tl0uNK3iTFKABiIz7zb0nAC1GuwS9Iddx7rewdSaxU=; b=CFGlcfPeAiHMHa3smZlX5n3gGUtJyCKj4M98iAOrcyjHaP9CSUfkX4wfDJBMHW/XM+66xq jc9YJUvi54jO0T8VTqT97awbGzHEj8kl2p+uR1NXs3YdRNVZJOT/aKmcxKGNQNBFcXDfM5 qk2GiKKUTLJdc2Yapmrx9rsiy+UjCqc= 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-629-Q2tGUubEN3aW2VLS-NxC6w-1; Tue, 20 Jun 2023 09:15:17 -0400 X-MC-Unique: Q2tGUubEN3aW2VLS-NxC6w-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 61C0B89C7F3; Tue, 20 Jun 2023 13:14:54 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-166.pek2.redhat.com [10.72.12.166]) by smtp.corp.redhat.com (Postfix) with ESMTP id B8A0AC1ED96; Tue, 20 Jun 2023 13:14:46 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-arch@vger.kernel.org, linux-mm@kvack.org, arnd@arndb.de, hch@lst.de, christophe.leroy@csgroup.eu, rppt@kernel.org, willy@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, David.Laight@ACULAB.COM, shorne@gmail.com, deller@gmx.de, nathan@kernel.org, glaubitz@physik.fu-berlin.de, Baoquan He Subject: [PATCH v7 05/19] mm: ioremap: allow ARCH to have its own ioremap method definition Date: Tue, 20 Jun 2023 21:13:42 +0800 Message-Id: <20230620131356.25440-6-bhe@redhat.com> In-Reply-To: <20230620131356.25440-1-bhe@redhat.com> References: <20230620131356.25440-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: rspam06 X-Rspamd-Queue-Id: 1C2FA1C0022 X-Stat-Signature: 3si8me4sdmi9zxz1jw3wi7aac1a6kzzu X-HE-Tag: 1687266921-640404 X-HE-Meta: U2FsdGVkX1979o7G3+p9yPObJAUyOyQDwptMV6g3eyvdoWcKiJzgKaYjX/cpeZMDfiuJOJPLQGNImtwKjivnug+4nc8m3WZlA6cIFYrYNVIae8w0Nb5RS6yLAKGbmRlZ2zi80mPd+XMZ4n2vMYLSh5NBBPumBUKsiqjYYCbnUel81SQI5oyWOuY3lbFG8ce9srTK4bDgLpyhOCbH2mt9fLGnqa+2hfMynSUawk8YZVmuNNIJDNXx+HYO2lXifNYRSqCUtwUAeQcquhjp2VkufpkGjt8H5cmL+3YRVPssQBWu/weHRmkeU5pf94Of74Xi9syFgrv9bOke0Ip5aeKVXgKico+psHB/xJsaa8Sn25qhA9HA3S6YwB8nE0VQwkUR5BqBCWrX1XT7WrT62XXUnKTK83ZQVim1W2BFlp+sI4kqAMNolDKX3ihyaBUc1pZ05yiqqEZkq0ghfq8TG2w4SF+5+06+yNGcou2cgGIk1dG28jL/YCbFpM7Lpuext/Bnu4WABaj9xhnElSolFCkW2HGipJZCDYzGK+NNWtC2Y+/mH9kjEHZeKPV2VWjdWKltE0gaXyczS8tEQJM96Cpr2UOfhP48MUkoSnkSfWoIlabKgVAdIS5bOY4Se1t6GeZwEHX2cQ5gs6YeN7SQB+gMOpnnJUcdT1OSVnYhxYD4oyY5pbpKEvZQ6G9zTFulo31pm71uIR/WToWfPxk1BvrkXXFIO7JYVohl8Q0DEdJw4yQArMofiA+12OfkFKxHoAyUv5FwigHNS6iQRXPhUhvbyCSItILEKFJPhFqtdzibSAI3HohVh2to6btL2Ay04t4CcJjS7LJ0X3wydaJAFP7xtEtcCV+GyU00XLF/7YE9AeXgN//sgSfcMc2nl5C6Y2rIA4O6mgk0AiGfuk1EYiwde3ACKqD1XrHqA1Ghl7M3SRLpWbzMMFaVY+3WUu/gPp4p4ZOUarU0QBcjxCsaugi 0LSLHljg 2qJ7ybuR3653XbkbU66Ni4L8k+Cf0L1XuIo233ELCDQzrgwpvNDxaGQ09yhZXfDWdBZvnAHidR0dllRbUHqxu9Ck0bA06Lu2XqcXNu3peGUdh6rjVAwerQjZSNLTvU+7SFhzgDo2RMMRirJ8Kxltrl6NFOfP38L1epXDkW+rz/ZlBWValFfEAiqsin0/GTunYXSHgLU1zR6hKen2m+xeAvznkBK9szbeWEiPUZmCnKsiNTkxHdjkReEcthg9MFOlExKjM X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Architectures can be converted to GENERIC_IOREMAP, to take standard ioremap_xxx() and iounmap() way. But some ARCH-es could have specific handling for ioremap_prot(), ioremap() and iounmap(), than standard methods. In oder to convert these ARCH-es to take GENERIC_IOREMAP method, allow these architecutres to have their own ioremap_prot(), ioremap() and iounmap() definitions. Signed-off-by: Baoquan He Acked-by: Arnd Bergmann Reviewed-by: Christoph Hellwig Reviewed-by: Kefeng Wang Reviewed-by: Mike Rapoport (IBM) Cc: linux-arch@vger.kernel.org --- include/asm-generic/io.h | 3 +++ mm/ioremap.c | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/include/asm-generic/io.h b/include/asm-generic/io.h index a7ca2099ba19..39244c3ee797 100644 --- a/include/asm-generic/io.h +++ b/include/asm-generic/io.h @@ -1081,11 +1081,14 @@ void __iomem *ioremap_prot(phys_addr_t phys_addr, size_t size, void iounmap(volatile void __iomem *addr); void generic_iounmap(volatile void __iomem *addr); +#ifndef ioremap +#define ioremap ioremap static inline void __iomem *ioremap(phys_addr_t addr, size_t size) { /* _PAGE_IOREMAP needs to be supplied by the architecture */ return ioremap_prot(addr, size, _PAGE_IOREMAP); } +#endif #endif /* !CONFIG_MMU || CONFIG_GENERIC_IOREMAP */ #ifndef ioremap_wc diff --git a/mm/ioremap.c b/mm/ioremap.c index db6234b9db59..9f34a8f90b58 100644 --- a/mm/ioremap.c +++ b/mm/ioremap.c @@ -46,12 +46,14 @@ void __iomem *generic_ioremap_prot(phys_addr_t phys_addr, size_t size, return (void __iomem *)(vaddr + offset); } +#ifndef ioremap_prot void __iomem *ioremap_prot(phys_addr_t phys_addr, size_t size, unsigned long prot) { return generic_ioremap_prot(phys_addr, size, __pgprot(prot)); } EXPORT_SYMBOL(ioremap_prot); +#endif void generic_iounmap(volatile void __iomem *addr) { @@ -64,8 +66,10 @@ void generic_iounmap(volatile void __iomem *addr) vunmap(vaddr); } +#ifndef iounmap void iounmap(volatile void __iomem *addr) { generic_iounmap(addr); } EXPORT_SYMBOL(iounmap); +#endif From patchwork Tue Jun 20 13:13: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: 13285831 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 8990AEB64D8 for ; Tue, 20 Jun 2023 13:15:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2E2928D000A; Tue, 20 Jun 2023 09:15:34 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 292618D0001; Tue, 20 Jun 2023 09:15:34 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 15A9E8D000A; Tue, 20 Jun 2023 09:15:34 -0400 (EDT) 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 0846E8D0001 for ; Tue, 20 Jun 2023 09:15:34 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id A63D240F75 for ; Tue, 20 Jun 2023 13:15:33 +0000 (UTC) X-FDA: 80923172946.18.1DBEE5D Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf12.hostedemail.com (Postfix) with ESMTP id 7A94E40020 for ; Tue, 20 Jun 2023 13:15:31 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=g0ezbjGC; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf12.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1687266931; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=w2IfnXMZqwx1Jn18is50whUi5yxeZ3Kn4EXboxrstks=; b=OF4xS/zSKqXEH3knil+4AzYUscbSVX8rrhI8wKumqWCPgWetkC78NcIq7YCcc+hVCt3uhY 6l4EZr6IFm2/t6YPt+yOkAnm6P8DravhnPwst9D83MVF57li3tv28NXuonThzEoOTybL6Y QqW7P9EINNuZQ+W8G37TRnQl946zYFE= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=g0ezbjGC; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf12.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1687266931; a=rsa-sha256; cv=none; b=n7uxRB2AzOGeeKy5L/7waniQuEOFvrhM6uML8VFZpuPjx+VNlr/UPn8ObkMeDWeHuFJ8Pi Kar5WvW5Iy5w32Va10Jr+9sHyAE4WhFIWPCko2HdZYmQfravckCvuLTSXhWr/EAVnmzbHV kXoX+0Tn/Nos/SI7oymhqjQbD6OK3FE= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687266930; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=w2IfnXMZqwx1Jn18is50whUi5yxeZ3Kn4EXboxrstks=; b=g0ezbjGC46VxvcIq+UHr019/aL3Ob4NT/XBjOkhCzR3kJYsZOR0UM8UQEOICELZoiJshd7 MZeHzRq4UwCT7ZJgYJwTnOOFo5Aa0RDWlbMTs1HRRjuU+RVE/jXf3yJvGNC4n4j+KEDhy4 CGuS99QE+kTE1y7borS69q01iCrsKgA= 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-223-eZ8OPzrSP4eN5oanIq9oUw-1; Tue, 20 Jun 2023 09:15:25 -0400 X-MC-Unique: eZ8OPzrSP4eN5oanIq9oUw-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 4EDD1185A7AA; Tue, 20 Jun 2023 13:15:03 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-166.pek2.redhat.com [10.72.12.166]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4D9FCC1ED96; Tue, 20 Jun 2023 13:14:54 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-arch@vger.kernel.org, linux-mm@kvack.org, arnd@arndb.de, hch@lst.de, christophe.leroy@csgroup.eu, rppt@kernel.org, willy@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, David.Laight@ACULAB.COM, shorne@gmail.com, deller@gmx.de, nathan@kernel.org, glaubitz@physik.fu-berlin.de, Baoquan He Subject: [PATCH v7 06/19] mm/ioremap: add slab availability checking in ioremap_prot Date: Tue, 20 Jun 2023 21:13:43 +0800 Message-Id: <20230620131356.25440-7-bhe@redhat.com> In-Reply-To: <20230620131356.25440-1-bhe@redhat.com> References: <20230620131356.25440-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: 7A94E40020 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: dmtrjty6hgdgkdq8k4x39ns9zjhn3x7w X-HE-Tag: 1687266931-476241 X-HE-Meta: U2FsdGVkX18F2hiFb8osWpZU1zwi65iIYx4Q2BrQ7xebJa2MjC1XzBJ/kocwvn56WB4ozdw3fsxZg5CyeHhnmR0pRlM1GI0x23qWO8FCB3f7RZ1noQExe2HRnBxiL/0Gi/qMhRZoLsU+3+DG6HXqyAjYBsoPcdgl2I0cUXZdCuHahYPihiAniugvRZ9n5CqIDOQhg9FqatLcUCCguTfGWGeTRMYlDLqBFnbBsAWTSj3gXlTmdeGsjJPAbdaA0GrMzeZgJDVfz1qxis+F0KbhnCyBI9ID64NNvmhb+HsTeegs+p0Sx+eswblbm3PxA6lpBCC+xADrgbI5OyU3YEH6br019GyMo9ZmBMAp1lpXCYy4URV2P8Ns7kjszmpWgHst20A5/VcVuYBD3ddBGWYgOFz266GqFnRm0OWnBlKro2kXqwU3cXPX+D9EXDi7+gL2WcbRBG50s0fa+O1k5AJzl8qYa7nWmCcIix4HYk4oDXrIttsDWYCYFCGwIjyx4K3r9ROMgP7a+zGxVVTKpC20qhdFBcW8ITuaoX424KjmwWIBltJRxf4w8Ot5Xkm6bPtWEK+fzCd+hbw0fYDbiom3KqMSe5fs9Rlm8J6n0srZ4nl/p6EbWidG9p/IlWQjq+8cwq/Gc5A0wTXytjfkpQjyJtdeQJ5vq4YJkIbcxKqpOKFLtbKuHdxQg8rLoqkbV/Xg+1UJIOS9YmE+zWVpIbAzgyJod6zfHXmeK5X4uMfGBzSF5TkelTusS3up3Pmr4zQCjJzV8QV5lvUIKnSt7oCIp5BDDz+3H/MGV78bnefxAtpUfAvd9kaRlaEYGP68ANSa92YwcsNcaDLzaVyCh15m+UlUoZP3kQU7A4uKMHWpl2dGgIu4lvdovwpEGHOhzDSaHJW2pQRvSVpSb7gZc3uayaCnD4czcscxaxjPDPJi6bP/cdYYZBk7b2gAxvp3b/8RDKzBAzEUS73DxJ9rs1L FYTt24cU R6aikYrdOQlnMM8Za+ukk5aCE6oOERhNl045mENgEvMvdNWmN32tiaJep+IXd78LBL804zolzHrc5XKneHD4VXp3f5z8pSrcZKEHg/tQiHBVLcOYQ4gsrS/o8bOxQXDsku9YKPs6ce88bPJxTDAOpFlyGGlNz02DASZvZpw8ozgtHJUajF7xVry9PMIhhcmuocRmzNEgaB7AS/7hlqR1LtDKlAvzNYoaxVf6BSlWSgz7mj2+xfskErx5lCeafjZTKBoiMZu6O0GYl79Tc6KQ0qmZv0gFdye2a+wtGNRYpE0Ye3ve8YX0tywpZHXhxgKV+cNbl5VJ98+D4jpBibEAYO/CqOqiofE+3rPDbVCNddA39OOs= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Several architectures has done checking if slab if available in ioremap_prot(). In fact it should be done in generic ioremap_prot() since on any architecutre, slab allocator must be available before get_vm_area_caller() and vunmap() are used. Add the checking into generic_ioremap_prot(). Suggested-by: Christophe Leroy Signed-off-by: Baoquan He Reviewed-by: Christoph Hellwig Reviewed-by: Kefeng Wang Reviewed-by: Mike Rapoport (IBM) --- mm/ioremap.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mm/ioremap.c b/mm/ioremap.c index 9f34a8f90b58..86b82ec27d2b 100644 --- a/mm/ioremap.c +++ b/mm/ioremap.c @@ -18,6 +18,10 @@ void __iomem *generic_ioremap_prot(phys_addr_t phys_addr, size_t size, phys_addr_t last_addr; struct vm_struct *area; + /* An early platform driver might end up here */ + if (WARN_ON_ONCE(!slab_is_available())) + return NULL; + /* Disallow wrap-around or zero size */ last_addr = phys_addr + size - 1; if (!size || last_addr < phys_addr) From patchwork Tue Jun 20 13:13: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: 13285836 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 2C5C5EB64D7 for ; Tue, 20 Jun 2023 13:16:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C31FA8D0006; Tue, 20 Jun 2023 09:16:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BE1238D0001; Tue, 20 Jun 2023 09:16:15 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AA9898D0006; Tue, 20 Jun 2023 09:16:15 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 9C5E88D0001 for ; Tue, 20 Jun 2023 09:16:15 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 75FDA140EB1 for ; Tue, 20 Jun 2023 13:16:15 +0000 (UTC) X-FDA: 80923174710.04.6D3455A Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf29.hostedemail.com (Postfix) with ESMTP id 641CD12002A for ; Tue, 20 Jun 2023 13:16:11 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="Y/Ka63On"; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf29.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=1687266971; 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=AgITI2yqguKz3xZ3AEWeb8MIawpkLomY+LhKu59PhRc=; b=UQpm38bcRVMlpEKjJDkdLbdMp2ShcMh+1c2MomtjvyapRz+UDMqtzeWtuaVHe7knQ5jnBc BNDcv7aWwNTWJqYwDcRc16AF/n9ZVhNspBWjCDenma6Gkn1no4WaEUhb+eDEPQY2n2h3ae kTutgcxsw9J/WD0hxWikOCUH7e8nXX0= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="Y/Ka63On"; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf29.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=1687266971; a=rsa-sha256; cv=none; b=BJNJO5dn8sb6/rboaTJMR9Kx/MtEJXgE/XlXgkFxEePyMRallozmLgDTByx8ZsGagEpehJ 5UDWOhfO2nXu2SajbXp74K5rUjq+F1E4Uoy2NvE3M92gsf62RSxdy7V6VfSVMUATw8Fkqr Yu2wJPr//33lLvtucZPyw9nXrT9coA0= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687266970; 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=AgITI2yqguKz3xZ3AEWeb8MIawpkLomY+LhKu59PhRc=; b=Y/Ka63OnncpYWbpTY4zRZUjzKyPf1jhHrOMVmekRirIGplIbMg4/gbSpzNdhyijZMPvbqh iGCS2HQECex2INwf0neRuWb051fZsvAkP8D/Rf9rJwuyPZfj5IccMfvWPKNhUpLnYRmLiM JYWmK9COOkxRCkW5mlQd105qcqsT2ys= 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-628-2PC6h92vMtusrC1Vh20AjQ-1; Tue, 20 Jun 2023 09:15:29 -0400 X-MC-Unique: 2PC6h92vMtusrC1Vh20AjQ-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 D773788D06E; Tue, 20 Jun 2023 13:15:12 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-166.pek2.redhat.com [10.72.12.166]) by smtp.corp.redhat.com (Postfix) with ESMTP id 20176C1ED96; Tue, 20 Jun 2023 13:15: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, hch@lst.de, christophe.leroy@csgroup.eu, rppt@kernel.org, willy@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, David.Laight@ACULAB.COM, shorne@gmail.com, deller@gmx.de, nathan@kernel.org, glaubitz@physik.fu-berlin.de, Baoquan He , Vineet Gupta , linux-snps-arc@lists.infradead.org Subject: [PATCH v7 07/19] arc: mm: Convert to GENERIC_IOREMAP Date: Tue, 20 Jun 2023 21:13:44 +0800 Message-Id: <20230620131356.25440-8-bhe@redhat.com> In-Reply-To: <20230620131356.25440-1-bhe@redhat.com> References: <20230620131356.25440-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: rspam09 X-Rspamd-Queue-Id: 641CD12002A X-Stat-Signature: 89ettmwk87cnh6gjd16magu6zrfrkooh X-Rspam-User: X-HE-Tag: 1687266971-966650 X-HE-Meta: U2FsdGVkX19do3fLClyidjmKm7TOqGtV8dRXgzM2nfU+9dG5nkj9EkqGhLVtsE6ecXEmR+KoJ+AJAhOtc4ek9DrR14DxGD0rwFvjFbHb2K3aN8dxO/Ulcro8TOOoeEne8t3LMsABDsU6VlenA8wI1aJJNx9d37g3fXnuFtnmM4cWNE2FpVsZA5NH4XQ0nnWtYbz90o0Bp7XJxV4qa401FatveUKXiHOT5P82F9qthBxtylgfwVRa+hQpEG5MSId+OJjIk1+fiZ4mFn8N/9al8wVg3ula/p4axqYElUjgn0RvrnEyJ3RtmrODXowv1kAI8sTXyEQGHvexVVCKn82vR3Xj9HLlFMrn1+NiGWc3MX2j5Om8cKDByr5fETPnKDVYUrgbB85hZizuNo7hmHp3BwIHrjhPIHk2FC1B5yrV3ARxPSFdcSSO2fHlkMABAI8AjU8yl2bPuevnGBxB5zobOBupOj6ZkL4kFfhmr6onJ9lRnJjTBncB2Ob8B+fu2R5F36FtKPcunlWyNIf/DFFBUD9ph96E5zvpyCOWCL1Mi/IDEVuOLOkjiQ6aRpGoSUcC1vQR8ERE71yXXZHoPlI+Rm13cBp32SqEynbmMQM3ReCtc5DvODWz5H1aYE15YWdBoHRSI/HVu75SOqiQmfLHvkK/sLszDD3ZOG71p2HVyKAIX5gTR5Akb+Y0oKGXfoxmduPPpc4mI4J7umM/PMryAP3rYpyIdMKiMVKZ4o56US3idyPlCgBMzYzCO0YKWOLyuHbgFiIwOrwdpVZJe86Hia6yu1VSA9ZW7vOSMOuggEso9fQ7Mk74xnWTJCapRAKxfP888uEQ33xOll1MD907oPxHG4Rmy0ssMvyxyJcLNSZAKyCrUfEi+9/2I131K8o35+VvbMEiU66xt4kaGc10QcRfVH8ghCDhvhFMT7geDpHuDrSjiBWlEs1v4oppNivyK84CEYoenriskidetIL c2QzeYH+ QeasemLDzYMdIKYlrDzGRGiQvS4saRwMmSk7hR0ZftNRWEpT+mxAITkCMN7TEDwt91ysMFUpSLroq/nQLCOba48CxCJWdilRGByf4pnEHs3h58fFGCzam0FfgBNXjIls9mZ0Qm9ReldlKYL9KrEECiVLrltwSzr2i51ASf2sN1UQjh2LEuCLcphGT4P56LhSE+AaRYWqQ/ENUjJvQAD3pwCcnb3Z+c5VHJfzrRHQ/9SOktIGxGkBvcK+O/r8WIkkiUWHcK5qX6ZV5D2c8mCuEUeuW6+KxKzvWZ074W2OYMPGBY0jNax/t+GnKK5MbdXNI+KACgFgVW3FWbEKJ5ErKdWwQIA== 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 Reviewed-by: Christoph Hellwig Reviewed-by: Mike Rapoport (IBM) Cc: Vineet Gupta Cc: linux-snps-arc@lists.infradead.org --- arch/arc/Kconfig | 1 + arch/arc/include/asm/io.h | 7 +++--- arch/arc/mm/ioremap.c | 49 ++++----------------------------------- 3 files changed, 8 insertions(+), 49 deletions(-) diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig index ab6d701365bb..3a666ee0c0bc 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 Tue Jun 20 13:13: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: 13285832 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 36A69EB64D8 for ; Tue, 20 Jun 2023 13:16:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B6D618D0003; Tue, 20 Jun 2023 09:16:01 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B1DE78D0001; Tue, 20 Jun 2023 09:16:01 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9E5FA8D0003; Tue, 20 Jun 2023 09:16:01 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 8F30A8D0001 for ; Tue, 20 Jun 2023 09:16:01 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 46104A0EA1 for ; Tue, 20 Jun 2023 13:16:01 +0000 (UTC) X-FDA: 80923174122.02.CCB319A Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf27.hostedemail.com (Postfix) with ESMTP id 1148340010 for ; Tue, 20 Jun 2023 13:15:58 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="AJZhF9/k"; spf=pass (imf27.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=1687266959; 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=ua5XWkW27x0Nyt2yapSJ4JgStlbMxAmr6HBzd8gpRZY=; b=YshPGYrMvg5zgsKN+u++ssYpTizmqN6PRNlS6Xsx9a2/OBbRKW5v1oAbm/94S1B2leytq9 60bTn5jr4mN1Dhrbb6kF9Jqi+JfMI7t9GJzWGHJBW+nPPgYlBpCtPmJ5aNv9EOW/Zp2N5n HUj2UleL+0aHaa6R5j5rjLcrfpRmyD0= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="AJZhF9/k"; spf=pass (imf27.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=1687266959; a=rsa-sha256; cv=none; b=x1660SOI33XG2iBJB+Cr8uX8Gb5V2Q3l/WbYrO1QkaAjtacJ8n+dIGq1z06qceurtknc0h QmYsJlNq43JZUuZYTtQ/7pJvXxp7qPH1Tdipj0EuktBwuhfgmPjMg8fl/yb+l5Co0EybDH bnpqTETwGNI8TOSiZtsZJfcVvgM4y54= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687266958; 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=ua5XWkW27x0Nyt2yapSJ4JgStlbMxAmr6HBzd8gpRZY=; b=AJZhF9/kIQ8JRE0kXcGCHxO4sDfEl+Sypw8CZT2RFbuEEJMj8dxxmsD4Z6WkBI+7aTwj+7 2P9SBTviDoF7ExO/lxErpYCbU0fY3zXCI3kSg7NUsa09rdpXeRhKJbqB0qXjXtcQoEUmWA /SRXjgRrj3IK0hQTDV6PhxOAnxNnl9o= 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-348-3YurffZuN3-tB-8HQxDxBw-1; Tue, 20 Jun 2023 09:15:55 -0400 X-MC-Unique: 3YurffZuN3-tB-8HQxDxBw-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 BF2C12A5955D; Tue, 20 Jun 2023 13:15:22 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-166.pek2.redhat.com [10.72.12.166]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9B61FC1ED96; Tue, 20 Jun 2023 13:15:13 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-arch@vger.kernel.org, linux-mm@kvack.org, arnd@arndb.de, hch@lst.de, christophe.leroy@csgroup.eu, rppt@kernel.org, willy@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, David.Laight@ACULAB.COM, shorne@gmail.com, deller@gmx.de, nathan@kernel.org, glaubitz@physik.fu-berlin.de, Baoquan He , linux-ia64@vger.kernel.org Subject: [PATCH v7 08/19] ia64: mm: Convert to GENERIC_IOREMAP Date: Tue, 20 Jun 2023 21:13:45 +0800 Message-Id: <20230620131356.25440-9-bhe@redhat.com> In-Reply-To: <20230620131356.25440-1-bhe@redhat.com> References: <20230620131356.25440-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: 1148340010 X-Rspam-User: X-Stat-Signature: 7oefehwqe11n1zrtdm9edrqdsxcmiru5 X-Rspamd-Server: rspam01 X-HE-Tag: 1687266958-417057 X-HE-Meta: U2FsdGVkX19OMYJjWgXBCmGXfQPPxd0fhTUMhurrw44qUHG9R4TKElxpgCjqS6JnB4Ta7jAull/uSZtNWw6xy4SpNvA+HO3QsMcgGgOz7gonwSCbpxdW3mMxB+rF98CTXKWLFDcc6UdoqG9mNlK1gdITmdSsBDbZfSjHlQgUDkQYxXPjot4bqQ6RHE2N7ncYmMiMV5TjwxH9BIHjhR1cmshgQulGsJaqvWp3qFn1PfwaM89AKPDZPBM3q4DVQf7Qxdts1/MwJMyytJNXWIJ3T9hjEBK2lsITAGPa8rcHuIUaDNB8ZU14JeaBsG5BkG8fjiGPBHw6Dv58Mf2Eh1/TiVSczhrJnSbSSGVHMhUjvMNYE1RnaE/jdV+cwAmyqphuxqrX12I4/0D/CkcI0c9rneRvH5ALpHOSa37dctBtouZGvVI2i9B5tGy4VX61W9zHG5+8wZy9Z9HYPo3p3ftaZWYt2W04nzxbQ9y92VgS2FMc9NRMKK3Qd/zplQa8UuqycHOGiegdUPomizIQHL393OZMl42fIpx7preNrM2eD7cKeOqoXOOYTSV2wVtSNjsYUamf2LsbRGe6NKt8baxOTJmrxLm77ejgRcdaWqRJ950PaStIgfafFdVw0ELuEmXQCSSIBin3MnKgq8GEAT2s/K73176m9iJfhqok+JG9ztFX7QPWOO2skskpAP/egclEBssfzToMikjl0LIZhWXCpZ8SbYCA82YFuik51Ba4JBbVizzLzvrywBypG90X4L/arlbKZ/YJNAD7Nqu2dGIsW6vUEfQCcuhoPjKuloZSO1T4GC0yjHMwx3djR4wlD8LOSRlTKhbhZlDZQIesMEwyRSFWqXTDO7lNLmwGDhXUgxlkzFOutPpvjj81KHuDCrq5OBKE9r19wW9oR3zeMfNAp5ldyPEhi48EwSri2OPc/pDlaNCahTm+p/MzHabXXRglT5HqlggxmCRFpryMTSV 21lXJLiK dnhOl5hylsaBiYNTAGBuAHk5+59mVhLL+se4dSI6eDncedeQzoT3Qh4rsd52dF8W7gqtWNqBq3UV9edkivvLaNY29mMku4O2y+GFWkHZ/twOymGMA3pdbzI+Zw9btiBJQuOS9/iwGHWgLiTdXrpMM/2P+X5sYHYbacidsh8cSccGdzYscOnTv821Ojtv7HSd0GeGPM1DHpNVuHgoECzEpI8qxv5BCzCps49iiaVmzwNYHuBM+/ZqCrTLfcWXfSlwKkoYXI/M6UnDMAR4YUdbDND4qHQ== 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 Reviewed-by: Christoph Hellwig Reviewed-by: Mike Rapoport (IBM) Cc: linux-ia64@vger.kernel.org --- arch/ia64/Kconfig | 1 + arch/ia64/include/asm/io.h | 13 +++++------- arch/ia64/mm/ioremap.c | 41 ++++++-------------------------------- 3 files changed, 12 insertions(+), 43 deletions(-) diff --git a/arch/ia64/Kconfig b/arch/ia64/Kconfig index 21fa63ce5ffc..4f970b6d8032 100644 --- a/arch/ia64/Kconfig +++ b/arch/ia64/Kconfig @@ -46,6 +46,7 @@ config IA64 select GENERIC_IRQ_LEGACY select ARCH_HAVE_NMI_SAFE_CMPXCHG select GENERIC_IOMAP + select GENERIC_IOREMAP select GENERIC_SMP_IDLE_THREAD select ARCH_TASK_STRUCT_ON_STACK select ARCH_TASK_STRUCT_ALLOCATOR diff --git a/arch/ia64/include/asm/io.h b/arch/ia64/include/asm/io.h index 83a492c8d298..eedc0afa8cad 100644 --- a/arch/ia64/include/asm/io.h +++ b/arch/ia64/include/asm/io.h @@ -243,15 +243,12 @@ static inline void outsl(unsigned long port, const void *src, # ifdef __KERNEL__ -extern void __iomem * ioremap(unsigned long offset, unsigned long size); +#define _PAGE_IOREMAP pgprot_val(PAGE_KERNEL) + extern void __iomem * ioremap_uc(unsigned long offset, unsigned long size); -extern void iounmap (volatile void __iomem *addr); -static inline void __iomem * ioremap_cache (unsigned long phys_addr, unsigned long size) -{ - return ioremap(phys_addr, size); -} -#define ioremap ioremap -#define ioremap_cache ioremap_cache + +#define ioremap_prot ioremap_prot +#define ioremap_cache ioremap #define ioremap_uc ioremap_uc #define iounmap iounmap diff --git a/arch/ia64/mm/ioremap.c b/arch/ia64/mm/ioremap.c index 92b81bc91397..711b6abc822e 100644 --- a/arch/ia64/mm/ioremap.c +++ b/arch/ia64/mm/ioremap.c @@ -29,13 +29,9 @@ early_ioremap (unsigned long phys_addr, unsigned long size) return __ioremap_uc(phys_addr); } -void __iomem * -ioremap (unsigned long phys_addr, unsigned long size) +void __iomem *ioremap_prot(phys_addr_t phys_addr, size_t size, + unsigned long flags) { - void __iomem *addr; - struct vm_struct *area; - unsigned long offset; - pgprot_t prot; u64 attr; unsigned long gran_base, gran_size; unsigned long page_base; @@ -68,36 +64,12 @@ ioremap (unsigned long phys_addr, unsigned long size) */ page_base = phys_addr & PAGE_MASK; size = PAGE_ALIGN(phys_addr + size) - page_base; - if (efi_mem_attribute(page_base, size) & EFI_MEMORY_WB) { - prot = PAGE_KERNEL; - - /* - * Mappings have to be page-aligned - */ - offset = phys_addr & ~PAGE_MASK; - phys_addr &= PAGE_MASK; - - /* - * Ok, go for it.. - */ - area = get_vm_area(size, VM_IOREMAP); - if (!area) - return NULL; - - area->phys_addr = phys_addr; - addr = (void __iomem *) area->addr; - if (ioremap_page_range((unsigned long) addr, - (unsigned long) addr + size, phys_addr, prot)) { - vunmap((void __force *) addr); - return NULL; - } - - return (void __iomem *) (offset + (char __iomem *)addr); - } + if (efi_mem_attribute(page_base, size) & EFI_MEMORY_WB) + return generic_ioremap_prot(phys_addr, size, __pgprot(flags)); return __ioremap_uc(phys_addr); } -EXPORT_SYMBOL(ioremap); +EXPORT_SYMBOL(ioremap_prot); void __iomem * ioremap_uc(unsigned long phys_addr, unsigned long size) @@ -114,8 +86,7 @@ early_iounmap (volatile void __iomem *addr, unsigned long size) { } -void -iounmap (volatile void __iomem *addr) +void iounmap(volatile void __iomem *addr) { if (REGION_NUMBER(addr) == RGN_GATE) vunmap((void *) ((unsigned long) addr & PAGE_MASK)); From patchwork Tue Jun 20 13:13: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: 13285835 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 E090EEB64DB for ; Tue, 20 Jun 2023 13:16:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 860848D0005; Tue, 20 Jun 2023 09:16:07 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 810C98D0001; Tue, 20 Jun 2023 09:16:07 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6D8DB8D0005; Tue, 20 Jun 2023 09:16:07 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 5F9838D0001 for ; Tue, 20 Jun 2023 09:16:07 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 3B68580EF7 for ; Tue, 20 Jun 2023 13:16:07 +0000 (UTC) X-FDA: 80923174374.20.DB17659 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf29.hostedemail.com (Postfix) with ESMTP id 4EE56120027 for ; Tue, 20 Jun 2023 13:16:05 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="Y8uRA/Sv"; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf29.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=1687266965; 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=hRSXXySDVVhLotgjE0rU55vk+UOhOsM9Dref/f4m5gg=; b=Q8TdwDWVGlc5EXMNHfwLvQ+ldODACcqLE/qsdBNJ7p32JzsabSvbJjlVwa6vzjLU99o8So hUSvxXFbqzQ4hs4sjYANqgGotAx0UJLVes3vk3i7Sv6zBvbgHomWn9i5TdNQ/xa0SDHXXE oy0g526zMW4KKe59OqJBv9/p4ehL07Q= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="Y8uRA/Sv"; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf29.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=1687266965; a=rsa-sha256; cv=none; b=DmUrFGJlsstJ9HePDLi8RoYvfHKP0bsYFtIQuOsbzdi0jFkj7Sny5tDSNCygqJcj9o6sT6 Xdo2D/J/BLOiH35aT4W8F0c/5WGCPslxFiCEf2W1sOme9x3WN26nh4OWzvaCOSI7e+NVXt u6py0dMS9peR+0Iq2iulYNAv9MB9ZLE= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687266964; 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=hRSXXySDVVhLotgjE0rU55vk+UOhOsM9Dref/f4m5gg=; b=Y8uRA/Svkl/2lHSzKVqrKFhYZLzGcloEclrn+s4VJNbPRXs+HrucaBGMIJL5xKN1qSb8l/ StWwR7WdNdkSioYt672/E3mGkNHE4Jd9H/XQNq7+CNjRDITsJGWHR4pV4XALG5/irsfeZ9 0hNfDNVa2TVcYTVvK4v2aquGBJ+nVSE= 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-296-qOCASngvM_yZoj8Pd4FMrA-1; Tue, 20 Jun 2023 09:15:57 -0400 X-MC-Unique: qOCASngvM_yZoj8Pd4FMrA-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 9A037280BC4E; Tue, 20 Jun 2023 13:15:33 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-166.pek2.redhat.com [10.72.12.166]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8D154C1ED96; Tue, 20 Jun 2023 13:15: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, hch@lst.de, christophe.leroy@csgroup.eu, rppt@kernel.org, willy@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, David.Laight@ACULAB.COM, shorne@gmail.com, deller@gmx.de, nathan@kernel.org, glaubitz@physik.fu-berlin.de, Baoquan He , Jonas Bonn , Stefan Kristiansson , openrisc@lists.librecores.org Subject: [PATCH v7 09/19] openrisc: mm: Convert to GENERIC_IOREMAP Date: Tue, 20 Jun 2023 21:13:46 +0800 Message-Id: <20230620131356.25440-10-bhe@redhat.com> In-Reply-To: <20230620131356.25440-1-bhe@redhat.com> References: <20230620131356.25440-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: rspam09 X-Rspamd-Queue-Id: 4EE56120027 X-Stat-Signature: 34o8dyxykn65p5xskphesbnzh7ecxbm4 X-Rspam-User: X-HE-Tag: 1687266965-201879 X-HE-Meta: U2FsdGVkX1/J/7SJCPKA17C2z5QsVkAJ6vHrmiJogj7sGSebrDjy5PuBnhfpaTE0mEI6doE09mbEIonzv/DXnKUrz1Pcvs+QfVhB8Ix0oyR6V3IwBKNaoN2C0sXl9d/XINUl5yyo1d+lPWr6YOtmdKQviwclpAPgrQCZXmxOjHmrv0dLl0VZ3RMwtKmIZBmmtR8ZEKPpPouL2h25UQ9SyGTPkK0nbaiwGqmInY1EjIesmabqgICAtUGly16y2DlTyznEvrovt0x2FsMmG2PwZBXDK+egulnzO1ByNGdXpSHpOQ7j46TWFQEulbU8Gx10N8XzCDHZ3UTgWWofFtrcnliS5s8YbenRmxzvBg4PkOlqfZ/JXU9WSw+lclygyX9VsB//d8wmRcmZG9I5idBnFY2pQhoMW3U2waPMFABL8G/qLflbt6DwVvgyKz7fcs+eFXUVe2pgtykJb+jy7zvebP/QE0MV07S3/tCIuzioE/P6rNB0SwYsr8fusMt1xSqe6vm+lqd0fiPdV0eHlkaS0Vy/dRBnAPrfvCJ3Xg4Xx+YXLs9700Qxbxx4VI++ms3sF3+8ctTLyC1iv0Tcan5LZzeU94pwyoLLh1xaXP1Bg2PL9+TCvS79nuUxmBwVm3ebViCU8Fg/3Pi1fpKLTrw5+mn5RZCS4kdBPUfqWmkkux+h5l4fVFObviV6Bb9KRrV6f1GCZQY/DjPinFMQZHgIV8pkSJdWC+eT90PUvHczvhNcX/tj89uUv8FwyrgLWORUsZDPsgK+GdiJ2/jBx5IFpQAyUXcYzWiZpY7qxcrwuZQdK9z60rb/I1p8bbq5ys5YJWRfS4TZpFbyEDRemOY7t6H+P5+6gOxWhzJHce24MsefanhogKrAgNhvgb3zoYVd4TqOveDVzAR49kX84aI8hrhxXPP13XBOhfEK0RRQdeMjoOY/4EpygCNVTtROosvET7bsgF2Rd4imlfawQay t13MTI9z 2su1L1qy8Rpuz9H9MIt7lMFTyThn+PSWNQdXsn1NNzLewKqOHg+G3GBeU7EvUVzbPTXq4GhKbI51qwnurtReX5U60roM8jo8e9QJM3hnoLmE20WHoDrn+0ATH0MQZHCAtmsp36Ro37wJ9BvkK8zyqCyYh2KKmWFpubpsopvUzu7k0Szfa9nRpWVyoXNCbMOBuNHcOqczEaOZsfnaBR5Q9JoZ4GAazA1yrsW1Qnul0iAOCuyfJS9kYpIf+4LYD/BIuUUUbPsE8FIipggAAv0abeZi5KuqddS+8tlRwiUAwDdf5nNAChLgRO0EtzYO7BDqkAl7lv79h++RlGP77qjsKengc8D0LLMbd1Mt3lIdyBreHayY= 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. For openrisc, the current ioremap() and iounmap() are the same as generic version. After taking GENERIC_IOREMAP way, the old ioremap() and iounmap() can be completely removed. Signed-off-by: Baoquan He Reviewed-by: Christoph Hellwig Reviewed-by: Mike Rapoport (IBM) Cc: Stafford Horne Cc: Jonas Bonn Cc: Stefan Kristiansson Cc: openrisc@lists.librecores.org Acked-by: Stafford Horne --- arch/openrisc/Kconfig | 1 + arch/openrisc/include/asm/io.h | 11 ++++---- arch/openrisc/mm/ioremap.c | 49 ---------------------------------- 3 files changed, 7 insertions(+), 54 deletions(-) diff --git a/arch/openrisc/Kconfig b/arch/openrisc/Kconfig index c7f282f60f64..fd9bb76a610b 100644 --- a/arch/openrisc/Kconfig +++ b/arch/openrisc/Kconfig @@ -21,6 +21,7 @@ config OPENRISC select GENERIC_IRQ_PROBE select GENERIC_IRQ_SHOW select GENERIC_PCI_IOMAP + select GENERIC_IOREMAP select GENERIC_CPU_DEVICES select HAVE_PCI select HAVE_UID16 diff --git a/arch/openrisc/include/asm/io.h b/arch/openrisc/include/asm/io.h index ee6043a03173..5a6f0f16a5ce 100644 --- a/arch/openrisc/include/asm/io.h +++ b/arch/openrisc/include/asm/io.h @@ -15,6 +15,8 @@ #define __ASM_OPENRISC_IO_H #include +#include +#include /* * PCI: We do not use IO ports in OpenRISC @@ -27,11 +29,10 @@ #define PIO_OFFSET 0 #define PIO_MASK 0 -#define ioremap ioremap -void __iomem *ioremap(phys_addr_t offset, unsigned long size); - -#define iounmap iounmap -extern void iounmap(volatile void __iomem *addr); +/* + * I/O memory mapping functions. + */ +#define _PAGE_IOREMAP (pgprot_val(PAGE_KERNEL) | _PAGE_CI) #include diff --git a/arch/openrisc/mm/ioremap.c b/arch/openrisc/mm/ioremap.c index cdbcc7e73684..91c8259d4b7e 100644 --- a/arch/openrisc/mm/ioremap.c +++ b/arch/openrisc/mm/ioremap.c @@ -22,55 +22,6 @@ extern int mem_init_done; -/* - * Remap an arbitrary physical address space into the kernel virtual - * address space. Needed when the kernel wants to access high addresses - * directly. - * - * NOTE! We need to allow non-page-aligned mappings too: we will obviously - * have to convert them into an offset in a page-aligned mapping, but the - * caller shouldn't need to know that small detail. - */ -void __iomem *__ref ioremap(phys_addr_t addr, unsigned long size) -{ - phys_addr_t p; - unsigned long v; - unsigned long offset, last_addr; - struct vm_struct *area = NULL; - - /* Don't allow wraparound or zero size */ - last_addr = addr + size - 1; - if (!size || last_addr < addr) - return NULL; - - /* - * Mappings have to be page-aligned - */ - offset = addr & ~PAGE_MASK; - p = addr & PAGE_MASK; - size = PAGE_ALIGN(last_addr + 1) - p; - - area = get_vm_area(size, VM_IOREMAP); - if (!area) - return NULL; - v = (unsigned long)area->addr; - - if (ioremap_page_range(v, v + size, p, - __pgprot(pgprot_val(PAGE_KERNEL) | _PAGE_CI))) { - vfree(area->addr); - return NULL; - } - - return (void __iomem *)(offset + (char *)v); -} -EXPORT_SYMBOL(ioremap); - -void iounmap(volatile void __iomem *addr) -{ - return vfree((void *)(PAGE_MASK & (unsigned long)addr)); -} -EXPORT_SYMBOL(iounmap); - /** * OK, this one's a bit tricky... ioremap can get called before memory is * initialized (early serial console does this) and will want to alloc a page From patchwork Tue Jun 20 13:13: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: 13285837 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 A8CBBEB64D7 for ; Tue, 20 Jun 2023 13:16:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 48FA28D0007; Tue, 20 Jun 2023 09:16:43 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 43FF88D0001; Tue, 20 Jun 2023 09:16:43 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 32EEB8D0007; Tue, 20 Jun 2023 09:16:43 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 265B68D0001 for ; Tue, 20 Jun 2023 09:16:43 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id D57CA140ED6 for ; Tue, 20 Jun 2023 13:16:42 +0000 (UTC) X-FDA: 80923175844.14.834AD72 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 6AC6F18001A for ; Tue, 20 Jun 2023 13:16:40 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Oit32PKU; spf=pass (imf16.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=1687267000; 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=6JfLBgWKCdyh6wjUYOWVMGPpT4CuCPxtIaQnHkOENe8=; b=1VZ27z4JvUc+PCyq5eey6LejGbXBjBszgdySkga/OZUbSxHVxj+55KaaXScDT44ynL+2JC hFvvgY6DXrRHIKQ56FO7X1oOEOcSwGWsXmUtoB1ZStpVARL4fdlM/NiY04O66IAIllf327 pCsS9+konRJo+XvR6pAagisu/uIuooc= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1687267000; a=rsa-sha256; cv=none; b=yS9uYtJ8qTd2ti1tovwgbZgABaCd92g9uGJsAashwCRhGwinJrwXcV96vh3xKe/cGKZodS DmF8Q8RgSDwPTNffZjH1D0rbTvPWpx28utoimdCVx8lYeRU+hnN3QXVj1CgADPD9zjMrKf t6/L3Qi33M+pQDg09A78CS/RpPfi/t4= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Oit32PKU; spf=pass (imf16.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687266999; 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=6JfLBgWKCdyh6wjUYOWVMGPpT4CuCPxtIaQnHkOENe8=; b=Oit32PKU9BbvxmDImd6e/KdS001VNjSBmyrrumNHj6SXonDtOn/aMQPovctYxiiKDUjCdy P0kPVegO07D+ZBLlIDWBJPaaASNZ+MhneM4KUcWLrPPyHmZr876BPA5M5w86Uj67Pzth3S bQTrQ6jpeL7MCZtlxifNCBZBoIELEew= 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-597-ext3m0EJMzyEfwIVkycz7Q-1; Tue, 20 Jun 2023 09:16:35 -0400 X-MC-Unique: ext3m0EJMzyEfwIVkycz7Q-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 8E29F185A7A8; Tue, 20 Jun 2023 13:15:44 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-166.pek2.redhat.com [10.72.12.166]) by smtp.corp.redhat.com (Postfix) with ESMTP id 690B2C1ED96; Tue, 20 Jun 2023 13:15:34 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-arch@vger.kernel.org, linux-mm@kvack.org, arnd@arndb.de, hch@lst.de, christophe.leroy@csgroup.eu, rppt@kernel.org, willy@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, David.Laight@ACULAB.COM, shorne@gmail.com, deller@gmx.de, nathan@kernel.org, glaubitz@physik.fu-berlin.de, Baoquan He , Gerald Schaefer , Heiko Carstens , Vasily Gorbik , Christian Borntraeger , Sven Schnelle , linux-s390@vger.kernel.org Subject: [PATCH v7 10/19] s390: mm: Convert to GENERIC_IOREMAP Date: Tue, 20 Jun 2023 21:13:47 +0800 Message-Id: <20230620131356.25440-11-bhe@redhat.com> In-Reply-To: <20230620131356.25440-1-bhe@redhat.com> References: <20230620131356.25440-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: 6AC6F18001A X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: c5jm3re8ebeb8p81btkyxeikkdmtr6nf X-HE-Tag: 1687267000-193199 X-HE-Meta: U2FsdGVkX199DL3YNeWiblQXlDv2lu/08ILfK+hDDbQEtwkf3mFomqzYAvdCNA/sNDp77udL8pERd52V7FI13t+QntT9dHm+WBaoE23OnBcl6ozEfjh9PS6KwOL5Yu9WLXJauqCADsGmGVTyoZdm+DcRBZ/hBVDXk6iKj8p5HuiD0bKTc64UuOh7vZjOKUaOzm5HmXpwL+jpBhIej8pcKJpGAVeyOxEPK3dG6M5aMdegt6AcoI4GE0f2QCCRv6LiZJhslfX/ENIBZaI4sukA7NHsGTC4PMcEA4MwZ25HcnlmXT0nqr9kI8fuYkIxY+kQAcGMKCQ4T7tCWp7DQ3wiHgxcodEBQ7zDD0krmp47wsG+C0DI6sFl/vR/oCDB+sHrvI5vH5ELTMVgHC7AlagFrz/rRVSIYTPJUKtlMUIpGiv+bIZ10VWu0P8c3ed4zLABDHzqQYZIr+lS5j7DO51+Ye9SfXWuWwDX4W3UPKUiPGREb3/5GhB6VZ90Motv+DD1Or+moMUa7wPL7vDmE0OeuSYLmUZEuOL4fR+A6fDytRfLg+5SXiSpggsZu92PvQEVHpJtnyW8iwzU6FTtXsVXFF4Ic91+RM21Hf+HS7Ad+Qv0pH958fTp4yUg3ctF1uc11yF+jn0i0l0Jnh3HJsmG8dCfVLGaUJkwO1ydJqOUbO9Jehg0ihKtYCOwBtPhqGZCqke9HbHEmu3g47u+E8u1pH5KM9v0nAM29bNJMXZkPfiKWpDOiUR4AZhe8Mck2u481hNvVd7KKvQjMOtlbk6QEVSUX7TjxumPX31VA/n+xXFLc2fyDaPTQQFb58XTbxt6+VUW0YoAgXX+1GrZ4Y2hF9EeXdCzcdbqXz0yUuC7fY8Q2ktUZTSmI5sdBh3r/GTKkH1fbCEnXvj5JOZJxJEzB57mP4n/36FxrDRV1VzDEcK3s8vMfunaETlZ60plIVJ/2yNMzI3bQoS+lFoafek 0ZWuvshf Pq54xIKQza4OUs5faV/KQgRrnh+hjSs/sJCP5ahtK0I7rmwaoxVMtyHKOzKPycyzjhtn5Bpm066QV5iNEY+4BI0VXdijxYdY6cJ4/B809GNNfnAqYhZy98MWVzr9wioA5JHls95cZlklxoCXjac7wo156Q7pkR9so9oY0XCbg2k314/ciLqhUieCwbn3MgCbBBCI8ha0faWYNXcakjy4v20G2MJYK6wKAIJKiZKXmSWkIXt1b+LC+VeqMd9BnErYAzoO6fCo/P4w4i+eDrM25SHUESvLyfpKq7/yAwJ9lbmn/8Z/Sbx7xiKyyZwOifl/a4mtw06/4miBb2s4= 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(). And also replace including with in arch/s390/kernel/perf_cpum_sf.c, otherwise building error will be seen because macro defined in can't be seen in perf_cpum_sf.c. Signed-off-by: Baoquan He Reviewed-by: Niklas Schnelle Tested-by: Niklas Schnelle Reviewed-by: Christoph Hellwig Reviewed-by: Mike Rapoport (IBM) Cc: Gerald Schaefer Cc: Heiko Carstens Cc: Vasily Gorbik Cc: Alexander Gordeev Cc: Christian Borntraeger Cc: Sven Schnelle Cc: linux-s390@vger.kernel.org --- v6->v7: - Fix building error reported by lkp test robot. https://lore.kernel.org/oe-kbuild-all/202306100105.8GHnoMCP-lkp@intel.com/ arch/s390/Kconfig | 1 + arch/s390/include/asm/io.h | 21 ++++++------ arch/s390/kernel/perf_cpum_sf.c | 2 +- arch/s390/pci/pci.c | 57 ++++++--------------------------- 4 files changed, 24 insertions(+), 57 deletions(-) diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig index 6dab9c1be508..e625bb0cc6c7 100644 --- a/arch/s390/Kconfig +++ b/arch/s390/Kconfig @@ -142,6 +142,7 @@ config S390 select GENERIC_SMP_IDLE_THREAD select GENERIC_TIME_VSYSCALL select GENERIC_VDSO_TIME_NS + select GENERIC_IOREMAP if PCI select HAVE_ALIGNED_STRUCT_PAGE if SLUB select HAVE_ARCH_AUDITSYSCALL select HAVE_ARCH_JUMP_LABEL diff --git a/arch/s390/include/asm/io.h b/arch/s390/include/asm/io.h index e3882b012bfa..4453ad7c11ac 100644 --- a/arch/s390/include/asm/io.h +++ b/arch/s390/include/asm/io.h @@ -22,11 +22,18 @@ void unxlate_dev_mem_ptr(phys_addr_t phys, void *addr); #define IO_SPACE_LIMIT 0 -void __iomem *ioremap_prot(phys_addr_t addr, size_t size, unsigned long prot); -void __iomem *ioremap(phys_addr_t addr, size_t size); -void __iomem *ioremap_wc(phys_addr_t addr, size_t size); -void __iomem *ioremap_wt(phys_addr_t addr, size_t size); -void iounmap(volatile void __iomem *addr); +/* + * I/O memory mapping functions. + */ +#define ioremap_prot ioremap_prot +#define iounmap iounmap + +#define _PAGE_IOREMAP pgprot_val(PAGE_KERNEL) + +#define ioremap_wc(addr, size) \ + ioremap_prot((addr), (size), pgprot_val(pgprot_writecombine(PAGE_KERNEL))) +#define ioremap_wt(addr, size) \ + ioremap_prot((addr), (size), pgprot_val(pgprot_writethrough(PAGE_KERNEL))) static inline void __iomem *ioport_map(unsigned long port, unsigned int nr) { @@ -51,10 +58,6 @@ static inline void ioport_unmap(void __iomem *p) #define pci_iomap_wc pci_iomap_wc #define pci_iomap_wc_range pci_iomap_wc_range -#define ioremap ioremap -#define ioremap_wt ioremap_wt -#define ioremap_wc ioremap_wc - #define memcpy_fromio(dst, src, count) zpci_memcpy_fromio(dst, src, count) #define memcpy_toio(dst, src, count) zpci_memcpy_toio(dst, src, count) #define memset_io(dst, val, count) zpci_memset_io(dst, val, count) diff --git a/arch/s390/kernel/perf_cpum_sf.c b/arch/s390/kernel/perf_cpum_sf.c index 7ef72f5ff52e..b0269f3881aa 100644 --- a/arch/s390/kernel/perf_cpum_sf.c +++ b/arch/s390/kernel/perf_cpum_sf.c @@ -22,7 +22,7 @@ #include #include #include -#include +#include /* Minimum number of sample-data-block-tables: * At least one table is required for the sampling buffer structure. diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c index afc3f33788da..d34d5813d006 100644 --- a/arch/s390/pci/pci.c +++ b/arch/s390/pci/pci.c @@ -244,62 +244,25 @@ void __iowrite64_copy(void __iomem *to, const void *from, size_t count) zpci_memcpy_toio(to, from, count); } -static void __iomem *__ioremap(phys_addr_t addr, size_t size, pgprot_t prot) +void __iomem *ioremap_prot(phys_addr_t phys_addr, size_t size, + unsigned long prot) { - unsigned long offset, vaddr; - struct vm_struct *area; - phys_addr_t last_addr; - - last_addr = addr + size - 1; - if (!size || last_addr < addr) - return NULL; - + /* + * When PCI MIO instructions are unavailable the "physical" address + * encodes a hint for accessing the PCI memory space it represents. + * Just pass it unchanged such that ioread/iowrite can decode it. + */ if (!static_branch_unlikely(&have_mio)) - return (void __iomem *) addr; + return (void __iomem *)phys_addr; - offset = addr & ~PAGE_MASK; - addr &= PAGE_MASK; - size = PAGE_ALIGN(size + offset); - area = get_vm_area(size, VM_IOREMAP); - if (!area) - return NULL; - - vaddr = (unsigned long) area->addr; - if (ioremap_page_range(vaddr, vaddr + size, addr, prot)) { - free_vm_area(area); - return NULL; - } - return (void __iomem *) ((unsigned long) area->addr + offset); -} - -void __iomem *ioremap_prot(phys_addr_t addr, size_t size, unsigned long prot) -{ - return __ioremap(addr, size, __pgprot(prot)); + return generic_ioremap_prot(phys_addr, size, __pgprot(prot)); } EXPORT_SYMBOL(ioremap_prot); -void __iomem *ioremap(phys_addr_t addr, size_t size) -{ - return __ioremap(addr, size, PAGE_KERNEL); -} -EXPORT_SYMBOL(ioremap); - -void __iomem *ioremap_wc(phys_addr_t addr, size_t size) -{ - return __ioremap(addr, size, pgprot_writecombine(PAGE_KERNEL)); -} -EXPORT_SYMBOL(ioremap_wc); - -void __iomem *ioremap_wt(phys_addr_t addr, size_t size) -{ - return __ioremap(addr, size, pgprot_writethrough(PAGE_KERNEL)); -} -EXPORT_SYMBOL(ioremap_wt); - void iounmap(volatile void __iomem *addr) { if (static_branch_likely(&have_mio)) - vunmap((__force void *) ((unsigned long) addr & PAGE_MASK)); + generic_iounmap(addr); } EXPORT_SYMBOL(iounmap); From patchwork Tue Jun 20 13:13:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13285838 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 88F33EB64DB for ; Tue, 20 Jun 2023 13:16:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 111308D000B; Tue, 20 Jun 2023 09:16:44 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E2B798D0001; Tue, 20 Jun 2023 09:16:43 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CA4D98D000B; Tue, 20 Jun 2023 09:16:43 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id B9DB08D0001 for ; Tue, 20 Jun 2023 09:16:43 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 8AC4416085C for ; Tue, 20 Jun 2023 13:16:43 +0000 (UTC) X-FDA: 80923175886.29.7C70C96 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 F26701C0023 for ; Tue, 20 Jun 2023 13:16:39 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Ssnj9dED; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf21.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=1687267000; 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=VZ/Dh6S9uhSGanp847Ckw34lDf4ceJX1gVAd67nEVDo=; b=skRUmCkM1XubmByevE6B8PK7OZoXQtlX3EDgmmocXrpn9agvYHQV0mhsBusU93BhoYr+Fp hZrZWAR2YVNFY27tnuaXRlhK1jAksdxwlkyXZWrVWecLTevXe+xMuD6+qYFWfpqZx07EZe HZ2K2Uaxr0Y6/IySSrVmOyLBRQysQ/0= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Ssnj9dED; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf21.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=1687267000; a=rsa-sha256; cv=none; b=F4QKE1doLfFgxDctvRkyDXKVxXxVr1gyGUp0f7ZQaxBIU0FFSmbj0eRdi0i6r59ZDWfZ9T Kg+LyF47tBp9xEJAfOtk3u+tsqC3G326yI+dgFmjJSKzM2nDufKLldCx9HqeQaKheCm/PX hgjVeuvGcZfCPkoGDFUGkLuNRRfSB2E= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687266999; 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=VZ/Dh6S9uhSGanp847Ckw34lDf4ceJX1gVAd67nEVDo=; b=Ssnj9dEDpiO32MpVJKn7m1aBgA15++2KxLlDabyeyT9dOB9FCu8UeEfWeexM5TfNlUKfXY oitwgJnclJ9EvM5cNvVa0AlOhzDEX4+GizK30x4aKXn/E1AT2MBsaJl7OhOM5gVC8o1gKF Y9YNWgdmF0KiJ3o0CSXPNoLR031ySR0= 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-131-H9U8zhlLOZ68Ze0TdGrliQ-1; Tue, 20 Jun 2023 09:16:31 -0400 X-MC-Unique: H9U8zhlLOZ68Ze0TdGrliQ-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 63255830F28; Tue, 20 Jun 2023 13:15:54 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-166.pek2.redhat.com [10.72.12.166]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5CA5CC1ED96; Tue, 20 Jun 2023 13:15:44 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-arch@vger.kernel.org, linux-mm@kvack.org, arnd@arndb.de, hch@lst.de, christophe.leroy@csgroup.eu, rppt@kernel.org, willy@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, David.Laight@ACULAB.COM, shorne@gmail.com, deller@gmx.de, nathan@kernel.org, glaubitz@physik.fu-berlin.de, Baoquan He , Yoshinori Sato , Rich Felker , linux-sh@vger.kernel.org Subject: [PATCH v7 11/19] sh: add including Date: Tue, 20 Jun 2023 21:13:48 +0800 Message-Id: <20230620131356.25440-12-bhe@redhat.com> In-Reply-To: <20230620131356.25440-1-bhe@redhat.com> References: <20230620131356.25440-1-bhe@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Rspamd-Queue-Id: F26701C0023 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: iewho7cq1h79dnfw56bpawqop15d6s1n X-HE-Tag: 1687266999-971956 X-HE-Meta: U2FsdGVkX19xSTBB6Ih5E2krJFPN08seEGYgbxQAsCwBXsW39sHTmOQmTZbz982xO3zcdu+/OJqRnhw7fjVV9JkxP8jhpTeAi0b2eeH5DVyhn3+pGNIK4kibkezXj0rNhdqHYNaIoRemDwPFpGPJUeNi790QDXOFBYChHSy3nGBJ8/g4MM2gpiStJPqia2wlU/WirkZiVnvi8Vgl6MKeUf7KhZylTeyl4bYu3gzVP2sxbYHiF4DUOjPGpOtyn46K4kR8bFZBFPMcxcnCzBhUxSDK+QTllmxeaCvqt/vnGtWBBOL9Jj5EF0Y6TtgjGz8R9l9ADe6eiacse3S3CjfjkUqeFfVzpAApW9YzYo1nd6b/NueAgKHOpeLEKBRVMteOuQEdZedqUTznrknCDuIDzorAKsOagUqVmtEMOv7ofPUcosqPJQ94SYzs9FIOrOkdoOwI/e1sqsofIlfjsI2RPgEI7vtC2LuRgSN9YHqCa5/ZBNaIzpKnn4tUmoEJbYjg2fQ0zZ7X1ufKR2N1F6SA0Bu/Gxh7J482PbMjCpKf5I7STOU11U/SPOQ++P+4wB+VPqgwvy/I/+ZTVDqPYRWftOC3Wxxmh25ufnCT/jvZS/b8xa9uQe0D0FCAUbNBIyk4COj7nKI8DFADbal7Tw++LtxO/8K13BTzQPO5+892lCvIPUwQwsfcaMfbu/js4s8YGVpN1jwthjdOwnzaAQTK25ssOnER8HbE/DuqEwwmRPh+xY53lk6k7azciNnVkFpwPWhNri2yV6utVb1sgUhV2Lb1ItP2O+RzZlx/vxd3tnm7RB9Fo6kbY1MygMsZoDJanz63N7Z3RDfTmjOwTGmReSxOJ9eXgJWYPh2xvC06iuAxxGZpphTQ8lhZCKPxF7uO46iuyD38MfuNFes1YIHUUpn1UQtfSdzJJzj8/f/a0Z0hGcErJlhtJDT9yhRX3/+rXg3/O0FZSKHa0aADpaD Q5loFXOH dyBexYCHa5SYzTljrtqsttkd7mNIvmdteSVgHNJ+EtMpJSLhrD2RiEOhK0sGGmgFeUQHWTA655CHCOpPs6Tsu5ztyRERO3gZIHh8iTMAKriA0gq1f1da51VGQo5JewZCuBzkZUXacMMyAoAewV8x8a/svcPqlNcKoe0HJD8PP2ztMguSJBZVQI2nRaM4FrM3u12e+jy+7cZQ3qJf2tJH0CZBOpe6ctSZQ1M7R3Yi7wTb8oCV1NB2BoTDJdqDmOUMCPEPiGW4ibFjLVu5SICMaKqC0eggGGsjGPy/WmyzhXtQ8aQk= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: In , it provides a generic implementation of all I/O accessors. For some port|mm io functions, SuperH has its own implementation in arch/sh/kernel/iomap.c and arch/sh/include/asm/io_noioport.h. These will conflict with those in and cause compiling error. Hence add macro definitions to ensure that the SuperH version of them will override the generic version. Signed-off-by: Baoquan He Cc: Yoshinori Sato Cc: Rich Felker Cc: linux-sh@vger.kernel.org --- arch/sh/include/asm/io.h | 25 +++++++++++++++++++++++++ arch/sh/include/asm/io_noioport.h | 7 +++++++ 2 files changed, 32 insertions(+) diff --git a/arch/sh/include/asm/io.h b/arch/sh/include/asm/io.h index fba90e670ed4..270e7952950c 100644 --- a/arch/sh/include/asm/io.h +++ b/arch/sh/include/asm/io.h @@ -119,6 +119,26 @@ void __raw_readsl(const void __iomem *addr, void *data, int longlen); __BUILD_MEMORY_STRING(__raw_, q, u64) +#define ioread8 ioread8 +#define ioread16 ioread16 +#define ioread16be ioread16be +#define ioread32 ioread32 +#define ioread32be ioread32be + +#define iowrite8 iowrite8 +#define iowrite16 iowrite16 +#define iowrite16be iowrite16be +#define iowrite32 iowrite32 +#define iowrite32be iowrite32be + +#define ioread8_rep ioread8_rep +#define ioread16_rep ioread16_rep +#define ioread32_rep ioread32_rep + +#define iowrite8_rep iowrite8_rep +#define iowrite16_rep iowrite16_rep +#define iowrite32_rep iowrite32_rep + #ifdef CONFIG_HAS_IOPORT_MAP /* @@ -225,6 +245,9 @@ __BUILD_IOPORT_STRING(q, u64) #define IO_SPACE_LIMIT 0xffffffff /* We really want to try and get these to memcpy etc */ +#define memset_io memset_io +#define memcpy_fromio memcpy_fromio +#define memcpy_toio memcpy_toio void memcpy_fromio(void *, const volatile void __iomem *, unsigned long); void memcpy_toio(volatile void __iomem *, const void *, unsigned long); void memset_io(volatile void __iomem *, int, unsigned long); @@ -287,6 +310,8 @@ static inline void iounmap(volatile void __iomem *addr) { } */ #define xlate_dev_mem_ptr(p) __va(p) +#include + #define ARCH_HAS_VALID_PHYS_ADDR_RANGE int valid_phys_addr_range(phys_addr_t addr, size_t size); int valid_mmap_phys_addr_range(unsigned long pfn, size_t size); diff --git a/arch/sh/include/asm/io_noioport.h b/arch/sh/include/asm/io_noioport.h index f7938fe0f911..5ba4116b4265 100644 --- a/arch/sh/include/asm/io_noioport.h +++ b/arch/sh/include/asm/io_noioport.h @@ -53,6 +53,13 @@ static inline void ioport_unmap(void __iomem *addr) #define outw_p(x, addr) outw((x), (addr)) #define outl_p(x, addr) outl((x), (addr)) +#define insb insb +#define insw insw +#define insl insl +#define outsb outsb +#define outsw outsw +#define outsl outsl + static inline void insb(unsigned long port, void *dst, unsigned long count) { BUG(); From patchwork Tue Jun 20 13:13:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13285841 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 C802DEB64DC for ; Tue, 20 Jun 2023 13:17:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 99DA38D0001; Tue, 20 Jun 2023 09:17:16 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 900128D000F; Tue, 20 Jun 2023 09:17:16 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 689C58D0001; Tue, 20 Jun 2023 09:17:16 -0400 (EDT) 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 52A518D000D for ; Tue, 20 Jun 2023 09:17:16 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 16375160F3C for ; Tue, 20 Jun 2023 13:17:16 +0000 (UTC) X-FDA: 80923177272.01.EDBEF0A Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf14.hostedemail.com (Postfix) with ESMTP id 172CF100012 for ; Tue, 20 Jun 2023 13:17:13 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=QQsTnsOy; spf=pass (imf14.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=1687267034; 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=BZDW/9l2SXpk3O4K9ggpnwprp0OjaYClAxIb9iSyrKo=; b=T+J7YQw5hw3EO75BSeEo0ED1QHbTKreCnOCsvmawrcgV5INDpTcwtMd5S+hXBQTdHe2+n4 yCtVWU0s6HIa+llCAiZXFZgMvqlRRUc3kFQIzJ+6oAiaGEuyGO7WkjyAuKUaFF5PmF/6v5 4Xa2YD4NxpXNwV7+gWkPv/I+MmLHv3Y= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1687267034; a=rsa-sha256; cv=none; b=d50x0dt03agiA4mqC11h0WLuoU2ce2YSsp/L5do/9RvN35/tXRRnjYIdp2LW6bq36DFM5C uvUeKbQ+5JJVttJidzErXXLUuJ5uNWELhDtwJm/sYABZs15PdIiNlp2ydTf0Tep6O+iHTy X24afAI0adeccMy1nIxP7CJEE3ZU5MU= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=QQsTnsOy; spf=pass (imf14.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687267033; 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=BZDW/9l2SXpk3O4K9ggpnwprp0OjaYClAxIb9iSyrKo=; b=QQsTnsOytuDz8GwU0gEhNDQdDqh+lNUtxM59d6J+SjT6VRh9XtA6eTBs8Iy6sdFSGzpC0Y 5+NUDnqqoHCq5vf5UZIpNDQgwboTM296lSfJ25b33m6vDApOGUCsZbmnTjTUC/8XdL4Sag 06CHrEiUBbsky2HKCeCen6ww4+7wRxE= 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-393-oaZkYfEhNpSZi9l2-OVjAg-1; Tue, 20 Jun 2023 09:17:09 -0400 X-MC-Unique: oaZkYfEhNpSZi9l2-OVjAg-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 3A9AD38470A6; Tue, 20 Jun 2023 13:16:04 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-166.pek2.redhat.com [10.72.12.166]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2E0FFC1ED97; Tue, 20 Jun 2023 13:15:54 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-arch@vger.kernel.org, linux-mm@kvack.org, arnd@arndb.de, hch@lst.de, christophe.leroy@csgroup.eu, rppt@kernel.org, willy@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, David.Laight@ACULAB.COM, shorne@gmail.com, deller@gmx.de, nathan@kernel.org, glaubitz@physik.fu-berlin.de, Baoquan He , Yoshinori Sato , Rich Felker , linux-sh@vger.kernel.org Subject: [PATCH v7 12/19] sh: mm: Convert to GENERIC_IOREMAP Date: Tue, 20 Jun 2023 21:13:49 +0800 Message-Id: <20230620131356.25440-13-bhe@redhat.com> In-Reply-To: <20230620131356.25440-1-bhe@redhat.com> References: <20230620131356.25440-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: 172CF100012 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: h9juieyb83q4xjnwtfjz6aggfa44817s X-HE-Tag: 1687267033-142862 X-HE-Meta: U2FsdGVkX1/qR/U+FoHxfZ7fdeXy5DBWpzwTgdcvrQgweBKBNF3g4nd5jW/8kgNHD+5e9x9PVvn1c4d0kuuyX6TqXj+CFa+0OUR70OMo1aX7+rJ+LztlSxaf2icQYx4NH6c+9NkVDyAEUQuK4S3osB7I3skFoWRcys8N5gvo9k/we4SbiHkq9usEi/O0iSlLUuimh2XjO5356pNfofXyu+Ly8dynW21LVUNDNRO4dA1BTLdLz5B/MyWfNziEif585QtcLlgM4X7BhpGJnKDM4ESKw4zgUBk/4L16FwlwdJso6bdJ/JBvVMCo36H8dfD1TcQEKhgr9GzIk3+brJMHvWRcv4cux+Fs8wex+ZDLKT7texOuJ27X1Ex/lVmdVinxDZ8Tva1cj2OFIjj+jXnOCpYPNY67NvUgagfSymGuKWb1ofzuOvN1G0xLyj177gbo2YuRCC+tWuB/AYGo3ko12W+zzwEZTHCWkxVsHeJjkDsDr7+3JbQl7/zR38Un0iMKh4Yz2M7ZoK3AFxKx4HzFOqYDUyeLGA+8WCEAWZR13U+IRTj01cvR+lYG+qUbeji6AuklXzPN7VCZ9a0xgKTIHEzHO53XEsP+uIIxW9f5qUxfKMBypaikkzCc4rOPS93jrumiiBlKI91zuqdhy3BiswaCQRq97nBBE9J4UyE4MswVwQ7D1PN9j+nTtdqoJLILFmKWHQsJVvM4LdDAFoAGU9UC3fBXrMuxpwc2Sx6XsKss417hvH77H9mpAsq7klhRwuOfikISOWg0NmG3dQhzh2cKwKLCuUkAbT112mvnGRJo+FWAGPzbALAYv3yc0yfxCWTpvjlTtKr5V/byEP29pXcHF3Eppftd3tssYuC43SmWc6atk3iAPDDrsOb8j66Ptus+ZpvqylF+GcZbfRkIIl0jYgnie849WPjmjtF+70O3BRZ79L2EtH0Ct69zrhKkSoWpBmXSbRWKpIyAYB4 wUfEknhY Ow7zvK9/Gg/0i+nLlj9yJ6DDgjNdsVKKPbzeSUmbn8MOGd+YmknXFpPTvxyln+TfQKV7ujinlbfheHqphSZOpuDhfU3D90Mx9KLghod7Ueb5Olv1HZDNIa9Qf59wmussl/atKlAho7ySv0ZrRlk8ywMPb9et4ynzbIYMRexZu7ZfWqpEdM9Fg4qmqyDm7GYe/ugyIMT70SMmuJldyyu/F80TmYA5lZilzKFJNPJyxnlzPwzMDAK6DjSRwECoSrbM5N8eNeGngcVf1Q0BLxbIcd0JEqoVq6cFoNymHRolxo5QDfEj7LIMyzRcz/UN2e3rgG/1iLY+Kv3sr3+D0q/ymfd3Q4A== 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(). 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 | 40 +++++-------------------- arch/sh/mm/ioremap.c | 65 +++++++--------------------------------- 3 files changed, 20 insertions(+), 86 deletions(-) diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig index 9652d367fc37..f326985e46e0 100644 --- a/arch/sh/Kconfig +++ b/arch/sh/Kconfig @@ -28,6 +28,7 @@ config SUPERH select GENERIC_SMP_IDLE_THREAD select GUP_GET_PXX_LOW_HIGH if X2TLB select HAS_IOPORT if HAS_IOPORT_MAP + select GENERIC_IOREMAP if MMU select HAVE_ARCH_AUDITSYSCALL select HAVE_ARCH_KGDB select HAVE_ARCH_SECCOMP_FILTER diff --git a/arch/sh/include/asm/io.h b/arch/sh/include/asm/io.h index 270e7952950c..b3a26b405c8d 100644 --- a/arch/sh/include/asm/io.h +++ b/arch/sh/include/asm/io.h @@ -266,40 +266,16 @@ unsigned long long poke_real_address_q(unsigned long long addr, #endif #ifdef CONFIG_MMU -void iounmap(void __iomem *addr); -void __iomem *__ioremap_caller(phys_addr_t offset, unsigned long size, - pgprot_t prot, void *caller); - -static inline void __iomem *ioremap(phys_addr_t offset, unsigned long size) -{ - return __ioremap_caller(offset, size, PAGE_KERNEL_NOCACHE, - __builtin_return_address(0)); -} - -static inline void __iomem * -ioremap_cache(phys_addr_t offset, unsigned long size) -{ - return __ioremap_caller(offset, size, PAGE_KERNEL, - __builtin_return_address(0)); -} -#define ioremap_cache ioremap_cache - -#ifdef CONFIG_HAVE_IOREMAP_PROT -static inline void __iomem *ioremap_prot(phys_addr_t offset, unsigned long size, - unsigned long flags) -{ - return __ioremap_caller(offset, size, __pgprot(flags), - __builtin_return_address(0)); -} -#endif /* CONFIG_HAVE_IOREMAP_PROT */ +/* + * I/O memory mapping functions. + */ +#define ioremap_prot ioremap_prot +#define iounmap iounmap -#else /* CONFIG_MMU */ -static inline void __iomem *ioremap(phys_addr_t offset, size_t size) -{ - return (void __iomem *)(unsigned long)offset; -} +#define _PAGE_IOREMAP pgprot_val(PAGE_KERNEL_NOCACHE) -static inline void iounmap(volatile void __iomem *addr) { } +#define ioremap_cache(addr, size) \ + ioremap_prot((addr), (size), pgprot_val(PAGE_KERNEL)) #endif /* CONFIG_MMU */ #define ioremap_uc ioremap diff --git a/arch/sh/mm/ioremap.c b/arch/sh/mm/ioremap.c index 21342581144d..c33b3daa4ad1 100644 --- a/arch/sh/mm/ioremap.c +++ b/arch/sh/mm/ioremap.c @@ -72,22 +72,11 @@ __ioremap_29bit(phys_addr_t offset, unsigned long size, pgprot_t prot) #define __ioremap_29bit(offset, size, prot) NULL #endif /* CONFIG_29BIT */ -/* - * Remap an arbitrary physical address space into the kernel virtual - * address space. Needed when the kernel wants to access high addresses - * directly. - * - * NOTE! We need to allow non-page-aligned mappings too: we will obviously - * have to convert them into an offset in a page-aligned mapping, but the - * caller shouldn't need to know that small detail. - */ -void __iomem * __ref -__ioremap_caller(phys_addr_t phys_addr, unsigned long size, - pgprot_t pgprot, void *caller) +void __iomem *ioremap_prot(phys_addr_t phys_addr, size_t size, + unsigned long prot) { - struct vm_struct *area; - unsigned long offset, last_addr, addr, orig_addr; void __iomem *mapped; + pgprot_t pgprot = __pgprot(prot); mapped = __ioremap_trapped(phys_addr, size); if (mapped) @@ -97,11 +86,6 @@ __ioremap_caller(phys_addr_t phys_addr, unsigned long size, if (mapped) return mapped; - /* Don't allow wraparound or zero size */ - last_addr = phys_addr + size - 1; - if (!size || last_addr < phys_addr) - return NULL; - /* * If we can't yet use the regular approach, go the fixmap route. */ @@ -112,34 +96,14 @@ __ioremap_caller(phys_addr_t phys_addr, unsigned long size, * First try to remap through the PMB. * PMB entries are all pre-faulted. */ - mapped = pmb_remap_caller(phys_addr, size, pgprot, caller); + mapped = pmb_remap_caller(phys_addr, size, pgprot, + __builtin_return_address(0)); if (mapped && !IS_ERR(mapped)) return mapped; - /* - * Mappings have to be page-aligned - */ - offset = phys_addr & ~PAGE_MASK; - phys_addr &= PAGE_MASK; - size = PAGE_ALIGN(last_addr+1) - phys_addr; - - /* - * Ok, go for it.. - */ - area = get_vm_area_caller(size, VM_IOREMAP, caller); - if (!area) - return NULL; - area->phys_addr = phys_addr; - orig_addr = addr = (unsigned long)area->addr; - - if (ioremap_page_range(addr, addr + size, phys_addr, pgprot)) { - vunmap((void *)orig_addr); - return NULL; - } - - return (void __iomem *)(offset + (char *)orig_addr); + return generic_ioremap_prot(phys_addr, size, pgprot); } -EXPORT_SYMBOL(__ioremap_caller); +EXPORT_SYMBOL(ioremap_prot); /* * Simple checks for non-translatable mappings. @@ -158,10 +122,9 @@ static inline int iomapping_nontranslatable(unsigned long offset) return 0; } -void iounmap(void __iomem *addr) +void iounmap(volatile void __iomem *addr) { unsigned long vaddr = (unsigned long __force)addr; - struct vm_struct *p; /* * Nothing to do if there is no translatable mapping. @@ -172,21 +135,15 @@ void iounmap(void __iomem *addr) /* * There's no VMA if it's from an early fixed mapping. */ - if (iounmap_fixed(addr) == 0) + if (iounmap_fixed((void __iomem *)addr) == 0) return; /* * If the PMB handled it, there's nothing else to do. */ - if (pmb_unmap(addr) == 0) + if (pmb_unmap((void __iomem *)addr) == 0) return; - p = remove_vm_area((void *)(vaddr & PAGE_MASK)); - if (!p) { - printk(KERN_ERR "%s: bad address %p\n", __func__, addr); - return; - } - - kfree(p); + generic_iounmap(addr); } EXPORT_SYMBOL(iounmap); From patchwork Tue Jun 20 13:13:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13285839 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 42EBDEB64D7 for ; Tue, 20 Jun 2023 13:16:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D42868D000C; Tue, 20 Jun 2023 09:16:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CF3168D0001; Tue, 20 Jun 2023 09:16:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B94718D000C; Tue, 20 Jun 2023 09:16:46 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id AAA5F8D0001 for ; Tue, 20 Jun 2023 09:16:46 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 73B25A0F3F for ; Tue, 20 Jun 2023 13:16:46 +0000 (UTC) X-FDA: 80923176012.17.0691D6A 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 98146160021 for ; Tue, 20 Jun 2023 13:16:44 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=AX9hz6ey; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf08.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=1687267004; a=rsa-sha256; cv=none; b=BWto91fFNu736Y6cK7z6iPVmRiHZm4uKboS3MT/iUEEONGPwyu6HkoySgk6E2InsJ50yNH XA1hQF0s7nZcyilZbrtiG+wp2RqftP6jKKIRFj6YUzf0sbOrtx0Tbagp+7cAjh6LM24NmK Yz/N+5xqUUwsAnIxhitTayiZPgT2kpY= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=AX9hz6ey; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf08.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=1687267004; 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=8xAEmv+klZL2q1puNU7BpopKMmAERiOcnE6W7aPMkiU=; b=zd7QrNF+ZrQamYBi142fq1nMRYytmpYaiLRQqqZBeTD594JI+fn77qNH1USNyKtYtK1kZJ ee0ptWsy18rZHCN/MFvuLx0tTuy8lCeKx/+8jVcLXut50PncJ/nrvHZo4xIqS6R6pnc9UE raLwfxv7wxV4LT/0gL5rSnkWpxuw8Bo= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687267004; 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=8xAEmv+klZL2q1puNU7BpopKMmAERiOcnE6W7aPMkiU=; b=AX9hz6eysv7sXs84ADjEL0Om6flUxaeWOdCsSrxM6J+YVXrzNudNG9ahFvQ5tstUvILwPx +Dq2Jy/tJVDf09Z1TpCqvbmeAMPHGrfqLXAO9W/X6cCovGgXjQtA9D/h4M7iPpKvQ1MGyd cAM/UjsaDc/3SIJdSCOz83bLyEJ4Zy4= 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-651-dyXzD6xnNfqy13qwCKG8WA-1; Tue, 20 Jun 2023 09:16:37 -0400 X-MC-Unique: dyXzD6xnNfqy13qwCKG8WA-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 C9B031C09062; Tue, 20 Jun 2023 13:16:13 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-166.pek2.redhat.com [10.72.12.166]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0BC13C1ED96; Tue, 20 Jun 2023 13:16:04 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-arch@vger.kernel.org, linux-mm@kvack.org, arnd@arndb.de, hch@lst.de, christophe.leroy@csgroup.eu, rppt@kernel.org, willy@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, David.Laight@ACULAB.COM, shorne@gmail.com, deller@gmx.de, nathan@kernel.org, glaubitz@physik.fu-berlin.de, Baoquan He , Chris Zankel , Max Filippov Subject: [PATCH v7 13/19] xtensa: mm: Convert to GENERIC_IOREMAP Date: Tue, 20 Jun 2023 21:13:50 +0800 Message-Id: <20230620131356.25440-14-bhe@redhat.com> In-Reply-To: <20230620131356.25440-1-bhe@redhat.com> References: <20230620131356.25440-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: rspam06 X-Rspamd-Queue-Id: 98146160021 X-Stat-Signature: 389or7fdjh83rhtud55o7rjtxsjbx1fy X-HE-Tag: 1687267004-491407 X-HE-Meta: U2FsdGVkX19T7VlEKQkIHFzV0vdUCm8Lsr6TLu0+cl8K2N6a9vGzgIjIpWqSfIL4+vfAu0EQYOY0AmnpYH5s34NE5VTZhL8LdgmpgnA/lN8EnXQQMXwLU+lVMBgVVGgDVuIb0VX1j2fgFxDt1p0saRgE6o8FGCdBSVpGKt5avB9l6d3Ze47rohZJa/4weVDGR7UpP6FaPbt33+rr3rJs4aWblXuaQNT/mo3yQJEkpHlf70s2IhyNDokW7MnPd9tPp3INasV+YXIa96Tx2BRo7Fqr7+4HXB4bR4LhG751CTxarYhcAvihAiPecenKLNrjfwyJMuH1xhdGslLbJu/Cn8/bPEIClQT3Sfmz32iswa+5sLw1PdOPbOAosKAKLjfJyZKlpdLsaU5HfgYKXYqWQud5xMp/nWpg36H9MkHaS6cRJdYcIHbNDinUUd9/RflTqU4LfDOy2cHJdGWztGAMIMdovHON3BGKcTL/45jMcCHXAiiWLa1cz/BdABxZ/RKvuaeCPnUmEVRFRd0LI/VuIflhc0MYn3XqiF7gLo9sujSmXy1pyu6+ZybA2GbsZOsRpSv1SCKF2VtP5avSOPT53Xd5KrCW3uksMYcdJVv5b0SjQgJBrHKHHlytz6MDZeKM4I79S1s9EMrIm9g6xdAjo4f28Vvl62gGHLNa5pzMyEzeR1LGkTAMxyTod601Yk7ZTfjJaqaj0patBHhTnPmCgpAymj83NUKdqJQDJI+zghWlwkc1TAECqSIXoh0HPnH3dDjA+9EW2wY/UVwjlCy1A+5mAM4D9A9GXW6+nrwPw9vN+ZVSI+6ZFN90G2H6wXivW0duzkYVabvpVhUtl7JhO/i5KqFBwSEoFbPOaIMlt7SXA136iXZ/TrZhbSyqjfv+1eRyoeD30jBHese6Kbd88RbtQVX5aJWvuY15bh0rPfkeTnFmVEpUq5Uf1R0hb9SYIAy1rG/A7DkN9JL7drk FRjlbehO +bOVwcvyDDWri9YsmWS55QVKshDMdbDXlk/iVIOSCf5SYIJCiG3AMjihNZDwUz7XHJ0IMnVidRTksms2lKVRvrRW8h1yqB6V4/yR/P/uw5b0sWdjuEF3jp1NcvxHrsqFP+uNZ0yJ/dcD661/cK+W5n7LhGuOwmUO++hgAlRIkBtz4Vszs1zlDqNId4lpGZj3ITE+hg8iMS6g1otZWjex9Rk44khrRPqfh2aAbC0tYgyo8XEKBg6suyC+U0eHhMqjc+FOYVRT+SUOSnleLjImS9mQhsXJPjlA9W6VtALIDsJ1WaOEzV75pJaN0dKkAgzP9NyDLz5fcVay+2+ezEN70R6rRIWiIYE0vQdM6igDncReihhs= 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 Reviewed-by: Christoph Hellwig Reviewed-by: Mike Rapoport (IBM) Cc: Chris Zankel Cc: Max Filippov --- arch/xtensa/Kconfig | 1 + arch/xtensa/include/asm/io.h | 32 ++++++++------------ arch/xtensa/mm/ioremap.c | 58 +++++++++--------------------------- 3 files changed, 27 insertions(+), 64 deletions(-) diff --git a/arch/xtensa/Kconfig b/arch/xtensa/Kconfig index 3c6e5471f025..474cbbff3e6c 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 Tue Jun 20 13:13:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13285840 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 D76E9EB64D8 for ; Tue, 20 Jun 2023 13:17:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 79C978D000E; Tue, 20 Jun 2023 09:17:16 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 725AE8D000D; Tue, 20 Jun 2023 09:17:16 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5EEBC8D000E; Tue, 20 Jun 2023 09:17:16 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 4FA708D0001 for ; Tue, 20 Jun 2023 09:17:16 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id CD2E380F17 for ; Tue, 20 Jun 2023 13:17:15 +0000 (UTC) X-FDA: 80923177230.29.9F4AA57 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 ED29BC0023 for ; Tue, 20 Jun 2023 13:17:12 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=BMOu+Rur; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf28.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=1687267033; 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=L73uxYO6/gwUk9UCAvwzC3MI9+cjvFVAXT1CVkWyq/Y=; b=kS8rnO36UX6ydb5i5GFmvYhuiAhEH3wAwwPKmsUj7NDDmiipVaLdu+QI8xdO7hQYcGIxnV pmTTYLmashxq6wzWSAvGC21yvNKXd8p+IDS+FCL00oHk4vkTIVlTIEJig1JkNhJdsGU5Yf JASQrmrm/uCbAdmXo1oPmknXPv+Zjl0= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=BMOu+Rur; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf28.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=1687267033; a=rsa-sha256; cv=none; b=JTlk/3tL7ZeKMEuXtCUzF1McFJ2b7KCWq9/afk4WeI8djBr/u/wAki3lKBcWFI7/wMEBQW W/SnlzTZeP/HrXHAzkaDfcbazyBZRvvvuwap6jzLKsD4hebYYflmCjQC/QoCs8HjcqoIBH HfHSw1bZ1Y5IrfGPpxLuXf3p1/s3NNw= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687267032; 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=L73uxYO6/gwUk9UCAvwzC3MI9+cjvFVAXT1CVkWyq/Y=; b=BMOu+Rur1axQWspemMiScoLzvyoke7RmM88LSOoBuPOP+oIWyIRXpdcctWxI85ZpGQLnVE uaXjuxR7RT7nrL9xg4QWDBaOvCsnRhJS/XIQRPhw1n40cAZmzSH8HTx4ntNmuBHPlJe9HS kkQs1ZQQJzVHalq0HG1tqUwime0eOxg= 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-638-FRnLt72yPKKHm7OpzzusiQ-1; Tue, 20 Jun 2023 09:17:06 -0400 X-MC-Unique: FRnLt72yPKKHm7OpzzusiQ-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 773E28870E9; Tue, 20 Jun 2023 13:16:23 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-166.pek2.redhat.com [10.72.12.166]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8B9FBC1ED96; Tue, 20 Jun 2023 13:16:14 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-arch@vger.kernel.org, linux-mm@kvack.org, arnd@arndb.de, hch@lst.de, christophe.leroy@csgroup.eu, rppt@kernel.org, willy@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, David.Laight@ACULAB.COM, shorne@gmail.com, deller@gmx.de, nathan@kernel.org, glaubitz@physik.fu-berlin.de, Baoquan He , "James E.J. Bottomley" , linux-parisc@vger.kernel.org Subject: [PATCH v7 14/19] parisc: mm: Convert to GENERIC_IOREMAP Date: Tue, 20 Jun 2023 21:13:51 +0800 Message-Id: <20230620131356.25440-15-bhe@redhat.com> In-Reply-To: <20230620131356.25440-1-bhe@redhat.com> References: <20230620131356.25440-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-Stat-Signature: bybp1h6mefq3sdmwkqitxk5uqiqc75n5 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: ED29BC0023 X-HE-Tag: 1687267032-627270 X-HE-Meta: U2FsdGVkX19YKKYSP4yKnjikPAdIcVjD7jAcw3SBNmd3CBr3kNp+Og88vr3xAwaiJ8v5IhuEDXP+ViHoWMEWiTnL9nfIt6svHAFF6ZDJ4YTuRoP/QUJ1lu3gWtxwFw0c8wMDvagHiZEqOmWevVtRcCl3WHVGqhIw0IrTTM4NI2nAp2wNlUD7zVyoQT8Bz/wNodZvPI1QaQewZWNLQLQWt1idCJWdkTWL8B8DfTU0J0GrJ1JJL7Tu2yjyivtMUmrB8/+3tz6iJ2ACUbDoSoq7GeYVEiEAk6QYzTnmFjys0neJVsaWsbdN03ZDLpwffN7qXdYl5imG+UgJX0JRxu4WHYP6G2PQe7BKVyJfwCErySerunclY2GgGJAySCPl2aQcVn3UJCmbFsupriYNNaKMURq9RyR5S3XiSJfEIF1spUcFzHkh3FJzQEq9zTauFFgHk3rK+FYcQijSblYUKn8GgpWiQdIMGeonuzAxb9h2GFc758Y6ytkQOWfFTrVwJk2iNo9qjJS4E/Z6n7Xc2t5lcl1US3qrz2dCuP8r4ATtnSwGo2O4IExGk0aBKtwkDK6B1SKzb65AhhbGMHUR1bclaKibB/jX2jRnfOLR5XU6e948O7YM+fk/bEmu9/CPJ18HrUwIh4T4+S8qXh2ywXY7tEEXCKz6RXxhRcjfvll98+BUPCaYaVEj9TSJtSfzhT4JEtjZKUehEXEoVBxa2/au0snmYk8YzYGmxyj0ZyIZGjhQ0mkYoWnAZhpYtlYgX2Mj63uBlvmQwxlqWNDvB3yu35znEDCFIM0JXV3ce67Ct3F2jr7gzqmjCRWsOOUOWVdNMlfq3EQPuccy0F87tMMIfTG4QoiS8rkXCiVeryNqHz84AgzdgipeQ8cO0UQd0Y391YpuzgyXZieJun+h1kCZFvsTXvL5bpq8WO7F0KJVvhR+ZD9gJg8JTxr1JwyXro/IE5Lz+qISn+VwzDEp3VM KmOUejUC 2l1vQg1f+M8P/uDzh7Cef98iWzDDAMhEFum9bwTLO0dxLAjpIuodQ3F1OSDV7qJtcRzZlAIhnQIStx0fCzgQRm7erSB+pvvVgjxwNeA1c4FVQYlHxgvGyUq86MfG+MviJaRck13Vxrwwndy4/+TR1ae7UE7neN5gpW5fYKwjw2fSv67QtrS7ZNDr3UKtRobkJYIuxuyPhtkPaD01HYudVlKZAZl2dqpx924zftaueEdgRWhxRMSnvywXp3RM9pJnOolUN9PzuYfWhFaCwGzztYHfEW3d+HM7b3lDLbBTWwk5UEZJAGfYBmqKqXkeIXDGPiMrxFesImvAyC5p0PJ17pKkFNg== 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 Reviewed-by: Christoph Hellwig Reviewed-by: Mike Rapoport (IBM) Acked-by: Helge Deller Cc: "James E.J. Bottomley" Cc: Helge Deller Cc: linux-parisc@vger.kernel.org --- arch/parisc/Kconfig | 1 + arch/parisc/include/asm/io.h | 15 ++++++--- arch/parisc/mm/ioremap.c | 62 +++--------------------------------- 3 files changed, 15 insertions(+), 63 deletions(-) diff --git a/arch/parisc/Kconfig b/arch/parisc/Kconfig index 967bde65dd0e..315cc42b1a2c 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 Tue Jun 20 13:13:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13285843 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 F190AEB64D7 for ; Tue, 20 Jun 2023 13:17:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7EC548D0010; Tue, 20 Jun 2023 09:17:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 79BBA8D000D; Tue, 20 Jun 2023 09:17:32 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 68A3B8D0010; Tue, 20 Jun 2023 09:17:32 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 5AA6A8D000D for ; Tue, 20 Jun 2023 09:17:32 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 024ECC0F4F for ; Tue, 20 Jun 2023 13:17:31 +0000 (UTC) X-FDA: 80923177944.01.8681B28 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf23.hostedemail.com (Postfix) with ESMTP id D887E140017 for ; Tue, 20 Jun 2023 13:17:29 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=FSlUh4XI; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf23.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=1687267049; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=SboB+Gem+bQaB39EZZBPE5ZHPttNaa4nwbopj4kdit4=; b=O+pYF01GHYKFjlhfOilecO4nT8QJIsYtOQU4ovbaxBm1W/1LaTtNMUHf77YQ7tNE0keYBP Np6Hp70FjJq2q5h2Scukwdky8GstlhdmNiCEBywnEEngRkHY/Lw+Boqa5vTB6KYHMhUcJ+ pU7u7Jh1Ta+cL6stigUjAxfyp4Dg/X0= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=FSlUh4XI; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf23.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=1687267049; a=rsa-sha256; cv=none; b=cucKLplKun4ip/vO3fDJ7LiMoBH2Jw75qeE0S6EkXkoVSwvOoNhbqDNoZBmryBE/3p1uBV pMwPwMcACHN02EvymKoI/RujKlj6XXknrFB0TO15bSbuQ/XC7kqHI20Np47a9gSjfzebEh 5IlSy5H/l4Ag6/rpI9roCLw/4gaXLn8= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687267049; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SboB+Gem+bQaB39EZZBPE5ZHPttNaa4nwbopj4kdit4=; b=FSlUh4XI2jCzLAdmiFZd5MFYh1HKg9KqdY16nPc6zrQyuBCtVfpzjabzIv1UF4OL3AFv2h a3uMql1Z/gf0m5cQxmmVRAIRweGf4BYniR8BE6SOuMjGWbb66mMKjkYiAW7iHK+DG3udcE r37r1fidhQ2gXg8q1qOFtTeOdywFSiM= 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-438-SII62w3fOlOJtOu-TAuZBw-1; Tue, 20 Jun 2023 09:17:27 -0400 X-MC-Unique: SII62w3fOlOJtOu-TAuZBw-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 AC62A103963F; Tue, 20 Jun 2023 13:16:32 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-166.pek2.redhat.com [10.72.12.166]) by smtp.corp.redhat.com (Postfix) with ESMTP id 47129C1ED96; Tue, 20 Jun 2023 13:16: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, hch@lst.de, christophe.leroy@csgroup.eu, rppt@kernel.org, willy@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, David.Laight@ACULAB.COM, shorne@gmail.com, deller@gmx.de, nathan@kernel.org, glaubitz@physik.fu-berlin.de, Baoquan He Subject: [PATCH v7 15/19] mm/ioremap: Consider IOREMAP space in generic ioremap Date: Tue, 20 Jun 2023 21:13:52 +0800 Message-Id: <20230620131356.25440-16-bhe@redhat.com> In-Reply-To: <20230620131356.25440-1-bhe@redhat.com> References: <20230620131356.25440-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: D887E140017 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: nrkyom6pp8ioc45b4waptjmt8er6qjnz X-HE-Tag: 1687267049-928786 X-HE-Meta: U2FsdGVkX19vZO7952OXy6DeddbW2VB912QrphB9P077pHraSULFrCdHufAVjDUsW49tq9OGkGCZvwAwBZgcqzyCNIOb3lEH1SkuywYUpkh7ws2ujD1fJaPdf9XHcIp3Q639SU7ZwYH2dgmuUjkWX2R7ZUFKcl44YRPLyHp1HhCQCsCAOzrcETKrkgH2MN2qcP9RN67Lgwp16GgTPEvfOWXzjeWx8h1MuPHo/Nn2tikiTQj6nQpEyhOC4O3wFc9oz3PKxKx3KsGKCRh5KR8XlWVa9y/TPelxjKnz61bVsV508JEUkZ6rpYvEWgkZ4GlVQ6oQEfamSOp3N8BPvNj3rB1gyk2yBXrFbnL2oq3HyCr05MuEA5ZZTessmQoCVe7mRf6Z3jOKv9ugCKkA012PFl5Kkl60n7lwh7dhOzC1thAgoX96SNN3H+t+KL3aF5eAN8OFuVRcx6aOi3X3wvDDw32u9rcHUBgtZ1hon1KNCCsDnWdDZo1tsS5qw7gH1Dl2GKrvQwX9AOX9XzCrgV8XjtYwAAhK3NbXtRJWlcFW5mTGJLZMywSHGETSB31VdJao92gSW72Nf0pPo8H/HsbnnUPMkjnPxj2VElX5W153muzby/HMBjH8vubL3M6aYaAj1TZkib9TNthZIBTKXzY4Kg/ZgzB6I4nymX8P/YynoJUL4ERZgrgLEjljunMFZQFuQSFLARATZAy7XedDHlriOW9llZArMGAbIYyBa3rFzBSwMzUwetSu0mxEHTIzCSoAmUh7y6Ts2bxh5bPlagjSHgJsAzdZA3MNhBN3isUCmWDvbIMFpuM+1GrwnY89TQLiYXtSLTdtLItYCe8HDUSNgcU6DHQ0Mk30+eb8SAI2nTJO6uq5ifc2s7sc9/3y4GDSOFF12mK+wKa9N47mQ6B3/ZuDOHOHRRu1LIsl2/J0+OGtUrfz0eaTO/dkOiwzpANmePIGc6sLoraIwCoEe8z dSul6O2z +shckDlu75E0ajMxEwUN9VtEbInK1CEwx/EDlwfgTEqewo3R/GmYDcwABh46HFv++D3j2odfyGaHLCCRbJaG6KcvwnhVDfyADS+xFolCIeMAo6udD506G/NF6FCwoFogIBTOcp0YyZv0VG/CHOxmwBPowLVjiWRLH0Rmqh5trDyzc61juQgC9EvPPqtLK5AksDbwyH8Ij8FAbbkciavSjbt4nUyRsVinA/EMK0OQnpNqQOhs= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Christophe Leroy Architectures like powerpc have a dedicated space for IOREMAP mappings. If so, use it in generic_ioremap_prot(). Signed-off-by: Christophe Leroy Signed-off-by: Baoquan He Reviewed-by: Christoph Hellwig --- mm/ioremap.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/mm/ioremap.c b/mm/ioremap.c index 86b82ec27d2b..68d9895144ad 100644 --- a/mm/ioremap.c +++ b/mm/ioremap.c @@ -11,6 +11,15 @@ #include #include +/* + * Ioremap often, but not always uses the generic vmalloc area. E.g on + * Power ARCH, it could have different ioremap space. + */ +#ifndef IOREMAP_START +#define IOREMAP_START VMALLOC_START +#define IOREMAP_END VMALLOC_END +#endif + void __iomem *generic_ioremap_prot(phys_addr_t phys_addr, size_t size, pgprot_t prot) { @@ -35,8 +44,8 @@ void __iomem *generic_ioremap_prot(phys_addr_t phys_addr, size_t size, if (!ioremap_allowed(phys_addr, size, pgprot_val(prot))) return NULL; - area = get_vm_area_caller(size, VM_IOREMAP, - __builtin_return_address(0)); + area = __get_vm_area_caller(size, VM_IOREMAP, IOREMAP_START, + IOREMAP_END, __builtin_return_address(0)); if (!area) return NULL; vaddr = (unsigned long)area->addr; @@ -66,7 +75,7 @@ void generic_iounmap(volatile void __iomem *addr) if (!iounmap_allowed(vaddr)) return; - if (is_vmalloc_addr(vaddr)) + if (is_ioremap_addr(vaddr)) vunmap(vaddr); } From patchwork Tue Jun 20 13:13:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13285842 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 14A6DEB64D8 for ; Tue, 20 Jun 2023 13:17:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AD1768D000F; Tue, 20 Jun 2023 09:17:30 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A810C8D000D; Tue, 20 Jun 2023 09:17:30 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 949538D000F; Tue, 20 Jun 2023 09:17:30 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 84DE78D000D for ; Tue, 20 Jun 2023 09:17:30 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 4167F40F6C for ; Tue, 20 Jun 2023 13:17:30 +0000 (UTC) X-FDA: 80923177860.16.813F532 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 3CB9D80020 for ; Tue, 20 Jun 2023 13:17:27 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=DlFFxV1R; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf30.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=1687267048; a=rsa-sha256; cv=none; b=SQWSIRdzJl8vklRMCW5HWH5iDAny61bXejT4DkPWnM1f8gXVN7RYTuH7mqtDsdUm2QIvlV NWS/JMM9pLi2bMbb9nICESmbN7HlukcDJOxVDPRM7xcVXcdHJgLk4jMexrajXRMCrCcw67 T+L1CasySTN4bmFFT+NhxBW0t705rgM= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=DlFFxV1R; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf30.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=1687267048; 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=a8YWy6B/dkgubJEAfONkbnYrM9N6ISZoYICTMz8lkkw=; b=axWs/0b76ahC+x3q1zKTo9OrteUAxQbY6HFdexvdq8M6XuSG8Y/5BSo6R9JzJjx2EdxIHp uJEQ1oNjt/ID7zo6i2b0JOAWh7z82KmF+SfOMqbwzqs62f2Xf3vm9/WpCsQQ9g+UiLw5A5 o5l/BE2L3Wgopc5+rIo+FODlwvm+6Ys= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687267046; 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=a8YWy6B/dkgubJEAfONkbnYrM9N6ISZoYICTMz8lkkw=; b=DlFFxV1RZcoZJ4Zo4mFluvMo4xj6hLdMAnRdnoaXDQwpemSDAcgS1oN15AbxU8lo9TzTnA kpF8kU4TGynqoONx2Z7WIsEK/22iGElAPVTZowV6SjPotPsb882D3TO9dsNJS0fxgOrYtD ZX/b0lqIfBXUG8Gb8F2Ub2SIiqjzCfo= 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-445-ez00HCYEMsyDPHbeiCsRCQ-1; Tue, 20 Jun 2023 09:17:24 -0400 X-MC-Unique: ez00HCYEMsyDPHbeiCsRCQ-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 729AE1039D34; Tue, 20 Jun 2023 13:16:42 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-166.pek2.redhat.com [10.72.12.166]) by smtp.corp.redhat.com (Postfix) with ESMTP id 906A4C1ED96; Tue, 20 Jun 2023 13:16: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, hch@lst.de, christophe.leroy@csgroup.eu, rppt@kernel.org, willy@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, David.Laight@ACULAB.COM, shorne@gmail.com, deller@gmx.de, nathan@kernel.org, glaubitz@physik.fu-berlin.de, Baoquan He Subject: [PATCH v7 16/19] mm: move is_ioremap_addr() into new header file Date: Tue, 20 Jun 2023 21:13:53 +0800 Message-Id: <20230620131356.25440-17-bhe@redhat.com> In-Reply-To: <20230620131356.25440-1-bhe@redhat.com> References: <20230620131356.25440-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: rspam06 X-Rspamd-Queue-Id: 3CB9D80020 X-Stat-Signature: 4q13k9z6x9mufm8do4ya4z66kk97kbuf X-HE-Tag: 1687267047-816811 X-HE-Meta: U2FsdGVkX1/wEWuNuXDPPYHdOuSUYO6rLqQcwFU4Hl+arjkdLrVaU46V9hXADJbXDRc/miKVD0A3MG2JC/4k8PjTi9BX8m411Bh08kZWmTPYbQTygw7/s1f/iN76g2pWGEcci1KWldIA+aSBkdtC8VjnFZBFmCuc7ATL2sUZbquRyCBbDPUAURnmDEueXn6eXCWkgx2co8XOVBaQ1J0OB9/0HjIVITqRjMRlAeVFEJcGhjSpdCliecrGD3tu+rwueoOyncSetkiFLUJ15+zX3ShU8YqKhoyz3FV4uS1x/OKWAXB6TlutGrIXDF0xTVbyi4SHsklQDx+NvNNwZVFu7Vo6M5FELRo4jLXhCDpp7MJ7ycycj+fgQaz4iMyiX4BftOqw3e+vJeyi1/HTl+94tspGTLwruUIr09wBT0Re05K9tVVcg8NGSSOeFaeOY5jdgnYrIiy03xNprLwCpbnSlTVYNSiDjhEobHCArpTaiqSuw7X8OV7jQpEXerQR5xvQUCRhHctcZutUvsGriiZXeqQQqmRyiSFT2ZGL3/roUsaK6qv5wNQ9htD8hLs4arTE/wYpTGcOaa5Y5zodmnW5QAPQQOcbm3UVj0VcjLR9+cIuZk/F9kJpCCfJd2N6uGiASmsJdoRs1UiiUm2gBmFpEAXWBJwk0iGtsTE6N85aT4GC/bGriC5IR5rzYkfsWftGwBOjaPh+iPvmOX6eQ3VUc6HORpMzeWkak1fD+8hp+w0T10gDziPHKLDQ86qo5VaPknSkhTXMuHOWe4KZJ5/wPfTLUH9gslBAldJxMx2g9brucJzRKOVe8NRgi7yOqLqn1fZ5c47IDIQdKKAwVdtdNG4Fjz5jPEaY8i8+0cCVgj2RZkSAHwQRNnk4QoE5Fyu+9w9jMWLnpH0QuQwQA28d4EDk+7zKajpiSGUshMqlyyeyr69gCw0L2CbccMXNEdpHDRR2mpEYWFQ+zk66b+Q MUcbvMJl 7rJdUIQGsdP6b+aK9+gJJt7KPvOIksgNIDW5YLG9cy6KDnXxE714J0tASQcggSonSiQxNjynqCBoVktkiIDNvgoDc2ILcOC0k0LEBCYDnRAkMqIsbROW+p1yTDjn2T5LmgkhYjWIYps8aLeJsvrnjbJu73IvKQd2/RHiGpGCyhIOV6VPxpgt+H6M1Tsp0OZeqE3MiaUXFnB/qivAENwtgtZG4/dPLXBdmrHCu X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Now is_ioremap_addr() is only used in kernel/iomem.c and gonna be used in mm/ioremap.c. Move it into its own new header file linux/ioremap.h. Signed-off-by: Baoquan He Suggested-by: Christoph Hellwig Reviewed-by: Christoph Hellwig --- arch/powerpc/include/asm/pgtable.h | 8 -------- include/linux/ioremap.h | 30 ++++++++++++++++++++++++++++++ include/linux/mm.h | 5 ----- kernel/iomem.c | 1 + mm/ioremap.c | 10 +--------- 5 files changed, 32 insertions(+), 22 deletions(-) create mode 100644 include/linux/ioremap.h diff --git a/arch/powerpc/include/asm/pgtable.h b/arch/powerpc/include/asm/pgtable.h index 9972626ddaf6..d252323a753f 100644 --- a/arch/powerpc/include/asm/pgtable.h +++ b/arch/powerpc/include/asm/pgtable.h @@ -158,14 +158,6 @@ static inline pgtable_t pmd_pgtable(pmd_t pmd) } #ifdef CONFIG_PPC64 -#define is_ioremap_addr is_ioremap_addr -static inline bool is_ioremap_addr(const void *x) -{ - unsigned long addr = (unsigned long)x; - - return addr >= IOREMAP_BASE && addr < IOREMAP_END; -} - struct seq_file; void arch_report_meminfo(struct seq_file *m); #endif /* CONFIG_PPC64 */ diff --git a/include/linux/ioremap.h b/include/linux/ioremap.h new file mode 100644 index 000000000000..f0e99fc7dd8b --- /dev/null +++ b/include/linux/ioremap.h @@ -0,0 +1,30 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _LINUX_IOREMAP_H +#define _LINUX_IOREMAP_H + +#include +#include + +#if defined(CONFIG_HAS_IOMEM) || defined(CONFIG_GENERIC_IOREMAP) +/* + * Ioremap often, but not always uses the generic vmalloc area. E.g on + * Power ARCH, it could have different ioremap space. + */ +#ifndef IOREMAP_START +#define IOREMAP_START VMALLOC_START +#define IOREMAP_END VMALLOC_END +#endif +static inline bool is_ioremap_addr(const void *x) +{ + unsigned long addr = (unsigned long)kasan_reset_tag(x); + + return addr >= IOREMAP_START && addr < IOREMAP_END; +} +#else +static inline bool is_ioremap_addr(const void *x) +{ + return false; +} +#endif + +#endif /* _LINUX_IOREMAP_H */ diff --git a/include/linux/mm.h b/include/linux/mm.h index 27ce77080c79..7379f19768b4 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -1041,11 +1041,6 @@ unsigned long vmalloc_to_pfn(const void *addr); * On nommu, vmalloc/vfree wrap through kmalloc/kfree directly, so there * is no special casing required. */ - -#ifndef is_ioremap_addr -#define is_ioremap_addr(x) is_vmalloc_addr(x) -#endif - #ifdef CONFIG_MMU extern bool is_vmalloc_addr(const void *x); extern int is_vmalloc_or_module_addr(const void *x); diff --git a/kernel/iomem.c b/kernel/iomem.c index 62c92e43aa0d..9682471e6471 100644 --- a/kernel/iomem.c +++ b/kernel/iomem.c @@ -3,6 +3,7 @@ #include #include #include +#include #ifndef ioremap_cache /* temporary while we convert existing ioremap_cache users to memremap */ diff --git a/mm/ioremap.c b/mm/ioremap.c index 68d9895144ad..a21a6c9fa5ab 100644 --- a/mm/ioremap.c +++ b/mm/ioremap.c @@ -10,15 +10,7 @@ #include #include #include - -/* - * Ioremap often, but not always uses the generic vmalloc area. E.g on - * Power ARCH, it could have different ioremap space. - */ -#ifndef IOREMAP_START -#define IOREMAP_START VMALLOC_START -#define IOREMAP_END VMALLOC_END -#endif +#include void __iomem *generic_ioremap_prot(phys_addr_t phys_addr, size_t size, pgprot_t prot) From patchwork Tue Jun 20 13:13:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13285844 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 86768EB64DB for ; Tue, 20 Jun 2023 13:18:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 293688D000D; Tue, 20 Jun 2023 09:18:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 244198D000A; Tue, 20 Jun 2023 09:18:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 10C778D000D; Tue, 20 Jun 2023 09:18:05 -0400 (EDT) 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 02FE68D000A for ; Tue, 20 Jun 2023 09:18:05 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id A6C2B40F2B for ; Tue, 20 Jun 2023 13:18:04 +0000 (UTC) X-FDA: 80923179288.11.418B1F4 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf29.hostedemail.com (Postfix) with ESMTP id A7D04120013 for ; Tue, 20 Jun 2023 13:18:01 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=SHRCgk5m; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf29.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=1687267081; 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=mrr2cNyhDy3XHVdkhg3dGxWKYfHUscXJOX9H9m6IS1s=; b=x2sUaNNwCqsMasg/2AzDkqwqMP/JuqkQbmlNO68GmDZ6BG4WyajrV+pFvLJXyAnNcyjmrN 0OIN0+G3Drry+kcZ5PJZcRpOkNzxIgJBVmG/jrBfuO21eqgGXxzmReD4J0f3/mOqEWSuQP eNVIrzgf+d1Zo9ruigZK4mgH+mEvm1s= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=SHRCgk5m; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf29.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=1687267081; a=rsa-sha256; cv=none; b=kqph2CbGKNd3YYTMKwlLl/yqOKMJ3oXei6lqTXDxnHSSgQfY1W4zVlyFYObeCM16trhyaT A1qrtCVM98/gN8LaNkrfTC8axw7jJvyUxmoMRZ23Xa4hNpRuXIY9ku2Nn2Ih4Q9XTh1bE/ TiqYA82MLtIktich6iXAcGCFPz0WNxQ= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687267081; 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=mrr2cNyhDy3XHVdkhg3dGxWKYfHUscXJOX9H9m6IS1s=; b=SHRCgk5m+59pMpdEjWmZv8vj2Tp2kNcfoinei8xhWopLDd+cnc28hX4R7Nvs8pcRkmdQ7V /6h0TpFGfO6Qt20GqZxWQA6QDUradaB9uF/a4riEItWxXpDxSnBdKCZLnp65PJY9irKvRq uZZc/VUhbPKm+keGDxv11uxAOcASuOc= 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-100-cbsQdSbTO9iAyNHoribILg-1; Tue, 20 Jun 2023 09:17:52 -0400 X-MC-Unique: cbsQdSbTO9iAyNHoribILg-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 2CDB33C28C17; Tue, 20 Jun 2023 13:16:52 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-166.pek2.redhat.com [10.72.12.166]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5B052C1ED97; Tue, 20 Jun 2023 13:16:42 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-arch@vger.kernel.org, linux-mm@kvack.org, arnd@arndb.de, hch@lst.de, christophe.leroy@csgroup.eu, rppt@kernel.org, willy@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, David.Laight@ACULAB.COM, shorne@gmail.com, deller@gmx.de, nathan@kernel.org, glaubitz@physik.fu-berlin.de, Baoquan He , Michael Ellerman , Nicholas Piggin , linuxppc-dev@lists.ozlabs.org Subject: [PATCH v7 17/19] powerpc: mm: Convert to GENERIC_IOREMAP Date: Tue, 20 Jun 2023 21:13:54 +0800 Message-Id: <20230620131356.25440-18-bhe@redhat.com> In-Reply-To: <20230620131356.25440-1-bhe@redhat.com> References: <20230620131356.25440-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: A7D04120013 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: nmhgirgk3mpf1y6i5uatiidy16cn5i7t X-HE-Tag: 1687267081-899001 X-HE-Meta: U2FsdGVkX1+DmU1ACT8VqnO5FRy2hyq5kx6c91225nSCG/fYTWCEnnSDc8uoDpmRRcYM25tOQI6YnvmVFNw2zD5LxDVaS5qfKtnAO9CzSrneOd+oiPl1P0FNX2L3wxcvQz7UIrfSjb8B8KDAFgdJogjrwvDmOQH5Ob84Louuc7mZCZCECQQMZBXpe2mEkXolYhl4EWa1pZybuQw2Q9JwxgjoZZReXreI7s4jdXsCwcI+WbAybU+RcEPGrUgw0aLVVSwijG7Tsx1CfNoAxlLTlzHG5oXsfbSRY0yRUzYK02KHI9VdGpPGv7ixxB/mk8xiAqnmVqxgdw+xpYv1HDo7aiVqdUr2bLyh1GQKgmv1NnLMTiVy/MYScmtLBMw5+ed8mBnLRS/zB8wLScsmxxDIpUflg7k5X1wB2lPNM+jbyg6iQxCvKCA1NEWYL8raiMcJkLsEWULSrp39J6ZE+QVMNZVokR7UaMWWm2ZrZI3fXTNLbjNgdCvN2aTy9Z73cdzzOx0DEuvIi3EAgpEkjEVc3/UV7JCQv/FHL05aj5InC/iw0+jyc7VJYcC7urnVGCRLI8F0jL7Z0pl4pucb6PIDaGTnG2eI+0GoKnTOPyJxcNxDvCIGdVivakfHcp/6j+CKMo+HxzrHNueNBWuufSBO2BpBXxXX+GGB5hl43Pf6D+DOvbmFkVM2HX2F1q9s0m4XrOPPRyQw0NZAASHfmEdXnZ0fq3YivqIOniZV9OmPY0jQ8Mk5AI66mLxuAJmRRGozwYgjkhQG7l4fPQNhDDQWl0KluQfeShfAyosGTOWDEw/ULcdONBUI7XbLYqbQnIvHmC1c/t+U7VHNJpyX61l45CMRnmgudvf3l3RItalEX9gJCnfEo0UJt7jw98KbpFp8LjjMIV8KTScjU02M00DBP/CeIfp1CfaazHaii1sRiKJxR9ltxzvUrf4mhsi0XKRwVSB8429JVTfGzyf2FkA BILjdSy8 u3YU2YA6Z0BOJYSJwwqkhZIHjm+V7Ayu8zWArVuzIRCCKlL+Ys/e0TTDbamxdHippvYh9rBQbnYRYUE6bApOfmPaVWePg5hoVovWD6fPaPgf5xUVdEyF1cfZuS+AoiLShKxfAhsHtySZZ2D3PwOgMF952ImpIfdmwp+I0AKLOnhUyX3Tdy/OKGqIqknrJlmdAYgI6nq+jJbGjSnjwyolcyzb7l/zWCMPO9PNWwP7wG8dCN/LdqQ1LR2530+mHgy25Ifnltn0+8VKxXb+xmFexd2rAGWWqWSOaDBjQ35zLoU9VShdM5LOoBar2L6hWvQnabI/xNAUsqfOfiGGmTpE65cVp5DjhzXnVyL+PTjZ3ow8eH6qN9NT5Rj1lNr4oAhvpzlMFAXNLLV3G+iJycbWa6C3O7YzXJLYTA5JuiPV5vWP0n0Q= 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 Reviewed-by: Christoph Hellwig Reviewed-by: Mike Rapoport (IBM) Cc: Michael Ellerman Cc: Nicholas Piggin Cc: linuxppc-dev@lists.ozlabs.org --- arch/powerpc/Kconfig | 1 + arch/powerpc/include/asm/io.h | 8 +++----- arch/powerpc/mm/ioremap.c | 26 +------------------------- arch/powerpc/mm/ioremap_32.c | 19 +++++++++---------- arch/powerpc/mm/ioremap_64.c | 12 ++---------- 5 files changed, 16 insertions(+), 50 deletions(-) diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index bff5820b7cda..aadb280a539e 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig @@ -194,6 +194,7 @@ config PPC select GENERIC_CPU_VULNERABILITIES if PPC_BARRIER_NOSPEC select GENERIC_EARLY_IOREMAP select GENERIC_GETTIMEOFDAY + select GENERIC_IOREMAP select GENERIC_IRQ_SHOW select GENERIC_IRQ_SHOW_LEVEL select GENERIC_PCI_IOMAP if PCI diff --git a/arch/powerpc/include/asm/io.h b/arch/powerpc/include/asm/io.h index 67a3fb6de498..0732b743e099 100644 --- a/arch/powerpc/include/asm/io.h +++ b/arch/powerpc/include/asm/io.h @@ -889,8 +889,8 @@ static inline void iosync(void) * */ extern void __iomem *ioremap(phys_addr_t address, unsigned long size); -extern void __iomem *ioremap_prot(phys_addr_t address, unsigned long size, - unsigned long flags); +#define ioremap ioremap +#define ioremap_prot ioremap_prot extern void __iomem *ioremap_wc(phys_addr_t address, unsigned long size); #define ioremap_wc ioremap_wc @@ -904,14 +904,12 @@ void __iomem *ioremap_coherent(phys_addr_t address, unsigned long size); #define ioremap_cache(addr, size) \ ioremap_prot((addr), (size), pgprot_val(PAGE_KERNEL)) -extern void iounmap(volatile void __iomem *addr); +#define iounmap iounmap void __iomem *ioremap_phb(phys_addr_t paddr, unsigned long size); int early_ioremap_range(unsigned long ea, phys_addr_t pa, unsigned long size, pgprot_t prot); -void __iomem *do_ioremap(phys_addr_t pa, phys_addr_t offset, unsigned long size, - pgprot_t prot, void *caller); extern void __iomem *__ioremap_caller(phys_addr_t, unsigned long size, pgprot_t prot, void *caller); diff --git a/arch/powerpc/mm/ioremap.c b/arch/powerpc/mm/ioremap.c index 4f12504fb405..705e8e8ffde4 100644 --- a/arch/powerpc/mm/ioremap.c +++ b/arch/powerpc/mm/ioremap.c @@ -41,7 +41,7 @@ void __iomem *ioremap_coherent(phys_addr_t addr, unsigned long size) return __ioremap_caller(addr, size, prot, caller); } -void __iomem *ioremap_prot(phys_addr_t addr, unsigned long size, unsigned long flags) +void __iomem *ioremap_prot(phys_addr_t addr, size_t size, unsigned long flags) { pte_t pte = __pte(flags); void *caller = __builtin_return_address(0); @@ -74,27 +74,3 @@ int early_ioremap_range(unsigned long ea, phys_addr_t pa, return 0; } - -void __iomem *do_ioremap(phys_addr_t pa, phys_addr_t offset, unsigned long size, - pgprot_t prot, void *caller) -{ - struct vm_struct *area; - int ret; - unsigned long va; - - area = __get_vm_area_caller(size, VM_IOREMAP, IOREMAP_START, IOREMAP_END, caller); - if (area == NULL) - return NULL; - - area->phys_addr = pa; - va = (unsigned long)area->addr; - - ret = ioremap_page_range(va, va + size, pa, prot); - if (!ret) - return (void __iomem *)area->addr + offset; - - vunmap_range(va, va + size); - free_vm_area(area); - - return NULL; -} diff --git a/arch/powerpc/mm/ioremap_32.c b/arch/powerpc/mm/ioremap_32.c index 9d13143b8be4..ca5bc6be3e6f 100644 --- a/arch/powerpc/mm/ioremap_32.c +++ b/arch/powerpc/mm/ioremap_32.c @@ -21,6 +21,13 @@ __ioremap_caller(phys_addr_t addr, unsigned long size, pgprot_t prot, void *call phys_addr_t p, offset; int err; + /* + * If the address lies within the first 16 MB, assume it's in ISA + * memory space + */ + if (addr < SZ_16M) + addr += _ISA_MEM_BASE; + /* * Choose an address to map it to. * Once the vmalloc system is running, we use it. @@ -31,13 +38,6 @@ __ioremap_caller(phys_addr_t addr, unsigned long size, pgprot_t prot, void *call offset = addr & ~PAGE_MASK; size = PAGE_ALIGN(addr + size) - p; - /* - * If the address lies within the first 16 MB, assume it's in ISA - * memory space - */ - if (p < 16 * 1024 * 1024) - p += _ISA_MEM_BASE; - #ifndef CONFIG_CRASH_DUMP /* * Don't allow anybody to remap normal RAM that we're using. @@ -63,7 +63,7 @@ __ioremap_caller(phys_addr_t addr, unsigned long size, pgprot_t prot, void *call return (void __iomem *)v + offset; if (slab_is_available()) - return do_ioremap(p, offset, size, prot, caller); + return generic_ioremap_prot(addr, size, prot); /* * Should check if it is a candidate for a BAT mapping @@ -87,7 +87,6 @@ void iounmap(volatile void __iomem *addr) if (v_block_mapped((unsigned long)addr)) return; - if (addr > high_memory && (unsigned long)addr < ioremap_bot) - vunmap((void *)(PAGE_MASK & (unsigned long)addr)); + generic_iounmap(addr); } EXPORT_SYMBOL(iounmap); diff --git a/arch/powerpc/mm/ioremap_64.c b/arch/powerpc/mm/ioremap_64.c index 3acece00b33e..d24e5f166723 100644 --- a/arch/powerpc/mm/ioremap_64.c +++ b/arch/powerpc/mm/ioremap_64.c @@ -29,7 +29,7 @@ void __iomem *__ioremap_caller(phys_addr_t addr, unsigned long size, return NULL; if (slab_is_available()) - return do_ioremap(paligned, offset, size, prot, caller); + return generic_ioremap_prot(addr, size, prot); pr_warn("ioremap() called early from %pS. Use early_ioremap() instead\n", caller); @@ -49,17 +49,9 @@ void __iomem *__ioremap_caller(phys_addr_t addr, unsigned long size, */ void iounmap(volatile void __iomem *token) { - void *addr; - if (!slab_is_available()) return; - addr = (void *)((unsigned long __force)PCI_FIX_ADDR(token) & PAGE_MASK); - - if ((unsigned long)addr < ioremap_bot) { - pr_warn("Attempt to iounmap early bolted mapping at 0x%p\n", addr); - return; - } - vunmap(addr); + generic_iounmap(PCI_FIX_ADDR(token)); } EXPORT_SYMBOL(iounmap); From patchwork Tue Jun 20 13:13:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13285846 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 ED85AEB64D8 for ; Tue, 20 Jun 2023 13:18:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 94A0D8D0005; Tue, 20 Jun 2023 09:18:29 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8F9BE8D0003; Tue, 20 Jun 2023 09:18:29 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7C21C8D0005; Tue, 20 Jun 2023 09:18:29 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 6D5138D0003 for ; Tue, 20 Jun 2023 09:18:29 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 1DA3440F88 for ; Tue, 20 Jun 2023 13:18:29 +0000 (UTC) X-FDA: 80923180338.03.0D85C4C Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf25.hostedemail.com (Postfix) with ESMTP id 549CFA001F for ; Tue, 20 Jun 2023 13:18:26 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=U63JWqWq; spf=pass (imf25.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=1687267107; 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=72w03eJEhQqo4F/RBmYdJ2/NuxxsDP8AZF6XbBTG/zk=; b=49ksuRGxmh4P6p1a0yAMAZK3tpLsoXQEbO92LYxubKqGT/7Jefne2/iJYyn4k8Y7XQhtc0 qSWtWpVc6Jx00dRnt4e9ytQ1mnAOY/xM5kcDjUwgJ6eh2XIHnwKdEEqfCeuxkivCpC/XIn pqXTz8DJd0RCwECwdJTXBMhm2Raw41M= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1687267107; a=rsa-sha256; cv=none; b=e2WI1HuQweFbuXwaB01BVacKi81mi36Px2LJr1uA0O68LLlBvFFBs5mksVwx2fFB2/6X4R WOIsckoqWncwqCFq37zRcGNCB7S/ezq6X1wDAVxkOIcHkMRsiCFsb74p0S9oX2UlRBSj9a PL+dW/Q3P5Bwy7PM2heaK4xRtNOeKgY= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=U63JWqWq; spf=pass (imf25.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687267106; 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=72w03eJEhQqo4F/RBmYdJ2/NuxxsDP8AZF6XbBTG/zk=; b=U63JWqWqzp+HCHKw6GoSZnSadTvotcDRklom0xm0wy4MylbeV/Zq5c8v7VCe0ja+LJBEL5 rrkIsS10sSLBuzD+3UInBdmzs0qqJtIRCZoLn7mQwwbZi+ttvZT3SFOE5k6B/lq+glc4u6 1BsogvMmOMilH7Q3jSCG6swZ/yf/UDc= 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-494-IvFW2tAHNyCwbGqZN7_6DA-1; Tue, 20 Jun 2023 09:18:22 -0400 X-MC-Unique: IvFW2tAHNyCwbGqZN7_6DA-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 F3289185A795; Tue, 20 Jun 2023 13:17:01 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-166.pek2.redhat.com [10.72.12.166]) by smtp.corp.redhat.com (Postfix) with ESMTP id D9852C1ED96; Tue, 20 Jun 2023 13:16: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, hch@lst.de, christophe.leroy@csgroup.eu, rppt@kernel.org, willy@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, David.Laight@ACULAB.COM, shorne@gmail.com, deller@gmx.de, nathan@kernel.org, glaubitz@physik.fu-berlin.de, Baoquan He , Catalin Marinas , Will Deacon , linux-arm-kernel@lists.infradead.org Subject: [PATCH v7 18/19] arm64 : mm: add wrapper function ioremap_prot() Date: Tue, 20 Jun 2023 21:13:55 +0800 Message-Id: <20230620131356.25440-19-bhe@redhat.com> In-Reply-To: <20230620131356.25440-1-bhe@redhat.com> References: <20230620131356.25440-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: py9t5i7rsczmfpex4an4hs7tz4eqtekt X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 549CFA001F X-Rspam-User: X-HE-Tag: 1687267106-879541 X-HE-Meta: U2FsdGVkX1/mlHiTIGZ4TXgJ2ZpZGIXTmCJGm+j3N/EUXcrs3h2A8Vbs5SBNVNX6pFEPDfQdx2TjugLlXx7WbTF8GpPQsakt+v/b97Jf7PM52gGoUKrN5F/hST9ZL37U4ppJSOGDX8Gx6zH2GH4aqpMTjsAQsu7l5kOz9s9qOtouTt3LrJYiB+1lZAQ3hrt2jK8jGoV4B2FRsNjNRgn1YJld4qraoi2tsySyuDnbqMFg8Kx+spDJJ99C1uNyuZQwCYxDuISXRCDvk/sU9B0T2sWZ7zTImSkTo4jNiBFvZR7ljULZja0Qm0aNzq00xceCuE5CX+8Bi2LlQA4hNzStU97Is76/j9NbM2y1KH28fSUO4oYoEMqvplFkh/qXStwsC8+io8UwFru4UeGatj4zWg9WLS7xMbB9uDM54eXNav9rHvIhxwgKTX1hwg5urzAVd2XBAmuImTx1cl1tDIZwYqVJ+0baa0XPjOTx4T/JTzYE+PHXrHKiy7nSFJUJBDpQ+YkC5naungwRjE6wtfnUfaUDrXW0Bc8X4EJdeIi9NQZmb8i3Wbjq93GLr7DjBE9B9MYm0mRP6PyR/KPlKbmmbn/SEVmbJrjfCtJVqIe4qYcsPWbcw6ZeolKUZYNQkwde74Yh1cieJvagUFquf55YUL3rAZEsjJf+wmUWegLWIUbsHd/4emORTZyxTh9naH4kYr3R16acwchxNBonnfGQNol7jd8hyoujTJcWnhMKmOZv8QX/lIQCfgwJ4bg4gwwPIMI/gH84tCS83mg5vmwGmygbcXO2atea4gMZKFebtZpXPpty50Fp/A2WsFgZWTX44HLvUDUSVDlT172XnpAlkoby+USEqgbrt7N1NQ27Wj9TSogv0z15Q53dQpvBOZbU/11utX9mgCtmrTIdvaSOXyWZo9vmPUGLGXCnDMS114VF2q8iQ2ZNSskwt8cEGL29uOIC0GDRP1Y1RnXU9vw MYE+CxUc koeKjN/WhMY4nGGP08prqg0B+AAFnnopY6Ofu5m0ZVLfxkivNJgFU8RvtuZOm9Q6KCexGtqM3DE1AW/74GDcA9FieZ7EzNwnoq+eF08K/FRos+ak6N+VtrkQqOYZ2LYbAqfkDlWPAfCzKFNxsL+5T8IQNBOE3MRBi4Qsyz0H6Uw7hMxY1zr0BwVC6fnJDYhh3u83fbcyGANesdzl7HLTSWXYeUwR3QmANCoFP5bxPh7k/DLj3chpJPfJpEHxnmSxHxb8N0TlwWaSqBT/R0+unY4nP1by7vx9LeAiJq/7EkYVmm4+93iND5giv9AWVseE9rz660XoNHn56v+HtSTwfucX0OnyHKwl9UPD4GHW1rqsEtZ87kCcbLAxYmMxwMzm1TKfvxMXxUHu/myWNemANAChJo0iw3qRjyDX8oKsJe/EgTgM= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Since hook functions ioremap_allowed() and iounmap_allowed() will be obsoleted, add wrapper function ioremap_prot() to contain the the specific handling in addition to generic_ioremap_prot() invocation. Signed-off-by: Baoquan He Reviewed-by: Christoph Hellwig Reviewed-by: Kefeng Wang Reviewed-by: Mike Rapoport (IBM) Acked-by: Catalin Marinas Cc: Catalin Marinas Cc: Will Deacon Cc: linux-arm-kernel@lists.infradead.org --- arch/arm64/include/asm/io.h | 3 +-- arch/arm64/mm/ioremap.c | 10 ++++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/arch/arm64/include/asm/io.h b/arch/arm64/include/asm/io.h index 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 Tue Jun 20 13:13:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13285845 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 6D796EB64DB for ; Tue, 20 Jun 2023 13:18:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 097D98D000A; Tue, 20 Jun 2023 09:18:08 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 047D48D0005; Tue, 20 Jun 2023 09:18:08 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E79048D000A; Tue, 20 Jun 2023 09:18:07 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id D814E8D0005 for ; Tue, 20 Jun 2023 09:18:07 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 8B3E980F18 for ; Tue, 20 Jun 2023 13:18:07 +0000 (UTC) X-FDA: 80923179414.11.31D2EE2 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 93AFA1C0014 for ; Tue, 20 Jun 2023 13:18:05 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=DOa+i9+x; 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=1687267085; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=keQ78Mv/VCFMjxLJbgEgr2h/sjN0UpPUn6QsvR3JRNU=; b=Hx/6/HkkGfsNOsUsc17L1A1zUHxCKxvj5QY17YrOx2vMAakOmVeOYeQprWOC1Tv9N2+3qQ rL7A+GKunaIiHYjbwKkDdfKOWqwkKM9YUFfCTrdytd0KU/+PnFuX+3MejRqOuFpzZAqkE6 YKhBNkJ4MhjjHd3M0XbCiOpV6wrLj2Q= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1687267085; a=rsa-sha256; cv=none; b=DN/QpNEV/O+eGD7JbtlGXp2vCEAsknti86+KbYKn+L0rdpUvelqW7ApZfMg2Kt7ESIG9xW DfB9oiHWVw8Nyukzw/JEZ5TRmrGhJWvCa1QxZ8ipwswOJUhtu0zGbYnDXymw22ga1aTVpI kTWolmJxD/iQDfNSdKT76U19iNUMSus= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=DOa+i9+x; 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687267084; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=keQ78Mv/VCFMjxLJbgEgr2h/sjN0UpPUn6QsvR3JRNU=; b=DOa+i9+xnjer9WRb/ZpT5TWcsrrAKX/+7wi2BIJ0hSk75/0RM4VaceKHLFL/0AtW5UEp8F y1zvV8Rhpfxai8TI+H079mhqkG6jl15PyiDD58oxM+hLil05VXJKEADhmGYf1cKEc+pyLR nkCpt4FZCsdLxCXg7i3GQ5VkP/xYdaY= 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-168-10jviPZINQmT4T6apGJu0w-1; Tue, 20 Jun 2023 09:17:55 -0400 X-MC-Unique: 10jviPZINQmT4T6apGJu0w-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 934BC3C0F691; Tue, 20 Jun 2023 13:17:10 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-166.pek2.redhat.com [10.72.12.166]) by smtp.corp.redhat.com (Postfix) with ESMTP id CA753C478C7; Tue, 20 Jun 2023 13:17:02 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-arch@vger.kernel.org, linux-mm@kvack.org, arnd@arndb.de, hch@lst.de, christophe.leroy@csgroup.eu, rppt@kernel.org, willy@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, David.Laight@ACULAB.COM, shorne@gmail.com, deller@gmx.de, nathan@kernel.org, glaubitz@physik.fu-berlin.de, Baoquan He Subject: [PATCH v7 19/19] mm: ioremap: remove unneeded ioremap_allowed and iounmap_allowed Date: Tue, 20 Jun 2023 21:13:56 +0800 Message-Id: <20230620131356.25440-20-bhe@redhat.com> In-Reply-To: <20230620131356.25440-1-bhe@redhat.com> References: <20230620131356.25440-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: 93AFA1C0014 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: yz7syfhety9by1otijf61sty3jjci3og X-HE-Tag: 1687267085-656160 X-HE-Meta: U2FsdGVkX1+1n5O9tXbe3qRsxCF93lBmm9DcUf8hmEqiivYvvvz6ECcrxIm0YqjSXkRlWQG6CDALVbER0Nw4Jd9cVgcDyYJ7cSvjOYAWxkVCTiHDSS1/ejj1kP7HDpr9G32M2y9uzR/uMZy+o59vCjc8O4T8BlEqaYBcFKCx2hLi2hhsPbUAet7E+MvOwTicw2VCaI2HTI7Y8JtoU2d4YhGkb6aBz24W9WWaVndY610WJ4bNVHQZFGf+/pI2UuP18DxQGOHvS2kFg17WKS9raedmmtVpFhXx+aAbycDtdMSoOPR444TFej5mdK4Sx14p7JYNU9O6ppgNVYmFIxVcfP2em1XrjUe6V3DUm2ET+NROkyBV1gH1N2kAn0XGsTCmh83cDde7eovQOPZEFZ8xWrwoUvAWqKkcsTAC5QU0+er8Ft85m0+jVB/H8q3FqiutdFNa2YeUVjcyW8v295QjneCBeUgObFXRa4nC9NZjcvdjlnlXPXUTWVc48IzUwvBtfxctKQwkwJkI63xOBH8p+qS3Jp4QpwLWkgzEp82spBFhDW1koNknF2njgZQ2J9icl6YhJnlGF/VOj7joQsD0e2c4LJ4Q4nvPj/iBlWixJsuu/R6hogVXXeMtuKwL4MQEMs52kZERPK2HEZyl/5lORtl05iByVsp2VT087F+WvLeqLnY3YjyJKE7at/BC5+5cIgGlz9e3d5rMYJYO9ocEemlWOvuJnFumnHrmqhfWPEj1SYsAQzuquG6Bpt/Ogc/McCUxFzU8MvXpl3regmScuQ9GuiL1bh5SuCkl1wxO35USEB7sgULE6qKO9zLae5FUQcwyC+3FN2qOo+JvnM8radMIJ6Se9UAeUYGwmJJDRuX7qV5q73IRYG9R5sBSVV6JDkj6fslDgpqz0FcfP6VhSRX5A/JSjX6jLxpps7MUyG1WALXUlf980QCISuP++GPxrwdomQsQHTPc+1AjQpu GgWMZwGK zwBtOVZcUYR85QlokjFv/iMIs7lB7B5Pe6vUnFN3Nyq1bYMPFWHbCKvCTM7aIu5H8Xg5cbVPi1eDY/y+WNhJ3xzBCr0drEtMXNBv6GKFQGl6qPGTVi5dLT8XF7Kv3WwRDTDqNyDskBs23WqhdPooa6ZYcnC8sDmsCGqlHtfQvH5t2qEODs43bBMl2BbGWoN9UGLMWeqSa6fPnFzCA2jmq3SmAhXqpVVqnys2cYtAYpFPfLDmhZVYcLtzMSW8LPETeXFBoEaBcBDdRGjYlkizjE4P3soluSSqyqmXyGjSjoqSpV9I= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Now there are no users of ioremap_allowed and iounmap_allowed, clean them up. Signed-off-by: Baoquan He Reviewed-by: Christoph Hellwig Reviewed-by: Kefeng Wang Reviewed-by: Mike Rapoport (IBM) --- include/asm-generic/io.h | 26 -------------------------- mm/ioremap.c | 6 ------ 2 files changed, 32 deletions(-) diff --git a/include/asm-generic/io.h b/include/asm-generic/io.h index 39244c3ee797..bac63e874c7b 100644 --- a/include/asm-generic/io.h +++ b/include/asm-generic/io.h @@ -1047,32 +1047,6 @@ static inline void iounmap(volatile void __iomem *addr) #elif defined(CONFIG_GENERIC_IOREMAP) #include -/* - * Arch code can implement the following two hooks when using GENERIC_IOREMAP - * ioremap_allowed() return a bool, - * - true means continue to remap - * - false means skip remap and return directly - * iounmap_allowed() return a bool, - * - true means continue to vunmap - * - false means skip vunmap and return directly - */ -#ifndef ioremap_allowed -#define ioremap_allowed ioremap_allowed -static inline bool ioremap_allowed(phys_addr_t phys_addr, size_t size, - unsigned long prot) -{ - return true; -} -#endif - -#ifndef iounmap_allowed -#define iounmap_allowed iounmap_allowed -static inline bool iounmap_allowed(void *addr) -{ - return true; -} -#endif - void __iomem *generic_ioremap_prot(phys_addr_t phys_addr, size_t size, pgprot_t prot); diff --git a/mm/ioremap.c b/mm/ioremap.c index a21a6c9fa5ab..3e049dfb28bd 100644 --- a/mm/ioremap.c +++ b/mm/ioremap.c @@ -33,9 +33,6 @@ void __iomem *generic_ioremap_prot(phys_addr_t phys_addr, size_t size, phys_addr -= offset; size = PAGE_ALIGN(size + offset); - if (!ioremap_allowed(phys_addr, size, pgprot_val(prot))) - return NULL; - area = __get_vm_area_caller(size, VM_IOREMAP, IOREMAP_START, IOREMAP_END, __builtin_return_address(0)); if (!area) @@ -64,9 +61,6 @@ void generic_iounmap(volatile void __iomem *addr) { void *vaddr = (void *)((unsigned long)addr & PAGE_MASK); - if (!iounmap_allowed(vaddr)) - return; - if (is_ioremap_addr(vaddr)) vunmap(vaddr); }