From patchwork Mon May 15 09:08:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13240990 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 D1FE3C7EE22 for ; Mon, 15 May 2023 09:10:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6D9CD900004; Mon, 15 May 2023 05:10:16 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 68A52900002; Mon, 15 May 2023 05:10:16 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 55229900004; Mon, 15 May 2023 05:10:16 -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 488DA900002 for ; Mon, 15 May 2023 05:10:16 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 217C5C13FA for ; Mon, 15 May 2023 09:10:16 +0000 (UTC) X-FDA: 80791918032.05.5C09F2C Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf05.hostedemail.com (Postfix) with ESMTP id 4E60810000A for ; Mon, 15 May 2023 09:10:14 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Wn2b5z3Q; spf=pass (imf05.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=1684141814; a=rsa-sha256; cv=none; b=xPpgmTg+7yXMeYgxavgs1y3YOJ/JqzmrnOSpeuEumSi0sceDPAfhPZAzGOLvcElL1vWy6T YBXJLwE61xmRoFAZkFW8l+k2bHOS04Ah5nn0VRt0yaBztuiKbUsmIzwXgr31+FjvUGUl6M 4rqVDXkzvYiCNkR53AY9FPSU1vGHREc= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Wn2b5z3Q; spf=pass (imf05.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=1684141814; 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=azGzfmfDWLXQSsWgcDLG3oWZvZKGLsUd275x0CmbinpCcV//W5e1BTH2RRbq0iD7+5atAp t39gB4bccHMiLzWmTJUmdasCPK5ZGYdq5PHq14vQITuU9yhUUpWnJ38Meou+h3pyJKBYJO rNW4R2lbOGnjPscDBWDVjYBmFCcAGoI= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684141813; 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=Wn2b5z3QOyc3hb6IhqhnWrsu3k6idbMNXspfxVzOX1gCfJHvsPhM22aXrteEQlgQvymxwt WPIskmz0Emc3O6oL9g2bUb5OEWSpUHSqdh+CqD0g8+A3ZQHzmj6lhxo4piUCmaeF1pZQnD rqSMssrWND3MY/P0SegGYSzW2tsudZU= 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-361-8VhVlINrMUqFbBxlXUrf_A-1; Mon, 15 May 2023 05:10:09 -0400 X-MC-Unique: 8VhVlINrMUqFbBxlXUrf_A-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C6DCE380671D; Mon, 15 May 2023 09:10:08 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-32.pek2.redhat.com [10.72.12.32]) by smtp.corp.redhat.com (Postfix) with ESMTP id 646C440C2063; Mon, 15 May 2023 09:10: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@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, David.Laight@ACULAB.COM, shorne@gmail.com, willy@infradead.org, deller@gmx.de, Baoquan He , Jonas Bonn , Stefan Kristiansson , openrisc@lists.librecores.org Subject: [PATCH v5 RESEND 09/17] openrisc: mm: Convert to GENERIC_IOREMAP Date: Mon, 15 May 2023 17:08:40 +0800 Message-Id: <20230515090848.833045-10-bhe@redhat.com> In-Reply-To: <20230515090848.833045-1-bhe@redhat.com> References: <20230515090848.833045-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Rspam-User: X-Stat-Signature: y6jasc1bbiq3e9q55kf6hf66j9phbgwx X-Rspamd-Server: rspam08 X-Rspamd-Queue-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2I+44ePtbd1DrSFfMtZ1t0tnQQCOyUIOB70v0ZONi3+6ACVfxbOMWxvwUtDWjZZ4SjdE/19IGbofOmfvJLsk0t7c9qR7cAMvsRJREC544r0smEDu9nGW/wElLIaZIoLt/c8Gbfj+KtY0GWGKbS15CRHyBiyUkuck3YeiuGJvQRVW2XTIT9v/cEd2tsmFtyfy+79KQHbKRG58OKVcO3xrPQyus9KD0GpURhLulFWldpXmQMDO9mIvBztpelvl+itPLzOA9s/v9DVAXA== 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