From patchwork Thu Feb 16 12:34: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: 13143033 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 C0565C636CC for ; Thu, 16 Feb 2023 12:35:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 614FB6B0083; Thu, 16 Feb 2023 07:35:29 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 59E6C6B0085; Thu, 16 Feb 2023 07:35:29 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 43F396B0087; Thu, 16 Feb 2023 07:35:29 -0500 (EST) 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 3405E6B0083 for ; Thu, 16 Feb 2023 07:35:29 -0500 (EST) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 0D5761A0D5F for ; Thu, 16 Feb 2023 12:35:29 +0000 (UTC) X-FDA: 80473100778.09.4B23376 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf20.hostedemail.com (Postfix) with ESMTP id 481011C0017 for ; Thu, 16 Feb 2023 12:35:27 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=A0PJuLua; spf=pass (imf20.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=1676550927; 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=Q8XMgqsidsolWT+9vTShA+vg/WDVgjNUN6m5J9Drmfc=; b=UXHBsJP7nDfFqXz2hzhtszZVNMnOpQd0RE6xEIEGPSCphC7OTZgxbFjN2+w1uyrHjVMVYY SUf6ZGbraT5Z/Ye0+jmvNFxiUHxUZwvSp6ejkBQMAZ1hZ4kS9fi3c+jTsvbCBkmYGDHdDH jjwfzwhqzAjrETVpP6rktkGnb+eo/Po= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=A0PJuLua; spf=pass (imf20.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=1676550927; a=rsa-sha256; cv=none; b=P4v8vH2QHNfbT04vObpjOe5H6/uGVKa7UPYO3ccpGN3W9SlME2h3W69Hwk6sIm9acxp5kq BLcONzJEtEA7kIPUz/VOPqj9Q22KmZR6O5CIKdkWeBP1jOw0NPTz2mXY8E642jZlnrNvmE Q7to6+kNHNG4xAfN6JeE5PKkUwodNVI= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1676550926; 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=Q8XMgqsidsolWT+9vTShA+vg/WDVgjNUN6m5J9Drmfc=; b=A0PJuLua+cTRNDUjw87jWsxMcgcVs5AsoQi5Dy3CrRiX7kQyGSFZBzUPLQRj8Ozy9TED3i uZ+aNY/hq7RkZApbDA8fRBi71lNUUMEyss1tPvNNn8QWmXopJRzj3oGFg4sJIgXL4hvGfV BeINcuZUlBywpGzskx5x4cMAw6XdfwQ= 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-255-VWr6U_S8NyGaA2SN__tblg-1; Thu, 16 Feb 2023 07:35:22 -0500 X-MC-Unique: VWr6U_S8NyGaA2SN__tblg-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9393E183B3C6; Thu, 16 Feb 2023 12:35:21 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-99.pek2.redhat.com [10.72.12.99]) by smtp.corp.redhat.com (Postfix) with ESMTP id 98143492C3C; Thu, 16 Feb 2023 12:35:15 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, akpm@linux-foundation.org, christophe.leroy@csgroup.eu, hch@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, David.Laight@ACULAB.COM, shorne@gmail.com, arnd@arndb.de, Baoquan He , linux-ia64@vger.kernel.org Subject: [PATCH v4 07/16] ia64: mm: Convert to GENERIC_IOREMAP Date: Thu, 16 Feb 2023 20:34:10 +0800 Message-Id: <20230216123419.461016-8-bhe@redhat.com> In-Reply-To: <20230216123419.461016-1-bhe@redhat.com> References: <20230216123419.461016-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Rspamd-Queue-Id: 481011C0017 X-Stat-Signature: dz4rjh79xquk5oddk1iwxms4bu3sdosu X-Rspam-User: X-Rspamd-Server: rspam08 X-H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ABGDqet2fA5zPO//iWyKfAbHGnPQmmt51N8piZVA8Gx3YAYRqxjKHAnB7Sob1ta2kPCl1pJchyrWKMNq/7UFp0InAiF2yo+un3xudul1gdEJfz7saYKEEhGbwH1U5IZD+Ur4v3UN6dXhs6WnRmcaSLLLhj+KvSsRGBccmKXpJYMFQIn1Qbix3lMDzAQrV0VLYUPQkrYHnRt4n2VHnVm6S8h30LYTom0BfqKRWzapi2R+81htSiIB6tjK4qsw1tqdfjDaWA/PqbbBxuK0HKQ1I9SHDC6rrJJv0= 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 Cc: linux-ia64@vger.kernel.org Signed-off-by: Christophe Leroy --- 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 d7e4a24e8644..74568cb73d87 100644 --- a/arch/ia64/Kconfig +++ b/arch/ia64/Kconfig @@ -45,6 +45,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 55fd3eb753ff..35e75e9c878b 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));