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 DCB34C77B75 for ; Tue, 16 May 2023 06:49:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7B0F5900003; Tue, 16 May 2023 02:49:29 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 73A04900002; Tue, 16 May 2023 02:49:29 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5DBD8900003; Tue, 16 May 2023 02:49:29 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 4D1CB900002 for ; Tue, 16 May 2023 02:49:29 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id AE6AE81437 for ; Tue, 16 May 2023 06:49:28 +0000 (UTC) X-FDA: 80795192016.24.A6E601F Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf16.hostedemail.com (Postfix) with ESMTP id DF956180007 for ; Tue, 16 May 2023 06:49:26 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=F5juZCTr; spf=pass (imf16.hostedemail.com: domain of rppt@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=rppt@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1684219767; 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=tO69jVwe5eoYxPsaBIYjTNRCVPqEjvvSmG2feOIcCU4=; b=75875DOIKeUpyK3OaN53M95iH3qcFBYumYvkzCmIeJt/rLTr1YxvS3FOPw3Rx4XLIZQfEs 3bz9G56Of0og5dBI7FCt+FOUf6dLjomyP9/nZFwIgAGJMl3cIq+pUYuLvSFhRjjDk1xOb6 R5eQIHrSe3O8tFYtR5vALfsLU2fifFI= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684219767; a=rsa-sha256; cv=none; b=Ufvkt5Pq8/o4IIYUAjs5mqDNVUH4vT8+GDcpCAr250Opfsv39jbLdYam5sfvw062KlMaXc mAaHJ7HZjcdYYslDASAI/F4+z2MGvcL/6C04JZM+JRzFTB1LOqPpP/ULjcKU5Y2x5K3c19 XdArJX2F7WRDHVf1JioYxBL0FgOwZfU= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=F5juZCTr; spf=pass (imf16.hostedemail.com: domain of rppt@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=rppt@kernel.org; dmarc=pass (policy=none) header.from=kernel.org Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 1ACC063498; Tue, 16 May 2023 06:49:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8CC85C433EF; Tue, 16 May 2023 06:49:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1684219765; bh=7v5ge8KRvf/1Bpm8sGEAQfoJXbPpCNh7fVbx82qCVFU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=F5juZCTrIEZknbXJgybsDRYtUNZWvK3sGzxA1kxRz0EBsyaeepD9XlWQcf8p/o+Ad a2w0/PpkvDv90Kyh4h/3G4kuricu39bl1+ELp924Q2HMQ3YTLC2a63VqbQpMXNH/JY vJctOq4zU+ZikrArw8CfYTBHz2E3sShpVjFlHAh91L/8sQEcf0QIkcDOqNqQTq0QYL eTrdzrZyRAnEemF23NOHAAW9RJRTr5Mgp/spT43FbCoStbIGb0vllf7T2/VtVsyqNX 75TwbTx1ksQI0ke0XdwcjWsJCkU2GJ8K4zPEZPwfqb9/ZPOyLEI5VQKxJ7IEI/7we1 /ZWBGnvFFhDgg== Date: Tue, 16 May 2023 09:49:17 +0300 From: Mike Rapoport To: Baoquan He Cc: linux-kernel@vger.kernel.org, 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, Vineet Gupta , linux-snps-arc@lists.infradead.org Subject: Re: [PATCH v5 RESEND 07/17] arc: mm: Convert to GENERIC_IOREMAP Message-ID: References: <20230515090848.833045-1-bhe@redhat.com> <20230515090848.833045-8-bhe@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230515090848.833045-8-bhe@redhat.com> X-Stat-Signature: meanfi5zu8wnjgignuchgb3nkjs53hca X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: DF956180007 X-Rspam-User: X-HE-Tag: 1684219766-843270 X-HE-Meta: U2FsdGVkX18QGdIMu6uADOloedSkzQSOY3RpU4m0QmMb8MOZBaJBu2T4x+j3TzOl18GJV48tgy5u8gK1TPNznm6+xXbn6cr1qodDnFIapywQawFRmkFCtdlYy5fAisiomHuh4HNjdEKrz9LF1GZzgLNvQb3P321X2vnNJj8MYoIvFQsrWmcj9zEQmM9Rt2oOKNtsFhuU9y8ZfRbtmv5uNmPJRob35oPTT+CUSW5t3YlF0lm//acfGT8TcTbyRJR4rfqjlJgEcYwHqfwy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32kN9j7RZfaiBBMt8So+UkwOZGTG5uqxyAlBnOcdvJXsxQ/3xSK9BVJ5BhR2eMFwYX97xFknnQoRSbqg9t6IbyNlgyLYXo/TfyrrvNir7ErMKGrF7TGNtlmp8w7 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 Mon, May 15, 2023 at 05:08:38PM +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. > > Here, add wrapper functions ioremap_prot() and iounmap() for arc's > special operation when ioremap_prot() and iounmap(). > > Signed-off-by: Baoquan He > Cc: Vineet Gupta > Cc: linux-snps-arc@lists.infradead.org Reviewed-by: Mike Rapoport (IBM) > --- > arch/arc/Kconfig | 1 + > arch/arc/include/asm/io.h | 7 +++--- > arch/arc/mm/ioremap.c | 49 ++++----------------------------------- > 3 files changed, 8 insertions(+), 49 deletions(-) > > diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig > index ab6d701365bb..3a666ee0c0bc 100644 > --- a/arch/arc/Kconfig > +++ b/arch/arc/Kconfig > @@ -26,6 +26,7 @@ config ARC > select GENERIC_PENDING_IRQ if SMP > select GENERIC_SCHED_CLOCK > select GENERIC_SMP_IDLE_THREAD > + select GENERIC_IOREMAP > select HAVE_ARCH_KGDB > select HAVE_ARCH_TRACEHOOK > select HAVE_ARCH_TRANSPARENT_HUGEPAGE if ARC_MMU_V4 > diff --git a/arch/arc/include/asm/io.h b/arch/arc/include/asm/io.h > index 80347382a380..4fdb7350636c 100644 > --- a/arch/arc/include/asm/io.h > +++ b/arch/arc/include/asm/io.h > @@ -21,8 +21,9 @@ > #endif > > extern void __iomem *ioremap(phys_addr_t paddr, unsigned long size); > -extern void __iomem *ioremap_prot(phys_addr_t paddr, unsigned long size, > - unsigned long flags); > +#define ioremap ioremap > +#define ioremap_prot ioremap_prot > +#define iounmap iounmap > static inline void __iomem *ioport_map(unsigned long port, unsigned int nr) > { > return (void __iomem *)port; > @@ -32,8 +33,6 @@ static inline void ioport_unmap(void __iomem *addr) > { > } > > -extern void iounmap(const volatile void __iomem *addr); > - > /* > * io{read,write}{16,32}be() macros > */ > diff --git a/arch/arc/mm/ioremap.c b/arch/arc/mm/ioremap.c > index 712c2311daef..b07004d53267 100644 > --- a/arch/arc/mm/ioremap.c > +++ b/arch/arc/mm/ioremap.c > @@ -8,7 +8,6 @@ > #include > #include > #include > -#include > #include > > static inline bool arc_uncached_addr_space(phys_addr_t paddr) > @@ -25,13 +24,6 @@ static inline bool arc_uncached_addr_space(phys_addr_t paddr) > > void __iomem *ioremap(phys_addr_t paddr, unsigned long size) > { > - phys_addr_t end; > - > - /* Don't allow wraparound or zero size */ > - end = paddr + size - 1; > - if (!size || (end < paddr)) > - return NULL; > - > /* > * If the region is h/w uncached, MMU mapping can be elided as optim > * The cast to u32 is fine as this region can only be inside 4GB > @@ -51,55 +43,22 @@ EXPORT_SYMBOL(ioremap); > * ARC hardware uncached region, this one still goes thru the MMU as caller > * might need finer access control (R/W/X) > */ > -void __iomem *ioremap_prot(phys_addr_t paddr, unsigned long size, > +void __iomem *ioremap_prot(phys_addr_t paddr, size_t size, > unsigned long flags) > { > - unsigned int off; > - unsigned long vaddr; > - struct vm_struct *area; > - phys_addr_t end; > pgprot_t prot = __pgprot(flags); > > - /* Don't allow wraparound, zero size */ > - end = paddr + size - 1; > - if ((!size) || (end < paddr)) > - return NULL; > - > - /* An early platform driver might end up here */ > - if (!slab_is_available()) > - return NULL; > - > /* force uncached */ > - prot = pgprot_noncached(prot); > - > - /* Mappings have to be page-aligned */ > - off = paddr & ~PAGE_MASK; > - paddr &= PAGE_MASK_PHYS; > - size = PAGE_ALIGN(end + 1) - paddr; > - > - /* > - * Ok, go for it.. > - */ > - area = get_vm_area(size, VM_IOREMAP); > - if (!area) > - return NULL; > - area->phys_addr = paddr; > - vaddr = (unsigned long)area->addr; > - if (ioremap_page_range(vaddr, vaddr + size, paddr, prot)) { > - vunmap((void __force *)vaddr); > - return NULL; > - } > - return (void __iomem *)(off + (char __iomem *)vaddr); > + return generic_ioremap_prot(paddr, size, pgprot_noncached(prot)); > } > EXPORT_SYMBOL(ioremap_prot); > > - > -void iounmap(const volatile void __iomem *addr) > +void iounmap(volatile void __iomem *addr) > { > /* weird double cast to handle phys_addr_t > 32 bits */ > if (arc_uncached_addr_space((phys_addr_t)(u32)addr)) > return; > > - vfree((void *)(PAGE_MASK & (unsigned long __force)addr)); > + generic_iounmap(addr); > } > EXPORT_SYMBOL(iounmap); > -- > 2.34.1 > > -- Sincerely yours, Mike.