From patchwork Mon Jun 4 13:16:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 10446581 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 71F5860284 for ; Mon, 4 Jun 2018 13:16:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5DEBB28F8C for ; Mon, 4 Jun 2018 13:16:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5193B28F99; Mon, 4 Jun 2018 13:16:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9FD6C28F8C for ; Mon, 4 Jun 2018 13:16:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=7/S5gyhgBvy41FKcXuCXnvPE09HXyM0PUgUSD85Z+50=; b=psi gRuLrDl7SDh9uPN4Dov3hncxOPv2BueJt2eG4IpFRtdZp+cSCm0f8KpprdAQuKkiUKwpuNZJWtZ8q 6qk1X78P5JQbEo2vvWTY81ot8uLBfR1eHP/vrODNOde+8FRntOxq420GeYhQsQGMKt5GWE4jRS7Pg ig3ebQK76gcUZ76fN/MwR5zqDCXNrxp05A73bPwHE3JWPeTR7FDK0ycJFWtFSgbur1Qv433W30G5s sRuDi1Rz4urkHjRgx6zA7eTtFEMhyign6zqyt1lwXIGMyu2HwPZ6qVjypuumMxIHugACP1g/yoK7g fe0uP338jF2AiWIGtb0E3tbSOxZ6Muw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fPpLb-000088-RY; Mon, 04 Jun 2018 13:16:31 +0000 Received: from mail-wr0-x242.google.com ([2a00:1450:400c:c0c::242]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fPpLX-00005b-Fv for linux-arm-kernel@lists.infradead.org; Mon, 04 Jun 2018 13:16:29 +0000 Received: by mail-wr0-x242.google.com with SMTP id l41-v6so43366224wre.7 for ; Mon, 04 Jun 2018 06:16:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=nCyRx0D0bBJHKC6UtAYtwgU2omPmENDWqjFO4mynw/w=; b=A5dvtVgAbI3Ocam6QGiAN1/uk6YGedSXViVzEjVrKUXol9qDZP/8AfYLPUW7Lem4XZ isDs3ADeNtzZfyGhTUm55uy3qyPJt5UakjTdQw+nzLIaeLxOAQW6U2XPSehmL6ofcf1U RAWvp2hYEhnnCYLVoVb8445SOdRy/X4ovBA8c= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=nCyRx0D0bBJHKC6UtAYtwgU2omPmENDWqjFO4mynw/w=; b=tl5mSDGabXRORjxWvSyf0nik7mh0j31mVjezN5atDx8ZSZHCMj4L+hKNJCQaCxVHFh 6/YQm0PfNWIGhXBt3Nwx4E/LZxfDG1+gMlo4hyaKKuZUI7DREEfor1ltZmF+ovRaeO0P BSWYj8TGWZVVUXuzRDOMCYd/zHgIYul3pXnJv7raQhuKZ+n7YbHVHK9y72GQ9bk7zZ+M BfuG4czLI/nRwbcOwhLlS9O0LkXiDj8xmszvdV9SIQElQXoTDZE22hKtoVu9QG3qH66W pohbKHjkezrc92Zr+F4GGBh8GC12ZSvmNzNfIo8kLQgQ0w10k4vHehf9YnXkTYUCM732 mO0g== X-Gm-Message-State: APt69E1OXDBBaxiJqhy7mwP0JcN/dZu3EF0FId9QJhEEhOvsKHbCcWB4 bERSZXBcvoZ+jMn4za08W7hTBw== X-Google-Smtp-Source: ADUXVKLgNR7HZihCgmT/2w4llxxKWyPnLMgI7H4mDgUcEQlrGAH45m3hENHZBlaEk3UsCpOZD7s6Zw== X-Received: by 2002:a1c:e184:: with SMTP id y126-v6mr7532366wmg.128.1528118175299; Mon, 04 Jun 2018 06:16:15 -0700 (PDT) Received: from dogfood.home (LFbn-NIC-1-75-91.w2-15.abo.wanadoo.fr. [2.15.165.91]) by smtp.gmail.com with ESMTPSA id s13-v6sm1808601wrq.48.2018.06.04.06.16.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 04 Jun 2018 06:16:13 -0700 (PDT) From: Ard Biesheuvel To: stable@vger.kernel.org Subject: [PATCH v4.9-stable] serial: pl011: add console matching function Date: Mon, 4 Jun 2018 15:16:12 +0200 Message-Id: <20180604131612.14407-1-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180604_061627_556187_EA4F92DF X-CRM114-Status: GOOD ( 18.37 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: graeme.gregory@linaro.org, ard.biesheuvel@linaro.org, gregkh@linuxfoundation.org, linux@armlinux.org.uk, leif.lindholm@linaro.org, linux-serial@vger.kernel.org, jslaby@suse.com, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Aleksey Makarov Commit 10879ae5f12e9cab3c4e8e9504c1aaa8a033bde7 upstream. This patch adds function pl011_console_match() that implements method match of struct console. It allows to match consoles against data specified in a string, for example taken from command line or compiled by ACPI SPCR table handler. This patch was merged to tty-next but then reverted because of conflict with commit 46e36683f433 ("serial: earlycon: Extend earlycon command line option to support 64-bit addresses") Now it is fixed. Signed-off-by: Aleksey Makarov Reviewed-by: Peter Hurley Acked-by: Russell King Tested-by: Christopher Covington Signed-off-by: Greg Kroah-Hartman Signed-off-by: Ard Biesheuvel --- Please consider for v4.9-stable. It is the missing puzzle piece for SPCR support on arm64 ACPI systems, which got merged for v4.9 [0]. Now that more systems are becoming available to people working in the kernel community, it turns out that v4.9 distro installers (e.g., Debian Stretch) won't work unless you pass a 'console=' parameter explicitly, which is annoying. Given that it was clearly the intent to include this code at the time, I hope it will be considered for backporting. [0] To quote the tty maintainer: Also in here is the long-suffering ACPI SPCR patchset, which was passed around from maintainer to maintainer like a hot-potato. Seems I was the sucker^Wlucky one. All of those patches have been acked by the various subsystem maintainers as well. drivers/tty/serial/amba-pl011.c | 55 ++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c index b42d7f1c9089..6b1863293fe1 100644 --- a/drivers/tty/serial/amba-pl011.c +++ b/drivers/tty/serial/amba-pl011.c @@ -2320,12 +2320,67 @@ static int __init pl011_console_setup(struct console *co, char *options) return uart_set_options(&uap->port, co, baud, parity, bits, flow); } +/** + * pl011_console_match - non-standard console matching + * @co: registering console + * @name: name from console command line + * @idx: index from console command line + * @options: ptr to option string from console command line + * + * Only attempts to match console command lines of the form: + * console=pl011,mmio|mmio32,[,] + * console=pl011,0x[,] + * This form is used to register an initial earlycon boot console and + * replace it with the amba_console at pl011 driver init. + * + * Performs console setup for a match (as required by interface) + * If no are specified, then assume the h/w is already setup. + * + * Returns 0 if console matches; otherwise non-zero to use default matching + */ +static int __init pl011_console_match(struct console *co, char *name, int idx, + char *options) +{ + unsigned char iotype; + resource_size_t addr; + int i; + + if (strcmp(name, "pl011") != 0) + return -ENODEV; + + if (uart_parse_earlycon(options, &iotype, &addr, &options)) + return -ENODEV; + + if (iotype != UPIO_MEM && iotype != UPIO_MEM32) + return -ENODEV; + + /* try to match the port specified on the command line */ + for (i = 0; i < ARRAY_SIZE(amba_ports); i++) { + struct uart_port *port; + + if (!amba_ports[i]) + continue; + + port = &amba_ports[i]->port; + + if (port->mapbase != addr) + continue; + + co->index = i; + port->cons = co; + return pl011_console_setup(co, options); + } + + return -ENODEV; +} + static struct uart_driver amba_reg; static struct console amba_console = { .name = "ttyAMA", .write = pl011_console_write, .device = uart_console_device, .setup = pl011_console_setup, + .match = pl011_console_match, .flags = CON_PRINTBUFFER, .index = -1, .data = &amba_reg,