Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp4894283imm; Tue, 9 Oct 2018 06:52:37 -0700 (PDT) X-Google-Smtp-Source: ACcGV61BsJzJLXt/lVPUp6bvhuFCgBl48wk2liswpuqLdSJdR1gZ9CSBI39oQGBnL/dEqB8u5e3j X-Received: by 2002:a63:8b43:: with SMTP id j64-v6mr25810672pge.149.1539093157431; Tue, 09 Oct 2018 06:52:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539093157; cv=none; d=google.com; s=arc-20160816; b=GSX6k9BVJIt/5HPzhLux6DTwXu5Rd8IWbtoK7vjwqtRoRwLST//OrKOYv1RrcG/Oj3 Z6D7JnLUpGDQhgm6wZHaBHF7c9ysQX+a0hdqMD9WsS/sFc7LlB42pPqyW1Pu1EYEv6tj tmC8ZuHPjhRB/J5lHxbXJzxHNy7HqouhLUKYzpyCfG1x6jqgMg63W5Gghco0wZ9P3wrE 9Em7JGvnqVee0SCZTiz2lfBLy5JWuNLMB2M3bDTihLngxM2bErBPyIAvgWYzDhbDParX IzIE3n7ksI2/QIt1pj/ZAoayxmpSqTYozcW/Lku+4P/pOtz+8xTHoVNKNQicLgjG8NaZ a5sQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:cc:to:subject:from:references :in-reply-to:message-id; bh=+6JoZMXJUPWWkBBO1T6jzYFPBbGBZITvnkFwyKzuSn8=; b=hhOkWTzV0LDDMo3ttT/i//nsoY1+KJwhVvPJ18no7UQtPkm16r1iXpTStfuoO9IvPH QqgBFtaqFJjL11/CbZEWJoIzAipsgjhftRV+zIWmz5t8XPSQ78VNKscAalMikaOU+rSD +pvbQZvLFK1B1OlV2DjYhlxvC14wj8N3Per3lY2z1QCD66WCoQduPYTxNahQtfVIGUwX lvEwII3rTOCd6UMeLb6UCtv93uqD9fMu2gmmVTljyBceKq31OsxGh2R4vWuB7uhHZFM3 gBNCx4wg70D6khVMYPY6cxyzPuNEAoIiga/hr/i+HMJl70wjveSAVE0jZHYVDdrZB6cX Ddhw== ARC-Authentication-Results: i=1; mx.google.com; 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 m66-v6si15531098pfm.191.2018.10.09.06.52.22; Tue, 09 Oct 2018 06:52:37 -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; 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 S1726996AbeJIVIm (ORCPT + 99 others); Tue, 9 Oct 2018 17:08:42 -0400 Received: from pegase1.c-s.fr ([93.17.236.30]:40793 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726445AbeJIVIl (ORCPT ); Tue, 9 Oct 2018 17:08:41 -0400 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 42TzCt4nV2z9ttSj; Tue, 9 Oct 2018 15:51:22 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at c-s.fr Received: from pegase1.c-s.fr ([192.168.12.234]) by localhost (pegase1.c-s.fr [192.168.12.234]) (amavisd-new, port 10024) with ESMTP id Liyy-lUo66M5; Tue, 9 Oct 2018 15:51:22 +0200 (CEST) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase1.c-s.fr (Postfix) with ESMTP id 42TzCt4CdHz9ttRm; Tue, 9 Oct 2018 15:51:22 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 424F48B80A; Tue, 9 Oct 2018 15:51:34 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id abCXGTy6nRFq; Tue, 9 Oct 2018 15:51:34 +0200 (CEST) Received: from pc13168vm.idsi0.si.c-s.fr (unknown [192.168.232.3]) by messagerie.si.c-s.fr (Postfix) with ESMTP id E79C58B80C; Tue, 9 Oct 2018 15:51:33 +0200 (CEST) Received: by pc13168vm.idsi0.si.c-s.fr (Postfix, from userid 0) id C7E7C6F444; Tue, 9 Oct 2018 13:51:33 +0000 (UTC) Message-Id: In-Reply-To: References: From: Christophe Leroy Subject: [PATCH v3 01/24] powerpc/32: Add ioremap_wt() and ioremap_coherent() To: Bartlomiej Zolnierkiewicz , Benjamin Herrenschmidt , Dominik Brodowski , Geoff Levand , Jens Axboe , Kumar Gala , Li Yang , Michael Ellerman , Nicholas Piggin , Paul Mackerras , Scott Wood , aneesh.kumar@linux.vnet.ibm.com Cc: linux-arm-kernel@lists.infradead.org, linux-block@vger.kernel.org, linux-fbdev@vger.kernel.org, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, dri-devel@lists.freedesktop.org Date: Tue, 9 Oct 2018 13:51:33 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Other arches have ioremap_wt() to map IO areas write-through. Implement it on PPC as well in order to avoid drivers using __ioremap(_PAGE_WRITETHRU) Also implement ioremap_coherent() to avoid drivers using __ioremap(_PAGE_COHERENT) Signed-off-by: Christophe Leroy --- arch/powerpc/include/asm/io.h | 9 +++++++++ arch/powerpc/mm/pgtable_32.c | 16 ++++++++++++++++ arch/powerpc/mm/pgtable_64.c | 10 ++++++++++ 3 files changed, 35 insertions(+) diff --git a/arch/powerpc/include/asm/io.h b/arch/powerpc/include/asm/io.h index e0331e754568..cdccab3938db 100644 --- a/arch/powerpc/include/asm/io.h +++ b/arch/powerpc/include/asm/io.h @@ -3,6 +3,9 @@ #ifdef __KERNEL__ #define ARCH_HAS_IOREMAP_WC +#ifdef CONFIG_PPC32 +#define ARCH_HAS_IOREMAP_WT +#endif /* * This program is free software; you can redistribute it and/or @@ -746,6 +749,10 @@ static inline void iosync(void) * * * ioremap_wc enables write combining * + * * ioremap_wt enables write through + * + * * ioremap_coherent maps coherent cached memory + * * * iounmap undoes such a mapping and can be hooked * * * __ioremap_at (and the pending __iounmap_at) are low level functions to @@ -767,6 +774,8 @@ extern void __iomem *ioremap(phys_addr_t address, unsigned long size); extern void __iomem *ioremap_prot(phys_addr_t address, unsigned long size, unsigned long flags); extern void __iomem *ioremap_wc(phys_addr_t address, unsigned long size); +void __iomem *ioremap_wt(phys_addr_t address, unsigned long size); +void __iomem *ioremap_coherent(phys_addr_t address, unsigned long size); #define ioremap_nocache(addr, size) ioremap((addr), (size)) #define ioremap_uc(addr, size) ioremap((addr), (size)) #define ioremap_cache(addr, size) \ diff --git a/arch/powerpc/mm/pgtable_32.c b/arch/powerpc/mm/pgtable_32.c index 120a49bfb9c6..4c3adde09d95 100644 --- a/arch/powerpc/mm/pgtable_32.c +++ b/arch/powerpc/mm/pgtable_32.c @@ -90,6 +90,22 @@ ioremap_wc(phys_addr_t addr, unsigned long size) EXPORT_SYMBOL(ioremap_wc); void __iomem * +ioremap_wt(phys_addr_t addr, unsigned long size) +{ + return __ioremap_caller(addr, size, _PAGE_WRITETHRU, + __builtin_return_address(0)); +} +EXPORT_SYMBOL(ioremap_wt); + +void __iomem * +ioremap_coherent(phys_addr_t addr, unsigned long size) +{ + return __ioremap_caller(addr, size, _PAGE_COHERENT, + __builtin_return_address(0)); +} +EXPORT_SYMBOL(ioremap_coherent); + +void __iomem * ioremap_prot(phys_addr_t addr, unsigned long size, unsigned long flags) { /* writeable implies dirty for kernel addresses */ diff --git a/arch/powerpc/mm/pgtable_64.c b/arch/powerpc/mm/pgtable_64.c index e15e63079ba8..c0f356d9b135 100644 --- a/arch/powerpc/mm/pgtable_64.c +++ b/arch/powerpc/mm/pgtable_64.c @@ -222,6 +222,16 @@ void __iomem * ioremap_wc(phys_addr_t addr, unsigned long size) return __ioremap_caller(addr, size, flags, caller); } +void __iomem *ioremap_coherent(phys_addr_t addr, unsigned long size) +{ + unsigned long flags = pgprot_val(pgprot_cached(__pgprot(0))); + void *caller = __builtin_return_address(0); + + if (ppc_md.ioremap) + return ppc_md.ioremap(addr, size, flags, caller); + return __ioremap_caller(addr, size, flags, caller); +} + void __iomem * ioremap_prot(phys_addr_t addr, unsigned long size, unsigned long flags) { -- 2.13.3