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: 13273351 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3AB0FC7EE25 for ; Fri, 9 Jun 2023 07:55:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A10F68E0005; Fri, 9 Jun 2023 03:55:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9C1148E0001; Fri, 9 Jun 2023 03:55:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 888B38E0005; Fri, 9 Jun 2023 03:55:54 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 7AFBE8E0001 for ; Fri, 9 Jun 2023 03:55:54 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 41C6D4016F for ; Fri, 9 Jun 2023 07:55:54 +0000 (UTC) X-FDA: 80882450628.19.AAD9CF3 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf14.hostedemail.com (Postfix) with ESMTP id 66C05100012 for ; Fri, 9 Jun 2023 07:55:51 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="hmcbE/kv"; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf14.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1686297351; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=r3g4ZP9oM4r19WBz6/w6ckLHluvVzIZl/J+34OobsOk=; b=w9FNbILS3vclOz/bOA/jKL+H7QRS1JChf36xzXgPl3/rMHqlDnlfoHjK7T170gstxGAa9R s2KQu9QAX7E/F+BFLpAL9nEVL5kQWUerJCkLQrXIrBMMQ2t1yKpxn0DhDqSSL+7rmTvO1E NwLNhdZ15zUbrZJbMSw0wdwvthFxOF0= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="hmcbE/kv"; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf14.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1686297351; a=rsa-sha256; cv=none; b=cue95zGwyvca4goHknAt7wpWRL37fzWi+wopYbEQGtlqBv/+Hv6lkrfC65tclcoal6ZQvg h/KWzRX1O7dSRMhZgQHkuJkMhkcGrwCojZYLOQtI3Jh7JxFd6k5iKpdi1Z4YKgY15tJ6Bf uinkkquevPcFIQhwu+kipLRr/2Fjyy0= 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-Rspamd-Queue-Id: 66C05100012 X-Rspam-User: X-Rspamd-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rxR0WTzeXjI27wnqSx8w6fYqWVwqepJML3cDxnqbekzrJTfgCTaOo8Q9NucGt2cKWSwrDJsFs56H2GcEBM/qCAXz7BQgxpB+qjTV74825a+lQ88bSw91a4zgjNcKi4Soa0k9dHH39KHQ2GydCjb75BiupmdhRmYL2rLcm1UgNphCSoShjvn0W2DoEM/42aUHazE+4ZSkgIobv9zXvmH9phW3XkEfcc1JxqwwZmPBnPXnzlUvkV/nj/QYC4z3zIMkN+s/HKhkbmIz5BrUTrNg64x4DY1Ou334nI3jo2YcpUvyDczltSh2yh6tbgOQvraXpW7edFx6602fGo3ROCW1qSDTX/lHIx66K4p6/wmfCSB5jKMGvzrIEUhWEtSbS+41t7RnQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Let's use '#define ioremap_xx' and "#ifdef ioremap_xx" instead. To remove defined ARCH_HAS_IOREMAP_xx macros in of each ARCH, the ARCH's own ioremap_wc|wt|np definition need be above "#include . Otherwise the redefinition error would be seen during compiling. So the relevant adjustments are made to avoid compiling error: loongarch: - doesn't include , defining ARCH_HAS_IOREMAP_WC is redundant, so simply remove it. m68k: - selected GENERIC_IOMAP, has been added in , and is included above , so simply remove ARCH_HAS_IOREMAP_WT defining. mips: - move "#include " below ioremap_wc definition in powerpc: - remove "#include " in because it's duplicated with the one in , let's rely on the latter. x86: - selected GENERIC_IOMAP, remove #include in the middle of . Let's rely on . Signed-off-by: Baoquan He Acked-by: Geert Uytterhoeven Reviewed-by: Mike Rapoport (IBM) Reviewed-by: Christoph Hellwig --- 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: 13273352 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id EC45AC7EE25 for ; Fri, 9 Jun 2023 07:56:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8B1B38E0006; Fri, 9 Jun 2023 03:56:04 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 862D98E0001; Fri, 9 Jun 2023 03:56:04 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 750198E0006; Fri, 9 Jun 2023 03:56:04 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 683418E0001 for ; Fri, 9 Jun 2023 03:56:04 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 2F5171A0172 for ; Fri, 9 Jun 2023 07:56:04 +0000 (UTC) X-FDA: 80882451048.09.3DC2EC2 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf03.hostedemail.com (Postfix) with ESMTP id 674D32001A for ; Fri, 9 Jun 2023 07:56:01 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=MUygy+Ap; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf03.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1686297361; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=3DenNY7MBGvhJyodc+H0T1cCxvBg9zEtJ+UDYfYUhPQ=; b=NTOCVopNhznSNHJZE1tMdxHOT52DPLSCp532ubT6kbhIn10SBUsKyuwsn12oSAdOcraeWn fYRIhTw+ZEkoCcakSvrcnRRyAIiCgrys/2fXCyS8UblVt8YP1Zgk4c+wnpeAQGmPAvIAqE CmALgviiZcasj4yBOJ96FwiDEAjRdCE= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=MUygy+Ap; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf03.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1686297361; a=rsa-sha256; cv=none; b=FJUvKp0K7Y44YekTZF6RpPRekgPwK4DnNlWoFiTt1BUEZZrYZIkpatmGGNTmce3JdsvlJ0 iFJEjiudFpXlI2GgtWGEEkniuUCttopz+dyg4u/GSCf4k8EKUmATpFmTr9lVId57QwqQaF Jx2TiprhwGb2bi2eIhfoe7ZXl6XvQhk= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686297360; 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=MUygy+Aphtyq84KuQDwDW/YEzGgCZmm/h236D6w9d23iTO59oB1DX/U9AvmBoN2B/VzRdW xONSS3aEQgPTJKBqd8tGgjtT8CdBECaHlMXJgfDf3ezpj12b6IRgKHn6cxtjDAuAFe25tb bvrM22kAGEi3CUj89fAVC0aIeWHt02o= 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-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 674D32001A X-Stat-Signature: 5yua9xh16iyjwkmqpjsb3ij3es9zkeyf X-HE-Tag: 1686297361-483480 X-HE-Meta: U2FsdGVkX19nyiqdu0lm4qmXkaTbidioYkE1EnR4qhiR4lTlEKkRY355zZJuCHsHj29XTIkii/TcbkBmqWfEPfgPYldgNhmP1kFobzlMH6VgG4v8rrlUw3AobDQ0qTpLUJ7gmu/3/cqdoo8Vh4KP9zvXVCPbYHfmkxoMRNz1oqhQ9WaTlxWo37zljuwyrK+fNpcYv3PFksg33JrMOIcv1d4so/gOf7IBgp/bXKUPfwt5INfneRPhHBL2iscGPAG0T6QOHlp7VAyqLBcYpxbjtj+hrcFl/5LDCp0NE6URw4eTVfl9w5I6SlqzshTVw93toIVvl7tHgHpZReJCUwGw0kC8jmnJc0Uc0n9XGJZGWXoSpj38cfCy6d1WL6pNyFwkWepriQUJs2t63aOEejwPl0sroOOOcgaK8TUlKNoR//36U8etRthe3uu/JkX8bYUmggg0jDZNJpjiCndVlm0xgqck5XDnfX4g74MmV2F63FEvmhqYlAP96aMJ7NK5oa6BdAVx7jNrRwHJvWV34//JQnKi8JrN6viCo7vOjWypwHEhyqbJUp8GOuhINJk16ceM0hUMfLuum6+mrsFw6DnUIW5rgUdi6Ru0R3pJk6bcSVhbuIe8pHkwgzr54xai1Xe8s9i+ywfD2ZTxgNeGKW3Lwk5yi27jhFuDyHTFBuC7mlukdPFqgomhVZ1W/KZpxFiDZ46PLxosuKdhJNnTVCaRgkHS7mwGUNKp3D8DAXwEwoQUR8UUu3g4ldvtu16DqIvuTHpdglOF5Ht1iZDPYcYef1UluT1+Ei1t178+4Fxpg0Kr15Qq0awnbYiC2tG6mcvGeQPeYL5buyDf2Vpzwou8hEL8GBdZeRgqT/w54rx236Xuo9n5o9gJw6onpVDyEQAIN/symhJySVcF5kSBHMhjRkHw9ZnCOUv+8TKkJn23yP/M86hRsVlNCYMkU90qCwuTy3zs4XC3u9RTxd8heCd nljxRp5G ANYwGf4oS/N9puSZroY2YDx31Upfh0AF4orpMjF5QUft2uHgNwI745oHCzM0AlHpcs7lgYO/njWrrvjjhgdJpGhRzSBb6++QKDa5FC5NbelKyoGEms9M44qjua5P3g/E9TbiK2Iegkyeq9vhXqElo98fH4AA+6U4hy6tEKMq42E3kxZsfmlakhq26k+bRRJUvhIDF1kM6mPMGETbusoGh8jbgJiRldrCEwCb9TNTIJmlAMnitDEhhFtYy5bLFS/YFCBPWY4G6kjfbnOBgVKJWCePUweM+Xav5T+alY7V3/iqOO37jlJrqSCW/zlAyTYEP8PmuCBnL8S8Mpn6Qn7+/GW5Wdg== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: By taking GENERIC_IOREMAP method, the generic ioremap_prot() and iounmap() are visible and available to arch. This change will simplify implementation by removing duplicated codes with generic ioremap_prot() and iounmap(), and has the equivalent functioality. For hexagon, the current ioremap() and iounmap() are the same as generic version. After taking GENERIC_IOREMAP way, the old ioremap() and iounmap() can be completely removed. Signed-off-by: Baoquan He Reviewed-by: Mike Rapoport (IBM) Reviewed-by: Christoph Hellwig Cc: Brian Cain Cc: linux-hexagon@vger.kernel.org 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: 13273354 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id DCD26C7EE25 for ; Fri, 9 Jun 2023 07:56:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 72A038E0007; Fri, 9 Jun 2023 03:56:17 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6B40F8E0001; Fri, 9 Jun 2023 03:56:17 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 553688E0007; Fri, 9 Jun 2023 03:56:17 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 48BFF8E0001 for ; Fri, 9 Jun 2023 03:56:17 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 27BE31A014F for ; Fri, 9 Jun 2023 07:56:17 +0000 (UTC) X-FDA: 80882451594.15.77F59DA Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf26.hostedemail.com (Postfix) with ESMTP id 2F1FE140004 for ; Fri, 9 Jun 2023 07:56:13 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=EJNzIF94; spf=pass (imf26.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1686297374; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=b1cwgKpxB+oYTQq0br6utRWEYNI4guxqhcfHp/vK96c=; b=eobFRYTgQMv0EGWihIEV7fcpX/YRJ7sC9pGx2vkrQ8RXXb5A3x29bxiqD7n87jky6s1iAy vVgvGuiL09ykGbQ233/DQhFTvEe5LjZQo9Bq+o3EmmTTsFgwjXoNdC0emGnOLvvH+k8l2g 7sJGCUOPP4TWyigiCGR1Om6au8ohj48= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=EJNzIF94; spf=pass (imf26.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1686297374; a=rsa-sha256; cv=none; b=Ft/P4DBVXoGu3Kzjp/5q6Hlbz4gcR4OZWYCe2RT4+FexbbMN0GovaPjG6cHL+so3cpD4zd 4+HOnmj2LMHOhhDEJGX/IwUaWddA4a1gy8MbreeFJMmTSCbuu3ICN4Pc+9UpDiA3QANWB9 suY9FaqkxOw2WwkYWZI0IgMJ+8Kv1fo= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686297373; 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=EJNzIF94IwbqgQXcnfvUbQ3VVTHH/jEkuTICrENZH9d8/IQ5istLZ7LQUhQIdxbhucSjRU pP33qG2piWzOztJH62PZOm2B7oJ6xeyKA4wH/dicUou89GvxwAk4IeT+HFwKE7Td8RskLZ zxc3HXm3ZSWZzmxhLuM9OsIxFpDcV0Y= 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-Rspamd-Queue-Id: 2F1FE140004 X-Rspam-User: X-Stat-Signature: 78qndfg5jwm6a3tjw6ozyrux85zhs98p X-Rspamd-Server: rspam01 X-HE-Tag: 1686297373-849813 X-HE-Meta: U2FsdGVkX19mNG5NZqY+N6w8MdkrMur5hx0UKFf0XFugKuzppcyKb5hFbul+z0neMJrMwmoEPlyY3KSK9uDgK9ZelCgkeyGIn5lspoKFmBNP2y/NAioGhcDA7y1Lpi1R/zJ3u8AD+6kBRh0tdZs7gUa2d0cNT6SjiWLQygPJ/lgFluNNTDcHr6+jbmNsmbNlGGy1pht6dVfc6H42leA2sjc8OCm2dhkxUsl/kMPPRW2m51KzRys4Ze/IjbcgAu6nKrhPFZq10A77oMKFYmz3XVbsRIVUNskTeIZuL3uRs32Yh2E48HqwK/NtjosN10IEJ1Fps6w5b3F9AsSdDhlKHnO4F7nS79+q7ULLuawcXJI3zpUlLygS327ZWw3bn4/cUfDsyA5oUgsZFIfa08uDZ6te955rGLGPE34Hzmzy9qMaB8wHzMxT9KK6BKB5vDC3yWyIbF3j+2b8retEL3V/ft1m+fmEvI/QbLsydeld1RbeZMbfsk8FaTxT62jMXG9DFxHnK9qEOWWoV9lmqwSppXGtW20vmxd98cezvpmWAqdK7KYA/znwJQVewNcNj8AYxYeG8bVIO6uKEWZxnm54xXUEBd3knFmFNT5coupoUP8ZT8rydUnN74rpnC52tpelMh8X6DbSPZLt1QL3IZ5j3nKvdigwIi1PTzlLLtoRVTiKrvX2EuaZUqFcLyf77GFZSnibalpAWLlIkvCSXHufMEmuIDy/F4sXrFeKY5Ai8gTT3dAojeUhVIPCc6WpXKKlz9PFUwU4rair96yBbRCwznRgzxgEcS70NGjM71/z5D0hiT3NoHSVgcgtBoyeF7ZLrd10urH4bKAYqc8yfm1g6MVhzPWha21i7QblivGGgghwh9dSDUgCc4g6mowwHc3ZvcA1WYHcjI+6GzJOAxxVDspsPwwTv69Lwxz5XJB7O8ZfQZm86zGKfAfYWxAapLg8H9T4jUZrXJy2b5CF+o/ DfCnCUeX YXkHfgFiy5/sZn+JZDgJhekO11ikWh6891jGbAAaPWWpjccGjT/74G03J4PMD7U4sAsqRkYb5FXC9Q9TKRT0T1remlPVwVUXUlnEcCUpOf4tMA68RiFhtDmvAtZtOHY+HJbRRI4v7len9ufvkqCmUfiFZf1auFd2nQ0+ANI/fIrxMgupyqADXoFV1I3Qt9jrgkKhAPm/lVtGm/2sgOMo66VLYSFgSDKKjL4/W7EhWoj6QV+eSsFgGxev78IyU6YEmpJnuRoMVP+RY+zg7HMxIdxyccwJuSO+fWkaocY+mgA7E0sdpClQYGiyJbPk68um9o2yN X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Under arch/openrisc, there isn't any place where ioremap() is called. It means that there isn't early ioremap handling needed in openrisc, So the early ioremap handling code in ioremap() of arch/openrisc/mm/ioremap.c is unnecessary and can be removed. And also remove the special handling in iounmap() since no page is got from fixmap pool along with early ioremap code removing in ioremap(). Link: https://lore.kernel.org/linux-mm/YwxfxKrTUtAuejKQ@oscomms1/ Signed-off-by: Baoquan He Acked-by: Stafford Horne 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: 13273353 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id D1A8AC7EE2F for ; Fri, 9 Jun 2023 07:56:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5F1C88E0008; Fri, 9 Jun 2023 03:56:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5A20C8E0001; Fri, 9 Jun 2023 03:56:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 46A388E0008; Fri, 9 Jun 2023 03:56:18 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 34CDC8E0001 for ; Fri, 9 Jun 2023 03:56:18 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 02508A014F for ; Fri, 9 Jun 2023 07:56:17 +0000 (UTC) X-FDA: 80882451636.10.BB6B385 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf21.hostedemail.com (Postfix) with ESMTP id 34D5B1C000C for ; Fri, 9 Jun 2023 07:56:16 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=UbnUJHr2; spf=pass (imf21.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1686297376; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=X3bCqAOghUMsrFt01sdBss+0xjEFSAaHuAsd0sFdmyw=; b=cl2UWZtcs9E1b6EGhTLPZVNlVRSWV/jqT1p7NETvakKs2YCxBW1Kii430A9xjLWGZpNMNm AfKJiNW1VPmNCy9x6NjRtEfxO0kOlIbpaVnSJgqR+uIZlF9hrSpzc6cWfaIUYSepJNlhsy CioREX8OfySiEaymx8X10XgDMyObCZU= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1686297376; a=rsa-sha256; cv=none; b=NfH0X1P6/HFTCKW3kqMiFnUxkjtgJBb3GQRnYv8nfX9tL7sfXXcEg1kZlWyorSsCymsZB5 Awy60+tahamQHFQ74XkXT+ko+a6Nedgp6yO+NIIpOPvpBetM3LEe88n1zPeJ5xKWVducPy oKfi7gtBNpQ2XOkekDz59g4nI6/7dss= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=UbnUJHr2; spf=pass (imf21.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=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=X3bCqAOghUMsrFt01sdBss+0xjEFSAaHuAsd0sFdmyw=; b=UbnUJHr223BuPHVPR8FQMaZM0K2qjTMoJQ4P8WAUBUcrOfT4pbggOO2qmkBQiH2tOJwbsy f94ajFPpI2QOgASaKGousT0OVC6ZnPlK9mPZx9N2F8nOzJPlVt/0tp/jWfTUTL1D7lUc7c 0k8Xp7VI8ItswlUZAFQl3+nUXQL0698= 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-Rspamd-Queue-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7vuhDjf7TG U89wLk+E OcoYtJ2wd0N0rHIxtPQRlhunOhT2fae649QASAMQyeFsCe5FG7WwerAFnVFEPPMreW/wXSFam8Q5qX7QYFK+xezNR6aG2/CBepaySRyYR5FVLqBnK5Hl5PQoGV7mix4uXbsMj6dgVfEa1ou2npgzFVROb6H/qTGeQRyqn1/XURYXlyj2zvE9bXYwGDmnU4X0FJE6sggzrTdN8NNkvrZFo4keJW4VhI9ielS5iaykq0YkLJyLKBb6671/NarGUqB/q+oIuRPO9PbfpqjLdiraHoCjiYsOsKjeaZimfQfxatg9HB9hN80zS33WuhKJoaHGs1/V9s1fk64SJ4d2hzJiLVNk7ML45YdBZnlbgI+S2Rzen0nk= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Christophe Leroy Define a generic version of ioremap_prot() and iounmap() that architectures can call after they have performed the necessary alteration to parameters and/or necessary verifications. Signed-off-by: Christophe Leroy Signed-off-by: Baoquan He Reviewed-by: Christoph Hellwig Reviewed-by: Kefeng Wang Reviewed-by: Mike Rapoport (IBM) 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: 13273355 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2C991C7EE2F for ; Fri, 9 Jun 2023 07:56:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B24498E0009; Fri, 9 Jun 2023 03:56:21 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AD2608E0001; Fri, 9 Jun 2023 03:56:21 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 972CE8E0009; Fri, 9 Jun 2023 03:56:21 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 8B4E38E0001 for ; Fri, 9 Jun 2023 03:56:21 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 5625C8015F for ; Fri, 9 Jun 2023 07:56:21 +0000 (UTC) X-FDA: 80882451762.27.C64C65D Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf12.hostedemail.com (Postfix) with ESMTP id 5CDE340017 for ; Fri, 9 Jun 2023 07:56:19 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=ild4EO3d; spf=pass (imf12.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1686297379; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=7Tl0uNK3iTFKABiIz7zb0nAC1GuwS9Iddx7rewdSaxU=; b=IBGaPDzJ20O0mQpAJ47vcuOLDxxP4c+UnZ3CcA4gTs779DM56VnVsc21nHwADaXo8GPMJ4 /GWJJci/1XuPUIUco0EYtobgXXZzFxykBu1pflotbdsUsRtkvNPAP6TDz6nqQotGm56G1A Q861IC2hTgIw8Y7+pVrwXLlrnEYW9pM= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1686297379; a=rsa-sha256; cv=none; b=gGtQmfHvXR4qwfz+uNmPgB+1YZ+YyN26NDHQEdFNYgbBlQ3urdP/6sO1w/kqKxOTYte/wT FO9SWUg21USosoARJejbq8xD5sDj3ZBxKbzhCh6yvUEVCJ3RoFbrOggJ4f04LvIhYq3hr5 8/xOP3820vAB/14ngZRFqOkKRTBslps= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=ild4EO3d; spf=pass (imf12.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686297378; 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=ild4EO3d1vlq0dWCOc/DB13nyc/wkDMpgXLzXiZzl0PiUmGd/zKu3cmnNlEASBsn9YgmoU gYWmGnPtvhhD5Pet6TXhE1rz+kYDnhW2vz0vQfDfeHv32Lna7kTltPiQqORtcXeiWnn4xs zv0xKnrZ4PTKL8TevNAkBpp4s8jdyq8= 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-Rspamd-Queue-Id: 5CDE340017 X-Rspam-User: X-Stat-Signature: kesaeqed75wu61fowm8ixsgrispn6sew X-Rspamd-Server: rspam03 X-HE-Tag: 1686297379-172674 X-HE-Meta: U2FsdGVkX1/jd5dxJWS2IWrtHRGRBG0ehVW/Cu6PSso6dNk79sUctAW/seqvPiNzUZN/wdSpbC2a1BxFD0SuCk5TrwRzVurk8vAdAcLDa/n7YweLI5CP03+PTLNVbJy7pQOS81j46ag6m489FTu3mEZqdYI1tKvwO8FDHeqgc9Z0+ZyW4+5023m4P/jXivIZKshBmPqmeCJ+rjbCm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.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Architectures can be converted to GENERIC_IOREMAP, to take standard ioremap_xxx() and iounmap() way. But some ARCH-es could have specific handling for ioremap_prot(), ioremap() and iounmap(), than standard methods. In oder to convert these ARCH-es to take GENERIC_IOREMAP method, allow these architecutres to have their own ioremap_prot(), ioremap() and iounmap() definitions. Signed-off-by: Baoquan He Acked-by: Arnd Bergmann Reviewed-by: Christoph Hellwig Reviewed-by: Kefeng Wang Reviewed-by: Mike Rapoport (IBM) Cc: linux-arch@vger.kernel.org --- include/asm-generic/io.h | 3 +++ mm/ioremap.c | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/include/asm-generic/io.h b/include/asm-generic/io.h index a7ca2099ba19..39244c3ee797 100644 --- a/include/asm-generic/io.h +++ b/include/asm-generic/io.h @@ -1081,11 +1081,14 @@ void __iomem *ioremap_prot(phys_addr_t phys_addr, size_t size, void iounmap(volatile void __iomem *addr); void generic_iounmap(volatile void __iomem *addr); +#ifndef ioremap +#define ioremap ioremap static inline void __iomem *ioremap(phys_addr_t addr, size_t size) { /* _PAGE_IOREMAP needs to be supplied by the architecture */ return ioremap_prot(addr, size, _PAGE_IOREMAP); } +#endif #endif /* !CONFIG_MMU || CONFIG_GENERIC_IOREMAP */ #ifndef ioremap_wc diff --git a/mm/ioremap.c b/mm/ioremap.c index db6234b9db59..9f34a8f90b58 100644 --- a/mm/ioremap.c +++ b/mm/ioremap.c @@ -46,12 +46,14 @@ void __iomem *generic_ioremap_prot(phys_addr_t phys_addr, size_t size, return (void __iomem *)(vaddr + offset); } +#ifndef ioremap_prot void __iomem *ioremap_prot(phys_addr_t phys_addr, size_t size, unsigned long prot) { return generic_ioremap_prot(phys_addr, size, __pgprot(prot)); } EXPORT_SYMBOL(ioremap_prot); +#endif void generic_iounmap(volatile void __iomem *addr) { @@ -64,8 +66,10 @@ void generic_iounmap(volatile void __iomem *addr) vunmap(vaddr); } +#ifndef iounmap void iounmap(volatile void __iomem *addr) { generic_iounmap(addr); } EXPORT_SYMBOL(iounmap); +#endif From patchwork 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: 13273356 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1E378C7EE25 for ; Fri, 9 Jun 2023 07:56:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B21028E0002; Fri, 9 Jun 2023 03:56:28 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AD3758E0001; Fri, 9 Jun 2023 03:56:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 999C08E0002; Fri, 9 Jun 2023 03:56:28 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 8D5818E0001 for ; Fri, 9 Jun 2023 03:56:28 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 5DA871A016E for ; Fri, 9 Jun 2023 07:56:28 +0000 (UTC) X-FDA: 80882452056.09.468A2E5 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf02.hostedemail.com (Postfix) with ESMTP id 82F508000C for ; Fri, 9 Jun 2023 07:56:26 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=BHboCAXc; spf=pass (imf02.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1686297386; a=rsa-sha256; cv=none; b=T+MPNljR5bIMip5vJkGWPRI1Zv2fIb2snUsIUKEXRjsdhwUbkPssNkqh0EYlzvaut5KLLt ngDxlPAq+E24dhzPnYn0/vW1+4TqBfunIKZ2vczghVzUxyLFD+Uq3mc2/AGJryL0JaUlUv 39KrA9leF4JwTrQ8kEoL8Ft3EKUqDQM= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=BHboCAXc; spf=pass (imf02.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1686297386; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=0wYOGjo01By5N6ypk4T/kszJYngB2yHKY4BDovVrGlY=; b=Xq/759Mh3vK94UOTit8todGQ6GvABT8cUyMTqfFFDwtucpHoFliVIDJ73eAQ0d3xh7Vhki 3pF1okduXs+NVacSqaCJhJTuB3DURFEFiFLEn0qq0ERi32RoR5Mjr0TfeWn2UZMJTiBVFi tMx+eZmghro9IySayUiWvAElY5PQkYE= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686297385; 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=BHboCAXcp/foVP+3euYOC7QTrV+HfcPLlpWZjAUBQqwxtODcF/4Fsub1z1IwjVWnvfgd2n BqJO1pk8BzbmDryZlTemEU6Lq2TkEJvbrjxTnxfDdkJo122VkUUM/fOYHbnXmLYvmDlZVR FT+XTaWWWtTg+4CuSDPj+AJlH2Dgdro= 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-Rspamd-Server: rspam08 X-Rspamd-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7cb2QYm D8DfcAQt7XbztoeC9yQOyUiYUd9EHEcMi+cP34yLPHXUYCEAB6Q574nlpCPgdWx4ZyTuYUyYFiFSuKFEiO29+x9Oddhks6OUNvKxVVSyqAun1ANl3lUg5FycCpnm3bo8MGzxEo8s/Gxjqpon9MptdV6lcsOGB86H7wADpw2CGXlAoV4WuVRK1QT6mILtHE7cgv2PHMmGj6i6UWsU1wyJSSf6tKfc7BbMeBECfdcI8V7c+VdojMvnNQ02qtgigaJd4I6fd1xNDrfpAiO5kQj/FEpYcaDaPnSw8AkFGI615SGmRqY5n0TWXh89YnjKlwYSAJDfOWa+aozmPbWD/FkQHdCJr6SFp6ySN/S7TZ7u5Av8QsCY= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Several architectures has done checking if slab if available in ioremap_prot(). In fact it should be done in generic ioremap_prot() since on any architecutre, slab allocator must be available before get_vm_area_caller() and vunmap() are used. Add the checking into generic_ioremap_prot(). Suggested-by: Christophe Leroy Signed-off-by: Baoquan He Reviewed-by: Christoph Hellwig Reviewed-by: Kefeng Wang Reviewed-by: Mike Rapoport (IBM) --- 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: 13273357 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id DAAB4C7EE2F for ; Fri, 9 Jun 2023 07:56:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 750CF8E0003; Fri, 9 Jun 2023 03:56:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 701BD8E0001; Fri, 9 Jun 2023 03:56:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5A1558E0003; Fri, 9 Jun 2023 03:56:41 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 4CEA78E0001 for ; Fri, 9 Jun 2023 03:56:41 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 4DAD1160164 for ; Fri, 9 Jun 2023 07:56:38 +0000 (UTC) X-FDA: 80882452476.13.699F1C1 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf08.hostedemail.com (Postfix) with ESMTP id 92AED160009 for ; Fri, 9 Jun 2023 07:56:36 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="iABgIBB/"; spf=pass (imf08.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1686297396; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=AgITI2yqguKz3xZ3AEWeb8MIawpkLomY+LhKu59PhRc=; b=e5ZudPGdJH/JmCLp33l1vcx7PBXJ4NBzKqqUJyJmw7fJqSpHiCPOEGvjKUJe3c+koR85Fo UWybbkmq/1sJi3VAWqWOJseam8SvQgYZrr8KlF/gdeYZ33XZttYBZ1mwWjnwKGVZPCusfC l78ESV0uV0SEt8o3BTXUkKfX2rJR6OI= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="iABgIBB/"; spf=pass (imf08.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1686297396; a=rsa-sha256; cv=none; b=sGWV0IRbH89buup7Q/G521qKXdbMO6It5yPS9hfh4UUWm6skdi1TA88E+QYOGWN51nswgh JUX+wyuhcZCitGaOrZfs7Z0y427VdKyyk52CoC1pcwphKhdhNjuPMn/5t79okMESEGaXve 258H4lSTOzrhk1R4Ob/1za0iVc9p438= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686297395; 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=iABgIBB/3UCgrr71nHYc89nn1nmO56X6PI/q+lbiLUhzpToBvwV27dmXtFpnogMKU1tqoO g/SbA5g1eFHiwzj0Cdsi02esSNZJAK89zypzEOhEi2PwLuEQVoSyv9WI9Q8L7Twz3fmqsL kJcZNGO04OlskmZUQpqdZPYAzDQbb/Q= 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-Rspamd-Queue-Id: 92AED160009 X-Rspam-User: X-Stat-Signature: 5abkacdgt88pzc11hzaapoqndbkrkn3g X-Rspamd-Server: rspam01 X-HE-Tag: 1686297396-525004 X-HE-Meta: U2FsdGVkX19Gic+mz97fVNYGQAFiihDsXWG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ZVAmk1zBH03yradcquOSqTXnUSm+JZI0qvRyhEIMQQjpt985kYgUQau3ZLwK4ywGWZQ3WjQrKTqVLxb/q9gW72TjlQWlkbcp5Wsw8/liubRKZHdhYXphEehOQKAcAjGs7/PAdM/MHnojQnBrab3CFtSH2UfyexaB6s3RgrQgh69BV+XMrLlbOzg0FtBiODcs0Gd/jjnojbdJSvzc3LcA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: By taking GENERIC_IOREMAP method, the generic generic_ioremap_prot(), generic_iounmap(), and their generic wrapper ioremap_prot(), ioremap() and iounmap() are all visible and available to arch. Arch needs to provide wrapper functions to override the generic versions if there's arch specific handling in its ioremap_prot(), ioremap() or iounmap(). This change will simplify implementation by removing duplicated codes with generic_ioremap_prot() and generic_iounmap(), and has the equivalent functioality as before. Here, add wrapper functions ioremap_prot() and iounmap() for arc's special operation when ioremap_prot() and iounmap(). Signed-off-by: Baoquan He Reviewed-by: Christoph Hellwig Reviewed-by: Mike Rapoport (IBM) Cc: Vineet Gupta Cc: linux-snps-arc@lists.infradead.org --- arch/arc/Kconfig | 1 + arch/arc/include/asm/io.h | 7 +++--- arch/arc/mm/ioremap.c | 49 ++++----------------------------------- 3 files changed, 8 insertions(+), 49 deletions(-) diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig index ab6d701365bb..3a666ee0c0bc 100644 --- a/arch/arc/Kconfig +++ b/arch/arc/Kconfig @@ -26,6 +26,7 @@ config ARC select GENERIC_PENDING_IRQ if SMP select GENERIC_SCHED_CLOCK select GENERIC_SMP_IDLE_THREAD + select GENERIC_IOREMAP select HAVE_ARCH_KGDB select HAVE_ARCH_TRACEHOOK select HAVE_ARCH_TRANSPARENT_HUGEPAGE if ARC_MMU_V4 diff --git a/arch/arc/include/asm/io.h b/arch/arc/include/asm/io.h index 80347382a380..4fdb7350636c 100644 --- a/arch/arc/include/asm/io.h +++ b/arch/arc/include/asm/io.h @@ -21,8 +21,9 @@ #endif extern void __iomem *ioremap(phys_addr_t paddr, unsigned long size); -extern void __iomem *ioremap_prot(phys_addr_t paddr, unsigned long size, - unsigned long flags); +#define ioremap ioremap +#define ioremap_prot ioremap_prot +#define iounmap iounmap static inline void __iomem *ioport_map(unsigned long port, unsigned int nr) { return (void __iomem *)port; @@ -32,8 +33,6 @@ static inline void ioport_unmap(void __iomem *addr) { } -extern void iounmap(const volatile void __iomem *addr); - /* * io{read,write}{16,32}be() macros */ diff --git a/arch/arc/mm/ioremap.c b/arch/arc/mm/ioremap.c index 712c2311daef..b07004d53267 100644 --- a/arch/arc/mm/ioremap.c +++ b/arch/arc/mm/ioremap.c @@ -8,7 +8,6 @@ #include #include #include -#include #include static inline bool arc_uncached_addr_space(phys_addr_t paddr) @@ -25,13 +24,6 @@ static inline bool arc_uncached_addr_space(phys_addr_t paddr) void __iomem *ioremap(phys_addr_t paddr, unsigned long size) { - phys_addr_t end; - - /* Don't allow wraparound or zero size */ - end = paddr + size - 1; - if (!size || (end < paddr)) - return NULL; - /* * If the region is h/w uncached, MMU mapping can be elided as optim * The cast to u32 is fine as this region can only be inside 4GB @@ -51,55 +43,22 @@ EXPORT_SYMBOL(ioremap); * ARC hardware uncached region, this one still goes thru the MMU as caller * might need finer access control (R/W/X) */ -void __iomem *ioremap_prot(phys_addr_t paddr, unsigned long size, +void __iomem *ioremap_prot(phys_addr_t paddr, size_t size, unsigned long flags) { - unsigned int off; - unsigned long vaddr; - struct vm_struct *area; - phys_addr_t end; pgprot_t prot = __pgprot(flags); - /* Don't allow wraparound, zero size */ - end = paddr + size - 1; - if ((!size) || (end < paddr)) - return NULL; - - /* An early platform driver might end up here */ - if (!slab_is_available()) - return NULL; - /* force uncached */ - prot = pgprot_noncached(prot); - - /* Mappings have to be page-aligned */ - off = paddr & ~PAGE_MASK; - paddr &= PAGE_MASK_PHYS; - size = PAGE_ALIGN(end + 1) - paddr; - - /* - * Ok, go for it.. - */ - area = get_vm_area(size, VM_IOREMAP); - if (!area) - return NULL; - area->phys_addr = paddr; - vaddr = (unsigned long)area->addr; - if (ioremap_page_range(vaddr, vaddr + size, paddr, prot)) { - vunmap((void __force *)vaddr); - return NULL; - } - return (void __iomem *)(off + (char __iomem *)vaddr); + return generic_ioremap_prot(paddr, size, pgprot_noncached(prot)); } EXPORT_SYMBOL(ioremap_prot); - -void iounmap(const volatile void __iomem *addr) +void iounmap(volatile void __iomem *addr) { /* weird double cast to handle phys_addr_t > 32 bits */ if (arc_uncached_addr_space((phys_addr_t)(u32)addr)) return; - vfree((void *)(PAGE_MASK & (unsigned long __force)addr)); + generic_iounmap(addr); } EXPORT_SYMBOL(iounmap); From patchwork 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: 13273358 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 92A56C7EE25 for ; Fri, 9 Jun 2023 07:56:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2BE338E000A; Fri, 9 Jun 2023 03:56:43 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 246998E0001; Fri, 9 Jun 2023 03:56:43 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0E73F8E000A; Fri, 9 Jun 2023 03:56:43 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 02F958E0001 for ; Fri, 9 Jun 2023 03:56:43 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id CC99F160164 for ; Fri, 9 Jun 2023 07:56:42 +0000 (UTC) X-FDA: 80882452644.17.E72D4AA Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf21.hostedemail.com (Postfix) with ESMTP id 197631C0006 for ; Fri, 9 Jun 2023 07:56:40 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=MVpzLGXX; spf=pass (imf21.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1686297401; a=rsa-sha256; cv=none; b=E+7wIPakHfudk4NlCplYyAe1qr2idw6motDG2nIj8ZC1x8sQ/vnmYMiG77ZAj4EDPCi7RB qfQAGiQmJC4Am2ek+bjC9zm4s/55Dgcd/8KkjP5/uHOL/gmwICTrkYk69Dy/G5aK0hKMZE Pz/mXrKAGChuyeeRp9N6liy9vlFKqec= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=MVpzLGXX; spf=pass (imf21.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1686297401; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=ua5XWkW27x0Nyt2yapSJ4JgStlbMxAmr6HBzd8gpRZY=; b=3zmlwF05T4KNQM/1fw3WhOSquQtB1Epozib4pxelt0r6yXOWiqutv+GVF7KD2HWkvGbKmR dflvl6/7H6NuJuTxKWw72cgDW4X2LOs4jFF3uUvfvAXApkp3OJ64aYyhQCLVsxMBqdtka6 0go1RaTls5DdWJltUGuxfr27xGIYAu0= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686297400; 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=MVpzLGXXeJH5THnR39TQvT5rNlj5Ao0W2l7tBFYBcme8vfvpHpl89sCElu0R1lcVhNgAoX IjIFYzj19W7PU0NGJarHlCV0mBS9vmmnJlKMdUhHohEZAOsVnTvM3ZPJl7vvLMPDhCjB+n mh27mhwcANP/ormgN6RVU4Dhr3ZUXWI= 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-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 197631C0006 X-Stat-Signature: 6krm8xzr71tcqbtekybzkek6ccyocdfb X-Rspam-User: X-HE-Tag: 1686297400-837993 X-HE-Meta: U2FsdGVkX1/63QEihEVcdZfCmRhyg5QF44MrrDsELHr3N5hmRm59wLbeSd4UcT/bcY7yg2206t3h99NYlLR/jQ05uh52eBAAgS0XtN9vH66/8rRivEspXUJwSdcNCprAUW3MUj0qA53Jc8SZj+PylNAxzmfDy5GuWfeYKEW5AN34RudZ2EB+ULufGXMZ6+yHGtstnW13Rp8Rudq1mVTZqrQuc5xHTTApuaUskT2RuRhWidrv7ayZdcyZ2CZjVW5RgvTih+FU7ohOrUzj/tPSu1eCkEsXDvQoUA37r3sVBjQZPaKbV+vDYEety5QZuWQg+I9Ku9NAOEz0zIEzTiW67oST26PMzo/7evkDFcJ8oRwVcj85P7P+Yh+GsUBPsmUdfDONxqTqxIdzvEbzg4I8/ztVubfYWeRBMa8zGPXAbQorZpbjBXmMZuwf1Jgy9gxFQMZbniKcJvJjRL4AAV6n/shVWS8KH/bK3q1t9Bw+vQGr/RP5x4/7eIu0u+uRhIH4oMM3Q12FtDtWpZVz3jW8EwZr/RzGDd2tZdmxfaCBO8dSa0k7eEBWTV9Ys7RzIb8p7Q6OacvpbNeWoIFw7Bqacdmkx/OFaFpBXUMGApE1UGUFWIi5JJ2rVye+2sZ2GMdGuARinEPGw+xtRl39qiiPwq32/pC7nA5j6x+PYH61O3nq0aHzwewX7EUAsxIPF1iAm0+uogMnA/e8GO6gjN1paetkMllNU4POt5swPICySUTzNwSqy/ULBcVa58U3klkcOboNeynFij6quzJgZiE/SoGuKCtiVbAjPRtVxVbTKdkxhHMQQyviq2t0NRt8FCmCazEsp1r15HaTEK1GO8fDMbBYKUHbd4Wv2B8J+qv4iT/RrFEM23Zhu51N7qNSFHaWGDKUjwauyetN9CyEHxkOzXTC0MbDNIIR4ZOANe280l+7fHwmNSSENrHuUEaHIB2eXPo2MPn/wA+yziY4Nh5 oTr3nDi6 dEtR3jXA9IBS0Hdg2vSdabKUvmIQbwuamwD9DfCCwP/X3nFffhmhAK9/HbysdkiTXOjP646oXf1uisZZs/wSDTGSFg+WqkBiqyFn82kHml4A2xgNHx14wkgphKS+NrGNLTWkwcXf+XjUS6OrX2wO3MfR3V66vZM3APf3V8c2wGc6+8+G30nDsSllLK8+shdnmBnRIQWpTET7slKgyEeiiM0ZTF3zqMeqT+jzjPX2ew4TiqjmW7xIaXxRGON0C9WN255RmN+QskTFUZIPLQu4JFIqJ4w== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: By taking GENERIC_IOREMAP method, the generic generic_ioremap_prot(), generic_iounmap(), and their generic wrapper ioremap_prot(), ioremap() and iounmap() are all visible and available to arch. Arch needs to provide wrapper functions to override the generic versions if there's arch specific handling in its ioremap_prot(), ioremap() or iounmap(). This change will simplify implementation by removing duplicated codes with generic_ioremap_prot() and generic_iounmap(), and has the equivalent functioality as before. Here, add wrapper functions ioremap_prot() and iounmap() for ia64's special operation when ioremap() and iounmap(). Signed-off-by: Baoquan He Reviewed-by: Christoph Hellwig Reviewed-by: Mike Rapoport (IBM) Cc: linux-ia64@vger.kernel.org --- arch/ia64/Kconfig | 1 + arch/ia64/include/asm/io.h | 13 +++++------- arch/ia64/mm/ioremap.c | 41 ++++++-------------------------------- 3 files changed, 12 insertions(+), 43 deletions(-) diff --git a/arch/ia64/Kconfig b/arch/ia64/Kconfig index 21fa63ce5ffc..4f970b6d8032 100644 --- a/arch/ia64/Kconfig +++ b/arch/ia64/Kconfig @@ -46,6 +46,7 @@ config IA64 select GENERIC_IRQ_LEGACY select ARCH_HAVE_NMI_SAFE_CMPXCHG select GENERIC_IOMAP + select GENERIC_IOREMAP select GENERIC_SMP_IDLE_THREAD select ARCH_TASK_STRUCT_ON_STACK select ARCH_TASK_STRUCT_ALLOCATOR diff --git a/arch/ia64/include/asm/io.h b/arch/ia64/include/asm/io.h index 83a492c8d298..eedc0afa8cad 100644 --- a/arch/ia64/include/asm/io.h +++ b/arch/ia64/include/asm/io.h @@ -243,15 +243,12 @@ static inline void outsl(unsigned long port, const void *src, # ifdef __KERNEL__ -extern void __iomem * ioremap(unsigned long offset, unsigned long size); +#define _PAGE_IOREMAP pgprot_val(PAGE_KERNEL) + extern void __iomem * ioremap_uc(unsigned long offset, unsigned long size); -extern void iounmap (volatile void __iomem *addr); -static inline void __iomem * ioremap_cache (unsigned long phys_addr, unsigned long size) -{ - return ioremap(phys_addr, size); -} -#define ioremap ioremap -#define ioremap_cache ioremap_cache + +#define ioremap_prot ioremap_prot +#define ioremap_cache ioremap #define ioremap_uc ioremap_uc #define iounmap iounmap diff --git a/arch/ia64/mm/ioremap.c b/arch/ia64/mm/ioremap.c index 92b81bc91397..711b6abc822e 100644 --- a/arch/ia64/mm/ioremap.c +++ b/arch/ia64/mm/ioremap.c @@ -29,13 +29,9 @@ early_ioremap (unsigned long phys_addr, unsigned long size) return __ioremap_uc(phys_addr); } -void __iomem * -ioremap (unsigned long phys_addr, unsigned long size) +void __iomem *ioremap_prot(phys_addr_t phys_addr, size_t size, + unsigned long flags) { - void __iomem *addr; - struct vm_struct *area; - unsigned long offset; - pgprot_t prot; u64 attr; unsigned long gran_base, gran_size; unsigned long page_base; @@ -68,36 +64,12 @@ ioremap (unsigned long phys_addr, unsigned long size) */ page_base = phys_addr & PAGE_MASK; size = PAGE_ALIGN(phys_addr + size) - page_base; - if (efi_mem_attribute(page_base, size) & EFI_MEMORY_WB) { - prot = PAGE_KERNEL; - - /* - * Mappings have to be page-aligned - */ - offset = phys_addr & ~PAGE_MASK; - phys_addr &= PAGE_MASK; - - /* - * Ok, go for it.. - */ - area = get_vm_area(size, VM_IOREMAP); - if (!area) - return NULL; - - area->phys_addr = phys_addr; - addr = (void __iomem *) area->addr; - if (ioremap_page_range((unsigned long) addr, - (unsigned long) addr + size, phys_addr, prot)) { - vunmap((void __force *) addr); - return NULL; - } - - return (void __iomem *) (offset + (char __iomem *)addr); - } + if (efi_mem_attribute(page_base, size) & EFI_MEMORY_WB) + return generic_ioremap_prot(phys_addr, size, __pgprot(flags)); return __ioremap_uc(phys_addr); } -EXPORT_SYMBOL(ioremap); +EXPORT_SYMBOL(ioremap_prot); void __iomem * ioremap_uc(unsigned long phys_addr, unsigned long size) @@ -114,8 +86,7 @@ early_iounmap (volatile void __iomem *addr, unsigned long size) { } -void -iounmap (volatile void __iomem *addr) +void iounmap(volatile void __iomem *addr) { if (REGION_NUMBER(addr) == RGN_GATE) vunmap((void *) ((unsigned long) addr & PAGE_MASK)); From patchwork 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: 13273359 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6122DC7EE29 for ; Fri, 9 Jun 2023 07:56:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EF39A8E0005; Fri, 9 Jun 2023 03:56:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EA27B8E0001; Fri, 9 Jun 2023 03:56:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D924A8E0005; Fri, 9 Jun 2023 03:56:51 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id CAC878E0001 for ; Fri, 9 Jun 2023 03:56:51 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id A43498014E for ; Fri, 9 Jun 2023 07:56:51 +0000 (UTC) X-FDA: 80882453022.28.83A9ADA Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf24.hostedemail.com (Postfix) with ESMTP id E8133180010 for ; Fri, 9 Jun 2023 07:56:49 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="P5hR+/iQ"; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf24.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1686297410; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=0lDwY01DeRkcypkPwr3wPDENx+u681h4hIQx3NHXU5U=; b=1CrwSrGIyEcf97Dwej/nyRBmdYMHTtWFbjFTh2emHYlaFaR1VV87AN0VP2aVohbJKAvaL8 7MSQ/CIyrAnhLeMMwHwhSCazDNdXWOfgxsaNytPyjBjFdtV/UuyBN178clYHGh7TPGi7nd pYtWIxUWLnFpb0DnLYQyC0OaY6ctKTM= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="P5hR+/iQ"; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf24.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1686297410; a=rsa-sha256; cv=none; b=a+qdrwVChdxwEMrqNCBMbqx7l2AuOYjyjQthtYq4N4h6BK6ZDoSoRf2e3L0dvdoxhOnRXY CPwYIMqkYuOYwLvYx16bid/mQzLEbUHyvyFSwTRVERWWxQczALLzH5se+EbqhtwQfC3/h4 ZVBdAgo8XwZGkBFQB1kS87Fc1YTgI2Q= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686297409; 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=P5hR+/iQcb5NywF51ctfi1cYYzsPhYPiWygQ0rVZGBt4nFZgEUSh6MbnOzP7VhL86XOz3e QQO6KzGNGKsbG0b2P7lkpDwfDv5Xqr3kU8eaMm8J20eJRYIETLsrkea7IYLaQwn/B2JP57 pMUYoYQ2Q3hx3XEpnDFDTtLfmKakrpw= 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-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: E8133180010 X-Stat-Signature: xjzkuan9q3sr7n6hqp4nfxjscbum4dzh X-Rspam-User: X-HE-Tag: 1686297409-61969 X-HE-Meta: U2FsdGVkX18cTO0DLVpNTnZyW3UIukJfJoAIot2rz7oWTaGhpIvBUz56JYySmkcxVJDUf68OIrzyZZIy2s9tGbJGnJInJkMGmW+dX5D8GFvso9lGXGsuEDnUASJXi85kgmYk5Mfp7YEHNFcqCmHjCmKOxavgX3kynz8OztjkjN+F1NYcKNujdBqPBV4yxdzUx12s6j6VcVLij3yAQCOsYFTrW0UAFrbBveRSArwYc2uOZ8pzAe6jtNKqG+7FB2dmfJT7oYw1Pi+xhIk+qp2BevtSkROqek+wB4Dp3YrcD/Gdz9+fmk+do6HCN3qqYQuQ+HJWPmfUhhTmYlAQyObL1evX6UVhCvpJ+dv8XN1NP4PJNsP+BlxB/zz6psx/zZUlBENPwn25jPscghSIOWWoIuTis2vZUNVyKePL2vBFWd+OPyub35dh+18uCOJ/TdoUtpg2NvvOvhKQyxtUdWVDtlK9v/M2hb/lfORlpa0Rg/aK9gjHO7AsymLKz9RiFcRLxXK0Xt26tz4vSWu+FGJNWt0fLUXsUuXCwJ5p21dGXi3Euc9H34WaTl/6A3ovlKwlK5L6nBz5cv8gYrUGs5nlm/+VjWk0X445Ie2Nw60LUK7Re9rLm9KPFu0sazlWAtMLQ2B5UhuMMesVaaMF148YLLfXzwWFTK5BSutJr0Qhgmyz7ogntmr+GluPLK/b3qKYRIvCqTyMtBWZCqCY9zCYdhWvcWaxui8rPjFs57Olu3u4M5Iyn7I+boFJhvtDnHr2x95HhMsLfJmLFnoigWcEozd8OejAQuc/g/Ct4OCvlXCJXle68KPYuiLyjbQe5nTYDuAOWNpUQ7GWKWf3lWaHLegjhvI62daheZyLHpuRJGRJpSDAJMUHXrnoumTw4tqKmg5EWW3Zl+ah4PhKLkVR2sUi6mkbooNajHsE8M9YVQIUT4RhmGSlF+rjHx2ayl1ajwqAuVMHb/VrYHXN4b3 gYfb75+f 69hedb+rXPmA9JP0+4u7UPvHS/EmWZdik3NyAeCCWDC55JdU3hnMOZUr7akbU7F53yEDoWI4cYirA5bl4odbQ9fI4MeO9MzStcUd9Hg7Mxe85sF0UMjQHRnWdadFOAlr9yXB6Jb3Xg061x+fBaPnibBo6WMFco1scywUBV+88VbVAy6d1DsL4F2y6cc4iMMMITcn5808GnHM4noYb40LeLSvxVT/6voXJGi3eO8lRErCySdeNyuTGGiHdaOA8B2J2ExW84jgGIcO7YcdfGdZuN/ZPp3sgC2VvpzLhht5bII9Ho5+v3f6QSOxnrg== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: By taking GENERIC_IOREMAP method, the generic generic_ioremap_prot(), generic_iounmap(), and their generic wrapper ioremap_prot(), ioremap() and iounmap() are all visible and available to arch. Arch needs to provide wrapper functions to override the generic versions if there's arch specific handling in its ioremap_prot(), ioremap() or iounmap(). This change will simplify implementation by removing duplicated codes with generic_ioremap_prot() and generic_iounmap(), and has the equivalent functioality as before. For openrisc, the current ioremap() and iounmap() are the same as generic version. After taking GENERIC_IOREMAP way, the old ioremap() and iounmap() can be completely removed. Signed-off-by: Baoquan He 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: 13273360 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7E966C7EE25 for ; Fri, 9 Jun 2023 07:56:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1D3038E0006; Fri, 9 Jun 2023 03:56:57 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1B5AE8E0001; Fri, 9 Jun 2023 03:56:57 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0718F8E0006; Fri, 9 Jun 2023 03:56:57 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id EEE498E0001 for ; Fri, 9 Jun 2023 03:56:56 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id AF57E12016A for ; Fri, 9 Jun 2023 07:56:56 +0000 (UTC) X-FDA: 80882453232.23.49B7AAA Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf15.hostedemail.com (Postfix) with ESMTP id E87C5A0019 for ; Fri, 9 Jun 2023 07:56:54 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=NI9WLVKz; spf=pass (imf15.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1686297415; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=etYbctmjhFxwpuu9vO4kynRojZXXRgJ3ulf2IbYPQOU=; b=CQJRDQaEPiDZLhKcBXmLtTLZeekQA9NrbZAfHlA7L/nveiLv92RGIaIm4seCvpjBanYbMz u2dooBeEiCE+LYAthuHOXm92Yopo+j42nWV9Qe/UTG5LbATinZieJLRxqMGFX9haXX+0EF QuESOMhE1ClAtk7eaPjCVCZQQRv/IXc= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1686297415; a=rsa-sha256; cv=none; b=ebecOT+GN2+1QqiSVFDdrDkV7EmoQSVCK3SzjBbubdjWUIY4HlXNGgZ4Rzp36NDF3fIeQN m8zYxaj/8pWBViWr94cZhEjELIIhWvUUdgcJ0ejiQFv228964ZCP3USMxW5rBBnyYXmaOz LH5gbLx66tTyTFrR26EKuBv8x5TCo7E= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=NI9WLVKz; spf=pass (imf15.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686297414; 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=NI9WLVKz+VbuTCcidBUFN5l7z2hGC/PDw0gYxAYQKpJj+5Ny/rmUMJKVszzEJpAE/uDWZp 5qRTyJfM+ISXJ9s0X3UPA6TnCFgxnBF6AeKWIwDOlDLBH3hSUgBbdhBdNgcOAJKcwIZEYH SYtMvbdY+uVNlXv0mWgFvsy36UjXzt0= 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-Stat-Signature: csstg64etbwuojdmbywgx78h16p49zf9 X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: E87C5A0019 X-Rspam-User: X-HE-Tag: 1686297414-155999 X-HE-Meta: U2FsdGVkX18Rx+9oWejMSp7GbEbcc3sEuNygDW3RK/CYI8auY2XUdIkcEQS00Uo8k3ZGbngI8ePhWDkvkxg82A+iccEf0LfEuPYuEepTsAk4aDzmxHUGfe3N1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5o6nfSkW42j9CSAyHVpggoYIw/1FzPMaau5NaN+EbhACXFrKF8eiqlgnHiiFPK11bSlmBGOW8C1iVAF+C9ZCTedM2+KGMmrOSenUUBOQB4+vqZw== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: By taking GENERIC_IOREMAP method, the generic generic_ioremap_prot(), generic_iounmap(), and their generic wrapper ioremap_prot(), ioremap() and iounmap() are all visible and available to arch. Arch needs to provide wrapper functions to override the generic versions if there's arch specific handling in its ioremap_prot(), ioremap() or iounmap(). This change will simplify implementation by removing duplicated codes with generic_ioremap_prot() and generic_iounmap(), and has the equivalent functioality as before. Here, add wrapper functions ioremap_prot() and iounmap() for s390's special operation when ioremap() and iounmap(). Signed-off-by: Baoquan He Reviewed-by: Niklas Schnelle Tested-by: Niklas Schnelle 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: 13273362 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6BCBAC7EE29 for ; Fri, 9 Jun 2023 07:57:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0C2578E000B; Fri, 9 Jun 2023 03:57:17 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 04B098E0001; Fri, 9 Jun 2023 03:57:16 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E2CE38E000B; Fri, 9 Jun 2023 03:57:16 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id CE0BF8E0001 for ; Fri, 9 Jun 2023 03:57:16 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 97473140162 for ; Fri, 9 Jun 2023 07:57:16 +0000 (UTC) X-FDA: 80882454072.16.9864521 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf16.hostedemail.com (Postfix) with ESMTP id CEF8A180011 for ; Fri, 9 Jun 2023 07:57:14 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=CWHAKSEW; spf=pass (imf16.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1686297434; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=LUIKuTNwx3aGCN/mpc81rLXKw/yQlIAJox5sUw6Md70=; b=MhLr3us7SLk4mzKicMraIRWTtfay+llfagWTVM6FoEOwEyFwYj42Vps+HbZu1kwYZql7kW ygxe5Myzgn0Nhf3b2MCoqnsnKta/fVWHjxAc7NNP8yEg5B2z6yAzCZ8ElmHZnUcau2Kny2 SjM0lH+vG58dvWyV0rdmSbYCU890hu0= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1686297434; a=rsa-sha256; cv=none; b=7nOiT1jIMehGOH/eyxxbxz22fyj+/e18NXgq4S8UMMnINNzVv8Cmu9ssBQaFWxklKpbTv7 a4FH36yAaqt72lcnIrBD7cVN4wbY4UWkHgZgjLrG9J2V0xrDCHlnS3svYmz3d7jsEO0xAJ 5CHdMb/pNX8gKQVbnj4FqLAaTrOZQrM= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=CWHAKSEW; spf=pass (imf16.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686297434; 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=CWHAKSEWmJJzJkiOyZG9eFPU8KON9eYOHwLG6WUuDwIHlt1MCdr2cMMF1u9HYjWo6gAzDv OPFXUplSfINESmno72SmSxLTGHtQXymdTwoNpu/yyFS/NUQUuP1Sh+C4UL9ZoLyPlEEeD1 6+mleVKmeBZvr732Z4vyZ7TPGyKDgCw= 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-Stat-Signature: auhnphoh1rhp7pa9nsu51tobx13hx89i X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: CEF8A180011 X-Rspam-User: X-HE-Tag: 1686297434-384033 X-HE-Meta: U2FsdGVkX1+bKtwCK4Us3NYPu585t4PJAnFmh4k1/YMR7ZAr73bSTYPzEdvoI12/vYrs+d9Oc4UZOdReOWtR8n9uyJqipjWseWlTCM82vDsLmmVXkbaJKO6cyiswpBPbz9/6754NayZYi1IeYoV1nplGmXymlEPHLoE4IkME8ci5Sy/wbnH+jTDJ9ni/A62VBVWo/T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ogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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: 13273361 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id EDD26C7EE29 for ; Fri, 9 Jun 2023 07:57:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 925338E0007; Fri, 9 Jun 2023 03:57:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 888208E0001; Fri, 9 Jun 2023 03:57:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7295F8E0007; Fri, 9 Jun 2023 03:57:10 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 5FF088E0001 for ; Fri, 9 Jun 2023 03:57:10 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 388531C7272 for ; Fri, 9 Jun 2023 07:57:10 +0000 (UTC) X-FDA: 80882453820.29.7B59F39 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf23.hostedemail.com (Postfix) with ESMTP id 7346F140015 for ; Fri, 9 Jun 2023 07:57:08 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=XIcCyN7V; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf23.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1686297428; a=rsa-sha256; cv=none; b=BmXJ9EXF0tgx5EWO9mR6it4f40HJYYabOo41s2MZfuQ7Wcl8wKLaPg2PzvKjRgyRrGXYdX gKm6I9+mffm/7xUjdRkJi2Z/Uszz7aMj52eCeWOVQsU2bzCnP+fKAwFcI5SDTRzLOfXLAm eRB3c1ksp7OXc2SOkYZte7rxHTULMnA= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=XIcCyN7V; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf23.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1686297428; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=J2JqJ5DVfD1RBef7ys9lCToVJCiVC3QaC6lHIm4BgJc=; b=AvjAGCi+S6GwrKIjGSg74bEw7smiCZIunVESIqy0k34Hza6SshF2NukMQlCJULI4OfuaFe BdpJCDfv8GlilWDIzEX8xO6xgeODv24mCjT5PDbACm7ftNuKEuJvgJnmer0nh4y2MEtkNm qmbCvvULoicaI2LUhHpw1yVLHCNazc0= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686297427; 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=XIcCyN7Vt27a6MDWV17TgqsKDiaUP8o8WEJvsLKu0kAfHjIWlYu/RQvDDUte/az+1ryAUr eF1fcg7zu6XkwiiQuft5v05GNv2YPVJGpv6ZOyubYbQptjlCqJpwJkBc8J+Oy7DFUjFpku EEGQ+idQOt7vzmO/Z11ecLbYfdbARXk= 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-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 7346F140015 X-Stat-Signature: 97n1aidaueef746qt8i3qbpzur5wfa5j X-HE-Tag: 1686297428-352272 X-HE-Meta: U2FsdGVkX18qvsfV0eXNQP+B9glzSdX55ZnXBcQ9++OSTA5QjKSpPkH3FxH6vTpakQdwpg9AGNPUK5mzBE/BwPcu0INEVZR4uc3yM5whGdY1an3PvwhcM0gfph1qw9E3iQNkejrGTHsRaV0FF7fdIXL49Yu9uaL6haDLtRm2TBVxIZ4RHFyzrUOLP6rO4y2h/uQca6CZ157vNsa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5aguvs47ynK77wXFoUXLBrr1KuT6A7kNS4tUugAM5em7cRttldw3fCA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: By taking GENERIC_IOREMAP method, the generic generic_ioremap_prot(), generic_iounmap(), and their generic wrapper ioremap_prot(), ioremap() and iounmap() are all visible and available to arch. Arch needs to provide wrapper functions to override the generic versions if there's arch specific handling in its ioremap_prot(), ioremap() or iounmap(). This change will simplify implementation by removing duplicated codes with generic_ioremap_prot() and generic_iounmap(), and has the equivalent functioality as before. Here, add wrapper functions ioremap_prot() and iounmap() for SuperH's special operation when ioremap() and iounmap(). 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: 13273364 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id ECBCEC7EE2F for ; Fri, 9 Jun 2023 07:57:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D45078E0001; Fri, 9 Jun 2023 03:57:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CF46D8E0008; Fri, 9 Jun 2023 03:57:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B6FDD8E0001; Fri, 9 Jun 2023 03:57:26 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id A44D68E0008 for ; Fri, 9 Jun 2023 03:57:26 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 7CD2E1C72C5 for ; Fri, 9 Jun 2023 07:57:26 +0000 (UTC) X-FDA: 80882454492.24.79BB954 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf21.hostedemail.com (Postfix) with ESMTP id A8FE61C0006 for ; Fri, 9 Jun 2023 07:57:23 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=eEB+oWLg; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf21.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1686297443; a=rsa-sha256; cv=none; b=SwdU/Y24PROS6D8cA73WKQhSbO9Ds4x9pqoolQDocRinSMVeZM84PbcYeI6QsjOy9WdtOr /bNMZzLGf2GLBhA+Q4rUAlgYcXugvvYZ9GDcKyTZmsJ43nBNUCu2G1lmQJn2tOAaxcUYcP aZcOCvKo33hzSar6Qjn2iOUwEIYytXc= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=eEB+oWLg; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf21.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1686297443; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=8xAEmv+klZL2q1puNU7BpopKMmAERiOcnE6W7aPMkiU=; b=ofaVWC3GNcQeIXrmY9Mi/1DKg6C+eRFmWOc0mFk/L1hjIy8SZcJ5u3IH/oI/2xrNspHuuG xVT0IYAXamS/YCwRY4Zh8wrYOspjS6tXCSDn7g4AvpY0FHPiCr8ZlytoFRqvLwwj2oYEm2 Z2hMG7ITyJnZF/uO/EALTgp0pe4mGh0= 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-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: A8FE61C0006 X-Stat-Signature: hyfcerew759zobz9pcjqeeagibrqaef1 X-HE-Tag: 1686297443-908210 X-HE-Meta: U2FsdGVkX18b0T/TFzpJLzFy1HNWQYzMdaD3fRnofHunBezC/SQJ5PTI9eQVvEq4mq8/KxLWU9l8PLn6WArm6rcdpQTpw/KFVxxmDu74oG2LhmPNJLbcxfNDhSei/pepEZS2qLBTi4SGQhk1cTO46ei0bgmXJj3mNhpl51QpIpUAXGuYjbGXlr2C1wTB+5GFl7PP/fypHyP18KdKYxeAWDWGz2PdGKiXr/A9tJJq1wErUzRkwc299V8Yms0vkVFVK5syveN4sksdU9VJ/ERkDmwOUkNG9za9txe9CdiHn9g4CWQFGcRyamD7q6yuH9aARpOU4vCK+WsqwyunV3mWAJxThqc6m6fT5L/unjgJkS46rYMxiAf1L4HKymfA5SRWDuhp3uJJU49/q2tsvviyXxgiUfjX43q7mFKBCLhUDw8pyJcIRRxo/9NfcUW6f1LG6Thn20tUjKK26F9kkseHKlru4bH3c7ltmhybaQvE3vp1wlx560GahNgY1losgxRjge6CMUZoPX17KQSb/V8F/ATAeFRjMHeFzp6d6i/rBNNWS91V5as4WSAiBIt0qDsSjUl7QJNZN2o/Xik6J55lAuySxin6O/Up03hFXf9gbfJ+ozVXRLrUgfdonXgac9F3CjYFA9v+VynlZ2hGk7AYDFhqt+N0jwBB4xxVev3+MlGqTfeTWvKoc87d229BCj8bsT/zvQ/0/ZVTb662LhyYV8qf+0pKcJS25xhsBXX0Sz/5V81DesSz4K/6xTosPSCD3sqELV1StkRiJIcfheJF9dII//Q4PYrNEfcy61jwIP7a8TecMHsZ9wfJAG0QtfYf/f5GAeAJsNLIwLsYEG19V0snQG9gRz1g4AdW4y71bgjJxfzznMvVLk+57lqOjqAeWVLFWRVJBlLcOiaTTZlYLTVxeLgLWxcg+eF43+OMrSW9u34K/Edl4fyt4cwqRR+PwJGtthPNAyAS8E9cchv sVRH2h5I hLVftmojovDO1AjbDy97zXt2hhJSJ4q27/j1ljOSaPWX3Ug4LgAJZVAnnLJUzg1Vf27tGobXXM3NpftOEk34zi+M25NPHylYoxJBsbftNJsphaBSJvlBQb38Id+5gPabzYgXTVeGMpT9nx2AzshRxBdT1QjayYFbItCAUia7I3DPxQKvTp6EjVs26R8EFAjb9zNFy5GgJ++75dXZWYjy1PsHMfj4ld1e4rAVssZc3ZPaGpYwGGAFtfGOObjF5w/XjN7ELPwUwHN50V8mwDJPiOIIF5jYoUCtq8zER/wqWIVkUZYqTG94jJClaSJLpUQeHCwPgj+r1PrjDCw5bymhGU1EZZ4/fwA1RBw35bvVwfL9P6Io= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: By taking GENERIC_IOREMAP method, the generic generic_ioremap_prot(), generic_iounmap(), and their generic wrapper ioremap_prot(), ioremap() and iounmap() are all visible and available to arch. Arch needs to provide wrapper functions to override the generic versions if there's arch specific handling in its ioremap_prot(), ioremap() or iounmap(). This change will simplify implementation by removing duplicated codes with generic_ioremap_prot() and generic_iounmap(), and has the equivalent functioality as before. Here, add wrapper functions ioremap_prot(), ioremap() and iounmap() for xtensa's special operation when ioremap() and iounmap(). Signed-off-by: Baoquan He Reviewed-by: Christoph Hellwig Reviewed-by: Mike Rapoport (IBM) Cc: Chris Zankel Cc: Max Filippov --- arch/xtensa/Kconfig | 1 + arch/xtensa/include/asm/io.h | 32 ++++++++------------ arch/xtensa/mm/ioremap.c | 58 +++++++++--------------------------- 3 files changed, 27 insertions(+), 64 deletions(-) diff --git a/arch/xtensa/Kconfig b/arch/xtensa/Kconfig index 3c6e5471f025..474cbbff3e6c 100644 --- a/arch/xtensa/Kconfig +++ b/arch/xtensa/Kconfig @@ -29,6 +29,7 @@ config XTENSA select GENERIC_LIB_UCMPDI2 select GENERIC_PCI_IOMAP select GENERIC_SCHED_CLOCK + select GENERIC_IOREMAP if MMU select HAVE_ARCH_AUDITSYSCALL select HAVE_ARCH_JUMP_LABEL if !XIP_KERNEL select HAVE_ARCH_KASAN if MMU && !XIP_KERNEL diff --git a/arch/xtensa/include/asm/io.h b/arch/xtensa/include/asm/io.h index a5b707e1c0f4..934e58399c8c 100644 --- a/arch/xtensa/include/asm/io.h +++ b/arch/xtensa/include/asm/io.h @@ -16,6 +16,7 @@ #include #include #include +#include #include @@ -24,22 +25,24 @@ #define PCI_IOBASE ((void __iomem *)XCHAL_KIO_BYPASS_VADDR) #ifdef CONFIG_MMU - -void __iomem *xtensa_ioremap_nocache(unsigned long addr, unsigned long size); -void __iomem *xtensa_ioremap_cache(unsigned long addr, unsigned long size); -void xtensa_iounmap(volatile void __iomem *addr); - /* - * Return the virtual address for the specified bus memory. + * I/O memory mapping functions. */ +void __iomem *ioremap_prot(phys_addr_t phys_addr, size_t size, + unsigned long prot); +#define ioremap_prot ioremap_prot +#define iounmap iounmap + static inline void __iomem *ioremap(unsigned long offset, unsigned long size) { if (offset >= XCHAL_KIO_PADDR && offset - XCHAL_KIO_PADDR < XCHAL_KIO_SIZE) return (void*)(offset-XCHAL_KIO_PADDR+XCHAL_KIO_BYPASS_VADDR); else - return xtensa_ioremap_nocache(offset, size); + return ioremap_prot(offset, size, + pgprot_val(pgprot_noncached(PAGE_KERNEL))); } +#define ioremap ioremap static inline void __iomem *ioremap_cache(unsigned long offset, unsigned long size) @@ -48,21 +51,10 @@ static inline void __iomem *ioremap_cache(unsigned long offset, && offset - XCHAL_KIO_PADDR < XCHAL_KIO_SIZE) return (void*)(offset-XCHAL_KIO_PADDR+XCHAL_KIO_CACHED_VADDR); else - return xtensa_ioremap_cache(offset, size); -} -#define ioremap_cache ioremap_cache + return ioremap_prot(offset, size, pgprot_val(PAGE_KERNEL)); -static inline void iounmap(volatile void __iomem *addr) -{ - unsigned long va = (unsigned long) addr; - - if (!(va >= XCHAL_KIO_CACHED_VADDR && - va - XCHAL_KIO_CACHED_VADDR < XCHAL_KIO_SIZE) && - !(va >= XCHAL_KIO_BYPASS_VADDR && - va - XCHAL_KIO_BYPASS_VADDR < XCHAL_KIO_SIZE)) - xtensa_iounmap(addr); } - +#define ioremap_cache ioremap_cache #endif /* CONFIG_MMU */ #include diff --git a/arch/xtensa/mm/ioremap.c b/arch/xtensa/mm/ioremap.c index a400188c16b9..8ca660b7ab49 100644 --- a/arch/xtensa/mm/ioremap.c +++ b/arch/xtensa/mm/ioremap.c @@ -6,60 +6,30 @@ */ #include -#include #include #include #include -static void __iomem *xtensa_ioremap(unsigned long paddr, unsigned long size, - pgprot_t prot) +void __iomem *ioremap_prot(phys_addr_t phys_addr, size_t size, + unsigned long prot) { - unsigned long offset = paddr & ~PAGE_MASK; - unsigned long pfn = __phys_to_pfn(paddr); - struct vm_struct *area; - unsigned long vaddr; - int err; - - paddr &= PAGE_MASK; - + unsigned long pfn = __phys_to_pfn((phys_addr)); WARN_ON(pfn_valid(pfn)); - size = PAGE_ALIGN(offset + size); - - area = get_vm_area(size, VM_IOREMAP); - if (!area) - return NULL; - - vaddr = (unsigned long)area->addr; - area->phys_addr = paddr; - - err = ioremap_page_range(vaddr, vaddr + size, paddr, prot); - - if (err) { - vunmap((void *)vaddr); - return NULL; - } - - flush_cache_vmap(vaddr, vaddr + size); - return (void __iomem *)(offset + vaddr); -} - -void __iomem *xtensa_ioremap_nocache(unsigned long addr, unsigned long size) -{ - return xtensa_ioremap(addr, size, pgprot_noncached(PAGE_KERNEL)); + return generic_ioremap_prot(phys_addr, size, __pgprot(prot)); } -EXPORT_SYMBOL(xtensa_ioremap_nocache); +EXPORT_SYMBOL(ioremap_prot); -void __iomem *xtensa_ioremap_cache(unsigned long addr, unsigned long size) +void iounmap(volatile void __iomem *addr) { - return xtensa_ioremap(addr, size, PAGE_KERNEL); -} -EXPORT_SYMBOL(xtensa_ioremap_cache); + unsigned long va = (unsigned long) addr; -void xtensa_iounmap(volatile void __iomem *io_addr) -{ - void *addr = (void *)(PAGE_MASK & (unsigned long)io_addr); + if ((va >= XCHAL_KIO_CACHED_VADDR && + va - XCHAL_KIO_CACHED_VADDR < XCHAL_KIO_SIZE) || + (va >= XCHAL_KIO_BYPASS_VADDR && + va - XCHAL_KIO_BYPASS_VADDR < XCHAL_KIO_SIZE)) + return; - vunmap(addr); + generic_iounmap(addr); } -EXPORT_SYMBOL(xtensa_iounmap); +EXPORT_SYMBOL(iounmap); From patchwork 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: 13273363 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id EF522C7EE25 for ; Fri, 9 Jun 2023 07:57:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8FFD88E0002; Fri, 9 Jun 2023 03:57:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 888068E0001; Fri, 9 Jun 2023 03:57:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7014D8E0002; Fri, 9 Jun 2023 03:57:26 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 5F6ED8E0001 for ; Fri, 9 Jun 2023 03:57:26 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 188AE12017C for ; Fri, 9 Jun 2023 07:57:26 +0000 (UTC) X-FDA: 80882454492.27.9D4AFEE Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf16.hostedemail.com (Postfix) with ESMTP id 477C2180017 for ; Fri, 9 Jun 2023 07:57:24 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="JjEr4BQ/"; spf=pass (imf16.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1686297444; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=LUPq0cnzOLgrLVKYAlQ346H5looYZtvjQRVHWSAi6lQ=; b=WbKfaj/ayfd4E6A2Of4GTkBzPCIs8BAygD5+2zIWCSWztdJH8yWEfzcr5uRc/KmPRk6TPu GYQtWq6RCkxLiPpuurfeMNGtNzpqJQp2/xpPxrkXSuwMXtPynaTdoMZb1PoGWsGn4CW2o+ 7D4vz6XfTdqA1ZFaQuVtwY6Qp9TC5EU= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1686297444; a=rsa-sha256; cv=none; b=p7+8wx/HkZuzig+y2bJp9523z8o60U6tEPhiXKMWAr0DcxwaMSKs55RdwZ3rp5o5831AfS kqdsikXTVUw7h68z1xbiQTPwOcCDRc8HVKqhz3sNo83d3SVJKALpfeLU7VS7XAkKhG9UuP gHz2LeKQjRnfHSENJKGghoKwtLT67HU= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="JjEr4BQ/"; spf=pass (imf16.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=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=LUPq0cnzOLgrLVKYAlQ346H5looYZtvjQRVHWSAi6lQ=; b=JjEr4BQ/J3Zs/Y2cXQNLSyvcpIjI4NZk6MDLQADiH8h/s1lM6J2Xao1Xdl98Chgbw/ugk3 ES7ibWR9modRKP2aMVvwjOcPpeQ1DteVXtiUagYnyUGLkt0mCQjGlRjODr7+lHR21hXSnb 8nVRdYmLUyVCmhSCkZZ0TBVrZDLpqR4= 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-Stat-Signature: mbfgftkgcyhe78fqbmt48texkd1d8mtb X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 477C2180017 X-Rspam-User: X-HE-Tag: 1686297444-210867 X-HE-Meta: U2FsdGVkX18jHxSH+noU83uSUr69Dj1J8pP1ONa8da3adflAkWA2pGBnd9iVTBeOdr8VbbwogXGMf5ZwfLXDP9llgzvy3xCaiWtixtf/7ujOyRTGeFqEbqdtB1TR4fitu+Rv13MUhY0GSuqq3HBApCh0/pjWeUdF9h0CEZIucKW2sQ7EE76l4yhXZQAW0dT2hgBSoeWrY19W1TIDGTNbg8LFmy9rG7jEZsRgxU3eRFrBw8kgMIeZ5R/JOEc926Dvkx20zkJhUvd10XhKcI0DFK6Ep5edJXJM0nkciQEQbwQcHmWcnJ4fTLX0sEQm5BdMWK+3T30VshF/kL00ftMAwsnpLEE1dODs64YHAeWBTr2SHIir2CF2bCYEyZuXoUg71QweawaX7hxv6gjmNXPeQgQbiBz1aX+6dbqMclim3NEQwPhOAP1nV1vycKUnN6QsPwuVzoJnymf7I9T53wtODQBPlSJ5EizskGCe5EU+BBVOtDC25iv7QIvhzqfKnrUatreqA2+eDMkTZVLOooPVNCSqmM+Cj/QbY5ehWo7a7v9a0wx4q4p9arsRA62POXutiWqRPwsl6X9XmttHVQptVvI3squwXXLpPbrsZ5KjkQ6EIV0vrZdC4ora3kl1n8FChugsdLpQ5xSQZcOrfkpNDogC2K4qv0I0MLOE8azC1czuX13Yq+0We9wer0fKzN/z2wO1pi4Bk6QhohO2ZxqaJSvVQOMQcIwyhlADZxn4W2O3iwQsfWdpkSLzb/4lBNskN9g9yCvAzfeJTDUh4qdnuMZ38NMCwWhwnE/E6ZmDpWYZ/LEB/rQIUuSLXftREd5+u+NeJIaTWD+Wmf2GA0IGtXYgmQ8qsInfVLaMvyxyhOiOEJEuv2eNrVauAOFCl/YvdZ/e4uFrm7WnB6RAeYT/ivFfftgyMvtUvYp+szXRGuwUDSgD/6XLBr5fAb2UDrm5BEBx274gXhwosbVSVOh vin9RA+m aVdb0Ts99KnwWNx98nalvb6jTHz0FhtyTYI4VUSpZgK8RKjUK8kyZdgdqpi7yb/BPKyq7FJ+YPV1rdMYskQcVTegoAoD8421e3cqHLa/SN9DmeEXPWGkfw1/eh4bDYhXz6lo+kQgDOKHsOM/vkeMVnvB6dhL4AuGXJav5lH8L/j/R1SHK7nNBY/iOHgBWoRp92Dk4u3uzK2tn2dQ6zn/MSHwJH2IPZrzkRJLfx7yxZYOqGDF1yeYZcDIryQxPehlrZs2vAjOsXMnEXvRrHmOyPiQ9R5wgiul28V8v8W7MdFDQMrNHmwN9F+YLXtQfCHJzCrDE36R+12mcSRDMsI1ViMH2/A== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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: 13273365 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7ABF7C7EE2F for ; Fri, 9 Jun 2023 07:57:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 136468E000C; Fri, 9 Jun 2023 03:57:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 071F08E0008; Fri, 9 Jun 2023 03:57:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E2DE58E000C; Fri, 9 Jun 2023 03:57:32 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id CDB928E0008 for ; Fri, 9 Jun 2023 03:57:32 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 9EA3E1C71D0 for ; Fri, 9 Jun 2023 07:57:32 +0000 (UTC) X-FDA: 80882454744.22.E92F47B Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf07.hostedemail.com (Postfix) with ESMTP id ED80A4001B for ; Fri, 9 Jun 2023 07:57:30 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=NbYybZwI; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf07.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1686297451; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=pRjmDB/MhJX2uAhXZR6PcmrnbkF0aNZomeUUr4ZAM3o=; b=fFZvJ44nZkg69xE5sTiL0NPMsjKTJwmQLQcasobjI1qI95N59+NLVWQDtrnSybg8jX0SUL EydaDmywofsSO9g5KOeCpV5a/3amoofAFwzVNFDPhKVFTKtMEKv9li88p8wCdkLkdv6eE2 QTzL9qQ+wTv1ZgwH/cpdpctAKP1pfyI= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=NbYybZwI; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf07.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1686297451; a=rsa-sha256; cv=none; b=qpng7FpfFiyrPPf6q9krU/ZpRH2LE5BSD8o+f7GvxzDwKO6iPgE7VoIRtbkCdQOTBSxwZE s63d7SYjBmy+0gFYLU9GKUEwx2Oz3aygMyWt/JcdhUNfhwawVgKARK9AeY7M/w0zpu0GwQ EoPeLoYoVb2kSTXCHnBLdTDVhXy8CMo= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686297450; 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=NbYybZwIRGDTXpSOOkx43P9kYFStKP4GX8VkOzz5GENzdshU6uSMGJkuHDUePN75BbvDgv JGs3Pzy6sHdKeyxSzH0UbN5xvum+UgynBxVA5jwwKYJ6xK9EWPIbvg8myIG0DSAEck4+4p wftgOGfAQxwXd2UqyDw36v6h8/if0fE= 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-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: ED80A4001B X-Stat-Signature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rkyI5Lpw8g2LLE36MHbhhuX12rj26aJVVdmBXSp8xrpHd/NLyuxG+QLeom8vBMaGmSUrmKhBdOyXB6jIM1z1NxSaA9bzaPwCSr6znnzduxFAccm3ZT31ODf0LhUv14Urwhgv6eekpptfK7ZgPxu4hL/3XoCQtUsiqIvSXYjwO+nruwwpUf5QosjJgUSq0EGY1uvv55CEUyo+MI8YY= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Christophe Leroy Architectures like powerpc have a dedicated space for IOREMAP mappings. If so, use it in generic_ioremap_prot(). Signed-off-by: Christophe Leroy Signed-off-by: Baoquan He Reviewed-by: Christoph Hellwig --- 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: 13273366 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4C510C7EE25 for ; Fri, 9 Jun 2023 07:57:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DB9178E0008; Fri, 9 Jun 2023 03:57:45 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D42E68E0005; Fri, 9 Jun 2023 03:57:45 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BE3568E0008; Fri, 9 Jun 2023 03:57:45 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id A75F68E0005 for ; Fri, 9 Jun 2023 03:57:45 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 633D0140169 for ; Fri, 9 Jun 2023 07:57:45 +0000 (UTC) X-FDA: 80882455290.14.59380E0 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf09.hostedemail.com (Postfix) with ESMTP id 98A33140019 for ; Fri, 9 Jun 2023 07:57:43 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=X8LgvGBz; spf=pass (imf09.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1686297463; a=rsa-sha256; cv=none; b=5JaogcTHIXMT1JiYUi/2ZeLAw3DeO9Emy8Sy83VYgKeurDPeO+FGVVsWS7u2Yb3hiMkNJD cQsltK7UvtUUWqgEEtUhuXe5LtkrtlMOyJkCCw7HCGN0TY1qerp1El5WiXiVKrqXtb3wqi fQ/23nbnWs0J8W7qWFiiLYoA0b4AkOI= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=X8LgvGBz; spf=pass (imf09.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1686297463; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=fH0C7VtLpIk/ymZUFK43wUJtPx7iE/R4kc3YOi7r/TI=; b=yb2rDafhHxefkeGFoqvTjsBc9KIVlDE0PZ4DHsEKuNr6peCBmcBipMCs3uUDpE8Ouah9gl IY8dPwfuj9vRgXeBNacXak/cieqfmctBCVgB5d42UTvVC8NW37CRWHE/AsZmZT+UJ1D8He XoSi+bNYQEOFltObl97xg45PtA8O29Y= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686297462; 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=X8LgvGBzp7bP/+Ul4IlDc+TxEHdt38kMnvPRHhKupSneZ8qnXsvMiM0D1OlX1gKBgZxCWi 0ottnCDMgsJWIn6GUFlLy8unvCcdV2LaSKbT1OfUe5YUVOPpbfui085YHOQzv8tubcp73u icMeYpwgEvmnIe0zJCFXN0Iia4g8VU0= 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-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 98A33140019 X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8G5WrBScIWdBn4eZLps5VvgGDvUykZ904WWq5Q8RiFXnaeh+TgIhm5OaHSexlSwyI25IkIX4lmWSW0p/LmGr72Vv2OP+BEbSxyFN4WkT47BnkpmFPyRNW39nACBQMsHzUxzKZhn3objr9aMBLXJgZf9kx+jk/SorRv00CweDo0drlt/XfLTJE/NeRcZcNyfCDgJcLKpLZet7rUmSVzW6 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Now is_ioremap_addr() is only used in kernel/iomem.c and gonna be used in mm/ioremap.c. Move it into its own new header file linux/ioremap.h. 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: 13273367 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id D6017C7EE29 for ; Fri, 9 Jun 2023 07:57:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6B4498E0006; Fri, 9 Jun 2023 03:57:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 63E158E0005; Fri, 9 Jun 2023 03:57:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4B7D38E0006; Fri, 9 Jun 2023 03:57:50 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 3AD198E0005 for ; Fri, 9 Jun 2023 03:57:50 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 1084AC0167 for ; Fri, 9 Jun 2023 07:57:50 +0000 (UTC) X-FDA: 80882455500.15.11BC1B8 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf03.hostedemail.com (Postfix) with ESMTP id 3FAFD2001A for ; Fri, 9 Jun 2023 07:57:48 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=LbzlVMsh; spf=pass (imf03.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1686297468; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=mrr2cNyhDy3XHVdkhg3dGxWKYfHUscXJOX9H9m6IS1s=; b=CNA3NcgEBoppYAZWoNK3pC6S2gfhP6tsVIYwKCWH1AHnRLdbOheCsHei9zQWUAKPTOCh/I 8ME5oxYsYm7sN0w69L8xh7VAgSTDHcUA2hgKvcch094PmvHeBcM6+lvz98X7NXL7p897U4 Wp2rV1QJY4QvnL9BY/OS4Z5ytogXzFw= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1686297468; a=rsa-sha256; cv=none; b=0VjuWezIDVJcA4HGHtlMgsFSwwJafG79qV190Zuar106M66wETzrdWr5ZGzO912usXU2jn auJNn3pfxnozi5+DofGu+chaxtjmEQ40mBY1PELtIgkJHOlnOah6n2g1k2onc6qg2z0Oxa 6x52ok6BT+c1SEY8EiVYO24R9LSjDGs= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=LbzlVMsh; spf=pass (imf03.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=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-Rspamd-Queue-Id: 3FAFD2001A X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: wxx8dbqfwbqkexki7d9ixzbpjucj6uff X-HE-Tag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Aqs+SQJcCfNWnJNTieOqWhJLTi2p2kZbjnvgy4gY4r1vYwOOVCVQXY+iIaBiEor5JkNufh/DwdRqDVvQVaBQdjioqSFVd5iVM5Y7Fxpb2+BK4SXjk8197kCqi4WdEdt19/7J0zrlmitO/7V7mmCrGor89REIyAgcUH0rxGFtWICak9U7K+EErPLCK61dWaIXkd0TDn23BPjfAQLqImQeiuT+fCuGptQU6hhDAhD3npsXugXB+/3qNlpBhTFwbqiK1bSRKocIfxyWJleBNlk0+K7Uo4NEvGsHK7N8+3gPhoCb2p8limfk+OSrGYdAZ35s/jErs/w4q4jOoLNn8t4edclYSVdEjSccIvPhqui8Y= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Christophe Leroy By taking GENERIC_IOREMAP method, the generic generic_ioremap_prot(), generic_iounmap(), and their generic wrapper ioremap_prot(), ioremap() and iounmap() are all visible and available to arch. Arch needs to provide wrapper functions to override the generic versions if there's arch specific handling in its ioremap_prot(), ioremap() or iounmap(). This change will simplify implementation by removing duplicated codes with generic_ioremap_prot() and generic_iounmap(), and has the equivalent functioality as before. Here, add wrapper functions ioremap_prot() and iounmap() for powerpc's special operation when ioremap() and iounmap(). Signed-off-by: Christophe Leroy Signed-off-by: Baoquan He Reviewed-by: Christoph Hellwig Reviewed-by: Mike Rapoport (IBM) Cc: Michael Ellerman Cc: Nicholas Piggin Cc: linuxppc-dev@lists.ozlabs.org --- arch/powerpc/Kconfig | 1 + arch/powerpc/include/asm/io.h | 8 +++----- arch/powerpc/mm/ioremap.c | 26 +------------------------- arch/powerpc/mm/ioremap_32.c | 19 +++++++++---------- arch/powerpc/mm/ioremap_64.c | 12 ++---------- 5 files changed, 16 insertions(+), 50 deletions(-) diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index bff5820b7cda..aadb280a539e 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig @@ -194,6 +194,7 @@ config PPC select GENERIC_CPU_VULNERABILITIES if PPC_BARRIER_NOSPEC select GENERIC_EARLY_IOREMAP select GENERIC_GETTIMEOFDAY + select GENERIC_IOREMAP select GENERIC_IRQ_SHOW select GENERIC_IRQ_SHOW_LEVEL select GENERIC_PCI_IOMAP if PCI diff --git a/arch/powerpc/include/asm/io.h b/arch/powerpc/include/asm/io.h index 67a3fb6de498..0732b743e099 100644 --- a/arch/powerpc/include/asm/io.h +++ b/arch/powerpc/include/asm/io.h @@ -889,8 +889,8 @@ static inline void iosync(void) * */ extern void __iomem *ioremap(phys_addr_t address, unsigned long size); -extern void __iomem *ioremap_prot(phys_addr_t address, unsigned long size, - unsigned long flags); +#define ioremap ioremap +#define ioremap_prot ioremap_prot extern void __iomem *ioremap_wc(phys_addr_t address, unsigned long size); #define ioremap_wc ioremap_wc @@ -904,14 +904,12 @@ void __iomem *ioremap_coherent(phys_addr_t address, unsigned long size); #define ioremap_cache(addr, size) \ ioremap_prot((addr), (size), pgprot_val(PAGE_KERNEL)) -extern void iounmap(volatile void __iomem *addr); +#define iounmap iounmap void __iomem *ioremap_phb(phys_addr_t paddr, unsigned long size); int early_ioremap_range(unsigned long ea, phys_addr_t pa, unsigned long size, pgprot_t prot); -void __iomem *do_ioremap(phys_addr_t pa, phys_addr_t offset, unsigned long size, - pgprot_t prot, void *caller); extern void __iomem *__ioremap_caller(phys_addr_t, unsigned long size, pgprot_t prot, void *caller); diff --git a/arch/powerpc/mm/ioremap.c b/arch/powerpc/mm/ioremap.c index 4f12504fb405..705e8e8ffde4 100644 --- a/arch/powerpc/mm/ioremap.c +++ b/arch/powerpc/mm/ioremap.c @@ -41,7 +41,7 @@ void __iomem *ioremap_coherent(phys_addr_t addr, unsigned long size) return __ioremap_caller(addr, size, prot, caller); } -void __iomem *ioremap_prot(phys_addr_t addr, unsigned long size, unsigned long flags) +void __iomem *ioremap_prot(phys_addr_t addr, size_t size, unsigned long flags) { pte_t pte = __pte(flags); void *caller = __builtin_return_address(0); @@ -74,27 +74,3 @@ int early_ioremap_range(unsigned long ea, phys_addr_t pa, return 0; } - -void __iomem *do_ioremap(phys_addr_t pa, phys_addr_t offset, unsigned long size, - pgprot_t prot, void *caller) -{ - struct vm_struct *area; - int ret; - unsigned long va; - - area = __get_vm_area_caller(size, VM_IOREMAP, IOREMAP_START, IOREMAP_END, caller); - if (area == NULL) - return NULL; - - area->phys_addr = pa; - va = (unsigned long)area->addr; - - ret = ioremap_page_range(va, va + size, pa, prot); - if (!ret) - return (void __iomem *)area->addr + offset; - - vunmap_range(va, va + size); - free_vm_area(area); - - return NULL; -} diff --git a/arch/powerpc/mm/ioremap_32.c b/arch/powerpc/mm/ioremap_32.c index 9d13143b8be4..ca5bc6be3e6f 100644 --- a/arch/powerpc/mm/ioremap_32.c +++ b/arch/powerpc/mm/ioremap_32.c @@ -21,6 +21,13 @@ __ioremap_caller(phys_addr_t addr, unsigned long size, pgprot_t prot, void *call phys_addr_t p, offset; int err; + /* + * If the address lies within the first 16 MB, assume it's in ISA + * memory space + */ + if (addr < SZ_16M) + addr += _ISA_MEM_BASE; + /* * Choose an address to map it to. * Once the vmalloc system is running, we use it. @@ -31,13 +38,6 @@ __ioremap_caller(phys_addr_t addr, unsigned long size, pgprot_t prot, void *call offset = addr & ~PAGE_MASK; size = PAGE_ALIGN(addr + size) - p; - /* - * If the address lies within the first 16 MB, assume it's in ISA - * memory space - */ - if (p < 16 * 1024 * 1024) - p += _ISA_MEM_BASE; - #ifndef CONFIG_CRASH_DUMP /* * Don't allow anybody to remap normal RAM that we're using. @@ -63,7 +63,7 @@ __ioremap_caller(phys_addr_t addr, unsigned long size, pgprot_t prot, void *call return (void __iomem *)v + offset; if (slab_is_available()) - return do_ioremap(p, offset, size, prot, caller); + return generic_ioremap_prot(addr, size, prot); /* * Should check if it is a candidate for a BAT mapping @@ -87,7 +87,6 @@ void iounmap(volatile void __iomem *addr) if (v_block_mapped((unsigned long)addr)) return; - if (addr > high_memory && (unsigned long)addr < ioremap_bot) - vunmap((void *)(PAGE_MASK & (unsigned long)addr)); + generic_iounmap(addr); } EXPORT_SYMBOL(iounmap); diff --git a/arch/powerpc/mm/ioremap_64.c b/arch/powerpc/mm/ioremap_64.c index 3acece00b33e..d24e5f166723 100644 --- a/arch/powerpc/mm/ioremap_64.c +++ b/arch/powerpc/mm/ioremap_64.c @@ -29,7 +29,7 @@ void __iomem *__ioremap_caller(phys_addr_t addr, unsigned long size, return NULL; if (slab_is_available()) - return do_ioremap(paligned, offset, size, prot, caller); + return generic_ioremap_prot(addr, size, prot); pr_warn("ioremap() called early from %pS. Use early_ioremap() instead\n", caller); @@ -49,17 +49,9 @@ void __iomem *__ioremap_caller(phys_addr_t addr, unsigned long size, */ void iounmap(volatile void __iomem *token) { - void *addr; - if (!slab_is_available()) return; - addr = (void *)((unsigned long __force)PCI_FIX_ADDR(token) & PAGE_MASK); - - if ((unsigned long)addr < ioremap_bot) { - pr_warn("Attempt to iounmap early bolted mapping at 0x%p\n", addr); - return; - } - vunmap(addr); + generic_iounmap(PCI_FIX_ADDR(token)); } EXPORT_SYMBOL(iounmap); From patchwork 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: 13273368 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 65F62C7EE25 for ; Fri, 9 Jun 2023 07:57:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F19428E000D; Fri, 9 Jun 2023 03:57:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E54278E0005; Fri, 9 Jun 2023 03:57:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D1D5A8E000D; Fri, 9 Jun 2023 03:57:56 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id BB7A28E0005 for ; Fri, 9 Jun 2023 03:57:56 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 9CED6AE912 for ; Fri, 9 Jun 2023 07:57:56 +0000 (UTC) X-FDA: 80882455752.29.A0A3931 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf03.hostedemail.com (Postfix) with ESMTP id D6E062001A for ; Fri, 9 Jun 2023 07:57:54 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=QYbn12ur; spf=pass (imf03.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1686297474; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=81nV18C3v1lk6vsTsYHvlL2VrwGGV2i7WxKaTwXwgOE=; b=ELkVtCZjoNBMmBvAAW+WiT+I5q4BmhVtEaY3cGER5SFbi/SRdtnvCokIHI0hg4Az7pe0R3 uLWIGqw5eXnYMKJZfGPRqh4XDYFC13Rf6poNZZDhnCqOGFZp1q4rSsrNRn5XfV/NkAq48h gBZtI8fTO9Q7Zc7kQykFFN8ej+QwajU= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1686297474; a=rsa-sha256; cv=none; b=jag2lcCpxp4SiDyVi0DqY4n6lOAR5V0oP1Ty/wxhGOv8zQrFr+ROo2jSC1w7sajxEM5r0T EizoM3b6vrPF0GKRwUKektXJegcPZ4Eq3FMacJ0WYSMwzAWx8duMlrfkiDxvQdvrSkQKcA 31nbl3AJF8tbcixcQM73PWzLren/eYg= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=QYbn12ur; spf=pass (imf03.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=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-Rspamd-Queue-Id: D6E062001A X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: 7mzatbjpssptubedqn34go9iyosa3hhx X-HE-Tag: 1686297474-609489 X-HE-Meta: U2FsdGVkX19DZhj1LQzLCj16hNLlIRIOPaWGcQtvaGwO29MTpVZGoxAnJq6rHrQHPFgDu0Efhpu9YNCdTHgudiDRY2AZ3EJ+ki7i87k279X9NOl9T1eiDuuZCO0ilA2ey9vGY/FgjZypi3mnxBC9TLBu79wtgCLivem/xvoEIZE2Xnn90B3RZBxHMBemtyt37nMYg7OuPItt1Sdb+aKIeexfrMbyvmzBlw6tkruLk+sHd6lgfidvgidH3e3vM/2reP2CNjx7sT48HBA7g/xN26l/cY/Chg8kSSWNKFgldsv1qmKSu5NYVbZYWHmt5Ab7f2bi2dOxGiUs+nIoUX1Okw/RfAsNOPUgYmM645Z301MBhUiXXJF7ypx7TuGwQZqqG1CvoSTb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ner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Since hook functions ioremap_allowed() and iounmap_allowed() will be obsoleted, add wrapper function ioremap_prot() to contain the 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: 13273369 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 987F6C7EE29 for ; Fri, 9 Jun 2023 07:57:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 507C78E0005; Fri, 9 Jun 2023 03:57:57 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 468F88E000E; Fri, 9 Jun 2023 03:57:57 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2E3A38E0005; Fri, 9 Jun 2023 03:57:57 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 00FE58E000E for ; Fri, 9 Jun 2023 03:57:56 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id C5BC840149 for ; Fri, 9 Jun 2023 07:57:56 +0000 (UTC) X-FDA: 80882455752.01.0A74FD2 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf05.hostedemail.com (Postfix) with ESMTP id 10572100009 for ; Fri, 9 Jun 2023 07:57:54 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=iT2qUXuM; spf=pass (imf05.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1686297475; a=rsa-sha256; cv=none; b=197ampZTlapQEiEBi5DAg2hpnsLrT0X658uVPZxVbVuI+o4LxwvDYoDGPHM+adkrJu1tTh H3ZVfO5HI4xnwiooC4ue91KuzN0f1m6ReXKKhgTPZm+HvoPRihmUNuVXcPJgjPhP9wxlbQ TxUzmlQqiRtBdAJ2sgh8YcOtaTIVK58= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=iT2qUXuM; spf=pass (imf05.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1686297475; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=keQ78Mv/VCFMjxLJbgEgr2h/sjN0UpPUn6QsvR3JRNU=; b=VvI5x6EmzN7nlm7edTB2pxNrhc4HLA7qDzaIxN9BX7bF6cQGqP55CqFVdnbFt9gqOGIqlT IGxlzBqtnjG4lrjpuf17SThkgiaGCvi5cQdH35GAU2IOjgWbGpovJGbOU10Ejxpblgp4Ji vtk8ZgtgSkhHTb9IxqNUl2USl9iy1EI= 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=keQ78Mv/VCFMjxLJbgEgr2h/sjN0UpPUn6QsvR3JRNU=; b=iT2qUXuMJugjjPYb90LjzqxunZHMc1V/OelutykZ9aCOTm2CwuTdAMS5mihqLh4r9vLgSj I+M9/Nr+UEzWvgBx8xsVPnVq5nTDqvHFgrCJWSQuEad5EQnhZnWRf+/8uN6U5zsc1az5iU +DbzzHr6EhkJq6KDOFn05cMoXRi1g2c= 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-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 10572100009 X-Stat-Signature: dcwkqgqgpxax486jubz5dpsmefpkm6y8 X-Rspam-User: X-HE-T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Kglq3SMYevFdVn84TcOz4ROGrAAIaRa/GjRxF9wny/nHeIi1v6AFMq19XOJrEzjBXqrftyID6c5sMIKPRhQ+EPI5TDndncKfCv4hyCYW/bkVoayN2NFNuxzb9H4ZQno+Uw/fGQwQUY2KRQt9WjRGlol5uEtso3GWpyh4nUTnTSOSPAqJSZy0atP0w8qKd1TJvBHsHyZtwqlRxwasuC2o95Tr8qexwgWSn4DTm11zOvEUKDCo= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Now there are no users of ioremap_allowed and iounmap_allowed, clean them up. Signed-off-by: Baoquan He Reviewed-by: Christoph Hellwig Reviewed-by: Kefeng Wang Reviewed-by: Mike Rapoport (IBM) --- include/asm-generic/io.h | 26 -------------------------- mm/ioremap.c | 6 ------ 2 files changed, 32 deletions(-) diff --git a/include/asm-generic/io.h b/include/asm-generic/io.h index 39244c3ee797..bac63e874c7b 100644 --- a/include/asm-generic/io.h +++ b/include/asm-generic/io.h @@ -1047,32 +1047,6 @@ static inline void iounmap(volatile void __iomem *addr) #elif defined(CONFIG_GENERIC_IOREMAP) #include -/* - * Arch code can implement the following two hooks when using GENERIC_IOREMAP - * ioremap_allowed() return a bool, - * - true means continue to remap - * - false means skip remap and return directly - * iounmap_allowed() return a bool, - * - true means continue to vunmap - * - false means skip vunmap and return directly - */ -#ifndef ioremap_allowed -#define ioremap_allowed ioremap_allowed -static inline bool ioremap_allowed(phys_addr_t phys_addr, size_t size, - unsigned long prot) -{ - return true; -} -#endif - -#ifndef iounmap_allowed -#define iounmap_allowed iounmap_allowed -static inline bool iounmap_allowed(void *addr) -{ - return true; -} -#endif - void __iomem *generic_ioremap_prot(phys_addr_t phys_addr, size_t size, pgprot_t prot); diff --git a/mm/ioremap.c b/mm/ioremap.c index a21a6c9fa5ab..3e049dfb28bd 100644 --- a/mm/ioremap.c +++ b/mm/ioremap.c @@ -33,9 +33,6 @@ void __iomem *generic_ioremap_prot(phys_addr_t phys_addr, size_t size, phys_addr -= offset; size = PAGE_ALIGN(size + offset); - if (!ioremap_allowed(phys_addr, size, pgprot_val(prot))) - return NULL; - area = __get_vm_area_caller(size, VM_IOREMAP, IOREMAP_START, IOREMAP_END, __builtin_return_address(0)); if (!area) @@ -64,9 +61,6 @@ void generic_iounmap(volatile void __iomem *addr) { void *vaddr = (void *)((unsigned long)addr & PAGE_MASK); - if (!iounmap_allowed(vaddr)) - return; - if (is_ioremap_addr(vaddr)) vunmap(vaddr); }