Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1470214ybl; Tue, 13 Aug 2019 13:13:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqwkYcpT/XdQQ569Hi6G0hda1m2OCUVZsk22/ctDYF13AIrjA/U57Wf3gPW5V6eD+XlRBM9V X-Received: by 2002:a17:90a:cb12:: with SMTP id z18mr3661771pjt.82.1565727225858; Tue, 13 Aug 2019 13:13:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565727225; cv=none; d=google.com; s=arc-20160816; b=wKRNIWuaQmwhebTkAtX3Lj4VJHwFjb4lxeN0CsqwNIvCvlv5g2e1bii/KdExU2M6x9 wFP8D2XaN5e+3AJIQpO0351Uhg4e4+z3wqadVOhgQyyPr3Wg1iLcias6Tz3M8ndACE4K ewPfjdavIUNQdZcq0Xgf0KiFmn1VfVg4R9a/AdrKD3OJ6yTTZ9rFCtywa8zIJPCGlHJM 1sq3A5sIonbrP8+4SG2ycf8YzlRdcr/lYj9/JdLOqYOo+BZaZu9/GlfRs2xpOvIlPOj4 D8dcZj30qoke9qEIZT4KM0McLsKmqBGMpDKficqtlMO2jR27V3IycAVhpgPpup85wj+0 qDcA== 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:dkim-signature; bh=fWESdiJOEhqopqv9pmvMpyC9QDIf6/EZbHgCKEO0na0=; b=vuES/uq/ytnROg4EQwrDd/lbEHuF9ovwI8JgZ+Go3S8SvO3nyyhVD/CWsyYF5B+sKV /nz1KYU0dYq+1Uq+eNZ7N30lArBIW/XSBb7kK0IzU/ae51vQ5EoC0HGbVozsjrk9UrDz orxOBfSHa1CDOnWvVq6sTLV7sydelKvq0GMotj1PUBsTq6Uc7yamVdwc3+1EpAt0lgXG tIJ7gp6ix73iq+pRwn3XUf5wdg6TQxorgesuYI74ASYk40i1nrjEKB2wJJgCa9U8/Uiy LuQnLgbW4bOEBOlmXAdimKXWiLAKqh3S6gNy8nDna9ENuPHJcSp0I380ftperrK8ukQp 7suA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@c-s.fr header.s=mail header.b=GOARWqum; 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 t20si52602843pgv.580.2019.08.13.13.13.26; Tue, 13 Aug 2019 13:13:45 -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=pass header.i=@c-s.fr header.s=mail header.b=GOARWqum; 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 S1726858AbfHMULm (ORCPT + 99 others); Tue, 13 Aug 2019 16:11:42 -0400 Received: from pegase1.c-s.fr ([93.17.236.30]:35063 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726802AbfHMULk (ORCPT ); Tue, 13 Aug 2019 16:11:40 -0400 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 467P4V30s9z9v0CP; Tue, 13 Aug 2019 22:11:38 +0200 (CEST) Authentication-Results: localhost; dkim=pass reason="1024-bit key; insecure key" header.d=c-s.fr header.i=@c-s.fr header.b=GOARWqum; dkim-adsp=pass; dkim-atps=neutral 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 ETnBwsFF4CiC; Tue, 13 Aug 2019 22:11:38 +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 467P4V1yv7z9v0CM; Tue, 13 Aug 2019 22:11:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=c-s.fr; s=mail; t=1565727098; bh=fWESdiJOEhqopqv9pmvMpyC9QDIf6/EZbHgCKEO0na0=; h=In-Reply-To:References:From:Subject:To:Cc:Date:From; b=GOARWqumr3a9JtCdQxN2IqcFcjNTaXYD5lF6CUOFEWnRZpF+rgviv4hRCrQB5Xyrt PFibgtkN6r9s+P7Y2Sab4Y9s70Ua2I6RJ602xU5ZHrc5mOj52bB+MJ0BWkZSkpiCa6 VvuZggMHzXD+Y96uWPAAa33rYDjtgnP7LvcAUOLQ= Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 6B6668B7F2; Tue, 13 Aug 2019 22:11:38 +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 6u8WfcFOvfOe; Tue, 13 Aug 2019 22:11:38 +0200 (CEST) Received: from pc17473vm.idsi0.si.c-s.fr (unknown [192.168.4.90]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 2E8F58B7F0; Tue, 13 Aug 2019 22:11:38 +0200 (CEST) Received: by pc17473vm.idsi0.si.c-s.fr (Postfix, from userid 0) id 1439A69632; Tue, 13 Aug 2019 20:11:38 +0000 (UTC) Message-Id: <019c5d90f7027ccff00e38a3bcd633d290f6af59.1565726867.git.christophe.leroy@c-s.fr> In-Reply-To: <6bc35eca507359075528bc0e55938bc1ce8ee485.1565726867.git.christophe.leroy@c-s.fr> References: <6bc35eca507359075528bc0e55938bc1ce8ee485.1565726867.git.christophe.leroy@c-s.fr> From: Christophe Leroy Subject: [PATCH v1 05/10] powerpc/mm: Do early ioremaps from top to bottom on PPC64 too. To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , npiggin@gmail.com Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Date: Tue, 13 Aug 2019 20:11:38 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Until vmalloc system is up and running, ioremap basically allocates addresses at the border of the IOREMAP area. On PPC32, addresses are allocated down from the top of the area while on PPC64, addresses are allocated up from the base of the area. On PPC32, the base of vmalloc area is not known yet when ioremap() starts to be used, while the end of it is fixed. On PPC64, both the start and the end are already fixed when ioremap() starts to being used. Changing PPC64 behaviour is the lighest change, so change PPC64 ioremap() to allocate addresses from the top as PPC32 does. Signed-off-by: Christophe Leroy --- arch/powerpc/mm/book3s64/hash_utils.c | 2 +- arch/powerpc/mm/book3s64/radix_pgtable.c | 2 +- arch/powerpc/mm/pgtable_64.c | 18 +++++++++--------- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/arch/powerpc/mm/book3s64/hash_utils.c b/arch/powerpc/mm/book3s64/hash_utils.c index e6d471058597..0f954dc40346 100644 --- a/arch/powerpc/mm/book3s64/hash_utils.c +++ b/arch/powerpc/mm/book3s64/hash_utils.c @@ -1030,7 +1030,7 @@ void __init hash__early_init_mmu(void) __kernel_io_start = H_KERN_IO_START; __kernel_io_end = H_KERN_IO_END; vmemmap = (struct page *)H_VMEMMAP_START; - ioremap_bot = IOREMAP_BASE; + ioremap_bot = IOREMAP_END; #ifdef CONFIG_PCI pci_io_base = ISA_IO_BASE; diff --git a/arch/powerpc/mm/book3s64/radix_pgtable.c b/arch/powerpc/mm/book3s64/radix_pgtable.c index b4ca9e95e678..11303e2fffb1 100644 --- a/arch/powerpc/mm/book3s64/radix_pgtable.c +++ b/arch/powerpc/mm/book3s64/radix_pgtable.c @@ -611,7 +611,7 @@ void __init radix__early_init_mmu(void) __kernel_io_start = RADIX_KERN_IO_START; __kernel_io_end = RADIX_KERN_IO_END; vmemmap = (struct page *)RADIX_VMEMMAP_START; - ioremap_bot = IOREMAP_BASE; + ioremap_bot = IOREMAP_END; #ifdef CONFIG_PCI pci_io_base = ISA_IO_BASE; diff --git a/arch/powerpc/mm/pgtable_64.c b/arch/powerpc/mm/pgtable_64.c index 6fa2e969bf0e..0f0b1e1ea5ab 100644 --- a/arch/powerpc/mm/pgtable_64.c +++ b/arch/powerpc/mm/pgtable_64.c @@ -101,7 +101,7 @@ unsigned long __pte_frag_size_shift; EXPORT_SYMBOL(__pte_frag_size_shift); unsigned long ioremap_bot; #else /* !CONFIG_PPC_BOOK3S_64 */ -unsigned long ioremap_bot = IOREMAP_BASE; +unsigned long ioremap_bot = IOREMAP_END; #endif int __weak ioremap_range(unsigned long ea, phys_addr_t pa, unsigned long size, pgprot_t prot, int nid) @@ -169,11 +169,11 @@ void __iomem * __ioremap_caller(phys_addr_t addr, unsigned long size, /* * Choose an address to map it to. - * Once the imalloc system is running, we use it. + * Once the vmalloc system is running, we use it. * Before that, we map using addresses going - * up from ioremap_bot. imalloc will use - * the addresses from ioremap_bot through - * IMALLOC_END + * down from ioremap_bot. vmalloc will use + * the addresses from IOREMAP_BASE through + * ioremap_bot * */ paligned = addr & PAGE_MASK; @@ -186,7 +186,7 @@ void __iomem * __ioremap_caller(phys_addr_t addr, unsigned long size, struct vm_struct *area; area = __get_vm_area_caller(size, VM_IOREMAP, - ioremap_bot, IOREMAP_END, + IOREMAP_BASE, ioremap_bot, caller); if (area == NULL) return NULL; @@ -194,9 +194,9 @@ void __iomem * __ioremap_caller(phys_addr_t addr, unsigned long size, area->phys_addr = paligned; ret = __ioremap_at(paligned, area->addr, size, prot); } else { - ret = __ioremap_at(paligned, (void *)ioremap_bot, size, prot); + ret = __ioremap_at(paligned, (void *)ioremap_bot - size, size, prot); if (ret) - ioremap_bot += size; + ioremap_bot -= size; } if (ret) @@ -217,7 +217,7 @@ void __iounmap(volatile void __iomem *token) addr = (void *) ((unsigned long __force) PCI_FIX_ADDR(token) & PAGE_MASK); - if ((unsigned long)addr < ioremap_bot) { + if ((unsigned long)addr >= ioremap_bot) { printk(KERN_WARNING "Attempt to iounmap early bolted mapping" " at 0x%p\n", addr); return; -- 2.13.3