Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp7816323rwd; Tue, 20 Jun 2023 06:40:37 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6JbVTw5J6jXBSNBKcMqE8dAwn2c6/yEs8W7VTsJZyf1QOmGwRVTNG+XgIAg5r/Lr+XN76b X-Received: by 2002:a92:de08:0:b0:342:28f1:75ae with SMTP id x8-20020a92de08000000b0034228f175aemr8682380ilm.12.1687268436936; Tue, 20 Jun 2023 06:40:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687268436; cv=none; d=google.com; s=arc-20160816; b=KCciIpCOJhdNOCxMHPPpSY2V2Q7ixZXcIFol/pocv9LZn5fraidoIdJxkG1MvExR1+ 2Y3mFiEM3mjSludBtX2ULACj/aW46szYy+t19/TVUIi0waOMBK4JBIxFigcttbjC9e9g 2xS7z/vfR22USRofHi+/O5EtARHt84oPnW+y07gxAdUAvlezo7n4T7HBdETwKolk0rdA ixdNdtoSwYdWZRvnA8R+5QOiQupnTaG22eyj3RhQ8j9A2/Er3EpEquNR8ckDKHeer285 5VnPYMjkcEI1Q3e7SO61twEQXa+XFYbAj7SN2WldzoZcSmdbbdcrVq5AJ02kg0SgrBMJ 2hkg== 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=a8YWy6B/dkgubJEAfONkbnYrM9N6ISZoYICTMz8lkkw=; b=m91zeX7Q7WOC5wLHV1HV7nUd1Dh4yRwuakanFiJsODicvE5vhNg1hTBNX21M5pZwo6 wc3pUjoZ2Nf6cC766bZXUV5X3i/0TBkimKfxiNjGUwTfPekFsEImcfcS+a8v/iOkCUDn sx6aSuhGuhNmv9V5g+3dO6NZcT11fSPnm+uCj1jF25iDZld+7FupJYEaoq4LQE//2dM2 j5fztTHpbVXACb5TnnHYXxkc1aCI3VTJQFyrwWJK+jxooxiT2UeEwC2RLLF7H3gz0P5Z 5OLg2ZZmtYm+u2BaD90/OIywfG8A0efQZribt/2Od3cCe6PoIF7cLLekt8xSNsi96Lnc fWmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=WC3rQd2L; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p19-20020a637413000000b0054ff0049d08si1739800pgc.404.2023.06.20.06.40.22; Tue, 20 Jun 2023 06:40:36 -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=WC3rQd2L; 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 S232732AbjFTNTg (ORCPT + 99 others); Tue, 20 Jun 2023 09:19:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48908 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232887AbjFTNSr (ORCPT ); Tue, 20 Jun 2023 09:18: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 200401731 for ; Tue, 20 Jun 2023 06:17:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687267048; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=a8YWy6B/dkgubJEAfONkbnYrM9N6ISZoYICTMz8lkkw=; b=WC3rQd2LG5lcw6cjBkYFBXfeBUjW/+/XU/MAhZdPVDXMLsil2E1Hd3/2wq4/qz5y/5mGeH K++ev5hx1oXrw5T8Ijth4keZamuz5XDSSW16rpNMa+OJTwzKAY2Zs9+gr3mQE9Irxa4gx6 U/60b1TN/l14PiGRha6dWj3kPDGtYNI= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-445-ez00HCYEMsyDPHbeiCsRCQ-1; Tue, 20 Jun 2023 09:17:24 -0400 X-MC-Unique: ez00HCYEMsyDPHbeiCsRCQ-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 729AE1039D34; Tue, 20 Jun 2023 13:16:42 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-166.pek2.redhat.com [10.72.12.166]) by smtp.corp.redhat.com (Postfix) with ESMTP id 906A4C1ED96; Tue, 20 Jun 2023 13:16:33 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-arch@vger.kernel.org, linux-mm@kvack.org, arnd@arndb.de, hch@lst.de, christophe.leroy@csgroup.eu, rppt@kernel.org, willy@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, David.Laight@ACULAB.COM, shorne@gmail.com, deller@gmx.de, nathan@kernel.org, glaubitz@physik.fu-berlin.de, Baoquan He Subject: [PATCH v7 16/19] mm: move is_ioremap_addr() into new header file Date: Tue, 20 Jun 2023 21:13:53 +0800 Message-Id: <20230620131356.25440-17-bhe@redhat.com> In-Reply-To: <20230620131356.25440-1-bhe@redhat.com> References: <20230620131356.25440-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 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, 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 Now is_ioremap_addr() is only used in kernel/iomem.c and gonna be used in mm/ioremap.c. Move it into its own new header file linux/ioremap.h. Signed-off-by: Baoquan He Suggested-by: Christoph Hellwig Reviewed-by: Christoph Hellwig --- arch/powerpc/include/asm/pgtable.h | 8 -------- include/linux/ioremap.h | 30 ++++++++++++++++++++++++++++++ include/linux/mm.h | 5 ----- kernel/iomem.c | 1 + mm/ioremap.c | 10 +--------- 5 files changed, 32 insertions(+), 22 deletions(-) create mode 100644 include/linux/ioremap.h diff --git a/arch/powerpc/include/asm/pgtable.h b/arch/powerpc/include/asm/pgtable.h index 9972626ddaf6..d252323a753f 100644 --- a/arch/powerpc/include/asm/pgtable.h +++ b/arch/powerpc/include/asm/pgtable.h @@ -158,14 +158,6 @@ static inline pgtable_t pmd_pgtable(pmd_t pmd) } #ifdef CONFIG_PPC64 -#define is_ioremap_addr is_ioremap_addr -static inline bool is_ioremap_addr(const void *x) -{ - unsigned long addr = (unsigned long)x; - - return addr >= IOREMAP_BASE && addr < IOREMAP_END; -} - struct seq_file; void arch_report_meminfo(struct seq_file *m); #endif /* CONFIG_PPC64 */ diff --git a/include/linux/ioremap.h b/include/linux/ioremap.h new file mode 100644 index 000000000000..f0e99fc7dd8b --- /dev/null +++ b/include/linux/ioremap.h @@ -0,0 +1,30 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _LINUX_IOREMAP_H +#define _LINUX_IOREMAP_H + +#include +#include + +#if defined(CONFIG_HAS_IOMEM) || defined(CONFIG_GENERIC_IOREMAP) +/* + * Ioremap often, but not always uses the generic vmalloc area. E.g on + * Power ARCH, it could have different ioremap space. + */ +#ifndef IOREMAP_START +#define IOREMAP_START VMALLOC_START +#define IOREMAP_END VMALLOC_END +#endif +static inline bool is_ioremap_addr(const void *x) +{ + unsigned long addr = (unsigned long)kasan_reset_tag(x); + + return addr >= IOREMAP_START && addr < IOREMAP_END; +} +#else +static inline bool is_ioremap_addr(const void *x) +{ + return false; +} +#endif + +#endif /* _LINUX_IOREMAP_H */ diff --git a/include/linux/mm.h b/include/linux/mm.h index 27ce77080c79..7379f19768b4 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -1041,11 +1041,6 @@ unsigned long vmalloc_to_pfn(const void *addr); * On nommu, vmalloc/vfree wrap through kmalloc/kfree directly, so there * is no special casing required. */ - -#ifndef is_ioremap_addr -#define is_ioremap_addr(x) is_vmalloc_addr(x) -#endif - #ifdef CONFIG_MMU extern bool is_vmalloc_addr(const void *x); extern int is_vmalloc_or_module_addr(const void *x); diff --git a/kernel/iomem.c b/kernel/iomem.c index 62c92e43aa0d..9682471e6471 100644 --- a/kernel/iomem.c +++ b/kernel/iomem.c @@ -3,6 +3,7 @@ #include #include #include +#include #ifndef ioremap_cache /* temporary while we convert existing ioremap_cache users to memremap */ diff --git a/mm/ioremap.c b/mm/ioremap.c index 68d9895144ad..a21a6c9fa5ab 100644 --- a/mm/ioremap.c +++ b/mm/ioremap.c @@ -10,15 +10,7 @@ #include #include #include - -/* - * Ioremap often, but not always uses the generic vmalloc area. E.g on - * Power ARCH, it could have different ioremap space. - */ -#ifndef IOREMAP_START -#define IOREMAP_START VMALLOC_START -#define IOREMAP_END VMALLOC_END -#endif +#include void __iomem *generic_ioremap_prot(phys_addr_t phys_addr, size_t size, pgprot_t prot) -- 2.34.1