Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

hexagon: mm: convert to GENERIC_IOREMAP

By taking GENERIC_IOREMAP method, the generic ioremap_prot() and iounmap()
are visible and available to arch. This change will simplify
implementation by removing duplicated code with generic ioremap_prot() and
iounmap(), and has the equivalent functioality.

For hexagon, 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.

Link: https://lkml.kernel.org/r/20230706154520.11257-3-bhe@redhat.com
Signed-off-by: Baoquan He <bhe@redhat.com>
Cc: Brian Cain <bcain@quicinc.com>
Cc: Alexander Gordeev <agordeev@linux.ibm.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Christian Borntraeger <borntraeger@linux.ibm.com>
Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Chris Zankel <chris@zankel.net>
Cc: David Laight <David.Laight@ACULAB.COM>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Gerald Schaefer <gerald.schaefer@linux.ibm.com>
Cc: Heiko Carstens <hca@linux.ibm.com>
Cc: Helge Deller <deller@gmx.de>
Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>
Cc: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Cc: Jonas Bonn <jonas@southpole.se>
Cc: Kefeng Wang <wangkefeng.wang@huawei.com>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Max Filippov <jcmvbkbc@gmail.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Mike Rapoport (IBM) <rppt@kernel.org>
Cc: Nathan Chancellor <nathan@kernel.org>
Cc: Nicholas Piggin <npiggin@gmail.com>
Cc: Niklas Schnelle <schnelle@linux.ibm.com>
Cc: Rich Felker <dalias@libc.org>
Cc: Stafford Horne <shorne@gmail.com>
Cc: Stefan Kristiansson <stefan.kristiansson@saunalahti.fi>
Cc: Sven Schnelle <svens@linux.ibm.com>
Cc: Vasily Gorbik <gor@linux.ibm.com>
Cc: Vineet Gupta <vgupta@kernel.org>
Cc: Will Deacon <will@kernel.org>
Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Baoquan He and committed by
Andrew Morton
5bd2cc56 0b1f77e7

+9 -51
+1
arch/hexagon/Kconfig
··· 25 25 select NEED_SG_DMA_LENGTH 26 26 select NO_IOPORT_MAP 27 27 select GENERIC_IOMAP 28 + select GENERIC_IOREMAP 28 29 select GENERIC_SMP_IDLE_THREAD 29 30 select STACKTRACE_SUPPORT 30 31 select GENERIC_CLOCKEVENTS_BROADCAST
+7 -4
arch/hexagon/include/asm/io.h
··· 27 27 extern int remap_area_pages(unsigned long start, unsigned long phys_addr, 28 28 unsigned long end, unsigned long flags); 29 29 30 - extern void iounmap(const volatile void __iomem *addr); 31 - 32 30 /* Defined in lib/io.c, needed for smc91x driver. */ 33 31 extern void __raw_readsw(const void __iomem *addr, void *data, int wordlen); 34 32 extern void __raw_writesw(void __iomem *addr, const void *data, int wordlen); ··· 168 170 #define writew_relaxed __raw_writew 169 171 #define writel_relaxed __raw_writel 170 172 171 - void __iomem *ioremap(unsigned long phys_addr, unsigned long size); 172 - #define ioremap_uc(X, Y) ioremap((X), (Y)) 173 + /* 174 + * I/O memory mapping functions. 175 + */ 176 + #define _PAGE_IOREMAP (_PAGE_PRESENT | _PAGE_READ | _PAGE_WRITE | \ 177 + (__HEXAGON_C_DEV << 6)) 178 + 179 + #define ioremap_uc(addr, size) ioremap((addr), (size)) 173 180 174 181 175 182 #define __raw_writel writel
-2
arch/hexagon/kernel/hexagon_ksyms.c
··· 14 14 EXPORT_SYMBOL(__clear_user_hexagon); 15 15 EXPORT_SYMBOL(raw_copy_from_user); 16 16 EXPORT_SYMBOL(raw_copy_to_user); 17 - EXPORT_SYMBOL(iounmap); 18 17 EXPORT_SYMBOL(__vmgetie); 19 18 EXPORT_SYMBOL(__vmsetie); 20 19 EXPORT_SYMBOL(__vmyield); 21 20 EXPORT_SYMBOL(empty_zero_page); 22 - EXPORT_SYMBOL(ioremap); 23 21 EXPORT_SYMBOL(memcpy); 24 22 EXPORT_SYMBOL(memset); 25 23
+1 -1
arch/hexagon/mm/Makefile
··· 3 3 # Makefile for Hexagon memory management subsystem 4 4 # 5 5 6 - obj-y := init.o ioremap.o uaccess.o vm_fault.o cache.o 6 + obj-y := init.o uaccess.o vm_fault.o cache.o 7 7 obj-y += copy_to_user.o copy_from_user.o vm_tlb.o
-44
arch/hexagon/mm/ioremap.c
··· 1 - // SPDX-License-Identifier: GPL-2.0-only 2 - /* 3 - * I/O remap functions for Hexagon 4 - * 5 - * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved. 6 - */ 7 - 8 - #include <linux/io.h> 9 - #include <linux/vmalloc.h> 10 - #include <linux/mm.h> 11 - 12 - void __iomem *ioremap(unsigned long phys_addr, unsigned long size) 13 - { 14 - unsigned long last_addr, addr; 15 - unsigned long offset = phys_addr & ~PAGE_MASK; 16 - struct vm_struct *area; 17 - 18 - pgprot_t prot = __pgprot(_PAGE_PRESENT|_PAGE_READ|_PAGE_WRITE 19 - |(__HEXAGON_C_DEV << 6)); 20 - 21 - last_addr = phys_addr + size - 1; 22 - 23 - /* Wrapping not allowed */ 24 - if (!size || (last_addr < phys_addr)) 25 - return NULL; 26 - 27 - /* Rounds up to next page size, including whole-page offset */ 28 - size = PAGE_ALIGN(offset + size); 29 - 30 - area = get_vm_area(size, VM_IOREMAP); 31 - addr = (unsigned long)area->addr; 32 - 33 - if (ioremap_page_range(addr, addr+size, phys_addr, prot)) { 34 - vunmap((void *)addr); 35 - return NULL; 36 - } 37 - 38 - return (void __iomem *) (offset + addr); 39 - } 40 - 41 - void iounmap(const volatile void __iomem *addr) 42 - { 43 - vunmap((void *) ((unsigned long) addr & PAGE_MASK)); 44 - }