From patchwork Fri Jun 9 07:55: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: 105347 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp782078vqr; Fri, 9 Jun 2023 01:00:39 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4DryIkmSw2ASIFpCS5WTSmVoenqVeAgTp50dTF89hko9f8KQioUcxJqV36DGnOGeQjwkPW X-Received: by 2002:a17:90b:4c10:b0:259:dd60:d90e with SMTP id na16-20020a17090b4c1000b00259dd60d90emr647532pjb.20.1686297639001; Fri, 09 Jun 2023 01:00:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686297638; cv=none; d=google.com; s=arc-20160816; b=MN6waX8ZXGl17S4yzWPVGWAmicemMRVkCr7LOiElfCYhNzrDryi4kZeciUwkifQV89 MObRD5EzCa9Il5eM4QHMXwc1X3vtRVmJCTucDtRMohWn/K7Odutgby70lpdloMeFJ4uu ibcuKhS2S++KKMou4n3hqsmLY/Adwtv3ieGJdfF01aL7zWw3vsXu2CyOXj6XxFHopY26 Xj+mUmdLw5gHejqHtk1ZAyWcankU0X/qxpEglZfyXdCiM/QyCiEMCKBuRkuCrKpXvvrR S5EWlwA1yx1esDclUfgTlPM5Im4hXv98GVsukWlzaQf3C/EXWMlxlX8k9J8jyPZBgpjH KCog== 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=r3g4ZP9oM4r19WBz6/w6ckLHluvVzIZl/J+34OobsOk=; b=f01xByncuNOLs03lXpuhKgZGShRxP03q/kBMhnkjz09uIAzmtG5VwmT0J+tIjt0eq/ 4Ss7V3Yx/8EnTMLrHYwmDS+Sl1gijRCyMi285rWRxTf8S1BE+dRQhhvvBsc+55+F9ih6 uZ4utjBsA5EUB+r6nxEoVRLlJPP7IvJ3BjGyWiSaEAtByHqV9MEt3XVd6Ux01GOhifhM yW7+IP8XDjmD8+2qRCuvDiuXfXyxNsq7bcP4LV81QRlhrEELb/LUiH6FXUd3TtWolp3f sFIJw8O91SWN+lpPrVed3s6ECEC8uq4nWoC3yTKwQyqwa6HJjvo5xuIK2A7Q0UdQa7tm 5oMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="hmcbE/kv"; 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 np17-20020a17090b4c5100b002475bc0a186si4042670pjb.69.2023.06.09.01.00.26; Fri, 09 Jun 2023 01:00:38 -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="hmcbE/kv"; 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 S239118AbjFIH50 (ORCPT + 99 others); Fri, 9 Jun 2023 03:57:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34166 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230062AbjFIH5O (ORCPT ); Fri, 9 Jun 2023 03:57:14 -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 7CC1F4208 for ; Fri, 9 Jun 2023 00:56:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686297350; 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=r3g4ZP9oM4r19WBz6/w6ckLHluvVzIZl/J+34OobsOk=; b=hmcbE/kvDethtAP8U2xJ2gGQkqa2qGccCQ0yOH36dqXDd0o3Kjbw+134B+h/mc5Hl7dzLS s3gKEuwHMd/Av6jNrXPCxIhCB2bcMnoWwjeDx8PIe9EBFBhhe4yn2YKO1pnmH1nrZXAT1Y N3Zug0+jkiReOWX0KbEx34qOaIouonA= 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-475-fy6Y5YnIOTejxLrYBdqUWQ-1; Fri, 09 Jun 2023 03:55:46 -0400 X-MC-Unique: fy6Y5YnIOTejxLrYBdqUWQ-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8EB6A858EEC; Fri, 9 Jun 2023 07:55:45 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-92.pek2.redhat.com [10.72.12.92]) by smtp.corp.redhat.com (Postfix) with ESMTP id B776D20268C7; Fri, 9 Jun 2023 07:55:39 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-arch@vger.kernel.org, linux-mm@kvack.org, arnd@arndb.de, christophe.leroy@csgroup.eu, hch@lst.de, 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, Baoquan He , Geert Uytterhoeven Subject: [PATCH v6 01/19] asm-generic/iomap.h: remove ARCH_HAS_IOREMAP_xx macros Date: Fri, 9 Jun 2023 15:55:10 +0800 Message-Id: <20230609075528.9390-2-bhe@redhat.com> In-Reply-To: <20230609075528.9390-1-bhe@redhat.com> References: <20230609075528.9390-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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=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?1768211233032058277?= X-GMAIL-MSGID: =?utf-8?q?1768211233032058277?= 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 --- v5->v6: Remove stale sentence in log - Mike. arch/loongarch/include/asm/io.h | 2 -- arch/m68k/include/asm/io_mm.h | 2 -- arch/m68k/include/asm/kmap.h | 2 -- arch/mips/include/asm/io.h | 5 ++--- arch/powerpc/include/asm/io.h | 9 +-------- arch/x86/include/asm/io.h | 5 ----- drivers/net/ethernet/sfc/io.h | 2 +- drivers/net/ethernet/sfc/siena/io.h | 2 +- include/asm-generic/iomap.h | 6 +++--- 9 files changed, 8 insertions(+), 27 deletions(-) diff --git a/arch/loongarch/include/asm/io.h b/arch/loongarch/include/asm/io.h index 545e2708fbf7..5fef1246c6fb 100644 --- a/arch/loongarch/include/asm/io.h +++ b/arch/loongarch/include/asm/io.h @@ -5,8 +5,6 @@ #ifndef _ASM_IO_H #define _ASM_IO_H -#define ARCH_HAS_IOREMAP_WC - #include #include diff --git a/arch/m68k/include/asm/io_mm.h b/arch/m68k/include/asm/io_mm.h index d41fa488453b..6a0abd4846c6 100644 --- a/arch/m68k/include/asm/io_mm.h +++ b/arch/m68k/include/asm/io_mm.h @@ -26,8 +26,6 @@ #include #include -#include - #ifdef CONFIG_ATARI #define atari_readb raw_inb #define atari_writeb raw_outb diff --git a/arch/m68k/include/asm/kmap.h b/arch/m68k/include/asm/kmap.h index dec05743d426..4efb3efa593a 100644 --- a/arch/m68k/include/asm/kmap.h +++ b/arch/m68k/include/asm/kmap.h @@ -4,8 +4,6 @@ #ifdef CONFIG_MMU -#define ARCH_HAS_IOREMAP_WT - /* Values for nocacheflag and cmode */ #define IOMAP_FULL_CACHING 0 #define IOMAP_NOCACHE_SER 1 diff --git a/arch/mips/include/asm/io.h b/arch/mips/include/asm/io.h index cc28d207a061..477773328a06 100644 --- a/arch/mips/include/asm/io.h +++ b/arch/mips/include/asm/io.h @@ -12,8 +12,6 @@ #ifndef _ASM_IO_H #define _ASM_IO_H -#define ARCH_HAS_IOREMAP_WC - #include #include #include @@ -25,7 +23,6 @@ #include #include #include -#include #include #include #include @@ -210,6 +207,8 @@ void iounmap(const volatile void __iomem *addr); #define ioremap_wc(offset, size) \ ioremap_prot((offset), (size), boot_cpu_data.writecombine) +#include + #if defined(CONFIG_CPU_CAVIUM_OCTEON) #define war_io_reorder_wmb() wmb() #else diff --git a/arch/powerpc/include/asm/io.h b/arch/powerpc/include/asm/io.h index f1e657c9bbe8..67a3fb6de498 100644 --- a/arch/powerpc/include/asm/io.h +++ b/arch/powerpc/include/asm/io.h @@ -3,11 +3,6 @@ #define _ASM_POWERPC_IO_H #ifdef __KERNEL__ -#define ARCH_HAS_IOREMAP_WC -#ifdef CONFIG_PPC32 -#define ARCH_HAS_IOREMAP_WT -#endif - /* */ @@ -732,9 +727,7 @@ static inline void name at \ #define writel_relaxed(v, addr) writel(v, addr) #define writeq_relaxed(v, addr) writeq(v, addr) -#ifdef CONFIG_GENERIC_IOMAP -#include -#else +#ifndef CONFIG_GENERIC_IOMAP /* * Here comes the implementation of the IOMAP interfaces. */ diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h index e9025640f634..76238842406a 100644 --- a/arch/x86/include/asm/io.h +++ b/arch/x86/include/asm/io.h @@ -35,9 +35,6 @@ * - Arnaldo Carvalho de Melo */ -#define ARCH_HAS_IOREMAP_WC -#define ARCH_HAS_IOREMAP_WT - #include #include #include @@ -212,8 +209,6 @@ void memset_io(volatile void __iomem *, int, size_t); #define memcpy_toio memcpy_toio #define memset_io memset_io -#include - /* * ISA space is 'always mapped' on a typical x86 system, no need to * explicitly ioremap() it. The fact that the ISA IO space is mapped diff --git a/drivers/net/ethernet/sfc/io.h b/drivers/net/ethernet/sfc/io.h index 30439cc83a89..07f99ad14bf3 100644 --- a/drivers/net/ethernet/sfc/io.h +++ b/drivers/net/ethernet/sfc/io.h @@ -70,7 +70,7 @@ */ #ifdef CONFIG_X86_64 /* PIO is a win only if write-combining is possible */ -#ifdef ARCH_HAS_IOREMAP_WC +#ifdef ioremap_wc #define EFX_USE_PIO 1 #endif #endif diff --git a/drivers/net/ethernet/sfc/siena/io.h b/drivers/net/ethernet/sfc/siena/io.h index 30439cc83a89..07f99ad14bf3 100644 --- a/drivers/net/ethernet/sfc/siena/io.h +++ b/drivers/net/ethernet/sfc/siena/io.h @@ -70,7 +70,7 @@ */ #ifdef CONFIG_X86_64 /* PIO is a win only if write-combining is possible */ -#ifdef ARCH_HAS_IOREMAP_WC +#ifdef ioremap_wc #define EFX_USE_PIO 1 #endif #endif diff --git a/include/asm-generic/iomap.h b/include/asm-generic/iomap.h index 08237ae8b840..196087a8126e 100644 --- a/include/asm-generic/iomap.h +++ b/include/asm-generic/iomap.h @@ -93,15 +93,15 @@ extern void __iomem *ioport_map(unsigned long port, unsigned int nr); extern void ioport_unmap(void __iomem *); #endif -#ifndef ARCH_HAS_IOREMAP_WC +#ifndef ioremap_wc #define ioremap_wc ioremap #endif -#ifndef ARCH_HAS_IOREMAP_WT +#ifndef ioremap_wt #define ioremap_wt ioremap #endif -#ifndef ARCH_HAS_IOREMAP_NP +#ifndef ioremap_np /* See the comment in asm-generic/io.h about ioremap_np(). */ #define ioremap_np ioremap_np static inline void __iomem *ioremap_np(phys_addr_t offset, size_t size) From patchwork Fri Jun 9 07:55: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: 105350 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp782849vqr; Fri, 9 Jun 2023 01:01:47 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6/urIp4KDU1nc2OEKQBRuICogWtmVKbf57g13b6hCH/Oorgf0jGre57rSkEHMj/Gv5yAvR X-Received: by 2002:a05:6a20:e307:b0:10f:8798:9feb with SMTP id nb7-20020a056a20e30700b0010f87989febmr246621pzb.57.1686297706714; Fri, 09 Jun 2023 01:01:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686297706; cv=none; d=google.com; s=arc-20160816; b=KbpH4ErsmECZWbqOrIFxaAIJarOKm/ZhH0sa9ao/7ETBGOnKXiw25lOMMYcEj/g7qU +YlufS7Dj7NsGzd6QFF34FBP/ula2wVySNWFS9uxbt45O+nOcciEpCixKIij21HVNTNA oG26GrfP9/1EqlKLUQI8be3uyTJz7h788jxRwAO6vFGpkXxyO6+NQLTWT19DkFmFodyF 0/iH8AAhcBsCceqciYY3j5tMnhKYJV3lpCL5yT/JEWvmxFbDj6mk3DW8bjsH+nCOJQtN YyDw/BJGL8+Kvz257SaTIgQ9FPjZaHGur79lv1Ub3dp1dCb/uStZHsNTBDSlfySX8Osk Cu5A== 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=3DenNY7MBGvhJyodc+H0T1cCxvBg9zEtJ+UDYfYUhPQ=; b=YHTDK3bx4o8K2akAYVVdN/5bjXHFsufMDWnRVgUoPunTRfhhmHlOsi0+KqW2nGsTFH V45PBOvNwj6bhkGgF0AhRFnz+kkPFa/1NPkSig29knmiBBelC6OQ0ffW5Ox0KuL4iYJ3 0YZ+35oVEhbT1sbWvIkPeiyVxmd1dY+oMA+BHNvqKqkAqvJ+Fsp0XjvCJpn3WrEjUI4l R8cBCfIbwwmd/1l42yN87i/lEIt4aKPxidicneIuhkXjZAGsOfwHqgvIi2rNl/WH93uH QjizYWPaznRXhJbuRFDJMWu8qUw4mJGxGTR+igJKXoVDNYoQSoqj+OUeSHQRCS6HtnY7 QGAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=M7qWPBQl; 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 c28-20020aa7953c000000b006620f8fae9asi2104425pfp.371.2023.06.09.01.01.32; Fri, 09 Jun 2023 01:01:46 -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=M7qWPBQl; 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 S239506AbjFIH5g (ORCPT + 99 others); Fri, 9 Jun 2023 03:57:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33814 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239518AbjFIH5V (ORCPT ); Fri, 9 Jun 2023 03:57:21 -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 180C730ED for ; Fri, 9 Jun 2023 00:56:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686297361; 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=3DenNY7MBGvhJyodc+H0T1cCxvBg9zEtJ+UDYfYUhPQ=; b=M7qWPBQlllg61ryVi8LPO/PbELldVokk7Ys8EeG7tPXwigfJmNl+eI78/CFfQK/GRjk6Zf X5AS57Vk923xYpAUZx6W2VaQhauBJBTMFJaY4TJbcHDv9C/sjCY5qcCSN2+TamnIk3MedY +XVxWjHBX4M9qYDHoRfkQD/XGaK4/TY= 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-627-iJkQnqI-MI24KPf3bK0ngg-1; Fri, 09 Jun 2023 03:55:54 -0400 X-MC-Unique: iJkQnqI-MI24KPf3bK0ngg-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 59EC0384952A; Fri, 9 Jun 2023 07:55:53 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-92.pek2.redhat.com [10.72.12.92]) by smtp.corp.redhat.com (Postfix) with ESMTP id 34AD920268C6; Fri, 9 Jun 2023 07:55:45 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-arch@vger.kernel.org, linux-mm@kvack.org, arnd@arndb.de, christophe.leroy@csgroup.eu, hch@lst.de, 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, Baoquan He , Brian Cain , linux-hexagon@vger.kernel.org Subject: [PATCH v6 02/19] hexagon: mm: Convert to GENERIC_IOREMAP Date: Fri, 9 Jun 2023 15:55:11 +0800 Message-Id: <20230609075528.9390-3-bhe@redhat.com> In-Reply-To: <20230609075528.9390-1-bhe@redhat.com> References: <20230609075528.9390-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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=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?1768211304250335129?= X-GMAIL-MSGID: =?utf-8?q?1768211304250335129?= By taking GENERIC_IOREMAP method, the generic ioremap_prot() and iounmap() are visible and available to arch. This change will simplify implementation by removing duplicated codes with generic ioremap_prot() and iounmap(), and has the equivalent functioality. For hexagon, the current ioremap() and iounmap() are the same as generic version. After taking GENERIC_IOREMAP way, the old ioremap() and iounmap() can be completely removed. Signed-off-by: Baoquan He Reviewed-by: Mike Rapoport (IBM) Reviewed-by: Christoph Hellwig Cc: Brian Cain Cc: linux-hexagon@vger.kernel.org Reported-by: kernel test robot Signed-off-by: Baoquan He --- arch/hexagon/Kconfig | 1 + arch/hexagon/include/asm/io.h | 9 +++++-- arch/hexagon/mm/ioremap.c | 44 ----------------------------------- 3 files changed, 8 insertions(+), 46 deletions(-) delete mode 100644 arch/hexagon/mm/ioremap.c diff --git a/arch/hexagon/Kconfig b/arch/hexagon/Kconfig index 54eadf265178..17afffde1a7f 100644 --- a/arch/hexagon/Kconfig +++ b/arch/hexagon/Kconfig @@ -25,6 +25,7 @@ config HEXAGON select NEED_SG_DMA_LENGTH select NO_IOPORT_MAP select GENERIC_IOMAP + select GENERIC_IOREMAP select GENERIC_SMP_IDLE_THREAD select STACKTRACE_SUPPORT select GENERIC_CLOCKEVENTS_BROADCAST diff --git a/arch/hexagon/include/asm/io.h b/arch/hexagon/include/asm/io.h index 46a099de85b7..dcd9cbbf5934 100644 --- a/arch/hexagon/include/asm/io.h +++ b/arch/hexagon/include/asm/io.h @@ -170,8 +170,13 @@ static inline void writel(u32 data, volatile void __iomem *addr) #define writew_relaxed __raw_writew #define writel_relaxed __raw_writel -void __iomem *ioremap(unsigned long phys_addr, unsigned long size); -#define ioremap_uc(X, Y) ioremap((X), (Y)) +/* + * I/O memory mapping functions. + */ +#define _PAGE_IOREMAP (_PAGE_PRESENT | _PAGE_READ | _PAGE_WRITE | \ + (__HEXAGON_C_DEV << 6)) + +#define ioremap_uc(addr, size) ioremap((addr), (size)) #define __raw_writel writel diff --git a/arch/hexagon/mm/ioremap.c b/arch/hexagon/mm/ioremap.c deleted file mode 100644 index 255c5b1ee1a7..000000000000 --- a/arch/hexagon/mm/ioremap.c +++ /dev/null @@ -1,44 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-only -/* - * I/O remap functions for Hexagon - * - * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved. - */ - -#include -#include -#include - -void __iomem *ioremap(unsigned long phys_addr, unsigned long size) -{ - unsigned long last_addr, addr; - unsigned long offset = phys_addr & ~PAGE_MASK; - struct vm_struct *area; - - pgprot_t prot = __pgprot(_PAGE_PRESENT|_PAGE_READ|_PAGE_WRITE - |(__HEXAGON_C_DEV << 6)); - - last_addr = phys_addr + size - 1; - - /* Wrapping not allowed */ - if (!size || (last_addr < phys_addr)) - return NULL; - - /* Rounds up to next page size, including whole-page offset */ - size = PAGE_ALIGN(offset + size); - - area = get_vm_area(size, VM_IOREMAP); - addr = (unsigned long)area->addr; - - if (ioremap_page_range(addr, addr+size, phys_addr, prot)) { - vunmap((void *)addr); - return NULL; - } - - return (void __iomem *) (offset + addr); -} - -void iounmap(const volatile void __iomem *addr) -{ - vunmap((void *) ((unsigned long) addr & PAGE_MASK)); -} From patchwork Fri Jun 9 07:55: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: 105348 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp782381vqr; Fri, 9 Jun 2023 01:01:05 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6YI6VaLF+WXi+X+WNlVxyYSnT2Lz9oThJlStqIvNkO2HZEf5f6PSeivgUXUayCg/tslYY1 X-Received: by 2002:a17:902:f54f:b0:1ac:b449:3528 with SMTP id h15-20020a170902f54f00b001acb4493528mr721745plf.46.1686297665206; Fri, 09 Jun 2023 01:01:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686297665; cv=none; d=google.com; s=arc-20160816; b=0V219jA/6FEGQyoPQ+m35ecP3PcX0yxFHYpE2xZeCqu1Uv/GqwWaHB7FjvHMrLcYPz 6d4PjXAEYsxErt9nvQvVW75Lm3zHWT6vYqDk7DhsQjj7Xqps7vlNO/LNCaBBY3ssfAWt 9L3AWDhwzwJmMDMKYPK+lGWmyZGJhEkru8SMaueVeuPPT22llqW612bRykIHLPBBnpiQ lg7zim+azWSi1lYzp+oENYmRlDviKVWAEKve42MQAfhAF/nLtRchCLhPy5DmqDVmqGeh cLIS4d3bsRidFXqFY5IbJkx2kOtdkml0ib5oD+gGD/UXR7YGOtn16/Ac7QWu6bPCu8Bv +nZw== 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=b1cwgKpxB+oYTQq0br6utRWEYNI4guxqhcfHp/vK96c=; b=jUC/im9vWD+O3pFI8SIptOOGxZ7C9YomQB1zavS1Y+mRuWMF+8v0QsOkQqn+5Q2R4g BomuAADi5uRiWvCUwxpj0WV83VTfK3t2lDh8a9zg0GZYkuPymvrmtUGhcdxBuEzRuWT8 NhS5uBSrSes/qXLqCaDyd0iXqkY9achrzYb26PSs7yKt2JcJS3ktJxLEZyxlpIHVfjL7 RUsa3msrJGteNHd7YvBTV86XRtFIpnzZHBMqwtNkIHKbeSaC/iLreBNfYCD7f+NCSylO qgMwxuvyq7pttj84SacelOrXxBevEKgGPspUh1B20EI0yhUSKOP8MNbuw0JYHhwFK5Ap bqRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=hmD3SnBU; 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 y17-20020a170903011100b001a986e5bd92si2235665plc.83.2023.06.09.01.00.48; Fri, 09 Jun 2023 01:01:05 -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=hmD3SnBU; 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 S239599AbjFIH6D (ORCPT + 99 others); Fri, 9 Jun 2023 03:58:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34192 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239479AbjFIH53 (ORCPT ); Fri, 9 Jun 2023 03:57: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 488C03AAA for ; Fri, 9 Jun 2023 00:56:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686297375; 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=b1cwgKpxB+oYTQq0br6utRWEYNI4guxqhcfHp/vK96c=; b=hmD3SnBUvWOR9U03gxZ0MZpRH3T0wH+srnXs1WA3FiPXYBeZKmWoFtmAdCBAmWiLXrfIGW WD4+0nY4CYM0B00VJVZY4z5ZsO0HLVoBHIGo4s175QFNsqAktql8N8y3ccJWRAHS2SJW/G RjwoHkMoPF+G4/pkOQr4Hr8omwP79p8= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-668-KXU_qVZcOVSgr_rQs7LwAQ-1; Fri, 09 Jun 2023 03:56:01 -0400 X-MC-Unique: KXU_qVZcOVSgr_rQs7LwAQ-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B4B8085A5BA; Fri, 9 Jun 2023 07:56:00 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-92.pek2.redhat.com [10.72.12.92]) by smtp.corp.redhat.com (Postfix) with ESMTP id 012CE20268C6; Fri, 9 Jun 2023 07:55:53 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-arch@vger.kernel.org, linux-mm@kvack.org, arnd@arndb.de, christophe.leroy@csgroup.eu, hch@lst.de, 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, Baoquan He , Jonas Bonn , Stefan Kristiansson , openrisc@lists.librecores.org Subject: [PATCH v6 03/19] openrisc: mm: remove unneeded early ioremap code Date: Fri, 9 Jun 2023 15:55:12 +0800 Message-Id: <20230609075528.9390-4-bhe@redhat.com> In-Reply-To: <20230609075528.9390-1-bhe@redhat.com> References: <20230609075528.9390-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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_H5,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?1768211260479609129?= X-GMAIL-MSGID: =?utf-8?q?1768211260479609129?= 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 Cc: Jonas Bonn Cc: Stefan Kristiansson Cc: Stafford Horne Cc: openrisc@lists.librecores.org Reviewed-by: Christoph Hellwig Reviewed-by: Mike Rapoport (IBM) --- v5->v6: Remove the special handling in iounmap() because no page is got from fixmap pool along with early ioremap code removing in ioremap() - Mike. 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 Fri Jun 9 07:55: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: 105369 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp789065vqr; Fri, 9 Jun 2023 01:15:31 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7NQw6waBUER8dqNBfC593Tj6WM92YERj/ZRsh8QUhF02YGaAxzbnn/hxSlGrx8QyfF6vWR X-Received: by 2002:a05:6a00:13a8:b0:657:1fe5:eb63 with SMTP id t40-20020a056a0013a800b006571fe5eb63mr5186104pfg.7.1686298530935; Fri, 09 Jun 2023 01:15:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686298530; cv=none; d=google.com; s=arc-20160816; b=J8FiA0O4stRDcpebkKfvs8aZv9g7i/fd2MEdzzZZp1O3LRZSkPHXwxj3zWoIvKAAs4 E3Eupd6J1BOYa03LniLqzS0yro/WzA1f1xF8zUS99NxfmYuMBXMbhkXfGsnjljb47nvk snw1Yg4Y4joG8vWDcrUzmyd3nAybXbGDjEAfLosSQO7GUy0+cvAN2kHlirf97egYHqrC MWNeWfFSLQqF1JGSZ620tftfFj7JWhlkevjs7UVlS8HlyKeih+pl/+5gHCEq5INPFtm9 wrTSPlHZiTgW8F4cAWp0i8JozI4eBAsppxwNONlsdgayZ5bZtTv6LKw9Nk6hHJ5bih+D lOpQ== 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=; b=JgT3xgNi1ZdEadcLKRID1l7vRdrhA3WAzP/azQWi5bF3ymXJUrZZnZMbeWb12j0ME3 VmZT3ApJRBU0DYHgN7dunx/IoTKFM49zyOdaC2TlPhnfKPDwPrqHHwRj2cgk4XVKlpU2 wSZEdmjKUdyP6yUQ0CHFhO5DZXUqVmSAZClKO2wUFGyOWXI9/GXf98LIDLy1VVWADDOo vw0pyNG1PSAAYZGc4UBFQlGMGjgufVYNu2hAzMLNm1BGWM91IfjHuPbbsT7Z2XuJaBhg 5SNoAx1QKETtnhkdSqOltuJ5f55aUlas1792uNi4mcpM7DlZptiddZTRrAIo5CJ1QtJi XU7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=aFdx9+R6; 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 6-20020a621906000000b00656d1628952si2105935pfz.296.2023.06.09.01.15.18; Fri, 09 Jun 2023 01:15:30 -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=aFdx9+R6; 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 S239636AbjFIH56 (ORCPT + 99 others); Fri, 9 Jun 2023 03:57:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34024 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239478AbjFIH53 (ORCPT ); Fri, 9 Jun 2023 03:57: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 1AFBC3AAE for ; Fri, 9 Jun 2023 00:56:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686297377; 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=aFdx9+R6+0PGOjZBcELs4mHXfv7BGXhe29O3/WP99QZHni81TGxF/FUL2xIpMvyKx8uL/B 2OIRLLTa/tKG691bSiktdmwi1kUbd5MiANGTLfLMlYQ9TA6CLHEljiMNH1BsTxSad+7smm enEacumaBeC3o/QF4W9Zn5PbhKEbsuk= 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-138-GRetf83ANGaLxKsxo5bctQ-1; Fri, 09 Jun 2023 03:56:08 -0400 X-MC-Unique: GRetf83ANGaLxKsxo5bctQ-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8AF8385A5A8; Fri, 9 Jun 2023 07:56:07 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-92.pek2.redhat.com [10.72.12.92]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6EFCF20268C6; Fri, 9 Jun 2023 07:56:01 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-arch@vger.kernel.org, linux-mm@kvack.org, arnd@arndb.de, christophe.leroy@csgroup.eu, hch@lst.de, 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, Baoquan He Subject: [PATCH v6 04/19] mm/ioremap: Define generic_ioremap_prot() and generic_iounmap() Date: Fri, 9 Jun 2023 15:55:13 +0800 Message-Id: <20230609075528.9390-5-bhe@redhat.com> In-Reply-To: <20230609075528.9390-1-bhe@redhat.com> References: <20230609075528.9390-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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_H5,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?1768212168607702875?= X-GMAIL-MSGID: =?utf-8?q?1768212168607702875?= 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) Reviewed-by: Christoph Hellwig --- 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 Fri Jun 9 07:55: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: 105376 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp789569vqr; Fri, 9 Jun 2023 01:16:37 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4PREIOqbT/WUoUGoiy9Mb3SDsyOAkUY+EiCpkY1dwyZL/MvxeLmZ/zXrsNqKcjezygIbVs X-Received: by 2002:a05:6a00:c88:b0:65d:83d8:c3e3 with SMTP id a8-20020a056a000c8800b0065d83d8c3e3mr702150pfv.32.1686298596792; Fri, 09 Jun 2023 01:16:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686298596; cv=none; d=google.com; s=arc-20160816; b=I7Mk7o0E9FOTtWFqrroh9t3V8f5ZdHD7AnyXHf8yj3G3LJVpFMFhjcHJQv1U8i/G0i oB6mM2JQ/EGf+RK0zbp3JSqCs7mt6Sq0zjpFa2N54LqW19Lfm5gQdrZ2LFV1cEHev8xu ZmKhv+6o8vtN+IB2pRbyIVx081VmP8xzHCQ3djBNgIkC37HgI2vs1YT166BWExQJPduS gRbwzlqpSTNxVafsd5SzrVk84isqTu7rZkLrwxikYlNcWbbJ9ONT2Whc+8NOO54kkxvD RPRcJa8Rfxzsp7RbXa3rihMF+R8B2YtF6im/WBfVCC92QPXkrdDDLDl6FakiuBl+zTnZ gMIw== 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=; b=etYP+T4HjlSM6yBo/sJoXSIWAqdWBixvLwjZer8GNJx6Z5brPNMN5MvGOlh85pkjWS Jd2V0bqlJODXN/NdrukmM98zPbcgR+bDJzbsegxyCzTiOMejuquylxHckKNahmXB7bZ7 DC7CIrijkdriX0jv5kiPHNPDkkOyxvGbq4ehTFLB6/2c8pstbEgzEiUFH6Ub8zCf8uFn PubU1NJGkjkfnAHx0ldGnk7q2Exlm5Q23IsydzOcMufKq6XsDDhpzdXLQPsgq91KAJdG ysPuboqmqLYurJCh6KAU/wM1kYuyStmLCn8VCCvl7leTWiZPwTtApZtccCFV58zwiBO8 Duzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=hJ+d55OM; 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 y82-20020a626455000000b00643652c8879si2018328pfb.326.2023.06.09.01.16.23; Fri, 09 Jun 2023 01:16: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=hJ+d55OM; 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 S239662AbjFIH6G (ORCPT + 99 others); Fri, 9 Jun 2023 03:58:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33804 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239387AbjFIH5a (ORCPT ); Fri, 9 Jun 2023 03:57:30 -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 976994224 for ; Fri, 9 Jun 2023 00:56:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686297379; 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=hJ+d55OMRgIpuQtE3NzLKw6sj4a3FFES/G+axssZnwpmLHmCp2So3pn/gKwKMn5cLCXQjJ ImF20cWyOoJiAY41d15fCuJVMLYpeFrWvxnkbaVoUUhKIXKx1xViXRxrSiZnVtTSDKiSZe G5ovi0FCP9+Sphnzs0cQM9rKat9i+Ts= 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-562-XLUSNABUP-uOYtCvZesmAg-1; Fri, 09 Jun 2023 03:56:14 -0400 X-MC-Unique: XLUSNABUP-uOYtCvZesmAg-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9E61C384952B; Fri, 9 Jun 2023 07:56:13 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-92.pek2.redhat.com [10.72.12.92]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2DC1720268C7; Fri, 9 Jun 2023 07:56:07 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-arch@vger.kernel.org, linux-mm@kvack.org, arnd@arndb.de, christophe.leroy@csgroup.eu, hch@lst.de, 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, Baoquan He Subject: [PATCH v6 05/19] mm: ioremap: allow ARCH to have its own ioremap method definition Date: Fri, 9 Jun 2023 15:55:14 +0800 Message-Id: <20230609075528.9390-6-bhe@redhat.com> In-Reply-To: <20230609075528.9390-1-bhe@redhat.com> References: <20230609075528.9390-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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_H5,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?1768212237454635066?= X-GMAIL-MSGID: =?utf-8?q?1768212237454635066?= 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 Fri Jun 9 07:55: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: 105360 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp785862vqr; Fri, 9 Jun 2023 01:07:50 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7hMe71WeobYFZZvWdB5wuXZ8I+YCM5ciSqKuYA26gjegAFIJMHBKwYjeyFm9a3AMXhdlwR X-Received: by 2002:a05:6a00:807:b0:656:e7a2:5362 with SMTP id m7-20020a056a00080700b00656e7a25362mr455458pfk.16.1686298070443; Fri, 09 Jun 2023 01:07:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686298070; cv=none; d=google.com; s=arc-20160816; b=T+pOE+zWUBLOxTEAsA/9+4Z42xdQYps++7KKkYrxGS2nLQNJiyPuMXO8lu7knu8qCX bMnzZqf/zD1+VaI7mVgXoFXLHpNi7o07cu77hYIYYaydUfSR1815MMAqwWwtGi06i1FS OUGAXed9aEAuLf9R2PrwEC4hwxMWeOO34Ud4HlpLxFz4wTXtFPxn/0coeUpCcmFSx1hX I8M8rvDFSFOQiK4Mf0jCoT7x5zIbpJs97PYN4GEDEMT0J1xWFFwS6+/KzNO84bgrqgNz 1js7fSBlZkz4M9QPRpqYd1JYH2NpNWrxBtxuqR8tzqZuXDsQ+x2T7nvpHAbaYCivXT0W s8WQ== 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=0wYOGjo01By5N6ypk4T/kszJYngB2yHKY4BDovVrGlY=; b=efM9ywZ7a+4WnUE1/VT350mpzZhQa6aN9VctL4lBNC3EnaIbsxA5ccdbdkGNy4O0fU 7Vr+olBGLZg4Fwj3NI31VPgoNokzFFPyg6ST40yEEk9iWYX5w/WkxhdBcopXGxOCtuXK EHmrXhxIVFegg7lUNBs5bdmv80DFGA0y7OQHlg8yHcmDIenWn+8Q0HN9qm0Zxj+HEBV2 ocAOhLVigFUCiK83vjXW7dYSS5ER1DI2dfL6fUq1vtzOxLt9bX7jyQebnEKacT6ATW4i OLn3x0CbjMR34+jP/9HksouJlh0Rbbp0Nlpy4aq97gwWbszVHCxzvbqDlXtsqhIX7ItU y4Pw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=O7G+H0Sb; 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 m186-20020a633fc3000000b0053ef1799a71si2360383pga.399.2023.06.09.01.07.36; Fri, 09 Jun 2023 01:07:50 -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=O7G+H0Sb; 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 S239615AbjFIH6a (ORCPT + 99 others); Fri, 9 Jun 2023 03:58:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33628 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239372AbjFIH5x (ORCPT ); Fri, 9 Jun 2023 03:57:53 -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 A13F6423C for ; Fri, 9 Jun 2023 00:56:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686297384; 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=0wYOGjo01By5N6ypk4T/kszJYngB2yHKY4BDovVrGlY=; b=O7G+H0SbD04zNIRChWZD/Ck4riOoFzaosmzUb5px7vcfZPxULGkmUIGX/QD2vt1kCOSkjr nBLsCx9AtPj7s5kk4EvGXVG6GRlnI2NKdRFvUyxfapPq3EXodAT8bmzphJZ6/EWWDRCtK8 tTvn9YHiIVshpx6p7ZNtkfgmDCeTZrc= 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-468-G5FEyEG6MS-Y-nyIC9k_aA-1; Fri, 09 Jun 2023 03:56:20 -0400 X-MC-Unique: G5FEyEG6MS-Y-nyIC9k_aA-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D69A4811E7C; Fri, 9 Jun 2023 07:56:19 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-92.pek2.redhat.com [10.72.12.92]) by smtp.corp.redhat.com (Postfix) with ESMTP id 47A0A20268C6; Fri, 9 Jun 2023 07:56:13 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-arch@vger.kernel.org, linux-mm@kvack.org, arnd@arndb.de, christophe.leroy@csgroup.eu, hch@lst.de, 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, Baoquan He Subject: [PATCH v6 06/19] mm/ioremap: add slab availability checking in ioremap_prot Date: Fri, 9 Jun 2023 15:55:15 +0800 Message-Id: <20230609075528.9390-7-bhe@redhat.com> In-Reply-To: <20230609075528.9390-1-bhe@redhat.com> References: <20230609075528.9390-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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_H5,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?1768211685300347094?= X-GMAIL-MSGID: =?utf-8?q?1768211685300347094?= 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) --- v5-v6: Add WARN_ON_ONCE to aid debugging - Christoph. 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 Fri Jun 9 07:55: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: 105365 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp787723vqr; Fri, 9 Jun 2023 01:12:14 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5oSpUps3QrhV0JwESbb1E/KclwQrfl1EDsqJ8loB9dGP9S2Aw9WM2dl0kaqtYrEIEbn3JG X-Received: by 2002:a05:6a21:680d:b0:ef:7aa2:3cfd with SMTP id wr13-20020a056a21680d00b000ef7aa23cfdmr340503pzb.50.1686298333934; Fri, 09 Jun 2023 01:12:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686298333; cv=none; d=google.com; s=arc-20160816; b=gm9QZD3+4phsyhU9bZ4hHIx9lNp4J6SVjIRwnz1OG0vhUykY17/wv7L5YbmeUZxj/V vxp8c0p5+62nnYBtC+iYzV1eCaP5uozmoWf2kpNshRbPCv/yCI+NwMwt2Gy8NOili3Gp GlJ4L2FpK03hD3DRWWkbNw9SRfrvDC3p9Xos7+S6bT1vsR+CxfrmDjkCt4qil07ntoTT AUTuyjvyhTyHE+Gu9EvJB14AJUJQIwZYiTECcIYLRO6tmW+SoeiDh5sguWcXPyC982C5 Bc8XusrrQfIhLhjG/lzlvcQZbhbUEiG7BwVkGoJ8DrcmFcrBTnjyQIcXC+mSezf0G8cg H7mA== 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=AgITI2yqguKz3xZ3AEWeb8MIawpkLomY+LhKu59PhRc=; b=vqPaDDnV2VH0+SDkRSQCI+H7e7Vo5ie2WNwtVmcNXuc0lsILIq5Xv0CMv57YfdVNov 9Z0QnMi2zuFM/E0pqGtYt0Y/PNONFq1TXY6Q68h3k6cNRfX1+JtTixZwDBniIzXJH9Xi 8spJqVdFCbp28b2zV5GXn5WhFGg52OVhuEpBaB5FZS+AvE2fN11ArUpbePLxPk+h8YCj r7JLwf4FmzuymH1RJYMLK7HLzmMpZ8j7F1jWRorkXl4nODERJLCSKbMFcafnxiRUKwni yilHcqRhWAZjh2Nni8RsBljVsrqtxxa1GMyXQvRygfT8/9rGTclmZ899yXnJVg2hfeqm A/Rw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=SAak5dry; 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 a14-20020a170902ecce00b001b000b3f132si157276plh.298.2023.06.09.01.11.56; Fri, 09 Jun 2023 01:12:13 -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=SAak5dry; 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 S239642AbjFIH6i (ORCPT + 99 others); Fri, 9 Jun 2023 03:58:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33532 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239633AbjFIH56 (ORCPT ); Fri, 9 Jun 2023 03:57:58 -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 F3BB535AC for ; Fri, 9 Jun 2023 00:56:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686297393; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=AgITI2yqguKz3xZ3AEWeb8MIawpkLomY+LhKu59PhRc=; b=SAak5dryQieG2Ia798UUz6woEKofZB9W61tlBhL8YSJzTyCs4mbGwjIiJiV8oplW2imM36 twqKxlrcLC+ousyA10ipGCmjfj/noGV2ZJPayiEUyFHxbR5wcr84T9zEHvgPrlYX/nfxYp Lqr5fXjpK2rnOviCDAGAFjH0TwQGsc4= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-507-GsgpTOSBOV27xs_zRW3t0Q-1; Fri, 09 Jun 2023 03:56:27 -0400 X-MC-Unique: GsgpTOSBOV27xs_zRW3t0Q-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B11538007D9; Fri, 9 Jun 2023 07:56:26 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-92.pek2.redhat.com [10.72.12.92]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7E2AE20268C6; Fri, 9 Jun 2023 07:56:20 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-arch@vger.kernel.org, linux-mm@kvack.org, arnd@arndb.de, christophe.leroy@csgroup.eu, hch@lst.de, 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, Baoquan He , Vineet Gupta , linux-snps-arc@lists.infradead.org Subject: [PATCH v6 07/19] arc: mm: Convert to GENERIC_IOREMAP Date: Fri, 9 Jun 2023 15:55:16 +0800 Message-Id: <20230609075528.9390-8-bhe@redhat.com> In-Reply-To: <20230609075528.9390-1-bhe@redhat.com> References: <20230609075528.9390-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768211961772841650?= X-GMAIL-MSGID: =?utf-8?q?1768211961772841650?= By taking GENERIC_IOREMAP method, the generic generic_ioremap_prot(), generic_iounmap(), and their generic wrapper ioremap_prot(), ioremap() and iounmap() are all visible and available to arch. Arch needs to provide wrapper functions to override the generic versions if there's arch specific handling in its ioremap_prot(), ioremap() or iounmap(). This change will simplify implementation by removing duplicated codes with generic_ioremap_prot() and generic_iounmap(), and has the equivalent functioality as before. Here, add wrapper functions ioremap_prot() and iounmap() for arc's special operation when ioremap_prot() and iounmap(). Signed-off-by: Baoquan He Reviewed-by: Christoph Hellwig Reviewed-by: Mike Rapoport (IBM) Cc: Vineet Gupta Cc: linux-snps-arc@lists.infradead.org --- arch/arc/Kconfig | 1 + arch/arc/include/asm/io.h | 7 +++--- arch/arc/mm/ioremap.c | 49 ++++----------------------------------- 3 files changed, 8 insertions(+), 49 deletions(-) diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig index ab6d701365bb..3a666ee0c0bc 100644 --- a/arch/arc/Kconfig +++ b/arch/arc/Kconfig @@ -26,6 +26,7 @@ config ARC select GENERIC_PENDING_IRQ if SMP select GENERIC_SCHED_CLOCK select GENERIC_SMP_IDLE_THREAD + select GENERIC_IOREMAP select HAVE_ARCH_KGDB select HAVE_ARCH_TRACEHOOK select HAVE_ARCH_TRANSPARENT_HUGEPAGE if ARC_MMU_V4 diff --git a/arch/arc/include/asm/io.h b/arch/arc/include/asm/io.h index 80347382a380..4fdb7350636c 100644 --- a/arch/arc/include/asm/io.h +++ b/arch/arc/include/asm/io.h @@ -21,8 +21,9 @@ #endif extern void __iomem *ioremap(phys_addr_t paddr, unsigned long size); -extern void __iomem *ioremap_prot(phys_addr_t paddr, unsigned long size, - unsigned long flags); +#define ioremap ioremap +#define ioremap_prot ioremap_prot +#define iounmap iounmap static inline void __iomem *ioport_map(unsigned long port, unsigned int nr) { return (void __iomem *)port; @@ -32,8 +33,6 @@ static inline void ioport_unmap(void __iomem *addr) { } -extern void iounmap(const volatile void __iomem *addr); - /* * io{read,write}{16,32}be() macros */ diff --git a/arch/arc/mm/ioremap.c b/arch/arc/mm/ioremap.c index 712c2311daef..b07004d53267 100644 --- a/arch/arc/mm/ioremap.c +++ b/arch/arc/mm/ioremap.c @@ -8,7 +8,6 @@ #include #include #include -#include #include static inline bool arc_uncached_addr_space(phys_addr_t paddr) @@ -25,13 +24,6 @@ static inline bool arc_uncached_addr_space(phys_addr_t paddr) void __iomem *ioremap(phys_addr_t paddr, unsigned long size) { - phys_addr_t end; - - /* Don't allow wraparound or zero size */ - end = paddr + size - 1; - if (!size || (end < paddr)) - return NULL; - /* * If the region is h/w uncached, MMU mapping can be elided as optim * The cast to u32 is fine as this region can only be inside 4GB @@ -51,55 +43,22 @@ EXPORT_SYMBOL(ioremap); * ARC hardware uncached region, this one still goes thru the MMU as caller * might need finer access control (R/W/X) */ -void __iomem *ioremap_prot(phys_addr_t paddr, unsigned long size, +void __iomem *ioremap_prot(phys_addr_t paddr, size_t size, unsigned long flags) { - unsigned int off; - unsigned long vaddr; - struct vm_struct *area; - phys_addr_t end; pgprot_t prot = __pgprot(flags); - /* Don't allow wraparound, zero size */ - end = paddr + size - 1; - if ((!size) || (end < paddr)) - return NULL; - - /* An early platform driver might end up here */ - if (!slab_is_available()) - return NULL; - /* force uncached */ - prot = pgprot_noncached(prot); - - /* Mappings have to be page-aligned */ - off = paddr & ~PAGE_MASK; - paddr &= PAGE_MASK_PHYS; - size = PAGE_ALIGN(end + 1) - paddr; - - /* - * Ok, go for it.. - */ - area = get_vm_area(size, VM_IOREMAP); - if (!area) - return NULL; - area->phys_addr = paddr; - vaddr = (unsigned long)area->addr; - if (ioremap_page_range(vaddr, vaddr + size, paddr, prot)) { - vunmap((void __force *)vaddr); - return NULL; - } - return (void __iomem *)(off + (char __iomem *)vaddr); + return generic_ioremap_prot(paddr, size, pgprot_noncached(prot)); } EXPORT_SYMBOL(ioremap_prot); - -void iounmap(const volatile void __iomem *addr) +void iounmap(volatile void __iomem *addr) { /* weird double cast to handle phys_addr_t > 32 bits */ if (arc_uncached_addr_space((phys_addr_t)(u32)addr)) return; - vfree((void *)(PAGE_MASK & (unsigned long __force)addr)); + generic_iounmap(addr); } EXPORT_SYMBOL(iounmap); From patchwork Fri Jun 9 07:55: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: 105349 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp782411vqr; Fri, 9 Jun 2023 01:01:07 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4gxeIHhrKhWaf22zkTETqGDcSXWUSS2DE7EK7RuDlHTw6vaf83x1h2X4Zb3TBq9FzVKCPl X-Received: by 2002:a05:6a20:1613:b0:10b:cb77:5403 with SMTP id l19-20020a056a20161300b0010bcb775403mr665286pzj.52.1686297666749; Fri, 09 Jun 2023 01:01:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686297666; cv=none; d=google.com; s=arc-20160816; b=PxKqhfDo5wjWLv8pNroRZ5dLgZZQJUMzouxoIwBKC4C1Os9sB0REHcKvnJj4mt7O4j HdRtcgyH1YtTeTIAaXcjMp3hh6BrVxJWY26Bh7BgWSiUbLkor1OElVLsiRkfU+3v6/0L XFoYJSLrrN3SnB4S6j4SGUsZfVFXsl8tBVVy1BhDemsnWXJxgkO8UzfTkxxQ7egf2/OX 26IzpPyfT4cWs3nKIWbJleljtTsxGsew9mkTNp4/cg9hculF9dvFXVDJzJryseXfozvw tzxq8dehZtJubrFHfEN4aVR9O22TcnQj4ih6I9pmtgiyjJGngaZqd6nrCq2DEromPyCj hk+g== 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=ua5XWkW27x0Nyt2yapSJ4JgStlbMxAmr6HBzd8gpRZY=; b=VRdBVOnfiLHEgWQ1S0dMVScOeH5c2mhH6ZbnR2jq+rdxTzmEMIS80rody5HSS1UJkM Om2AVb/agwwGCbH2FuVCQYii4fQkWG0JHxT4lLnFkEw8Qi0mZagSDpg8nDwltJ0RfZAx MIs7fKiCZLm1uxQLIcuLgQaEa+B3nn1ntYjF/XiDtbBCmieipSfeG4b20LW+0Vz46cTI dyQ69DLFABJ8Y5CeW5wc0B8cLR+taTbvaMefqlxxuav5kSwFbwZx02bzDgJiffZUYnqI BuTiyDPDJEHoEVYx+1sVG4nt+3jiRsx9piIyPnajhqeHGJJDRNXvgUH8fEJbEwCHQlpz bjVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="cO/2Si4s"; 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 e25-20020aa79819000000b0064d2cca82b1si2182724pfl.48.2023.06.09.01.00.54; Fri, 09 Jun 2023 01:01:06 -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="cO/2Si4s"; 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 S239432AbjFIH62 (ORCPT + 99 others); Fri, 9 Jun 2023 03:58:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33562 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238799AbjFIH5x (ORCPT ); Fri, 9 Jun 2023 03:57: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 358802697 for ; Fri, 9 Jun 2023 00:56:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686297399; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ua5XWkW27x0Nyt2yapSJ4JgStlbMxAmr6HBzd8gpRZY=; b=cO/2Si4sSOLYxvHw2AS1NyjB05MQ/cZEMEbsZO8s9vVAtfHEknuhrm7shExVBd6eimljov VYJiSA0gpWhcRIC5Oktq139XIbSd86zxkVFqzdufRmzWg/APOUABd7X9M9GAs3UH8gfn98 UGqhakYLs49YuLh+/ijbFDO9ArZMFmw= 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-247-_famHlYDMIKFIVaU9zWlSA-1; Fri, 09 Jun 2023 03:56:35 -0400 X-MC-Unique: _famHlYDMIKFIVaU9zWlSA-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1F75C3849525; Fri, 9 Jun 2023 07:56:33 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-92.pek2.redhat.com [10.72.12.92]) by smtp.corp.redhat.com (Postfix) with ESMTP id 53F6F20268C6; Fri, 9 Jun 2023 07:56:27 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-arch@vger.kernel.org, linux-mm@kvack.org, arnd@arndb.de, christophe.leroy@csgroup.eu, hch@lst.de, 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, Baoquan He , linux-ia64@vger.kernel.org Subject: [PATCH v6 08/19] ia64: mm: Convert to GENERIC_IOREMAP Date: Fri, 9 Jun 2023 15:55:17 +0800 Message-Id: <20230609075528.9390-9-bhe@redhat.com> In-Reply-To: <20230609075528.9390-1-bhe@redhat.com> References: <20230609075528.9390-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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=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?1768211262184522804?= X-GMAIL-MSGID: =?utf-8?q?1768211262184522804?= By taking GENERIC_IOREMAP method, the generic generic_ioremap_prot(), generic_iounmap(), and their generic wrapper ioremap_prot(), ioremap() and iounmap() are all visible and available to arch. Arch needs to provide wrapper functions to override the generic versions if there's arch specific handling in its ioremap_prot(), ioremap() or iounmap(). This change will simplify implementation by removing duplicated codes with generic_ioremap_prot() and generic_iounmap(), and has the equivalent functioality as before. Here, add wrapper functions ioremap_prot() and iounmap() for ia64's special operation when ioremap() and iounmap(). Signed-off-by: Baoquan He Reviewed-by: Christoph Hellwig Reviewed-by: Mike Rapoport (IBM) Cc: linux-ia64@vger.kernel.org --- arch/ia64/Kconfig | 1 + arch/ia64/include/asm/io.h | 13 +++++------- arch/ia64/mm/ioremap.c | 41 ++++++-------------------------------- 3 files changed, 12 insertions(+), 43 deletions(-) diff --git a/arch/ia64/Kconfig b/arch/ia64/Kconfig index 21fa63ce5ffc..4f970b6d8032 100644 --- a/arch/ia64/Kconfig +++ b/arch/ia64/Kconfig @@ -46,6 +46,7 @@ config IA64 select GENERIC_IRQ_LEGACY select ARCH_HAVE_NMI_SAFE_CMPXCHG select GENERIC_IOMAP + select GENERIC_IOREMAP select GENERIC_SMP_IDLE_THREAD select ARCH_TASK_STRUCT_ON_STACK select ARCH_TASK_STRUCT_ALLOCATOR diff --git a/arch/ia64/include/asm/io.h b/arch/ia64/include/asm/io.h index 83a492c8d298..eedc0afa8cad 100644 --- a/arch/ia64/include/asm/io.h +++ b/arch/ia64/include/asm/io.h @@ -243,15 +243,12 @@ static inline void outsl(unsigned long port, const void *src, # ifdef __KERNEL__ -extern void __iomem * ioremap(unsigned long offset, unsigned long size); +#define _PAGE_IOREMAP pgprot_val(PAGE_KERNEL) + extern void __iomem * ioremap_uc(unsigned long offset, unsigned long size); -extern void iounmap (volatile void __iomem *addr); -static inline void __iomem * ioremap_cache (unsigned long phys_addr, unsigned long size) -{ - return ioremap(phys_addr, size); -} -#define ioremap ioremap -#define ioremap_cache ioremap_cache + +#define ioremap_prot ioremap_prot +#define ioremap_cache ioremap #define ioremap_uc ioremap_uc #define iounmap iounmap diff --git a/arch/ia64/mm/ioremap.c b/arch/ia64/mm/ioremap.c index 92b81bc91397..711b6abc822e 100644 --- a/arch/ia64/mm/ioremap.c +++ b/arch/ia64/mm/ioremap.c @@ -29,13 +29,9 @@ early_ioremap (unsigned long phys_addr, unsigned long size) return __ioremap_uc(phys_addr); } -void __iomem * -ioremap (unsigned long phys_addr, unsigned long size) +void __iomem *ioremap_prot(phys_addr_t phys_addr, size_t size, + unsigned long flags) { - void __iomem *addr; - struct vm_struct *area; - unsigned long offset; - pgprot_t prot; u64 attr; unsigned long gran_base, gran_size; unsigned long page_base; @@ -68,36 +64,12 @@ ioremap (unsigned long phys_addr, unsigned long size) */ page_base = phys_addr & PAGE_MASK; size = PAGE_ALIGN(phys_addr + size) - page_base; - if (efi_mem_attribute(page_base, size) & EFI_MEMORY_WB) { - prot = PAGE_KERNEL; - - /* - * Mappings have to be page-aligned - */ - offset = phys_addr & ~PAGE_MASK; - phys_addr &= PAGE_MASK; - - /* - * Ok, go for it.. - */ - area = get_vm_area(size, VM_IOREMAP); - if (!area) - return NULL; - - area->phys_addr = phys_addr; - addr = (void __iomem *) area->addr; - if (ioremap_page_range((unsigned long) addr, - (unsigned long) addr + size, phys_addr, prot)) { - vunmap((void __force *) addr); - return NULL; - } - - return (void __iomem *) (offset + (char __iomem *)addr); - } + if (efi_mem_attribute(page_base, size) & EFI_MEMORY_WB) + return generic_ioremap_prot(phys_addr, size, __pgprot(flags)); return __ioremap_uc(phys_addr); } -EXPORT_SYMBOL(ioremap); +EXPORT_SYMBOL(ioremap_prot); void __iomem * ioremap_uc(unsigned long phys_addr, unsigned long size) @@ -114,8 +86,7 @@ early_iounmap (volatile void __iomem *addr, unsigned long size) { } -void -iounmap (volatile void __iomem *addr) +void iounmap(volatile void __iomem *addr) { if (REGION_NUMBER(addr) == RGN_GATE) vunmap((void *) ((unsigned long) addr & PAGE_MASK)); From patchwork Fri Jun 9 07:55: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: 105370 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp789089vqr; Fri, 9 Jun 2023 01:15:33 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ41CFlXUfQsmM6fG4Sb1B9kC5kvJf8WjT/3vsjGauFliXYUGQWtjGssKgoApsy5SsFb7qYZ X-Received: by 2002:a05:6358:ba86:b0:129:c8f7:c1a6 with SMTP id dg6-20020a056358ba8600b00129c8f7c1a6mr788412rwb.2.1686298533180; Fri, 09 Jun 2023 01:15:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686298533; cv=none; d=google.com; s=arc-20160816; b=widwKOva5PCmju2eI2BaA50Pnfip9wgvf4wnkhWUTd0fYPvUfXIUgtCG/d6mdXCs9k Iia2IZpU1UDf2D4p5EHuZSNLsAZ+31VJ9DFIrXUxcr9UK+G8NE2m8pSPb1tk5J4o1Bcd Suz2oweFZGHkpDmGNefj2TSHN4Hw+rlE/xbf+6vUpQGWFVk2rHm0e6M92VXpT/Ppo8XB M3vkWCW2B4WQ4ehoWFunKRXQXX1GuIfo6RDstZVDJSGKknz95HhubUSRph7SxchQFqLw VS07loYRod+giHhKSfGuDXDPs6A9C7XM9V8WwAcIXFQ0ND/Jr7CNJfUHWVfQwusL0Mrt 9g/Q== 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=0lDwY01DeRkcypkPwr3wPDENx+u681h4hIQx3NHXU5U=; b=yiIL2StTz7KPgcdV5RBV2ysXmi02Jp3RqpP22UZMut9I1SzIj2BRuA6Rk65/NYv7w2 RG8UKm2c8xeLgoueBqTS/JoUQoAd/3WAyge7Jfg49daAUX4FS2TCEvaDMpKfMWW1j9Z4 L6UOA20kzfkczBLMfrfEqQagBXsjEKckvubFQNtFvi/7bCi0l6lNaAm5YyMDF/7yHvt/ nVPQL5xzAJEYM+x68izDXCA7LAJHc9SX+jtJ3ADZiPL6GDdYXGVRy6zKB7FAgdEbGYSy F1PyLUdLB+pQkuv94brobf3vxwjM8y/n2HtqWjsq2r9zWBm1CtjcP+nmPoFpAWffR6jo T3Ig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=gbANOYqH; 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 p29-20020a63951d000000b00544054a1555si2345330pgd.460.2023.06.09.01.15.18; Fri, 09 Jun 2023 01:15: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=gbANOYqH; 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 S239725AbjFIH6y (ORCPT + 99 others); Fri, 9 Jun 2023 03:58:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34054 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239387AbjFIH6J (ORCPT ); Fri, 9 Jun 2023 03:58:09 -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 27E5F3C32 for ; Fri, 9 Jun 2023 00:56:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686297408; 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=0lDwY01DeRkcypkPwr3wPDENx+u681h4hIQx3NHXU5U=; b=gbANOYqHRSKXzZMT5ulFXo3tpPSgyqtyfrdWn+9wOeVBkNHsQpCW9lSQqqO4mqATkMOafz w+vvNQa3ZwnBe7w4DkmfvbbFYrJP5I4S4JuPRUh3R/GxRhWLtCGiHMJBBIOumoiKuRMUwO v1R32tgdOrbGmiHnNCDlaPisy6gSfwU= 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-673-RicPtZkPNu6XXaXpAxIvew-1; Fri, 09 Jun 2023 03:56:41 -0400 X-MC-Unique: RicPtZkPNu6XXaXpAxIvew-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 376CA185A78F; Fri, 9 Jun 2023 07:56:40 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-92.pek2.redhat.com [10.72.12.92]) by smtp.corp.redhat.com (Postfix) with ESMTP id BD93420268C6; Fri, 9 Jun 2023 07:56:33 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-arch@vger.kernel.org, linux-mm@kvack.org, arnd@arndb.de, christophe.leroy@csgroup.eu, hch@lst.de, 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, Baoquan He , Jonas Bonn , Stefan Kristiansson , openrisc@lists.librecores.org Subject: [PATCH v6 09/19] openrisc: mm: Convert to GENERIC_IOREMAP Date: Fri, 9 Jun 2023 15:55:18 +0800 Message-Id: <20230609075528.9390-10-bhe@redhat.com> In-Reply-To: <20230609075528.9390-1-bhe@redhat.com> References: <20230609075528.9390-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768212170635915700?= X-GMAIL-MSGID: =?utf-8?q?1768212170635915700?= By taking GENERIC_IOREMAP method, the generic generic_ioremap_prot(), generic_iounmap(), and their generic wrapper ioremap_prot(), ioremap() and iounmap() are all visible and available to arch. Arch needs to provide wrapper functions to override the generic versions if there's arch specific handling in its ioremap_prot(), ioremap() or iounmap(). This change will simplify implementation by removing duplicated codes with generic_ioremap_prot() and generic_iounmap(), and has the equivalent functioality as before. For openrisc, the current ioremap() and iounmap() are the same as generic version. After taking GENERIC_IOREMAP way, the old ioremap() and iounmap() can be completely removed. Signed-off-by: Baoquan He Cc: Stafford Horne Cc: Jonas Bonn Cc: Stefan Kristiansson Cc: openrisc@lists.librecores.org Reviewed-by: Christoph Hellwig Reviewed-by: Mike Rapoport (IBM) --- v5->v6: Remove iounmap() because it's the same as the generic version since we have removed the code handling ealry mapping from fixmap pool in patch 3 - Mike 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 Fri Jun 9 07:55: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: 105361 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp785860vqr; Fri, 9 Jun 2023 01:07:50 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6HS0esu2Q7lwsXokB00KvByqGMvMqTgeisSu/z5EGZ91nXz3mAhJAIz6TxEvMaVmGrl1jS X-Received: by 2002:a17:90a:1a1a:b0:258:99d1:6b84 with SMTP id 26-20020a17090a1a1a00b0025899d16b84mr394874pjk.41.1686298070353; Fri, 09 Jun 2023 01:07:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686298070; cv=none; d=google.com; s=arc-20160816; b=ZER1EIXqIN63lVlR2d0RoD7H5E0HSkfPX9e46WhmygyO50On1dojgJzZ7klxAXCSsu oPlktfeyGw0AVW2s1Q8thY29GULxckEek6EBF397Qzrd3Vxq1x4ZvEcLHv7RD4dcX244 10xAzuGgqrSHLpT2x0gm+dXMEKb70wVT9NLUw58x/LXuc8IUKcJKWbiJNhu7vcxObEh1 Zlt7mr9PViABDDW7NHiIgVvN5bDvMnkJ0nRfuPEN6X8qfuoIL+ILkLCdQArFWoSiRJHW KXHfuv16tUlMLZJPp9kyXK43/AUiMgg39OlfRbtcHMhFVxcHZETNHVb2nF7V1CiHwp0R i/Lw== 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=etYbctmjhFxwpuu9vO4kynRojZXXRgJ3ulf2IbYPQOU=; b=aS94Gg0z2SPod4ruhRXVD5lkwjmqwn9oSQ0Al4xVoqthT8D8X3ZUTgsmZaUZwqKBMQ 4ch+TmA4HnlNBfSfWYUOnqMBGJ4s2yPSZ3MFGfEotlc7LOJvesNrBv3dawES/GMCo2UY 80XsDCII1VKSIUAXd03mNfplCHVmhnfCGkAJqK+xe/2BJ7+a3oDlBNYej8CQZMtgcCHd jhsqGLv0ePbZgh0s5B2ZPfFpjHtFz2VU5eShsX+Js71IWib9jgodhe5hYUa5TURgkvs5 Eou2J/KwrUJypQ271KfKD1E+MAKDkuCRFW8uc2aL/bZHP/5y4J3IeQqLqu/r646Po0zr 1pMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="ffCfcM/k"; 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 c9-20020a17090a674900b002594c8d9506si2327028pjm.159.2023.06.09.01.07.36; Fri, 09 Jun 2023 01:07:50 -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="ffCfcM/k"; 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 S239563AbjFIH64 (ORCPT + 99 others); Fri, 9 Jun 2023 03:58:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34150 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238934AbjFIH6M (ORCPT ); Fri, 9 Jun 2023 03:58:12 -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 11ECFE4E for ; Fri, 9 Jun 2023 00:56:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686297416; 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=etYbctmjhFxwpuu9vO4kynRojZXXRgJ3ulf2IbYPQOU=; b=ffCfcM/kcRbg+pXFqornNmn7pT0y2mwLtB5lcfDR6M/CByhXI9jjg1hTOxpW4ED37HjebR PLDv+61tDVsW0Q75ZCBLhP8muFIruYiW6/EI3J+0AxpfeldcejP/KSuZtQ8GNcNr/Rw/3t OHG3E2wwjDRzd2f+dfNSR8e1/oU0vjQ= 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-281-jWs9skGqP8aLkn57za9NmQ-1; Fri, 09 Jun 2023 03:56:49 -0400 X-MC-Unique: jWs9skGqP8aLkn57za9NmQ-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 487698039C9; Fri, 9 Jun 2023 07:56:48 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-92.pek2.redhat.com [10.72.12.92]) by smtp.corp.redhat.com (Postfix) with ESMTP id D0BE820268C7; Fri, 9 Jun 2023 07:56:40 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-arch@vger.kernel.org, linux-mm@kvack.org, arnd@arndb.de, christophe.leroy@csgroup.eu, hch@lst.de, 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, Baoquan He , Gerald Schaefer , Heiko Carstens , Vasily Gorbik , Christian Borntraeger , Sven Schnelle , linux-s390@vger.kernel.org Subject: [PATCH v6 10/19] s390: mm: Convert to GENERIC_IOREMAP Date: Fri, 9 Jun 2023 15:55:19 +0800 Message-Id: <20230609075528.9390-11-bhe@redhat.com> In-Reply-To: <20230609075528.9390-1-bhe@redhat.com> References: <20230609075528.9390-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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=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?1768211685555425345?= X-GMAIL-MSGID: =?utf-8?q?1768211685555425345?= By taking GENERIC_IOREMAP method, the generic generic_ioremap_prot(), generic_iounmap(), and their generic wrapper ioremap_prot(), ioremap() and iounmap() are all visible and available to arch. Arch needs to provide wrapper functions to override the generic versions if there's arch specific handling in its ioremap_prot(), ioremap() or iounmap(). This change will simplify implementation by removing duplicated codes with generic_ioremap_prot() and generic_iounmap(), and has the equivalent functioality as before. Here, add wrapper functions ioremap_prot() and iounmap() for s390's special operation when ioremap() and iounmap(). Signed-off-by: Baoquan He Reviewed-by: Niklas Schnelle Tested-by: Niklas Schnelle 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 Reported-by: kernel test robot Signed-off-by: Baoquan He --- arch/s390/Kconfig | 1 + arch/s390/include/asm/io.h | 21 ++++++++------ arch/s390/pci/pci.c | 57 +++++++------------------------------- 3 files changed, 23 insertions(+), 56 deletions(-) diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig index 6dab9c1be508..e625bb0cc6c7 100644 --- a/arch/s390/Kconfig +++ b/arch/s390/Kconfig @@ -142,6 +142,7 @@ config S390 select GENERIC_SMP_IDLE_THREAD select GENERIC_TIME_VSYSCALL select GENERIC_VDSO_TIME_NS + select GENERIC_IOREMAP if PCI select HAVE_ALIGNED_STRUCT_PAGE if SLUB select HAVE_ARCH_AUDITSYSCALL select HAVE_ARCH_JUMP_LABEL diff --git a/arch/s390/include/asm/io.h b/arch/s390/include/asm/io.h index e3882b012bfa..4453ad7c11ac 100644 --- a/arch/s390/include/asm/io.h +++ b/arch/s390/include/asm/io.h @@ -22,11 +22,18 @@ void unxlate_dev_mem_ptr(phys_addr_t phys, void *addr); #define IO_SPACE_LIMIT 0 -void __iomem *ioremap_prot(phys_addr_t addr, size_t size, unsigned long prot); -void __iomem *ioremap(phys_addr_t addr, size_t size); -void __iomem *ioremap_wc(phys_addr_t addr, size_t size); -void __iomem *ioremap_wt(phys_addr_t addr, size_t size); -void iounmap(volatile void __iomem *addr); +/* + * I/O memory mapping functions. + */ +#define ioremap_prot ioremap_prot +#define iounmap iounmap + +#define _PAGE_IOREMAP pgprot_val(PAGE_KERNEL) + +#define ioremap_wc(addr, size) \ + ioremap_prot((addr), (size), pgprot_val(pgprot_writecombine(PAGE_KERNEL))) +#define ioremap_wt(addr, size) \ + ioremap_prot((addr), (size), pgprot_val(pgprot_writethrough(PAGE_KERNEL))) static inline void __iomem *ioport_map(unsigned long port, unsigned int nr) { @@ -51,10 +58,6 @@ static inline void ioport_unmap(void __iomem *p) #define pci_iomap_wc pci_iomap_wc #define pci_iomap_wc_range pci_iomap_wc_range -#define ioremap ioremap -#define ioremap_wt ioremap_wt -#define ioremap_wc ioremap_wc - #define memcpy_fromio(dst, src, count) zpci_memcpy_fromio(dst, src, count) #define memcpy_toio(dst, src, count) zpci_memcpy_toio(dst, src, count) #define memset_io(dst, val, count) zpci_memset_io(dst, val, count) diff --git a/arch/s390/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 Fri Jun 9 07:55:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 105371 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp789196vqr; Fri, 9 Jun 2023 01:15:47 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5gN0SG5GxfOWhyN2G9cLLU/hYu1R2/8yEnLdKokIsy0qJmRZGSbSzWPx4P4zwPNJkrcRfD X-Received: by 2002:a05:6a00:2d9d:b0:643:aa8d:8cd7 with SMTP id fb29-20020a056a002d9d00b00643aa8d8cd7mr421817pfb.32.1686298547062; Fri, 09 Jun 2023 01:15:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686298547; cv=none; d=google.com; s=arc-20160816; b=xvSfGwGLlEz+J7yEI73jZBEaY5IYYlb6OcaCYZNIGLNYVqSpAwy+tGWSm6IdzjQ29b tqOUtyUGN5mtwnMsFxBJ9MTipCaCZSi1cfSjWXZBNx2nPKwQE55HzXqTRgjmNPwlihg/ iQlXie1OfMPiC6gHfzX6kw5x9tvuovyRNejGUK61HaUXCZzQrgLgJNQPix2ZbDHTaAaH m4bPcI8Bs3YlLwcMIsFVGNonwR/UC4fxybcn8BSiwpJe7qzBGKHEAWbdXoPwyzoShW0a 4JgMalWuPtPBRBAFBQR21Hp3FF9z8GQaiSmLRj3Omo2dx3MkQcwWYxaWSQLQ13p4MDGB d5SA== 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=LUIKuTNwx3aGCN/mpc81rLXKw/yQlIAJox5sUw6Md70=; b=Jdb9dprdyKx8Tip3f8OZcB7LbO/4u4d8Ds5rn6/wT1SVClkF74BqPIsP3JlNdsMmjR dvcCogtzAWevQclb3gf1O0UAaQ/mwMPddVGYHNXbsbHmomnJelyYB9Xbnj2L7MWIyJDZ dJ43zHABFe3w1hbqdgS8xUjWsM4mCV6/XDVrC0/oCilwL+BikZbT6zgHWBtgTeie6N4f n7gh0UCvrCaETAK/5u8RNQmT3J2FqJMZTb4CYmAT8QUjJQOQ+kH29YpTTAqcYPFGJyMv Bt9omuO+VMWWWpy2zwxoFiIYxZvx2+njGjIDwAoz/XjSL07giRwnrlq/W1m27BTktYAj SZpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=QQaoXk5p; 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 n184-20020a6327c1000000b00543a89c95c2si2254107pgn.207.2023.06.09.01.15.32; Fri, 09 Jun 2023 01:15: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=QQaoXk5p; 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 S239024AbjFIIAC (ORCPT + 99 others); Fri, 9 Jun 2023 04:00:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34044 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239993AbjFIH7R (ORCPT ); Fri, 9 Jun 2023 03:59:17 -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 4C80D4239 for ; Fri, 9 Jun 2023 00:57:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686297439; 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=LUIKuTNwx3aGCN/mpc81rLXKw/yQlIAJox5sUw6Md70=; b=QQaoXk5pUhx1ca+IAgr6kAim40HfzPW7r8rVtLI8DDfZ+YdqwO9AC1tGzALe6isZGdKe3d tkBJ77LHOHUWxqEfdh6YSRURFriqWEcwRa3shUbCLXfkObWZdSJwCGmVg43GiOAfOrm6lc OhMQxI2x3JhUAANxJ6TRNc+RcQ92lM4= 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-298-qdGF8u1yOFKOwOjmf_5LtQ-1; Fri, 09 Jun 2023 03:56:57 -0400 X-MC-Unique: qdGF8u1yOFKOwOjmf_5LtQ-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7360385A5BB; Fri, 9 Jun 2023 07:56:56 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-92.pek2.redhat.com [10.72.12.92]) by smtp.corp.redhat.com (Postfix) with ESMTP id E440120268C6; Fri, 9 Jun 2023 07:56:48 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-arch@vger.kernel.org, linux-mm@kvack.org, arnd@arndb.de, christophe.leroy@csgroup.eu, hch@lst.de, 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, Baoquan He , Yoshinori Sato , Rich Felker , linux-sh@vger.kernel.org Subject: [PATCH v6 11/19] sh: add including Date: Fri, 9 Jun 2023 15:55:20 +0800 Message-Id: <20230609075528.9390-12-bhe@redhat.com> In-Reply-To: <20230609075528.9390-1-bhe@redhat.com> References: <20230609075528.9390-1-bhe@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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_H5,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?1768212185332176885?= X-GMAIL-MSGID: =?utf-8?q?1768212185332176885?= Also add macro definitions for port|mm io functions since SuperH has its own implementation in arch/sh/kernel/iomap.c and arch/sh/include/asm/io_noioport.h. These will conflict with the port|mm io function definitions in include/asm-generic/io.h to cause compiling errors like below: ==== CC arch/sh/kernel/asm-offsets.s In file included from ./arch/sh/include/asm/io.h:294, from ./include/linux/io.h:13, ...... from arch/sh/kernel/asm-offsets.c:16: ./include/asm-generic/io.h:792:17: error: conflicting types for ‘ioread8’ 792 | #define ioread8 ioread8 | ^~~~~~~ ./include/asm-generic/io.h:793:18: note: in expansion of macro ‘ioread8’ 793 | static inline u8 ioread8(const volatile void __iomem *addr) | ^~~~~~~ In file included from ./arch/sh/include/asm/io.h:22, from ./include/linux/io.h:13, ...... from arch/sh/kernel/asm-offsets.c:16: ./include/asm-generic/iomap.h:29:21: note: previous declaration of ‘ioread8’ was here 29 | extern unsigned int ioread8(const void __iomem *); ==== Signed-off-by: Baoquan He Cc: Yoshinori Sato Cc: Rich Felker Cc: linux-sh@vger.kernel.org --- v5->v6: split that inclusion of include/asm-generic/io.h and redefining of the helpers from the old patch 11 into this prep patch - Christoph 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 Fri Jun 9 07:55:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 105364 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp786611vqr; Fri, 9 Jun 2023 01:09:36 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6+f/v8Dv0AkuGfcOh/nPuFTKqRxJnPOFsPH9qw0iWx5kJlNJnt+cviHMsheGCTQ8IqDeDL X-Received: by 2002:a17:902:9a46:b0:1aa:ff24:f8f0 with SMTP id x6-20020a1709029a4600b001aaff24f8f0mr416241plv.4.1686298175905; Fri, 09 Jun 2023 01:09:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686298175; cv=none; d=google.com; s=arc-20160816; b=kIE0OKpAue0qk0E4mUl8nnfVDc6qut++10ZLyXOcWfhoos5H5NIpCMI9vqn17Y7co4 GHUVar9GgRoEU3YrEpceIIiS+5iMsVlTJY1UR6uROxM0XOaQ/oOQcCsoUSkbHXAA9otP THcd4C9gGUhJrIFpEuOHQp+O8j+sjCHZw/s7Ux8IP50Js6/mA0Dv2ussWdGfpBXQjnMw zo1tw5mfew7d2YCr1YvaDs9kNz1nIOcbJHIb0n9L1PTrj43Q1dQZEbTn4uV9EvKSDupA FaK2D9j4bvqkfTraq5ryqfvAqWIxfYN/VxUrxL/GO4PB6+u8zA2YyADUo7RzC3nErL1Z mihg== 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=J2JqJ5DVfD1RBef7ys9lCToVJCiVC3QaC6lHIm4BgJc=; b=s9dPiE4vONLDnke+lQSNRagZNQ3SaPkxkguvvoJ31qVsbWH1G47eDKxjw7yhvKTaVh Xc+Ua1juvCWeYfvDBD2bA3awwMOM2gYPUbaf6iS5kEtTBGBfkSxXIsEuild7h6jGgqXH 3bXkZILfKr47H+4i6rLsgzh/ErPupDL9CYvtoQS7h9RkHC0HY1m7ZLgqdKf5NClEdwTK agQS4VEFtV9DmcN3e12DPcVQmcJNpSxKeohcYu/q6rN5zCk1ad1xIhVWM5V30DJl2OOK cmzK/62kWb89YhiLZMii2kK4oTmA8sRYVDzHtAB993xJP+RCpGNrr2iAtiVOZTYdYgaP 83gQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=a5RPnjd8; 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 lk8-20020a17090308c800b001b042e93c11si2310633plb.262.2023.06.09.01.09.19; Fri, 09 Jun 2023 01:09:35 -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=a5RPnjd8; 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 S239070AbjFIH7a (ORCPT + 99 others); Fri, 9 Jun 2023 03:59:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33678 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238780AbjFIH6n (ORCPT ); Fri, 9 Jun 2023 03:58:43 -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 9739B30F1 for ; Fri, 9 Jun 2023 00:57:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686297429; 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=J2JqJ5DVfD1RBef7ys9lCToVJCiVC3QaC6lHIm4BgJc=; b=a5RPnjd87qcS2UJ9TpRXeniEvC9NZ72tDGmpclXXVvsoGuW6kxV9B1cFHN+tENmA3CUaos eeB2pqWJkCDO2bvXEsE5RoDjqROqDjAzHt8gNDhkwDfazAohGXZyZmRRMra2IetFnY+8sZ OzGpoqH5H46CWR8E20/G4wJCrOHECW8= 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-425-63ItICqVMnCnNe_-eICvug-1; Fri, 09 Jun 2023 03:57:04 -0400 X-MC-Unique: 63ItICqVMnCnNe_-eICvug-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A30D8185A78F; Fri, 9 Jun 2023 07:57:03 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-92.pek2.redhat.com [10.72.12.92]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1D51720268C6; Fri, 9 Jun 2023 07:56:56 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-arch@vger.kernel.org, linux-mm@kvack.org, arnd@arndb.de, christophe.leroy@csgroup.eu, hch@lst.de, 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, Baoquan He , Yoshinori Sato , Rich Felker , linux-sh@vger.kernel.org Subject: [PATCH v6 12/19] sh: mm: Convert to GENERIC_IOREMAP Date: Fri, 9 Jun 2023 15:55:21 +0800 Message-Id: <20230609075528.9390-13-bhe@redhat.com> In-Reply-To: <20230609075528.9390-1-bhe@redhat.com> References: <20230609075528.9390-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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=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?1768211795785555274?= X-GMAIL-MSGID: =?utf-8?q?1768211795785555274?= By taking GENERIC_IOREMAP method, the generic generic_ioremap_prot(), generic_iounmap(), and their generic wrapper ioremap_prot(), ioremap() and iounmap() are all visible and available to arch. Arch needs to provide wrapper functions to override the generic versions if there's arch specific handling in its ioremap_prot(), ioremap() or iounmap(). This change will simplify implementation by removing duplicated codes with generic_ioremap_prot() and generic_iounmap(), and has the equivalent functioality as before. Here, add wrapper functions ioremap_prot() and iounmap() for SuperH's special operation when ioremap() and iounmap(). Cc: Yoshinori Sato Cc: Rich Felker Cc: linux-sh@vger.kernel.org Signed-off-by: Baoquan He --- v5->v6: Based on the previous prep patch, this only focuses on converting to GENERIC_IOREMAP for SuperH - Christoph arch/sh/Kconfig | 1 + arch/sh/include/asm/io.h | 40 +++++-------------------- arch/sh/mm/ioremap.c | 65 +++++++--------------------------------- 3 files changed, 20 insertions(+), 86 deletions(-) diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig index 9652d367fc37..f326985e46e0 100644 --- a/arch/sh/Kconfig +++ b/arch/sh/Kconfig @@ -28,6 +28,7 @@ config SUPERH select GENERIC_SMP_IDLE_THREAD select GUP_GET_PXX_LOW_HIGH if X2TLB select HAS_IOPORT if HAS_IOPORT_MAP + select GENERIC_IOREMAP if MMU select HAVE_ARCH_AUDITSYSCALL select HAVE_ARCH_KGDB select HAVE_ARCH_SECCOMP_FILTER diff --git a/arch/sh/include/asm/io.h b/arch/sh/include/asm/io.h index 270e7952950c..b3a26b405c8d 100644 --- a/arch/sh/include/asm/io.h +++ b/arch/sh/include/asm/io.h @@ -266,40 +266,16 @@ unsigned long long poke_real_address_q(unsigned long long addr, #endif #ifdef CONFIG_MMU -void iounmap(void __iomem *addr); -void __iomem *__ioremap_caller(phys_addr_t offset, unsigned long size, - pgprot_t prot, void *caller); - -static inline void __iomem *ioremap(phys_addr_t offset, unsigned long size) -{ - return __ioremap_caller(offset, size, PAGE_KERNEL_NOCACHE, - __builtin_return_address(0)); -} - -static inline void __iomem * -ioremap_cache(phys_addr_t offset, unsigned long size) -{ - return __ioremap_caller(offset, size, PAGE_KERNEL, - __builtin_return_address(0)); -} -#define ioremap_cache ioremap_cache - -#ifdef CONFIG_HAVE_IOREMAP_PROT -static inline void __iomem *ioremap_prot(phys_addr_t offset, unsigned long size, - unsigned long flags) -{ - return __ioremap_caller(offset, size, __pgprot(flags), - __builtin_return_address(0)); -} -#endif /* CONFIG_HAVE_IOREMAP_PROT */ +/* + * I/O memory mapping functions. + */ +#define ioremap_prot ioremap_prot +#define iounmap iounmap -#else /* CONFIG_MMU */ -static inline void __iomem *ioremap(phys_addr_t offset, size_t size) -{ - return (void __iomem *)(unsigned long)offset; -} +#define _PAGE_IOREMAP pgprot_val(PAGE_KERNEL_NOCACHE) -static inline void iounmap(volatile void __iomem *addr) { } +#define ioremap_cache(addr, size) \ + ioremap_prot((addr), (size), pgprot_val(PAGE_KERNEL)) #endif /* CONFIG_MMU */ #define ioremap_uc ioremap diff --git a/arch/sh/mm/ioremap.c b/arch/sh/mm/ioremap.c index 21342581144d..c33b3daa4ad1 100644 --- a/arch/sh/mm/ioremap.c +++ b/arch/sh/mm/ioremap.c @@ -72,22 +72,11 @@ __ioremap_29bit(phys_addr_t offset, unsigned long size, pgprot_t prot) #define __ioremap_29bit(offset, size, prot) NULL #endif /* CONFIG_29BIT */ -/* - * Remap an arbitrary physical address space into the kernel virtual - * address space. Needed when the kernel wants to access high addresses - * directly. - * - * NOTE! We need to allow non-page-aligned mappings too: we will obviously - * have to convert them into an offset in a page-aligned mapping, but the - * caller shouldn't need to know that small detail. - */ -void __iomem * __ref -__ioremap_caller(phys_addr_t phys_addr, unsigned long size, - pgprot_t pgprot, void *caller) +void __iomem *ioremap_prot(phys_addr_t phys_addr, size_t size, + unsigned long prot) { - struct vm_struct *area; - unsigned long offset, last_addr, addr, orig_addr; void __iomem *mapped; + pgprot_t pgprot = __pgprot(prot); mapped = __ioremap_trapped(phys_addr, size); if (mapped) @@ -97,11 +86,6 @@ __ioremap_caller(phys_addr_t phys_addr, unsigned long size, if (mapped) return mapped; - /* Don't allow wraparound or zero size */ - last_addr = phys_addr + size - 1; - if (!size || last_addr < phys_addr) - return NULL; - /* * If we can't yet use the regular approach, go the fixmap route. */ @@ -112,34 +96,14 @@ __ioremap_caller(phys_addr_t phys_addr, unsigned long size, * First try to remap through the PMB. * PMB entries are all pre-faulted. */ - mapped = pmb_remap_caller(phys_addr, size, pgprot, caller); + mapped = pmb_remap_caller(phys_addr, size, pgprot, + __builtin_return_address(0)); if (mapped && !IS_ERR(mapped)) return mapped; - /* - * Mappings have to be page-aligned - */ - offset = phys_addr & ~PAGE_MASK; - phys_addr &= PAGE_MASK; - size = PAGE_ALIGN(last_addr+1) - phys_addr; - - /* - * Ok, go for it.. - */ - area = get_vm_area_caller(size, VM_IOREMAP, caller); - if (!area) - return NULL; - area->phys_addr = phys_addr; - orig_addr = addr = (unsigned long)area->addr; - - if (ioremap_page_range(addr, addr + size, phys_addr, pgprot)) { - vunmap((void *)orig_addr); - return NULL; - } - - return (void __iomem *)(offset + (char *)orig_addr); + return generic_ioremap_prot(phys_addr, size, pgprot); } -EXPORT_SYMBOL(__ioremap_caller); +EXPORT_SYMBOL(ioremap_prot); /* * Simple checks for non-translatable mappings. @@ -158,10 +122,9 @@ static inline int iomapping_nontranslatable(unsigned long offset) return 0; } -void iounmap(void __iomem *addr) +void iounmap(volatile void __iomem *addr) { unsigned long vaddr = (unsigned long __force)addr; - struct vm_struct *p; /* * Nothing to do if there is no translatable mapping. @@ -172,21 +135,15 @@ void iounmap(void __iomem *addr) /* * There's no VMA if it's from an early fixed mapping. */ - if (iounmap_fixed(addr) == 0) + if (iounmap_fixed((void __iomem *)addr) == 0) return; /* * If the PMB handled it, there's nothing else to do. */ - if (pmb_unmap(addr) == 0) + if (pmb_unmap((void __iomem *)addr) == 0) return; - p = remove_vm_area((void *)(vaddr & PAGE_MASK)); - if (!p) { - printk(KERN_ERR "%s: bad address %p\n", __func__, addr); - return; - } - - kfree(p); + generic_iounmap(addr); } EXPORT_SYMBOL(iounmap); From patchwork Fri Jun 9 07:55:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 105351 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp782875vqr; Fri, 9 Jun 2023 01:01:49 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7pQ1go2beOsOElpEAr6MR+TNADFqu0if0JB+8En7Lh9Z5vo0922WeMaAnZDF4l5G8L24CF X-Received: by 2002:a05:6a21:99aa:b0:118:eeef:2a25 with SMTP id ve42-20020a056a2199aa00b00118eeef2a25mr670344pzb.34.1686297709294; Fri, 09 Jun 2023 01:01:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686297709; cv=none; d=google.com; s=arc-20160816; b=nInUdV4Ch42a9IvY/0t2zE1UT8RnE46ZBlbVnwpL6UBmgHBwsNTPPMv2Fqhm73yWK2 NHfkPOC4icaCe2vpYaR4KJOndL5TPTHKKmD+lPTFGPWb5ERuvUPmblTZzxFPNSdO2U9i SWwwCGhBDG1hbWxgS20cGIxbkOmrBuQDrUGLP/V17pHuUt11UTsEXc7X4jiJEL3ebzFr WtwpU3VL4VSbHsnr5wOgWzU6QwNvX9IgFLo3SPw2E0e1PYM6efiLEItfGtf2K7Kx0DrN NtlnFcwRWmaAehlxd4aLcJfIVTZV3Y7arzk0hkp5ha8fGCpP/mokbxewfNo4Ip9yus4X WfLQ== 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=8xAEmv+klZL2q1puNU7BpopKMmAERiOcnE6W7aPMkiU=; b=hp1WAf/tgpNZIAMYkuNhQxKF0EypUX693lLRrdyhTZie+dxcUBUxbXVTuvNmhAexqG KiRaT34oSHOT5ZI3w4QMMl7cUEYJzcxzdK6pLCPT+zbSu6nr6J5gWOVdB+pDYBb2HuyG TdpQ/zy2rJAOLy+i+rObjsNpzFhjgtBxEnLyGM0VS32anSrLSZEwxWDpsnSWveJl5z8m 8Z10eZPOED2+vwnu1hX6fT3FKVun5bco7PSni3NqJOIYH5b9ikfrzacomUPSyi0M0ryf A/qIcsrDKVUDStnQ3Jvehc8NoTThYqTxknCvd/pDs5Rx7vT90EEs0tfITRWPzmb45nUc xT2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=eEB+oWLg; 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 a27-20020a63705b000000b0053f27c5efe4si2258413pgn.857.2023.06.09.01.01.34; Fri, 09 Jun 2023 01:01:49 -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=eEB+oWLg; 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 S239622AbjFIIAL (ORCPT + 99 others); Fri, 9 Jun 2023 04:00:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34056 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239708AbjFIH7l (ORCPT ); Fri, 9 Jun 2023 03:59:41 -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 BE6C53C10 for ; Fri, 9 Jun 2023 00:57:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686297443; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8xAEmv+klZL2q1puNU7BpopKMmAERiOcnE6W7aPMkiU=; b=eEB+oWLgIeSIS79dR/T7Cn257So95HmunI7F4LTe+KWgXd5/8d4kQBx2cAZOfN+myMrws1 i360/sF6IXHBT/E+n7LfMJZDFQHByrBpMKABqYw2YkEmO+PmJkLqiabYRevODsCiTdOKYA nZpQwYYnZ+xpAlQ3NFvry/YK9BSFnDo= 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-578-c42ZBneGMXScmgFC4Vjc7g-1; Fri, 09 Jun 2023 03:57:11 -0400 X-MC-Unique: c42ZBneGMXScmgFC4Vjc7g-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 94D0B1C060D0; Fri, 9 Jun 2023 07:57:10 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-92.pek2.redhat.com [10.72.12.92]) by smtp.corp.redhat.com (Postfix) with ESMTP id 48A5820268C6; Fri, 9 Jun 2023 07:57:03 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-arch@vger.kernel.org, linux-mm@kvack.org, arnd@arndb.de, christophe.leroy@csgroup.eu, hch@lst.de, 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, Baoquan He , Chris Zankel , Max Filippov Subject: [PATCH v6 13/19] xtensa: mm: Convert to GENERIC_IOREMAP Date: Fri, 9 Jun 2023 15:55:22 +0800 Message-Id: <20230609075528.9390-14-bhe@redhat.com> In-Reply-To: <20230609075528.9390-1-bhe@redhat.com> References: <20230609075528.9390-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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_H5,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?1768211306856419359?= X-GMAIL-MSGID: =?utf-8?q?1768211306856419359?= By taking GENERIC_IOREMAP method, the generic generic_ioremap_prot(), generic_iounmap(), and their generic wrapper ioremap_prot(), ioremap() and iounmap() are all visible and available to arch. Arch needs to provide wrapper functions to override the generic versions if there's arch specific handling in its ioremap_prot(), ioremap() or iounmap(). This change will simplify implementation by removing duplicated codes with generic_ioremap_prot() and generic_iounmap(), and has the equivalent functioality as before. Here, add wrapper functions ioremap_prot(), ioremap() and iounmap() for xtensa's special operation when ioremap() and iounmap(). Signed-off-by: Baoquan He Reviewed-by: Christoph Hellwig Reviewed-by: Mike Rapoport (IBM) Cc: Chris Zankel Cc: Max Filippov --- arch/xtensa/Kconfig | 1 + arch/xtensa/include/asm/io.h | 32 ++++++++------------ arch/xtensa/mm/ioremap.c | 58 +++++++++--------------------------- 3 files changed, 27 insertions(+), 64 deletions(-) diff --git a/arch/xtensa/Kconfig b/arch/xtensa/Kconfig index 3c6e5471f025..474cbbff3e6c 100644 --- a/arch/xtensa/Kconfig +++ b/arch/xtensa/Kconfig @@ -29,6 +29,7 @@ config XTENSA select GENERIC_LIB_UCMPDI2 select GENERIC_PCI_IOMAP select GENERIC_SCHED_CLOCK + select GENERIC_IOREMAP if MMU select HAVE_ARCH_AUDITSYSCALL select HAVE_ARCH_JUMP_LABEL if !XIP_KERNEL select HAVE_ARCH_KASAN if MMU && !XIP_KERNEL diff --git a/arch/xtensa/include/asm/io.h b/arch/xtensa/include/asm/io.h index a5b707e1c0f4..934e58399c8c 100644 --- a/arch/xtensa/include/asm/io.h +++ b/arch/xtensa/include/asm/io.h @@ -16,6 +16,7 @@ #include #include #include +#include #include @@ -24,22 +25,24 @@ #define PCI_IOBASE ((void __iomem *)XCHAL_KIO_BYPASS_VADDR) #ifdef CONFIG_MMU - -void __iomem *xtensa_ioremap_nocache(unsigned long addr, unsigned long size); -void __iomem *xtensa_ioremap_cache(unsigned long addr, unsigned long size); -void xtensa_iounmap(volatile void __iomem *addr); - /* - * Return the virtual address for the specified bus memory. + * I/O memory mapping functions. */ +void __iomem *ioremap_prot(phys_addr_t phys_addr, size_t size, + unsigned long prot); +#define ioremap_prot ioremap_prot +#define iounmap iounmap + static inline void __iomem *ioremap(unsigned long offset, unsigned long size) { if (offset >= XCHAL_KIO_PADDR && offset - XCHAL_KIO_PADDR < XCHAL_KIO_SIZE) return (void*)(offset-XCHAL_KIO_PADDR+XCHAL_KIO_BYPASS_VADDR); else - return xtensa_ioremap_nocache(offset, size); + return ioremap_prot(offset, size, + pgprot_val(pgprot_noncached(PAGE_KERNEL))); } +#define ioremap ioremap static inline void __iomem *ioremap_cache(unsigned long offset, unsigned long size) @@ -48,21 +51,10 @@ static inline void __iomem *ioremap_cache(unsigned long offset, && offset - XCHAL_KIO_PADDR < XCHAL_KIO_SIZE) return (void*)(offset-XCHAL_KIO_PADDR+XCHAL_KIO_CACHED_VADDR); else - return xtensa_ioremap_cache(offset, size); -} -#define ioremap_cache ioremap_cache + return ioremap_prot(offset, size, pgprot_val(PAGE_KERNEL)); -static inline void iounmap(volatile void __iomem *addr) -{ - unsigned long va = (unsigned long) addr; - - if (!(va >= XCHAL_KIO_CACHED_VADDR && - va - XCHAL_KIO_CACHED_VADDR < XCHAL_KIO_SIZE) && - !(va >= XCHAL_KIO_BYPASS_VADDR && - va - XCHAL_KIO_BYPASS_VADDR < XCHAL_KIO_SIZE)) - xtensa_iounmap(addr); } - +#define ioremap_cache ioremap_cache #endif /* CONFIG_MMU */ #include diff --git a/arch/xtensa/mm/ioremap.c b/arch/xtensa/mm/ioremap.c index a400188c16b9..8ca660b7ab49 100644 --- a/arch/xtensa/mm/ioremap.c +++ b/arch/xtensa/mm/ioremap.c @@ -6,60 +6,30 @@ */ #include -#include #include #include #include -static void __iomem *xtensa_ioremap(unsigned long paddr, unsigned long size, - pgprot_t prot) +void __iomem *ioremap_prot(phys_addr_t phys_addr, size_t size, + unsigned long prot) { - unsigned long offset = paddr & ~PAGE_MASK; - unsigned long pfn = __phys_to_pfn(paddr); - struct vm_struct *area; - unsigned long vaddr; - int err; - - paddr &= PAGE_MASK; - + unsigned long pfn = __phys_to_pfn((phys_addr)); WARN_ON(pfn_valid(pfn)); - size = PAGE_ALIGN(offset + size); - - area = get_vm_area(size, VM_IOREMAP); - if (!area) - return NULL; - - vaddr = (unsigned long)area->addr; - area->phys_addr = paddr; - - err = ioremap_page_range(vaddr, vaddr + size, paddr, prot); - - if (err) { - vunmap((void *)vaddr); - return NULL; - } - - flush_cache_vmap(vaddr, vaddr + size); - return (void __iomem *)(offset + vaddr); -} - -void __iomem *xtensa_ioremap_nocache(unsigned long addr, unsigned long size) -{ - return xtensa_ioremap(addr, size, pgprot_noncached(PAGE_KERNEL)); + return generic_ioremap_prot(phys_addr, size, __pgprot(prot)); } -EXPORT_SYMBOL(xtensa_ioremap_nocache); +EXPORT_SYMBOL(ioremap_prot); -void __iomem *xtensa_ioremap_cache(unsigned long addr, unsigned long size) +void iounmap(volatile void __iomem *addr) { - return xtensa_ioremap(addr, size, PAGE_KERNEL); -} -EXPORT_SYMBOL(xtensa_ioremap_cache); + unsigned long va = (unsigned long) addr; -void xtensa_iounmap(volatile void __iomem *io_addr) -{ - void *addr = (void *)(PAGE_MASK & (unsigned long)io_addr); + if ((va >= XCHAL_KIO_CACHED_VADDR && + va - XCHAL_KIO_CACHED_VADDR < XCHAL_KIO_SIZE) || + (va >= XCHAL_KIO_BYPASS_VADDR && + va - XCHAL_KIO_BYPASS_VADDR < XCHAL_KIO_SIZE)) + return; - vunmap(addr); + generic_iounmap(addr); } -EXPORT_SYMBOL(xtensa_iounmap); +EXPORT_SYMBOL(iounmap); From patchwork Fri Jun 9 07:55:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 105372 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp789256vqr; Fri, 9 Jun 2023 01:15:54 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7h1aXl9/BfQ+aktUDZYQc0tgtha+tPVDiM3yXIgk7XiQ1Jpz2Wn9BLNdwhKkBbzaoEXI1g X-Received: by 2002:a05:6a00:124f:b0:65d:d5cd:6f17 with SMTP id u15-20020a056a00124f00b0065dd5cd6f17mr491333pfi.24.1686298554214; Fri, 09 Jun 2023 01:15:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686298554; cv=none; d=google.com; s=arc-20160816; b=BTamFKq7k2fnMqERrC3KQlErrVTySjlilV5gfdoy79nDlXEX35xr3wznNh+GAmbD6R pFyR2yfvT79L/kCfhgUCP6bjIgaiLh3WOvpxKxAH4mpeNUsG+EfpMsB5cxeVlzYNHE7J +Xt2QaGJ3RsqoV8OJ6oSzI22hIoz8M2VELKHYjjBNI4pFv3gHnPtScHCEelOD5w5C5yM vxNCybaRrEUBqMVvEK6LOIPLi44owM2tfInmOOP2kFV8RvJ9Y3EAeeD1pKkhTVvgRzbT d+5IqNk1XIUsWj6RGwGmfCODOxmgwQh9wGZpKPk15TMIi//lfwPsIc7rHVbE2V++iJ3Y xnDg== 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=LUPq0cnzOLgrLVKYAlQ346H5looYZtvjQRVHWSAi6lQ=; b=s6fR4m7a76IN8DRDO2dTo4jlsP1KNQ935EuguQfmxlAEnhlSjloEqB5vwPMoscS+h+ T4eSFO07MNYEUlYj98Uw4e14NVQdjQNxr6iTkP2dT30mDcEnSCXsmKT8YXel+KPj1f+7 T1n+YQ1KCjs/oJgqtHxyS2e3tfUNODpXUMjYIhOsuBnIq0KEKuFJ1/v8KmKgTDJ0pzUo SdajXIqGWNyGBYM/j0MMpNzUKDgIewZX2BkNBfz7AvuWJxn0o4rNFNjxaExrlkPoSyVi geM2pNx/5xoFOOCY54Okx3ufkL59BQsEU5w6/RQ0SZhLeW5yH/cQ64u/AWS8ht2MUgjI ch7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=bcEoN44B; 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 k137-20020a636f8f000000b00543a6b76431si2229193pgc.326.2023.06.09.01.15.41; Fri, 09 Jun 2023 01:15:54 -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=bcEoN44B; 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 S239561AbjFIIAH (ORCPT + 99 others); Fri, 9 Jun 2023 04:00:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34182 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238777AbjFIH7Y (ORCPT ); Fri, 9 Jun 2023 03:59:24 -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 94AA32D7E for ; Fri, 9 Jun 2023 00:57:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686297441; 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=LUPq0cnzOLgrLVKYAlQ346H5looYZtvjQRVHWSAi6lQ=; b=bcEoN44BzapxqfHywiaU1ul9icxocTgff4nFCPyYYv7kQO3alncT7LiImHZ+SJckg0nkDa 6ObskitFUUZMCuOkw8b0eqx1nRl8vjNbJyVcYvlUAAP8CF1jVNdhtQ1X4aB8OlC4NcWLxL r+l9syIw3OGHAiAlKc8lZIN3rVd10ZE= 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-329-H4pi8mw1NUO8f6MFV9ToJw-1; Fri, 09 Jun 2023 03:57:18 -0400 X-MC-Unique: H4pi8mw1NUO8f6MFV9ToJw-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6E9BA3C0CEFB; Fri, 9 Jun 2023 07:57:17 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-92.pek2.redhat.com [10.72.12.92]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3FD2C20268C6; Fri, 9 Jun 2023 07:57:10 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-arch@vger.kernel.org, linux-mm@kvack.org, arnd@arndb.de, christophe.leroy@csgroup.eu, hch@lst.de, 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, Baoquan He , "James E.J. Bottomley" , linux-parisc@vger.kernel.org Subject: [PATCH v6 14/19] parisc: mm: Convert to GENERIC_IOREMAP Date: Fri, 9 Jun 2023 15:55:23 +0800 Message-Id: <20230609075528.9390-15-bhe@redhat.com> In-Reply-To: <20230609075528.9390-1-bhe@redhat.com> References: <20230609075528.9390-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768212192833098241?= X-GMAIL-MSGID: =?utf-8?q?1768212192833098241?= By taking GENERIC_IOREMAP method, the generic generic_ioremap_prot(), generic_iounmap(), and their generic wrapper ioremap_prot(), ioremap() and iounmap() are all visible and available to arch. Arch needs to provide wrapper functions to override the generic versions if there's arch specific handling in its ioremap_prot(), ioremap() or iounmap(). This change will simplify implementation by removing duplicated codes with generic_ioremap_prot() and generic_iounmap(), and has the equivalent functioality as before. Here, add wrapper function ioremap_prot() for parisc's special operation when iounmap(). Signed-off-by: Baoquan He Reviewed-by: Christoph Hellwig Cc: "James E.J. Bottomley" Cc: Helge Deller Cc: linux-parisc@vger.kernel.org Acked-by: Helge Deller # parisc --- v5->v6: Remove the stale paragraph related to ARCH_HAS_IOREMAP_WC adding in log - Mike arch/parisc/Kconfig | 1 + arch/parisc/include/asm/io.h | 15 ++++++--- arch/parisc/mm/ioremap.c | 62 +++--------------------------------- 3 files changed, 15 insertions(+), 63 deletions(-) diff --git a/arch/parisc/Kconfig b/arch/parisc/Kconfig index 967bde65dd0e..315cc42b1a2c 100644 --- a/arch/parisc/Kconfig +++ b/arch/parisc/Kconfig @@ -36,6 +36,7 @@ config PARISC select GENERIC_ATOMIC64 if !64BIT select GENERIC_IRQ_PROBE select GENERIC_PCI_IOMAP + select GENERIC_IOREMAP select ARCH_HAVE_NMI_SAFE_CMPXCHG select GENERIC_SMP_IDLE_THREAD select GENERIC_ARCH_TOPOLOGY if SMP diff --git a/arch/parisc/include/asm/io.h b/arch/parisc/include/asm/io.h index c05e781be2f5..366537042465 100644 --- a/arch/parisc/include/asm/io.h +++ b/arch/parisc/include/asm/io.h @@ -125,12 +125,17 @@ static inline void gsc_writeq(unsigned long long val, unsigned long addr) /* * The standard PCI ioremap interfaces */ -void __iomem *ioremap(unsigned long offset, unsigned long size); -#define ioremap_wc ioremap -#define ioremap_uc ioremap -#define pci_iounmap pci_iounmap +#define ioremap_prot ioremap_prot + +#define _PAGE_IOREMAP (_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | \ + _PAGE_ACCESSED | _PAGE_NO_CACHE) -extern void iounmap(const volatile void __iomem *addr); +#define ioremap_wc(addr, size) \ + ioremap_prot((addr), (size), _PAGE_IOREMAP) +#define ioremap_uc(addr, size) \ + ioremap_prot((addr), (size), _PAGE_IOREMAP) + +#define pci_iounmap pci_iounmap void memset_io(volatile void __iomem *addr, unsigned char val, int count); void memcpy_fromio(void *dst, const volatile void __iomem *src, int count); diff --git a/arch/parisc/mm/ioremap.c b/arch/parisc/mm/ioremap.c index 345ff0b66499..fd996472dfe7 100644 --- a/arch/parisc/mm/ioremap.c +++ b/arch/parisc/mm/ioremap.c @@ -13,25 +13,9 @@ #include #include -/* - * Generic mapping function (not visible outside): - */ - -/* - * Remap an arbitrary physical address space into the kernel virtual - * address space. - * - * NOTE! We need to allow non-page-aligned mappings too: we will obviously - * have to convert them into an offset in a page-aligned mapping, but the - * caller shouldn't need to know that small detail. - */ -void __iomem *ioremap(unsigned long phys_addr, unsigned long size) +void __iomem *ioremap_prot(phys_addr_t phys_addr, size_t size, + unsigned long prot) { - void __iomem *addr; - struct vm_struct *area; - unsigned long offset, last_addr; - pgprot_t pgprot; - #ifdef CONFIG_EISA unsigned long end = phys_addr + size - 1; /* Support EISA addresses */ @@ -40,11 +24,6 @@ void __iomem *ioremap(unsigned long phys_addr, unsigned long size) phys_addr |= F_EXTEND(0xfc000000); #endif - /* Don't allow wraparound or zero size */ - last_addr = phys_addr + size - 1; - if (!size || last_addr < phys_addr) - return NULL; - /* * Don't allow anybody to remap normal RAM that we're using.. */ @@ -62,39 +41,6 @@ void __iomem *ioremap(unsigned long phys_addr, unsigned long size) } } - pgprot = __pgprot(_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | - _PAGE_ACCESSED | _PAGE_NO_CACHE); - - /* - * Mappings have to be page-aligned - */ - offset = phys_addr & ~PAGE_MASK; - phys_addr &= PAGE_MASK; - size = PAGE_ALIGN(last_addr + 1) - phys_addr; - - /* - * Ok, go for it.. - */ - area = get_vm_area(size, VM_IOREMAP); - if (!area) - return NULL; - - addr = (void __iomem *) area->addr; - if (ioremap_page_range((unsigned long)addr, (unsigned long)addr + size, - phys_addr, pgprot)) { - vunmap(addr); - return NULL; - } - - return (void __iomem *) (offset + (char __iomem *)addr); -} -EXPORT_SYMBOL(ioremap); - -void iounmap(const volatile void __iomem *io_addr) -{ - unsigned long addr = (unsigned long)io_addr & PAGE_MASK; - - if (is_vmalloc_addr((void *)addr)) - vunmap((void *)addr); + return generic_ioremap_prot(phys_addr, size, __pgprot(prot)); } -EXPORT_SYMBOL(iounmap); +EXPORT_SYMBOL(ioremap_prot); From patchwork Fri Jun 9 07:55:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 105358 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp785739vqr; Fri, 9 Jun 2023 01:07:32 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7P8gx+lpp+aoRqUM2DbYJ8rYHybpwysgOwibW6Umldr9NxSmS1SSXb6zsnwqOpyawNGr/b X-Received: by 2002:a05:6a20:d387:b0:10b:2f5a:83af with SMTP id iq7-20020a056a20d38700b0010b2f5a83afmr340650pzb.16.1686298052278; Fri, 09 Jun 2023 01:07:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686298052; cv=none; d=google.com; s=arc-20160816; b=KPEPqF7oRoyDrBA56DrENUAyV8w7d8jjkQmJaBXagXU+ghjXSFdg8p8lJF6asoz33v Pcn6Dn4hVl8YZgj/AHwWb08NTQDtfL3VlBY7i8MhbBiOoQBLvqcv9cN0rN5HquJWeRPV z6BJlj3Ge80D/P17N/sd/tMagvU2L+qSBAbtJPf8r0m43ry2aj6DDhIl6Vr6cVPUiwPA zRycbBm0l7IhNU0quq47YlcebTCbRueTVyrFvzZ/d9HeoRWAJmdMngyfKDrQ2vlZcd6A GMect8ynq1uDYGakdtLUXqDzn3umNutGdhBXtfFK7fbRiXantIPKONFizNGUQEjSQsRR plug== 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=pRjmDB/MhJX2uAhXZR6PcmrnbkF0aNZomeUUr4ZAM3o=; b=yWMUI0sv72DqOTeASeYC9ozIgLbwz46UOppRvU5t1pLOU3TU9WojKtUcjgMEjL5Tdt EKoBzVKtYjlSo3C0lD15ZPHUbNcP3BieFiuQsfLmk/rQdaCaPcer0RzaeFxXMMoWCVmj us8q1iueEW6XwW07MZNzWvWKZaDXazsxDY3qG92P37mp2sPEJ/gH6bK2blGbyfYLLaoR XWrtdoo3G2PEzH3McoiD3HyA8XLUSULw+VJlpF7l6UW82ZHd8p0mXqgjGeLDdMXnwged I6lYJgWkhE1vDpgew/ZOHA9Uq6cQy1PJ+kIgigFhpkP473TflnV/bl4poWdQudoXevA9 8uVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=DoDkc7SB; 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 t21-20020aa79475000000b0064f400fcb99si2132380pfq.148.2023.06.09.01.07.17; Fri, 09 Jun 2023 01:07:32 -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=DoDkc7SB; 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 S239742AbjFIIAg (ORCPT + 99 others); Fri, 9 Jun 2023 04:00:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33526 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239841AbjFIH7t (ORCPT ); Fri, 9 Jun 2023 03:59:49 -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 1B6FF3C2F for ; Fri, 9 Jun 2023 00:57:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686297451; 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=pRjmDB/MhJX2uAhXZR6PcmrnbkF0aNZomeUUr4ZAM3o=; b=DoDkc7SBlIINeMaGw76OfpYjJfkTLUaAfFW8oe32iqC4v+EjPa3OmcGhYvYkmMD11PTiu7 E28ZuWccwKguhfumPk23avaM/tdAP1/Y8MGptzJ7Hd0mklMLsVh9ARqZ362vVQznymRXQ4 URpQSbPhq1OddjmLf+sPAUmqszLqp9c= 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-437-Rqd3XGSRMJmpF0VEV5s9pg-1; Fri, 09 Jun 2023 03:57:24 -0400 X-MC-Unique: Rqd3XGSRMJmpF0VEV5s9pg-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id AEC4280120A; Fri, 9 Jun 2023 07:57:23 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-92.pek2.redhat.com [10.72.12.92]) by smtp.corp.redhat.com (Postfix) with ESMTP id 244B620268C6; Fri, 9 Jun 2023 07:57:17 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-arch@vger.kernel.org, linux-mm@kvack.org, arnd@arndb.de, christophe.leroy@csgroup.eu, hch@lst.de, 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, Baoquan He Subject: [PATCH v6 15/19] mm/ioremap: Consider IOREMAP space in generic ioremap Date: Fri, 9 Jun 2023 15:55:24 +0800 Message-Id: <20230609075528.9390-16-bhe@redhat.com> In-Reply-To: <20230609075528.9390-1-bhe@redhat.com> References: <20230609075528.9390-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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=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?1768211666313863280?= X-GMAIL-MSGID: =?utf-8?q?1768211666313863280?= 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 --- v5->v6: Add definition of IOREMAP_START|END in mm/ioremap.c so that we can call __get_vm_area_caller() for all ARCH-es - Christoph 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 Fri Jun 9 07:55:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 105352 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp783026vqr; Fri, 9 Jun 2023 01:02:06 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6BPHJ4u3czGsXxntvHrUlfpW4t3EdvduHnUeCMyGEld9nktl03AAvMQd9eNp5FqkvNzh7p X-Received: by 2002:a17:90a:1c2:b0:256:468b:fb50 with SMTP id 2-20020a17090a01c200b00256468bfb50mr632748pjd.47.1686297726067; Fri, 09 Jun 2023 01:02:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686297726; cv=none; d=google.com; s=arc-20160816; b=SUrZx2XOkC/kL1yQPVrpypx1P9b9USS7tab2XaotD+ar2k3RZKrG8gxdaovwVAdHTZ chQttd6IEAQCmUbgrcWvHC0hFNJ/DSWcah9USabHZix7kjSNaAnEC//moXqSFKmNO79t IRGqyomivyB4BhjRapObwUzvmoPtOg2fYkb6oYAqjgri9Ao/oE98gWdlYVbORC99NbqH iKKB2QoeoFItyE5bQIx1ds33EBPpANdrzOI6KBB26b4o5CW1u6a6J+LrH1L64WmFcjCe R8oMcUzOdX297CYFQbK4e/l3uQMjDcO1BiwAah5oxurrKItHwV677VZL8F+HzGgGr/3z jAHg== 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=fH0C7VtLpIk/ymZUFK43wUJtPx7iE/R4kc3YOi7r/TI=; b=na3cYkjOF1cD6fW3IN2+res/wB8WWLiC+kZfyF4HJOMzDnh1efQHwqs5xxKiIDwCdy TB5+tPOyK2tfkjU+0bdwBajoX7OEymUEk0RnJTYq1m/H/T0ae6SCUUTPFx/kmphJ3enl 1/O9e3FxO+1FaI5gW8G2RokvXtkJ1kIV6uJ2ZALfWrY/Qz3WswpeD0uJv80dg6BrEa23 HoPDZUYpfu4SVtkXMPo7ZPC0Z3XLVjkB2G004BLpuRGcEb6tZplRAuX0g1m6J+TF/G3o B+5u2wuZ0e59lbePO1L3aChWl+ZprXmUx8zmvvNymPvxzMfkr08ehud9mWbWeqq0hwqj LzCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=RtDhJHtS; 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 o2-20020a17090a55c200b0025679bf9761si2336684pjm.56.2023.06.09.01.01.53; Fri, 09 Jun 2023 01:02:06 -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=RtDhJHtS; 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 S238963AbjFIIAx (ORCPT + 99 others); Fri, 9 Jun 2023 04:00:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33926 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240077AbjFIH7z (ORCPT ); Fri, 9 Jun 2023 03:59:55 -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 DA57F468A for ; Fri, 9 Jun 2023 00:57:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686297460; 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=fH0C7VtLpIk/ymZUFK43wUJtPx7iE/R4kc3YOi7r/TI=; b=RtDhJHtS/AEqlKYHJk1JQjlZTfZmw8Q46RS6Bs2DeFoUuCyhXWKu/OHW7MRNJTUAGYSQiB G1xyNnqBnhB9+xGg5ZWIovoy22A6CF+fhkvwTwH1bfrMUnz6tFoK5vbNUHTKZOJJvG5pcQ OS34tYLciqwSAyGdGlSGBjcLQCqQ4Jk= 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-538-cWt-btDzOe2x3ifFz6Dtgg-1; Fri, 09 Jun 2023 03:57:30 -0400 X-MC-Unique: cWt-btDzOe2x3ifFz6Dtgg-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E04BA280BC5D; Fri, 9 Jun 2023 07:57:29 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-92.pek2.redhat.com [10.72.12.92]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5626720268C6; Fri, 9 Jun 2023 07:57:24 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-arch@vger.kernel.org, linux-mm@kvack.org, arnd@arndb.de, christophe.leroy@csgroup.eu, hch@lst.de, 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, Baoquan He Subject: [PATCH v6 16/19] mm: move is_ioremap_addr() into new header file Date: Fri, 9 Jun 2023 15:55:25 +0800 Message-Id: <20230609075528.9390-17-bhe@redhat.com> In-Reply-To: <20230609075528.9390-1-bhe@redhat.com> References: <20230609075528.9390-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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_H5,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?1768211324374600571?= X-GMAIL-MSGID: =?utf-8?q?1768211324374600571?= 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 Reviewed-by: Christoph Hellwig Signed-off-by: Baoquan He --- v6: Newly added - Christoph arch/powerpc/include/asm/pgtable.h | 8 -------- include/linux/ioremap.h | 30 ++++++++++++++++++++++++++++++ include/linux/mm.h | 5 ----- kernel/iomem.c | 1 + mm/ioremap.c | 10 +--------- 5 files changed, 32 insertions(+), 22 deletions(-) create mode 100644 include/linux/ioremap.h diff --git a/arch/powerpc/include/asm/pgtable.h b/arch/powerpc/include/asm/pgtable.h index 9972626ddaf6..d252323a753f 100644 --- a/arch/powerpc/include/asm/pgtable.h +++ b/arch/powerpc/include/asm/pgtable.h @@ -158,14 +158,6 @@ static inline pgtable_t pmd_pgtable(pmd_t pmd) } #ifdef CONFIG_PPC64 -#define is_ioremap_addr is_ioremap_addr -static inline bool is_ioremap_addr(const void *x) -{ - unsigned long addr = (unsigned long)x; - - return addr >= IOREMAP_BASE && addr < IOREMAP_END; -} - struct seq_file; void arch_report_meminfo(struct seq_file *m); #endif /* CONFIG_PPC64 */ diff --git a/include/linux/ioremap.h b/include/linux/ioremap.h new file mode 100644 index 000000000000..f0e99fc7dd8b --- /dev/null +++ b/include/linux/ioremap.h @@ -0,0 +1,30 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _LINUX_IOREMAP_H +#define _LINUX_IOREMAP_H + +#include +#include + +#if defined(CONFIG_HAS_IOMEM) || defined(CONFIG_GENERIC_IOREMAP) +/* + * Ioremap often, but not always uses the generic vmalloc area. E.g on + * Power ARCH, it could have different ioremap space. + */ +#ifndef IOREMAP_START +#define IOREMAP_START VMALLOC_START +#define IOREMAP_END VMALLOC_END +#endif +static inline bool is_ioremap_addr(const void *x) +{ + unsigned long addr = (unsigned long)kasan_reset_tag(x); + + return addr >= IOREMAP_START && addr < IOREMAP_END; +} +#else +static inline bool is_ioremap_addr(const void *x) +{ + return false; +} +#endif + +#endif /* _LINUX_IOREMAP_H */ diff --git a/include/linux/mm.h b/include/linux/mm.h index 27ce77080c79..7379f19768b4 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -1041,11 +1041,6 @@ unsigned long vmalloc_to_pfn(const void *addr); * On nommu, vmalloc/vfree wrap through kmalloc/kfree directly, so there * is no special casing required. */ - -#ifndef is_ioremap_addr -#define is_ioremap_addr(x) is_vmalloc_addr(x) -#endif - #ifdef CONFIG_MMU extern bool is_vmalloc_addr(const void *x); extern int is_vmalloc_or_module_addr(const void *x); diff --git a/kernel/iomem.c b/kernel/iomem.c index 62c92e43aa0d..9682471e6471 100644 --- a/kernel/iomem.c +++ b/kernel/iomem.c @@ -3,6 +3,7 @@ #include #include #include +#include #ifndef ioremap_cache /* temporary while we convert existing ioremap_cache users to memremap */ diff --git a/mm/ioremap.c b/mm/ioremap.c index 68d9895144ad..a21a6c9fa5ab 100644 --- a/mm/ioremap.c +++ b/mm/ioremap.c @@ -10,15 +10,7 @@ #include #include #include - -/* - * Ioremap often, but not always uses the generic vmalloc area. E.g on - * Power ARCH, it could have different ioremap space. - */ -#ifndef IOREMAP_START -#define IOREMAP_START VMALLOC_START -#define IOREMAP_END VMALLOC_END -#endif +#include void __iomem *generic_ioremap_prot(phys_addr_t phys_addr, size_t size, pgprot_t prot) From patchwork Fri Jun 9 07:55:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 105353 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp783186vqr; Fri, 9 Jun 2023 01:02:23 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6qCdKeS+lmP8dSdiaQS87naP3azY4+9lM2I+N1ONZBqAsKVkGkhxLiVsnx2Wf3OKy0QpMC X-Received: by 2002:a17:902:74c2:b0:1aa:e5cd:647a with SMTP id f2-20020a17090274c200b001aae5cd647amr447099plt.23.1686297743140; Fri, 09 Jun 2023 01:02:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686297743; cv=none; d=google.com; s=arc-20160816; b=wvCb71V4YzOqCJR/e+lM9tOXCjfvnE2NuHZTn35MUvUt87XG294v4KPsy5Oz3OXjuP NBwM18E4BmDdkkjLtqk4Li4tO3XfFVNNfdM2MxTLAn5vIVo1OztWPD4VfKOBg/MVZR13 +uQv4/jKNb/BYJteoUgAADtFms55B5EO6Zc+zDGUR/hxyBqd0rNxehHV7I46grwuMGDj 3r3Hgyiq02oR0FcMhDUnErU/fs0TG3L3M6WepsfJwWDo0HzsIXEcAo2D/9+Kmfpx2iRy RQm2+QftB8nHyJC5vPPmN6+Q1eM6PcEONgbU450ASiqyMqqEwoEz9tWNy7dpEDgiulBw 9R7A== 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=mrr2cNyhDy3XHVdkhg3dGxWKYfHUscXJOX9H9m6IS1s=; b=a2LjaQawrHzWX0masjZZ5wBOi7INKSfechhB1Dsj229dTpwnDwPzDtRVurRrdpd04H trAOnrCgsya2EL8v9g1lv9ecqIQqHPRqWy6OOlJiiV6UCE42qYIcwdGCQv7ioDNJsfld Ou56dIvuTYqhqtI56rULwaRGd06bGxzPHdnVgf7ZIXFJuGqGUK7Q2bqCbpGcLthy4ZD4 IX4Y2pF0bBdvjm11Y5em3huqcjUyeX8vSA+C5koK5HG6Je4rZetX1Qa2DXybsJTPv0Lo 0mbAeUeJLet3D4Jmv/LEyWauj+0QRqypRMSKabi/hxA5MFHxyaBk+y3tYCFtr0yt2Zqv kI4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=LbzlVMsh; 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 y17-20020a170903011100b001a986e5bd92si2235665plc.83.2023.06.09.01.02.09; Fri, 09 Jun 2023 01:02:23 -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=LbzlVMsh; 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 S239567AbjFIIA6 (ORCPT + 99 others); Fri, 9 Jun 2023 04:00:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34028 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239467AbjFIIAF (ORCPT ); Fri, 9 Jun 2023 04:00: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 C2E1F359C for ; Fri, 9 Jun 2023 00:57:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686297467; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mrr2cNyhDy3XHVdkhg3dGxWKYfHUscXJOX9H9m6IS1s=; b=LbzlVMshK6wT1awCwyN49u/RvqVLaNhcX+RREZtYv2rlOXTzIOHh4Ct33RO3JOZjpYVl9k c4PzASFRA5gtmDHr+FBJxo2nsT5Z9UJw0NZ6Tnz+C4TXua2UThc4z/YEFkIfYxYABMoa/B e1QAjavdqW9eZRYcEqkuXa2furSAsh0= 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-76-1o8RxqJuNy6kld5Aajr5wQ-1; Fri, 09 Jun 2023 03:57:38 -0400 X-MC-Unique: 1o8RxqJuNy6kld5Aajr5wQ-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 625713849528; Fri, 9 Jun 2023 07:57:37 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-92.pek2.redhat.com [10.72.12.92]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8C15C20268C6; Fri, 9 Jun 2023 07:57:30 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-arch@vger.kernel.org, linux-mm@kvack.org, arnd@arndb.de, christophe.leroy@csgroup.eu, hch@lst.de, 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, Baoquan He , Michael Ellerman , Nicholas Piggin , linuxppc-dev@lists.ozlabs.org Subject: [PATCH v6 17/19] powerpc: mm: Convert to GENERIC_IOREMAP Date: Fri, 9 Jun 2023 15:55:26 +0800 Message-Id: <20230609075528.9390-18-bhe@redhat.com> In-Reply-To: <20230609075528.9390-1-bhe@redhat.com> References: <20230609075528.9390-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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_H5,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?1768211342152697476?= X-GMAIL-MSGID: =?utf-8?q?1768211342152697476?= From: Christophe Leroy By taking GENERIC_IOREMAP method, the generic generic_ioremap_prot(), generic_iounmap(), and their generic wrapper ioremap_prot(), ioremap() and iounmap() are all visible and available to arch. Arch needs to provide wrapper functions to override the generic versions if there's arch specific handling in its ioremap_prot(), ioremap() or iounmap(). This change will simplify implementation by removing duplicated codes with generic_ioremap_prot() and generic_iounmap(), and has the equivalent functioality as before. Here, add wrapper functions ioremap_prot() and iounmap() for powerpc's special operation when ioremap() and iounmap(). Signed-off-by: Christophe Leroy Signed-off-by: Baoquan He Reviewed-by: Christoph Hellwig Reviewed-by: Mike Rapoport (IBM) Cc: Michael Ellerman Cc: Nicholas Piggin Cc: linuxppc-dev@lists.ozlabs.org --- arch/powerpc/Kconfig | 1 + arch/powerpc/include/asm/io.h | 8 +++----- arch/powerpc/mm/ioremap.c | 26 +------------------------- arch/powerpc/mm/ioremap_32.c | 19 +++++++++---------- arch/powerpc/mm/ioremap_64.c | 12 ++---------- 5 files changed, 16 insertions(+), 50 deletions(-) diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index bff5820b7cda..aadb280a539e 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig @@ -194,6 +194,7 @@ config PPC select GENERIC_CPU_VULNERABILITIES if PPC_BARRIER_NOSPEC select GENERIC_EARLY_IOREMAP select GENERIC_GETTIMEOFDAY + select GENERIC_IOREMAP select GENERIC_IRQ_SHOW select GENERIC_IRQ_SHOW_LEVEL select GENERIC_PCI_IOMAP if PCI diff --git a/arch/powerpc/include/asm/io.h b/arch/powerpc/include/asm/io.h index 67a3fb6de498..0732b743e099 100644 --- a/arch/powerpc/include/asm/io.h +++ b/arch/powerpc/include/asm/io.h @@ -889,8 +889,8 @@ static inline void iosync(void) * */ extern void __iomem *ioremap(phys_addr_t address, unsigned long size); -extern void __iomem *ioremap_prot(phys_addr_t address, unsigned long size, - unsigned long flags); +#define ioremap ioremap +#define ioremap_prot ioremap_prot extern void __iomem *ioremap_wc(phys_addr_t address, unsigned long size); #define ioremap_wc ioremap_wc @@ -904,14 +904,12 @@ void __iomem *ioremap_coherent(phys_addr_t address, unsigned long size); #define ioremap_cache(addr, size) \ ioremap_prot((addr), (size), pgprot_val(PAGE_KERNEL)) -extern void iounmap(volatile void __iomem *addr); +#define iounmap iounmap void __iomem *ioremap_phb(phys_addr_t paddr, unsigned long size); int early_ioremap_range(unsigned long ea, phys_addr_t pa, unsigned long size, pgprot_t prot); -void __iomem *do_ioremap(phys_addr_t pa, phys_addr_t offset, unsigned long size, - pgprot_t prot, void *caller); extern void __iomem *__ioremap_caller(phys_addr_t, unsigned long size, pgprot_t prot, void *caller); diff --git a/arch/powerpc/mm/ioremap.c b/arch/powerpc/mm/ioremap.c index 4f12504fb405..705e8e8ffde4 100644 --- a/arch/powerpc/mm/ioremap.c +++ b/arch/powerpc/mm/ioremap.c @@ -41,7 +41,7 @@ void __iomem *ioremap_coherent(phys_addr_t addr, unsigned long size) return __ioremap_caller(addr, size, prot, caller); } -void __iomem *ioremap_prot(phys_addr_t addr, unsigned long size, unsigned long flags) +void __iomem *ioremap_prot(phys_addr_t addr, size_t size, unsigned long flags) { pte_t pte = __pte(flags); void *caller = __builtin_return_address(0); @@ -74,27 +74,3 @@ int early_ioremap_range(unsigned long ea, phys_addr_t pa, return 0; } - -void __iomem *do_ioremap(phys_addr_t pa, phys_addr_t offset, unsigned long size, - pgprot_t prot, void *caller) -{ - struct vm_struct *area; - int ret; - unsigned long va; - - area = __get_vm_area_caller(size, VM_IOREMAP, IOREMAP_START, IOREMAP_END, caller); - if (area == NULL) - return NULL; - - area->phys_addr = pa; - va = (unsigned long)area->addr; - - ret = ioremap_page_range(va, va + size, pa, prot); - if (!ret) - return (void __iomem *)area->addr + offset; - - vunmap_range(va, va + size); - free_vm_area(area); - - return NULL; -} diff --git a/arch/powerpc/mm/ioremap_32.c b/arch/powerpc/mm/ioremap_32.c index 9d13143b8be4..ca5bc6be3e6f 100644 --- a/arch/powerpc/mm/ioremap_32.c +++ b/arch/powerpc/mm/ioremap_32.c @@ -21,6 +21,13 @@ __ioremap_caller(phys_addr_t addr, unsigned long size, pgprot_t prot, void *call phys_addr_t p, offset; int err; + /* + * If the address lies within the first 16 MB, assume it's in ISA + * memory space + */ + if (addr < SZ_16M) + addr += _ISA_MEM_BASE; + /* * Choose an address to map it to. * Once the vmalloc system is running, we use it. @@ -31,13 +38,6 @@ __ioremap_caller(phys_addr_t addr, unsigned long size, pgprot_t prot, void *call offset = addr & ~PAGE_MASK; size = PAGE_ALIGN(addr + size) - p; - /* - * If the address lies within the first 16 MB, assume it's in ISA - * memory space - */ - if (p < 16 * 1024 * 1024) - p += _ISA_MEM_BASE; - #ifndef CONFIG_CRASH_DUMP /* * Don't allow anybody to remap normal RAM that we're using. @@ -63,7 +63,7 @@ __ioremap_caller(phys_addr_t addr, unsigned long size, pgprot_t prot, void *call return (void __iomem *)v + offset; if (slab_is_available()) - return do_ioremap(p, offset, size, prot, caller); + return generic_ioremap_prot(addr, size, prot); /* * Should check if it is a candidate for a BAT mapping @@ -87,7 +87,6 @@ void iounmap(volatile void __iomem *addr) if (v_block_mapped((unsigned long)addr)) return; - if (addr > high_memory && (unsigned long)addr < ioremap_bot) - vunmap((void *)(PAGE_MASK & (unsigned long)addr)); + generic_iounmap(addr); } EXPORT_SYMBOL(iounmap); diff --git a/arch/powerpc/mm/ioremap_64.c b/arch/powerpc/mm/ioremap_64.c index 3acece00b33e..d24e5f166723 100644 --- a/arch/powerpc/mm/ioremap_64.c +++ b/arch/powerpc/mm/ioremap_64.c @@ -29,7 +29,7 @@ void __iomem *__ioremap_caller(phys_addr_t addr, unsigned long size, return NULL; if (slab_is_available()) - return do_ioremap(paligned, offset, size, prot, caller); + return generic_ioremap_prot(addr, size, prot); pr_warn("ioremap() called early from %pS. Use early_ioremap() instead\n", caller); @@ -49,17 +49,9 @@ void __iomem *__ioremap_caller(phys_addr_t addr, unsigned long size, */ void iounmap(volatile void __iomem *token) { - void *addr; - if (!slab_is_available()) return; - addr = (void *)((unsigned long __force)PCI_FIX_ADDR(token) & PAGE_MASK); - - if ((unsigned long)addr < ioremap_bot) { - pr_warn("Attempt to iounmap early bolted mapping at 0x%p\n", addr); - return; - } - vunmap(addr); + generic_iounmap(PCI_FIX_ADDR(token)); } EXPORT_SYMBOL(iounmap); From patchwork Fri Jun 9 07:55:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 105367 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp787897vqr; Fri, 9 Jun 2023 01:12:38 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ699INGE5k0yAP/ofE196/nC+c5AQqgqwd+mDG+Tz7yIj9shTzMmbMSDRTTek98F1ygwpHy X-Received: by 2002:a17:90a:688d:b0:259:17c9:fda7 with SMTP id a13-20020a17090a688d00b0025917c9fda7mr377363pjd.4.1686298357746; Fri, 09 Jun 2023 01:12:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686298357; cv=none; d=google.com; s=arc-20160816; b=ZPpfZTMXmdwED0H4kVWXKqfWmlUzKS5bcEsqkdFVHxJWV/Z0jLMldsnIFN/5IcRWFO c1Mox1Lw1CqfBpLn6es3UXRvoC3ZHlmD5X0PNI9tKBXan8Z/8WVSJN+ELrIj1/9t5LmE m/QqUrIa3jmVEwEQzgnxVOeFb0SwL1XbwFqHOVzczqPNizbUlQ/cp2G38WWW4WTl9Fz2 S8dfMg3DN9eAvjUVK48NG0qAXne0HlZiNNZxJ4sGxUUT0UeZKXhJNK+U6y6ULZAa2EyY Vr4KML6aDU254ZS3fv4q5RkVE9K0KBEw+3JmrXEZGYjamSUHqgWxGS7pJpVQBpNzsg9d cE7w== 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=81nV18C3v1lk6vsTsYHvlL2VrwGGV2i7WxKaTwXwgOE=; b=0nfzYYdX5NWO0j+XKokPYyD0UBgaKeRQDaYtChIom5u9aGHX+MjjBP+CLLvfJDpGTI 8+8Ri9HhqZqD66kTsuw1oo25IqNK3o3wxIqIZq0FYi4KsgYn7mXSw9cFSWuQ9gA7eIF6 mEqW56WNld/8HhusgbjYfIJ1bOzrMEYXHsWQEMErtl07tr2bPMOSY0S5lo75+2eEKxwz bzbWFvuU0qOIyS8brnpXlGfebB2jo/OINm3dFltNhC2ZF4Qfj1MsWL5PzN7pnOWKyCrH YYsLyyHxdepZIsBIkpOCOqe8PPHsv4MZXTPEWzFEumqFPfmOweEOjfdhePMGyfHLfCFl guwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=QYbn12ur; 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 i6-20020a636d06000000b0052cba2d0187si2358834pgc.704.2023.06.09.01.12.22; Fri, 09 Jun 2023 01:12: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=QYbn12ur; 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 S236407AbjFIIBE (ORCPT + 99 others); Fri, 9 Jun 2023 04:01:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34144 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239655AbjFIIAT (ORCPT ); Fri, 9 Jun 2023 04:00: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 5B8AB46B6 for ; Fri, 9 Jun 2023 00:58:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686297474; 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=81nV18C3v1lk6vsTsYHvlL2VrwGGV2i7WxKaTwXwgOE=; b=QYbn12urwrYDvLlrgdjoCyjR7ChtZURo6ihuP9Ev/NVjzTZjk2Q458xfsfBah2C462DFOR VsiMneVuS9Hxpl4Z54Ls9Z4pVzpQXSryOllkOWsHN+/LRDVgEPwkDI+XbPGANVHYXE8/Yb 621j+5KDaTWdkwhu3iKbNY18k9lf7Us= 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-147-ka62SOjHPdCC3QS6MTgItw-1; Fri, 09 Jun 2023 03:57:45 -0400 X-MC-Unique: ka62SOjHPdCC3QS6MTgItw-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A34AD3C0CEF9; Fri, 9 Jun 2023 07:57:44 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-92.pek2.redhat.com [10.72.12.92]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1B08E20268C7; Fri, 9 Jun 2023 07:57:37 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-arch@vger.kernel.org, linux-mm@kvack.org, arnd@arndb.de, christophe.leroy@csgroup.eu, hch@lst.de, 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, Baoquan He , Catalin Marinas , Will Deacon , linux-arm-kernel@lists.infradead.org Subject: [PATCH v6 18/19] arm64 : mm: add wrapper function ioremap_prot() Date: Fri, 9 Jun 2023 15:55:27 +0800 Message-Id: <20230609075528.9390-19-bhe@redhat.com> In-Reply-To: <20230609075528.9390-1-bhe@redhat.com> References: <20230609075528.9390-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768211986480549500?= X-GMAIL-MSGID: =?utf-8?q?1768211986480549500?= Since hook functions ioremap_allowed() and iounmap_allowed() will be obsoleted, add wrapper function ioremap_prot() to contain 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) Cc: Catalin Marinas Cc: Will Deacon Cc: linux-arm-kernel@lists.infradead.org Acked-by: Catalin Marinas --- arch/arm64/include/asm/io.h | 3 +-- arch/arm64/mm/ioremap.c | 10 ++++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/arch/arm64/include/asm/io.h b/arch/arm64/include/asm/io.h index 877495a0fd0c..97dd4ff1253b 100644 --- a/arch/arm64/include/asm/io.h +++ b/arch/arm64/include/asm/io.h @@ -139,8 +139,7 @@ extern void __memset_io(volatile void __iomem *, int, size_t); * I/O memory mapping functions. */ -bool ioremap_allowed(phys_addr_t phys_addr, size_t size, unsigned long prot); -#define ioremap_allowed ioremap_allowed +#define ioremap_prot ioremap_prot #define _PAGE_IOREMAP PROT_DEVICE_nGnRE diff --git a/arch/arm64/mm/ioremap.c b/arch/arm64/mm/ioremap.c index c5af103d4ad4..269f2f63ab7d 100644 --- a/arch/arm64/mm/ioremap.c +++ b/arch/arm64/mm/ioremap.c @@ -3,20 +3,22 @@ #include #include -bool ioremap_allowed(phys_addr_t phys_addr, size_t size, unsigned long prot) +void __iomem *ioremap_prot(phys_addr_t phys_addr, size_t size, + unsigned long prot) { unsigned long last_addr = phys_addr + size - 1; /* Don't allow outside PHYS_MASK */ if (last_addr & ~PHYS_MASK) - return false; + return NULL; /* Don't allow RAM to be mapped. */ if (WARN_ON(pfn_is_map_memory(__phys_to_pfn(phys_addr)))) - return false; + return NULL; - return true; + return generic_ioremap_prot(phys_addr, size, __pgprot(prot)); } +EXPORT_SYMBOL(ioremap_prot); /* * Must be called after early_fixmap_init From patchwork Fri Jun 9 07:55:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 105373 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp789273vqr; Fri, 9 Jun 2023 01:15:57 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7N6cgPivDagNe3YefqfnvhUSFs4JS3i2FWvCCW55NJzcUgk42KKCtpwvEJ58FrFneOavwI X-Received: by 2002:a05:6870:b1d2:b0:19a:2343:b69e with SMTP id x18-20020a056870b1d200b0019a2343b69emr712198oak.40.1686298557602; Fri, 09 Jun 2023 01:15:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686298557; cv=none; d=google.com; s=arc-20160816; b=NKQAstrwX/t3ADPPFC9WEM27tRNn7/Z+8P6GjKz0So23oVif5o+ssk1LYoBFMHrx5X bOIcs2egAg8Luvz0eeegGvp3rHLiQ8blPRwPI+APXlDBpLJUpez52aOBi2oLAI8ZVx/K ELEHhrocfHvlGSIDFabLSL7DIgeMk9MaTTSImHNXlImFp6ikSIbHntsY/AlJmNmmLCrA 7MqE6/R4X7xkJMHZM2FOp0wq9FmYXim8IrJuFD6DQvnvX0fl4oPXTXVvnTc11y+BEgqM Lj4KmZNFJbPqkgxDRZ+EuG+WeWLb/1YcC9fHDZURkKUiqKrQBHQ9QvDgvf0FUF/zPOTL KvTw== 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=; b=AroyaFIXyE4tbAvIqlh1QrxdyAXKspKiNDXufhVTThbAOWnzy314fmriq8MyY55uWA 7y4UrozLuadpIdMFNMfXPt1Eywc5PaTubCfmTRgNjb+tIcFrf59H21ToD82SOwBvXtHA SmpdJxwMPEh/HbklOvpYfYXnxg2am73ScHG5+rFNKDTGQWb1hjm6pcW9a1yPxJ1NaK9i Rqet5GbyZzuTQpOGBL6AFLuqaTyB7dRkQnJG95qNNbJ2ntKTLcOWdao2iRnFu2YbM5yL J6bIhfCmefIZL6O8mQH1EXHvRkzGQ714PIDLMGX3Z6RiPapbLladf34UJfjZR0D5Hv4T +Pxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="D6La/hwR"; 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 w4-20020a63b744000000b00534780446d9si2249792pgt.640.2023.06.09.01.15.44; Fri, 09 Jun 2023 01:15:57 -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="D6La/hwR"; 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 S239932AbjFIIBJ (ORCPT + 99 others); Fri, 9 Jun 2023 04:01:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34086 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235585AbjFIIA1 (ORCPT ); Fri, 9 Jun 2023 04:00:27 -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 97C0249C2 for ; Fri, 9 Jun 2023 00:58:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686297475; 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=D6La/hwRfReJ4WdYtJ2Py8lbsq8PRvObxqiXrkxgw8G2HnyfXkT07cEvMZPY28/Wqlu4Vj r4Hstw2hiCFgf1zdd92BG2qs5nRqBDWQqi8z/l5GeIzwg5mvsj0HsAddvmBP2f2UaKmEEj 8c5QMf8dXqXu7MBs+8my6QXRei25Y1w= 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-380-jhbKVNRpPu-vZvSBv7VYEg-1; Fri, 09 Jun 2023 03:57:51 -0400 X-MC-Unique: jhbKVNRpPu-vZvSBv7VYEg-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id CF9B83C0CF05; Fri, 9 Jun 2023 07:57:50 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-92.pek2.redhat.com [10.72.12.92]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4930320268C6; Fri, 9 Jun 2023 07:57:44 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-arch@vger.kernel.org, linux-mm@kvack.org, arnd@arndb.de, christophe.leroy@csgroup.eu, hch@lst.de, 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, Baoquan He Subject: [PATCH v6 19/19] mm: ioremap: remove unneeded ioremap_allowed and iounmap_allowed Date: Fri, 9 Jun 2023 15:55:28 +0800 Message-Id: <20230609075528.9390-20-bhe@redhat.com> In-Reply-To: <20230609075528.9390-1-bhe@redhat.com> References: <20230609075528.9390-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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_H5,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?1768212196349641015?= X-GMAIL-MSGID: =?utf-8?q?1768212196349641015?= 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); }