From patchwork Mon May 15 09:08:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13240980 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 5612EC7EE22 for ; Mon, 15 May 2023 09:09:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D429C900004; Mon, 15 May 2023 05:09:16 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CF2FB900002; Mon, 15 May 2023 05:09:16 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B9573900004; Mon, 15 May 2023 05:09:16 -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 AAA9C900002 for ; Mon, 15 May 2023 05:09:16 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 74B19A13C1 for ; Mon, 15 May 2023 09:09:16 +0000 (UTC) X-FDA: 80791915512.12.D33B8E9 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf17.hostedemail.com (Postfix) with ESMTP id B51024000D for ; Mon, 15 May 2023 09:09:13 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=gSm70LfV; spf=pass (imf17.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=1684141754; 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=awWutqv7Tku6RTy5++zNn2CsetnK4SAvTciCez0pzMg=; b=VHlo3gzwK7eUMDlal4mK0TkScGIE2gaw2ykUp/F7L7frxeb4lxK964YPAQAaR3D2kNtMxt qZ86qZxScTKVgAQph1+nUmqnhHoCYaxmy1D9uOBwoxCUgmdc46lPys7wptC14VqYiVfELa 9iYZI/BAndr64qSrlVurfVwbDvSC9jM= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684141754; a=rsa-sha256; cv=none; b=sMl33zvGgm3jN2Zj9cKXvC2EbPBUJ9zwPomt7DbEoHKTblM+rwnTADTVITTsxB2dhM8Jxg EYOsY3FECybf4l7YqH5UQIr1yjOe+SlOo4etfvB5Sdz8/p2OYMjG9Yx0aGeqekqOcro3D/ v/lgmFEJTS4IfrneP2JaQ3kB8J77hDw= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=gSm70LfV; spf=pass (imf17.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=1684141752; 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=awWutqv7Tku6RTy5++zNn2CsetnK4SAvTciCez0pzMg=; b=gSm70LfVjv3ikRzcupF66FCR5+IVhCgSElqc04GIgpBEmw3dL4VMTgGpV8DsZuP4sKSfgo xHocvB/Y4lwXZCt86ZLTD5sylxDq8j1LW5wIQ9T/5uctzNNMoor881kfdOOF0K5gDCKQfS dSOKdEqxg8ixlPKEE5V1h/kKSfKUszo= 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-659-KJdy53drOYK6CyyGE_o-bQ-1; Mon, 15 May 2023 05:09:08 -0400 X-MC-Unique: KJdy53drOYK6CyyGE_o-bQ-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id BB828800047; Mon, 15 May 2023 09:09:07 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-32.pek2.redhat.com [10.72.12.32]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6FF2D40C2063; Mon, 15 May 2023 09:08:59 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-arch@vger.kernel.org, linux-mm@kvack.org, arnd@arndb.de, christophe.leroy@csgroup.eu, hch@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, David.Laight@ACULAB.COM, shorne@gmail.com, willy@infradead.org, deller@gmx.de, Baoquan He , loongarch@lists.linux.dev, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, x86@kernel.org, netdev@vger.kernel.org Subject: [PATCH v5 RESEND 01/17] asm-generic/iomap.h: remove ARCH_HAS_IOREMAP_xx macros Date: Mon, 15 May 2023 17:08:32 +0800 Message-Id: <20230515090848.833045-2-bhe@redhat.com> In-Reply-To: <20230515090848.833045-1-bhe@redhat.com> References: <20230515090848.833045-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Stat-Signature: 5t7iq1u7pj3aw8q6eazg947dye9mxbfw X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: B51024000D X-Rspam-User: X-HE-Tag: 1684141753-366430 X-HE-Meta: U2FsdGVkX1+jWfZkbm84vnYpHc65Cee+1dEULdq15UzXvebNjnBy7cHxtAPhVx5Ms6A5RFn3q322QkuhHdqhFHWWqy9RO1jcC0iQKA4zsm9Kcw/vvw9St9X90JdYBUpGZAOUQQ82P2eXnp9pR2pBLKLyYdVDciSU9M2OIGgQ/Z9eVPRjTshaXiNPLSDD8W5FrueyBjf1Rp6jQdd6Y/irO68nYsFdT3mpNOQm50Neby2rx6oy3lpt/jsQs8d8cbmN3vKytxLAvWH1cM6gJFzf1aCqh/WgF2qltfSWNsC76EcVD2lgFi0XlUxe+nmM1t8bkqFtnT7K0Kh3IFePJ9HDyCzIwHKB8QGzJjPrgh24ZK+Kq4cFTtm8yzz3DvUaVBIvgImsdHSbA+13yxLAk0U+x6nh0Ccayk2F9bD3JoNskX2oGqtjqkkZxru+Za+UIJWnNgk0iVLji3q2iZLGqtyry0NzhH/CW5VS3BHqkojC3F1K1XspEvOHp3C4813ZcPT1GcUPCHDYHcHjKrcZFImCglG/3kgHSgrllqiPY/lW81eT9lcODW4aWIQWlO573lhVNjI5ysPoKAH8hcHKjORTDp48CPXHtzQ0xZFdXiP21UoGiO9ra3lQMgbBicP99Yx/ZjgcZLXj/khFWLs+xR5bh0qJPXDrSI215rPgeZ147CDqqIdzEhqMAQyrRXJdhintVvOR9/CsWhMbwnY90+TA9ySBBamOiIEug6/M1ssqi0HkdW31qE868AFCtW0XWkp/6GYX4reZjE3l5aeGd4e87cdZ2m+vqGcg9ABnMthMnIRrGG1qH8HuW9mxinn0AemycLqLGsj67HbZC7IS8TGZR3hsG+SSGENmKG/RNGTlorBtcGF7wDGttPhy4H2OSqHdxngDg5LUsP6NkDJxpxYXP0N4IB+/7Vz7XxtHXJ1aec9qVAfJ7U+WZbXW8bKxJF6dxBu+uwQU8s83lFAz3Ae N7iGqZcX ul87IkgwhHSRxKfpFlxJx7nddG/jMW5JGjVuG9EDdlUEf/qEO70sQcLBzFbDAi/qv1CI793oSHbjI4ZiTT7VcP5Em4NvCYG01SVM+cpwnK+j4bFur8cZBD8EDv3bb+SYAxxwuQtRU+ZGe6EMq35bAjv1fERWZY8SQuiRz9XIruOmu8xIoQLfn0DlLSWaPtHtF2ecTAlIhWVpsXF2pC2NSCkajP5vCxlc7DsR8+EbcB2C90fzxU/oLwdZWcT7fns+4COhfZ63DMWNuUP8DinbmPTRqt1DOZ71ySNmpQRvVw1to9nlCUOYCdBE5ttYnN4T12q6MVCMHN1HkRr36yNgxtw1bpEN5u+x8VGeceORDLE0nrKgwDRU7chNVFIA0gI+3nP7kuMoyjeFMBUUy37Eb62F6NI+hyRiz/q95A3LKlj93XA21EjAnd4uPWmpcKNYgVVkq5J+5g3TrVD4= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Let's use '#define ioremap_xx' and "#ifdef ioremap_xx" instead. For each architecture to remove defined ARCH_HAS_IOREMAP_xx macros in 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 Cc: loongarch@lists.linux.dev Cc: linux-m68k@lists.linux-m68k.org Cc: linux-mips@vger.kernel.org Cc: linuxppc-dev@lists.ozlabs.org Cc: x86@kernel.org Cc: netdev@vger.kernel.org Cc: linux-arch@vger.kernel.org Reviewed-by: Mike Rapoport (IBM) Acked-by: Geert Uytterhoeven 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 Mon May 15 09:08:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13240981 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 E320CC7EE22 for ; Mon, 15 May 2023 09:09:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6B377900005; Mon, 15 May 2023 05:09:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 663DB900002; Mon, 15 May 2023 05:09:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 553BF900005; Mon, 15 May 2023 05:09:26 -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 48A47900002 for ; Mon, 15 May 2023 05:09:26 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 13EC7AF4CC for ; Mon, 15 May 2023 09:09:26 +0000 (UTC) X-FDA: 80791915932.11.2B79E85 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf17.hostedemail.com (Postfix) with ESMTP id 5096A40009 for ; Mon, 15 May 2023 09:09:23 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=eEuSMKJJ; spf=pass (imf17.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1684141763; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=v0nZZRtgRBEjd1TuZoUTX3TC1k0a64a2n3jlsJishp4=; b=SrpHkKi3YdznCTBqHKCg9IuSXOTqZYKCZxKF06HGBi3dvJQ40BOOPRXympP3vq9liOpFEX 3cWKnukD+L++1KR7YpQcb7J1Ja888Rw8hTVmImn+avbRLBoreIRiZyodLFFU5CYA4m9tzN bcZ796gG1jbD8zgM7Eb9hw2DE9ipfGM= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=eEuSMKJJ; spf=pass (imf17.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684141763; a=rsa-sha256; cv=none; b=BlRTXXMaGvfFqrI2M8cZwE3ONuj2c3GHEIQT6ueFbPHHCFXjF6Lbq/qI8Jk8BvI+KUSeI/ b1vaaotoQqeaH8TqO/NYYmQmesjdiy3uak08x4Kma8+o5tFdhkSDNjKN7XhBEbbWBCEuF+ 2OvN7v0qMfSmyFmO65E9NEZkhoGQwBE= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684141762; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=v0nZZRtgRBEjd1TuZoUTX3TC1k0a64a2n3jlsJishp4=; b=eEuSMKJJ3fhH56ioipOy0Nbn/6QI75QhMIhD1WrToG4Rk6Pylbrr7MlplG9ARqgPnyBHfe 3QQshNp9jfQqmmgKLzugYPCoS7FybFky3Cgvq/LET0L9btMcQ60rV8fhQOMseSkUwFQsHS UAEPO+yNXEd2e+FKBTfzZCVe/DjCWKA= 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-672-74Ahrn84PGaX_v4p8ksNng-1; Mon, 15 May 2023 05:09:16 -0400 X-MC-Unique: 74Ahrn84PGaX_v4p8ksNng-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3FBD21C08788; Mon, 15 May 2023 09:09:15 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-32.pek2.redhat.com [10.72.12.32]) by smtp.corp.redhat.com (Postfix) with ESMTP id 70BD340C2063; Mon, 15 May 2023 09:09: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, christophe.leroy@csgroup.eu, hch@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, David.Laight@ACULAB.COM, shorne@gmail.com, willy@infradead.org, deller@gmx.de, Baoquan He , Brian Cain , linux-hexagon@vger.kernel.org Subject: [PATCH v5 RESEND 02/17] hexagon: mm: Convert to GENERIC_IOREMAP Date: Mon, 15 May 2023 17:08:33 +0800 Message-Id: <20230515090848.833045-3-bhe@redhat.com> In-Reply-To: <20230515090848.833045-1-bhe@redhat.com> References: <20230515090848.833045-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Stat-Signature: a4tmkdiocedespqn6sjmxstrfnasnc1n X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 5096A40009 X-Rspam-User: X-HE-Tag: 1684141763-791917 X-HE-Meta: U2FsdGVkX19HoUOYVVg/XXG+BdpzDgJMTRcjgQibj/lTQG7bz3B2RDy9BDOqAh3kHfH+Sl3SMtkBEYTS8iGwW8xtdqnVAw8oRPdD9Sn7kg7HYkMpsFsJ0UlvGMk0YFnhhwJ7faoKmi/X7O19f3czGU/4XkqfIebci00dxBvGUP1CLOh26fHHLUH1q/AIaGkKo5foua1/KTBYCT7hVSeMS04DenARbOsU7Qx3LDlmuMigmrelIqTngA6qiUx8+NiQDn97KcK/51elWu0puMxqyC6APuR3l0lkW2XMEQIAhrt+CykPhDuQDXMTOdov2iaJW63cquDeS1B3++dPoHi7g7S1kUjoCNm0CHWlBqWE1X1FDX7ssZT7E3jfVT+ottMDcPNb9CybBPy2o9Wnz35FIOrCCmPfcBINSKq2gmw+TZfAe/CNkmDMabh2d//uRe6sSZQrrryCJg//t0/WEQNtX6JqMcnGAR6vQRDhjmXuM5K9gcoAyhUQYuRUHjSvkozN2GzQfaHDqmAJeADsskrVVaKU3E4o9TGnf0ZdhWbB+GoEgjO4dO/youPDe6P726ghr1xX4w5X9+5Ttm4U/jJf34OaiQSBqmNENzAwK+hnTil0Zsg+MMcd7f92/vB9VuUdRGJP0syMpqpt1jOWI6KTzNu9+2sTtehyBPO4ZZGDQjd+Tsm4v0Zcb5/sr/XAaej4Klcz9x7LBezBZIV6CZHv9NSqHs70CeX8DS3WUikMuoMxBh8nsYzwmo58K+wxPxCkTuBgwD4wVGxqK/6dszs4Ispmn0/QNiiOtSas9B1KKTiuwUDaXMJfbprOcn1RrcRe+fSCE+/RpLGwEzhdqQzBJv+Fs02v+y//yeTEVQYPU6o+mstgIM0/EN5s37NQefv3ZpIlMiFE/bOwMPR7uBGCM2GbwqQTixZsDW9KVsnCvOJ0hLxb+sFFVnHV13YFiHWRSvlbP1IyJOXrRPEd77k h5kkTHqB lE9HS96OEPsn/jppJeKOfR3+bMFx72Xx1YtudZns5AGGI4h1Hzd8WofAQInpZh6iqpPD42uSmcn6bwjRyqnY9fIWxs6n9K9S8fTfKKyiu8rjB9ykZo298rYI4HQRI5FSdMFHe3tDmMyYIhssHuUpGvOQaDnSjzVbXbt4VxCpIJCI6Mnok7RZmuMEKKP1ep0o35s2SyX4TruiI5KdF9wWnbfIEQ7Xg9/KcDApHIOG+SVuaPwzP5AXi+jE07FD4U6w3RC7lDYM4+a16x4cNyNkew5L0Yj8jdDC1s/8Vavw1TgPb2Iz0f1TSIyDsYUVC9wJapth84qaasz8w3qES/xSEqosnjA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: By taking GENERIC_IOREMAP method, the generic ioremap_prot() and iounmap() are visible and available to arch. This change will simplify implementation by removing duplicated codes with generic ioremap_prot() and iounmap(), and has the equivalent functioality. For hexagon, the current ioremap() and iounmap() are the same as generic version. After taking GENERIC_IOREMAP way, the old ioremap() and iounmap() can be completely removed. Signed-off-by: Baoquan He Cc: Brian Cain Cc: linux-hexagon@vger.kernel.org Reviewed-by: Mike Rapoport (IBM) Reviewed-by: Christoph Hellwig --- arch/hexagon/Kconfig | 1 + arch/hexagon/include/asm/io.h | 9 +++++-- arch/hexagon/mm/ioremap.c | 44 ----------------------------------- 3 files changed, 8 insertions(+), 46 deletions(-) delete mode 100644 arch/hexagon/mm/ioremap.c diff --git a/arch/hexagon/Kconfig b/arch/hexagon/Kconfig index 54eadf265178..17afffde1a7f 100644 --- a/arch/hexagon/Kconfig +++ b/arch/hexagon/Kconfig @@ -25,6 +25,7 @@ config HEXAGON select NEED_SG_DMA_LENGTH select NO_IOPORT_MAP select GENERIC_IOMAP + select GENERIC_IOREMAP select GENERIC_SMP_IDLE_THREAD select STACKTRACE_SUPPORT select GENERIC_CLOCKEVENTS_BROADCAST diff --git a/arch/hexagon/include/asm/io.h b/arch/hexagon/include/asm/io.h index 46a099de85b7..dcd9cbbf5934 100644 --- a/arch/hexagon/include/asm/io.h +++ b/arch/hexagon/include/asm/io.h @@ -170,8 +170,13 @@ static inline void writel(u32 data, volatile void __iomem *addr) #define writew_relaxed __raw_writew #define writel_relaxed __raw_writel -void __iomem *ioremap(unsigned long phys_addr, unsigned long size); -#define ioremap_uc(X, Y) ioremap((X), (Y)) +/* + * I/O memory mapping functions. + */ +#define _PAGE_IOREMAP (_PAGE_PRESENT | _PAGE_READ | _PAGE_WRITE | \ + (__HEXAGON_C_DEV << 6)) + +#define ioremap_uc(addr, size) ioremap((addr), (size)) #define __raw_writel writel diff --git a/arch/hexagon/mm/ioremap.c b/arch/hexagon/mm/ioremap.c deleted file mode 100644 index 255c5b1ee1a7..000000000000 --- a/arch/hexagon/mm/ioremap.c +++ /dev/null @@ -1,44 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-only -/* - * I/O remap functions for Hexagon - * - * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved. - */ - -#include -#include -#include - -void __iomem *ioremap(unsigned long phys_addr, unsigned long size) -{ - unsigned long last_addr, addr; - unsigned long offset = phys_addr & ~PAGE_MASK; - struct vm_struct *area; - - pgprot_t prot = __pgprot(_PAGE_PRESENT|_PAGE_READ|_PAGE_WRITE - |(__HEXAGON_C_DEV << 6)); - - last_addr = phys_addr + size - 1; - - /* Wrapping not allowed */ - if (!size || (last_addr < phys_addr)) - return NULL; - - /* Rounds up to next page size, including whole-page offset */ - size = PAGE_ALIGN(offset + size); - - area = get_vm_area(size, VM_IOREMAP); - addr = (unsigned long)area->addr; - - if (ioremap_page_range(addr, addr+size, phys_addr, prot)) { - vunmap((void *)addr); - return NULL; - } - - return (void __iomem *) (offset + addr); -} - -void iounmap(const volatile void __iomem *addr) -{ - vunmap((void *) ((unsigned long) addr & PAGE_MASK)); -} From patchwork Mon May 15 09:08:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13240984 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 A8869C7EE22 for ; Mon, 15 May 2023 09:09:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 443DE900006; Mon, 15 May 2023 05:09:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3F286900002; Mon, 15 May 2023 05:09:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2BA72900006; Mon, 15 May 2023 05:09:33 -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 1D1E9900002 for ; Mon, 15 May 2023 05:09:33 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id D9F9AA1390 for ; Mon, 15 May 2023 09:09:32 +0000 (UTC) X-FDA: 80791916184.04.8D1133E 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 1ADE2120009 for ; Mon, 15 May 2023 09:09:29 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=CUIOMLhF; spf=pass (imf29.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=1684141770; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=jHZa8mu+sMxKIWEAwvYcXi8mFXnonAyjIbMLTnXCGN4=; b=4rIuSWqi3GEP/Jv79CEPULZ2sl34NSoHdPKg6SWQDJNJUDhCXujKeFVKzRLjrUqCrWpT+D UPbbfIP0oV02JbqvPDUKDLNQemUx86F5AxAFrcdhgsjsfv/MUUHHVjOXTf0YOjLtMYx5jj DlTCDMP8Hu4BAiMhYllLmhEcU/79HfA= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=CUIOMLhF; spf=pass (imf29.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=1684141770; a=rsa-sha256; cv=none; b=Ao7jGvTXTgO+MLOm7V2Evi999Fm2+NEwMUtE3jNGyEjYQ7W6ceMsiXBq+veF/mGEBndXvl 7H9DfMbvyd6Gx26aKz+78Wx8jAvAPk+mL+UGv2tbdMriyBjeMajQd9p/tjLnwc3bhbS+Xj LE71WRmYJWx1f3Eyh/NRmH/UUPG7zUI= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684141769; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=jHZa8mu+sMxKIWEAwvYcXi8mFXnonAyjIbMLTnXCGN4=; b=CUIOMLhFqXoMmNzwyJpNa4ORFdydvVtpkvgA2U+17WVeNJYVlB0zJV++A9B1Qv19D72w+X 5zovLSkMV39mLEkCw9sfhOtwFop/q8Dx+MLlLXYH0hoJPJnoFU/OY8lx3DhWcsjLxVCiBx 29iQaczgy+RG0gJr2eT7fKinZ9b9qCE= 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-390-F9OGOUBiNvmyjtoAQ6ukpQ-1; Mon, 15 May 2023 05:09:25 -0400 X-MC-Unique: F9OGOUBiNvmyjtoAQ6ukpQ-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id EB38B1C08780; Mon, 15 May 2023 09:09:24 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-32.pek2.redhat.com [10.72.12.32]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1006440C2063; Mon, 15 May 2023 09:09:15 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-arch@vger.kernel.org, linux-mm@kvack.org, arnd@arndb.de, christophe.leroy@csgroup.eu, hch@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, David.Laight@ACULAB.COM, shorne@gmail.com, willy@infradead.org, deller@gmx.de, Baoquan He , Jonas Bonn , Stefan Kristiansson , openrisc@lists.librecores.org Subject: [PATCH v5 RESEND 03/17] openrisc: mm: remove unneeded early ioremap code Date: Mon, 15 May 2023 17:08:34 +0800 Message-Id: <20230515090848.833045-4-bhe@redhat.com> In-Reply-To: <20230515090848.833045-1-bhe@redhat.com> References: <20230515090848.833045-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Stat-Signature: 43j8mkns1s9pfnikpx3ff7rzwxi6txqa X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 1ADE2120009 X-Rspam-User: X-HE-Tag: 1684141769-790379 X-HE-Meta: U2FsdGVkX19wf+1MhIxaUNI+Pt2CmvLpClywa0tePOJ7Zj+C0ZallZVqcIb81hYsYj0linmHfUI9QrnLY4UzJ1ULmNkWU9CobbMaAnkkYDgshXE2vqR1GbP4x0so5wnRmC14lpO8ZkV2JTdoYgNIaZCvNq4Ojxd9t0cAJKB84thPe+r/Oeb0DrtAyB+iaC7cqBM0vWzoJheDLxsEYzXm9UXputOTk4Hf1z6ffIFtwokQxcUH9MDLxB+ysADTAQnwFqyAiG7kFytq6U6Bn2oHgobiW1Ef8H9S5gvkd7swCDCUhaF7grd2UbiIpleSxvenetrWgb7eqZLuVe/49TSF4YO0XX85O8vc5rkcjT6kXMx1gBBwdZiJZRz1h98H436ARJgGAKjgfuAYZbJBUjDsvARkf+Y1oK/K4diSotlJJdFvhfjEMYUqAHvNnme4PQvLXyKYu+lxLyc7+bXAN3GDOVwBlMJpov8W/EHYrJm+2L13Sg9Vu78zoQm17fcL1pOmmYUuIl1f++3Xu5K88Obksl3lVB1K20Wl8ieCQjyU/ZAjHcN505uozplrUbEBM/gZLUl/buMYFcuyV+3m+5NdzS12x7+SheEhWDUN5v+Zibor70dlUg5HiW9OiJ5osw/9ohIrvbsAj/znazOl4z5ikpSy3YAoc1FVboButvVcawVV/+Hthk6D538cKJFLiNJ7lXpv78Js1WcUDoJv1jEre709Ishala5BxSQhHiP/WCsHT2MnMsz5sVpH3/mGgBMdrAyUkubLFv/kM4DLh5QRC0oSRA1PfkL7jZ7jtye0X32zsvdt/lcmkXdy6lLTdpX+y2LMHCyGJCXIj9ASEE7Ny2a+f7jA0d0j6GbNrNLIeAIxIA5PuE+pndm6fUpG3iMFR3PLD198dM+EbPMgd6Z//h/l/R1eTGSSkRz78H1evRYZBDnBXchmrnlaSchpJwhvamm8NEPPAoZVky/X8Jy 1N25dfyl q1G72Kqt0TwWfXjURDk+kBDvQsHMJamvau8XBCGRN46p6Iw9/5Dy/30L1fv0z1Cs/rD+DIHtkbc4p307KN9VYz7ku+zfZegeLjKlz8H0m3EQK8ZzTLxC48crBGrzgSwF31Dk9XxbfkT52ENlOQdyrjJB/WXMiUNac2wkFsQBHm0du+fv9q1+9jiIm9VXLnKa8FINU/dOK479XturxzcwmMvkASUpH2JNIm5UNExQOUBip/e5bxPQxUQ4vQveLzHRThR+SFRbKvvbmnB8a0Ygy5v9ep6LIfCtNA7RT8RbPVs+yUdkk24o8ARLL0omEJsSaakrI X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Under arch/openrisc, there isn't any place where ioremap() is called. It means that there isn't early ioremap handling needed in openrisc, So the early ioremap handling code in ioremap() of arch/openrisc/mm/ioremap.c is unnecessary and can be removed. Link: https://lore.kernel.org/linux-mm/YwxfxKrTUtAuejKQ@oscomms1/ Signed-off-by: Baoquan He Acked-by: Stafford Horne Cc: Jonas Bonn Cc: Stefan Kristiansson Cc: Stafford Horne Cc: openrisc@lists.librecores.org Reviewed-by: Christoph Hellwig --- arch/openrisc/mm/ioremap.c | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/arch/openrisc/mm/ioremap.c b/arch/openrisc/mm/ioremap.c index 8ec0dafecf25..90b59bc53c8c 100644 --- a/arch/openrisc/mm/ioremap.c +++ b/arch/openrisc/mm/ioremap.c @@ -22,8 +22,6 @@ extern int mem_init_done; -static unsigned int fixmaps_used __initdata; - /* * Remap an arbitrary physical address space into the kernel virtual * address space. Needed when the kernel wants to access high addresses @@ -52,24 +50,14 @@ void __iomem *__ref ioremap(phys_addr_t addr, unsigned long size) p = addr & PAGE_MASK; size = PAGE_ALIGN(last_addr + 1) - p; - if (likely(mem_init_done)) { - area = get_vm_area(size, VM_IOREMAP); - if (!area) - return NULL; - v = (unsigned long)area->addr; - } else { - if ((fixmaps_used + (size >> PAGE_SHIFT)) > FIX_N_IOREMAPS) - return NULL; - v = fix_to_virt(FIX_IOREMAP_BEGIN + fixmaps_used); - fixmaps_used += (size >> PAGE_SHIFT); - } + area = get_vm_area(size, VM_IOREMAP); + if (!area) + return NULL; + v = (unsigned long)area->addr; if (ioremap_page_range(v, v + size, p, __pgprot(pgprot_val(PAGE_KERNEL) | _PAGE_CI))) { - if (likely(mem_init_done)) - vfree(area->addr); - else - fixmaps_used -= (size >> PAGE_SHIFT); + vfree(area->addr); return NULL; } From patchwork Mon May 15 09:08:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13240985 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 63965C7EE22 for ; Mon, 15 May 2023 09:09:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F3FE8900007; Mon, 15 May 2023 05:09:39 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EEF2D900002; Mon, 15 May 2023 05:09:39 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E0533900007; Mon, 15 May 2023 05:09:39 -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 D29ED900002 for ; Mon, 15 May 2023 05:09:39 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 2045181381 for ; Mon, 15 May 2023 09:09:39 +0000 (UTC) X-FDA: 80791916478.05.BA6FC5D 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 51892160016 for ; Mon, 15 May 2023 09:09:36 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=P7UXRq21; 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=1684141776; a=rsa-sha256; cv=none; b=dhpsMHvDxi4MJdxGNpEZbKKesDCW+p0rHEB2PD64xhG9Vth2kZqwMEBp6f+sRVOHEQ3QZ7 e80CxcPPPv85GsdrSNW25Sg3I+eii9JczUhyduG95/2FWKT7RQ5ANTAjOhUCWOnZcAz82c WOD9Oj0BEpht7WA9SHmcf+roUMOG/a8= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=P7UXRq21; 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=1684141776; 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=GS7DhM1WqHNM9FsA4uYO/JqR1nvbxtBam9rqPSjZvHw=; b=Ax/TTLB9Nxy0tmjHUK6dxgitk2hapwZ8X8bSBQ9XPjzlZ+Tn2bLOMRweGGuPfjJudMEaER OvOtDxpZVM9YiMuGf22DtLIDzjwlBDL1MNwyopVFA9hFboZa+Xn3szVRCfEB31i1hc0+ct osTIE+Q+jXBiKW7+/vQddAlUHroG8Yk= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684141775; 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=GS7DhM1WqHNM9FsA4uYO/JqR1nvbxtBam9rqPSjZvHw=; b=P7UXRq21qAUClhCmKrm+c78NG2f4zU3YwS8DgOME/oPO3SgoTsXhm1afi7j/qwEz0/7uvK 87kEmO4/lR1q41XLEy67GiG+aKOlATYZd/jv5oZsDRRVQF2OgTh47xUXEKHwxzpE0RSQTW Q0IEyj9TyDdbIK6ZEOV8yphzqgqvWbg= 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-252-hNrNbfidM3eGdxOGyRRvVA-1; Mon, 15 May 2023 05:09:32 -0400 X-MC-Unique: hNrNbfidM3eGdxOGyRRvVA-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 99AC6800047; Mon, 15 May 2023 09:09:31 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-32.pek2.redhat.com [10.72.12.32]) by smtp.corp.redhat.com (Postfix) with ESMTP id A2A2440C2063; Mon, 15 May 2023 09:09:25 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-arch@vger.kernel.org, linux-mm@kvack.org, arnd@arndb.de, christophe.leroy@csgroup.eu, hch@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, David.Laight@ACULAB.COM, shorne@gmail.com, willy@infradead.org, deller@gmx.de, Baoquan He Subject: [PATCH v5 RESEND 04/17] mm/ioremap: Define generic_ioremap_prot() and generic_iounmap() Date: Mon, 15 May 2023 17:08:35 +0800 Message-Id: <20230515090848.833045-5-bhe@redhat.com> In-Reply-To: <20230515090848.833045-1-bhe@redhat.com> References: <20230515090848.833045-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Rspam-User: X-Stat-Signature: t9bftydtbfx6oorpdr38fa5gkyrg97mf X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 51892160016 X-HE-Tag: 1684141776-201084 X-HE-Meta: U2FsdGVkX19IEBDx89FJJUuWhBxRFiMbYx5rCXrOnzgGEFQahnG0LWrYqLTgbCo3tU4t/cIroDyxBt6p4matXXSm+6zrR0Tc3ncBhHjksqgDL2c3r3GHN067RdGXONwZNrzJ7nnB9AjM3W5DCWq6wlp1sgx8GEmVYZikjHdorJC1Qc4D/j1NnzZxmnvpHELH4P2vx6VEuq3UW6RCi8z3BsnInnnfft/+PDZR4U+Y6X5HjNio/1Og3slzVwG3WTmuLnOKhhAoff1/2ax2o0KhQ6OLO//jyx8mQkhboJ4OM/oAjANdTarAGDV8Ss/aRNIXJAQgGXNh1bSdSQIdk9W4DHiHK3+Fo11NW68GRS5kkjyWrYhzbNOG2+awz4jqVFUq5YydnBbGcJJrac+I77q6+8Iu/BWtTVZbeM6zGOi/OAxKvhuWpj6xs1TNzZS0krpsRsNaAO/R8kahzeY2TcmE+sbL9PS/SQcqkzKPG/Im76+xOJr/GFSqwrV6KnxDsUAqtL3HMVYhQoEkjmhaT79p7CYfv5tK6waUneCh9LDFDqrsw0ng+vmtGrcicgBXl35fYolQnvLUAdCcfQNVuqqyYsV5Xnoe8builEWvwjy863DWxUqrAoupImA+UaEb7D7CxU3J31ep1JXb44PPyDUJ33JxmRxZzEi6UMq7OYgl91fX4gAOzuwowzX5Vgh2mt/qA8OUeRc/VOK+0RkGl/8Y/W+38V/f51Rxvwv98lY1qAn2ODMRhdjX+eDdHoZvXOHauP67X0BJXSS0LEjVUBNFgzKy4ncW9Q2+wOVEsNzgdL1W+FugbxSg+dKwbi6HUL8ukvd46Jv2Zt7TwlK2sgkzBHE1kgnsh/xdYoZsnUuMVEfjSZCT5OlIuY8HVDLlv3iO1qoj4ThJJCB4ZM+mxNAMan8o1xenfMdZt9X6tS904qrB13D4RlBpuFMogBOQ/wqcAOSCkdCFCq5saUS5SJ5 Wdzd/RDZ I7mm3RlhuiHG85ae22Qx7MfUeAmC5cx+Ek7GbIoRcg26FynbJFBEWNYLzvS291OODMIP3CVxHCGEOe8/ZG8Y/lPlpb28Dibdj+2Cl7WgfoYc4w0kcZAeCNU+xfq5XVIooqi4mVP2hn/NVR0pVtVgL9juj/Ys4eKMVDY2lVpCXVzXA9+6b0xHz4ix779Bx1p77/uA/pvcaS+gpiDYeiqprKp84M+Kw1SYBuM5IbUj6pk0euxslsUtE5vaJIGTro+49pMMUJvCOHTgMVL0BSQE6/F/k+A== 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: Mike Rapoport (IBM) Reviewed-by: Christoph Hellwig Reviewed-by: Kefeng Wang --- 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 Mon May 15 09:08:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13240986 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 490F9C77B75 for ; Mon, 15 May 2023 09:09:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DDF3A900008; Mon, 15 May 2023 05:09:49 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D8F7B900002; Mon, 15 May 2023 05:09:49 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C575A900008; Mon, 15 May 2023 05:09:49 -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 B829D900002 for ; Mon, 15 May 2023 05:09:49 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 45021161387 for ; Mon, 15 May 2023 09:09:48 +0000 (UTC) X-FDA: 80791916856.01.B7EDAFC Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf30.hostedemail.com (Postfix) with ESMTP id 77B2880005 for ; Mon, 15 May 2023 09:09:46 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=AK95B4Z5; spf=pass (imf30.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1684141786; 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=9r4k6GMEtwaHs0eyrctTCZaY/jYlipAlomuLvm3n9yA=; b=JexgMDuB/Ix87ZivJ7FEPLHaj/rVagbO4QCDNTCEEO3cTN6eQmjA1lSzssofbkl3Z3goxw AcIaBBjBLJwEq7BimHWZ3UFXwPhssEIfaidme65xd68XKUOqSCm4cazd4j9+SgnRqcPTrP 8o64UBSgLkUOFuusOkyhgm3NOkVtrPQ= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=AK95B4Z5; spf=pass (imf30.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684141786; a=rsa-sha256; cv=none; b=uF1F14VeV+MkZ4clyu3oaCr/wvgTjEc/z7jSWLnrItQMJMmQYhIfAZc8dRZhNfKDUGFGQg DQxUGdir2RWyQb2su1kk9IeHVtdf2z3E9xxHwPeFAE5Kr2lr9X7KfBann1mFjvUPMyArXb 2zwM8uiYTgwzTi7+4PGws1vWbZMbra4= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684141785; 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=9r4k6GMEtwaHs0eyrctTCZaY/jYlipAlomuLvm3n9yA=; b=AK95B4Z54lT+4iEpABOgnxzt9iq0zsv0fBMdvnjppaIr/jSEey6A+sEhwD2JMtgrwP143e TQy/Zfn8psuwturPiL729rQAq9fpLaVN/H7ka3VOauAgxVaAew7iDXpiNU6FQ8DXEwk8T6 NRRyLiLXFLUcPSSQy1+yQwnhPH7wd+k= 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-198-ytjTTgK7Oim1HJHE23zSuQ-1; Mon, 15 May 2023 05:09:39 -0400 X-MC-Unique: ytjTTgK7Oim1HJHE23zSuQ-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id BFED13C0CF02; Mon, 15 May 2023 09:09:38 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-32.pek2.redhat.com [10.72.12.32]) by smtp.corp.redhat.com (Postfix) with ESMTP id 542EA40C2063; Mon, 15 May 2023 09:09:32 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-arch@vger.kernel.org, linux-mm@kvack.org, arnd@arndb.de, christophe.leroy@csgroup.eu, hch@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, David.Laight@ACULAB.COM, shorne@gmail.com, willy@infradead.org, deller@gmx.de, Baoquan He Subject: [PATCH v5 RESEND 05/17] mm: ioremap: allow ARCH to have its own ioremap method definition Date: Mon, 15 May 2023 17:08:36 +0800 Message-Id: <20230515090848.833045-6-bhe@redhat.com> In-Reply-To: <20230515090848.833045-1-bhe@redhat.com> References: <20230515090848.833045-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Stat-Signature: igis53bgf4turwnnrm8ah3xogniio13x X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 77B2880005 X-Rspam-User: X-HE-Tag: 1684141786-233916 X-HE-Meta: U2FsdGVkX1+ZawIUwUMiL8H4GwkqQdXVgs8wFzHj5qo9dkktZnNSb/q3wHEABeDkanDcZeXDqwFewKIBcesihjR2veTdikPhARBCRxpwSzpwi4tgWf9ft0M1ioWW3h5lq74h6LfK9aFojGreeDG5pM6AXkF3EK9fyjPzgqqhXYk/6oPZkDpMdLNOoLZDjxjtMPcDrzmk9BV5HgTVGTHLJL8W5k+Qh8LvD843oAw0gPD2udtJujjeV8lH0GGAD9k7MTyslOoLxUbwzoE6VfK9ktNu7hMAhxuBo3jgb+7Mm/6b4sB31BHIS6k/X4kKesE1FnvV2XeqPKE3xoEn928ippzdEmlrsE4St2LEPtFQZvJGKJOjPaNtXGTOqSeqve9ts3ZzsrrshTC7x6to/rjY4481myjgIS050qmU6iN2W72OkxTZx3NDwcnA6Ijs6SF4ipb9VQ7m37pRakIe9lp5M68cQ5d+BAPXRz/hTeW0IuGHZnz2yYk/KAH2wdeb6q4hHdUsevJWBcwMTc9h5bLdHyxbTTYKkfa2I6cgMSZRPWsTPVK11dfqrdcZ65xzovimaXpAYYa3h3MY2L1rLhFgJHat9Te4rEFFqY4aiB9gCT6ThOUbhIG+Qs+vGOMd69qBv2MCI+eh9bVABfO9rWhRiRJLEd/Hs8Z9ZhF57ZTNX0jmkJWJZ7jRaGOvLt+0pT73LR9193/QBIj8kDjHd5tNaIMuh3UnES1/zP9yU83WetegGbyFe+3ldm68kIveGkWyePhomW41dfhx9fF2JtMuUtvHbMnGqKt003EGvZTAs9jPwWiJw4cRcUpHTsLIbJTUHnEXk0K3Qoy+QPqkEm24UZQ9WFiV77DZKvgl1qF+mWsPKZ/LPDcib8Hmi9H8KdwAEaY7Ln3O7ydQXqvSVKgq5DAh+zoHdYPaBdhAawXqxMIuexwupNPYxSViDNuiwFZZf2r1L8WugQzKeMgONy6 ZLP/myAY BNt6kfOhCcUr1c/nTTyu/Az4UO0jtNUSPy4BErZreKaN1oipneU6ek4HNbxlzkM0lRd3c3Th5MSJmbWf1eqzyJamhcjIghFtz0CDet4sg5nqRsihX9MK3hyj+FFqgmSL8yfXWntRAka8t5Kv6Scb0nFkgRUHKptOUF1KYA/78Tg9eidtjaoH+Q5FLNJbG+r+jrRT+Z8++wPngWsU0Enq74OWQryT5qYNm9caG8+y0SnFKbqwm7BLSHZ+J1D1V1LyDjPlu X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Architectures can be converted to GENERIC_IOREMAP, to take standard ioremap_xxx() and iounmap() way. But some ARCH-es could have specific handling for ioremap_prot(), ioremap() and iounmap(), than standard methods. In oder to convert these ARCH-es to take GENERIC_IOREMAP method, allow these architecutres to have their own ioremap_prot(), ioremap() and iounmap() definitions. Signed-off-by: Baoquan He Acked-by: Arnd Bergmann Cc: linux-arch@vger.kernel.org Cc: Kefeng Wang Reviewed-by: Mike Rapoport (IBM) Reviewed-by: Christoph Hellwig Reviewed-by: Kefeng Wang --- include/asm-generic/io.h | 3 +++ mm/ioremap.c | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/include/asm-generic/io.h b/include/asm-generic/io.h index 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 Mon May 15 09:08:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13240987 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 8CAF9C77B75 for ; Mon, 15 May 2023 09:09:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2BB92900009; Mon, 15 May 2023 05:09:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 24552900002; Mon, 15 May 2023 05:09:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 10C6F900009; Mon, 15 May 2023 05:09:54 -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 041F9900002 for ; Mon, 15 May 2023 05:09:54 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id A6E27141392 for ; Mon, 15 May 2023 09:09:53 +0000 (UTC) X-FDA: 80791917066.02.3CE8AE0 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf23.hostedemail.com (Postfix) with ESMTP id E1104140016 for ; Mon, 15 May 2023 09:09:51 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=QZdgSE9j; spf=pass (imf23.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1684141791; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=b04gx2CEsZva7MKdHssokOo8Q5KwYfP6QKwltziak5c=; b=XC8U31xP5fFLjHL6RzrHHB2MczvK+57cnrfGUBCjEu1AoK+fI7vBrPOVqcZOp2p9SP8dTL YAy5QpTEX3jWNQehhM7IH+SV0ivN7JfR3ikMIfUndkiUdp7Um8LsAheXJVfeHxhvNRBAcI q83YnpheD0LvEmf6VuMhhi4/9n4qgu0= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684141791; a=rsa-sha256; cv=none; b=mle6CbDksyb4/RI/sFYSHtVKdUmIAkJW4A6oiyeKh8LHCnE17DjFLPke6UtATW1UMdBPBj 2TapDuxKMGHiROJqy0D3i0JhBnoofc8mDSOO/OsYOoRDbiv5B6RsX004e1jhzYa0yVs2tv eTNBezvGvL4DH5kdYb5Jkyb7Rna3iQw= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=QZdgSE9j; spf=pass (imf23.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684141791; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=b04gx2CEsZva7MKdHssokOo8Q5KwYfP6QKwltziak5c=; b=QZdgSE9jS1uEt/JxSb4nHlkXJ4IXVvV8gf+xs3eX1CXqR8WnyhDsqa/5XMv/BJlBBWzRDH 5wbnrJ8GOq5xmBZbZN7H1umWaewUjSTfIFqrNVVAh1IJSrzHkw0eYJeX/LFofotC02AW4J rFF/wuCZk4/5rRVECGF1OqsaKQrdQaI= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-49-pgJ34I4-N4Gq1USkcYQgAg-1; Mon, 15 May 2023 05:09:46 -0400 X-MC-Unique: pgJ34I4-N4Gq1USkcYQgAg-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1C4503C0CEFD; Mon, 15 May 2023 09:09:46 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-32.pek2.redhat.com [10.72.12.32]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8FFEC40C2063; Mon, 15 May 2023 09:09:39 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-arch@vger.kernel.org, linux-mm@kvack.org, arnd@arndb.de, christophe.leroy@csgroup.eu, hch@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, David.Laight@ACULAB.COM, shorne@gmail.com, willy@infradead.org, deller@gmx.de, Baoquan He Subject: [PATCH v5 RESEND 06/17] mm/ioremap: add slab availability checking in ioremap_prot Date: Mon, 15 May 2023 17:08:37 +0800 Message-Id: <20230515090848.833045-7-bhe@redhat.com> In-Reply-To: <20230515090848.833045-1-bhe@redhat.com> References: <20230515090848.833045-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Stat-Signature: zikbpypumcrbzk9u5gkxnh3s5n3keki3 X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: E1104140016 X-Rspam-User: X-HE-Tag: 1684141791-522145 X-HE-Meta: U2FsdGVkX198EA6ld3/uFckmkG1TkgMbGGK6MW+ExmAERVKHIilhxDYeQ6n4myifXXhXnLrGgCKszXIExggz0t3AApvvuZgFdio03onkgwNu3nyVpKskJ8xbMMmf1bb+FWKyq45YN+YPVj5kr6yd3K/hMWejT9J3N06teXwbjXxy+rVNtbWJ4GOSiLsdons0N89yLRjok5gyQDYQnv1FklbRHRG65KIi3bHwRSmIQLh6tVQTC9mf56pokDHLS6K8CFwb+7fJ7DSyhMAcDTzRYn/3tbEqfPJlSQT5+JV7MRqpX44LXZ0BdlreeeFKed/9d28qmGEauP/OlejdpFYmYb/YyrF2wRinAg7ilI7FL7NDkU/kW+oFu5h2DlCsN1z0j287IVYWv2W5e2T9IKjI9jxQgeZCrVe+45CLV6wSCGNNjvGwT5GEm5VyfUjitI9QkpOl2jSlcRI0b9pWzwgdPSiA6xlcYhzkMsBUh7BYhfkvfvn9qn7px6PcELyxhC/VnoQwcsYMy9JgcoJsGutTA75KFkj1UbSQA6qf8cTpJ4jRnO3pJ963AXC5arNu7ltieuia6E1XYBJShKnVvwlA884cvl8lQcgs4TCGyr+4aFFl1SXX0tZMyePRSu1R+RD/rPmvw7P1LrV03Smqw/w9air/3jthMM71h+iZaVhuVAALLLKvdEFIcmUB1jofw6TKyPLQc7hbBYG6XK99x/XYNMkWqd0q4l0aKqoGkAHbS58hK7UJ95CoY1+U0Ga3R51nWgVdEZfIccy+TI/9w7PFC/O/sZmxg+hED3+ZJphTaxr8Ubcrb/WxUgRiO3f2W83F5HMjDMyv8JV3Nb9eI0YTpLHOJfMgj4UOzD40UrAomd6dglPj4V52kbG6M9D6n2Efrw8yS47S0fyN4rWm3cWUFzluM3k64Y45Aa3hg/RPBWOyKO7TZj6HSDBMCgfGS8ukfAPuEG16zJZbfp7+Qus CGS/Tdrh h5sow1qwGCUjD+4eyDpvGCYVjvTbmZ0hD/AjtYg1IbcGJkzuiZGhrqX3H19EBZXHk/CeElT8ZTUuhYq2mAJiKN/1RfAkwczny9KGKqTGclKbegjnSkemzbi/6v5Vphbm9eLDYwwwiozctQW9/kPfvVTtxagDz5zx4z0az313fz/zESEIwkWqphbKeHT+lQ2WxD7PEBMa+LVJDy0S9QW62180UhH/TmekKoH2KGfeNq3ulPvK97fuuVBhNPjHrvM0LeUoxjKxPiJvevTlzTvgZypA5tIgCiPLS8n304DmAOaZQUJg= 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: Mike Rapoport (IBM) Reviewed-by: Christoph Hellwig Reviewed-by: Kefeng Wang --- mm/ioremap.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mm/ioremap.c b/mm/ioremap.c index 9f34a8f90b58..2fbe6b9bc50e 100644 --- a/mm/ioremap.c +++ b/mm/ioremap.c @@ -18,6 +18,10 @@ void __iomem *generic_ioremap_prot(phys_addr_t phys_addr, size_t size, phys_addr_t last_addr; struct vm_struct *area; + /* An early platform driver might end up here */ + if (!slab_is_available()) + return NULL; + /* Disallow wrap-around or zero size */ last_addr = phys_addr + size - 1; if (!size || last_addr < phys_addr) From patchwork Mon May 15 09:08: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: 13240988 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 3BF5DC7EE22 for ; Mon, 15 May 2023 09:10:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CF45E90000A; Mon, 15 May 2023 05:10:01 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C7D9D900002; Mon, 15 May 2023 05:10:01 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B459A90000A; Mon, 15 May 2023 05:10:01 -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 A6269900002 for ; Mon, 15 May 2023 05:10:01 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 733CAAF4CE for ; Mon, 15 May 2023 09:10:01 +0000 (UTC) X-FDA: 80791917402.04.D732970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf27.hostedemail.com (Postfix) with ESMTP id B40834000D for ; Mon, 15 May 2023 09:09:59 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=c04fBi9G; spf=pass (imf27.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=1684141799; 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=kDNjnaCpF+GTSorypbQb9IveRvDAN3hj4EIuzc2cJxI=; b=oHHBVVJWuAfBvDwWXmVNcB+U+iHy/HHXCDXhQF63z5lyqTgIJKIOKnext13OSLAKKeqe+k ZCkPdBKFPK68V//EIylaWW+9HDVuMICeazF8r/zG7A6hRVFGjM9gLQOcBVrLSkVtoCxMiL SiRKZUV4XpdrHm5zU7ex8yRLq7vtGSg= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684141799; a=rsa-sha256; cv=none; b=uJxxHrfJQ4g/45btbEhOeWtg9/5boeGeD+i/++byjhsaTeiOa78IHDaw/cX2CkJt/H7LXQ vfJvDwZXOTDXwkcDSa5vkiTWrj3YONuCK1okPJLAT508xoBxpJWrncNHTjndiUUuXO2hEK dfSoT5nifO4DraTnaxaJKQyy1SEdAqw= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=c04fBi9G; spf=pass (imf27.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=1684141798; 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=kDNjnaCpF+GTSorypbQb9IveRvDAN3hj4EIuzc2cJxI=; b=c04fBi9G9sNCVxM/wP03C2GEXXVmeyC7STgI3vnltnc9SaGM30fdjp8bUwXlqW0tyuq7Nv ByEPv0tU5+oApHebNrM5/8O4oXtidrJoaEsT9RIxDKNdy1rd/mxgTrT1rS+M9J8o/EKKOw J7CfjLJ3LFnoI4kZtTUCzYiWAJPx7SA= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-659-pMEw_n4HMayxwlRnEJbtBg-1; Mon, 15 May 2023 05:09:54 -0400 X-MC-Unique: pMEw_n4HMayxwlRnEJbtBg-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B45E73814945; Mon, 15 May 2023 09:09:53 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-32.pek2.redhat.com [10.72.12.32]) by smtp.corp.redhat.com (Postfix) with ESMTP id D2F0940C2063; Mon, 15 May 2023 09:09: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, christophe.leroy@csgroup.eu, hch@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, David.Laight@ACULAB.COM, shorne@gmail.com, willy@infradead.org, deller@gmx.de, Baoquan He , Vineet Gupta , linux-snps-arc@lists.infradead.org Subject: [PATCH v5 RESEND 07/17] arc: mm: Convert to GENERIC_IOREMAP Date: Mon, 15 May 2023 17:08:38 +0800 Message-Id: <20230515090848.833045-8-bhe@redhat.com> In-Reply-To: <20230515090848.833045-1-bhe@redhat.com> References: <20230515090848.833045-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Rspamd-Queue-Id: B40834000D X-Stat-Signature: 3w4gmej4m1wqom1mfmjs1nyjst8zcift X-Rspam-User: X-Rspamd-Server: rspam09 X-HE-Tag: 1684141799-710033 X-HE-Meta: U2FsdGVkX1/INJu62SUExeSDchtrHni7iPu3IbOTD9LdHdVFjJ3MF3I50Xl4f1ZM1ceE6cvgxOqORtJ7vefrNlHQoHZ1bsBiEDCEVeLsCPsjINS6NLnWtwjrt01HZeszUvm7AvdbeN7v0PjJLARh2wk94233N7owksQzAQRcdhsq5lHVKdV5mzaKfvW0fX/aS46633fdgoUFA3txulKCEhm7wO6Fa2VDu8NoYTy2vBVI4D/nqrzXgb/wUJnPMfxhHD5ic8f7MlCdzUAcPu7bXOmP9AHg1YJsJ/ZbsdfKajw2wJvEFvQZ6CtP7Fb0kHiQjr+U4oQB6rjr6PvJAwLocOLVR6doQNshTrOncd5cK7355OvYsKuVEcPmgWv/pMCpY4BVi4gPeBjA7R4Hw589sgWiDwrilDJ03fJ5VpsfcOUOq0mWyD1XQJCLhhoz/IB+6VYivpbbOPxiOexYkldUomYMPC+qvLngHQOBO/qFBMgNfAqFnkefy5dMxVVwo7BIGgZdzacx/VHgpZGM/ZHTMoZ/6DVuD7u6CvdAaKrR9+0C4M/mWjq5U7V+QZju6h7kNalqaTx4UDdjBJbtPnJBy5mcFb4R5fWJvsCWwwkOCPZY53jPX7QTXbtGmRQtmpK6jA8Ml2Hg4ZY5mRJR2im/RdjjYDZhd4JP73YrJuOZq2aKbTDnuq+WYNne2M24IX3UnEMpaeZcpWzNA/dYTuuBNQs+pFfQbpWXMV5Xxzm1aIqtIqQvNyhn46yaKcPeRBvh0k7Wo6h/lUyOphv4pDEvUPWTmj+xOCkEZECN+Bd9MJ4Sm5aK10NoFNJoL+HSfkjkJRxmuYNxCVyYV9NCxRoH5ON2aCl1fqn0Un875RlQinQ5+EQbtxyTf337rAixoi5vjvpoijjyqEDgqBmOBZTGd0kYXIwzKg9di5khNrTfo1OAjTDd0On0sS8RfZ3mw2NXDqslr3vr18dVBVQUkRw IGf+L6zc I1eida9SZq5k3pFVmOacVYg3iAqySfPFEP4WUM3osKU5d5pEdg5QwYqXC5AHm+sycUqX1vECIhBzCi7A5friEy1B9jpO0GgwUdcuZ4N6JDT724Nv29/nKMipyZ6cXfITKEvt7XabFlTnDH1ecFlAnxPzksBujoizBgqHxo98OC1Ujz+DjMjRVAp8ctQKCW7oUJ9tVn4lxMAfC/W81P2nhXb2s9GxsaueZvelvzrJc2EjuRXoKaudlVqXf4c6r48IoeLbgijbxjw3oWz2SZsXM1RdoMuI4BtgzIws0ha4TI00NDa2zaVkdM8dM0cqUrMiGgW+p+TnIDQOyjEiNqc+JytZImw== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: By taking GENERIC_IOREMAP method, the generic generic_ioremap_prot(), generic_iounmap(), and their generic wrapper ioremap_prot(), ioremap() and iounmap() are all visible and available to arch. Arch needs to provide wrapper functions to override the generic versions if there's arch specific handling in its ioremap_prot(), ioremap() or iounmap(). This change will simplify implementation by removing duplicated codes with generic_ioremap_prot() and generic_iounmap(), and has the equivalent functioality as before. Here, add wrapper functions ioremap_prot() and iounmap() for arc's special operation when ioremap_prot() and iounmap(). Signed-off-by: Baoquan He Cc: Vineet Gupta Cc: linux-snps-arc@lists.infradead.org Reviewed-by: Mike Rapoport (IBM) Reviewed-by: Christoph Hellwig --- 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 Mon May 15 09:08: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: 13240989 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 584E5C77B75 for ; Mon, 15 May 2023 09:10:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E7B7F900003; Mon, 15 May 2023 05:10:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E2B7E900002; Mon, 15 May 2023 05:10:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CF35F900003; Mon, 15 May 2023 05:10:05 -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 C2D3D900002 for ; Mon, 15 May 2023 05:10:05 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 91764AF4CB for ; Mon, 15 May 2023 09:10:05 +0000 (UTC) X-FDA: 80791917570.10.C2A7879 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf12.hostedemail.com (Postfix) with ESMTP id D2DBF40009 for ; Mon, 15 May 2023 09:10:03 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=R9bTmHDN; spf=pass (imf12.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1684141803; 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=Be3YZPYQKe3fVhwvu6S3wHOgSricTE7yqKPORN0fijw=; b=c0IeqDcG2nDBQpdiCsfol5kyIrdNK4GZF/Wl83CFc8kuZZo8kBhjzHSByhHY9frgSsfjxm YxJnYFdLDwIcFwz2LB/fWnIEVVarhKd+gYiCnqqdJBBEelschyz3IsBES//AWp3OgvzC4j xuHJ7SywDeqC7UoSUvqIadtCfOVxPHo= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=R9bTmHDN; spf=pass (imf12.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684141803; a=rsa-sha256; cv=none; b=VThK4sPPlKSKC8f/+v5RKzFW91PuFYNWV2N8GRsMtvXEAbE5LDnd+DLpfSoxWPK0vLIh25 wf5jK/O1dA452Es5Sk4NrLHWMeMpq0IXrpsYeMVbRlYA/HDsmuR0BSik/EAeKDODN1IyxK d/NQagxp5xNZMX+PcjOC4ALtKuhoquc= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684141803; 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=Be3YZPYQKe3fVhwvu6S3wHOgSricTE7yqKPORN0fijw=; b=R9bTmHDN6WDT7+be8GjX+BGLTwaF6IRsGWwRfQe8pYEjMtbcTTo3th5IcCZ+m60wjZYIIl ZoAWIrunUNlCp0KNElDAS5fgb48+cH+WEdU4LFJH0oo96NJ7JgcZuU6SMhpgzkSa/9zvps 3AWjDj0pJgUJHXU8tAYBtSjGK9RVRvY= 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-550-OwQRqC1OOXG4zvhgV9a-lA-1; Mon, 15 May 2023 05:10:01 -0400 X-MC-Unique: OwQRqC1OOXG4zvhgV9a-lA-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id AF28C3C0CF02; Mon, 15 May 2023 09:10:00 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-32.pek2.redhat.com [10.72.12.32]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6B0F940C2063; Mon, 15 May 2023 09:09: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, christophe.leroy@csgroup.eu, hch@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, David.Laight@ACULAB.COM, shorne@gmail.com, willy@infradead.org, deller@gmx.de, Baoquan He , linux-ia64@vger.kernel.org Subject: [PATCH v5 RESEND 08/17] ia64: mm: Convert to GENERIC_IOREMAP Date: Mon, 15 May 2023 17:08:39 +0800 Message-Id: <20230515090848.833045-9-bhe@redhat.com> In-Reply-To: <20230515090848.833045-1-bhe@redhat.com> References: <20230515090848.833045-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Rspam-User: X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: D2DBF40009 X-Stat-Signature: 7pteuugh6j1p469jimgp1jzbuuxe6xyd X-HE-Tag: 1684141803-422692 X-HE-Meta: U2FsdGVkX1+gKt69uyuc+H1Dj51kw5k0VUMWYz5eS/q1f5/R1pG6yiDbSLkyJTeyINp+dWMAYUaD0kuYw7eXXkVofdp0vC+5Mv3t1nKHBmqKP2lKZa3Njr/lOGJlIVQb0mtQyy1bPNPBIwQhLk+/uvFx9c9h4sbyDUfwOXMV52fRNt+5SlRM7K040mOSnGQVuug4+Ux2NZrFpoRYkzqS3d3k62fWyxV8zziNUM5BQgMvVfPxkTmPEbr//UtAKqcpoy8gOcMwHcq3+Eu98NXRIUZfnTQMQbzbzU6215FMv9mH/pB9hupwlrx5Jjlyc8lYsYFm/PwVWA6MCaUu+eoGvJumAIGEZj1QfrbX+fkfjGSU8SCisq3JPAyFXcy0SP3xYGnSUXuEBWVvqM58YacNQ1xOiqLyJ23/y4zkYM8PHFxCroTqkrRQ5x73Db1imzt+2uawDloT8YlWHE4CYoIqWztDr4ndLiZTflDuZtAXa3qX1CX3rgBTE9PioI5q9JHeyKIZKFWuw9MaLhfk+oJMk6r2ige4JRmW0hSJ1aIGylK328IL5M4Sx9N6tEKpKtpa2b0WSWnREj8EkcluMJ70WouyP+Qm2OPmIQWF8yyVExQQpN0DDqT4A9jdiANnfWSdF1DqTZoCxmtHCtGW/4XgunAkqmwn3tItRMss84ChxNDHuWqepYGcsEpyiys+SZpLccB6HQJxvO1LgZMecSr8mohnL8UTD5LhbGffl+iJyobmeYnzTaPdqh5XM/MslQTcedmE5Z9YwJQxovs0PlP31u4JV2sTFVlfxWw2VvLGRnLlX7wisqaBjbZ9/9gAFd8YEdfh88zE5+r7GDbcJXytuDXoI8lDBY1NJRcP4TCO9jwzDVOxWxjtqU8qkZ8tQCcArIDTsi4P8TGqFjYblNyqMS4m200PT22DW3nAmFjc2xIW41xht7Ea/L1R15b5NQUBPn9uXuzGDlL9+LcxR+5 EMMJNA8X FZRQb+0APHR/NZZrSLWy6Y+KxgUVqy0w8G08BPOxZB1CDHF2n521LRAJGrySYIgAM9MTz6yjYKGIggSRoQeaGHR4USLwcpknSpCUzO4vIKZk824dcBnEWhzAUQTbrE44m8HNNSkki4BIy1JqahcYgti0l5cmRHKwXVkfJTUanO1OfcaVPSK42tnxaJBRimuapmXOFJWtDwMclmRBiywMZHkhZ73vVIP/yPaYxaAnW9P0mcsi04avkN5//AjS2oYwQLm0XditHe4Vhztethl4SFhIZIA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: By taking GENERIC_IOREMAP method, the generic generic_ioremap_prot(), generic_iounmap(), and their generic wrapper ioremap_prot(), ioremap() and iounmap() are all visible and available to arch. Arch needs to provide wrapper functions to override the generic versions if there's arch specific handling in its ioremap_prot(), ioremap() or iounmap(). This change will simplify implementation by removing duplicated codes with generic_ioremap_prot() and generic_iounmap(), and has the equivalent functioality as before. Here, add wrapper functions ioremap_prot() and iounmap() for ia64's special operation when ioremap() and iounmap(). Signed-off-by: Baoquan He Cc: linux-ia64@vger.kernel.org Reviewed-by: Mike Rapoport (IBM) Reviewed-by: Christoph Hellwig --- 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 Mon May 15 09:08: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: 13240990 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 D1FE3C7EE22 for ; Mon, 15 May 2023 09:10:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6D9CD900004; Mon, 15 May 2023 05:10:16 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 68A52900002; Mon, 15 May 2023 05:10:16 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 55229900004; Mon, 15 May 2023 05:10:16 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 488DA900002 for ; Mon, 15 May 2023 05:10:16 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 217C5C13FA for ; Mon, 15 May 2023 09:10:16 +0000 (UTC) X-FDA: 80791918032.05.5C09F2C Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf05.hostedemail.com (Postfix) with ESMTP id 4E60810000A for ; Mon, 15 May 2023 09:10:14 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Wn2b5z3Q; spf=pass (imf05.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684141814; a=rsa-sha256; cv=none; b=xPpgmTg+7yXMeYgxavgs1y3YOJ/JqzmrnOSpeuEumSi0sceDPAfhPZAzGOLvcElL1vWy6T YBXJLwE61xmRoFAZkFW8l+k2bHOS04Ah5nn0VRt0yaBztuiKbUsmIzwXgr31+FjvUGUl6M 4rqVDXkzvYiCNkR53AY9FPSU1vGHREc= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Wn2b5z3Q; spf=pass (imf05.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=1684141814; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=K1VrnQks8P5H4lhuQHdk0PEcxF0GSibhsi/oBTknLWs=; b=azGzfmfDWLXQSsWgcDLG3oWZvZKGLsUd275x0CmbinpCcV//W5e1BTH2RRbq0iD7+5atAp t39gB4bccHMiLzWmTJUmdasCPK5ZGYdq5PHq14vQITuU9yhUUpWnJ38Meou+h3pyJKBYJO rNW4R2lbOGnjPscDBWDVjYBmFCcAGoI= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684141813; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=K1VrnQks8P5H4lhuQHdk0PEcxF0GSibhsi/oBTknLWs=; b=Wn2b5z3QOyc3hb6IhqhnWrsu3k6idbMNXspfxVzOX1gCfJHvsPhM22aXrteEQlgQvymxwt WPIskmz0Emc3O6oL9g2bUb5OEWSpUHSqdh+CqD0g8+A3ZQHzmj6lhxo4piUCmaeF1pZQnD rqSMssrWND3MY/P0SegGYSzW2tsudZU= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-361-8VhVlINrMUqFbBxlXUrf_A-1; Mon, 15 May 2023 05:10:09 -0400 X-MC-Unique: 8VhVlINrMUqFbBxlXUrf_A-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C6DCE380671D; Mon, 15 May 2023 09:10:08 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-32.pek2.redhat.com [10.72.12.32]) by smtp.corp.redhat.com (Postfix) with ESMTP id 646C440C2063; Mon, 15 May 2023 09:10:01 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-arch@vger.kernel.org, linux-mm@kvack.org, arnd@arndb.de, christophe.leroy@csgroup.eu, hch@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, David.Laight@ACULAB.COM, shorne@gmail.com, willy@infradead.org, deller@gmx.de, Baoquan He , Jonas Bonn , Stefan Kristiansson , openrisc@lists.librecores.org Subject: [PATCH v5 RESEND 09/17] openrisc: mm: Convert to GENERIC_IOREMAP Date: Mon, 15 May 2023 17:08:40 +0800 Message-Id: <20230515090848.833045-10-bhe@redhat.com> In-Reply-To: <20230515090848.833045-1-bhe@redhat.com> References: <20230515090848.833045-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Rspam-User: X-Stat-Signature: y6jasc1bbiq3e9q55kf6hf66j9phbgwx X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 4E60810000A X-HE-Tag: 1684141814-550701 X-HE-Meta: U2FsdGVkX18AVSuwxTErakbm3xrrvdA1FosdMp2f0KLZVcyUUUwPtWK9fK95PrpniVPqqRtww4LqVctDqhL4B7ckcsBSlXUeEBHBGrvpnaUcRxl+mrEHQaVCAHZL73udqA52FWolOf8qdFE5pMUQbdoZagSrSPW4NARpU3ukDP+hVV9LkJahSbTbOgEcGKfiKxZ59kGRSRHJzfGkg2RAtC87S3mbGxoXgBhTDu0kMfn3zCXn4mEBxXP2LoCOLaqdTRzLVipe9iTLZrcN3pnfc55qx2m1rpGy84H3NRTbef/nFUvY1EZ3t9KiP3tgvCPOMim24laoZTe4WwKmmCMO7pzM5MmY8W8Vm7mvOOhJ/tYQbj9TQWFt01PG5z7zs9lmoXkAyyxGJ4SFGulOOqJ4LqACWaFx8IRbMdEglE0kfmoaZdKnk70h+a5fS8yU27gbiq7x3fEAbeigZxM3Ll1oth3WxShLM42+RQaMos5L/isAtet5fd/jJH4W4oIuyPwA/imC5N8FVWBuPB7gmYZVq1eT++IJeg79aQUrSxLfrwJ2WwRrrQ2buAkU81a9XePRwrJC6APMQV3Js2PfD3BZYcBgdFpAfCIWfCJ9Lgnz1g29juWcUmdsdxhY0k5B++c6Rsi3oqR9Fl3ax+PoIZsB4fFvQFg7TKQC/4VLxNekLkpWaeBXBrIFk0jrmhN+5HgsQqoFFZVA7Na0q8+YkSMQ/iSeBsb/34xrMjIfK+0tF2bBh1P4Ehhh8laNpqF8h2wTm2Mp/zwqESp22kDdQbYRQsp9tCEcgGelARPfcn4dZ4x3+20IZHzcXCvxqlNj/Ue+dC6k7CpiRS6HJFPaDAJrKd7A3FyYcp8DtYYUNbyJH82nXDBKe6UMJkwu4F07qErZZt8C44tiVqIe1M7hcBM5Jf07gwphbL730eBATAKqCXrAI2Qkg0g64b4z9ogUmpz/xqq4vsnaHpVVoUwwhS9 yhL6k49L PeX1HqyD5vrgOdRrKMf57rqS5oWSIvZEzZD7mMIj0VRlJ2I+44ePtbd1DrSFfMtZ1t0tnQQCOyUIOB70v0ZONi3+6ACVfxbOMWxvwUtDWjZZ4SjdE/19IGbofOmfvJLsk0t7c9qR7cAMvsRJREC544r0smEDu9nGW/wElLIaZIoLt/c8Gbfj+KtY0GWGKbS15CRHyBiyUkuck3YeiuGJvQRVW2XTIT9v/cEd2tsmFtyfy+79KQHbKRG58OKVcO3xrPQyus9KD0GpURhLulFWldpXmQMDO9mIvBztpelvl+itPLzOA9s/v9DVAXA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: By taking GENERIC_IOREMAP method, the generic generic_ioremap_prot(), generic_iounmap(), and their generic wrapper ioremap_prot(), ioremap() and iounmap() are all visible and available to arch. Arch needs to provide wrapper functions to override the generic versions if there's arch specific handling in its ioremap_prot(), ioremap() or iounmap(). This change will simplify implementation by removing duplicated codes with generic_ioremap_prot() and generic_iounmap(), and has the equivalent functioality as before. Here, add wrapper function iounmap() for openrisc's special operation when iounmap(). Signed-off-by: Baoquan He Cc: Stafford Horne Cc: Jonas Bonn Cc: Stefan Kristiansson Cc: openrisc@lists.librecores.org --- arch/openrisc/Kconfig | 1 + arch/openrisc/include/asm/io.h | 11 +++++--- arch/openrisc/mm/ioremap.c | 46 +--------------------------------- 3 files changed, 9 insertions(+), 49 deletions(-) diff --git a/arch/openrisc/Kconfig b/arch/openrisc/Kconfig index c7f282f60f64..fd9bb76a610b 100644 --- a/arch/openrisc/Kconfig +++ b/arch/openrisc/Kconfig @@ -21,6 +21,7 @@ config OPENRISC select GENERIC_IRQ_PROBE select GENERIC_IRQ_SHOW select GENERIC_PCI_IOMAP + select GENERIC_IOREMAP select GENERIC_CPU_DEVICES select HAVE_PCI select HAVE_UID16 diff --git a/arch/openrisc/include/asm/io.h b/arch/openrisc/include/asm/io.h index ee6043a03173..e640960c26c2 100644 --- a/arch/openrisc/include/asm/io.h +++ b/arch/openrisc/include/asm/io.h @@ -15,6 +15,8 @@ #define __ASM_OPENRISC_IO_H #include +#include +#include /* * PCI: We do not use IO ports in OpenRISC @@ -27,11 +29,12 @@ #define PIO_OFFSET 0 #define PIO_MASK 0 -#define ioremap ioremap -void __iomem *ioremap(phys_addr_t offset, unsigned long size); - +/* + * I/O memory mapping functions. + */ #define iounmap iounmap -extern void iounmap(volatile void __iomem *addr); + +#define _PAGE_IOREMAP (pgprot_val(PAGE_KERNEL) | _PAGE_CI) #include diff --git a/arch/openrisc/mm/ioremap.c b/arch/openrisc/mm/ioremap.c index 90b59bc53c8c..9f9941df7d4c 100644 --- a/arch/openrisc/mm/ioremap.c +++ b/arch/openrisc/mm/ioremap.c @@ -22,49 +22,6 @@ extern int mem_init_done; -/* - * Remap an arbitrary physical address space into the kernel virtual - * address space. Needed when the kernel wants to access high addresses - * directly. - * - * NOTE! We need to allow non-page-aligned mappings too: we will obviously - * have to convert them into an offset in a page-aligned mapping, but the - * caller shouldn't need to know that small detail. - */ -void __iomem *__ref ioremap(phys_addr_t addr, unsigned long size) -{ - phys_addr_t p; - unsigned long v; - unsigned long offset, last_addr; - struct vm_struct *area = NULL; - - /* Don't allow wraparound or zero size */ - last_addr = addr + size - 1; - if (!size || last_addr < addr) - return NULL; - - /* - * Mappings have to be page-aligned - */ - offset = addr & ~PAGE_MASK; - p = addr & PAGE_MASK; - size = PAGE_ALIGN(last_addr + 1) - p; - - area = get_vm_area(size, VM_IOREMAP); - if (!area) - return NULL; - v = (unsigned long)area->addr; - - if (ioremap_page_range(v, v + size, p, - __pgprot(pgprot_val(PAGE_KERNEL) | _PAGE_CI))) { - vfree(area->addr); - return NULL; - } - - return (void __iomem *)(offset + (char *)v); -} -EXPORT_SYMBOL(ioremap); - void iounmap(volatile void __iomem *addr) { /* If the page is from the fixmap pool then we just clear out @@ -88,9 +45,8 @@ void iounmap(volatile void __iomem *addr) return; } - return vfree((void *)(PAGE_MASK & (unsigned long)addr)); + generic_iounmap(addr); } -EXPORT_SYMBOL(iounmap); /** * OK, this one's a bit tricky... ioremap can get called before memory is From patchwork Mon May 15 09:08: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: 13240991 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 8B10FC77B75 for ; Mon, 15 May 2023 09:10:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 21EC0900003; Mon, 15 May 2023 05:10:28 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1CF15900002; Mon, 15 May 2023 05:10:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 09739900003; Mon, 15 May 2023 05:10:28 -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 EED7B900002 for ; Mon, 15 May 2023 05:10:27 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id AE48A141363 for ; Mon, 15 May 2023 09:10:27 +0000 (UTC) X-FDA: 80791918494.22.8E821A6 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf13.hostedemail.com (Postfix) with ESMTP id A00ED20006 for ; Mon, 15 May 2023 09:10:25 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=A8qEwoR9; spf=pass (imf13.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=1684141826; 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=fY3gRwzRURcZWtcbcQurri6vCUgFw9upurCvoIMXj/I=; b=T/ixe8l4ZBIy92ucOZue9CNqIz9YYGIswnPM/8r0qOA4iuzVLYQykOEutKwlkLIY6BtV// pTrnYNBuRGhwT6Gmzg6rpq/u1A3KAeBDgGerRxSxDDunTnkp74UUjQSPZFEMqU3GGsKX3m OzA9Y6P9roVwLkaQKjMAwStiGtIvpcE= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684141826; a=rsa-sha256; cv=none; b=AQ/kbFu1rG8bjoz/xrNc0Wb0vuDUdyYw2IBjTpv858zI6GSHQB4Si8nLbOsLacz1X5Rrg/ 8x/gfglSNB9BwhLZP7FszUr72BAzu5YQ+ldZFgkybEKPDIfnjFDUX2fPYARgr5WMAiihMC 4ql6gZajC3Z4NYB8actKGPSTWTbpfMs= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=A8qEwoR9; spf=pass (imf13.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=1684141824; 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=fY3gRwzRURcZWtcbcQurri6vCUgFw9upurCvoIMXj/I=; b=A8qEwoR9pLww2leDUJo7SnkbKv8GBxElXk0Ba+IP7zo0iFaefFi8WreiIj5jWdwz/9Wila 0hHO5wbTV9NUUIYVS16s4AUzjmwjfUk9SSLdoEvMKlE4wAKrDtj7rHJzWc4ncuHTF7LjdY QB1E5xLNoMn++B7/AxK+3+I+ywP4O+k= 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-609-gB0tK1tDMqSr0rE7U-c66Q-1; Mon, 15 May 2023 05:10:19 -0400 X-MC-Unique: gB0tK1tDMqSr0rE7U-c66Q-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 20D8981DA1A; Mon, 15 May 2023 09:10:18 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-32.pek2.redhat.com [10.72.12.32]) by smtp.corp.redhat.com (Postfix) with ESMTP id 91BA040C2063; Mon, 15 May 2023 09:10:09 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-arch@vger.kernel.org, linux-mm@kvack.org, arnd@arndb.de, christophe.leroy@csgroup.eu, hch@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, David.Laight@ACULAB.COM, shorne@gmail.com, willy@infradead.org, deller@gmx.de, Baoquan He , Gerald Schaefer , Heiko Carstens , Vasily Gorbik , Christian Borntraeger , Sven Schnelle , linux-s390@vger.kernel.org Subject: [PATCH v5 RESEND 10/17] s390: mm: Convert to GENERIC_IOREMAP Date: Mon, 15 May 2023 17:08:41 +0800 Message-Id: <20230515090848.833045-11-bhe@redhat.com> In-Reply-To: <20230515090848.833045-1-bhe@redhat.com> References: <20230515090848.833045-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Stat-Signature: 6rcetsb5u37ukczbabpjjkcuk16f68s5 X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: A00ED20006 X-Rspam-User: X-HE-Tag: 1684141825-231283 X-HE-Meta: U2FsdGVkX19H2aLBJdVLAIHWSmjrsOZutxIC7O+7ZYy5hctnTQd/c/N7QvIDn4l5eLDIkM6tQyJIyqpcE4o7mVVLruUfMtxo20U2Z+vv0scXjJs7F63aOO44E+t+3UkgiWSfcCkkleLv4IlaZU9PAfhLpKHGUIq2guu4cw6+BLEfQlE2zdGzsr48VsQm7HuUFVrduNAkRbdKEcz4AJIGD80zEeamhQqYHK2G4j5LeEvgpfBlH5lRi8vdWrkMl3/JOczGaYZCTm6TYf6FFn5KWCGZA1edrMNgnsH0pOn3NBmzqzJ2d5Lncygb5pjNwY7DcmbNBx1J4g6R806ZJu9q8BrPXbq/AxM9MLf6Gi2cwMhe/7DNSQQimLOqO/VD4P9+7pck9PyBrvvgCA65LmwS74mhcZRFUew5iQLkVUe/kD1CO7u7JNxt8tsOFXSK5CvqrHKz0v7EgvJC2RYHDR3Fm9lxHXiik8mST75JBTNmZJ45z2Z0AuejbAlMlMOqlosUbtkZh6AB0Q+/yOoZxNKmJe6WVfr8e7u/w2rJfoBY03YekbanWF6f7rF1Rh3GhAJcSzaLicyZmyFYtGHGk4AKiZML+4YKID4wTynNxRzpCWNpLQpjWH7gxI7w8P/TURixZ/bEkMOnTNMTZC+pMOnSpw5MB8gmU6KY0rLaXL7SdDu2E5vKnQTrxPqSTA85Lv28/UPwG1JJcc1q030I5MIisJ4xeeFUcmgOEHUTa/i5NpLlDGOHMGkWsw0BWHvr0Nw8eQX2Mk4/YVTfP553Ky7Qp8PtohAuqu1cLHtjN1fIgm0XTTXhGgULd7P1pFQZStplec7kCIaLoJBrXrP7v5826Z7NfQmg41KKgBDnvl1jHW9/CRDR/c0WQkaD+roPV8kaNE9VjrcGLsbEr2GXGnDcGXh3M2eOEdZBZE7D6v2ezsnafZNdvEthnoYOCceLqbVKyGh2h6RswYQ+Vro4HfW F5NVeaW+ qfJPb1hTGpKVIXUJ3T+eLgT7Go7lkNWvmvwxIk4fuzYn6AOrVmQmb3uQt4oqPEsUN7NqPF8f4JRDUylgDv+hG3SzhQAE4A4JNasUKWJF33i7O6B2geUMvNntw2FgR2VjuB3cbmW98C5IabEPVQovTLm/D2D9hg9y0rTGJ8Ce8AAmkrlq148jk8i/NWGYZgL7aSBSvP4ln4DQRBEnQEiBw7a0y1zLl2+1lnSvhweRY/lFD8LSVQQZiJeL2bdjVelYtylW561zPI4RFWEqRWSC397SsQy6zAs9IXwo+hYdiK3tR/TSk3F6gKCUtfw== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: By taking GENERIC_IOREMAP method, the generic generic_ioremap_prot(), generic_iounmap(), and their generic wrapper ioremap_prot(), ioremap() and iounmap() are all visible and available to arch. Arch needs to provide wrapper functions to override the generic versions if there's arch specific handling in its ioremap_prot(), ioremap() or iounmap(). This change will simplify implementation by removing duplicated codes with generic_ioremap_prot() and generic_iounmap(), and has the equivalent functioality as before. Here, add wrapper functions ioremap_prot() and iounmap() for s390's special operation when ioremap() and iounmap(). Signed-off-by: Baoquan He Reviewed-by: Niklas Schnelle Tested-by: Niklas Schnelle Cc: Gerald Schaefer Cc: Heiko Carstens Cc: Vasily Gorbik Cc: Alexander Gordeev Cc: Christian Borntraeger Cc: Sven Schnelle Cc: linux-s390@vger.kernel.org Reviewed-by: Mike Rapoport (IBM) Reviewed-by: Christoph Hellwig --- arch/s390/Kconfig | 1 + arch/s390/include/asm/io.h | 21 ++++++++------ arch/s390/pci/pci.c | 57 +++++++------------------------------- 3 files changed, 23 insertions(+), 56 deletions(-) diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig index db20c1589a98..f33923fa8c99 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/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 Mon May 15 09:08:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13240992 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 40D5EC7EE22 for ; Mon, 15 May 2023 09:10:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CCD13900004; Mon, 15 May 2023 05:10:34 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C7DB2900002; Mon, 15 May 2023 05:10:34 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B1E84900004; Mon, 15 May 2023 05:10:34 -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 A48C8900002 for ; Mon, 15 May 2023 05:10:34 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 7BC9181354 for ; Mon, 15 May 2023 09:10:34 +0000 (UTC) X-FDA: 80791918788.03.DD53A35 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf06.hostedemail.com (Postfix) with ESMTP id AE62518000F for ; Mon, 15 May 2023 09:10:32 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=LwCtcWVb; spf=pass (imf06.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684141832; a=rsa-sha256; cv=none; b=QngrjkpweyIsqQjrCnm60PopBikHy9H7GZMJsvDCDNlFxUSPh0tRiTEgPvmFXiwox7M59C vKQ/qbbCIHKC6bdY7qYubu4WIArPRYo2zsLJfAI9xg2SNXH7ASVicc2F0X57jDANSqjLnx Iar7n4WjyjOwHLwC9R4Zl5Sb8BHRVH8= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=LwCtcWVb; spf=pass (imf06.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1684141832; 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=p8qEquP01UJzuUVmjHErarqQIAtxjzFbcD1ySUGX2k8=; b=g6obQixo6BkTti+Vp6TQK34aCl4NN1A2zZKTqrV7zsRf1UdkX66FhQJUe4f3EMDXtT/ER2 FgyyTSFXowU0mRIjBhmbTQ4OSZKelYVvfjR8E+cfav8JTor5wntPA3iDCYwbeiTEAH275s rTSm3vGlgFLuRusY0+an3j69gFKFiIw= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684141832; 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=p8qEquP01UJzuUVmjHErarqQIAtxjzFbcD1ySUGX2k8=; b=LwCtcWVbJAbwnx/y6EeLZ3LjGiqPfWF1h1mW1xC5fUXm+z97dsFO1D5W5ssIIqwP4C7fHR BV3h5yzCpAtYC4A3L29zyPvCWLQdfwD6X38fruPy/GAZgQu0E6bweOywiyFe7N7LuvE0jx l3wNf+8USGiqz33TT34Q66yV3knFsFg= 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-615--4CQWEinM5SC3EfIchWr2Q-1; Mon, 15 May 2023 05:10:27 -0400 X-MC-Unique: -4CQWEinM5SC3EfIchWr2Q-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1FB2185A5B1; Mon, 15 May 2023 09:10:27 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-32.pek2.redhat.com [10.72.12.32]) by smtp.corp.redhat.com (Postfix) with ESMTP id CA14140C2070; Mon, 15 May 2023 09:10:18 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-arch@vger.kernel.org, linux-mm@kvack.org, arnd@arndb.de, christophe.leroy@csgroup.eu, hch@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, David.Laight@ACULAB.COM, shorne@gmail.com, willy@infradead.org, deller@gmx.de, Baoquan He , Yoshinori Sato , Rich Felker , linux-sh@vger.kernel.org Subject: [PATCH v5 RESEND 11/17] sh: mm: Convert to GENERIC_IOREMAP Date: Mon, 15 May 2023 17:08:42 +0800 Message-Id: <20230515090848.833045-12-bhe@redhat.com> In-Reply-To: <20230515090848.833045-1-bhe@redhat.com> References: <20230515090848.833045-1-bhe@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: AE62518000F X-Stat-Signature: qm7knuem5adgt4i5jrbn43t6pc5x4m6z X-HE-Tag: 1684141832-541097 X-HE-Meta: U2FsdGVkX186yIIDcVDK/KgqEjSAUWO3yoHltVjZgupMaeP8UoaN4GuXmFT0F7nfnJkDHtO9ylqP0QXAy9DirDoDE9yywL8vlCLNBEZ2q2DB1HsWLl+ZAUzUuiUDsQiGnzldUMNC534fNUoXsK2Z6nOjwrXDpHi+Yr+RVo1/TqC/lyncyxA2pyaZTbca5LRF1zGRpbObE77NpbmyWhltBUqj99fjP7hvrKNG0198LhD9q22uK2IB7NYh7osFLZautUqX602nZ2kTGD6WjLQugzfIYg6SiUluunJIVV6QkaP6zmXEFi0jpTVZ62smDZrKrXHEknplqjzIKIAG+pV6BfV1d+yKKKkMZxnP8E8QVU7jB8z08qtU/Hb/UKiZMEhdYJzdazqZalSGF2lhqDULOz8RlcPirFbzY/MhhCW23kLRF7eAteJQY2ah1agPY72EE3pCuWXoQCSbHcG356r225nkhKvXxcndEpz0hiFfm0UaazI0a9hKlCQDV9TidoKbx3UX3TV0oCIcQ1Ru16Pm5IU+w9YIO2qHGVMc+4KJ0r5fPulZDUTDmsy04w71nTEXgO419howlbDFN7av4c/14/mL7opgEkInpZ8Gj6TuoRmrcwrf0YSCRwaEoPGBR682TZz405YH0Bqj8iT9uvnmK/3WzGd6d6hnNNhZ/BDqr7c/CiDD3YOBgB9/KTBGjc1WDa5hHWTOqe30GABqKwMEscddRyOH/6A2KkCXNmwMNaI04Hdh5z1TTRhcbxd1DTu0n3pbsI724khp9aU7XxiuvVNJyJi4X6BQ9U5mxV1A6Wb4WU/uCiYxtqvd4/fK5pkab5x0MGfl5IBXNL85vNvv8ydsqstnc2L6S1SJF84U3j4Is0qNMTbwXktvpQjoa3YXL8JgDOPmu44rzfalsVQwrtJj+iO8tFwC0b1atCFo8OD1Tg4a951o3OrGKT4huciKB49nDEktIYq8cw1+b7S XyeLzh0Y 1gJuD6gVZRVWd7WSqoBCkNmv3JElTwha1VGWeU9tKRQ9PTTTTCBmXyaCTQxUO0aWAInjOrI/tnX6Ci0W+BwB1aD3YF3xk/Hx8ERCF79Pi/o8NcYMD8RsOem13U4aAbrwHMHxUG9F3oI46Y4gJVyJC7pm+xCfl4ZHM3yhcTOQex0PMO/yvH4Mumxu732lxOwhKnv70vlxrmUmF1iLkoEzRXCVZaWZn2ZVogIC3yEfRxDiRX35o4lc6U5nWizWIQZPav8YA4CsnNOP0vAuOqb8F+/LcWIIY2R7v/U4yi8NHFxjcOrSOlj1Gqq7KeCpHfxf6YglHkmkdqi7PVU9xvodchWFJr+1uAA+V9Rd6 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: By taking GENERIC_IOREMAP method, the generic generic_ioremap_prot(), generic_iounmap(), and their generic wrapper ioremap_prot(), ioremap() and iounmap() are all visible and available to arch. Arch needs to provide wrapper functions to override the generic versions if there's arch specific handling in its ioremap_prot(), ioremap() or iounmap(). This change will simplify implementation by removing duplicated codes with generic_ioremap_prot() and generic_iounmap(), and has the equivalent functioality as before. Here, add wrapper functions ioremap_prot() and iounmap() for SuperH's special operation when ioremap() and iounmap(). Meanwhile, add macro definitions for port|mm io functions since SuperH has its own implementation in arch/sh/kernel/iomap.c and arch/sh/include/asm/io_noioport.h. These will conflict with the port|mm io function definitions in include/asm-generic/io.h to cause compiling errors like below: ==== CC arch/sh/kernel/asm-offsets.s In file included from ./arch/sh/include/asm/io.h:294, from ./include/linux/io.h:13, ...... from arch/sh/kernel/asm-offsets.c:16: ./include/asm-generic/io.h:792:17: error: conflicting types for ‘ioread8’ 792 | #define ioread8 ioread8 | ^~~~~~~ ./include/asm-generic/io.h:793:18: note: in expansion of macro ‘ioread8’ 793 | static inline u8 ioread8(const volatile void __iomem *addr) | ^~~~~~~ In file included from ./arch/sh/include/asm/io.h:22, from ./include/linux/io.h:13, ...... from arch/sh/kernel/asm-offsets.c:16: ./include/asm-generic/iomap.h:29:21: note: previous declaration of ‘ioread8’ was here 29 | extern unsigned int ioread8(const void __iomem *); ==== Signed-off-by: Baoquan He Cc: Yoshinori Sato Cc: Rich Felker Cc: linux-sh@vger.kernel.org Reviewed-by: Christoph Hellwig --- arch/sh/Kconfig | 1 + arch/sh/include/asm/io.h | 65 ++++++++++++++++--------------- arch/sh/include/asm/io_noioport.h | 7 ++++ arch/sh/mm/ioremap.c | 65 ++++++------------------------- 4 files changed, 52 insertions(+), 86 deletions(-) diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig index 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 fba90e670ed4..b3a26b405c8d 100644 --- a/arch/sh/include/asm/io.h +++ b/arch/sh/include/asm/io.h @@ -119,6 +119,26 @@ void __raw_readsl(const void __iomem *addr, void *data, int longlen); __BUILD_MEMORY_STRING(__raw_, q, u64) +#define ioread8 ioread8 +#define ioread16 ioread16 +#define ioread16be ioread16be +#define ioread32 ioread32 +#define ioread32be ioread32be + +#define iowrite8 iowrite8 +#define iowrite16 iowrite16 +#define iowrite16be iowrite16be +#define iowrite32 iowrite32 +#define iowrite32be iowrite32be + +#define ioread8_rep ioread8_rep +#define ioread16_rep ioread16_rep +#define ioread32_rep ioread32_rep + +#define iowrite8_rep iowrite8_rep +#define iowrite16_rep iowrite16_rep +#define iowrite32_rep iowrite32_rep + #ifdef CONFIG_HAS_IOPORT_MAP /* @@ -225,6 +245,9 @@ __BUILD_IOPORT_STRING(q, u64) #define IO_SPACE_LIMIT 0xffffffff /* We really want to try and get these to memcpy etc */ +#define memset_io memset_io +#define memcpy_fromio memcpy_fromio +#define memcpy_toio memcpy_toio void memcpy_fromio(void *, const volatile void __iomem *, unsigned long); void memcpy_toio(volatile void __iomem *, const void *, unsigned long); void memset_io(volatile void __iomem *, int, unsigned long); @@ -243,40 +266,16 @@ unsigned long long poke_real_address_q(unsigned long long addr, #endif #ifdef CONFIG_MMU -void iounmap(void __iomem *addr); -void __iomem *__ioremap_caller(phys_addr_t offset, unsigned long size, - pgprot_t prot, void *caller); - -static inline void __iomem *ioremap(phys_addr_t offset, unsigned long size) -{ - return __ioremap_caller(offset, size, PAGE_KERNEL_NOCACHE, - __builtin_return_address(0)); -} - -static inline void __iomem * -ioremap_cache(phys_addr_t offset, unsigned long size) -{ - return __ioremap_caller(offset, size, PAGE_KERNEL, - __builtin_return_address(0)); -} -#define ioremap_cache ioremap_cache - -#ifdef CONFIG_HAVE_IOREMAP_PROT -static inline void __iomem *ioremap_prot(phys_addr_t offset, unsigned long size, - unsigned long flags) -{ - return __ioremap_caller(offset, size, __pgprot(flags), - __builtin_return_address(0)); -} -#endif /* CONFIG_HAVE_IOREMAP_PROT */ +/* + * I/O memory mapping functions. + */ +#define ioremap_prot ioremap_prot +#define iounmap iounmap -#else /* CONFIG_MMU */ -static inline void __iomem *ioremap(phys_addr_t offset, size_t size) -{ - return (void __iomem *)(unsigned long)offset; -} +#define _PAGE_IOREMAP pgprot_val(PAGE_KERNEL_NOCACHE) -static inline void iounmap(volatile void __iomem *addr) { } +#define ioremap_cache(addr, size) \ + ioremap_prot((addr), (size), pgprot_val(PAGE_KERNEL)) #endif /* CONFIG_MMU */ #define ioremap_uc ioremap @@ -287,6 +286,8 @@ static inline void iounmap(volatile void __iomem *addr) { } */ #define xlate_dev_mem_ptr(p) __va(p) +#include + #define ARCH_HAS_VALID_PHYS_ADDR_RANGE int valid_phys_addr_range(phys_addr_t addr, size_t size); int valid_mmap_phys_addr_range(unsigned long pfn, size_t size); diff --git a/arch/sh/include/asm/io_noioport.h b/arch/sh/include/asm/io_noioport.h index f7938fe0f911..5ba4116b4265 100644 --- a/arch/sh/include/asm/io_noioport.h +++ b/arch/sh/include/asm/io_noioport.h @@ -53,6 +53,13 @@ static inline void ioport_unmap(void __iomem *addr) #define outw_p(x, addr) outw((x), (addr)) #define outl_p(x, addr) outl((x), (addr)) +#define insb insb +#define insw insw +#define insl insl +#define outsb outsb +#define outsw outsw +#define outsl outsl + static inline void insb(unsigned long port, void *dst, unsigned long count) { BUG(); diff --git a/arch/sh/mm/ioremap.c b/arch/sh/mm/ioremap.c index 21342581144d..c33b3daa4ad1 100644 --- a/arch/sh/mm/ioremap.c +++ b/arch/sh/mm/ioremap.c @@ -72,22 +72,11 @@ __ioremap_29bit(phys_addr_t offset, unsigned long size, pgprot_t prot) #define __ioremap_29bit(offset, size, prot) NULL #endif /* CONFIG_29BIT */ -/* - * Remap an arbitrary physical address space into the kernel virtual - * address space. Needed when the kernel wants to access high addresses - * directly. - * - * NOTE! We need to allow non-page-aligned mappings too: we will obviously - * have to convert them into an offset in a page-aligned mapping, but the - * caller shouldn't need to know that small detail. - */ -void __iomem * __ref -__ioremap_caller(phys_addr_t phys_addr, unsigned long size, - pgprot_t pgprot, void *caller) +void __iomem *ioremap_prot(phys_addr_t phys_addr, size_t size, + unsigned long prot) { - struct vm_struct *area; - unsigned long offset, last_addr, addr, orig_addr; void __iomem *mapped; + pgprot_t pgprot = __pgprot(prot); mapped = __ioremap_trapped(phys_addr, size); if (mapped) @@ -97,11 +86,6 @@ __ioremap_caller(phys_addr_t phys_addr, unsigned long size, if (mapped) return mapped; - /* Don't allow wraparound or zero size */ - last_addr = phys_addr + size - 1; - if (!size || last_addr < phys_addr) - return NULL; - /* * If we can't yet use the regular approach, go the fixmap route. */ @@ -112,34 +96,14 @@ __ioremap_caller(phys_addr_t phys_addr, unsigned long size, * First try to remap through the PMB. * PMB entries are all pre-faulted. */ - mapped = pmb_remap_caller(phys_addr, size, pgprot, caller); + mapped = pmb_remap_caller(phys_addr, size, pgprot, + __builtin_return_address(0)); if (mapped && !IS_ERR(mapped)) return mapped; - /* - * Mappings have to be page-aligned - */ - offset = phys_addr & ~PAGE_MASK; - phys_addr &= PAGE_MASK; - size = PAGE_ALIGN(last_addr+1) - phys_addr; - - /* - * Ok, go for it.. - */ - area = get_vm_area_caller(size, VM_IOREMAP, caller); - if (!area) - return NULL; - area->phys_addr = phys_addr; - orig_addr = addr = (unsigned long)area->addr; - - if (ioremap_page_range(addr, addr + size, phys_addr, pgprot)) { - vunmap((void *)orig_addr); - return NULL; - } - - return (void __iomem *)(offset + (char *)orig_addr); + return generic_ioremap_prot(phys_addr, size, pgprot); } -EXPORT_SYMBOL(__ioremap_caller); +EXPORT_SYMBOL(ioremap_prot); /* * Simple checks for non-translatable mappings. @@ -158,10 +122,9 @@ static inline int iomapping_nontranslatable(unsigned long offset) return 0; } -void iounmap(void __iomem *addr) +void iounmap(volatile void __iomem *addr) { unsigned long vaddr = (unsigned long __force)addr; - struct vm_struct *p; /* * Nothing to do if there is no translatable mapping. @@ -172,21 +135,15 @@ void iounmap(void __iomem *addr) /* * There's no VMA if it's from an early fixed mapping. */ - if (iounmap_fixed(addr) == 0) + if (iounmap_fixed((void __iomem *)addr) == 0) return; /* * If the PMB handled it, there's nothing else to do. */ - if (pmb_unmap(addr) == 0) + if (pmb_unmap((void __iomem *)addr) == 0) return; - p = remove_vm_area((void *)(vaddr & PAGE_MASK)); - if (!p) { - printk(KERN_ERR "%s: bad address %p\n", __func__, addr); - return; - } - - kfree(p); + generic_iounmap(addr); } EXPORT_SYMBOL(iounmap); From patchwork Mon May 15 09:08: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: 13240993 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 65008C77B75 for ; Mon, 15 May 2023 09:10:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D1BAC900006; Mon, 15 May 2023 05:10:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CCBA2900002; Mon, 15 May 2023 05:10:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B9343900006; Mon, 15 May 2023 05:10:50 -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 AB17D900002 for ; Mon, 15 May 2023 05:10:50 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 86976A03B5 for ; Mon, 15 May 2023 09:10:50 +0000 (UTC) X-FDA: 80791919460.15.5643B86 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf10.hostedemail.com (Postfix) with ESMTP id B9748C0009 for ; Mon, 15 May 2023 09:10:46 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Z1dR8nIX; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf10.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=1684141846; 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=Cj/HswZMHXnWMaqNG+JgGGNkjmKUuKmi6GYqnEi0zbM=; b=jLrQFspw468XF3rMT+uNO6pcYjKSm9kEddw3jlc4V497Ng2h41f5+q+fhs7qwtU3HPLBdl UYyKW+nrSEBAWTSACnFqS+VuCsM3IQ9f3sOUvhzTa5a0wgkAS/TH+qsGp5avAIXOhyPdCA NDXllSomYfMwd0M2XLsF2icWwIlrIFU= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Z1dR8nIX; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf10.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=1684141846; a=rsa-sha256; cv=none; b=a5bxYWRGn0iP8Sq3eDyO/5v0XAudG9EoAJMoM2U1GxxyHuOWQyGMxQT0osk1fJGg+cy6rU qrNTXyu43uDrwmVFbTVTIeZS1S6xI/eod7deUe2oo7pT13SdmgolSmCisDKlsHXuWu1YNO p1i9gx8hzx5suqAnlBZ/hK+O4kQX4MY= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684141846; 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=Cj/HswZMHXnWMaqNG+JgGGNkjmKUuKmi6GYqnEi0zbM=; b=Z1dR8nIXxjC3qj+iP2ozsaXkpRxYZryFW5XSW+MURzL6Noue2vOluywlBOc+IodUb0o6Ph nKIH2WwIVqtbzkjA1nijVmzdTYhvTkOIZeeom+y4KGCQmXpUeXNK1/J30IpK43kRmI4oQ2 8kZGRGmjz5oRrfbzz7Ky8zniA600vzk= 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-610-jyObHTUBPbqexipS89w3tg-1; Mon, 15 May 2023 05:10:35 -0400 X-MC-Unique: jyObHTUBPbqexipS89w3tg-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7970D800047; Mon, 15 May 2023 09:10:34 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-32.pek2.redhat.com [10.72.12.32]) by smtp.corp.redhat.com (Postfix) with ESMTP id E197B40C2063; Mon, 15 May 2023 09:10:27 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-arch@vger.kernel.org, linux-mm@kvack.org, arnd@arndb.de, christophe.leroy@csgroup.eu, hch@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, David.Laight@ACULAB.COM, shorne@gmail.com, willy@infradead.org, deller@gmx.de, Baoquan He , Chris Zankel , Max Filippov Subject: [PATCH v5 RESEND 12/17] xtensa: mm: Convert to GENERIC_IOREMAP Date: Mon, 15 May 2023 17:08:43 +0800 Message-Id: <20230515090848.833045-13-bhe@redhat.com> In-Reply-To: <20230515090848.833045-1-bhe@redhat.com> References: <20230515090848.833045-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Stat-Signature: 48qoo6or9ebra6g4zkecbsiyyd93t67k X-Rspam-User: X-Rspamd-Queue-Id: B9748C0009 X-Rspamd-Server: rspam07 X-HE-Tag: 1684141846-462742 X-HE-Meta: U2FsdGVkX19XvaSIy21K65W3PN9veQmosTmIVPZ9HAPCd1WWO/QENNM6tgqn72pr7+9d4yM0bFN3zR90wGZZjgbM3ksLuTKdQ1mcSAdLFABPRMZo4Nxr094j81o4UhDDI4XdcNvyXtnmS9t6i4Ue5ryqOIaxANBxbUIi4Gy2d9KGYOTNEGOwnJzz4yB7eDxhMauw4YFC/Pe5tn5JjbROpCZqReFanSsxPPDCrt2vDqmFUmCRS/FujjxE+j6pL95i79TKqt/3bPxJXlnXXXZ0ZimVoptaVD6UvHUTRrbbDph4G1+atUoLQhqNmqsJnO7g8xQXZrYR1o5V0I3FFry2vRFaPwykCGgGo7cp5/N5dyP7bMkEHf464eW4ZEVZ031m1shor4Wk5Dr1/78JKpnX+jZBqkKuYqRV2nUBso+tuLmOfMn8ujfzbk86BqPvRFItRSEFZUnxfcWg7HuclFXXFO4RoHYknNSrgzd2tNcHclfbIhmiRDhEHynmCQDunNBgGUbqK94v8J7MT9w80XLz/LVQ2+h1Jm+TKSl+3esYBARvCRrEifKMhiUVurEhKMirhwtJou2QdW5BMTpn15OQnm/whYDAWGjChegU0WlvaxtAxVHjychPlwJmpdxhM84gAKpbKezysYHGSmQnFBOQmUZyVvvw2A4kmutIDVh5UfejUnHaS4K3qXUd0AJMonxmmncICfKUU95YJ5XbesCm0dZYovqiGIUlEPXy7GeR2stj9MVneAX836tenfxjT7BR/tq/gCvrjU48agBhrHox2UsOWVDv9S/T6zOyM9DkDMknN07tbq8WuXD2na7KQpJ/kjaEDZwDR0Ju3eRPNsn5oWawfxg/EeSWKcT7VX1K7iszUFB99Xy9eI3TuTrcvz71dC9sMidRS9UKZY4ATPk3MMibIqCNgTYb01kJQKpfTAXJnDg7I3s/zuScRL6Xf25ZKHCOZ+rpA8Vce9qyeTn cldLBd9a 5NmSWlSfzhoGQwGA5bCygdv27U+AZAy0bpMoghNmmrx599q3Liw0584CKg7bK/vBfvKTL3Me1x6/LHuvzN1FYPRx1L8cr1PycivTE/KO2fu/18P5GNB2SmFgvrgIX+0TcNTTJ8I9DPPZNxrIZ70OZPPd9sMwJveQYOekqzHbpnSfTFeWzgwt0JHkqbJr/XP8xDymXXmZP33/ZuXTZhdmvjpRcJ6jCZLpFpvOGSTWvNdgVVJmqcgShIRvRFFWqPjJeQ0ov3m616+D3m3yNBqTjfAzWq8aI2Uj6r+vQWYwUBCM6Et6oAd9P0vm0xg== 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 Cc: Chris Zankel Cc: Max Filippov Reviewed-by: Mike Rapoport (IBM) Reviewed-by: Christoph Hellwig --- 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 Mon May 15 09:08: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: 13240994 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 B75DDC7EE22 for ; Mon, 15 May 2023 09:10:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5A0E7900003; Mon, 15 May 2023 05:10:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5518A900002; Mon, 15 May 2023 05:10:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 41992900003; Mon, 15 May 2023 05:10:50 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 357C5900002 for ; Mon, 15 May 2023 05:10:50 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id F2159AF4CD for ; Mon, 15 May 2023 09:10:49 +0000 (UTC) X-FDA: 80791919418.18.49BFB7F Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf05.hostedemail.com (Postfix) with ESMTP id 3E3CE100016 for ; Mon, 15 May 2023 09:10:48 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Qq8MYjLU; spf=pass (imf05.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=1684141848; 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=SkuBcRmfwXAx+LokLW8LUvbvQG1M59NAVaKGe2qHG6A=; b=2eFVofNcKLVaTsBC1QWpuGg+C6nvCACiKOPhFp1J7iTAknfE12uaD2O68FlqF3j09t9L+u qj6og3JJfHuEgxsfpHc7wBigf552yReRtsqLD7sbaX1NW+18VAKBuUpBCioZX1KS4Aksyl NBgLM0eV96dcC9zvvU9NZ+16iIzRy2A= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Qq8MYjLU; spf=pass (imf05.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684141848; a=rsa-sha256; cv=none; b=ZdD5mphqpwGArlLQhBNe87PdFTiswb3fvnWFv7A0EzJg84XH23GmyrhwtwqVDf2UTX8A0p vwAUqH8biXkvHiCK2ff+fNtkDTtnBoCJwG2z4sOSFEMk9sPKKp5B1PqcSvJFgXHFLk1v/i XYRYJYcCjxmj9pWDe9X9zK7YPz7EuWA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684141847; 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=SkuBcRmfwXAx+LokLW8LUvbvQG1M59NAVaKGe2qHG6A=; b=Qq8MYjLUzCjVnqQNNUB7owj2eToV044F+FN/gLCF1tGm0DyW0sauOIGV+ArEWBS1IIVIYa xCrattNKE+ig27ujV3lbx5PtSHp39pOBLgwoLkmsQwn/oIXRHV3Z083z+wQcSkEiHOeSkh Pb8VPpkjpyoEdAMPK43HW7LtnNkM81U= 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-401-iME_X8SqMeeI4gcmlx700w-1; Mon, 15 May 2023 05:10:43 -0400 X-MC-Unique: iME_X8SqMeeI4gcmlx700w-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 75F7C85C069; Mon, 15 May 2023 09:10:42 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-32.pek2.redhat.com [10.72.12.32]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4973E40C2063; Mon, 15 May 2023 09:10: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, christophe.leroy@csgroup.eu, hch@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, David.Laight@ACULAB.COM, shorne@gmail.com, willy@infradead.org, deller@gmx.de, Baoquan He , "James E.J. Bottomley" , linux-parisc@vger.kernel.org Subject: [PATCH v5 RESEND 13/17] parisc: mm: Convert to GENERIC_IOREMAP Date: Mon, 15 May 2023 17:08:44 +0800 Message-Id: <20230515090848.833045-14-bhe@redhat.com> In-Reply-To: <20230515090848.833045-1-bhe@redhat.com> References: <20230515090848.833045-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Stat-Signature: h65rxnc9zxix3mazech15576qwoohz9g X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 3E3CE100016 X-Rspam-User: X-HE-Tag: 1684141848-707320 X-HE-Meta: U2FsdGVkX18h0Q/oXJZimMoPsi35WlxFskfcMITOeyYlIMz8gVI3MgwbBFK9R5qMAHRYivJEH5bO9V8nFFe5H3Ixvn8ZeD8+JOd/xvbmq4uWtCsql1bLtdf2ojZGw43ER6ldDiQBg710waU84Af4nk4j5Dx/TMLln0R44p5ZOiqpiyKMohDInx2sPQbmFC47r4Q6NhQl7lsw1KOdGL89N+LKwBZBH32qJseoicM4u9bO6ihv0jbu6RKbAUahE3SVgLzHdCH5XN1h9hMt4IjqyDvcW2oXbqBc7HV4203wQgPc3dsgItGKELfFF2BR7PlI3ecRn2ywyy6bJfbx+u587IPRmhCfbnTJ0l5Yf5sh68gfbSFx/z16+N2NJt1S828AfXdyvUd8snvBsv2ZzSu/IKbefT3XO7j07XRnxLrOmqoT0rNdIbJxwkxZAMx+Z02uwtxk/Y0PCxo22hAiFUTxp56Pcxhl0GemSnZtjXfZoz+F/edzJBBi0MGlKj31uMTK3nv2qF+QLWzVJCFpAtS3hMH4K/hRXSmEJAeSsGOIs0/L13xjo2HVN2doL2AHU8G33nH2CvCpEgLwfMY7tVuY+jyIB1ysjTYaoZ3pE42qDtG8Zw/NKJ7UpPhBg/SvtMo8bQzbdm6MC7TsneyZHIVIDnvNpe5nAUjUUQ7hCe5Ypk1W2SAydDVsk+fwD5W+flAcNOdZ42HvfsRW2guxOH1uuuL7qNmxx1wzi+YDaNW2Xwf7BqI+cAyw1fMVD4SghuKlegYGfflA3OigmyvWROu683HS5p+aaIhBAS67Tur3sLo2BQRYgTu1g/CQ+umkBq03+FtxZHD6TwRFg6YQZyXs6c2Jkq15aSZ9W0sDV/GaSlzfTagqhalOrIs/QwBCV7BXMig01/HrjaWPs7H5M/baL/aG9Y4lMPzS/sgrmvHA9PjMCLYQrx1Pu+QQ24GqjutQw7qWNhpj+NyrepRGlhh 99olN5kl rW6Pzwfmfk6cRkqgId6KnuxqvXj8f1vc74PXuF0GafMepYYn6AuCRTBFTbZ/s9WqyY8JrHDTh7hipLeWVkzWURbVqYZyG6Uc5Ibn6WQjTXp1g0331UKZpb3Yh3i0GYqg4VWe3aov5v9vl36Bb2KMIe1HsaSJY88tIJjy76JP2kxSQIM/mUFYtUom9gjs7QiRBSRd4+kASxai34Dcxie10jKmZmWp1s4liYLO7JugECL0HV8aFT9RUPNP2D53N0umkbfPT/LYTlKIBZuOEhH9uvIVbwh8wGVncdXh/iUN0j/xjCn62TUDaGTB16Adifno7PrUU4gL+dkFVIWuwW+JScwDwpQ== 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(). Meanwhile, add macro ARCH_HAS_IOREMAP_WC since the added ioremap_wc() will conflict with the one in include/asm-generic/iomap.h, then an compiling error is seen: ./include/asm-generic/iomap.h:97: warning: "ioremap_wc" redefined 97 | #define ioremap_wc ioremap And benefit from the commit 437b6b35362b ("parisc: Use the generic IO helpers"), those macros don't need be added any more. Signed-off-by: Baoquan He Acked-by: Helge Deller Cc: "James E.J. Bottomley" Cc: linux-parisc@vger.kernel.org Reviewed-by: Christoph Hellwig --- 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 466a25525364..be6ab4530390 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 Mon May 15 09:08: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: 13240995 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 C540AC77B75 for ; Mon, 15 May 2023 09:10:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 616AD900007; Mon, 15 May 2023 05:10:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5C718900002; Mon, 15 May 2023 05:10:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 48F8C900007; Mon, 15 May 2023 05:10:56 -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 31BD0900002 for ; Mon, 15 May 2023 05:10:56 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 03FF6AF4D1 for ; Mon, 15 May 2023 09:10:56 +0000 (UTC) X-FDA: 80791919712.10.07B21EE Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf09.hostedemail.com (Postfix) with ESMTP id 3FEDF14000A for ; Mon, 15 May 2023 09:10:54 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="hLVtTz/W"; spf=pass (imf09.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1684141854; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=Uaseq8uUQQ6QMQSRfFux0A76lTwwiGZ3GmLj5/5Y0lk=; b=P8rUQ2QBA4BXL7bFWdnhPSSD3VWX0+CcYCn6zv3mMWdXezLcQ7AW4LgrUgJO7+KVU87i5/ Zo9+Rl6MARDLifqlZ28RU/LynBVsqeAl5aorQuV7bQmvQQLhmKy5VyVHTpnIogJOtg8Ejk 4792k0BrYl106uZSnXD4A/uhLNlmGeY= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="hLVtTz/W"; spf=pass (imf09.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684141854; a=rsa-sha256; cv=none; b=NPKuefMfENZWbycMBbzKz2FOjR9Xwkpp9T9Thgcl2WcAYzk6LHuUdkV3vQRpobdyB/71hP UPF3c3yGDEksKo1DMkLdBQDWB1W7EvJiRf8lUi1ANJvWIXfK0U/oXEUM5aIanS6eggb9Os ase03zbu/0d2d9+lCs7/7dkD7g8Ufdg= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684141853; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Uaseq8uUQQ6QMQSRfFux0A76lTwwiGZ3GmLj5/5Y0lk=; b=hLVtTz/WvCwJgMNr78AO2M+yQj8iy7TzeGb4GBePRbSeCXcRrhCQJflHexF17iMuRJYJNr F78NI5sw+2Sx/AuWUc1BXlMuSa0LGNBAvEbFGNpkFO56SBp+qZySqdJ1SBTElb5qGC5EMw HIcVCCB3+kREV6TsGi26utEQCzirYIw= 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-507-ER6juC3BMNSvQDD-_oKHbw-1; Mon, 15 May 2023 05:10:50 -0400 X-MC-Unique: ER6juC3BMNSvQDD-_oKHbw-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A324585A588; Mon, 15 May 2023 09:10:49 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-32.pek2.redhat.com [10.72.12.32]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3611340C2070; Mon, 15 May 2023 09:10: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, christophe.leroy@csgroup.eu, hch@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, David.Laight@ACULAB.COM, shorne@gmail.com, willy@infradead.org, deller@gmx.de, Baoquan He Subject: [PATCH v5 RESEND 14/17] mm/ioremap: Consider IOREMAP space in generic ioremap Date: Mon, 15 May 2023 17:08:45 +0800 Message-Id: <20230515090848.833045-15-bhe@redhat.com> In-Reply-To: <20230515090848.833045-1-bhe@redhat.com> References: <20230515090848.833045-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Stat-Signature: 7xm1wnsnw9wefcp1y1fs8kx9q941o7m5 X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 3FEDF14000A X-Rspam-User: X-HE-Tag: 1684141854-516855 X-HE-Meta: U2FsdGVkX1/xxnMmoVViQX02i4Aq4zpqL6gPgv/Y9J9+bbwfnTb8TrzwvGlr+PLnYF5D99wALsFiW5MqvwhJoN5RvEquiO3fh3EDsGQ+Y7szB4++8Z5pW9PNTFd8kIHFroXeCNDNia9tSx6EKQ76QLVJbTJVPb+nyR5hyoSuLH4+7j8CaKpokSq1pzZvMpUi5JXqHrdgfobYo84nCMHR3XJ8iua2lPp5uAbNfoeUAAok5ru55A4Ig1jUREzVEsSC5lZsxjL4Eow7OjRPHUIvcI2nGlV77Pu84rsVc8aArCiQlobcgW5TBQA51daHhZGeihBlh3HSh0nMaAyfbARwm9O+jsE1q9KzPb8J2DMIahuTPCLM6XfiXk9bzMzys41bv/yISClKgIYGJdrMOwG/KhbELnJ5wsnJgY4+qRfo8yOv+5rqpuO4+Z3ENvXwxjA6Xv7Bm3mP/dCX5/AJhNUa4QzoQ2SiX6RIl3OPCdT0Yktn7nFVH3yz6NU703NPn1LHTl+GWUku6+wqqQEBev1A70/nYJ1Q40se5UzHZYDqTU3oR4bJkZ4ki49H8wAER74NWLnkC9XiLPkCJjNFYjkFWjMOviKZRsJVYY3lMX9mfqRSqSt/Q64F7Zfqa9OtMutndz0A7JxWQySwrKQOymuYNSi3mJfFeu9vC9X1SJBc5Ww62lkzFGZgegEMZgbhTHdGGUIWF2DNRKtMFKdJ0WefWcsMl+/zx7cLHHJf7swOjRdfPk3xjKSVMJBr/7G3EWtSB7aOor5iM6ZzmnybbuNyoZ24dxiT2jMrqyZYi9a1Mw9qj6xuACNhMFjnBvG2BQzVcl9XAHdEX/gEcg6pXgulCwIZI/oFGgAsUWD9HcuWXpq8L1tZKDKD7wf6CB8rtUyTQyRAlEOLgjgijCR3GoVlPC1x6wrIVZh1tfeYQiEg16bE2sRqM24+KXKQlsNrId45uT111mZ15TQfKbInLQ/ glOvCnbF tt6im1CiQtYHUqzcVwITK+V26hRoFtCMBjmwKrg60p1oS96XaMub7nH8xGI2FC7eKVqdjoRg9XGWf86QtvjlpW+Ft44XUCTCHwAqBfdjK0lbmxHVYoDDXGnJouUBTK4/X49QZ7F4Dj+TFMUnBJwqKU4/ot8mJ/EQdOvt3pGuyKmWaTIPiOB6zLCYUMkmsTu+rrmRuIvITbBF6KprrniybdL5F0sNONIIiTzXaPeutqqlyigM= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Christophe Leroy Architectures like powerpc have a dedicated space for IOREMAP mappings. If so, use it in generic_ioremap_pro(). Signed-off-by: Christophe Leroy Signed-off-by: Baoquan He Reviewed-by: Mike Rapoport (IBM) --- mm/ioremap.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/mm/ioremap.c b/mm/ioremap.c index 2fbe6b9bc50e..4a7749d85044 100644 --- a/mm/ioremap.c +++ b/mm/ioremap.c @@ -35,8 +35,13 @@ void __iomem *generic_ioremap_prot(phys_addr_t phys_addr, size_t size, if (!ioremap_allowed(phys_addr, size, pgprot_val(prot))) return NULL; +#ifdef IOREMAP_START + area = __get_vm_area_caller(size, VM_IOREMAP, IOREMAP_START, + IOREMAP_END, __builtin_return_address(0)); +#else area = get_vm_area_caller(size, VM_IOREMAP, __builtin_return_address(0)); +#endif if (!area) return NULL; vaddr = (unsigned long)area->addr; @@ -66,7 +71,7 @@ void generic_iounmap(volatile void __iomem *addr) if (!iounmap_allowed(vaddr)) return; - if (is_vmalloc_addr(vaddr)) + if (is_ioremap_addr(vaddr)) vunmap(vaddr); } From patchwork Mon May 15 09:08: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: 13240996 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 6AEBFC7EE22 for ; Mon, 15 May 2023 09:11:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0BF60900008; Mon, 15 May 2023 05:11:08 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 06FD9900002; Mon, 15 May 2023 05:11:08 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E79CE900008; Mon, 15 May 2023 05:11: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 D8979900002 for ; Mon, 15 May 2023 05:11:07 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id B09E14141B for ; Mon, 15 May 2023 09:11:07 +0000 (UTC) X-FDA: 80791920174.23.DB2B5E6 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf06.hostedemail.com (Postfix) with ESMTP id DEBF7180002 for ; Mon, 15 May 2023 09:11:04 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=P2QoQ5mE; spf=pass (imf06.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1684141864; 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=mBuHsMVsHTAI0RHYgISB0uXb9e32Yu/B2askY5ny76Y=; b=vOUHUwa82TAybz9AUiHCGrCYCP2h29kP97NeqiUPggfwow5AT4Qvg+YhFsqZ0cfganDcXD 0yh7InSl6xO2023uCfzISt6gbHSd7zDTHkIAvpUl+gCe0auAJ0qqM/YH0Pg7etHrFyO9zi olMzoo4KTYrl6fwp80MKv8+FeVk5Gpc= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=P2QoQ5mE; spf=pass (imf06.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684141864; a=rsa-sha256; cv=none; b=BUvQm8bsa4cljqf1euKdF2rZpmblGPlr8hOAHOrFhEPvBqad6rTchDzjDBDJaYFAWXB3HQ s0K2A5EVngHCRBsiDF6Eu2shyYGly942IoC1ElWCekRcrBPyrXRGHGEepN7Q/hZtRfDZHI RnazJSenBpQ/53Ue6XSZnVCmAB+vnlM= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684141864; 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=mBuHsMVsHTAI0RHYgISB0uXb9e32Yu/B2askY5ny76Y=; b=P2QoQ5mEI0aQgfPb+oJcARmhFFSNBOQPbALPDSSI/YCldKduinSrNatq/zRznW8NDY3IEM oHVduIjzM59CLQkNtThJPVDOoOA7bJKhWVl6GVNXnrwNfX8raU0hIQv2piIWdIU+vlpbNz 9gwRJo5RZH+WG8xkvDQuTTX6zwJ+Yqg= 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-609-9A1xWtYJNY267tJuB8jy-Q-1; Mon, 15 May 2023 05:10:59 -0400 X-MC-Unique: 9A1xWtYJNY267tJuB8jy-Q-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D0D24857E06; Mon, 15 May 2023 09:10:57 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-32.pek2.redhat.com [10.72.12.32]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7212840C206F; Mon, 15 May 2023 09:10:50 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-arch@vger.kernel.org, linux-mm@kvack.org, arnd@arndb.de, christophe.leroy@csgroup.eu, hch@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, David.Laight@ACULAB.COM, shorne@gmail.com, willy@infradead.org, deller@gmx.de, Baoquan He , Michael Ellerman , Nicholas Piggin , linuxppc-dev@lists.ozlabs.org Subject: [PATCH v5 RESEND 15/17] powerpc: mm: Convert to GENERIC_IOREMAP Date: Mon, 15 May 2023 17:08:46 +0800 Message-Id: <20230515090848.833045-16-bhe@redhat.com> In-Reply-To: <20230515090848.833045-1-bhe@redhat.com> References: <20230515090848.833045-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Stat-Signature: 3efzt4ij737kwr6gxn849airdeuue8xy X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: DEBF7180002 X-Rspam-User: X-HE-Tag: 1684141864-853148 X-HE-Meta: U2FsdGVkX19eWdtCEUSwbo+r0OfwePjne1j3eAbqPD4q1rTeD+FaeeHpO5LKb0YWjQLxwuqMVIFYJZNyRqyjwZXwqR7u6AdOzW0QDoFtT4gFxFcJ0bu/3lAOYiTTVP8ZBeNZ3xCw8SuICP+qI3pz6V67Kk6DY4qYu3/W8nxQ3eKd/1MO8ma+arhCe+pvUECanzfF9yatsxnRaaQLkBTyMHkQpp3R/v5qFpW6Llj/1q6ddlWA5ey2U4H3OKCkKX7GrSSsIMBxKRQjWpXW/IKexpSseXZ02Gv1jPO1QwhliKI7ErOTO3BQOWAdhZex8FOkNvG4+R2A28aBFPIW3cBwpBLsUWyh+0wu7S72BHbXh40WcaDmOs/1NCVW8ZuAU/Lf3I3Nv5WolbaZTjnDCwM593yDUMvtFmc1U+I/jTEOjSmAeGtBKSRiB4kKvk4EkB7b2PF6uXMS5pkou+DHpuVAlnBuhH9iyP0CVk//vBw2Hv2UGFreQLdiGch9zCFtfkrefyAaksgqJLyfPo/oEcFIS7RCi0B55cym+xW85j5CrNxn1Qe6KIXEo2hi4EnY/CHznEDY6lgzFo5ZxEDrR0uAq9DIlBjC/K83z6qyc//EuxNHhDdrqWpPqCtAGFCCIWF8PLN6UBZTJw15uLTegOcWQbDL1iDyUQ82tM6MWlK9BJlXKTMFcJFW2GnboYXc80BwsQ1fzizirqzOi8kWmHrbOnUWxUfug/fc63u+ANUsAhMwiQDsd5JP/XsKC/UwCfU+nxsH4409DSSfIHT3xq2EZ4QM0sch0qguDg3i0h/uvGjxOJ3miMTvQNhTQosFGmamPhzBIGhNR2hTETaLjSOzyR9EE70LFCNjg3XmYy3a2+CLPNfdPAsmCf41G/1OD4qKZeVav696L3aZ2TM13VeQOkCcwqS5X8VD8wCfpcE3zx3DHBpPLQjbEmO0TWF1F7Ss2MCDdQ3cFrqemwtYJFy Te6OviOj mUo/e1oO+QG8S4znnn4nnw7IGOY6nPPQwZoCABXcDCK1OgHROmWrWYJ93/1BIRmN1DAcBqISccOMa/wTQS+AqdwyIK04bgq7u3pXQzBL8K5e/egkbylWVFh8Z0go98mBEsEUceiQcnvyLYe03gVFzmvv5xX6MTunA+CX4p2loZKWXlbXNYoU/BsCnTL3F+4xlB8mARecP5Qr1N4YiEbtCyc+z25ZRWENFEKSfo2iuQNjafmGTLoVuTdmz1E/zG1Pts8DYPfu6L7DRP5EwTdAZ5vsWcYed+Mklo2R1QhezVjz2g2t83BpBw93WpnUN7y/dktfWI7s8tbi2YHCy9rDwAGo2HQzI+XSdehXdlLCtY2WVtlM= 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 Cc: Michael Ellerman Cc: Nicholas Piggin Cc: linuxppc-dev@lists.ozlabs.org Reviewed-by: Mike Rapoport (IBM) Reviewed-by: Christoph Hellwig --- 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 539d1f03ff42..e0a88ebcd026 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 Mon May 15 09:08: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: 13240997 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 DDFB3C7EE22 for ; Mon, 15 May 2023 09:11:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 83A04900009; Mon, 15 May 2023 05:11:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7E9CA900002; Mon, 15 May 2023 05:11:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6B12C900009; Mon, 15 May 2023 05:11:18 -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 5E6B6900002 for ; Mon, 15 May 2023 05:11:18 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 15BEA1C8ACB for ; Mon, 15 May 2023 09:11:18 +0000 (UTC) X-FDA: 80791920636.22.420C998 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf12.hostedemail.com (Postfix) with ESMTP id 4D6184000D for ; Mon, 15 May 2023 09:11:16 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=EITqmBVa; spf=pass (imf12.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1684141876; 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=qE+zf2yG3U5XZ1GPvj+t+kX2BtRW0PoSBcAy/uzHAnk=; b=qC8k8VTlzdJrsIoEqqUm5y6xO3mFozAkgo4dbiGLNqhR2wmbxZyR2G2lo5+i6J48jrSDl0 +sGqDWQohw8tJccYWmzh89G0ta2ba/s1NGewOhnETiWKo753uaEQsOOTgjKbMoCod6RzCQ flbQyI2+VG+bhC/Lc4pUZ2E0+G8c4Uw= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684141876; a=rsa-sha256; cv=none; b=KOjeLvU3x5HsPJHZH9wpGlh5hsBu/5iQ7JuZdbR8HRyiQagoVwpyct2t7MIvzshwy1RoTF zC8JFJMvkYXnVTjYg/Hyrb3hX+V/0foj9SKVUwgUL/moEt3dFsQT9SQmddrQf9/ffEp/VY ZPXSWgjdEXhkHVZ/CeHS5oW6UCutkRU= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=EITqmBVa; spf=pass (imf12.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684141875; 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=qE+zf2yG3U5XZ1GPvj+t+kX2BtRW0PoSBcAy/uzHAnk=; b=EITqmBVaVbsbkY6hSJ8SEgcDs44S6vQk+u3vS+uidu/j5P2OOcAP1fzmwlcuneMl57qERu KyIC/YxpokxGs6khKrv7eMlIkt5oF9clilU1fdAaZhI+cQVnLRt1iP++BK+v7HRlqIh3KQ jf8rfLLttdcaTMM9itJ/VvURez6Ptfg= 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-418-L1t4JuW8MGOUd0mmDgUAjg-1; Mon, 15 May 2023 05:11:07 -0400 X-MC-Unique: L1t4JuW8MGOUd0mmDgUAjg-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 224B73814945; Mon, 15 May 2023 09:11:06 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-32.pek2.redhat.com [10.72.12.32]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9D2D840C2063; Mon, 15 May 2023 09:10:58 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-arch@vger.kernel.org, linux-mm@kvack.org, arnd@arndb.de, christophe.leroy@csgroup.eu, hch@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, David.Laight@ACULAB.COM, shorne@gmail.com, willy@infradead.org, deller@gmx.de, Baoquan He , Catalin Marinas , Will Deacon , linux-arm-kernel@lists.infradead.org Subject: [PATCH v5 RESEND 16/17] arm64 : mm: add wrapper function ioremap_prot() Date: Mon, 15 May 2023 17:08:47 +0800 Message-Id: <20230515090848.833045-17-bhe@redhat.com> In-Reply-To: <20230515090848.833045-1-bhe@redhat.com> References: <20230515090848.833045-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Rspamd-Queue-Id: 4D6184000D X-Stat-Signature: 9rxx6i4oujkqbiygpwtan17zdor8ytb4 X-Rspam-User: X-Rspamd-Server: rspam09 X-HE-Tag: 1684141876-409565 X-HE-Meta: U2FsdGVkX199M8BTO4wPjEKjNsFVATy2TYmInKle6scGeJgczQnTOmT0Ufg1FMvIYkgTqzLqhgDtLa+3WTsXceyaJD1pipvExTGLN+VVpsYukisfg8coMmWP1GbjFSirP3TMu5/DFmeJuYCJUYHtugCYjOzzqgCIRlGe89KYvNKe+x3HOKNnWzYPds/rceoUeQJZgkb6YrwzljPFQa0fka6GTU0ocAMGjtpnMCxIkeu4iVmWsFNp7SIUFyH+MBWb3CWmvLLOAqJnq23P73FzwprlVh6NLaG5lmj35btQ6i9Kmxjpkq9MOHRHnfJDUrpcnBPxAZloakCdduMUZJmJF0Z/Q4TpK5zU4xc1Oxpp1gc01KBDYP18QsGz8I9GRgLcX9kTfip5GoZx2cSvMC3JRnbSig2BG9iQBrvI2KiB/bfCliYPaSxVIQ2BMZs1gYaPiI910MH9ML9mUH80+1tsrVxKmNCl48QJgM+My77hG7IR8Ded8oQfKHdjPhq7egtflJKEhKZkKJQ6bu0Sy20ag3RN/+DRyHC/8MUc78Tx8LFoNONY4diSEzY2du+UttklN3B/+BdkvmfjVaa3BtHm6AOG2RPpTb2cgPcdjlFX7vSVfbdcIin+t+rTtdB057TISYCd/woDUfuM5mZ+35yvuVLB3z1P9XKJtSl8Nov7U2yhfof3IgMWrpCYc8Q7ZzDDCfh0t0Ym5WUhu5iYrjNQHyDotr9uyWcvXMtJCZdarpBMhSUklMHX1OP+dTVEtZxHEisEKU/WHrSI/Ncbw9QqJyclzD6mnodcCXSykOSfXR7sgUEuxClZgY7KFWB+JsEZVytb18AX9ltI634EfxpkiwqMp2fmOKZTqIiO0gr8UxUXRW/yDd32k8xwodd13WnknzTnFPc4XRtzlmsYUIBr/masraLxSoIkiYX8lUt1Y3pZp3aUBIa/0bRlLwt7aFbZLDHGB05ueg4//Z8+ATK +CPRQCTx HLkF4N8/rnbkCAK5JOfNpLnXZnzqhldr6bUPRqgAFOO+vRne7VrtjiNz95Vm3IUIjENBfSOawkPAsdGzpRSDHUHhdYrWJsmQwSb0iAPehdy+ijhDepfqfAeT08PbDoDwzbyZ5nQVaeDn4iwW0J/bTN6QvIAgSdigYbMvo+MQf9k0zGz+B138nbu1h3ihQNXtlptBVFpBjlL2QaHa2pEmQ/bBfSKbs72Ubcq/RGKUhRiSaRyeoJhp66b+ZIkmMhrCJyIhIu6IxAmR4T3wtFqVVvdkFS+308+UmdpGa6Ipa6I4/gO6Ar01z16a/f7gZkBiXlOCnaBDTg+y6Do1fw+8bz00/dKxfad0+PGzIo/wb2ttg018hV7u+varPx/7HJstXFeX3wyOIeKTvkz8= 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 Cc: Catalin Marinas Cc: Will Deacon Cc: linux-arm-kernel@lists.infradead.org Reviewed-by: Mike Rapoport (IBM) Reviewed-by: Christoph Hellwig Reviewed-by: Kefeng Wang --- 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 Mon May 15 09:08: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: 13240998 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 C711CC7EE22 for ; Mon, 15 May 2023 09:11:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6657990000A; Mon, 15 May 2023 05:11:23 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6150B900002; Mon, 15 May 2023 05:11:23 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4DCED90000A; Mon, 15 May 2023 05:11:23 -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 3BF7B900002 for ; Mon, 15 May 2023 05:11:23 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 0E1D141159 for ; Mon, 15 May 2023 09:11:23 +0000 (UTC) X-FDA: 80791920846.13.A8098C8 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 364A4160018 for ; Mon, 15 May 2023 09:11:20 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=gW9b0JNy; 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=1684141881; 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=Sk5VOSJIfD7nFCF0xkyXJ4tPwauxuD4OFust9+6yntw=; b=vd2DNvFOHcLKD91Wq/9uJojwj6u+IKzglca3oJM4/vYm94pSDcrk/VNG5mrgb3J/5eIhuR QUN/YRoK23QvtVuZLvMqF5L6SDHxq1lkC+69gPpuunB87wQAt53YXqg9/kb9nkjHdm4Lch oSkP+xmRr/ACHrMbirEeU8hO9VZpLM0= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684141881; a=rsa-sha256; cv=none; b=OMB8CWLsO4xOhAsB1s/V2HDG5GwR7LVKQTlbFsh9z6dB5tJRJ177w0mDJl4rF+KA4n6PD2 SDMCouxEOKaBcgpyX2W90r9HRc35mrLQPXgik2Sy3OjMBeiqzz9HlzngccaesANGbstcx7 p5+n+Qh+PJRigN4jmV8WtOWM8+1/qho= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=gW9b0JNy; 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684141880; 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=Sk5VOSJIfD7nFCF0xkyXJ4tPwauxuD4OFust9+6yntw=; b=gW9b0JNy69jhOGf4SMpAGEnShVZ1UoAHYXPjT07THkP0MS/gc8F6Wx2n55gm1LRXluqvMK yDoNdhIyF68A+Lg2hpycTaQ3hwJkpmbK9Ch2rq4e8aRdC1XDGNpyCfpRY8w5zF8MS2uxvp Da+XxnxGi6wCeloLlRiLmfFrgAhcwgc= 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-670-4nGHS227OHuEF4ZCDKqsZQ-1; Mon, 15 May 2023 05:11:15 -0400 X-MC-Unique: 4nGHS227OHuEF4ZCDKqsZQ-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4A63B88B767; Mon, 15 May 2023 09:11:13 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-32.pek2.redhat.com [10.72.12.32]) by smtp.corp.redhat.com (Postfix) with ESMTP id E537940C2063; Mon, 15 May 2023 09:11:06 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-arch@vger.kernel.org, linux-mm@kvack.org, arnd@arndb.de, christophe.leroy@csgroup.eu, hch@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, David.Laight@ACULAB.COM, shorne@gmail.com, willy@infradead.org, deller@gmx.de, Baoquan He Subject: [PATCH v5 RESEND 17/17] mm: ioremap: remove unneeded ioremap_allowed and iounmap_allowed Date: Mon, 15 May 2023 17:08:48 +0800 Message-Id: <20230515090848.833045-18-bhe@redhat.com> In-Reply-To: <20230515090848.833045-1-bhe@redhat.com> References: <20230515090848.833045-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Stat-Signature: 7qad6nkxmg4x7dzn3e9massz35jd3t9w X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 364A4160018 X-Rspam-User: X-HE-Tag: 1684141880-212839 X-HE-Meta: U2FsdGVkX1/5/mU30yTfhOGzRieqTPCWfuCq6Bi3SwBDMzFqhG+nIYiwOQooeWDxmEBY+qV9JgKnRuQMyEZLlXz0LFJKkykfWOmyu6pXDzJogmksOtNGomCUEwdGvRK4h8rXO1f5q+uPq7q3pdtPMPvT7tUf6ShxUdxwdB5gaJnYHZD1QBdYA3XkKXdOjIjGyIwPrlJDzs/HSOER7pKnZdfb5BiMJriqzGHMt7JO455DMGcubhZYhXZHu1Z72ZrAwHwIdNc8Lmg88fEtYwYarWQOUcPKgc8egtimM/rQjhfKEjHK+E9kXfTqArqHV4yP9R3R4sOxwleUMfD2/X1gOL+VzLmmLYgnzYh3e6FdRGPIG31H7blmpE76Ukv00Go19ybTU3XT7DKkME3MORDpla0zmy/rmpdst2w8QSM9rqPMrmdXu6wBN5X8SIAI593gE56FbJDy0CsdB537tL94oPuVa3Tuf2WLheFSIEQdsVnaXzx0isCsfW85oeUyL7+U62eNhp2prXwelhGQFboaFqLPstjCB1Wl1zlUlBNeLjdCcqOTejrAq8T6Svs2ZoTmmRCmJq9/Y5+zOdXbu9e1bHSjU8l2spkVm7ey76RwCHqlppaKgxzyKbKd3L9o5kLLqQib7qNjiJy6vGKbXTFC0S1Qv3OCbrhz10zWrbbJ0VmZ2IkaWxlsx63ACtN4wVJQL47IlwvsTRydR/uyqiOZfiZ/FFjYu03PbmmIvKHGl2hIlhdzAC99fsQAOfkIOmM935trdaT6NAL41MurS2R5R6IplQoQifapinS9YsNMcyucUVNe0dK9X78WUaeEGBG1Sp0VYIzTtDEfNcIdcguuaS+wO3aaP5rjAKlak32HMS25tgwkri+bIdcp3p7g7/npZH4lkKdq3E4Qkwn6yzJlwioRpW1GHYHjct8vRaHQEOGRetuCANTEqMgDG+eDhZ9SUcK5o/SNlaJADYbEW25 sLSuBL6E Yh/1zwH6+zB/HUDA98mTAyad8Ef2EnjRYncbfqlCTy6N8YLs7DssIliMBxYD02OjjEqO7HUb5wJ6jDOYCo3FlnO8gdz/ov9Q5pKJprFdyRpWL3/auJZeF3a+XPMk1JuqkqnIUUeFP7bNA7jWucnESgd+Rl0es/USPV/2pLlGKIyObMDBd6vfNZlsT95R2LdgO4yr3mS+obVougB6Vsp2bSObLumJjA6c5o9pq 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: Mike Rapoport (IBM) Reviewed-by: Christoph Hellwig Reviewed-by: Kefeng Wang --- 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 4a7749d85044..8cb337446bba 100644 --- a/mm/ioremap.c +++ b/mm/ioremap.c @@ -32,9 +32,6 @@ void __iomem *generic_ioremap_prot(phys_addr_t phys_addr, size_t size, phys_addr -= offset; size = PAGE_ALIGN(size + offset); - if (!ioremap_allowed(phys_addr, size, pgprot_val(prot))) - return NULL; - #ifdef IOREMAP_START area = __get_vm_area_caller(size, VM_IOREMAP, IOREMAP_START, IOREMAP_END, __builtin_return_address(0)); @@ -68,9 +65,6 @@ void generic_iounmap(volatile void __iomem *addr) { void *vaddr = (void *)((unsigned long)addr & PAGE_MASK); - if (!iounmap_allowed(vaddr)) - return; - if (is_ioremap_addr(vaddr)) vunmap(vaddr); }