Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp1281840ybg; Fri, 18 Oct 2019 15:10:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqxscnIInHCH0vs3aGVEiRSoIGgtdp0PK6B4S7BJMATwqe1j9V41i6zMQvaXzrswf+zE5nrM X-Received: by 2002:a17:906:d214:: with SMTP id w20mr10815400ejz.68.1571436600390; Fri, 18 Oct 2019 15:10:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571436600; cv=none; d=google.com; s=arc-20160816; b=OS+06PM1oorJNxO4PuTur443gOKMzmI016yP6Ee/MyOoQtqkBIZxRybm6r2xeUBfPk TjFQkhq9U0viAFK2YZ6tV6/Ayp3/Dtvo64AxcmEe9+wb+Gmbc0b3rll4bHKcW6rEGNzk XNjjCjcovQ2xHnjifuc1Kl/e7szf2Ug4pqgAZIHNqWR3QuQCrakhgaqHcs/DMhX4dKPe 6KQel9UN/1qHSO7k5d9s5OseBRYobDrSren37k96dXbArSutljGVuKXP6F23ioq5C32c Kf0mNXvTMnAtktuxY2TafgPjld+eT7daZ+6pPAMiw9QY/I4Y9Ous+jKyNxAUzOHF+abz uZjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=0G9VjTCDn1azePVEARZDWm3/hUf6+uTfkQZKCgB5wVo=; b=T4y+OCf6lHlIerpWGRdPLdzsDoqzXUKMZSVcMtr9RFIpctUh2E+vqyvVAOWNCMtDSl dmD2n9F4QyahxsTP/+0MVc9dJcD8E4zKUAJzMb3tqzQB/PKmP5gxBmdJ4E/biE5y/n63 G8l1++AaLLSJrd39zkx9UzSsQwuyjWTJE8MtesKk1ct2Zw+FOSevkc1FSC78e5QdDJ1N kyohQSEfYwVz7ioZGpAQgcDNE4pSvP/rEYCHpHYiJlA1rlIB0At8sFtCyGTu6jPmyWLX H3ujqA5FufLEXBs4GafjODP6KakLRuWfXQCRwwdZPWfYmeJNAfbBjMipwe4AZMyPYeSJ BlGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=OO8uHH01; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g1si4199311ejo.82.2019.10.18.15.09.37; Fri, 18 Oct 2019 15:10:00 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=OO8uHH01; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2441092AbfJQRrO (ORCPT + 99 others); Thu, 17 Oct 2019 13:47:14 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:56944 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2441071AbfJQRrM (ORCPT ); Thu, 17 Oct 2019 13:47:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=0G9VjTCDn1azePVEARZDWm3/hUf6+uTfkQZKCgB5wVo=; b=OO8uHH01lkLNVGTfVkN8iIpwAT c2D1h9fcU7xuzjCEXklU+jLEGv3IwTxxLz/2EcFDHIyiP8rpusO1EfGfiUGWQeaGn6TzZIIaIQ9fd i8g3G8yHRLmEgMEim4c5nxpmPiquio55+xykcpp1o6otIZQPJETr7caoZDRKDVemF8bvgyRdq5Tda 9ybeiLPk/H6YcZIzQCkjM9Ahb6xauO0lGIOWcGtFISjAvIET5w+4N8Fks4o0JIyOvRJylsDLLysWs 7wf/sZNlRvhTsfGd/nRqT9yL+dGtqdW+8RZ7WI/QY89rVNLkIa3SnAWVs0DkpX1gyM65Cstdew87K 02aaH6lQ==; Received: from [2001:4bb8:18c:d7b:c70:4a89:bc61:3] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1iL9rT-0006Qq-S0; Thu, 17 Oct 2019 17:46:56 +0000 From: Christoph Hellwig To: Arnd Bergmann , Guo Ren , Michal Simek , Greentime Hu , Vincent Chen , Guan Xuetao , x86@kernel.org Cc: linux-alpha@vger.kernel.org, linux-snps-arc@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-hexagon@vger.kernel.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, nios2-dev@lists.rocketboards.org, openrisc@lists.librecores.org, linux-parisc@vger.kernel.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-xtensa@linux-xtensa.org, linux-mtd@lists.infradead.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 21/21] csky: use generic ioremap Date: Thu, 17 Oct 2019 19:45:54 +0200 Message-Id: <20191017174554.29840-22-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191017174554.29840-1-hch@lst.de> References: <20191017174554.29840-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use the generic ioremap_prot and iounmap helpers. Signed-off-by: Christoph Hellwig --- arch/csky/Kconfig | 1 + arch/csky/include/asm/io.h | 8 +++--- arch/csky/include/asm/pgtable.h | 4 +++ arch/csky/mm/ioremap.c | 45 --------------------------------- 4 files changed, 8 insertions(+), 50 deletions(-) diff --git a/arch/csky/Kconfig b/arch/csky/Kconfig index 3973847b5f42..da09c884cc30 100644 --- a/arch/csky/Kconfig +++ b/arch/csky/Kconfig @@ -17,6 +17,7 @@ config CSKY select IRQ_DOMAIN select HANDLE_DOMAIN_IRQ select DW_APB_TIMER_OF + select GENERIC_IOREMAP select GENERIC_LIB_ASHLDI3 select GENERIC_LIB_ASHRDI3 select GENERIC_LIB_LSHRDI3 diff --git a/arch/csky/include/asm/io.h b/arch/csky/include/asm/io.h index f572605d5ad5..332f51bc68fb 100644 --- a/arch/csky/include/asm/io.h +++ b/arch/csky/include/asm/io.h @@ -36,11 +36,9 @@ /* * I/O memory mapping functions. */ -extern void __iomem *__ioremap(phys_addr_t addr, size_t size, pgprot_t prot); -extern void iounmap(void *addr); - -#define ioremap(addr, size) __ioremap((addr), (size), pgprot_noncached(PAGE_KERNEL)) -#define ioremap_wc(addr, size) __ioremap((addr), (size), pgprot_writecombine(PAGE_KERNEL)) +#define ioremap_wc(addr, size) \ + ioremap_prot((addr), (size), \ + (_PAGE_IOREMAP & ~_CACHE_MASK) | _CACHE_UNCACHED) #include diff --git a/arch/csky/include/asm/pgtable.h b/arch/csky/include/asm/pgtable.h index 7c21985c60dc..4b2a41e15f2e 100644 --- a/arch/csky/include/asm/pgtable.h +++ b/arch/csky/include/asm/pgtable.h @@ -86,6 +86,10 @@ #define PAGE_USERIO __pgprot(_PAGE_PRESENT | _PAGE_READ | _PAGE_WRITE | \ _CACHE_CACHED) +#define _PAGE_IOREMAP \ + (_PAGE_PRESENT | __READABLE | __WRITEABLE | _PAGE_GLOBAL | \ + _CACHE_UNCACHED | _PAGE_SO) + #define __P000 PAGE_NONE #define __P001 PAGE_READONLY #define __P010 PAGE_COPY diff --git a/arch/csky/mm/ioremap.c b/arch/csky/mm/ioremap.c index ae78256a56fd..70c8268d3b2b 100644 --- a/arch/csky/mm/ioremap.c +++ b/arch/csky/mm/ioremap.c @@ -3,53 +3,8 @@ #include #include -#include #include -#include - -static void __iomem *__ioremap_caller(phys_addr_t addr, size_t size, - pgprot_t prot, void *caller) -{ - phys_addr_t last_addr; - unsigned long offset, vaddr; - struct vm_struct *area; - - last_addr = addr + size - 1; - if (!size || last_addr < addr) - return NULL; - - offset = addr & (~PAGE_MASK); - addr &= PAGE_MASK; - size = PAGE_ALIGN(size + offset); - - area = get_vm_area_caller(size, VM_IOREMAP, caller); - if (!area) - return NULL; - - vaddr = (unsigned long)area->addr; - - if (ioremap_page_range(vaddr, vaddr + size, addr, prot)) { - free_vm_area(area); - return NULL; - } - - return (void __iomem *)(vaddr + offset); -} - -void __iomem *__ioremap(phys_addr_t phys_addr, size_t size, pgprot_t prot) -{ - return __ioremap_caller(phys_addr, size, prot, - __builtin_return_address(0)); -} -EXPORT_SYMBOL(__ioremap); - -void iounmap(void __iomem *addr) -{ - vunmap((void *)((unsigned long)addr & PAGE_MASK)); -} -EXPORT_SYMBOL(iounmap); - pgprot_t phys_mem_access_prot(struct file *file, unsigned long pfn, unsigned long size, pgprot_t vma_prot) { -- 2.20.1