Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp200099ybv; Wed, 5 Feb 2020 04:06:27 -0800 (PST) X-Google-Smtp-Source: APXvYqzhaK5XbYDN7YRf/686v8HgXEH29morOR2ZGYWs3reknIIKcZ+5eXP5mYwQq8yNNq5Xzgek X-Received: by 2002:a05:6830:14c3:: with SMTP id t3mr24863225otq.213.1580904387590; Wed, 05 Feb 2020 04:06:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580904387; cv=none; d=google.com; s=arc-20160816; b=zr+XOijaO4peI6Hdr+QfoxDMQSJRSIxUu98cEEN0xLA9XM8CI/pyIZaOpSLexEulVQ iCl2yq3yzOwZSj0brOzw1HXiXr/+UZmTJudYjfhfFHOvY3KvEBgDQKCdUCv46olZLcTm +/mGEM4COvxUhrlu8ho4KLHqInHs1CAy0NwS31gHuiWhDw2DSd1EO356zXH/o6C4vWIa V4huj4k3+6J1kGXaGK/SZDHXAN3OEV9K8o69AM90b8C+n6+URV8n11RrnoNH15n6klF6 Sqmz6d2GTmt9BLpuxCtc/SR0tpjF/RcFnGwMZdzmGIe3fpDZNgSR8DvOm2spIsxqdz0P rNoA== 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:message-id :dkim-signature; bh=C5M0Cj48NNBEOYHvqWjd1d/qw7guwrS5qscRXgVUNqo=; b=x0aqdTENJx15D5GPklEV+z1Kl/OSoHKWgEQ4iRW0iERPJKMTTehdOudSRvXoZLJXLM nVGCBZGRhyH7BppkbirWUJoXFjPc+toi3dlIeJt4XCAOHkN9Vd/1zyz6a7DZkod+Ibrs f6fNqS9peLe+TI9+4g8LO3/24/Nt/dFdfMGsqsNdmBym2etd2px8fLwVeRsqF4z63I9H CqVWnm8UcGc37sl6noNNvLfYxJ6tgcYoOWcwgBFwvO7KICpJEePU+UNOLBrsTUrM2Ppo yVIB/tSkRUl5c+KiYDh3rIX7f5vHvZOI0MXueyNNG3QK67P/dmK0JlNvgdfRsAhEEs5y pXOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@c-s.fr header.s=mail header.b=GU46OkPe; 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 f81si11680264oig.110.2020.02.05.04.06.13; Wed, 05 Feb 2020 04:06:27 -0800 (PST) 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=GU46OkPe; 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 S1727500AbgBEMDq (ORCPT + 99 others); Wed, 5 Feb 2020 07:03:46 -0500 Received: from pegase1.c-s.fr ([93.17.236.30]:15969 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726953AbgBEMDp (ORCPT ); Wed, 5 Feb 2020 07:03:45 -0500 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 48CKwG2j3Wz9vBQB; Wed, 5 Feb 2020 13:03:42 +0100 (CET) Authentication-Results: localhost; dkim=pass reason="1024-bit key; insecure key" header.d=c-s.fr header.i=@c-s.fr header.b=GU46OkPe; 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 n2QPUTf7otnk; Wed, 5 Feb 2020 13:03:42 +0100 (CET) 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 48CKwG1bYZz9vBQ8; Wed, 5 Feb 2020 13:03:42 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=c-s.fr; s=mail; t=1580904222; bh=C5M0Cj48NNBEOYHvqWjd1d/qw7guwrS5qscRXgVUNqo=; h=From:Subject:To:Cc:Date:From; b=GU46OkPeZvmRZ+kSnunZ4z8NT27FmHv/6wZpZ5v7QvXy5JwdOpdiLTLkEGIcC67tm U+vyox2GfDccu9iull750PB+VrBMkKA49BDq6rJ63VI8g891qH1zmome77g5/vjbcm QvlRLB5YxK6XWdIAAVWX1PwMbVLrSoaL9C6asddI= Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 4F37A8B838; Wed, 5 Feb 2020 13:03:43 +0100 (CET) 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 DjYsAgrkX-J5; Wed, 5 Feb 2020 13:03:43 +0100 (CET) Received: from po14934vm.idsi0.si.c-s.fr (po15451.idsi0.si.c-s.fr [172.25.230.107]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 2321D8B835; Wed, 5 Feb 2020 13:03:43 +0100 (CET) Received: by po14934vm.idsi0.si.c-s.fr (Postfix, from userid 0) id CE24665266; Wed, 5 Feb 2020 12:03:42 +0000 (UTC) Message-Id: <3df15946ed0c29663dc7928b31ca07576e1444f6.1580904214.git.christophe.leroy@c-s.fr> From: Christophe Leroy Subject: [PATCH] powerpc/legacy_serial: Use early_ioremap() To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Date: Wed, 5 Feb 2020 12:03:42 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ 0.000000] ioremap() called early from find_legacy_serial_ports+0x3cc/0x474. Use early_ioremap() instead find_legacy_serial_ports() is called early from setup_arch(), before paging_init(). vmalloc is not available yet, ioremap shouldn't be used that early. Use early_ioremap() and switch to a regular ioremap() later. Signed-off-by: Christophe Leroy --- arch/powerpc/kernel/legacy_serial.c | 33 +++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/arch/powerpc/kernel/legacy_serial.c b/arch/powerpc/kernel/legacy_serial.c index f061e06e9f51..8b2c1a8553a0 100644 --- a/arch/powerpc/kernel/legacy_serial.c +++ b/arch/powerpc/kernel/legacy_serial.c @@ -15,6 +15,7 @@ #include #include #include +#include #undef DEBUG @@ -34,6 +35,7 @@ static struct legacy_serial_info { unsigned int clock; int irq_check_parent; phys_addr_t taddr; + void __iomem *early_addr; } legacy_serial_infos[MAX_LEGACY_SERIAL_PORTS]; static const struct of_device_id legacy_serial_parents[] __initconst = { @@ -325,17 +327,16 @@ static void __init setup_legacy_serial_console(int console) { struct legacy_serial_info *info = &legacy_serial_infos[console]; struct plat_serial8250_port *port = &legacy_serial_ports[console]; - void __iomem *addr; unsigned int stride; stride = 1 << port->regshift; /* Check if a translated MMIO address has been found */ if (info->taddr) { - addr = ioremap(info->taddr, 0x1000); - if (addr == NULL) + info->early_addr = early_ioremap(info->taddr, 0x1000); + if (info->early_addr == NULL) return; - udbg_uart_init_mmio(addr, stride); + udbg_uart_init_mmio(info->early_addr, stride); } else { /* Check if it's PIO and we support untranslated PIO */ if (port->iotype == UPIO_PORT && isa_io_special) @@ -353,6 +354,30 @@ static void __init setup_legacy_serial_console(int console) udbg_uart_setup(info->speed, info->clock); } +static int __init ioremap_legacy_serial_console(void) +{ + struct legacy_serial_info *info = &legacy_serial_infos[legacy_serial_console]; + struct plat_serial8250_port *port = &legacy_serial_ports[legacy_serial_console]; + void __iomem *vaddr; + + if (legacy_serial_console < 0) + return 0; + + if (!info->early_addr) + return 0; + + vaddr = ioremap(info->taddr, 0x1000); + if (WARN_ON(!vaddr)) + return -ENOMEM; + + udbg_uart_init_mmio(vaddr, 1 << port->regshift); + early_iounmap(info->early_addr, 0x1000); + info->early_addr = NULL; + + return 0; +} +early_initcall(ioremap_legacy_serial_console); + /* * This is called very early, as part of setup_system() or eventually * setup_arch(), basically before anything else in this file. This function -- 2.25.0