From patchwork Tue Jun 20 13:13:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13285832 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 36A69EB64D8 for ; Tue, 20 Jun 2023 13:16:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B6D618D0003; Tue, 20 Jun 2023 09:16:01 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B1DE78D0001; Tue, 20 Jun 2023 09:16:01 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9E5FA8D0003; Tue, 20 Jun 2023 09:16:01 -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 8F30A8D0001 for ; Tue, 20 Jun 2023 09:16:01 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 46104A0EA1 for ; Tue, 20 Jun 2023 13:16:01 +0000 (UTC) X-FDA: 80923174122.02.CCB319A Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf27.hostedemail.com (Postfix) with ESMTP id 1148340010 for ; Tue, 20 Jun 2023 13:15:58 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="AJZhF9/k"; spf=pass (imf27.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=1687266959; 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=YshPGYrMvg5zgsKN+u++ssYpTizmqN6PRNlS6Xsx9a2/OBbRKW5v1oAbm/94S1B2leytq9 60bTn5jr4mN1Dhrbb6kF9Jqi+JfMI7t9GJzWGHJBW+nPPgYlBpCtPmJ5aNv9EOW/Zp2N5n HUj2UleL+0aHaa6R5j5rjLcrfpRmyD0= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="AJZhF9/k"; spf=pass (imf27.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=1687266959; a=rsa-sha256; cv=none; b=x1660SOI33XG2iBJB+Cr8uX8Gb5V2Q3l/WbYrO1QkaAjtacJ8n+dIGq1z06qceurtknc0h QmYsJlNq43JZUuZYTtQ/7pJvXxp7qPH1Tdipj0EuktBwuhfgmPjMg8fl/yb+l5Co0EybDH bnpqTETwGNI8TOSiZtsZJfcVvgM4y54= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687266958; 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=AJZhF9/kIQ8JRE0kXcGCHxO4sDfEl+Sypw8CZT2RFbuEEJMj8dxxmsD4Z6WkBI+7aTwj+7 2P9SBTviDoF7ExO/lxErpYCbU0fY3zXCI3kSg7NUsa09rdpXeRhKJbqB0qXjXtcQoEUmWA /SRXjgRrj3IK0hQTDV6PhxOAnxNnl9o= 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-348-3YurffZuN3-tB-8HQxDxBw-1; Tue, 20 Jun 2023 09:15:55 -0400 X-MC-Unique: 3YurffZuN3-tB-8HQxDxBw-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id BF2C12A5955D; Tue, 20 Jun 2023 13:15:22 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-166.pek2.redhat.com [10.72.12.166]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9B61FC1ED96; Tue, 20 Jun 2023 13:15: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, hch@lst.de, christophe.leroy@csgroup.eu, rppt@kernel.org, willy@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, David.Laight@ACULAB.COM, shorne@gmail.com, deller@gmx.de, nathan@kernel.org, glaubitz@physik.fu-berlin.de, Baoquan He , linux-ia64@vger.kernel.org Subject: [PATCH v7 08/19] ia64: mm: Convert to GENERIC_IOREMAP Date: Tue, 20 Jun 2023 21:13:45 +0800 Message-Id: <20230620131356.25440-9-bhe@redhat.com> In-Reply-To: <20230620131356.25440-1-bhe@redhat.com> References: <20230620131356.25440-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Rspamd-Queue-Id: 1148340010 X-Rspam-User: X-Stat-Signature: 7oefehwqe11n1zrtdm9edrqdsxcmiru5 X-Rspamd-Server: rspam01 X-HE-Tag: 1687266958-417057 X-HE-Meta: U2FsdGVkX19OMYJjWgXBCmGXfQPPxd0fhTUMhurrw44qUHG9R4TKElxpgCjqS6JnB4Ta7jAull/uSZtNWw6xy4SpNvA+HO3QsMcgGgOz7gonwSCbpxdW3mMxB+rF98CTXKWLFDcc6UdoqG9mNlK1gdITmdSsBDbZfSjHlQgUDkQYxXPjot4bqQ6RHE2N7ncYmMiMV5TjwxH9BIHjhR1cmshgQulGsJaqvWp3qFn1PfwaM89AKPDZPBM3q4DVQf7Qxdts1/MwJMyytJNXWIJ3T9hjEBK2lsITAGPa8rcHuIUaDNB8ZU14JeaBsG5BkG8fjiGPBHw6Dv58Mf2Eh1/TiVSczhrJnSbSSGVHMhUjvMNYE1RnaE/jdV+cwAmyqphuxqrX12I4/0D/CkcI0c9rneRvH5ALpHOSa37dctBtouZGvVI2i9B5tGy4VX61W9zHG5+8wZy9Z9HYPo3p3ftaZWYt2W04nzxbQ9y92VgS2FMc9NRMKK3Qd/zplQa8UuqycHOGiegdUPomizIQHL393OZMl42fIpx7preNrM2eD7cKeOqoXOOYTSV2wVtSNjsYUamf2LsbRGe6NKt8baxOTJmrxLm77ejgRcdaWqRJ950PaStIgfafFdVw0ELuEmXQCSSIBin3MnKgq8GEAT2s/K73176m9iJfhqok+JG9ztFX7QPWOO2skskpAP/egclEBssfzToMikjl0LIZhWXCpZ8SbYCA82YFuik51Ba4JBbVizzLzvrywBypG90X4L/arlbKZ/YJNAD7Nqu2dGIsW6vUEfQCcuhoPjKuloZSO1T4GC0yjHMwx3djR4wlD8LOSRlTKhbhZlDZQIesMEwyRSFWqXTDO7lNLmwGDhXUgxlkzFOutPpvjj81KHuDCrq5OBKE9r19wW9oR3zeMfNAp5ldyPEhi48EwSri2OPc/pDlaNCahTm+p/MzHabXXRglT5HqlggxmCRFpryMTSV 21lXJLiK dnhOl5hylsaBiYNTAGBuAHk5+59mVhLL+se4dSI6eDncedeQzoT3Qh4rsd52dF8W7gqtWNqBq3UV9edkivvLaNY29mMku4O2y+GFWkHZ/twOymGMA3pdbzI+Zw9btiBJQuOS9/iwGHWgLiTdXrpMM/2P+X5sYHYbacidsh8cSccGdzYscOnTv821Ojtv7HSd0GeGPM1DHpNVuHgoECzEpI8qxv5BCzCps49iiaVmzwNYHuBM+/ZqCrTLfcWXfSlwKkoYXI/M6UnDMAR4YUdbDND4qHQ== 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));