From patchwork Thu Feb 16 12:34: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: 13143034 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 65571C636CC for ; Thu, 16 Feb 2023 12:35:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 049036B007E; Thu, 16 Feb 2023 07:35:40 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id F14156B0085; Thu, 16 Feb 2023 07:35:39 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D8E406B0087; Thu, 16 Feb 2023 07:35:39 -0500 (EST) 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 C9D156B007E for ; Thu, 16 Feb 2023 07:35:39 -0500 (EST) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id A541A1203AA for ; Thu, 16 Feb 2023 12:35:39 +0000 (UTC) X-FDA: 80473101198.23.54516B2 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf06.hostedemail.com (Postfix) with ESMTP id BE563180009 for ; Thu, 16 Feb 2023 12:35:37 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=K+ZWmR0G; spf=pass (imf06.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=1676550937; 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=K1VrnQks8P5H4lhuQHdk0PEcxF0GSibhsi/oBTknLWs=; b=6emq5KUvpyrKEqVOCzW6Wbom79OOX5qYZHXhzhaLMFdtkRJiED0vPpIZG6l2Vp6G4KyTiv bIRHCnNfLOiCbp4Sw1NhnBkssQjuUoVAZhegLTEHmzvjxXqrm9GzwFMBdA3w0ssBBddgda /hGRqnY2ZBMl7tDEBxWynfjKnB8st/U= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=K+ZWmR0G; spf=pass (imf06.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=1676550937; a=rsa-sha256; cv=none; b=EA8SzMqSh2QKjMKVpbof/iFVUQBaFIAlFud/H7t/aaPLZktXuLLPbuZl2N5f1zMqZXrA2E +pE5RWa5CtkBaHPbB3pz56cgJFmppgteXblbplfWAX4gBM1jE01nmQJSh+4F9PaMrBFI6g WuU6/ZSFgANnQOWhU1NXeOf7MaolSOk= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1676550937; 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=K1VrnQks8P5H4lhuQHdk0PEcxF0GSibhsi/oBTknLWs=; b=K+ZWmR0GV3xE8IyB0W+o7WCwysdVHN0iCrc7uY+5/U2Nice6YYzNBQOrDY43kKw9mVhOnr fuZJDmvmZRoh0pTSIqivYGUU6ZShAXUvtKwLMWqvwCJSSxjG4eqR3tCamBQRtf8YHumNQG s+Gt/V4juNrD+pEBIxdHthwEBBnufW0= 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-163-G71q5-xmOVWeFL2sPqFCUA-1; Thu, 16 Feb 2023 07:35:31 -0500 X-MC-Unique: G71q5-xmOVWeFL2sPqFCUA-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 DBBC1183B3C7; Thu, 16 Feb 2023 12:35:30 +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 475B7492C3C; Thu, 16 Feb 2023 12:35:21 +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 , Jonas Bonn , Stefan Kristiansson , openrisc@lists.librecores.org Subject: [PATCH v4 08/16] openrisc: mm: Convert to GENERIC_IOREMAP Date: Thu, 16 Feb 2023 20:34:11 +0800 Message-Id: <20230216123419.461016-9-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: BE563180009 X-Stat-Signature: 3t6bedu6di56pst8sys7adqyfou5id6f X-Rspam-User: X-Rspamd-Server: rspam08 X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9ClnCzCwKtkb7mDEiFmKqD9N1eU8toKFMgDSDMURa0KvL0J8t8xHfStZYHeXcDU4ar6g/gtUgJpYzMqRy22kEZgMAzjXM3tuDBJVAvTBKT49X2V3uLYAJeIiBcH2/seAifG87ugT6pN1l+c3a/CQJmBC8aJhebmfDbfnw/+6zN8XwJZvnCLgXO1LcHLnCN6iSdRDWuyAuiv0rrVJ63GKWMXE5Kksa96DaaF36pgNJtOWzfL4cTNMsN3RUxigWHL3Vg796gqn+OF+R8tri 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 iounmap() for openrisc's special operation when iounmap(). Signed-off-by: Baoquan He Cc: Stafford Horne Cc: Jonas Bonn Cc: Stefan Kristiansson Cc: openrisc@lists.librecores.org --- arch/openrisc/Kconfig | 1 + arch/openrisc/include/asm/io.h | 11 +++++--- arch/openrisc/mm/ioremap.c | 46 +--------------------------------- 3 files changed, 9 insertions(+), 49 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..e640960c26c2 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,12 @@ #define PIO_OFFSET 0 #define PIO_MASK 0 -#define ioremap ioremap -void __iomem *ioremap(phys_addr_t offset, unsigned long size); - +/* + * I/O memory mapping functions. + */ #define iounmap iounmap -extern void iounmap(volatile void __iomem *addr); + +#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 90b59bc53c8c..9f9941df7d4c 100644 --- a/arch/openrisc/mm/ioremap.c +++ b/arch/openrisc/mm/ioremap.c @@ -22,49 +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) { /* If the page is from the fixmap pool then we just clear out @@ -88,9 +45,8 @@ void iounmap(volatile void __iomem *addr) return; } - return vfree((void *)(PAGE_MASK & (unsigned long)addr)); + generic_iounmap(addr); } -EXPORT_SYMBOL(iounmap); /** * OK, this one's a bit tricky... ioremap can get called before memory is