From patchwork Thu Jul 6 15:45:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 116795 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp2675012vqx; Thu, 6 Jul 2023 09:17:11 -0700 (PDT) X-Google-Smtp-Source: APBJJlG2PYbJGzkIguxNVEBFpBf58UpoALiE3iaCBAjbDL4iaax4x63Xz0LnUgezX38239PPioaj X-Received: by 2002:a05:6a20:6a0f:b0:12e:5fd0:f4af with SMTP id p15-20020a056a206a0f00b0012e5fd0f4afmr2040698pzk.28.1688660231481; Thu, 06 Jul 2023 09:17:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688660231; cv=none; d=google.com; s=arc-20160816; b=OfZfUvNATPnLeLr7SFuzEuMsUm6708FfP0v7fCzrbKeaVCt78wA33xfj8NP4U93dsD m/xwivc5v5T0p4JfJWT6tfxxeJ50h2W7s6Fw9wsp7C75gOuPTavaJqhXKm1xwAxpeinY 9c35VDeeHPdJDZLzErke0axZnCvYUVAvNTt6LRjC80SqDPLWKCNvKcXltzdOCczCPD2S 5AGIh+swelD6gx8vOjd4PCpMpiBX7/XLm+i1rCTEo8V2dyVOzLbCDTrqWVlZ726Bnmmb NRC0QT9q8ooDUTrFeCV7z+omEnofbmuPolqHx/kLu96yjxkVSeKONZRcUGJYue/lLfnv W3eg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=7XRRsQjlYVMO5pNlJJ0iFpIW4AR7WspRmqGO3azs4IQ=; fh=ze1msmsKDpxrCn0dpyIqjtRqT8JH1SALSGd7u8Ep60A=; b=xfEH3hdcaQwIhQ7jENlhiOrCc/+IZr7AjYY1djZEHBufJR/Aq5IAC4LCcFeLX4gChO +1NGMCdDifiXYqGiBZ55nTp8qAyPvDmlmudObZjjWpP4MY4Q/TWeZxFksCjPCskgTgp+ rOIccI56W1SwI6hqdwOPmJudZqWEmDJYCARsewzfQ13RnjXDKuJ7V0EUepo20W2B9vPX mIGf5rQsoj6FJrY9VlGhxOOTF5SMBai/8uGQlrY3qs/Q4f/slU2KSTEjIbJhKdapnbiQ isi2nNzhkblUnjQwmzNl9KHqrWv+ofuirnwOhe6x4atSQfCrZ4I7TVlendYfLsVf23Fp WcTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=LkKqwOZg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 10-20020a62170a000000b0067b77e7f473si1612163pfx.232.2023.07.06.09.16.56; Thu, 06 Jul 2023 09:17:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=LkKqwOZg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231467AbjGFPqg (ORCPT + 99 others); Thu, 6 Jul 2023 11:46:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44810 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229996AbjGFPqf (ORCPT ); Thu, 6 Jul 2023 11:46:35 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 03F8BCE for ; Thu, 6 Jul 2023 08:45:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1688658345; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7XRRsQjlYVMO5pNlJJ0iFpIW4AR7WspRmqGO3azs4IQ=; b=LkKqwOZgJ5SwAjvREbQ5gBB/xmnfT/nQcWuaQhGnv99EcBb8EkW0Ir8SqSmj/fNZLhwdnW mNs0CV4fdbNkyt9pZ/Mc2gcWFWSz59OmVKZ0U0jeGVZsbtQTso8dTzHZZpdpvfhfTMgRh0 rNbrgFcyT+xF5OIRj0lPjLvIMEbfxbY= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-247-rDwJ6E9hNMKvwMZGj3GkyQ-1; Thu, 06 Jul 2023 11:45:42 -0400 X-MC-Unique: rDwJ6E9hNMKvwMZGj3GkyQ-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 409CF858EED; Thu, 6 Jul 2023 15:45:41 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-39.pek2.redhat.com [10.72.12.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4EE0EF6431; Thu, 6 Jul 2023 15:45:32 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: akpm@linux-foundation.org, linux-mm@kvack.org, arnd@arndb.de, hch@lst.de, christophe.leroy@csgroup.eu, rppt@kernel.org, willy@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, shorne@gmail.com, David.Laight@ACULAB.COM, deller@gmx.de, nathan@kernel.org, glaubitz@physik.fu-berlin.de, Baoquan He , Geert Uytterhoeven Subject: [PATCH v8 01/19] asm-generic/iomap.h: remove ARCH_HAS_IOREMAP_xx macros Date: Thu, 6 Jul 2023 23:45:02 +0800 Message-Id: <20230706154520.11257-2-bhe@redhat.com> In-Reply-To: <20230706154520.11257-1-bhe@redhat.com> References: <20230706154520.11257-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770688590811896476?= X-GMAIL-MSGID: =?utf-8?q?1770688590811896476?= Let's use '#define ioremap_xx' and "#ifdef ioremap_xx" instead. To remove defined ARCH_HAS_IOREMAP_xx macros in of each ARCH, the ARCH's own ioremap_wc|wt|np definition need be above "#include . Otherwise the redefinition error would be seen during compiling. So the relevant adjustments are made to avoid compiling error: loongarch: - doesn't include , defining ARCH_HAS_IOREMAP_WC is redundant, so simply remove it. m68k: - selected GENERIC_IOMAP, has been added in , and is included above , so simply remove ARCH_HAS_IOREMAP_WT defining. mips: - move "#include " below ioremap_wc definition in powerpc: - remove "#include " in because it's duplicated with the one in , let's rely on the latter. x86: - selected GENERIC_IOMAP, remove #include in the middle of . Let's rely on . Signed-off-by: Baoquan He Acked-by: Geert Uytterhoeven Reviewed-by: Mike Rapoport (IBM) Reviewed-by: Christoph Hellwig --- arch/loongarch/include/asm/io.h | 2 -- arch/m68k/include/asm/io_mm.h | 2 -- arch/m68k/include/asm/kmap.h | 2 -- arch/mips/include/asm/io.h | 5 ++--- arch/powerpc/include/asm/io.h | 9 +-------- arch/x86/include/asm/io.h | 5 ----- drivers/net/ethernet/sfc/io.h | 2 +- drivers/net/ethernet/sfc/siena/io.h | 2 +- include/asm-generic/iomap.h | 6 +++--- 9 files changed, 8 insertions(+), 27 deletions(-) diff --git a/arch/loongarch/include/asm/io.h b/arch/loongarch/include/asm/io.h index 1c9410220040..0dcb36b32cb2 100644 --- a/arch/loongarch/include/asm/io.h +++ b/arch/loongarch/include/asm/io.h @@ -5,8 +5,6 @@ #ifndef _ASM_IO_H #define _ASM_IO_H -#define ARCH_HAS_IOREMAP_WC - #include #include diff --git a/arch/m68k/include/asm/io_mm.h b/arch/m68k/include/asm/io_mm.h index d41fa488453b..6a0abd4846c6 100644 --- a/arch/m68k/include/asm/io_mm.h +++ b/arch/m68k/include/asm/io_mm.h @@ -26,8 +26,6 @@ #include #include -#include - #ifdef CONFIG_ATARI #define atari_readb raw_inb #define atari_writeb raw_outb diff --git a/arch/m68k/include/asm/kmap.h b/arch/m68k/include/asm/kmap.h index dec05743d426..4efb3efa593a 100644 --- a/arch/m68k/include/asm/kmap.h +++ b/arch/m68k/include/asm/kmap.h @@ -4,8 +4,6 @@ #ifdef CONFIG_MMU -#define ARCH_HAS_IOREMAP_WT - /* Values for nocacheflag and cmode */ #define IOMAP_FULL_CACHING 0 #define IOMAP_NOCACHE_SER 1 diff --git a/arch/mips/include/asm/io.h b/arch/mips/include/asm/io.h index affd21e9c20b..062dd4e6b954 100644 --- a/arch/mips/include/asm/io.h +++ b/arch/mips/include/asm/io.h @@ -12,8 +12,6 @@ #ifndef _ASM_IO_H #define _ASM_IO_H -#define ARCH_HAS_IOREMAP_WC - #include #include #include @@ -25,7 +23,6 @@ #include #include #include -#include #include #include #include @@ -210,6 +207,8 @@ void iounmap(const volatile void __iomem *addr); #define ioremap_wc(offset, size) \ ioremap_prot((offset), (size), boot_cpu_data.writecombine) +#include + #if defined(CONFIG_CPU_CAVIUM_OCTEON) #define war_io_reorder_wmb() wmb() #else diff --git a/arch/powerpc/include/asm/io.h b/arch/powerpc/include/asm/io.h index f1e657c9bbe8..67a3fb6de498 100644 --- a/arch/powerpc/include/asm/io.h +++ b/arch/powerpc/include/asm/io.h @@ -3,11 +3,6 @@ #define _ASM_POWERPC_IO_H #ifdef __KERNEL__ -#define ARCH_HAS_IOREMAP_WC -#ifdef CONFIG_PPC32 -#define ARCH_HAS_IOREMAP_WT -#endif - /* */ @@ -732,9 +727,7 @@ static inline void name at \ #define writel_relaxed(v, addr) writel(v, addr) #define writeq_relaxed(v, addr) writeq(v, addr) -#ifdef CONFIG_GENERIC_IOMAP -#include -#else +#ifndef CONFIG_GENERIC_IOMAP /* * Here comes the implementation of the IOMAP interfaces. */ diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h index e9025640f634..76238842406a 100644 --- a/arch/x86/include/asm/io.h +++ b/arch/x86/include/asm/io.h @@ -35,9 +35,6 @@ * - Arnaldo Carvalho de Melo */ -#define ARCH_HAS_IOREMAP_WC -#define ARCH_HAS_IOREMAP_WT - #include #include #include @@ -212,8 +209,6 @@ void memset_io(volatile void __iomem *, int, size_t); #define memcpy_toio memcpy_toio #define memset_io memset_io -#include - /* * ISA space is 'always mapped' on a typical x86 system, no need to * explicitly ioremap() it. The fact that the ISA IO space is mapped diff --git a/drivers/net/ethernet/sfc/io.h b/drivers/net/ethernet/sfc/io.h index 30439cc83a89..07f99ad14bf3 100644 --- a/drivers/net/ethernet/sfc/io.h +++ b/drivers/net/ethernet/sfc/io.h @@ -70,7 +70,7 @@ */ #ifdef CONFIG_X86_64 /* PIO is a win only if write-combining is possible */ -#ifdef ARCH_HAS_IOREMAP_WC +#ifdef ioremap_wc #define EFX_USE_PIO 1 #endif #endif diff --git a/drivers/net/ethernet/sfc/siena/io.h b/drivers/net/ethernet/sfc/siena/io.h index 30439cc83a89..07f99ad14bf3 100644 --- a/drivers/net/ethernet/sfc/siena/io.h +++ b/drivers/net/ethernet/sfc/siena/io.h @@ -70,7 +70,7 @@ */ #ifdef CONFIG_X86_64 /* PIO is a win only if write-combining is possible */ -#ifdef ARCH_HAS_IOREMAP_WC +#ifdef ioremap_wc #define EFX_USE_PIO 1 #endif #endif diff --git a/include/asm-generic/iomap.h b/include/asm-generic/iomap.h index 08237ae8b840..196087a8126e 100644 --- a/include/asm-generic/iomap.h +++ b/include/asm-generic/iomap.h @@ -93,15 +93,15 @@ extern void __iomem *ioport_map(unsigned long port, unsigned int nr); extern void ioport_unmap(void __iomem *); #endif -#ifndef ARCH_HAS_IOREMAP_WC +#ifndef ioremap_wc #define ioremap_wc ioremap #endif -#ifndef ARCH_HAS_IOREMAP_WT +#ifndef ioremap_wt #define ioremap_wt ioremap #endif -#ifndef ARCH_HAS_IOREMAP_NP +#ifndef ioremap_np /* See the comment in asm-generic/io.h about ioremap_np(). */ #define ioremap_np ioremap_np static inline void __iomem *ioremap_np(phys_addr_t offset, size_t size) From patchwork Thu Jul 6 15:45:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 116769 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp2656108vqx; Thu, 6 Jul 2023 08:49:46 -0700 (PDT) X-Google-Smtp-Source: APBJJlH7RjSH5wjyN86w97QV5r7Yz6IHM9kDdJhtvwibs/t8ME3foUSm3iaiuCqHkffGGOJDHEfh X-Received: by 2002:a17:902:dac7:b0:1b8:a56b:989d with SMTP id q7-20020a170902dac700b001b8a56b989dmr2646100plx.6.1688658585846; Thu, 06 Jul 2023 08:49:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688658585; cv=none; d=google.com; s=arc-20160816; b=aOoxPBEeM3n6uReYQVIEdV856d13cNq3ZgIbfngZ80RNIr7UiD0HW3y1KR5KrWccOF KcKyOUUqf0OkBJo6VbRqjUTPCD71LDSnz4BNIkEiSLUtiZ+t7PeI1wUy8TVusVxcbZDt eLyQrggd6Um/2aW9+M8vA7QJVjqHZuaakTGNfIwWVwOV0OHqoTgkBYeM2BeTygayilVf NxorLL9RYqpe/fLPmQMstlFsIPBXZIOOpr8SbQ0RpNpw4gyqDuiryizEEaEi0pq2sl3u QEI9W+VMrpAv7iqVoufGMR8Thnpqgbw+RoWq7bKRCbe9wqehBswsCD/prk+PC6WrxZ4E CJbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=mrpD6SwU7RX+eLIqGEOviqMeuTumyLFYQ/9zvaQiSxE=; fh=2QBV+eaeUTe0tpj4hCVUAxcfQ4Vscp+8yGKN261Ew90=; b=YaaYRurWi5QRvCvU7uTiPle7ywYWsTbVtn8l22/pwbEX/jF36OXrPjGqWT421nRGhq d+UPTmsTZ7MlXyeNhbAgszjiZwIbCqqb/Tfzxq7uS1/YW6VZYsCAIgE06mB4pTRJSuBw C9ahSP/gIk20vP/TyaZ66jnZIoB4jkHSUObuP3QNzA+2o1gzUOJbFkq14Upuy0i+PYmG jx4Jkbo9AqEeOdeqK0BUmhdT6qA1TajYLtxRu9E6Hsu5uWe+NkM0QPurafzLKKQIF4GK x70k2CVh0zDB8l8CNMtzSr6PURpNzeVW1gvjjCxL6RW8bPcLOrLJDeF+GXu+6OSjTJeN X/eA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=CF5CbSbe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h8-20020a170902748800b001ac6e1fd203si1472844pll.180.2023.07.06.08.49.32; Thu, 06 Jul 2023 08:49:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=CF5CbSbe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231895AbjGFPqo (ORCPT + 99 others); Thu, 6 Jul 2023 11:46:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44832 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231630AbjGFPqm (ORCPT ); Thu, 6 Jul 2023 11:46:42 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8458C1997 for ; Thu, 6 Jul 2023 08:45:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1688658356; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mrpD6SwU7RX+eLIqGEOviqMeuTumyLFYQ/9zvaQiSxE=; b=CF5CbSbepFAGqMzBkKm5mjTGFBTnC6mlNAA2/gnHxi9pNXyX54YOIKKeijB42IVdPgFXFN I3ivcB83Rt01q2W2uygSfpP6UgU6GnYC849JifLymlrUW6DlD7m1J+YRw65SZTJWN4sFlo FvWMCU8nkOmLzIyP9eE8P58Sw03+gnE= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-601-mre9K1UsPoOt1IOmZqTezw-1; Thu, 06 Jul 2023 11:45:51 -0400 X-MC-Unique: mre9K1UsPoOt1IOmZqTezw-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5318B3C0D845; Thu, 6 Jul 2023 15:45:50 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-39.pek2.redhat.com [10.72.12.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id 067C9F5CF0; Thu, 6 Jul 2023 15:45:41 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: akpm@linux-foundation.org, linux-mm@kvack.org, arnd@arndb.de, hch@lst.de, christophe.leroy@csgroup.eu, rppt@kernel.org, willy@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, shorne@gmail.com, David.Laight@ACULAB.COM, deller@gmx.de, nathan@kernel.org, glaubitz@physik.fu-berlin.de, Baoquan He , Brian Cain , linux-hexagon@vger.kernel.org Subject: [PATCH v8 02/19] hexagon: mm: Convert to GENERIC_IOREMAP Date: Thu, 6 Jul 2023 23:45:03 +0800 Message-Id: <20230706154520.11257-3-bhe@redhat.com> In-Reply-To: <20230706154520.11257-1-bhe@redhat.com> References: <20230706154520.11257-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770686865267490429?= X-GMAIL-MSGID: =?utf-8?q?1770686865267490429?= By taking GENERIC_IOREMAP method, the generic ioremap_prot() and iounmap() are visible and available to arch. This change will simplify implementation by removing duplicated code with generic ioremap_prot() and iounmap(), and has the equivalent functioality. For hexagon, the current ioremap() and iounmap() are the same as generic version. After taking GENERIC_IOREMAP way, the old ioremap() and iounmap() can be completely removed. Signed-off-by: Baoquan He Cc: Brian Cain Cc: linux-hexagon@vger.kernel.org Reviewed-by: Christoph Hellwig --- v7->v8: Fix the error reported by lkp test robot on patch. Thanks to Nathan for providing the code fix after reproducing. arch/hexagon/Kconfig | 1 + arch/hexagon/include/asm/io.h | 11 +++++--- arch/hexagon/kernel/hexagon_ksyms.c | 2 -- arch/hexagon/mm/Makefile | 2 +- arch/hexagon/mm/ioremap.c | 44 ----------------------------- 5 files changed, 9 insertions(+), 51 deletions(-) delete mode 100644 arch/hexagon/mm/ioremap.c diff --git a/arch/hexagon/Kconfig b/arch/hexagon/Kconfig index 6726f4941015..a880ee067d2e 100644 --- a/arch/hexagon/Kconfig +++ b/arch/hexagon/Kconfig @@ -25,6 +25,7 @@ config HEXAGON select NEED_SG_DMA_LENGTH select NO_IOPORT_MAP select GENERIC_IOMAP + select GENERIC_IOREMAP select GENERIC_SMP_IDLE_THREAD select STACKTRACE_SUPPORT select GENERIC_CLOCKEVENTS_BROADCAST diff --git a/arch/hexagon/include/asm/io.h b/arch/hexagon/include/asm/io.h index 46a099de85b7..e2b308e32a37 100644 --- a/arch/hexagon/include/asm/io.h +++ b/arch/hexagon/include/asm/io.h @@ -27,8 +27,6 @@ extern int remap_area_pages(unsigned long start, unsigned long phys_addr, unsigned long end, unsigned long flags); -extern void iounmap(const volatile void __iomem *addr); - /* Defined in lib/io.c, needed for smc91x driver. */ extern void __raw_readsw(const void __iomem *addr, void *data, int wordlen); extern void __raw_writesw(void __iomem *addr, const void *data, int wordlen); @@ -170,8 +168,13 @@ static inline void writel(u32 data, volatile void __iomem *addr) #define writew_relaxed __raw_writew #define writel_relaxed __raw_writel -void __iomem *ioremap(unsigned long phys_addr, unsigned long size); -#define ioremap_uc(X, Y) ioremap((X), (Y)) +/* + * I/O memory mapping functions. + */ +#define _PAGE_IOREMAP (_PAGE_PRESENT | _PAGE_READ | _PAGE_WRITE | \ + (__HEXAGON_C_DEV << 6)) + +#define ioremap_uc(addr, size) ioremap((addr), (size)) #define __raw_writel writel diff --git a/arch/hexagon/kernel/hexagon_ksyms.c b/arch/hexagon/kernel/hexagon_ksyms.c index ec56ce2d92a2..36a80e31d187 100644 --- a/arch/hexagon/kernel/hexagon_ksyms.c +++ b/arch/hexagon/kernel/hexagon_ksyms.c @@ -14,12 +14,10 @@ EXPORT_SYMBOL(__clear_user_hexagon); EXPORT_SYMBOL(raw_copy_from_user); EXPORT_SYMBOL(raw_copy_to_user); -EXPORT_SYMBOL(iounmap); EXPORT_SYMBOL(__vmgetie); EXPORT_SYMBOL(__vmsetie); EXPORT_SYMBOL(__vmyield); EXPORT_SYMBOL(empty_zero_page); -EXPORT_SYMBOL(ioremap); EXPORT_SYMBOL(memcpy); EXPORT_SYMBOL(memset); diff --git a/arch/hexagon/mm/Makefile b/arch/hexagon/mm/Makefile index 49911a906fd0..ba4b04d962d6 100644 --- a/arch/hexagon/mm/Makefile +++ b/arch/hexagon/mm/Makefile @@ -3,5 +3,5 @@ # Makefile for Hexagon memory management subsystem # -obj-y := init.o ioremap.o uaccess.o vm_fault.o cache.o +obj-y := init.o uaccess.o vm_fault.o cache.o obj-y += copy_to_user.o copy_from_user.o vm_tlb.o diff --git a/arch/hexagon/mm/ioremap.c b/arch/hexagon/mm/ioremap.c deleted file mode 100644 index 255c5b1ee1a7..000000000000 --- a/arch/hexagon/mm/ioremap.c +++ /dev/null @@ -1,44 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-only -/* - * I/O remap functions for Hexagon - * - * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved. - */ - -#include -#include -#include - -void __iomem *ioremap(unsigned long phys_addr, unsigned long size) -{ - unsigned long last_addr, addr; - unsigned long offset = phys_addr & ~PAGE_MASK; - struct vm_struct *area; - - pgprot_t prot = __pgprot(_PAGE_PRESENT|_PAGE_READ|_PAGE_WRITE - |(__HEXAGON_C_DEV << 6)); - - last_addr = phys_addr + size - 1; - - /* Wrapping not allowed */ - if (!size || (last_addr < phys_addr)) - return NULL; - - /* Rounds up to next page size, including whole-page offset */ - size = PAGE_ALIGN(offset + size); - - area = get_vm_area(size, VM_IOREMAP); - addr = (unsigned long)area->addr; - - if (ioremap_page_range(addr, addr+size, phys_addr, prot)) { - vunmap((void *)addr); - return NULL; - } - - return (void __iomem *) (offset + addr); -} - -void iounmap(const volatile void __iomem *addr) -{ - vunmap((void *) ((unsigned long) addr & PAGE_MASK)); -} From patchwork Thu Jul 6 15:45:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 116790 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp2673508vqx; Thu, 6 Jul 2023 09:15:14 -0700 (PDT) X-Google-Smtp-Source: APBJJlFsjXTAVGbGTtnmQWC9wC+GWR6Wiey8hRzjCM6BCFuqcIQfmKcQGbosJIm7vBh6TyRuzjMl X-Received: by 2002:a05:6a00:10c9:b0:66f:7076:a5b8 with SMTP id d9-20020a056a0010c900b0066f7076a5b8mr2087823pfu.29.1688660114072; Thu, 06 Jul 2023 09:15:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688660114; cv=none; d=google.com; s=arc-20160816; b=uZf7wLc3bzFL2D/uEw1jY7JcVDopEyhR+hmex90ofd9CezmB3nUv4tzRYsinyq7kF4 CKyzO70eAFkXMicvw5qxCI9gfDFcT7VNnFl5NVVIRJPEAkQKNMFteGD8sbTnROS+cVB4 SbRIKF2L1Qg3eR1PMfRuFfnqawpdmEdmXWNzFRdjJY4YzqelNWLDqcGttpGZNzlpK/vL sj5QH3u75J/LbEarBvddb1hyGp9IxIetaE+59YgmsajPJNFOEkJ5vwsGPWGhsIWqE0Y1 6Xbg4mdYOa8I0NSE4qg3vljH66YFsO/9eNbsx8MwKVXaheL2TQazv11kgrO2V8BMrUPl ksIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=pQumlSibFcTmcmpj3o91A5K5Zwuz/UGXp5mnVQ2pvKA=; fh=eeeeInr/MmFywiB7btX0C71N9ahYx+v9/M7/z0Zrcp0=; b=iQ3MgNGF+z3tnGxzWle77o+qgBPl7rMnD+OnWM4NDEz7Ss1/DLcJu6nhvdU2CgkaA4 5o3ifTQ3CU6sAyW7omIayQjWGW7u5ITilW2hynzf+7LwPBmptqGBSOhVWRDiSgUNRiLs LkNpbeT0x0Ig+JoV5C5iiFnr/rfVhIKETKMnN8gLgNg533KrFpbpVmAkAR3lFMwWxJwf XbZOoBUx1Nvq/Pv6vtnvtVST0tbH1LOvLHSU0loXSqxvIwfvKc4s0cUQL/1EfukAMa06 3iC0LkRzL/CG174hsCwKpiz0lAPSoWkSd0SaXWLIrm9Mtv7EQLeOzK1oWBfZ4EHu+bay QjQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=fpXlYj5Z; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x69-20020a638648000000b0053eefa04dc0si1669968pgd.276.2023.07.06.09.14.59; Thu, 06 Jul 2023 09:15:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=fpXlYj5Z; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231909AbjGFPqy (ORCPT + 99 others); Thu, 6 Jul 2023 11:46:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44854 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229996AbjGFPqw (ORCPT ); Thu, 6 Jul 2023 11:46:52 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B3C819A7 for ; Thu, 6 Jul 2023 08:46:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1688658363; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=pQumlSibFcTmcmpj3o91A5K5Zwuz/UGXp5mnVQ2pvKA=; b=fpXlYj5ZHPP/E4JamhDvSdyC6ON0dj86/WGxFcnSHYYEw0rL0/3jcaZr7xomEH9AnTOiMS +qTF55Iwu5E4caW8BgxSSVMCpLubPvpVV8AqasR5W5EnLST9uJaQd6/VVyGBKiKJjcCIzo TxIo8gKiHgreEUwoybSIwceB6xP1Gtg= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-441-pVjnAUWyOpa14DMQOD0ttQ-1; Thu, 06 Jul 2023 11:46:02 -0400 X-MC-Unique: pVjnAUWyOpa14DMQOD0ttQ-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 55F7B101A528; Thu, 6 Jul 2023 15:46:00 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-39.pek2.redhat.com [10.72.12.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id 22C8FF5CF0; Thu, 6 Jul 2023 15:45:50 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: akpm@linux-foundation.org, linux-mm@kvack.org, arnd@arndb.de, hch@lst.de, christophe.leroy@csgroup.eu, rppt@kernel.org, willy@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, shorne@gmail.com, David.Laight@ACULAB.COM, deller@gmx.de, nathan@kernel.org, glaubitz@physik.fu-berlin.de, Baoquan He , Jonas Bonn , Stefan Kristiansson , openrisc@lists.librecores.org Subject: [PATCH v8 03/19] openrisc: mm: remove unneeded early ioremap code Date: Thu, 6 Jul 2023 23:45:04 +0800 Message-Id: <20230706154520.11257-4-bhe@redhat.com> In-Reply-To: <20230706154520.11257-1-bhe@redhat.com> References: <20230706154520.11257-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770688468007791685?= X-GMAIL-MSGID: =?utf-8?q?1770688468007791685?= Under arch/openrisc, there isn't any place where ioremap() is called. It means that there isn't early ioremap handling needed in openrisc, So the early ioremap handling code in ioremap() of arch/openrisc/mm/ioremap.c is unnecessary and can be removed. And also remove the special handling in iounmap() since no page is got from fixmap pool along with early ioremap code removing in ioremap(). Link: https://lore.kernel.org/linux-mm/YwxfxKrTUtAuejKQ@oscomms1/ Signed-off-by: Baoquan He Acked-by: Stafford Horne Reviewed-by: Christoph Hellwig Reviewed-by: Mike Rapoport (IBM) Cc: Jonas Bonn Cc: Stefan Kristiansson Cc: Stafford Horne Cc: openrisc@lists.librecores.org --- arch/openrisc/mm/ioremap.c | 43 +++++--------------------------------- 1 file changed, 5 insertions(+), 38 deletions(-) diff --git a/arch/openrisc/mm/ioremap.c b/arch/openrisc/mm/ioremap.c index 8ec0dafecf25..cdbcc7e73684 100644 --- a/arch/openrisc/mm/ioremap.c +++ b/arch/openrisc/mm/ioremap.c @@ -22,8 +22,6 @@ extern int mem_init_done; -static unsigned int fixmaps_used __initdata; - /* * Remap an arbitrary physical address space into the kernel virtual * address space. Needed when the kernel wants to access high addresses @@ -52,24 +50,14 @@ void __iomem *__ref ioremap(phys_addr_t addr, unsigned long size) p = addr & PAGE_MASK; size = PAGE_ALIGN(last_addr + 1) - p; - if (likely(mem_init_done)) { - area = get_vm_area(size, VM_IOREMAP); - if (!area) - return NULL; - v = (unsigned long)area->addr; - } else { - if ((fixmaps_used + (size >> PAGE_SHIFT)) > FIX_N_IOREMAPS) - return NULL; - v = fix_to_virt(FIX_IOREMAP_BEGIN + fixmaps_used); - fixmaps_used += (size >> PAGE_SHIFT); - } + area = get_vm_area(size, VM_IOREMAP); + if (!area) + return NULL; + v = (unsigned long)area->addr; if (ioremap_page_range(v, v + size, p, __pgprot(pgprot_val(PAGE_KERNEL) | _PAGE_CI))) { - if (likely(mem_init_done)) - vfree(area->addr); - else - fixmaps_used -= (size >> PAGE_SHIFT); + vfree(area->addr); return NULL; } @@ -79,27 +67,6 @@ EXPORT_SYMBOL(ioremap); void iounmap(volatile void __iomem *addr) { - /* If the page is from the fixmap pool then we just clear out - * the fixmap mapping. - */ - if (unlikely((unsigned long)addr > FIXADDR_START)) { - /* This is a bit broken... we don't really know - * how big the area is so it's difficult to know - * how many fixed pages to invalidate... - * just flush tlb and hope for the best... - * consider this a FIXME - * - * Really we should be clearing out one or more page - * table entries for these virtual addresses so that - * future references cause a page fault... for now, we - * rely on two things: - * i) this code never gets called on known boards - * ii) invalid accesses to the freed areas aren't made - */ - flush_tlb_all(); - return; - } - return vfree((void *)(PAGE_MASK & (unsigned long)addr)); } EXPORT_SYMBOL(iounmap); From patchwork Thu Jul 6 15:45:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 116791 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp2674039vqx; Thu, 6 Jul 2023 09:15:52 -0700 (PDT) X-Google-Smtp-Source: APBJJlHjsmLhCcYxiJHqMZE+T7/iIxb4nm0oF+Y/l32+rGNG32Ld37sZTWLaEGNCwyZxUMILdSYs X-Received: by 2002:a17:902:ea0c:b0:1b8:9461:6717 with SMTP id s12-20020a170902ea0c00b001b894616717mr8508039plg.6.1688660152171; Thu, 06 Jul 2023 09:15:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688660152; cv=none; d=google.com; s=arc-20160816; b=dtn0NkhjmGReDXRBGm0VqJpUSyGzAXqfQpnOTltFvVMTOSFT9Q5PyGTl+QFYSy5yuA IWECO6YPE800xuITlx2Pf2HgBL4utYm3mO2TqIRjo7J0clUKtFfKCKvTaK81FPtV/TIa 9O3t2/UiHQ8wHtf80LyLxbv+CQQo2TpQfVsswM0Ehx1CiOq2ezW1xYipMzqR69rEn3Ki We9Dbmp+LQB9KSoC2mexwH22EBfNSh8dGwFe7cL3jvrcj94fLObrgcKXFhTT1rfI9bT7 Q67Ms/XiFHpMJfzhiMfHpdpY9aUUmv0HJq9du1PAw7b1a7MmGzdEIlSehFAH7Y735L07 kHEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=X3bCqAOghUMsrFt01sdBss+0xjEFSAaHuAsd0sFdmyw=; fh=MRqAqm0/X6LLHlLdJym4NBXwcTEGRfSmsWs7mgX78Dg=; b=PUT27LKnPqPPSgJcEtybmz59xVeABgK1tMisTfdKYuUj5XybMjtne9ah+o0MPwe+UA UvPYiqQLoj08QAxslgR0NwIpRYmG/AKxSqSUX1OUQpjl+rK3tDphRp73iggC1uPbL/b0 NdwS7HtBJ3sTfgljkfqmJ1c8UdmTMPP8XgAnpybVcCkvqrIr5AB2gT3+VoiKhsKhX1NZ yERqidIaIQJYt8KX4lS52J7aGTIZ3SYW36H04RlIOYqII39aDWTnIiawNTWnsl28+fAT Y6p5ArUj/4qcACckN1T9NFiqXRONCtSGqfNAl/J8oLTKhZK+19kD5Bfhh/i949qnNBIv YT/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=IF8fGozy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t13-20020a1709027fcd00b001b546795669si1525878plb.391.2023.07.06.09.15.36; Thu, 06 Jul 2023 09:15:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=IF8fGozy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231963AbjGFPrH (ORCPT + 99 others); Thu, 6 Jul 2023 11:47:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44884 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229996AbjGFPrF (ORCPT ); Thu, 6 Jul 2023 11:47:05 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AEE7C19B2 for ; Thu, 6 Jul 2023 08:46:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1688658375; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=X3bCqAOghUMsrFt01sdBss+0xjEFSAaHuAsd0sFdmyw=; b=IF8fGozyH5BdhjFxzK679BBw/9Vjxcr92sKiIfGmtl0lb1z2ND3p3nw7u8zP60y/6b6t5H XF0ZR+nPuKwVR9NCJWzEsB7Am+lui6QbiJ5o9YuxeI5FVi7cAFLi76ZEwbj0kBcv+mYPaE v8i8fgkSGS04+aGinf+iFgKFYO2tXuQ= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-556-7eAVe7wZPSC4sGD6Lhz-8w-1; Thu, 06 Jul 2023 11:46:10 -0400 X-MC-Unique: 7eAVe7wZPSC4sGD6Lhz-8w-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id EC4E6185A792; Thu, 6 Jul 2023 15:46:08 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-39.pek2.redhat.com [10.72.12.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2D76AF5CF0; Thu, 6 Jul 2023 15:46:00 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: akpm@linux-foundation.org, linux-mm@kvack.org, arnd@arndb.de, hch@lst.de, christophe.leroy@csgroup.eu, rppt@kernel.org, willy@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, shorne@gmail.com, David.Laight@ACULAB.COM, deller@gmx.de, nathan@kernel.org, glaubitz@physik.fu-berlin.de, Baoquan He Subject: [PATCH v8 04/19] mm/ioremap: Define generic_ioremap_prot() and generic_iounmap() Date: Thu, 6 Jul 2023 23:45:05 +0800 Message-Id: <20230706154520.11257-5-bhe@redhat.com> In-Reply-To: <20230706154520.11257-1-bhe@redhat.com> References: <20230706154520.11257-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770688507432418491?= X-GMAIL-MSGID: =?utf-8?q?1770688507432418491?= From: Christophe Leroy Define a generic version of ioremap_prot() and iounmap() that architectures can call after they have performed the necessary alteration to parameters and/or necessary verifications. Signed-off-by: Christophe Leroy Signed-off-by: Baoquan He Reviewed-by: Christoph Hellwig Reviewed-by: Kefeng Wang Reviewed-by: Mike Rapoport (IBM) --- include/asm-generic/io.h | 4 ++++ mm/ioremap.c | 22 ++++++++++++++++------ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/include/asm-generic/io.h b/include/asm-generic/io.h index 587e7e9b9a37..a7ca2099ba19 100644 --- a/include/asm-generic/io.h +++ b/include/asm-generic/io.h @@ -1073,9 +1073,13 @@ static inline bool iounmap_allowed(void *addr) } #endif +void __iomem *generic_ioremap_prot(phys_addr_t phys_addr, size_t size, + pgprot_t prot); + void __iomem *ioremap_prot(phys_addr_t phys_addr, size_t size, unsigned long prot); void iounmap(volatile void __iomem *addr); +void generic_iounmap(volatile void __iomem *addr); static inline void __iomem *ioremap(phys_addr_t addr, size_t size) { diff --git a/mm/ioremap.c b/mm/ioremap.c index 8652426282cc..db6234b9db59 100644 --- a/mm/ioremap.c +++ b/mm/ioremap.c @@ -11,8 +11,8 @@ #include #include -void __iomem *ioremap_prot(phys_addr_t phys_addr, size_t size, - unsigned long prot) +void __iomem *generic_ioremap_prot(phys_addr_t phys_addr, size_t size, + pgprot_t prot) { unsigned long offset, vaddr; phys_addr_t last_addr; @@ -28,7 +28,7 @@ void __iomem *ioremap_prot(phys_addr_t phys_addr, size_t size, phys_addr -= offset; size = PAGE_ALIGN(size + offset); - if (!ioremap_allowed(phys_addr, size, prot)) + if (!ioremap_allowed(phys_addr, size, pgprot_val(prot))) return NULL; area = get_vm_area_caller(size, VM_IOREMAP, @@ -38,17 +38,22 @@ void __iomem *ioremap_prot(phys_addr_t phys_addr, size_t size, vaddr = (unsigned long)area->addr; area->phys_addr = phys_addr; - if (ioremap_page_range(vaddr, vaddr + size, phys_addr, - __pgprot(prot))) { + if (ioremap_page_range(vaddr, vaddr + size, phys_addr, prot)) { free_vm_area(area); return NULL; } return (void __iomem *)(vaddr + offset); } + +void __iomem *ioremap_prot(phys_addr_t phys_addr, size_t size, + unsigned long prot) +{ + return generic_ioremap_prot(phys_addr, size, __pgprot(prot)); +} EXPORT_SYMBOL(ioremap_prot); -void iounmap(volatile void __iomem *addr) +void generic_iounmap(volatile void __iomem *addr) { void *vaddr = (void *)((unsigned long)addr & PAGE_MASK); @@ -58,4 +63,9 @@ void iounmap(volatile void __iomem *addr) if (is_vmalloc_addr(vaddr)) vunmap(vaddr); } + +void iounmap(volatile void __iomem *addr) +{ + generic_iounmap(addr); +} EXPORT_SYMBOL(iounmap); From patchwork Thu Jul 6 15:45:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 116771 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp2656349vqx; Thu, 6 Jul 2023 08:50:15 -0700 (PDT) X-Google-Smtp-Source: APBJJlGrgMGeyR3XaYQVwcShygCkNzt4kvL1wiMCDgFoa1NMnJvD2YP/A/k48qeg5O7MBas8INrK X-Received: by 2002:a17:903:2448:b0:1a2:a904:c42e with SMTP id l8-20020a170903244800b001a2a904c42emr4085382pls.24.1688658614870; Thu, 06 Jul 2023 08:50:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688658614; cv=none; d=google.com; s=arc-20160816; b=yUlW5YXX7D/4taNZFmC2ainrrp46lDfkwRB1+yUM7GimHmU6ijTsI2ZDY1xCWKanH7 WTjyGQpSrpJkkic9oaQm5308NKi4LUUTVCNWwyylH8LXnp60mwf0Ef3uxKSL2krKumiO dAf6xIfkDHB7BX8UomvBc/T3/RbrBuiO7q3c3MQG1Kx5K8au94rnCjztCg0hfP3+wIHf JKtTbUVuFt4GqJN8TrQqYbId3uwWSqb7Y9Na8TLX4CpxBlnACq0zd7Et3agmlefbkfRO /8I/lZn27zR0ycKi6OqnGCZ8vq1kwv6W+VE8cLrcUmfyZ+oRVkL2a8D2sAFyin2Y450R oSag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=7Tl0uNK3iTFKABiIz7zb0nAC1GuwS9Iddx7rewdSaxU=; fh=Gzorixg490ZTdswETp+N6V5LjCPPpoJF3e6I9RXS4U0=; b=JngIioCFplfNnzE2y1qnVdwlB7NOtutuHOc275pJg+KZcDtSObKrLPqi697AwNX3AE rL5EKiTom9AlCnFR6xjkAjUUngNFhtQkl2fvu9Hh9YC0sfefo8hZT9inSHvAOw1AtzQ3 +L38ReSnZM5bZHsDmPBldc+lqIjnny8p0pDID54T6dWQjAcUXrGFx8y7pe+m3VVXJIwb KTNbjBZbuyH5+QQSrWAyqO9+H88hO7IvpEMN62QoOFtUWqKEwQG2xawy94i4Sxd79v28 +EwflwrxTF7BVdjKl9BeaKckXxALnI0r+g5N8lcCALKAo/haqhhQAuwPP9wmGAegE/TI c60w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Qhzgkb89; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r1-20020a170902e3c100b001b89f814e92si1410836ple.164.2023.07.06.08.49.59; Thu, 06 Jul 2023 08:50:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Qhzgkb89; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231613AbjGFPrK (ORCPT + 99 others); Thu, 6 Jul 2023 11:47:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44896 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232159AbjGFPrI (ORCPT ); Thu, 6 Jul 2023 11:47:08 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C133719BD for ; Thu, 6 Jul 2023 08:46:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1688658382; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7Tl0uNK3iTFKABiIz7zb0nAC1GuwS9Iddx7rewdSaxU=; b=Qhzgkb89fvvil1jeBqxthWSNoFmBx5Qfe/6jwsGKhViu7vvZFLvarauRp4kUAEKybp1hul yzUHXgdkocJhhPxBbVvMmXtRhZo+JGviKyfrkWg+KNd79+QOYAM+bDqDXM60Wlq8ZyWyuh zzDxlE3V/DYtzc0PDeE5xxgwhk8I57Y= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-113-ySB3notAN_2JJ180Qz1p8g-1; Thu, 06 Jul 2023 11:46:19 -0400 X-MC-Unique: ySB3notAN_2JJ180Qz1p8g-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7F2CF858F1E; Thu, 6 Jul 2023 15:46:18 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-39.pek2.redhat.com [10.72.12.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id BE6B8F5CF0; Thu, 6 Jul 2023 15:46:09 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: akpm@linux-foundation.org, linux-mm@kvack.org, arnd@arndb.de, hch@lst.de, christophe.leroy@csgroup.eu, rppt@kernel.org, willy@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, shorne@gmail.com, David.Laight@ACULAB.COM, deller@gmx.de, nathan@kernel.org, glaubitz@physik.fu-berlin.de, Baoquan He , linux-arch@vger.kernel.org Subject: [PATCH v8 05/19] mm: ioremap: allow ARCH to have its own ioremap method definition Date: Thu, 6 Jul 2023 23:45:06 +0800 Message-Id: <20230706154520.11257-6-bhe@redhat.com> In-Reply-To: <20230706154520.11257-1-bhe@redhat.com> References: <20230706154520.11257-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770686895942046404?= X-GMAIL-MSGID: =?utf-8?q?1770686895942046404?= Architectures can be converted to GENERIC_IOREMAP, to take standard ioremap_xxx() and iounmap() way. But some ARCH-es could have specific handling for ioremap_prot(), ioremap() and iounmap(), than standard methods. In oder to convert these ARCH-es to take GENERIC_IOREMAP method, allow these architecutres to have their own ioremap_prot(), ioremap() and iounmap() definitions. Signed-off-by: Baoquan He Acked-by: Arnd Bergmann Reviewed-by: Christoph Hellwig Reviewed-by: Kefeng Wang Reviewed-by: Mike Rapoport (IBM) Cc: linux-arch@vger.kernel.org --- include/asm-generic/io.h | 3 +++ mm/ioremap.c | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/include/asm-generic/io.h b/include/asm-generic/io.h index a7ca2099ba19..39244c3ee797 100644 --- a/include/asm-generic/io.h +++ b/include/asm-generic/io.h @@ -1081,11 +1081,14 @@ void __iomem *ioremap_prot(phys_addr_t phys_addr, size_t size, void iounmap(volatile void __iomem *addr); void generic_iounmap(volatile void __iomem *addr); +#ifndef ioremap +#define ioremap ioremap static inline void __iomem *ioremap(phys_addr_t addr, size_t size) { /* _PAGE_IOREMAP needs to be supplied by the architecture */ return ioremap_prot(addr, size, _PAGE_IOREMAP); } +#endif #endif /* !CONFIG_MMU || CONFIG_GENERIC_IOREMAP */ #ifndef ioremap_wc diff --git a/mm/ioremap.c b/mm/ioremap.c index db6234b9db59..9f34a8f90b58 100644 --- a/mm/ioremap.c +++ b/mm/ioremap.c @@ -46,12 +46,14 @@ void __iomem *generic_ioremap_prot(phys_addr_t phys_addr, size_t size, return (void __iomem *)(vaddr + offset); } +#ifndef ioremap_prot void __iomem *ioremap_prot(phys_addr_t phys_addr, size_t size, unsigned long prot) { return generic_ioremap_prot(phys_addr, size, __pgprot(prot)); } EXPORT_SYMBOL(ioremap_prot); +#endif void generic_iounmap(volatile void __iomem *addr) { @@ -64,8 +66,10 @@ void generic_iounmap(volatile void __iomem *addr) vunmap(vaddr); } +#ifndef iounmap void iounmap(volatile void __iomem *addr) { generic_iounmap(addr); } EXPORT_SYMBOL(iounmap); +#endif From patchwork Thu Jul 6 15:45:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 116772 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp2656364vqx; Thu, 6 Jul 2023 08:50:17 -0700 (PDT) X-Google-Smtp-Source: APBJJlEgEJWY0YUD4mP8PnFY24x+SxvjlmOqfv7uN8iOUBCTR5U/ncYGEVGsSipyCKFZc/uY19yU X-Received: by 2002:a05:6a00:3a14:b0:668:8705:57cf with SMTP id fj20-20020a056a003a1400b00668870557cfmr2497495pfb.25.1688658617380; Thu, 06 Jul 2023 08:50:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688658617; cv=none; d=google.com; s=arc-20160816; b=Xs5RJ7XwmoYBrFQairtq9OT9B44clMyZjuyZ4TW69oQQxCF8MaFIVJy7HHVbSsZ6FD 40L0Igqk1Z6ABamAkmvbypfTOTJmuH7N3mPrvEECORooLM98fDBGnGGzYyKdfF2wzbUZ mqJfWtqRUKBRz757Gz4AvLBZXxx9KyBmhd1pHHef6XaRuE7jPZZkYuqZynPzhnH+qcCb g3lGzoWbGzjCFHU1GxPyakXuq6VqDmSiyObpbFsnm0yAb2288ar/RImLWkW51NulPIlZ pBltYZPElVHjEZc6T6oXf5KsftXAzSfZ2Vv3lwSx4zLBz8yWhZdaGGinVe6YN0ve+k2x KjGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=w2IfnXMZqwx1Jn18is50whUi5yxeZ3Kn4EXboxrstks=; fh=MRqAqm0/X6LLHlLdJym4NBXwcTEGRfSmsWs7mgX78Dg=; b=EvmaBuryXaD1ADnDKr9EmT7gXLEUfzWirF11lm4YrOJegtUIWag6paAD9YJyIPfoOT a1AQukXJJAjlUfUVGevD0pU4qv1jS3yDkQfLYwVTgbgKwU3UqyPoMNS2X/9kD0Koup7D lNQ6qotmXLx6/xy2Diut6+UWoCmrTFmf8NmO7JLmP8L+kCm3WKEd3kssT9ZqM/TnFHIs YbhZnZBO9YRDDmOzIOIHUnh52d70Rtyr43lrONHyAUptF9tiWaJxrs7EYIeHxYzPqZEn OiHY2qDq+idrxCSaqjAJZBNFslpwmHnCY6prowsPpEz+XI5hVbNUNjxrwODLg7fpfWoy Ak5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=IWo+BA70; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id eh12-20020a056a00808c00b0066e4ceca385si1663480pfb.247.2023.07.06.08.49.47; Thu, 06 Jul 2023 08:50:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=IWo+BA70; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229996AbjGFPrT (ORCPT + 99 others); Thu, 6 Jul 2023 11:47:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44934 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232160AbjGFPrQ (ORCPT ); Thu, 6 Jul 2023 11:47:16 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DB8521992 for ; Thu, 6 Jul 2023 08:46:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1688658393; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=w2IfnXMZqwx1Jn18is50whUi5yxeZ3Kn4EXboxrstks=; b=IWo+BA70k7tVWmiXIm5ubXGXBcQNBGNnsQVYTIYzQeGlTR+2P8/hu/sTTxvY3OqIBzqtEE 37Jxrx4l/vqtnJju+GfOyDSxVoJc65XsSl+ZSBVMDGP0nrwppibOt+FQluEm4BP2nfEIdU AFkJuNCCz0xZMgmYyqS5STAqZWNMg2w= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-49-RU_tALYvP5a7WTS2Ws1CNg-1; Thu, 06 Jul 2023 11:46:27 -0400 X-MC-Unique: RU_tALYvP5a7WTS2Ws1CNg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id DAE023815EF8; Thu, 6 Jul 2023 15:46:26 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-39.pek2.redhat.com [10.72.12.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id 47CFFF5CF0; Thu, 6 Jul 2023 15:46:18 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: akpm@linux-foundation.org, linux-mm@kvack.org, arnd@arndb.de, hch@lst.de, christophe.leroy@csgroup.eu, rppt@kernel.org, willy@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, shorne@gmail.com, David.Laight@ACULAB.COM, deller@gmx.de, nathan@kernel.org, glaubitz@physik.fu-berlin.de, Baoquan He Subject: [PATCH v8 06/19] mm/ioremap: add slab availability checking in ioremap_prot Date: Thu, 6 Jul 2023 23:45:07 +0800 Message-Id: <20230706154520.11257-7-bhe@redhat.com> In-Reply-To: <20230706154520.11257-1-bhe@redhat.com> References: <20230706154520.11257-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770686898501498076?= X-GMAIL-MSGID: =?utf-8?q?1770686898501498076?= Several architectures has done checking if slab if available in ioremap_prot(). In fact it should be done in generic ioremap_prot() since on any architecutre, slab allocator must be available before get_vm_area_caller() and vunmap() are used. Add the checking into generic_ioremap_prot(). Suggested-by: Christophe Leroy Signed-off-by: Baoquan He Reviewed-by: Christoph Hellwig Reviewed-by: Kefeng Wang Reviewed-by: Mike Rapoport (IBM) --- mm/ioremap.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mm/ioremap.c b/mm/ioremap.c index 9f34a8f90b58..86b82ec27d2b 100644 --- a/mm/ioremap.c +++ b/mm/ioremap.c @@ -18,6 +18,10 @@ void __iomem *generic_ioremap_prot(phys_addr_t phys_addr, size_t size, phys_addr_t last_addr; struct vm_struct *area; + /* An early platform driver might end up here */ + if (WARN_ON_ONCE(!slab_is_available())) + return NULL; + /* Disallow wrap-around or zero size */ last_addr = phys_addr + size - 1; if (!size || last_addr < phys_addr) From patchwork Thu Jul 6 15:45:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 116784 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp2668891vqx; Thu, 6 Jul 2023 09:08:38 -0700 (PDT) X-Google-Smtp-Source: APBJJlF+lSPPzM35uUKWvs4aRqtP5a1pFl0F0TVFAHI1J0YUqAn7Le1D0VE5iu2EFnFnOaKbpDUR X-Received: by 2002:a17:903:1205:b0:1b8:5bcc:2ffc with SMTP id l5-20020a170903120500b001b85bcc2ffcmr1981211plh.45.1688659717774; Thu, 06 Jul 2023 09:08:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688659717; cv=none; d=google.com; s=arc-20160816; b=tKMRcGcQwY44fR+KhqUXj6pz+JHisVcxQrsk2vkDR8+UxzfpRr6me0YHC9GamvbfZU cgSGg3lw4DRhfA6R5VA1Tsg0EO8P3gSaBLBYThcFlYa2EzMmOxKg1MlDCUc//WuJA3eV FQdE83D5E96EMVHvl5epppgq401oTJ6RVGmqDWlUles6qT+KscBd0jAyhfSBqR3y4qyT qXbd9yJbTq/5i1Rj4afON3TC6iln1KSLoGhbIcbT7o6DWmn6gbh7CJZISHBkMw7fOfvw Id+O1ylID91fGIdBeSj6yTpC6VCESDtJ/JmTqK1pOCdv04IgOYFYhEsxUMoy2guFlgAL n/5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=lPVj8rhXKvQORbztn0NrK5wvOXfvzxv4+nZiwBKh1i0=; fh=s5WHMh6R80LU22ye/2XEY2Pl7uTMnF2N01wpwbetzwU=; b=GzpkAr203ziMHDJgA9/txzkKU/ntfCWJUVB3oeSHb7TvpjUXgZKRgDn+db87zIBLfL 5sL9LGSlpG4u5OuS00fC9DE3HX3TdNhI2Uc1jMzMD4WiamjOk+GlUqAVguKwOoXJ7wAP ColUYXtJGPP/bjOp3FtX+yTGvn2tq4ynlD7MBL6JuV89ALZWgmeGVhqVX9A4593xeswl hSLXlBGAtWV5Wk5dM6g4EcKfurXTUscoP8dxF9MJ9MdfjKzKymBpvZfp3x6dqc0+jq2Z 7PiyfsU3DZ73tvk4NPVLoGyQd15A4IY2pknuwcjYRbjEP/aQKSeIZ2iyb5ioRDWLfRlo KkXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=HnVwWxKz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l9-20020a170903244900b001b864e1a02asi1713891pls.393.2023.07.06.09.08.17; Thu, 06 Jul 2023 09:08:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=HnVwWxKz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232194AbjGFPre (ORCPT + 99 others); Thu, 6 Jul 2023 11:47:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45040 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232238AbjGFPrb (ORCPT ); Thu, 6 Jul 2023 11:47:31 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 22AD91BD3 for ; Thu, 6 Jul 2023 08:46:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1688658401; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lPVj8rhXKvQORbztn0NrK5wvOXfvzxv4+nZiwBKh1i0=; b=HnVwWxKzG+9WpVjxqFhuIx+xp0MdaRrKiaRb9IwIyy5zrBB2Nbrrz9voyvpzGB9lOQj6bv XARQL/opiyC6PjKm4PqAjC019fcnfsY/PczejMGJdtyLx7hgRiRiENpTIRPv8iUdhkVTzI swiiiRvy9GMTinh8S0HewEAwZ2lggak= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-164-CpM4hTDcNbKu62ox369UOA-1; Thu, 06 Jul 2023 11:46:38 -0400 X-MC-Unique: CpM4hTDcNbKu62ox369UOA-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 38F081C06ECD; Thu, 6 Jul 2023 15:46:37 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-39.pek2.redhat.com [10.72.12.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id AEA98F5CF0; Thu, 6 Jul 2023 15:46:27 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: akpm@linux-foundation.org, linux-mm@kvack.org, arnd@arndb.de, hch@lst.de, christophe.leroy@csgroup.eu, rppt@kernel.org, willy@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, shorne@gmail.com, David.Laight@ACULAB.COM, deller@gmx.de, nathan@kernel.org, glaubitz@physik.fu-berlin.de, Baoquan He , Vineet Gupta , linux-snps-arc@lists.infradead.org Subject: [PATCH v8 07/19] arc: mm: Convert to GENERIC_IOREMAP Date: Thu, 6 Jul 2023 23:45:08 +0800 Message-Id: <20230706154520.11257-8-bhe@redhat.com> In-Reply-To: <20230706154520.11257-1-bhe@redhat.com> References: <20230706154520.11257-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770688052421403689?= X-GMAIL-MSGID: =?utf-8?q?1770688052421403689?= By taking GENERIC_IOREMAP method, the generic generic_ioremap_prot(), generic_iounmap(), and their generic wrapper ioremap_prot(), ioremap() and iounmap() are all visible and available to arch. Arch needs to provide wrapper functions to override the generic versions if there's arch specific handling in its ioremap_prot(), ioremap() or iounmap(). This change will simplify implementation by removing duplicated code with generic_ioremap_prot() and generic_iounmap(), and has the equivalent functioality as before. Here, add wrapper functions ioremap_prot() and iounmap() for arc's special operation when ioremap_prot() and iounmap(). Signed-off-by: Baoquan He Reviewed-by: Christoph Hellwig Reviewed-by: Mike Rapoport (IBM) Cc: Vineet Gupta Cc: linux-snps-arc@lists.infradead.org --- arch/arc/Kconfig | 1 + arch/arc/include/asm/io.h | 7 +++--- arch/arc/mm/ioremap.c | 49 ++++----------------------------------- 3 files changed, 8 insertions(+), 49 deletions(-) diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig index 96cf8720bb93..6f4995ad9873 100644 --- a/arch/arc/Kconfig +++ b/arch/arc/Kconfig @@ -26,6 +26,7 @@ config ARC select GENERIC_PENDING_IRQ if SMP select GENERIC_SCHED_CLOCK select GENERIC_SMP_IDLE_THREAD + select GENERIC_IOREMAP select HAVE_ARCH_KGDB select HAVE_ARCH_TRACEHOOK select HAVE_ARCH_TRANSPARENT_HUGEPAGE if ARC_MMU_V4 diff --git a/arch/arc/include/asm/io.h b/arch/arc/include/asm/io.h index 80347382a380..4fdb7350636c 100644 --- a/arch/arc/include/asm/io.h +++ b/arch/arc/include/asm/io.h @@ -21,8 +21,9 @@ #endif extern void __iomem *ioremap(phys_addr_t paddr, unsigned long size); -extern void __iomem *ioremap_prot(phys_addr_t paddr, unsigned long size, - unsigned long flags); +#define ioremap ioremap +#define ioremap_prot ioremap_prot +#define iounmap iounmap static inline void __iomem *ioport_map(unsigned long port, unsigned int nr) { return (void __iomem *)port; @@ -32,8 +33,6 @@ static inline void ioport_unmap(void __iomem *addr) { } -extern void iounmap(const volatile void __iomem *addr); - /* * io{read,write}{16,32}be() macros */ diff --git a/arch/arc/mm/ioremap.c b/arch/arc/mm/ioremap.c index 712c2311daef..b07004d53267 100644 --- a/arch/arc/mm/ioremap.c +++ b/arch/arc/mm/ioremap.c @@ -8,7 +8,6 @@ #include #include #include -#include #include static inline bool arc_uncached_addr_space(phys_addr_t paddr) @@ -25,13 +24,6 @@ static inline bool arc_uncached_addr_space(phys_addr_t paddr) void __iomem *ioremap(phys_addr_t paddr, unsigned long size) { - phys_addr_t end; - - /* Don't allow wraparound or zero size */ - end = paddr + size - 1; - if (!size || (end < paddr)) - return NULL; - /* * If the region is h/w uncached, MMU mapping can be elided as optim * The cast to u32 is fine as this region can only be inside 4GB @@ -51,55 +43,22 @@ EXPORT_SYMBOL(ioremap); * ARC hardware uncached region, this one still goes thru the MMU as caller * might need finer access control (R/W/X) */ -void __iomem *ioremap_prot(phys_addr_t paddr, unsigned long size, +void __iomem *ioremap_prot(phys_addr_t paddr, size_t size, unsigned long flags) { - unsigned int off; - unsigned long vaddr; - struct vm_struct *area; - phys_addr_t end; pgprot_t prot = __pgprot(flags); - /* Don't allow wraparound, zero size */ - end = paddr + size - 1; - if ((!size) || (end < paddr)) - return NULL; - - /* An early platform driver might end up here */ - if (!slab_is_available()) - return NULL; - /* force uncached */ - prot = pgprot_noncached(prot); - - /* Mappings have to be page-aligned */ - off = paddr & ~PAGE_MASK; - paddr &= PAGE_MASK_PHYS; - size = PAGE_ALIGN(end + 1) - paddr; - - /* - * Ok, go for it.. - */ - area = get_vm_area(size, VM_IOREMAP); - if (!area) - return NULL; - area->phys_addr = paddr; - vaddr = (unsigned long)area->addr; - if (ioremap_page_range(vaddr, vaddr + size, paddr, prot)) { - vunmap((void __force *)vaddr); - return NULL; - } - return (void __iomem *)(off + (char __iomem *)vaddr); + return generic_ioremap_prot(paddr, size, pgprot_noncached(prot)); } EXPORT_SYMBOL(ioremap_prot); - -void iounmap(const volatile void __iomem *addr) +void iounmap(volatile void __iomem *addr) { /* weird double cast to handle phys_addr_t > 32 bits */ if (arc_uncached_addr_space((phys_addr_t)(u32)addr)) return; - vfree((void *)(PAGE_MASK & (unsigned long __force)addr)); + generic_iounmap(addr); } EXPORT_SYMBOL(iounmap); From patchwork Thu Jul 6 15:45:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 116785 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp2669060vqx; Thu, 6 Jul 2023 09:08:52 -0700 (PDT) X-Google-Smtp-Source: APBJJlGUdRfLevkayDBEWnly+VeDL70qzYjUkgcnQnDWWUWZWEupK04h9Yl1mive4ufuduO1CTjA X-Received: by 2002:a05:6a20:c1:b0:12d:cf29:b75d with SMTP id 1-20020a056a2000c100b0012dcf29b75dmr1996650pzh.18.1688659732069; Thu, 06 Jul 2023 09:08:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688659732; cv=none; d=google.com; s=arc-20160816; b=WrND2ROP/BwrjQNVQqBD7ZMjZc3xsbaSHHGrKx2Cz2fJUFBygQhevGT06QLOW27w5u lVIDgmA7DlVc+seqQ0dx5VkvkT5qfPHA5ucs36rCjUq+ym2NHs2rAO3KNHHA7uZF/af5 ZI3OCZP71u3lfshKp8a4VJePMurQdpz8742OkDKd6zH23Tf10rwTaFuvq1ZkoP9llqRb Ka6/jjWynE7HcukR2vFMc4Sg7k2pKfJIA88TX0Fma4eHCtBY7FB232PdCvY2Vqc8D2+1 r0z/FKOMDaGtZEFEfkHB64vWMh6rzcEYatvw8b1M4OkuwQkS3k1ZYVcWAPsDK2JAMK+X bBBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=HouZTQm+V70h+gsiEupRVBEwB3PeE/r1+sDrBkNv3ls=; fh=pFoT9Wl0o4P0smyvUJ1A0Dyn5HqF4vUtEcVaSoonSlo=; b=wGrv1llnDPvHptduGszu9/Aztqw2SFiHmTg4bJ/SQ/2jXf9bJqw5A2nbFbY6UOY2hF 4PxwbPrTX6vXpO5hYhmTlt35kqu74jd5dfp5MTzsNX9tRCnf/jGOEW9HRxATl44SIbYz m9drX7Ibfu/u+aCCusZMU490HzVwMPeGi1fLeYMcA0xa5XUp4MoeXUFZgXIXvQ1ARXd8 2zflkqMuSZ7vQQ+CT3mEGHexJ1YaqY6rP0EFr+/yrkCT3R7pYYPJR++bk3JERzodYaCv 9xP4pan8S2Ck/dkcKbCJOCRDygYy2J+38BeFf3iJvELcFII5tDw38mAFLbpU9YwPMwjA 2bMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=JCiviqCl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id eb8-20020a056a004c8800b0064d419dd566si1713056pfb.205.2023.07.06.09.08.37; Thu, 06 Jul 2023 09:08:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=JCiviqCl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232519AbjGFPry (ORCPT + 99 others); Thu, 6 Jul 2023 11:47:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45562 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231967AbjGFPrr (ORCPT ); Thu, 6 Jul 2023 11:47:47 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CD4781FD9 for ; Thu, 6 Jul 2023 08:46:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1688658414; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HouZTQm+V70h+gsiEupRVBEwB3PeE/r1+sDrBkNv3ls=; b=JCiviqClSNQsPhh1pF3jwW+HIPIEUvzG9TLR+7DqGeGkgk3lclqsUo5qDLoDjOtCUTnFVm zMLNlWCXV9xvi2L9f0EAOVvefKQK4tTCTHBu+ZyX5KAVTHD1sXVy59OIc2V6yxFkgflSUg 7aHGmJ3NXj5BDCHwUPStJvNyg/Daw/A= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-199-zStYdrw0PYmzXl3bYNKOLg-1; Thu, 06 Jul 2023 11:46:47 -0400 X-MC-Unique: zStYdrw0PYmzXl3bYNKOLg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id EFD23185A794; Thu, 6 Jul 2023 15:46:46 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-39.pek2.redhat.com [10.72.12.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0F6DCF6431; Thu, 6 Jul 2023 15:46:37 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: akpm@linux-foundation.org, linux-mm@kvack.org, arnd@arndb.de, hch@lst.de, christophe.leroy@csgroup.eu, rppt@kernel.org, willy@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, shorne@gmail.com, David.Laight@ACULAB.COM, deller@gmx.de, nathan@kernel.org, glaubitz@physik.fu-berlin.de, Baoquan He , linux-ia64@vger.kernel.org Subject: [PATCH v8 08/19] ia64: mm: Convert to GENERIC_IOREMAP Date: Thu, 6 Jul 2023 23:45:09 +0800 Message-Id: <20230706154520.11257-9-bhe@redhat.com> In-Reply-To: <20230706154520.11257-1-bhe@redhat.com> References: <20230706154520.11257-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770688067367715866?= X-GMAIL-MSGID: =?utf-8?q?1770688067367715866?= By taking GENERIC_IOREMAP method, the generic generic_ioremap_prot(), generic_iounmap(), and their generic wrapper ioremap_prot(), ioremap() and iounmap() are all visible and available to arch. Arch needs to provide wrapper functions to override the generic versions if there's arch specific handling in its ioremap_prot(), ioremap() or iounmap(). This change will simplify implementation by removing duplicated code with generic_ioremap_prot() and generic_iounmap(), and has the equivalent functioality as before. Here, add wrapper functions ioremap_prot() and iounmap() for ia64's special operation when ioremap() and iounmap(). Signed-off-by: Baoquan He Reviewed-by: Christoph Hellwig Reviewed-by: Mike Rapoport (IBM) Cc: linux-ia64@vger.kernel.org --- arch/ia64/Kconfig | 1 + arch/ia64/include/asm/io.h | 13 +++++------- arch/ia64/mm/ioremap.c | 41 ++++++-------------------------------- 3 files changed, 12 insertions(+), 43 deletions(-) diff --git a/arch/ia64/Kconfig b/arch/ia64/Kconfig index 2cd93e6bf0fe..3ab75f36c037 100644 --- a/arch/ia64/Kconfig +++ b/arch/ia64/Kconfig @@ -47,6 +47,7 @@ config IA64 select GENERIC_IRQ_LEGACY select ARCH_HAVE_NMI_SAFE_CMPXCHG select GENERIC_IOMAP + select GENERIC_IOREMAP select GENERIC_SMP_IDLE_THREAD select ARCH_TASK_STRUCT_ON_STACK select ARCH_TASK_STRUCT_ALLOCATOR diff --git a/arch/ia64/include/asm/io.h b/arch/ia64/include/asm/io.h index 83a492c8d298..eedc0afa8cad 100644 --- a/arch/ia64/include/asm/io.h +++ b/arch/ia64/include/asm/io.h @@ -243,15 +243,12 @@ static inline void outsl(unsigned long port, const void *src, # ifdef __KERNEL__ -extern void __iomem * ioremap(unsigned long offset, unsigned long size); +#define _PAGE_IOREMAP pgprot_val(PAGE_KERNEL) + extern void __iomem * ioremap_uc(unsigned long offset, unsigned long size); -extern void iounmap (volatile void __iomem *addr); -static inline void __iomem * ioremap_cache (unsigned long phys_addr, unsigned long size) -{ - return ioremap(phys_addr, size); -} -#define ioremap ioremap -#define ioremap_cache ioremap_cache + +#define ioremap_prot ioremap_prot +#define ioremap_cache ioremap #define ioremap_uc ioremap_uc #define iounmap iounmap diff --git a/arch/ia64/mm/ioremap.c b/arch/ia64/mm/ioremap.c index 92b81bc91397..711b6abc822e 100644 --- a/arch/ia64/mm/ioremap.c +++ b/arch/ia64/mm/ioremap.c @@ -29,13 +29,9 @@ early_ioremap (unsigned long phys_addr, unsigned long size) return __ioremap_uc(phys_addr); } -void __iomem * -ioremap (unsigned long phys_addr, unsigned long size) +void __iomem *ioremap_prot(phys_addr_t phys_addr, size_t size, + unsigned long flags) { - void __iomem *addr; - struct vm_struct *area; - unsigned long offset; - pgprot_t prot; u64 attr; unsigned long gran_base, gran_size; unsigned long page_base; @@ -68,36 +64,12 @@ ioremap (unsigned long phys_addr, unsigned long size) */ page_base = phys_addr & PAGE_MASK; size = PAGE_ALIGN(phys_addr + size) - page_base; - if (efi_mem_attribute(page_base, size) & EFI_MEMORY_WB) { - prot = PAGE_KERNEL; - - /* - * Mappings have to be page-aligned - */ - offset = phys_addr & ~PAGE_MASK; - phys_addr &= PAGE_MASK; - - /* - * Ok, go for it.. - */ - area = get_vm_area(size, VM_IOREMAP); - if (!area) - return NULL; - - area->phys_addr = phys_addr; - addr = (void __iomem *) area->addr; - if (ioremap_page_range((unsigned long) addr, - (unsigned long) addr + size, phys_addr, prot)) { - vunmap((void __force *) addr); - return NULL; - } - - return (void __iomem *) (offset + (char __iomem *)addr); - } + if (efi_mem_attribute(page_base, size) & EFI_MEMORY_WB) + return generic_ioremap_prot(phys_addr, size, __pgprot(flags)); return __ioremap_uc(phys_addr); } -EXPORT_SYMBOL(ioremap); +EXPORT_SYMBOL(ioremap_prot); void __iomem * ioremap_uc(unsigned long phys_addr, unsigned long size) @@ -114,8 +86,7 @@ early_iounmap (volatile void __iomem *addr, unsigned long size) { } -void -iounmap (volatile void __iomem *addr) +void iounmap(volatile void __iomem *addr) { if (REGION_NUMBER(addr) == RGN_GATE) vunmap((void *) ((unsigned long) addr & PAGE_MASK)); From patchwork Thu Jul 6 15:45:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 116777 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp2658430vqx; Thu, 6 Jul 2023 08:54:22 -0700 (PDT) X-Google-Smtp-Source: APBJJlHgpjNXuRHjyFCrNvhycjydwhcX5jbNMBZkR4+mShaU87WiFXb8CwfzyTpko5wKUvP2K81z X-Received: by 2002:a17:90a:7347:b0:25e:f696:1cf8 with SMTP id j7-20020a17090a734700b0025ef6961cf8mr3622158pjs.14.1688658861817; Thu, 06 Jul 2023 08:54:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688658861; cv=none; d=google.com; s=arc-20160816; b=R1ulTrL5HgNwOWcZ19LE1IsLKqIhOfabuLbj7jo2Ni4IxlipCYH1udUbjqWGO+QqhV mYF2143hpqNXCLeg8VzIPVBDJnYVcJAl7c1fVEky6s2SO0F9OuvUdBHgXWftLa2R8jUB oUk1+QOtqLhkYIEx42gtqfWrDg4kjPU9GtIYn98bfEh5Z/gyaooUEDEU7oMNbxNEXDyo qw5XtBHtbUzmhW/yQ9TgU2yW8VRLf1RtVst1a5iWQ23bx47j+gdcXyN16GmxoKONEsQg suVqSS8Qjj8L8+5bUWl2S/QmoquLHiVC07DPu3q8M3Nq2crLlf10QvdR+cfKDhwSGN/9 cXQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=MfP/dV90ghXNs4nny37p+AmeMzpGP5gepSHR9mCOjb8=; fh=eeeeInr/MmFywiB7btX0C71N9ahYx+v9/M7/z0Zrcp0=; b=Wir5njOI07EJxqhgOeIyIt/ewizk7bhl0ynj0V9R4/afpFNv7swODchwsy4LIRVRtT 05q1ad2fKMGOnU6SyZ6qLz1B3E81EyxcczuQD30oAFscqcTLvoTWzt+tZdPoieawMgES elLpoZaHH3k3l75NQfz+QOw8C7eWYHGHDqRV/gfQTo9x0KbYpSANj8oOTgLS1hgtbwpN PHifQiTknp5k/pa0w0FSCuYF6aBRJbeqrUSB5go/MlyVH5EOtBLG8aV7UJFmHaI+GHhm SjM2WdZk70QNSktWkUSo1SO4RmDiYHJi2hI+l53t6ZMFKdEL+VVGiC7X3+fn9vFV4Ewj 2K9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="Y8/4gZlu"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bs125-20020a632883000000b0054ff425ab2csi1662843pgb.234.2023.07.06.08.54.08; Thu, 06 Jul 2023 08:54:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="Y8/4gZlu"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232463AbjGFPsY (ORCPT + 99 others); Thu, 6 Jul 2023 11:48:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44896 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232807AbjGFPr5 (ORCPT ); Thu, 6 Jul 2023 11:47:57 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A0BDF1FE8 for ; Thu, 6 Jul 2023 08:46:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1688658418; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=MfP/dV90ghXNs4nny37p+AmeMzpGP5gepSHR9mCOjb8=; b=Y8/4gZluukpcrVDRosx1sfk8yr2WsZBRiNxQYaG+jvpU+rjFzguAOiquM9iXmSD+XpjCZA Lgc1q1dh+yHgeLqpoxirjTGtfCAJOIWJlipZVwcGsLpV12Nxq/lbuT8b7YalhY+F49TiCP A7OP0Xz1WvXrxkGtb7htNo3abZL7r4g= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-266-Mw8JIk7-MdGKjVVBaMzICg-1; Thu, 06 Jul 2023 11:46:57 -0400 X-MC-Unique: Mw8JIk7-MdGKjVVBaMzICg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 757ED3815EF3; Thu, 6 Jul 2023 15:46:56 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-39.pek2.redhat.com [10.72.12.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id C0792F6403; Thu, 6 Jul 2023 15:46:47 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: akpm@linux-foundation.org, linux-mm@kvack.org, arnd@arndb.de, hch@lst.de, christophe.leroy@csgroup.eu, rppt@kernel.org, willy@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, shorne@gmail.com, David.Laight@ACULAB.COM, deller@gmx.de, nathan@kernel.org, glaubitz@physik.fu-berlin.de, Baoquan He , Jonas Bonn , Stefan Kristiansson , openrisc@lists.librecores.org Subject: [PATCH v8 09/19] openrisc: mm: Convert to GENERIC_IOREMAP Date: Thu, 6 Jul 2023 23:45:10 +0800 Message-Id: <20230706154520.11257-10-bhe@redhat.com> In-Reply-To: <20230706154520.11257-1-bhe@redhat.com> References: <20230706154520.11257-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770687154824661026?= X-GMAIL-MSGID: =?utf-8?q?1770687154824661026?= By taking GENERIC_IOREMAP method, the generic generic_ioremap_prot(), generic_iounmap(), and their generic wrapper ioremap_prot(), ioremap() and iounmap() are all visible and available to arch. Arch needs to provide wrapper functions to override the generic versions if there's arch specific handling in its ioremap_prot(), ioremap() or iounmap(). This change will simplify implementation by removing duplicated code with generic_ioremap_prot() and generic_iounmap(), and has the equivalent functioality as before. For openrisc, the current ioremap() and iounmap() are the same as generic version. After taking GENERIC_IOREMAP way, the old ioremap() and iounmap() can be completely removed. Signed-off-by: Baoquan He Reviewed-by: Christoph Hellwig Reviewed-by: Mike Rapoport (IBM) Cc: Stafford Horne Cc: Jonas Bonn Cc: Stefan Kristiansson Cc: openrisc@lists.librecores.org --- arch/openrisc/Kconfig | 1 + arch/openrisc/include/asm/io.h | 11 ++++---- arch/openrisc/mm/ioremap.c | 49 ---------------------------------- 3 files changed, 7 insertions(+), 54 deletions(-) diff --git a/arch/openrisc/Kconfig b/arch/openrisc/Kconfig index c7f282f60f64..fd9bb76a610b 100644 --- a/arch/openrisc/Kconfig +++ b/arch/openrisc/Kconfig @@ -21,6 +21,7 @@ config OPENRISC select GENERIC_IRQ_PROBE select GENERIC_IRQ_SHOW select GENERIC_PCI_IOMAP + select GENERIC_IOREMAP select GENERIC_CPU_DEVICES select HAVE_PCI select HAVE_UID16 diff --git a/arch/openrisc/include/asm/io.h b/arch/openrisc/include/asm/io.h index ee6043a03173..5a6f0f16a5ce 100644 --- a/arch/openrisc/include/asm/io.h +++ b/arch/openrisc/include/asm/io.h @@ -15,6 +15,8 @@ #define __ASM_OPENRISC_IO_H #include +#include +#include /* * PCI: We do not use IO ports in OpenRISC @@ -27,11 +29,10 @@ #define PIO_OFFSET 0 #define PIO_MASK 0 -#define ioremap ioremap -void __iomem *ioremap(phys_addr_t offset, unsigned long size); - -#define iounmap iounmap -extern void iounmap(volatile void __iomem *addr); +/* + * I/O memory mapping functions. + */ +#define _PAGE_IOREMAP (pgprot_val(PAGE_KERNEL) | _PAGE_CI) #include diff --git a/arch/openrisc/mm/ioremap.c b/arch/openrisc/mm/ioremap.c index cdbcc7e73684..91c8259d4b7e 100644 --- a/arch/openrisc/mm/ioremap.c +++ b/arch/openrisc/mm/ioremap.c @@ -22,55 +22,6 @@ extern int mem_init_done; -/* - * Remap an arbitrary physical address space into the kernel virtual - * address space. Needed when the kernel wants to access high addresses - * directly. - * - * NOTE! We need to allow non-page-aligned mappings too: we will obviously - * have to convert them into an offset in a page-aligned mapping, but the - * caller shouldn't need to know that small detail. - */ -void __iomem *__ref ioremap(phys_addr_t addr, unsigned long size) -{ - phys_addr_t p; - unsigned long v; - unsigned long offset, last_addr; - struct vm_struct *area = NULL; - - /* Don't allow wraparound or zero size */ - last_addr = addr + size - 1; - if (!size || last_addr < addr) - return NULL; - - /* - * Mappings have to be page-aligned - */ - offset = addr & ~PAGE_MASK; - p = addr & PAGE_MASK; - size = PAGE_ALIGN(last_addr + 1) - p; - - area = get_vm_area(size, VM_IOREMAP); - if (!area) - return NULL; - v = (unsigned long)area->addr; - - if (ioremap_page_range(v, v + size, p, - __pgprot(pgprot_val(PAGE_KERNEL) | _PAGE_CI))) { - vfree(area->addr); - return NULL; - } - - return (void __iomem *)(offset + (char *)v); -} -EXPORT_SYMBOL(ioremap); - -void iounmap(volatile void __iomem *addr) -{ - return vfree((void *)(PAGE_MASK & (unsigned long)addr)); -} -EXPORT_SYMBOL(iounmap); - /** * OK, this one's a bit tricky... ioremap can get called before memory is * initialized (early serial console does this) and will want to alloc a page From patchwork Thu Jul 6 15:45:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 116792 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp2674036vqx; Thu, 6 Jul 2023 09:15:52 -0700 (PDT) X-Google-Smtp-Source: APBJJlGZ9W1BssEFvHT+eJrytPeWIKIXRxKZWIQ4nvjD3gTWfmX1lygz+rFZfpMcMcOcHWQJFqX2 X-Received: by 2002:a05:6a20:3d85:b0:12c:9100:362f with SMTP id s5-20020a056a203d8500b0012c9100362fmr2793655pzi.4.1688660152089; Thu, 06 Jul 2023 09:15:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688660152; cv=none; d=google.com; s=arc-20160816; b=FAHp7LF+pphxudJSBXgxwpPqRBiTz/27gQoOxLCxNCE+/tziyzvTRZO+BVXFoGFFOA oywEyGLMnVrBCcm6HpM1r0tZGsZe32BUj0rgqYLD3e5ielSzUlcqjh6YAue23DV562DL 5gFygdtgyBaQlFqazp4CnowHnUgdSFhQoRhUwJkUauIs+/Qnj8GZyHil32xwXLRP+MS/ nLnWZWLWk/rSpQ3T79ULTsnYFQmUGliKOw91UyjZ70s6lwm/0WPHcEr6xnO4Zcr2vZhZ XGxb9BYpMGLxUBFyCcABKUOwAWsot6gANiPV44UDX+VaVzcrI9DjaYiJv5dQnKOpCie5 Bf5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=fXmRLKyZhjK8lZnEN6ZgBD7TdWtmJLX0PHcxqK6st5o=; fh=hoCXx/F0U/fpcB0nkrGSYUVkCx9DYlKaojB4vuYUTmQ=; b=s5aB66QYGXu1CblIof5DHbHzEuXoMlireaunjNxswceY9HK1jwOwyM8rIYbunohkqL bAZUnuXJIw7MR3yF0pcfx41lMGl3v5hQkTRX2DIboxL9funixsvn2UfMcEpbovp0h32I yOJN8iy38zat6R0/jPeQkD+n5alxB0/J7xI7ucHk92lWIjSYUAKW6S422M1oyow7Mh+N BNYH2xKKpQabYJ1azLFU0GfT/vSVaR2+pik2PMqiuaonDl5ABoqXLec5vxTwAlZHuer6 49XGBF1uZGFFHQWYw6xD2fppnwOZ4KdRgOcBK6RVRI8JniiR/NNdjiKWuXY6weMpxc7s GC2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Rrm2HPCs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id be17-20020a056a001f1100b0067bb1f0b329si1698903pfb.93.2023.07.06.09.15.36; Thu, 06 Jul 2023 09:15:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Rrm2HPCs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233144AbjGFPso (ORCPT + 99 others); Thu, 6 Jul 2023 11:48:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45936 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231732AbjGFPsT (ORCPT ); Thu, 6 Jul 2023 11:48:19 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 080DD1FFB for ; Thu, 6 Jul 2023 08:47:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1688658433; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fXmRLKyZhjK8lZnEN6ZgBD7TdWtmJLX0PHcxqK6st5o=; b=Rrm2HPCsjpvMrgTHotw6B15KUpAyv5N2Y0ojTN/YqTJOzRuq9HFV5IfcfYMCU98Ha5fKO1 nx6hRYSR4qOoKnos6ENRX+0J3FP18rTavuD7PEQfkBenIycl5i2Vj19PBygiyKVjY5AhIH lGVwB7I0Z4ddz3BxcKQjKJjyOg/Obm4= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-627-40rembCSN4-mVvgWCYJEdg-1; Thu, 06 Jul 2023 11:47:10 -0400 X-MC-Unique: 40rembCSN4-mVvgWCYJEdg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 183C081D9EC; Thu, 6 Jul 2023 15:47:09 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-39.pek2.redhat.com [10.72.12.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id 487C1F6401; Thu, 6 Jul 2023 15:46:56 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: akpm@linux-foundation.org, linux-mm@kvack.org, arnd@arndb.de, hch@lst.de, christophe.leroy@csgroup.eu, rppt@kernel.org, willy@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, shorne@gmail.com, David.Laight@ACULAB.COM, deller@gmx.de, nathan@kernel.org, glaubitz@physik.fu-berlin.de, Baoquan He , Gerald Schaefer , Heiko Carstens , Vasily Gorbik , Christian Borntraeger , Sven Schnelle , linux-s390@vger.kernel.org Subject: [PATCH v8 10/19] s390: mm: Convert to GENERIC_IOREMAP Date: Thu, 6 Jul 2023 23:45:11 +0800 Message-Id: <20230706154520.11257-11-bhe@redhat.com> In-Reply-To: <20230706154520.11257-1-bhe@redhat.com> References: <20230706154520.11257-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770688507639461242?= X-GMAIL-MSGID: =?utf-8?q?1770688507639461242?= By taking GENERIC_IOREMAP method, the generic generic_ioremap_prot(), generic_iounmap(), and their generic wrapper ioremap_prot(), ioremap() and iounmap() are all visible and available to arch. Arch needs to provide wrapper functions to override the generic versions if there's arch specific handling in its ioremap_prot(), ioremap() or iounmap(). This change will simplify implementation by removing duplicated code with generic_ioremap_prot() and generic_iounmap(), and has the equivalent functioality as before. Here, add wrapper functions ioremap_prot() and iounmap() for s390's special operation when ioremap() and iounmap(). And also replace including with in arch/s390/kernel/perf_cpum_sf.c, otherwise building error will be seen because macro defined in can't be seen in perf_cpum_sf.c. Signed-off-by: Baoquan He Reviewed-by: Niklas Schnelle Tested-by: Niklas Schnelle Reviewed-by: Christoph Hellwig Reviewed-by: Mike Rapoport (IBM) Cc: Gerald Schaefer Cc: Heiko Carstens Cc: Vasily Gorbik Cc: Alexander Gordeev Cc: Christian Borntraeger Cc: Sven Schnelle Cc: linux-s390@vger.kernel.org --- arch/s390/Kconfig | 1 + arch/s390/include/asm/io.h | 21 ++++++------ arch/s390/kernel/perf_cpum_sf.c | 2 +- arch/s390/pci/pci.c | 57 ++++++--------------------------- 4 files changed, 24 insertions(+), 57 deletions(-) diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig index 5b39918b7042..290b6f93b816 100644 --- a/arch/s390/Kconfig +++ b/arch/s390/Kconfig @@ -143,6 +143,7 @@ config S390 select GENERIC_SMP_IDLE_THREAD select GENERIC_TIME_VSYSCALL select GENERIC_VDSO_TIME_NS + select GENERIC_IOREMAP if PCI select HAVE_ALIGNED_STRUCT_PAGE if SLUB select HAVE_ARCH_AUDITSYSCALL select HAVE_ARCH_JUMP_LABEL diff --git a/arch/s390/include/asm/io.h b/arch/s390/include/asm/io.h index e3882b012bfa..4453ad7c11ac 100644 --- a/arch/s390/include/asm/io.h +++ b/arch/s390/include/asm/io.h @@ -22,11 +22,18 @@ void unxlate_dev_mem_ptr(phys_addr_t phys, void *addr); #define IO_SPACE_LIMIT 0 -void __iomem *ioremap_prot(phys_addr_t addr, size_t size, unsigned long prot); -void __iomem *ioremap(phys_addr_t addr, size_t size); -void __iomem *ioremap_wc(phys_addr_t addr, size_t size); -void __iomem *ioremap_wt(phys_addr_t addr, size_t size); -void iounmap(volatile void __iomem *addr); +/* + * I/O memory mapping functions. + */ +#define ioremap_prot ioremap_prot +#define iounmap iounmap + +#define _PAGE_IOREMAP pgprot_val(PAGE_KERNEL) + +#define ioremap_wc(addr, size) \ + ioremap_prot((addr), (size), pgprot_val(pgprot_writecombine(PAGE_KERNEL))) +#define ioremap_wt(addr, size) \ + ioremap_prot((addr), (size), pgprot_val(pgprot_writethrough(PAGE_KERNEL))) static inline void __iomem *ioport_map(unsigned long port, unsigned int nr) { @@ -51,10 +58,6 @@ static inline void ioport_unmap(void __iomem *p) #define pci_iomap_wc pci_iomap_wc #define pci_iomap_wc_range pci_iomap_wc_range -#define ioremap ioremap -#define ioremap_wt ioremap_wt -#define ioremap_wc ioremap_wc - #define memcpy_fromio(dst, src, count) zpci_memcpy_fromio(dst, src, count) #define memcpy_toio(dst, src, count) zpci_memcpy_toio(dst, src, count) #define memset_io(dst, val, count) zpci_memset_io(dst, val, count) diff --git a/arch/s390/kernel/perf_cpum_sf.c b/arch/s390/kernel/perf_cpum_sf.c index 8ecfbce4ac92..dc6afc2221b4 100644 --- a/arch/s390/kernel/perf_cpum_sf.c +++ b/arch/s390/kernel/perf_cpum_sf.c @@ -22,7 +22,7 @@ #include #include #include -#include +#include /* Minimum number of sample-data-block-tables: * At least one table is required for the sampling buffer structure. diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c index afc3f33788da..d34d5813d006 100644 --- a/arch/s390/pci/pci.c +++ b/arch/s390/pci/pci.c @@ -244,62 +244,25 @@ void __iowrite64_copy(void __iomem *to, const void *from, size_t count) zpci_memcpy_toio(to, from, count); } -static void __iomem *__ioremap(phys_addr_t addr, size_t size, pgprot_t prot) +void __iomem *ioremap_prot(phys_addr_t phys_addr, size_t size, + unsigned long prot) { - unsigned long offset, vaddr; - struct vm_struct *area; - phys_addr_t last_addr; - - last_addr = addr + size - 1; - if (!size || last_addr < addr) - return NULL; - + /* + * When PCI MIO instructions are unavailable the "physical" address + * encodes a hint for accessing the PCI memory space it represents. + * Just pass it unchanged such that ioread/iowrite can decode it. + */ if (!static_branch_unlikely(&have_mio)) - return (void __iomem *) addr; + return (void __iomem *)phys_addr; - offset = addr & ~PAGE_MASK; - addr &= PAGE_MASK; - size = PAGE_ALIGN(size + offset); - area = get_vm_area(size, VM_IOREMAP); - if (!area) - return NULL; - - vaddr = (unsigned long) area->addr; - if (ioremap_page_range(vaddr, vaddr + size, addr, prot)) { - free_vm_area(area); - return NULL; - } - return (void __iomem *) ((unsigned long) area->addr + offset); -} - -void __iomem *ioremap_prot(phys_addr_t addr, size_t size, unsigned long prot) -{ - return __ioremap(addr, size, __pgprot(prot)); + return generic_ioremap_prot(phys_addr, size, __pgprot(prot)); } EXPORT_SYMBOL(ioremap_prot); -void __iomem *ioremap(phys_addr_t addr, size_t size) -{ - return __ioremap(addr, size, PAGE_KERNEL); -} -EXPORT_SYMBOL(ioremap); - -void __iomem *ioremap_wc(phys_addr_t addr, size_t size) -{ - return __ioremap(addr, size, pgprot_writecombine(PAGE_KERNEL)); -} -EXPORT_SYMBOL(ioremap_wc); - -void __iomem *ioremap_wt(phys_addr_t addr, size_t size) -{ - return __ioremap(addr, size, pgprot_writethrough(PAGE_KERNEL)); -} -EXPORT_SYMBOL(ioremap_wt); - void iounmap(volatile void __iomem *addr) { if (static_branch_likely(&have_mio)) - vunmap((__force void *) ((unsigned long) addr & PAGE_MASK)); + generic_iounmap(addr); } EXPORT_SYMBOL(iounmap); From patchwork Thu Jul 6 15:45:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 116782 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp2665480vqx; Thu, 6 Jul 2023 09:04:34 -0700 (PDT) X-Google-Smtp-Source: APBJJlExxK5YQjzz8s/2a7BWLVn5Uj+DLpzAMjvDrIh+m7ecHOfn7LdhZWqppSovgDQglAVS1Bgm X-Received: by 2002:a05:6a20:3d15:b0:12d:f1ac:e2cd with SMTP id y21-20020a056a203d1500b0012df1ace2cdmr2161538pzi.32.1688659473619; Thu, 06 Jul 2023 09:04:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688659473; cv=none; d=google.com; s=arc-20160816; b=Q6IxuUEaympRMO+ha2rEWw+460vGgCCAmXf5EF6KtCgIiQMC24dHCRC0NaXzqsQSXs wHjzFcTLYQsTV/cp4loHVkepM975UEpk8H/k/fIv0ArVRh5lTSIzuYxjQ2JsTmfJ/vDl gqe+U6WeR0Agi62Fu4ybg7MkfXY+jywGtnFZSoW91ttkZfBXsHG+MqTEnEYDNVl5f+Of TL/V6oydi1gUt9XR7L867LcxWRywSEHioC2HO3bMSgEXm+I6ZFduAB3MJdRc/MgFzzt/ z0DZ1VRUOeGfMyYVIF9wyNeAiYZfMQZKWQJEDLiR08wC/KwDMOSzlVb28UQIHBgoE5Z1 Yrfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=tzZiG+lU/mpwC2M6do1wPfvjsF6WIZJJprfTB9qP0II=; fh=ubdy/PBAtYfORAViLUf1QLnHIf5kc6J5VKbwuOo9FZY=; b=QBNdjO2+D9qc2bqw4CAFHfPwj4wuzWyU8vGRgqTT0/Jr8BlDt4DKlJA6OEO7mOSMF0 uQxDPV/S2UdMYg2m6JSHGHNQS5fGmqSb7DsVrLxyV2BM1/Kk3OZrxEoVzNNid2m/Nl+c CzWDfHnGBHtOgGH+2imEM2KUCK732Br1ejaR8e5ACjv0GSTgrBpza2PAGdUXjyOsI/CI FfH0PM2Sw5M21n3yUUN9PfOyGE89aayrtouHyiRcbJyBf+xgiY/3UNll2DOrjgT18sRx 79eb4kFP7PV6rVJ1cK+OmSwUq8N3p7W+6bbaJZ17YnILoAIzf7CB5AXhnLNSZA/ojp3y yD8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=XXK4y2mN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id jd20-20020a170903261400b001b53cb22fb3si1509310plb.277.2023.07.06.09.04.00; Thu, 06 Jul 2023 09:04:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=XXK4y2mN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232307AbjGFPs6 (ORCPT + 99 others); Thu, 6 Jul 2023 11:48:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45912 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229527AbjGFPsf (ORCPT ); Thu, 6 Jul 2023 11:48:35 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B029A212B for ; Thu, 6 Jul 2023 08:47:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1688658445; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tzZiG+lU/mpwC2M6do1wPfvjsF6WIZJJprfTB9qP0II=; b=XXK4y2mN82z3Br8kxvhnBDEDS/ASQ3WF7kFSrZnKyFS7VhXuyh2np9aW8EPPZ0Mx8v4UBS 0HnzpM8uWhlX6b7xGBuwa/ahzI1D8BBV8VZyeplJJH73MPyC57/V2d0CSwJNncGaB2jfAX YilBWNbeBn4UDkbI7Beutqh/zzmhu2s= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-672-0iqGGaRmOUaijaM3Mod1VQ-1; Thu, 06 Jul 2023 11:47:20 -0400 X-MC-Unique: 0iqGGaRmOUaijaM3Mod1VQ-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E391B800CB3; Thu, 6 Jul 2023 15:47:18 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-39.pek2.redhat.com [10.72.12.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id F1BA3F5CF0; Thu, 6 Jul 2023 15:47:09 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: akpm@linux-foundation.org, linux-mm@kvack.org, arnd@arndb.de, hch@lst.de, christophe.leroy@csgroup.eu, rppt@kernel.org, willy@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, shorne@gmail.com, David.Laight@ACULAB.COM, deller@gmx.de, nathan@kernel.org, glaubitz@physik.fu-berlin.de, Baoquan He , Yoshinori Sato , Rich Felker , linux-sh@vger.kernel.org Subject: [PATCH v8 11/19] sh: add including Date: Thu, 6 Jul 2023 23:45:12 +0800 Message-Id: <20230706154520.11257-12-bhe@redhat.com> In-Reply-To: <20230706154520.11257-1-bhe@redhat.com> References: <20230706154520.11257-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770687796012842465?= X-GMAIL-MSGID: =?utf-8?q?1770687796012842465?= In , it provides a generic implementation of all I/O accessors. For some port|mm io functions, SuperH has its own implementation in arch/sh/kernel/iomap.c and arch/sh/include/asm/io_noioport.h. These will conflict with those in and cause compiling error. Hence add macro definitions to ensure that the SuperH version of them will override the generic version. Signed-off-by: Baoquan He Cc: John Paul Adrian Glaubitz Cc: Yoshinori Sato Cc: Rich Felker Cc: linux-sh@vger.kernel.org Acked-by: John Paul Adrian Glaubitz --- arch/sh/include/asm/io.h | 25 +++++++++++++++++++++++++ arch/sh/include/asm/io_noioport.h | 7 +++++++ 2 files changed, 32 insertions(+) diff --git a/arch/sh/include/asm/io.h b/arch/sh/include/asm/io.h index fba90e670ed4..270e7952950c 100644 --- a/arch/sh/include/asm/io.h +++ b/arch/sh/include/asm/io.h @@ -119,6 +119,26 @@ void __raw_readsl(const void __iomem *addr, void *data, int longlen); __BUILD_MEMORY_STRING(__raw_, q, u64) +#define ioread8 ioread8 +#define ioread16 ioread16 +#define ioread16be ioread16be +#define ioread32 ioread32 +#define ioread32be ioread32be + +#define iowrite8 iowrite8 +#define iowrite16 iowrite16 +#define iowrite16be iowrite16be +#define iowrite32 iowrite32 +#define iowrite32be iowrite32be + +#define ioread8_rep ioread8_rep +#define ioread16_rep ioread16_rep +#define ioread32_rep ioread32_rep + +#define iowrite8_rep iowrite8_rep +#define iowrite16_rep iowrite16_rep +#define iowrite32_rep iowrite32_rep + #ifdef CONFIG_HAS_IOPORT_MAP /* @@ -225,6 +245,9 @@ __BUILD_IOPORT_STRING(q, u64) #define IO_SPACE_LIMIT 0xffffffff /* We really want to try and get these to memcpy etc */ +#define memset_io memset_io +#define memcpy_fromio memcpy_fromio +#define memcpy_toio memcpy_toio void memcpy_fromio(void *, const volatile void __iomem *, unsigned long); void memcpy_toio(volatile void __iomem *, const void *, unsigned long); void memset_io(volatile void __iomem *, int, unsigned long); @@ -287,6 +310,8 @@ static inline void iounmap(volatile void __iomem *addr) { } */ #define xlate_dev_mem_ptr(p) __va(p) +#include + #define ARCH_HAS_VALID_PHYS_ADDR_RANGE int valid_phys_addr_range(phys_addr_t addr, size_t size); int valid_mmap_phys_addr_range(unsigned long pfn, size_t size); diff --git a/arch/sh/include/asm/io_noioport.h b/arch/sh/include/asm/io_noioport.h index f7938fe0f911..5ba4116b4265 100644 --- a/arch/sh/include/asm/io_noioport.h +++ b/arch/sh/include/asm/io_noioport.h @@ -53,6 +53,13 @@ static inline void ioport_unmap(void __iomem *addr) #define outw_p(x, addr) outw((x), (addr)) #define outl_p(x, addr) outl((x), (addr)) +#define insb insb +#define insw insw +#define insl insl +#define outsb outsb +#define outsw outsw +#define outsl outsl + static inline void insb(unsigned long port, void *dst, unsigned long count) { BUG(); From patchwork Thu Jul 6 15:45:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 116788 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp2670850vqx; Thu, 6 Jul 2023 09:11:25 -0700 (PDT) X-Google-Smtp-Source: APBJJlEHym+tGzCpoQO9h07cOslaXVNzhh6gPaFitjPBnQIvW4mEsN2ZtPr3mfHR7/R37nLfQ3+i X-Received: by 2002:a05:6808:1508:b0:39e:ae2e:60e2 with SMTP id u8-20020a056808150800b0039eae2e60e2mr3538999oiw.32.1688659885179; Thu, 06 Jul 2023 09:11:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688659885; cv=none; d=google.com; s=arc-20160816; b=X6UzOyiHtrlqbtlpC+jxviuxIsISwTY1KeVsn82ufGboHqbsmqAm8DAf6CDvU/I9Yz iMt8wTaUDgLsDejx3oBmx+St9C88RGEKdcLFU2b3X3LzchL8bK5yIR4ZX6wQb/7kZW7p PQBGghpR8fhmMSOKxUtZ21whh9uMDvHWlO4E/VM0yRY8Qtd1EScHcEfmwsnHsctBVatY vwDS2ZZD454YRsnSEEowGSK4/UMH1VUpHYQQ5AVETYEkAX+4XKir1cQX20Dkd4O38zOK XBktPQdxnrX8PKlBBpaLgO4f2LqiV8torPV2TN1xSzkiRScdD1UAZEqAbQNohMqmzf6L tY3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=oemqTF5zxWGJe7eTucw4w0j0Azve239hRRVpg02qoms=; fh=ubdy/PBAtYfORAViLUf1QLnHIf5kc6J5VKbwuOo9FZY=; b=yv4ISGhHXrBrhcjRHgkxDKZF529qUrdW7rXzWtqPKsIzY42W+slfyuYfUTHHxeH4yO 0z2ba5M0xLLjHhkbubWWmxAFUWoixEjg9FZ5BEtfOAFtjIoWpWg4d0n+6skuvPxBWU8j Kd8BOSXm4HUYOzIKdrw50ApkzE2qFMRrG42hX8eewA553rCJZRS1HuB4rsho+sFonhQp Ialm9octYCWpcgAA/RngWNWmrEuMAwbX+VuXIjCDHz6X9pNbTz59zBR3/9ffvnunFJje x6qsubCl4vpcWi9MNro27FnEv0YXcHsrS5ABQQhMjWn4sYoJs1sJtMx0DS6VmMEC5cRy ksPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=QeWG1tfr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 206-20020a6300d7000000b0053ef08b29bbsi1669791pga.564.2023.07.06.09.10.59; Thu, 06 Jul 2023 09:11:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=QeWG1tfr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232996AbjGFPtK (ORCPT + 99 others); Thu, 6 Jul 2023 11:49:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44896 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231732AbjGFPss (ORCPT ); Thu, 6 Jul 2023 11:48:48 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA0931FDB for ; Thu, 6 Jul 2023 08:47:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1688658453; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=oemqTF5zxWGJe7eTucw4w0j0Azve239hRRVpg02qoms=; b=QeWG1tfrTeyEPhqcQbkhsIWn8LDh6Bmv0onFaDVed2ZhlRP2o5hZiDTQO4bDHZ8cq5By4L EJsOqyrCPYTolJbpdI8sJqsXj8AYEJ5z/k4LvQFoAeRXhWlxeGIHXLb1o0F86LC44sXiG0 ZthP1GiGsgnOT0+Vz3euScCcErQxAVs= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-457-zWaEbkE9Msm1q8C2Gnjlpw-1; Thu, 06 Jul 2023 11:47:30 -0400 X-MC-Unique: zWaEbkE9Msm1q8C2Gnjlpw-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B64CB803FDF; Thu, 6 Jul 2023 15:47:28 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-39.pek2.redhat.com [10.72.12.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id 884B9F5CFB; Thu, 6 Jul 2023 15:47:19 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: akpm@linux-foundation.org, linux-mm@kvack.org, arnd@arndb.de, hch@lst.de, christophe.leroy@csgroup.eu, rppt@kernel.org, willy@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, shorne@gmail.com, David.Laight@ACULAB.COM, deller@gmx.de, nathan@kernel.org, glaubitz@physik.fu-berlin.de, Baoquan He , Yoshinori Sato , Rich Felker , linux-sh@vger.kernel.org Subject: [PATCH v8 12/19] sh: mm: Convert to GENERIC_IOREMAP Date: Thu, 6 Jul 2023 23:45:13 +0800 Message-Id: <20230706154520.11257-13-bhe@redhat.com> In-Reply-To: <20230706154520.11257-1-bhe@redhat.com> References: <20230706154520.11257-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770688227823006062?= X-GMAIL-MSGID: =?utf-8?q?1770688227823006062?= By taking GENERIC_IOREMAP method, the generic generic_ioremap_prot(), generic_iounmap(), and their generic wrapper ioremap_prot(), ioremap() and iounmap() are all visible and available to arch. Arch needs to provide wrapper functions to override the generic versions if there's arch specific handling in its ioremap_prot(), ioremap() or iounmap(). This change will simplify implementation by removing duplicated code with generic_ioremap_prot() and generic_iounmap(), and has the equivalent functioality as before. Here, add wrapper functions ioremap_prot() and iounmap() for SuperH's special operation when ioremap() and iounmap(). Signed-off-by: Baoquan He Cc: John Paul Adrian Glaubitz Cc: Yoshinori Sato Cc: Rich Felker Cc: linux-sh@vger.kernel.org --- arch/sh/Kconfig | 1 + arch/sh/include/asm/io.h | 40 +++++-------------------- arch/sh/mm/ioremap.c | 65 +++++++--------------------------------- 3 files changed, 20 insertions(+), 86 deletions(-) diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig index 2b3ce4fd3956..6be32254211c 100644 --- a/arch/sh/Kconfig +++ b/arch/sh/Kconfig @@ -29,6 +29,7 @@ config SUPERH select GENERIC_SMP_IDLE_THREAD select GUP_GET_PXX_LOW_HIGH if X2TLB select HAS_IOPORT if HAS_IOPORT_MAP + select GENERIC_IOREMAP if MMU select HAVE_ARCH_AUDITSYSCALL select HAVE_ARCH_KGDB select HAVE_ARCH_SECCOMP_FILTER diff --git a/arch/sh/include/asm/io.h b/arch/sh/include/asm/io.h index 270e7952950c..b3a26b405c8d 100644 --- a/arch/sh/include/asm/io.h +++ b/arch/sh/include/asm/io.h @@ -266,40 +266,16 @@ unsigned long long poke_real_address_q(unsigned long long addr, #endif #ifdef CONFIG_MMU -void iounmap(void __iomem *addr); -void __iomem *__ioremap_caller(phys_addr_t offset, unsigned long size, - pgprot_t prot, void *caller); - -static inline void __iomem *ioremap(phys_addr_t offset, unsigned long size) -{ - return __ioremap_caller(offset, size, PAGE_KERNEL_NOCACHE, - __builtin_return_address(0)); -} - -static inline void __iomem * -ioremap_cache(phys_addr_t offset, unsigned long size) -{ - return __ioremap_caller(offset, size, PAGE_KERNEL, - __builtin_return_address(0)); -} -#define ioremap_cache ioremap_cache - -#ifdef CONFIG_HAVE_IOREMAP_PROT -static inline void __iomem *ioremap_prot(phys_addr_t offset, unsigned long size, - unsigned long flags) -{ - return __ioremap_caller(offset, size, __pgprot(flags), - __builtin_return_address(0)); -} -#endif /* CONFIG_HAVE_IOREMAP_PROT */ +/* + * I/O memory mapping functions. + */ +#define ioremap_prot ioremap_prot +#define iounmap iounmap -#else /* CONFIG_MMU */ -static inline void __iomem *ioremap(phys_addr_t offset, size_t size) -{ - return (void __iomem *)(unsigned long)offset; -} +#define _PAGE_IOREMAP pgprot_val(PAGE_KERNEL_NOCACHE) -static inline void iounmap(volatile void __iomem *addr) { } +#define ioremap_cache(addr, size) \ + ioremap_prot((addr), (size), pgprot_val(PAGE_KERNEL)) #endif /* CONFIG_MMU */ #define ioremap_uc ioremap diff --git a/arch/sh/mm/ioremap.c b/arch/sh/mm/ioremap.c index 21342581144d..c33b3daa4ad1 100644 --- a/arch/sh/mm/ioremap.c +++ b/arch/sh/mm/ioremap.c @@ -72,22 +72,11 @@ __ioremap_29bit(phys_addr_t offset, unsigned long size, pgprot_t prot) #define __ioremap_29bit(offset, size, prot) NULL #endif /* CONFIG_29BIT */ -/* - * Remap an arbitrary physical address space into the kernel virtual - * address space. Needed when the kernel wants to access high addresses - * directly. - * - * NOTE! We need to allow non-page-aligned mappings too: we will obviously - * have to convert them into an offset in a page-aligned mapping, but the - * caller shouldn't need to know that small detail. - */ -void __iomem * __ref -__ioremap_caller(phys_addr_t phys_addr, unsigned long size, - pgprot_t pgprot, void *caller) +void __iomem *ioremap_prot(phys_addr_t phys_addr, size_t size, + unsigned long prot) { - struct vm_struct *area; - unsigned long offset, last_addr, addr, orig_addr; void __iomem *mapped; + pgprot_t pgprot = __pgprot(prot); mapped = __ioremap_trapped(phys_addr, size); if (mapped) @@ -97,11 +86,6 @@ __ioremap_caller(phys_addr_t phys_addr, unsigned long size, if (mapped) return mapped; - /* Don't allow wraparound or zero size */ - last_addr = phys_addr + size - 1; - if (!size || last_addr < phys_addr) - return NULL; - /* * If we can't yet use the regular approach, go the fixmap route. */ @@ -112,34 +96,14 @@ __ioremap_caller(phys_addr_t phys_addr, unsigned long size, * First try to remap through the PMB. * PMB entries are all pre-faulted. */ - mapped = pmb_remap_caller(phys_addr, size, pgprot, caller); + mapped = pmb_remap_caller(phys_addr, size, pgprot, + __builtin_return_address(0)); if (mapped && !IS_ERR(mapped)) return mapped; - /* - * Mappings have to be page-aligned - */ - offset = phys_addr & ~PAGE_MASK; - phys_addr &= PAGE_MASK; - size = PAGE_ALIGN(last_addr+1) - phys_addr; - - /* - * Ok, go for it.. - */ - area = get_vm_area_caller(size, VM_IOREMAP, caller); - if (!area) - return NULL; - area->phys_addr = phys_addr; - orig_addr = addr = (unsigned long)area->addr; - - if (ioremap_page_range(addr, addr + size, phys_addr, pgprot)) { - vunmap((void *)orig_addr); - return NULL; - } - - return (void __iomem *)(offset + (char *)orig_addr); + return generic_ioremap_prot(phys_addr, size, pgprot); } -EXPORT_SYMBOL(__ioremap_caller); +EXPORT_SYMBOL(ioremap_prot); /* * Simple checks for non-translatable mappings. @@ -158,10 +122,9 @@ static inline int iomapping_nontranslatable(unsigned long offset) return 0; } -void iounmap(void __iomem *addr) +void iounmap(volatile void __iomem *addr) { unsigned long vaddr = (unsigned long __force)addr; - struct vm_struct *p; /* * Nothing to do if there is no translatable mapping. @@ -172,21 +135,15 @@ void iounmap(void __iomem *addr) /* * There's no VMA if it's from an early fixed mapping. */ - if (iounmap_fixed(addr) == 0) + if (iounmap_fixed((void __iomem *)addr) == 0) return; /* * If the PMB handled it, there's nothing else to do. */ - if (pmb_unmap(addr) == 0) + if (pmb_unmap((void __iomem *)addr) == 0) return; - p = remove_vm_area((void *)(vaddr & PAGE_MASK)); - if (!p) { - printk(KERN_ERR "%s: bad address %p\n", __func__, addr); - return; - } - - kfree(p); + generic_iounmap(addr); } EXPORT_SYMBOL(iounmap); From patchwork Thu Jul 6 15:45:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 116773 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp2656433vqx; Thu, 6 Jul 2023 08:50:24 -0700 (PDT) X-Google-Smtp-Source: APBJJlFo5sS5TVRaDSPdIefWeT3wNbP1rzr3bpJUPNAm4m3oP+n5mOAYv0PUJlqG1VKbf6lhsiHq X-Received: by 2002:a05:6a20:1610:b0:130:44be:eca0 with SMTP id l16-20020a056a20161000b0013044beeca0mr1460855pzj.51.1688658624237; Thu, 06 Jul 2023 08:50:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688658624; cv=none; d=google.com; s=arc-20160816; b=F7wtiTM+xlrsyI2ge9v/0A83J4IbUQ8oIgkzRLMC2V4gB1homvto20qT8ce4Sfy+UK /1lS8nyORE/ivkrM4QuFM3jJkCZEydh7GBp9pZzyzBbrsUR7lflmQsgVZKZjURHMJD91 l0klkrXEXmhrpXuGoBTZ/5AFeUCP350P/y6Wss2H6pwF7V4FR3argGah5V7KzQeZxIV4 rXzdYvin0c8Uk5/RnwGmyZbVdyrdo6gsrwbA2KnCalktmYqBJVMzYckUaarziXJvy572 LBPduSoKyHcmRAnmfjkC6D5SA+GP+PAVyNTwkOLnSN2j0KbHnDXtr8Wr0SGH8uPXmyz4 lGrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=oNtW2gZY5kTL8OZsi9xDDaXWO3ott7dJ82eWnmuGcO0=; fh=N8GpHOWTLJkIObiU7gO18E+snUBofxnPdQNFhujs5DA=; b=T99nbarSAuGSpNutX5p4qv/vI7QfcAl1yzmJnLJd4G6wrEWc+qt5SHaMZAO4ywZiYS XG37KiYhyvZ4AZzrooCWqlihB1pei+m/vX9IULfNV1mObQ7yiMaGMYDx/GAR3jvH7OSe RgmTV09Jkej7yHd+WqxSE2YityHhaMv7FOw0WDVDGbf4TpIkKYJ8orfcLoZkakpLGhH4 8bF5ApBx3soeZfMczQ6K19Jh1MX1KlOWGTW3n3mHoTz9g1IcyhCJXKIyJTXwnRgJ8LcY BUBznBuIXxP6+NI7ZcFH08vhUSSWQsOr4PVJpz29pz9ox27tTW++2ztTpFfXgyyVFK4x wL3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=KsBsMucO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id kv14-20020a17090328ce00b001b8867a7ce2si1467734plb.273.2023.07.06.08.50.10; Thu, 06 Jul 2023 08:50:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=KsBsMucO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232514AbjGFPtM (ORCPT + 99 others); Thu, 6 Jul 2023 11:49:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45978 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233037AbjGFPsx (ORCPT ); Thu, 6 Jul 2023 11:48:53 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 783211BF0 for ; Thu, 6 Jul 2023 08:47:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1688658463; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=oNtW2gZY5kTL8OZsi9xDDaXWO3ott7dJ82eWnmuGcO0=; b=KsBsMucO2tWRpVHdrhyNIPtoZcNprHERrqAMR/D906ML34m9ZroJZBYYourXa8fAPOwnNS Hv6SOCqgbczqFr0Kr+15ceTX0y+5YhSLrqdB717ZP/BsxOnWyv8NZkYGxKtpvUhWgp22Bz xquhlslcY/4t1Bb/3x29RLMEp8iIhIE= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-147-nR317nlKPae4uls70wOO-Q-1; Thu, 06 Jul 2023 11:47:39 -0400 X-MC-Unique: nR317nlKPae4uls70wOO-Q-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5E01B185A792; Thu, 6 Jul 2023 15:47:38 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-39.pek2.redhat.com [10.72.12.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id 88F8FF5CF0; Thu, 6 Jul 2023 15:47:29 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: akpm@linux-foundation.org, linux-mm@kvack.org, arnd@arndb.de, hch@lst.de, christophe.leroy@csgroup.eu, rppt@kernel.org, willy@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, shorne@gmail.com, David.Laight@ACULAB.COM, deller@gmx.de, nathan@kernel.org, glaubitz@physik.fu-berlin.de, Baoquan He , Chris Zankel , Max Filippov Subject: [PATCH v8 13/19] xtensa: mm: Convert to GENERIC_IOREMAP Date: Thu, 6 Jul 2023 23:45:14 +0800 Message-Id: <20230706154520.11257-14-bhe@redhat.com> In-Reply-To: <20230706154520.11257-1-bhe@redhat.com> References: <20230706154520.11257-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770686905503818507?= X-GMAIL-MSGID: =?utf-8?q?1770686905503818507?= By taking GENERIC_IOREMAP method, the generic generic_ioremap_prot(), generic_iounmap(), and their generic wrapper ioremap_prot(), ioremap() and iounmap() are all visible and available to arch. Arch needs to provide wrapper functions to override the generic versions if there's arch specific handling in its ioremap_prot(), ioremap() or iounmap(). This change will simplify implementation by removing duplicated code with generic_ioremap_prot() and generic_iounmap(), and has the equivalent functioality as before. Here, add wrapper functions ioremap_prot(), ioremap() and iounmap() for xtensa's special operation when ioremap() and iounmap(). Signed-off-by: Baoquan He Reviewed-by: Christoph Hellwig Reviewed-by: Mike Rapoport (IBM) Cc: Chris Zankel Cc: Max Filippov --- arch/xtensa/Kconfig | 1 + arch/xtensa/include/asm/io.h | 32 ++++++++------------ arch/xtensa/mm/ioremap.c | 58 +++++++++--------------------------- 3 files changed, 27 insertions(+), 64 deletions(-) diff --git a/arch/xtensa/Kconfig b/arch/xtensa/Kconfig index 2a51a466779f..a5488cc40f58 100644 --- a/arch/xtensa/Kconfig +++ b/arch/xtensa/Kconfig @@ -28,6 +28,7 @@ config XTENSA select GENERIC_LIB_UCMPDI2 select GENERIC_PCI_IOMAP select GENERIC_SCHED_CLOCK + select GENERIC_IOREMAP if MMU select HAVE_ARCH_AUDITSYSCALL select HAVE_ARCH_JUMP_LABEL if !XIP_KERNEL select HAVE_ARCH_KASAN if MMU && !XIP_KERNEL diff --git a/arch/xtensa/include/asm/io.h b/arch/xtensa/include/asm/io.h index a5b707e1c0f4..934e58399c8c 100644 --- a/arch/xtensa/include/asm/io.h +++ b/arch/xtensa/include/asm/io.h @@ -16,6 +16,7 @@ #include #include #include +#include #include @@ -24,22 +25,24 @@ #define PCI_IOBASE ((void __iomem *)XCHAL_KIO_BYPASS_VADDR) #ifdef CONFIG_MMU - -void __iomem *xtensa_ioremap_nocache(unsigned long addr, unsigned long size); -void __iomem *xtensa_ioremap_cache(unsigned long addr, unsigned long size); -void xtensa_iounmap(volatile void __iomem *addr); - /* - * Return the virtual address for the specified bus memory. + * I/O memory mapping functions. */ +void __iomem *ioremap_prot(phys_addr_t phys_addr, size_t size, + unsigned long prot); +#define ioremap_prot ioremap_prot +#define iounmap iounmap + static inline void __iomem *ioremap(unsigned long offset, unsigned long size) { if (offset >= XCHAL_KIO_PADDR && offset - XCHAL_KIO_PADDR < XCHAL_KIO_SIZE) return (void*)(offset-XCHAL_KIO_PADDR+XCHAL_KIO_BYPASS_VADDR); else - return xtensa_ioremap_nocache(offset, size); + return ioremap_prot(offset, size, + pgprot_val(pgprot_noncached(PAGE_KERNEL))); } +#define ioremap ioremap static inline void __iomem *ioremap_cache(unsigned long offset, unsigned long size) @@ -48,21 +51,10 @@ static inline void __iomem *ioremap_cache(unsigned long offset, && offset - XCHAL_KIO_PADDR < XCHAL_KIO_SIZE) return (void*)(offset-XCHAL_KIO_PADDR+XCHAL_KIO_CACHED_VADDR); else - return xtensa_ioremap_cache(offset, size); -} -#define ioremap_cache ioremap_cache + return ioremap_prot(offset, size, pgprot_val(PAGE_KERNEL)); -static inline void iounmap(volatile void __iomem *addr) -{ - unsigned long va = (unsigned long) addr; - - if (!(va >= XCHAL_KIO_CACHED_VADDR && - va - XCHAL_KIO_CACHED_VADDR < XCHAL_KIO_SIZE) && - !(va >= XCHAL_KIO_BYPASS_VADDR && - va - XCHAL_KIO_BYPASS_VADDR < XCHAL_KIO_SIZE)) - xtensa_iounmap(addr); } - +#define ioremap_cache ioremap_cache #endif /* CONFIG_MMU */ #include diff --git a/arch/xtensa/mm/ioremap.c b/arch/xtensa/mm/ioremap.c index a400188c16b9..8ca660b7ab49 100644 --- a/arch/xtensa/mm/ioremap.c +++ b/arch/xtensa/mm/ioremap.c @@ -6,60 +6,30 @@ */ #include -#include #include #include #include -static void __iomem *xtensa_ioremap(unsigned long paddr, unsigned long size, - pgprot_t prot) +void __iomem *ioremap_prot(phys_addr_t phys_addr, size_t size, + unsigned long prot) { - unsigned long offset = paddr & ~PAGE_MASK; - unsigned long pfn = __phys_to_pfn(paddr); - struct vm_struct *area; - unsigned long vaddr; - int err; - - paddr &= PAGE_MASK; - + unsigned long pfn = __phys_to_pfn((phys_addr)); WARN_ON(pfn_valid(pfn)); - size = PAGE_ALIGN(offset + size); - - area = get_vm_area(size, VM_IOREMAP); - if (!area) - return NULL; - - vaddr = (unsigned long)area->addr; - area->phys_addr = paddr; - - err = ioremap_page_range(vaddr, vaddr + size, paddr, prot); - - if (err) { - vunmap((void *)vaddr); - return NULL; - } - - flush_cache_vmap(vaddr, vaddr + size); - return (void __iomem *)(offset + vaddr); -} - -void __iomem *xtensa_ioremap_nocache(unsigned long addr, unsigned long size) -{ - return xtensa_ioremap(addr, size, pgprot_noncached(PAGE_KERNEL)); + return generic_ioremap_prot(phys_addr, size, __pgprot(prot)); } -EXPORT_SYMBOL(xtensa_ioremap_nocache); +EXPORT_SYMBOL(ioremap_prot); -void __iomem *xtensa_ioremap_cache(unsigned long addr, unsigned long size) +void iounmap(volatile void __iomem *addr) { - return xtensa_ioremap(addr, size, PAGE_KERNEL); -} -EXPORT_SYMBOL(xtensa_ioremap_cache); + unsigned long va = (unsigned long) addr; -void xtensa_iounmap(volatile void __iomem *io_addr) -{ - void *addr = (void *)(PAGE_MASK & (unsigned long)io_addr); + if ((va >= XCHAL_KIO_CACHED_VADDR && + va - XCHAL_KIO_CACHED_VADDR < XCHAL_KIO_SIZE) || + (va >= XCHAL_KIO_BYPASS_VADDR && + va - XCHAL_KIO_BYPASS_VADDR < XCHAL_KIO_SIZE)) + return; - vunmap(addr); + generic_iounmap(addr); } -EXPORT_SYMBOL(xtensa_iounmap); +EXPORT_SYMBOL(iounmap); From patchwork Thu Jul 6 15:45:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 116774 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp2656452vqx; Thu, 6 Jul 2023 08:50:27 -0700 (PDT) X-Google-Smtp-Source: APBJJlFH2ykwD41pPjGKDZdtULWDXEqjpOzS06kUrWvZUIduauyYh6x/HD53m/6mE9eo0MO3pk8B X-Received: by 2002:a05:6808:116:b0:3a1:dc0d:f337 with SMTP id b22-20020a056808011600b003a1dc0df337mr1897825oie.45.1688658626785; Thu, 06 Jul 2023 08:50:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688658626; cv=none; d=google.com; s=arc-20160816; b=idl5E+0NCXk7RnGAgQ4qyVAB6we5d49geGhvCusYkLmsBoPK3ZQ1JFb8K3BZUWhZLB S9kCXhLie1ChwkMEQR7HWxJCXRNez/pIHuhr3LvQYujUYIGTqFZDMXaI4mpPwSMlxPpt zuL1dwHPj9LRIJTwnfNtqmEsv0PRZ4phyKI3AAW6/cDidKPSl+RHr5iziQtVsfPeIFfi 1LmUKYEG6WtU2RKFuYpmJxBkYvEGIupXGHzcDq+Tsso1C9yBCS0SntNPgtG45Vdv8Z9u ShaWj9pFEIHaY8H2066yiv6B+IsP2iCkapGaWtDhGuiNRliis85A75ns5eLJvKqCPWHs C24g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=xVd2B5yrvoTei1eaDY2CI77gTkjY32uajA6qRNEVzX8=; fh=h7MzMOZadk+ug1P7Sw34znWpdEmuqDaSmOguBoiPaeY=; b=R4PFMxDW3cfjl/abUVxxIn1sajvur/TuUD7jY6HJlOHbIRX4fk1H6ouppHbM18EbQS Qz+pUJCbS7zfXUo83i/BJH4Ol8WNPVW+5n/ofMPm6sv4tQTTRalMhCcoCCP/umolXzhs Mvg27zuYDxXPaGELdiPOsKbkZRcYai6iVHSfc3E66ztDpYmcGL/0gMW+WvjZZcBrm6R+ 7N2YMKU7m6D40HhwpteUyrJ2s7d4FAZd8WtTjaTwoR0Oe2Ke8ftYpZMWQaUOUuivaMZZ 5DJLAYSiFLyOn6rD8nm7SMTQRLypD4WziwH4jv9iWeu6oDoCPWAX245pQLP+DA1ebnNm Z1sg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=brHtsX+w; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b13-20020a63d80d000000b0055ba5ea2de1si1733783pgh.855.2023.07.06.08.50.14; Thu, 06 Jul 2023 08:50:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=brHtsX+w; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233116AbjGFPtQ (ORCPT + 99 others); Thu, 6 Jul 2023 11:49:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46488 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232034AbjGFPsz (ORCPT ); Thu, 6 Jul 2023 11:48:55 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA96B2105 for ; Thu, 6 Jul 2023 08:47:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1688658471; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xVd2B5yrvoTei1eaDY2CI77gTkjY32uajA6qRNEVzX8=; b=brHtsX+w0IEhZUtC2X0XiKqx2Vvx2+ViuOW+oqEJiiPOeEnfE917Wq25Z3BPJpqFnHrlqp 96BMp4yUgH1XKgkW1qvnY8GHV71LAHAsGv/kBGJMK8zctBFc97HNUE/axQ+LVimAAgq9uX 6ai0xHbVmaWdG0/3kKR0ayDKQBa0qUs= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-45-UEVRCT9GNaiGMAVdytZG4g-1; Thu, 06 Jul 2023 11:47:49 -0400 X-MC-Unique: UEVRCT9GNaiGMAVdytZG4g-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id DC89085A58A; Thu, 6 Jul 2023 15:47:47 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-39.pek2.redhat.com [10.72.12.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id 42C56F5CFB; Thu, 6 Jul 2023 15:47:38 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: akpm@linux-foundation.org, linux-mm@kvack.org, arnd@arndb.de, hch@lst.de, christophe.leroy@csgroup.eu, rppt@kernel.org, willy@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, shorne@gmail.com, David.Laight@ACULAB.COM, deller@gmx.de, nathan@kernel.org, glaubitz@physik.fu-berlin.de, Baoquan He , "James E.J. Bottomley" , linux-parisc@vger.kernel.org Subject: [PATCH v8 14/19] parisc: mm: Convert to GENERIC_IOREMAP Date: Thu, 6 Jul 2023 23:45:15 +0800 Message-Id: <20230706154520.11257-15-bhe@redhat.com> In-Reply-To: <20230706154520.11257-1-bhe@redhat.com> References: <20230706154520.11257-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770686908066948150?= X-GMAIL-MSGID: =?utf-8?q?1770686908066948150?= By taking GENERIC_IOREMAP method, the generic generic_ioremap_prot(), generic_iounmap(), and their generic wrapper ioremap_prot(), ioremap() and iounmap() are all visible and available to arch. Arch needs to provide wrapper functions to override the generic versions if there's arch specific handling in its ioremap_prot(), ioremap() or iounmap(). This change will simplify implementation by removing duplicated code with generic_ioremap_prot() and generic_iounmap(), and has the equivalent functioality as before. Here, add wrapper function ioremap_prot() for parisc's special operation when iounmap(). Signed-off-by: Baoquan He Reviewed-by: Christoph Hellwig Reviewed-by: Mike Rapoport (IBM) Acked-by: Helge Deller Cc: "James E.J. Bottomley" Cc: Helge Deller Cc: linux-parisc@vger.kernel.org --- arch/parisc/Kconfig | 1 + arch/parisc/include/asm/io.h | 15 ++++++--- arch/parisc/mm/ioremap.c | 62 +++--------------------------------- 3 files changed, 15 insertions(+), 63 deletions(-) diff --git a/arch/parisc/Kconfig b/arch/parisc/Kconfig index 4cb46d5c64a2..4cda9f0a3277 100644 --- a/arch/parisc/Kconfig +++ b/arch/parisc/Kconfig @@ -36,6 +36,7 @@ config PARISC select GENERIC_ATOMIC64 if !64BIT select GENERIC_IRQ_PROBE select GENERIC_PCI_IOMAP + select GENERIC_IOREMAP select ARCH_HAVE_NMI_SAFE_CMPXCHG select GENERIC_SMP_IDLE_THREAD select GENERIC_ARCH_TOPOLOGY if SMP diff --git a/arch/parisc/include/asm/io.h b/arch/parisc/include/asm/io.h index c05e781be2f5..366537042465 100644 --- a/arch/parisc/include/asm/io.h +++ b/arch/parisc/include/asm/io.h @@ -125,12 +125,17 @@ static inline void gsc_writeq(unsigned long long val, unsigned long addr) /* * The standard PCI ioremap interfaces */ -void __iomem *ioremap(unsigned long offset, unsigned long size); -#define ioremap_wc ioremap -#define ioremap_uc ioremap -#define pci_iounmap pci_iounmap +#define ioremap_prot ioremap_prot + +#define _PAGE_IOREMAP (_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | \ + _PAGE_ACCESSED | _PAGE_NO_CACHE) -extern void iounmap(const volatile void __iomem *addr); +#define ioremap_wc(addr, size) \ + ioremap_prot((addr), (size), _PAGE_IOREMAP) +#define ioremap_uc(addr, size) \ + ioremap_prot((addr), (size), _PAGE_IOREMAP) + +#define pci_iounmap pci_iounmap void memset_io(volatile void __iomem *addr, unsigned char val, int count); void memcpy_fromio(void *dst, const volatile void __iomem *src, int count); diff --git a/arch/parisc/mm/ioremap.c b/arch/parisc/mm/ioremap.c index 345ff0b66499..fd996472dfe7 100644 --- a/arch/parisc/mm/ioremap.c +++ b/arch/parisc/mm/ioremap.c @@ -13,25 +13,9 @@ #include #include -/* - * Generic mapping function (not visible outside): - */ - -/* - * Remap an arbitrary physical address space into the kernel virtual - * address space. - * - * NOTE! We need to allow non-page-aligned mappings too: we will obviously - * have to convert them into an offset in a page-aligned mapping, but the - * caller shouldn't need to know that small detail. - */ -void __iomem *ioremap(unsigned long phys_addr, unsigned long size) +void __iomem *ioremap_prot(phys_addr_t phys_addr, size_t size, + unsigned long prot) { - void __iomem *addr; - struct vm_struct *area; - unsigned long offset, last_addr; - pgprot_t pgprot; - #ifdef CONFIG_EISA unsigned long end = phys_addr + size - 1; /* Support EISA addresses */ @@ -40,11 +24,6 @@ void __iomem *ioremap(unsigned long phys_addr, unsigned long size) phys_addr |= F_EXTEND(0xfc000000); #endif - /* Don't allow wraparound or zero size */ - last_addr = phys_addr + size - 1; - if (!size || last_addr < phys_addr) - return NULL; - /* * Don't allow anybody to remap normal RAM that we're using.. */ @@ -62,39 +41,6 @@ void __iomem *ioremap(unsigned long phys_addr, unsigned long size) } } - pgprot = __pgprot(_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | - _PAGE_ACCESSED | _PAGE_NO_CACHE); - - /* - * Mappings have to be page-aligned - */ - offset = phys_addr & ~PAGE_MASK; - phys_addr &= PAGE_MASK; - size = PAGE_ALIGN(last_addr + 1) - phys_addr; - - /* - * Ok, go for it.. - */ - area = get_vm_area(size, VM_IOREMAP); - if (!area) - return NULL; - - addr = (void __iomem *) area->addr; - if (ioremap_page_range((unsigned long)addr, (unsigned long)addr + size, - phys_addr, pgprot)) { - vunmap(addr); - return NULL; - } - - return (void __iomem *) (offset + (char __iomem *)addr); -} -EXPORT_SYMBOL(ioremap); - -void iounmap(const volatile void __iomem *io_addr) -{ - unsigned long addr = (unsigned long)io_addr & PAGE_MASK; - - if (is_vmalloc_addr((void *)addr)) - vunmap((void *)addr); + return generic_ioremap_prot(phys_addr, size, __pgprot(prot)); } -EXPORT_SYMBOL(iounmap); +EXPORT_SYMBOL(ioremap_prot); From patchwork Thu Jul 6 15:45:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 116786 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp2670851vqx; Thu, 6 Jul 2023 09:11:25 -0700 (PDT) X-Google-Smtp-Source: APBJJlGIv5lme5gLgrt9q6n4o9u5ixmispHNyaFmtXl5IeRJ0cmbNkBpV7p6WtiImrIIg5Rwgk2t X-Received: by 2002:a17:90b:3908:b0:263:f3d0:7ea2 with SMTP id ob8-20020a17090b390800b00263f3d07ea2mr7578941pjb.8.1688659885280; Thu, 06 Jul 2023 09:11:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688659885; cv=none; d=google.com; s=arc-20160816; b=mxA+i+ALdqmB3/4ToF7L0zi689lUcYwsJVD3kmnzUHYhgXM+4USpP+HgkfBaZ5IQIx /dlDWgD0XnOEXXv6TimeasWbgJGJNOeIkFgJe3LOQT0f4104QIhsLyH1EtYaoj2gpU2S qy7JBdUUAwkSdcX7lwTzXT6PYtJd5OWFdVOq7QxLcke5wnOmuQ8493YZQhFvpHXMSOvT nn9DGKL3D62yQtjOw9IK0Kp6LqTjfBQzaCmYru8/ousMT4SdCy6EoEXWqy05I5OSsoCX uOjLF6ExwZ96DPm45oxvLEM9YYkarVnR8+Z8fBj6dHfzZG/JwCv4cl6UWgEa/19VV8Vi 9zew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=SboB+Gem+bQaB39EZZBPE5ZHPttNaa4nwbopj4kdit4=; fh=MRqAqm0/X6LLHlLdJym4NBXwcTEGRfSmsWs7mgX78Dg=; b=qDTCzutsQgujgjgt10FkV97/OnA6c3olMlTPzZiaI0YVUAvnCkjIrZ8uuEthGLFUqx LyGOR3gixQZlv/x4CqorZK+eGtEp5/npnN+i9bITQpOk7/nA0NIxxYrow3XUe7uD6EZ4 kmdCkgrW/zhytO8s2/q6bx/l9NpniucoIiNP81lwHAd7zEV1S2nwihYtOOPbNvEkDH1v 0NsueZkjNTI+xAG6515iOoMwX+56Z3BcFFluKfYAwy+G9rmgmxi8bKYUxYt8+bMZPdUS QCAL+4JSX4WBoVbgk1Wxs+4oPOieXiXoY6LQXNSRexKOxnx5mrG4p+fiIgSe50fo480n EVPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=IQidm1EC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w8-20020a63f508000000b0055785ad71c5si1651220pgh.599.2023.07.06.09.11.01; Thu, 06 Jul 2023 09:11:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=IQidm1EC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233071AbjGFPtg (ORCPT + 99 others); Thu, 6 Jul 2023 11:49:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46206 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232879AbjGFPtF (ORCPT ); Thu, 6 Jul 2023 11:49:05 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2782D1BF8 for ; Thu, 6 Jul 2023 08:48:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1688658482; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SboB+Gem+bQaB39EZZBPE5ZHPttNaa4nwbopj4kdit4=; b=IQidm1EC58/vjDq6gQE+xUk7FunNqDhtYSJvhh4A3TjvCB/QeDtpdKGtArpqCuha6UPnFz N0vGco5yBHhv5yIAWvEuiggPXz7OuCYkxfafs5vsCbfH8T8ukZUHQ0E/1E1zR3F99nR7vz xUnbwtiJWaLD3DwG8yzas8cdvgwAX2I= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-102-Zgylzl54Oz6H0HNz3490IA-1; Thu, 06 Jul 2023 11:47:57 -0400 X-MC-Unique: Zgylzl54Oz6H0HNz3490IA-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 318981044591; Thu, 6 Jul 2023 15:47:56 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-39.pek2.redhat.com [10.72.12.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id C303DF5CF0; Thu, 6 Jul 2023 15:47:48 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: akpm@linux-foundation.org, linux-mm@kvack.org, arnd@arndb.de, hch@lst.de, christophe.leroy@csgroup.eu, rppt@kernel.org, willy@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, shorne@gmail.com, David.Laight@ACULAB.COM, deller@gmx.de, nathan@kernel.org, glaubitz@physik.fu-berlin.de, Baoquan He Subject: [PATCH v8 15/19] mm/ioremap: Consider IOREMAP space in generic ioremap Date: Thu, 6 Jul 2023 23:45:16 +0800 Message-Id: <20230706154520.11257-16-bhe@redhat.com> In-Reply-To: <20230706154520.11257-1-bhe@redhat.com> References: <20230706154520.11257-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770688227802200028?= X-GMAIL-MSGID: =?utf-8?q?1770688227802200028?= From: Christophe Leroy Architectures like powerpc have a dedicated space for IOREMAP mappings. If so, use it in generic_ioremap_prot(). Signed-off-by: Christophe Leroy Signed-off-by: Baoquan He Reviewed-by: Christoph Hellwig --- mm/ioremap.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/mm/ioremap.c b/mm/ioremap.c index 86b82ec27d2b..68d9895144ad 100644 --- a/mm/ioremap.c +++ b/mm/ioremap.c @@ -11,6 +11,15 @@ #include #include +/* + * Ioremap often, but not always uses the generic vmalloc area. E.g on + * Power ARCH, it could have different ioremap space. + */ +#ifndef IOREMAP_START +#define IOREMAP_START VMALLOC_START +#define IOREMAP_END VMALLOC_END +#endif + void __iomem *generic_ioremap_prot(phys_addr_t phys_addr, size_t size, pgprot_t prot) { @@ -35,8 +44,8 @@ void __iomem *generic_ioremap_prot(phys_addr_t phys_addr, size_t size, if (!ioremap_allowed(phys_addr, size, pgprot_val(prot))) return NULL; - area = get_vm_area_caller(size, VM_IOREMAP, - __builtin_return_address(0)); + area = __get_vm_area_caller(size, VM_IOREMAP, IOREMAP_START, + IOREMAP_END, __builtin_return_address(0)); if (!area) return NULL; vaddr = (unsigned long)area->addr; @@ -66,7 +75,7 @@ void generic_iounmap(volatile void __iomem *addr) if (!iounmap_allowed(vaddr)) return; - if (is_vmalloc_addr(vaddr)) + if (is_ioremap_addr(vaddr)) vunmap(vaddr); } From patchwork Thu Jul 6 15:45:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 116775 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp2656530vqx; Thu, 6 Jul 2023 08:50:34 -0700 (PDT) X-Google-Smtp-Source: APBJJlHhZndOzKMKTvbiYyB+lmMlHm9qh+BDe5/W3vw2RZ02ocAfmumFPdChgzt0ey3ITmDsj2gI X-Received: by 2002:a92:502:0:b0:345:c8ce:ff4e with SMTP id q2-20020a920502000000b00345c8ceff4emr2378310ile.3.1688658633682; Thu, 06 Jul 2023 08:50:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688658633; cv=none; d=google.com; s=arc-20160816; b=C+mtIapt+yMS1+rzu83NvcfIVQbtRzu5wqOanR3gISiDbx5S1TUeFJ8erA9zhLHTZE VwEJXXxWd1w047w8xLA6JD1Y3jT1obCHJA5JbSI9OtxDwmBLZoUeKisUHF/VZaODDuBB PfZD0KPWPpzzTiibQltEUNKRU90PKoBG+JUhaFzz+T5uMSKy4MKyAEJk0Rgyw3bK2LpE rhOM9KWnYMgQoUKQJKwCrkfHAx6bRJZGzgONiLQnMdWQr7dEw7nqnoxWGHqSMDO5NRy4 JGqSJykkME6ADj8U51+A9/9eg6Pr/M8BGHuDqxjSh/lixOCv7IJiLnRHYHrOFJwy00FQ TSNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=OXVHYJC8bujxYB4NxHtHfdw+gECptwECGyaOXWJ60Bo=; fh=MRqAqm0/X6LLHlLdJym4NBXwcTEGRfSmsWs7mgX78Dg=; b=EVKCgMjQsGykzhFMW/uPwNw6ti143juXHmnnkHKN2qQ4OB6+PT4QoQWvXu9I1miiJq gTKtUwyP7A6Mzy6iWkxyp0tXvqm6em+QI2CrxqLoJz8e4lA2DIPSiKU/8lYApmZmkvUm fVcYbSic6HVs2ucX1CCH9YcpWloQe38wMLRwBl+TIn999Wy8XQrcIfM+QByvUgyGbUhh 3C88dNG05AsJ71W1iy2tmzS0g4RMCJfUj+ZFYTKMIF+R7OeaMFdfjLvCaQAYHTG1iAkJ vdQxMPz6/GWEH1BkNF8HKmNMP9uL+xgnfOYCtKzCVU4mOsH2swlSRBltknemMqOCqrk+ UY+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=RSD+4cit; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 26-20020a63115a000000b0055b731aa992si1654316pgr.370.2023.07.06.08.50.20; Thu, 06 Jul 2023 08:50:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=RSD+4cit; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233048AbjGFPtd (ORCPT + 99 others); Thu, 6 Jul 2023 11:49:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46638 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232970AbjGFPtE (ORCPT ); Thu, 6 Jul 2023 11:49:04 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C60A219B7 for ; Thu, 6 Jul 2023 08:48:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1688658487; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=OXVHYJC8bujxYB4NxHtHfdw+gECptwECGyaOXWJ60Bo=; b=RSD+4citm7j/96P8L/qvZ1P7NDtEP070qST5zOk7OBBLLOsfsVpNm5cayqsKuTT1PT7E5y B/VIbvqlq3vN2EXhVVM2AuTvTucNFxZ663HPvM/mLh3rQFu8owBmh4TZEeo7jisRuaRQa9 4v0J+akIYRj0aABJEMsvd6PAy+V1Qtw= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-411-XuV2aqowPm2l_i_JZ1GQaw-1; Thu, 06 Jul 2023 11:48:05 -0400 X-MC-Unique: XuV2aqowPm2l_i_JZ1GQaw-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C64C52815E3D; Thu, 6 Jul 2023 15:48:04 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-39.pek2.redhat.com [10.72.12.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id F3DFEF5CF0; Thu, 6 Jul 2023 15:47:56 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: akpm@linux-foundation.org, linux-mm@kvack.org, arnd@arndb.de, hch@lst.de, christophe.leroy@csgroup.eu, rppt@kernel.org, willy@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, shorne@gmail.com, David.Laight@ACULAB.COM, deller@gmx.de, nathan@kernel.org, glaubitz@physik.fu-berlin.de, Baoquan He Subject: [PATCH v8 16/19] mm: move is_ioremap_addr() into new header file Date: Thu, 6 Jul 2023 23:45:17 +0800 Message-Id: <20230706154520.11257-17-bhe@redhat.com> In-Reply-To: <20230706154520.11257-1-bhe@redhat.com> References: <20230706154520.11257-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770686915102749102?= X-GMAIL-MSGID: =?utf-8?q?1770686915102749102?= Now is_ioremap_addr() is only used in kernel/iomem.c and gonna be used in mm/ioremap.c. Move it into its own new header file linux/ioremap.h. Suggested-by: Christoph Hellwig Signed-off-by: Baoquan He Reviewed-by: Christoph Hellwig --- v7->v8: Fix conflict when rebasing to the latest linus's tree, it's caused by commit ef104443bffa ("procfs: consolidate arch_report_meminfo declaration") in file arch/powerpc/include/asm/pgtable.h. arch/powerpc/include/asm/pgtable.h | 10 ---------- include/linux/ioremap.h | 30 ++++++++++++++++++++++++++++++ include/linux/mm.h | 5 ----- kernel/iomem.c | 1 + mm/ioremap.c | 10 +--------- 5 files changed, 32 insertions(+), 24 deletions(-) create mode 100644 include/linux/ioremap.h diff --git a/arch/powerpc/include/asm/pgtable.h b/arch/powerpc/include/asm/pgtable.h index 6a88bfdaa69b..445a22987aa3 100644 --- a/arch/powerpc/include/asm/pgtable.h +++ b/arch/powerpc/include/asm/pgtable.h @@ -157,16 +157,6 @@ static inline pgtable_t pmd_pgtable(pmd_t pmd) return (pgtable_t)pmd_page_vaddr(pmd); } -#ifdef CONFIG_PPC64 -#define is_ioremap_addr is_ioremap_addr -static inline bool is_ioremap_addr(const void *x) -{ - unsigned long addr = (unsigned long)x; - - return addr >= IOREMAP_BASE && addr < IOREMAP_END; -} -#endif /* CONFIG_PPC64 */ - #endif /* __ASSEMBLY__ */ #endif /* _ASM_POWERPC_PGTABLE_H */ diff --git a/include/linux/ioremap.h b/include/linux/ioremap.h new file mode 100644 index 000000000000..f0e99fc7dd8b --- /dev/null +++ b/include/linux/ioremap.h @@ -0,0 +1,30 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _LINUX_IOREMAP_H +#define _LINUX_IOREMAP_H + +#include +#include + +#if defined(CONFIG_HAS_IOMEM) || defined(CONFIG_GENERIC_IOREMAP) +/* + * Ioremap often, but not always uses the generic vmalloc area. E.g on + * Power ARCH, it could have different ioremap space. + */ +#ifndef IOREMAP_START +#define IOREMAP_START VMALLOC_START +#define IOREMAP_END VMALLOC_END +#endif +static inline bool is_ioremap_addr(const void *x) +{ + unsigned long addr = (unsigned long)kasan_reset_tag(x); + + return addr >= IOREMAP_START && addr < IOREMAP_END; +} +#else +static inline bool is_ioremap_addr(const void *x) +{ + return false; +} +#endif + +#endif /* _LINUX_IOREMAP_H */ diff --git a/include/linux/mm.h b/include/linux/mm.h index 2dd73e4f3d8e..2bac9ec3527e 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -1055,11 +1055,6 @@ unsigned long vmalloc_to_pfn(const void *addr); * On nommu, vmalloc/vfree wrap through kmalloc/kfree directly, so there * is no special casing required. */ - -#ifndef is_ioremap_addr -#define is_ioremap_addr(x) is_vmalloc_addr(x) -#endif - #ifdef CONFIG_MMU extern bool is_vmalloc_addr(const void *x); extern int is_vmalloc_or_module_addr(const void *x); diff --git a/kernel/iomem.c b/kernel/iomem.c index 62c92e43aa0d..9682471e6471 100644 --- a/kernel/iomem.c +++ b/kernel/iomem.c @@ -3,6 +3,7 @@ #include #include #include +#include #ifndef ioremap_cache /* temporary while we convert existing ioremap_cache users to memremap */ diff --git a/mm/ioremap.c b/mm/ioremap.c index 68d9895144ad..a21a6c9fa5ab 100644 --- a/mm/ioremap.c +++ b/mm/ioremap.c @@ -10,15 +10,7 @@ #include #include #include - -/* - * Ioremap often, but not always uses the generic vmalloc area. E.g on - * Power ARCH, it could have different ioremap space. - */ -#ifndef IOREMAP_START -#define IOREMAP_START VMALLOC_START -#define IOREMAP_END VMALLOC_END -#endif +#include void __iomem *generic_ioremap_prot(phys_addr_t phys_addr, size_t size, pgprot_t prot) From patchwork Thu Jul 6 15:45:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 116783 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp2668882vqx; Thu, 6 Jul 2023 09:08:37 -0700 (PDT) X-Google-Smtp-Source: APBJJlEpoSiHW2anaj86d01LrZJsyVU9+lzA7AE2mLHu9h/WWjZw8K4Q1vXSPWV1ITYUY0DfZM7v X-Received: by 2002:a05:6808:e87:b0:39d:f03e:71ca with SMTP id k7-20020a0568080e8700b0039df03e71camr2509592oil.53.1688659717215; Thu, 06 Jul 2023 09:08:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688659717; cv=none; d=google.com; s=arc-20160816; b=mzLv5S0P2erhxex2OBQhPUeNe3cN8G5SukeOi6YNZii2vXlwsmF7BWPSsKo6DZaOhY Ad1XiAKfJ0QG/fWurOwdpdidVutBwzs4tbK2/2qSeyal12eaSBV/5pxM3H2yHGSJe0pZ YLMIXozUSo6G0QO0OYyuD8G4cprzM7JugICO3xOQU9VHZESS699zFd8F19a+HaqyiaZt M4vOFCZBcycO1MrewKFqong3V4mfxm9d+qUUQ/c04nVAcCKwha3mq3GDBUeShMtwTy0A fsUfjdQXaDbjN3T+e+7rcCWtPs/iVHEvVjL+lWZtJVYbHlg0QHVFiGfHEIry3v9CuLX4 bPeQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=HWqxM4GZuS9Wh/EiDlklJiCP+B1QvwXEzK3M+6mNoD4=; fh=5+N04gRSPePUqluqfduu8DOblzhzIFc1MLjMCIFd4Tc=; b=y8HHt29xBHRaY14JyjEjD+pF5Q8efGDJIL54IO9l3uGaeQrquL1i55A07IA9ZnqzEC 055PFC8L+reDEFQS94EF607HW7U4Wn3WKIS00/29dL4NelNQjamZGuE03Qc9exx2dxpR h6CeX7anUnHCPR5pqKykJqaooEKAC11sbpKVgWPetf/vE6Rr/NtD2LoEVSKbdkiDcE0B DycWlfZIAa7SHgS0Lvl0nco825ms9c6VhL/Je4wFDfE3sJfYgwa5pduBycyVEO1x3F0c ND5yMxElxhQAtFe6Hd4CtOuCl2pwWAhpB2qZ2c85OYjjlsoRuJtTZ9/cdtGX9u2hfcUr lkgw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Ed+RF3na; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u35-20020a634563000000b0055ae207577csi1762086pgk.650.2023.07.06.09.08.17; Thu, 06 Jul 2023 09:08:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Ed+RF3na; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233329AbjGFPtv (ORCPT + 99 others); Thu, 6 Jul 2023 11:49:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47192 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233168AbjGFPtX (ORCPT ); Thu, 6 Jul 2023 11:49:23 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 410351FC2 for ; Thu, 6 Jul 2023 08:48:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1688658499; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HWqxM4GZuS9Wh/EiDlklJiCP+B1QvwXEzK3M+6mNoD4=; b=Ed+RF3na85vXz8tODkTnngSpTG2Ow96sVwRB/Dl7e6rMkb4UjhRVjSiLWdVX5lsc/EcxZ+ i7Z87CAM23Gzm6tSI3cGqdG3QD0PcLnE4RzPS632Xo1YXbF4o1B3J7c8xb+gLxtPrUJ4Fy jwM6huX1NuITnWenPz6WTDgV0s1r17M= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-132-UuzblcGlOgKAFhNrs83w1g-1; Thu, 06 Jul 2023 11:48:15 -0400 X-MC-Unique: UuzblcGlOgKAFhNrs83w1g-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C74BE2815E25; Thu, 6 Jul 2023 15:48:14 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-39.pek2.redhat.com [10.72.12.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9200EF6401; Thu, 6 Jul 2023 15:48:05 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: akpm@linux-foundation.org, linux-mm@kvack.org, arnd@arndb.de, hch@lst.de, christophe.leroy@csgroup.eu, rppt@kernel.org, willy@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, shorne@gmail.com, David.Laight@ACULAB.COM, deller@gmx.de, nathan@kernel.org, glaubitz@physik.fu-berlin.de, Baoquan He , Michael Ellerman , Nicholas Piggin , linuxppc-dev@lists.ozlabs.org Subject: [PATCH v8 17/19] powerpc: mm: Convert to GENERIC_IOREMAP Date: Thu, 6 Jul 2023 23:45:18 +0800 Message-Id: <20230706154520.11257-18-bhe@redhat.com> In-Reply-To: <20230706154520.11257-1-bhe@redhat.com> References: <20230706154520.11257-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770688051605484432?= X-GMAIL-MSGID: =?utf-8?q?1770688051605484432?= From: Christophe Leroy By taking GENERIC_IOREMAP method, the generic generic_ioremap_prot(), generic_iounmap(), and their generic wrapper ioremap_prot(), ioremap() and iounmap() are all visible and available to arch. Arch needs to provide wrapper functions to override the generic versions if there's arch specific handling in its ioremap_prot(), ioremap() or iounmap(). This change will simplify implementation by removing duplicated code with generic_ioremap_prot() and generic_iounmap(), and has the equivalent functioality as before. Here, add wrapper functions ioremap_prot() and iounmap() for powerpc's special operation when ioremap() and iounmap(). Signed-off-by: Christophe Leroy Signed-off-by: Baoquan He Reviewed-by: Christoph Hellwig Reviewed-by: Mike Rapoport (IBM) Cc: Michael Ellerman Cc: Nicholas Piggin Cc: linuxppc-dev@lists.ozlabs.org --- arch/powerpc/Kconfig | 1 + arch/powerpc/include/asm/io.h | 8 +++----- arch/powerpc/mm/ioremap.c | 26 +------------------------- arch/powerpc/mm/ioremap_32.c | 19 +++++++++---------- arch/powerpc/mm/ioremap_64.c | 12 ++---------- 5 files changed, 16 insertions(+), 50 deletions(-) diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index 0b1172cbeccb..9222c138c457 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig @@ -193,6 +193,7 @@ config PPC select GENERIC_CPU_VULNERABILITIES if PPC_BARRIER_NOSPEC select GENERIC_EARLY_IOREMAP select GENERIC_GETTIMEOFDAY + select GENERIC_IOREMAP select GENERIC_IRQ_SHOW select GENERIC_IRQ_SHOW_LEVEL select GENERIC_PCI_IOMAP if PCI diff --git a/arch/powerpc/include/asm/io.h b/arch/powerpc/include/asm/io.h index 67a3fb6de498..0732b743e099 100644 --- a/arch/powerpc/include/asm/io.h +++ b/arch/powerpc/include/asm/io.h @@ -889,8 +889,8 @@ static inline void iosync(void) * */ extern void __iomem *ioremap(phys_addr_t address, unsigned long size); -extern void __iomem *ioremap_prot(phys_addr_t address, unsigned long size, - unsigned long flags); +#define ioremap ioremap +#define ioremap_prot ioremap_prot extern void __iomem *ioremap_wc(phys_addr_t address, unsigned long size); #define ioremap_wc ioremap_wc @@ -904,14 +904,12 @@ void __iomem *ioremap_coherent(phys_addr_t address, unsigned long size); #define ioremap_cache(addr, size) \ ioremap_prot((addr), (size), pgprot_val(PAGE_KERNEL)) -extern void iounmap(volatile void __iomem *addr); +#define iounmap iounmap void __iomem *ioremap_phb(phys_addr_t paddr, unsigned long size); int early_ioremap_range(unsigned long ea, phys_addr_t pa, unsigned long size, pgprot_t prot); -void __iomem *do_ioremap(phys_addr_t pa, phys_addr_t offset, unsigned long size, - pgprot_t prot, void *caller); extern void __iomem *__ioremap_caller(phys_addr_t, unsigned long size, pgprot_t prot, void *caller); diff --git a/arch/powerpc/mm/ioremap.c b/arch/powerpc/mm/ioremap.c index 4f12504fb405..705e8e8ffde4 100644 --- a/arch/powerpc/mm/ioremap.c +++ b/arch/powerpc/mm/ioremap.c @@ -41,7 +41,7 @@ void __iomem *ioremap_coherent(phys_addr_t addr, unsigned long size) return __ioremap_caller(addr, size, prot, caller); } -void __iomem *ioremap_prot(phys_addr_t addr, unsigned long size, unsigned long flags) +void __iomem *ioremap_prot(phys_addr_t addr, size_t size, unsigned long flags) { pte_t pte = __pte(flags); void *caller = __builtin_return_address(0); @@ -74,27 +74,3 @@ int early_ioremap_range(unsigned long ea, phys_addr_t pa, return 0; } - -void __iomem *do_ioremap(phys_addr_t pa, phys_addr_t offset, unsigned long size, - pgprot_t prot, void *caller) -{ - struct vm_struct *area; - int ret; - unsigned long va; - - area = __get_vm_area_caller(size, VM_IOREMAP, IOREMAP_START, IOREMAP_END, caller); - if (area == NULL) - return NULL; - - area->phys_addr = pa; - va = (unsigned long)area->addr; - - ret = ioremap_page_range(va, va + size, pa, prot); - if (!ret) - return (void __iomem *)area->addr + offset; - - vunmap_range(va, va + size); - free_vm_area(area); - - return NULL; -} diff --git a/arch/powerpc/mm/ioremap_32.c b/arch/powerpc/mm/ioremap_32.c index 9d13143b8be4..ca5bc6be3e6f 100644 --- a/arch/powerpc/mm/ioremap_32.c +++ b/arch/powerpc/mm/ioremap_32.c @@ -21,6 +21,13 @@ __ioremap_caller(phys_addr_t addr, unsigned long size, pgprot_t prot, void *call phys_addr_t p, offset; int err; + /* + * If the address lies within the first 16 MB, assume it's in ISA + * memory space + */ + if (addr < SZ_16M) + addr += _ISA_MEM_BASE; + /* * Choose an address to map it to. * Once the vmalloc system is running, we use it. @@ -31,13 +38,6 @@ __ioremap_caller(phys_addr_t addr, unsigned long size, pgprot_t prot, void *call offset = addr & ~PAGE_MASK; size = PAGE_ALIGN(addr + size) - p; - /* - * If the address lies within the first 16 MB, assume it's in ISA - * memory space - */ - if (p < 16 * 1024 * 1024) - p += _ISA_MEM_BASE; - #ifndef CONFIG_CRASH_DUMP /* * Don't allow anybody to remap normal RAM that we're using. @@ -63,7 +63,7 @@ __ioremap_caller(phys_addr_t addr, unsigned long size, pgprot_t prot, void *call return (void __iomem *)v + offset; if (slab_is_available()) - return do_ioremap(p, offset, size, prot, caller); + return generic_ioremap_prot(addr, size, prot); /* * Should check if it is a candidate for a BAT mapping @@ -87,7 +87,6 @@ void iounmap(volatile void __iomem *addr) if (v_block_mapped((unsigned long)addr)) return; - if (addr > high_memory && (unsigned long)addr < ioremap_bot) - vunmap((void *)(PAGE_MASK & (unsigned long)addr)); + generic_iounmap(addr); } EXPORT_SYMBOL(iounmap); diff --git a/arch/powerpc/mm/ioremap_64.c b/arch/powerpc/mm/ioremap_64.c index 3acece00b33e..d24e5f166723 100644 --- a/arch/powerpc/mm/ioremap_64.c +++ b/arch/powerpc/mm/ioremap_64.c @@ -29,7 +29,7 @@ void __iomem *__ioremap_caller(phys_addr_t addr, unsigned long size, return NULL; if (slab_is_available()) - return do_ioremap(paligned, offset, size, prot, caller); + return generic_ioremap_prot(addr, size, prot); pr_warn("ioremap() called early from %pS. Use early_ioremap() instead\n", caller); @@ -49,17 +49,9 @@ void __iomem *__ioremap_caller(phys_addr_t addr, unsigned long size, */ void iounmap(volatile void __iomem *token) { - void *addr; - if (!slab_is_available()) return; - addr = (void *)((unsigned long __force)PCI_FIX_ADDR(token) & PAGE_MASK); - - if ((unsigned long)addr < ioremap_bot) { - pr_warn("Attempt to iounmap early bolted mapping at 0x%p\n", addr); - return; - } - vunmap(addr); + generic_iounmap(PCI_FIX_ADDR(token)); } EXPORT_SYMBOL(iounmap); From patchwork Thu Jul 6 15:45:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 116776 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp2656911vqx; Thu, 6 Jul 2023 08:51:19 -0700 (PDT) X-Google-Smtp-Source: APBJJlHv5A1/bGrMhUUgJG2ePLEUOIdkj3UPrwVliBq1TAKuXK3w6K/9YvxKlE7vD1HYvLB7DIBw X-Received: by 2002:a17:902:ecc1:b0:1b6:a37a:65b7 with SMTP id a1-20020a170902ecc100b001b6a37a65b7mr9097623plh.23.1688658678666; Thu, 06 Jul 2023 08:51:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688658678; cv=none; d=google.com; s=arc-20160816; b=CdOpETlqjpAX+9eommJbcElUsl8hfwzxzVB5sR4LSsW3xM99NGGAl7gqGged8HFgBc b2fPOA00nxXpn9vif+tzaXKentvePqKLAN3GuSElu8IeqLPOdK5plW5mH+IQjE3Bf+7n F6ZczHVeT1aFDggHn2YRrMdjyZ9KbO9nWy5OUbmNF3PgegUvgjK12On09kHT3TVjDYSR 6v3syWdRTd8VZp3HlIKXywDx0xV75RCyLAdteK/NKPuX8tDuqyKraR4Mt6rHrF9Tnuoh Ma/NwvOFFZWh53MMFt3NXEO5OYnuYDE+FJYT87pUYlv7+2W3qRlgjWXhKWZfXSkuMFRB 3IpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ufnbHw3CFVXR+TCLfdbzkgDAqTOwnZtETnnpIP+Ntq0=; fh=thKCWSszaxV4iUnX5NXNFwuEEAZRmqK090QLhI33OJc=; b=pXcdsQWA/QomEQ9uoMXbdl066zrCo1nazDguMAIEPeD8jBIX5F9wEfrHWOjR7KQMXj 4G53kXn7l2EMtWYTkclM5khgk1F6oBgmR+CdBc+NIKSU/6XJlt50gaeZnKrr+3ojJfV/ OMfwTORq+1RcBlBriOPcv2+zt+eX8ej0Xsd8keR78k7wH+TFNlBqrCHXZJL5aOctxEFA bfEVmIFnzjNe7wDL/4ZG0JAxoUvqGgiLWQsYzpWFd3oBTXS6a6QG8KzTLJu+KQkMDGs0 EMdTxh1tdXtlE2Rl3JoUKCRISkMZEUl19ARKghvcR0uHHL4WxpvrtGR3BZq3tCfYIOCV n7VQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=gQ4T53wA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z2-20020a1709027e8200b001b8c47563e7si1292548pla.28.2023.07.06.08.51.05; Thu, 06 Jul 2023 08:51:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=gQ4T53wA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233406AbjGFPuA (ORCPT + 99 others); Thu, 6 Jul 2023 11:50:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45456 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232865AbjGFPt3 (ORCPT ); Thu, 6 Jul 2023 11:49:29 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 48E2626A2 for ; Thu, 6 Jul 2023 08:48:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1688658515; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ufnbHw3CFVXR+TCLfdbzkgDAqTOwnZtETnnpIP+Ntq0=; b=gQ4T53wAhScScy+R2kitWNiUeremIyJ+YlEdm1ktq3Z2l+5ccFkoAkFjJKlTMQX44ahT8o mXaFNS1FFi5DZ3gNK6WHERin6sAyIMzngu01Pl8uKUaZgqWx54snc+isK/Qq4HdCkXIEAC 8zZ8x2NdKi376tD3l9qhdUxV9jRemSU= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-466--F65NclnMjCNxuCBTdT-Kg-1; Thu, 06 Jul 2023 11:48:25 -0400 X-MC-Unique: -F65NclnMjCNxuCBTdT-Kg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 723012815E3A; Thu, 6 Jul 2023 15:48:24 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-39.pek2.redhat.com [10.72.12.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id 99A41F5CF0; Thu, 6 Jul 2023 15:48:15 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: akpm@linux-foundation.org, linux-mm@kvack.org, arnd@arndb.de, hch@lst.de, christophe.leroy@csgroup.eu, rppt@kernel.org, willy@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, shorne@gmail.com, David.Laight@ACULAB.COM, deller@gmx.de, nathan@kernel.org, glaubitz@physik.fu-berlin.de, Baoquan He , Catalin Marinas , Will Deacon , linux-arm-kernel@lists.infradead.org Subject: [PATCH v8 18/19] arm64 : mm: add wrapper function ioremap_prot() Date: Thu, 6 Jul 2023 23:45:19 +0800 Message-Id: <20230706154520.11257-19-bhe@redhat.com> In-Reply-To: <20230706154520.11257-1-bhe@redhat.com> References: <20230706154520.11257-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770686962594267130?= X-GMAIL-MSGID: =?utf-8?q?1770686962594267130?= Since hook functions ioremap_allowed() and iounmap_allowed() will be obsoleted, add wrapper function ioremap_prot() to contain the the specific handling in addition to generic_ioremap_prot() invocation. Signed-off-by: Baoquan He Reviewed-by: Christoph Hellwig Reviewed-by: Kefeng Wang Reviewed-by: Mike Rapoport (IBM) Acked-by: Catalin Marinas Cc: Catalin Marinas Cc: Will Deacon Cc: linux-arm-kernel@lists.infradead.org --- arch/arm64/include/asm/io.h | 3 +-- arch/arm64/mm/ioremap.c | 10 ++++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/arch/arm64/include/asm/io.h b/arch/arm64/include/asm/io.h index 51d92abf945e..3b694511b98f 100644 --- a/arch/arm64/include/asm/io.h +++ b/arch/arm64/include/asm/io.h @@ -139,8 +139,7 @@ extern void __memset_io(volatile void __iomem *, int, size_t); * I/O memory mapping functions. */ -bool ioremap_allowed(phys_addr_t phys_addr, size_t size, unsigned long prot); -#define ioremap_allowed ioremap_allowed +#define ioremap_prot ioremap_prot #define _PAGE_IOREMAP PROT_DEVICE_nGnRE diff --git a/arch/arm64/mm/ioremap.c b/arch/arm64/mm/ioremap.c index c5af103d4ad4..269f2f63ab7d 100644 --- a/arch/arm64/mm/ioremap.c +++ b/arch/arm64/mm/ioremap.c @@ -3,20 +3,22 @@ #include #include -bool ioremap_allowed(phys_addr_t phys_addr, size_t size, unsigned long prot) +void __iomem *ioremap_prot(phys_addr_t phys_addr, size_t size, + unsigned long prot) { unsigned long last_addr = phys_addr + size - 1; /* Don't allow outside PHYS_MASK */ if (last_addr & ~PHYS_MASK) - return false; + return NULL; /* Don't allow RAM to be mapped. */ if (WARN_ON(pfn_is_map_memory(__phys_to_pfn(phys_addr)))) - return false; + return NULL; - return true; + return generic_ioremap_prot(phys_addr, size, __pgprot(prot)); } +EXPORT_SYMBOL(ioremap_prot); /* * Must be called after early_fixmap_init From patchwork Thu Jul 6 15:45:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 116793 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp2674698vqx; Thu, 6 Jul 2023 09:16:47 -0700 (PDT) X-Google-Smtp-Source: APBJJlHo6bTzeykPJ5x3JDBEeM+u6/jVcI0nJWXpjjFERu9bEXDR43vhragXIQuMC/f53I66ku/F X-Received: by 2002:a17:903:41c6:b0:1b2:1a79:147d with SMTP id u6-20020a17090341c600b001b21a79147dmr2937519ple.2.1688660207541; Thu, 06 Jul 2023 09:16:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688660207; cv=none; d=google.com; s=arc-20160816; b=Qxsty7UP735JDVRR9s9vlei6SjX33vOT8bTdZYD6WV+7o7E9bEWN1VaEU67jfcjTLM VKVU5Qq7NkgcCw7JDzsq2BwMVDnSfHtT9ZU+7qmfdGRcK3dzSyhrihiyAPyA1PMxIimT MpMTtDWO6mX24aJhKrTBhqAAAwYANOsEoq4+q+4TQDU+U5i/a9r0PpIHpqHJa3Ttz7iA 7dIWXBU85KxIpcNNk7+lA+4xBbWitivqyRcxfS9BdqXX5Zmna8Jhu8yNt/eSO20CrJzT aD4d+c2sH4PxCeVjFMSUoUmG9bq7ZrDcTR2elxku2GkDXC6CeqZeB1aovuuNLtQn4xDF nXqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=keQ78Mv/VCFMjxLJbgEgr2h/sjN0UpPUn6QsvR3JRNU=; fh=MRqAqm0/X6LLHlLdJym4NBXwcTEGRfSmsWs7mgX78Dg=; b=TywLOssMMbTI/EziCgGwXFLQOu3YDeEmS6Uvhl2I6s6NSGzJ3JY3HISRdm6OX4L3sn QSAkMe8VnYQLt+PEcNgqlw1coDfX8TCQ33nSME9zMExLm3YKGJrOZMuRFc84nskgK/6h oTtTU0heomGE1ZIQ6IBpnE7NBPvTpvNTRSrHDRwkXJMD1U6yKHQTyVf2LJB7y1WkLRMU F4Ktw1gFKMD6LngTF+nuyP6OICy4XWcQgKGYADEjN4erNZJggqOgFVSfcbW7HxSXi4wK dhE315tk7P0+PJItZzocQ2trYUXHKfSa/IkOYMWLg5sCMv1pBxhXRfQ/+wqdUgynzdAA Z+VQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ZayEjbbt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e16-20020a17090301d000b001b8c6890612si1154584plh.594.2023.07.06.09.16.32; Thu, 06 Jul 2023 09:16:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ZayEjbbt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232865AbjGFPuY (ORCPT + 99 others); Thu, 6 Jul 2023 11:50:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46374 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233194AbjGFPty (ORCPT ); Thu, 6 Jul 2023 11:49:54 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1A3052718 for ; Thu, 6 Jul 2023 08:48:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1688658519; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=keQ78Mv/VCFMjxLJbgEgr2h/sjN0UpPUn6QsvR3JRNU=; b=ZayEjbbtLA/Yh0N09UgzP8zv3i8GCx9TGSJhLA3XlsPeufPOqgazsUih03XORVq1fU10tz QP6xJ8ySQjxKeS7/Ldno4dpyEd+E895zcY5Ubf3+MJe6qoPHVW0rY7r24FajBOPPuMo3dJ 8pzMvrfsWA+y2fWUSPdWp5lzmLnTswk= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-592-vcwacN9DPj2Dhag0q5VkVA-1; Thu, 06 Jul 2023 11:48:34 -0400 X-MC-Unique: vcwacN9DPj2Dhag0q5VkVA-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0BBB9881B27; Thu, 6 Jul 2023 15:48:33 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-39.pek2.redhat.com [10.72.12.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id 42160F5CF0; Thu, 6 Jul 2023 15:48:24 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: akpm@linux-foundation.org, linux-mm@kvack.org, arnd@arndb.de, hch@lst.de, christophe.leroy@csgroup.eu, rppt@kernel.org, willy@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, shorne@gmail.com, David.Laight@ACULAB.COM, deller@gmx.de, nathan@kernel.org, glaubitz@physik.fu-berlin.de, Baoquan He Subject: [PATCH v8 19/19] mm: ioremap: remove unneeded ioremap_allowed and iounmap_allowed Date: Thu, 6 Jul 2023 23:45:20 +0800 Message-Id: <20230706154520.11257-20-bhe@redhat.com> In-Reply-To: <20230706154520.11257-1-bhe@redhat.com> References: <20230706154520.11257-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, TVD_SUBJ_WIPE_DEBT,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770688565772566655?= X-GMAIL-MSGID: =?utf-8?q?1770688565772566655?= Now there are no users of ioremap_allowed and iounmap_allowed, clean them up. Signed-off-by: Baoquan He Reviewed-by: Christoph Hellwig Reviewed-by: Kefeng Wang Reviewed-by: Mike Rapoport (IBM) --- include/asm-generic/io.h | 26 -------------------------- mm/ioremap.c | 6 ------ 2 files changed, 32 deletions(-) diff --git a/include/asm-generic/io.h b/include/asm-generic/io.h index 39244c3ee797..bac63e874c7b 100644 --- a/include/asm-generic/io.h +++ b/include/asm-generic/io.h @@ -1047,32 +1047,6 @@ static inline void iounmap(volatile void __iomem *addr) #elif defined(CONFIG_GENERIC_IOREMAP) #include -/* - * Arch code can implement the following two hooks when using GENERIC_IOREMAP - * ioremap_allowed() return a bool, - * - true means continue to remap - * - false means skip remap and return directly - * iounmap_allowed() return a bool, - * - true means continue to vunmap - * - false means skip vunmap and return directly - */ -#ifndef ioremap_allowed -#define ioremap_allowed ioremap_allowed -static inline bool ioremap_allowed(phys_addr_t phys_addr, size_t size, - unsigned long prot) -{ - return true; -} -#endif - -#ifndef iounmap_allowed -#define iounmap_allowed iounmap_allowed -static inline bool iounmap_allowed(void *addr) -{ - return true; -} -#endif - void __iomem *generic_ioremap_prot(phys_addr_t phys_addr, size_t size, pgprot_t prot); diff --git a/mm/ioremap.c b/mm/ioremap.c index a21a6c9fa5ab..3e049dfb28bd 100644 --- a/mm/ioremap.c +++ b/mm/ioremap.c @@ -33,9 +33,6 @@ void __iomem *generic_ioremap_prot(phys_addr_t phys_addr, size_t size, phys_addr -= offset; size = PAGE_ALIGN(size + offset); - if (!ioremap_allowed(phys_addr, size, pgprot_val(prot))) - return NULL; - area = __get_vm_area_caller(size, VM_IOREMAP, IOREMAP_START, IOREMAP_END, __builtin_return_address(0)); if (!area) @@ -64,9 +61,6 @@ void generic_iounmap(volatile void __iomem *addr) { void *vaddr = (void *)((unsigned long)addr & PAGE_MASK); - if (!iounmap_allowed(vaddr)) - return; - if (is_ioremap_addr(vaddr)) vunmap(vaddr); }