From mboxrd@z Thu Jan 1 00:00:00 1970 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 36C55C0015E for ; Sun, 9 Jul 2023 10:11:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 37EDE6B0072; Sun, 9 Jul 2023 06:11:20 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 308376B0074; Sun, 9 Jul 2023 06:11:20 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1AA166B0075; Sun, 9 Jul 2023 06:11:20 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 03BD86B0072 for ; Sun, 9 Jul 2023 06:11:20 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 72A42C0154 for ; Sun, 9 Jul 2023 10:11:19 +0000 (UTC) X-FDA: 80991655878.06.E34A1F7 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 AAA4C1C0015 for ; Sun, 9 Jul 2023 10:11:16 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="LTh6O/xk"; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf20.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1688897476; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=Ov3JfUvGcvY/gub0yO+OM0+NYIpkg7qweTL0CdVo1Bg=; b=PnRQLUHMwOWf9x1XPIKBo0a/f2DSPOzuTTfo2v3oqTfhXO4OAHtsj/lPgOOMY2Gny3ck++ sOZjrzCdM89hV+Zv8t3SruiTHbJQ0PaHmDQ2sOflwdRJpeuYHQd/1lEHqjqJgPyQm7zsik 3KOsQ4a1x8PP+byuR3IsCO12lefi98I= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="LTh6O/xk"; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf20.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1688897476; a=rsa-sha256; cv=none; b=XLxiY13vVwpKx+UbLJxzQys38pMOH2PBiQS9rCRkwWeKIRBqWqDZmCWZ+Eyyi260Y3fS/u VqaQ4DFEJyZYCh9HpGsDauR2e0zmJmFBgPzXvub15UDk0CUhg3IKCSUQDqRx94oFx0FknX AcD9mAYzqE/W3w8++tHi7Tc53hKKE/0= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1688897475; 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: in-reply-to:in-reply-to:references:references; bh=Ov3JfUvGcvY/gub0yO+OM0+NYIpkg7qweTL0CdVo1Bg=; b=LTh6O/xkWknHaC0P18iaXHUP+UG92d5hcDc6VtZxcK2NydcKg2a0InyF3zfASUtIwRHgP8 OU59SWSWdiZOTYUuxOdUWx9Ks3Q+gqOwYi7djQgtOih0ZpKO4hS8zDMiy3XU/Qfhs9LWWa 2+45PsDGxODbFAtCM8XCAERu+HZ3QsM= 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-649-ZPfXDT6uPQy1mNFrnfZTpw-1; Sun, 09 Jul 2023 06:11:12 -0400 X-MC-Unique: ZPfXDT6uPQy1mNFrnfZTpw-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6D9DC104458E; Sun, 9 Jul 2023 10:11:11 +0000 (UTC) Received: from localhost (ovpn-12-38.pek2.redhat.com [10.72.12.38]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0119D111F3CB; Sun, 9 Jul 2023 10:11:09 +0000 (UTC) Date: Sun, 9 Jul 2023 18:11:06 +0800 From: Baoquan He To: Stafford Horne Cc: linux-kernel@vger.kernel.org, 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, deller@gmx.de, nathan@kernel.org, glaubitz@physik.fu-berlin.de, Jonas Bonn , Stefan Kristiansson , openrisc@lists.librecores.org Subject: Re: [PATCH v7 09/19] openrisc: mm: Convert to GENERIC_IOREMAP Message-ID: References: <20230620131356.25440-1-bhe@redhat.com> <20230620131356.25440-10-bhe@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: AAA4C1C0015 X-Stat-Signature: mt6gyoyj8wxw7bhe1cuhmfdzmt3uojh3 X-Rspam-User: X-HE-Tag: 1688897476-153930 X-HE-Meta: U2FsdG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eDH2F4b6rj2vimr1uQa4G0Lpr8PJg8RJqOu93pdhGKaJKG2aaYYBesT0qeBkoiLO1vUt8Dae6Ygjcg2DY5WLegE5vL+IVTvDtN2YgIL2M/7Dftpe46FHY8uMG2dKSiijR0wtWxkmWYl7/G7JZny5tFI8E2pQ/TXix7MZK9Gc6lkL94EnZFr2BZBpdxXziIIDAo3nh2Zxj3J/w8xwaJk1Qg4NN3qUUgChze8dufiIqQa1MBbdPJ7BIfnGfg6kXAPsSzFaBrWlnNTyF7NWty2/jnldYORDuYRtOedd7O9ES7TApLUW9ODAoP6QOAMfH6+nJ/BlHPbWQ 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: On 07/08/23 at 01:33am, Stafford Horne wrote: > On Tue, Jun 20, 2023 at 09:13:46PM +0800, Baoquan He wrote: > > 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. > > > > For openrisc, the current ioremap() and iounmap() are the same as > > generic version. After taking GENERIC_IOREMAP way, the old ioremap() > > and iounmap() can be completely removed. > > > > Signed-off-by: Baoquan He > > Reviewed-by: Christoph Hellwig > > Reviewed-by: Mike Rapoport (IBM) > > 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 | 49 ---------------------------------- > > 3 files changed, 7 insertions(+), 54 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..5a6f0f16a5ce 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,10 @@ > > #define PIO_OFFSET 0 > > #define PIO_MASK 0 > > > > -#define ioremap ioremap > > -void __iomem *ioremap(phys_addr_t offset, unsigned long size); > > - > > -#define iounmap iounmap > > -extern void iounmap(volatile void __iomem *addr); > > +/* > > + * I/O memory mapping functions. > > + */ > > +#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 cdbcc7e73684..91c8259d4b7e 100644 > > --- a/arch/openrisc/mm/ioremap.c > > +++ b/arch/openrisc/mm/ioremap.c > > @@ -22,55 +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) > > -{ > > - return vfree((void *)(PAGE_MASK & (unsigned long)addr)); > > -} > > -EXPORT_SYMBOL(iounmap); > > - > > Hello, > > Thanks for the patch, I was able to test this booting openrisc and running a few > glibc tests and see no issues. Also the code cleanup looks good to me. > > Acked-by: Stafford Horne Thanks a lot, Stafford. I later posted v8 to add update for hexagon and s390, this is the link: https://lore.kernel.org/all/20230706154520.11257-10-bhe@redhat.com/T/#u Thanks