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: 137629 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp1502636lji; Mon, 4 Jun 2018 06:16:18 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLZVa1U5kLzn/wjM8HGSLIdehtzMZctjnDJtiYzHCFlyXmw6R9JZq+3pXxc4sMgkjMzA/hD X-Received: by 2002:a17:902:1c7:: with SMTP id b65-v6mr21804100plb.298.1528118178558; Mon, 04 Jun 2018 06:16:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528118178; cv=none; d=google.com; s=arc-20160816; b=dfbJQkXwm8C/Pb8nhuu4csBQT7ZyyX/r5UYzBKvcrPYov+YNLdfnEJntpr1oZw0lhE 45YBvNcfLx+YJl5vaM7AnVIHK6JWdDlgpo0FKMHmA7AS6xNRfVmjg//CIYm83K2hiZXo C+V2xO7wdyOSxdnvw44VrWGc34HHa60ZiveVNab96AjNhjIb9xg2xTHxzuUiGlQPFGcg s5jbNcuEVYcpWMyMpWtBFMTRnpGzd6dgIulzrtIZuojJScONbTyCfonkoEMOqkJfOJm3 miWB3qPIWigjjSiZHsHLvOPmHZFJJWhb0vnScvJ+BaYeHMRic9fZATsngO7rAal5CIKi ScLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=lXFDEub1uWNfN/GizygPA93gIvAwe6lWcDo0cHtg27U=; b=wynnppdsKgUltkLrFeI/ju7kXDzBdBeYEogHeRyW3sa6c05SqJ8lrrMrQahLhDGKzd Na/9ATCCCeB5gXVtKtsJ9c20JI47tZ+/mjos8Guvi6yNlMCdvhjecUXG26NwYD3LNfTr c9X1Re7fWWSdhOGQqoXKyWcnM+GmFWhvZspzaFns6a3mCZMtEw6I/kpJq1t7+m/SMsuC 681i7CibS0lcvGkKKfauE91f9/bXYtL2DJS1HXCwVU/IXzrwS2JezwVeakdOBnVY3P6B x49jV7OUgfKzdfeTmNQ45JU/6vDz2MuAxTKEyWpfIXaQ7X0bjgWj5/HoSwLTHvFkQj1g i83A== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=A5dvtVgA; spf=pass (google.com: best guess record for domain of linux-serial-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-serial-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 9-v6si18779011ple.104.2018.06.04.06.16.18; Mon, 04 Jun 2018 06:16:18 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-serial-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=A5dvtVgA; spf=pass (google.com: best guess record for domain of linux-serial-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-serial-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753154AbeFDNQR (ORCPT + 2 others); Mon, 4 Jun 2018 09:16:17 -0400 Received: from mail-wr0-f193.google.com ([209.85.128.193]:37552 "EHLO mail-wr0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752712AbeFDNQQ (ORCPT ); Mon, 4 Jun 2018 09:16:16 -0400 Received: by mail-wr0-f193.google.com with SMTP id d8-v6so12131323wro.4 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=mUHoRXtqIhnvfRkZScijm6UbDqZr+Gjux/oHis9FzbnqJ/CZQrgM0ocbIYV2Q9DYbX sJrdHb5ZA9VXOBTz3fBqjNvqHmP0YxMFtO7QE96iXbMNY1yLlqnI7gUovNrkpmkDdZ1Y 73ilCn2eDOe0IBwZ2qD912aPHFPORnKljr27lhuSEuaJY2QpjT9JEdAbS3XSIBFpEGy1 3xMrB/WCHGJ5koDwU7RqtrPx3kh0rU9oQvn5D3t2ffyCYapbgRrVzA0qSbHE7E1BE3TI 2y1XFXWLO4jOYMxRM/C2BS+djoAC86QGMELUKdoD9yMFdMf5a5dCXF/x+9Iq3ko0JUa6 ahjw== X-Gm-Message-State: APt69E29ZucdsmhYxvNC+kl3/3RNdioDea2YKrgBUgw4aWgDWodwQG3v l2ZgpqG3QnI64pPxau4Y+otwZg== 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 Cc: leif.lindholm@linaro.org, graeme.gregory@linaro.org, gregkh@linuxfoundation.org, linux@armlinux.org.uk, jslaby@suse.com, linux-serial@vger.kernel.org, linux-arm-kernel@lists.infradead.org, ard.biesheuvel@linaro.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 Sender: linux-serial-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org 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(+) -- 2.17.0 -- To unsubscribe from this list: send the line "unsubscribe linux-serial" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html 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,