From patchwork Wed Mar 1 03:42:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13155574 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 97BB2C7EE23 for ; Wed, 1 Mar 2023 03:43:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 34A5F6B0073; Tue, 28 Feb 2023 22:43:59 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 2F9326B0081; Tue, 28 Feb 2023 22:43:59 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 19A8F6B0083; Tue, 28 Feb 2023 22:43:59 -0500 (EST) 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 080D36B0073 for ; Tue, 28 Feb 2023 22:43:59 -0500 (EST) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id C73BA160FC4 for ; Wed, 1 Mar 2023 03:43:58 +0000 (UTC) X-FDA: 80518935756.20.A3335EA Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf17.hostedemail.com (Postfix) with ESMTP id 12E0E40004 for ; Wed, 1 Mar 2023 03:43:56 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=PF0ETX4M; spf=pass (imf17.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=1677642237; 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=P6/E/dJjw072Q36qYumwBTS5o6IV1NtYcDVzQFOyNCojv42IRRhvTKooD5hHYAmdTy80n8 aUIcISI9A/T/qbkHz2Rdg+o7jYNScmmsFB/ta2NVMPgVf1bWthW/1wWHe02mIjFG7WE5Vu 4rLNzhcm4jHDbR44mKk2k2OaYBTQOYQ= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=PF0ETX4M; spf=pass (imf17.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=1677642237; a=rsa-sha256; cv=none; b=T64NROtEmQU9c5URW2NKEj4oOHs4U1HEebWW6XtU2JC64FZjdtdxX+9q8+mYVzD9LEtSUj YNjwEGpOUzLaaZMCFQ5JhvB9+P7509WfR1OL7HQ/TFRqzRI4GSc6MEIoBbCT5twUa7RZIl FW9/tRQseEPQDrKyD3bZ30GYoNaAT3I= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677642236; 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=PF0ETX4Mm+bFzVG2Zcmi50Msj8A4uod/wN4EegxZQAUwZif1h6U2t4ZiXxZ9lDQJSoqCEE 1YYOb3AQObNtBG088BNfYVHoFfoVwmxoJD9H1VclrZxIm305SjKSocy3f+1z0IPWHx3uuD /5N194ofUliMHo3SB517evtI4oQ1Z2w= 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-170-EoxYF9wcOPaWWVVcEoz6SA-1; Tue, 28 Feb 2023 22:43:53 -0500 X-MC-Unique: EoxYF9wcOPaWWVVcEoz6SA-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 3E20B185A794; Wed, 1 Mar 2023 03:43:52 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-13-180.pek2.redhat.com [10.72.13.180]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1E76AC15BAD; Wed, 1 Mar 2023 03:43: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@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, David.Laight@ACULAB.COM, shorne@gmail.com, willy@infradead.org, Baoquan He , Jonas Bonn , Stefan Kristiansson , openrisc@lists.librecores.org Subject: [PATCH v5 09/17] openrisc: mm: Convert to GENERIC_IOREMAP Date: Wed, 1 Mar 2023 11:42:39 +0800 Message-Id: <20230301034247.136007-10-bhe@redhat.com> In-Reply-To: <20230301034247.136007-1-bhe@redhat.com> References: <20230301034247.136007-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: 12E0E40004 X-Stat-Signature: 9ijyhm656gjhznzgqfyfwe5ej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MR4PItqHFHnhQC8FVycKNFARS/bOkEYK5FPuyvjFrVeF6eCTvxNIFJN1uN5kmjXul0L3VJdm0f0g7SA3aocV8/GsIFRq6WOOHKPmu5xxq+22EZmucQ4HwXRKqNS8kneKFdNwtIUabwQlnL1TQvHXzgOegG+PUBB31e/rf7jNp1bbeUvD5h4ozsbI/jnoVNtRbLLpfKwGcEBp7j4Tb14wFK1chGDMJDGHSRvf2lDqOvYJofBXtDGXF1SGiOuOVJ7K3Hk8ukCtEtLxDBvEEvlqhSEyW8C 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