Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp4588391ybz; Tue, 28 Apr 2020 14:16:47 -0700 (PDT) X-Google-Smtp-Source: APiQypJg6xm5nUDdHdhOTvauGnnshrZK2AqZd+AyHecA+drebQ+cBYno1P/0p3Qhe6C8SGw2BrFN X-Received: by 2002:a17:906:c7c5:: with SMTP id dc5mr26988043ejb.50.1588108607166; Tue, 28 Apr 2020 14:16:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588108607; cv=none; d=google.com; s=arc-20160816; b=AjeCPuQ85lF+FBaXgk5duIohvp0QQa21cmMW0jpcN+YYoYRKdFxpXOABkwCxqEgF1M Er7b6iOHmYzjN/a/WeNT3V/JkLgoKbgR849aemnxAAgYgLwPxfAiRVkHvr6wOPaiZ4A8 7YzgkxQjtoVZc4VeKZxtreDyPIEFMgJBxgwhtqneopXnIuLzxqjo4lCMhYGbv9KQasBH Gr+NxEaJ1yXHFFB9UJYCyXvKKxJWvvdSeq8b/QIs4+DIHpjsGioYOlMaeOtEuKJg8iwd yhxuyYIW19tJHXj6joqvEqWsFxpU//YraOMC3YQN/Q0PUkAzq1kw6GCHBbWYMSsz8y8T Eusw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=olbDJB3S+bdQ1rHPM1o42dCtHB3e0ATdib9atqJ3CH0=; b=PN5N4eO8EwS8StKHuV/mBQWNGCikwp5t1u05Ad3MxllWl7zbalmlYVuO5Po65l93vS jOPS/UpCBe3pREE/wROroExAi83oU0MWyLvp7uU36p8y9+oBTB+UUhZPwdv5VRzotT5B kgJ26YndzG5pAj7jXB6FpoWCsajY1DpQ83QHKxd9OPGTmuJn+SJz1AWcq1sWdvbN8SYi 1kXQESUecVgnZzXlFUU9TEbVIja7BIHV8VOGloilBmxPWF44ZINHPQhrKXzNxRDkZg6+ Kji2g0yplbLx7suhPkL5MKOS0mULlu40DRsnebpArmH2DoYAwfP4Gpb6OK7MWSccDk42 sVbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="PIn5iHI/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gt7si2510877ejb.360.2020.04.28.14.16.22; Tue, 28 Apr 2020 14:16:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="PIn5iHI/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726921AbgD1VOk (ORCPT + 99 others); Tue, 28 Apr 2020 17:14:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41160 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726885AbgD1VOe (ORCPT ); Tue, 28 Apr 2020 17:14:34 -0400 Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 18616C03C1AD for ; Tue, 28 Apr 2020 14:14:34 -0700 (PDT) Received: by mail-pl1-x643.google.com with SMTP id f15so810750plr.3 for ; Tue, 28 Apr 2020 14:14:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=olbDJB3S+bdQ1rHPM1o42dCtHB3e0ATdib9atqJ3CH0=; b=PIn5iHI/IwS+TMjQUsr/2rRfGrEiC7wLceEHu2VgewBRrHcU+2V+W+ZAiKrY1GySUm voM5jTx9zygH5APLxR5laFyA0OZJt/joPffylYulA5va6p0bqd8+/oQtuvMlQvPT7Iw4 iOWldVK3Gzxz4MGAg0AYGRLa5WBTB28vN/Ofo= 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=olbDJB3S+bdQ1rHPM1o42dCtHB3e0ATdib9atqJ3CH0=; b=bSOEKsyGxZyCzMT2MuIHD2WX0xwhy/xkoGx5bhOns/JNZE8QVB3Ac2BQa4ZbrYM3EU JEI6tDnpiHRiXHSOsCb6SzV95OOH2ziQdzOG0o9GeO+UHoyQDEGV1y60lRXFC0lAfFz+ p1Yyh8gNuVsjhssNX0kprYF97NTtULQk2h29tUw6JVx3lpiHccI+G+Gq72y+k+vku+k4 tg+lr5CZOSn/ukQc4ptWqQ+1iU0wjPR3JZf4YPHjZpJiREA/JLYgmxOIUjARdoD7Yna+ W+C4M5AVKBP6pmn0dqpIBBv07ZeCe8Wf22Z40e48rVo33Wa8aafMAVBYBODEVrkAiD7d dP9g== X-Gm-Message-State: AGi0Pua2VKotNhL9XT5ngxSSdvbMsa0bJtaU2uuLzfp9bPKcUTpi8Y7V +TOMV7rz6MTeQywaXfCjK2Nt8g== X-Received: by 2002:a17:902:6ac9:: with SMTP id i9mr31679849plt.35.1588108473631; Tue, 28 Apr 2020 14:14:33 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:202:1:24fa:e766:52c9:e3b2]) by smtp.gmail.com with ESMTPSA id 18sm2988202pjf.30.2020.04.28.14.14.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Apr 2020 14:14:33 -0700 (PDT) From: Douglas Anderson To: jason.wessel@windriver.com, daniel.thompson@linaro.org, gregkh@linuxfoundation.org Cc: agross@kernel.org, kgdb-bugreport@lists.sourceforge.net, catalin.marinas@arm.com, linux-serial@vger.kernel.org, sumit.garg@linaro.org, corbet@lwn.net, mingo@redhat.com, will@kernel.org, hpa@zytor.com, tglx@linutronix.de, frowand.list@gmail.com, bp@alien8.de, bjorn.andersson@linaro.org, jslaby@suse.com, Douglas Anderson , Russell King , linux-kernel@vger.kernel.org Subject: [PATCH v3 11/11] serial: amba-pl011: Support kgdboc_earlycon Date: Tue, 28 Apr 2020 14:13:51 -0700 Message-Id: <20200428141218.v3.11.I8ee0811f0e0816dd8bfe7f2f5540b3dba074fae8@changeid> X-Mailer: git-send-email 2.26.2.303.gf8c07b1a785-goog In-Reply-To: <20200428211351.85055-1-dianders@chromium.org> References: <20200428211351.85055-1-dianders@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sumit Garg Implement the read() function in the early console driver. With recently added kgdboc_earlycon feature, this allows you to use kgdb to debug fairly early into the system boot. We only bother implementing this if polling is enabled since kgdb can't be enabled without that. Signed-off-by: Sumit Garg Reviewed-by: Douglas Anderson Reviewed-by: Daniel Thompson Signed-off-by: Douglas Anderson --- Changes in v3: - ("serial: amba-pl011: Support kgdboc_earlycon") pulled into my v3. - Renamed earlycon_kgdboc to kgdboc_earlycon. Changes in v2: None drivers/tty/serial/amba-pl011.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c index 2296bb0f9578..c010f639298d 100644 --- a/drivers/tty/serial/amba-pl011.c +++ b/drivers/tty/serial/amba-pl011.c @@ -2435,6 +2435,37 @@ static void pl011_early_write(struct console *con, const char *s, unsigned n) uart_console_write(&dev->port, s, n, pl011_putc); } +#ifdef CONFIG_CONSOLE_POLL +static int pl011_getc(struct uart_port *port) +{ + if (readl(port->membase + UART01x_FR) & UART01x_FR_RXFE) + return NO_POLL_CHAR; + + if (port->iotype == UPIO_MEM32) + return readl(port->membase + UART01x_DR); + else + return readb(port->membase + UART01x_DR); +} + +static int pl011_early_read(struct console *con, char *s, unsigned int n) +{ + struct earlycon_device *dev = con->data; + int ch, num_read = 0; + + while (num_read < n) { + ch = pl011_getc(&dev->port); + if (ch == NO_POLL_CHAR) + break; + + s[num_read++] = ch; + } + + return num_read; +} +#else +#define pl011_early_read NULL +#endif + /* * On non-ACPI systems, earlycon is enabled by specifying * "earlycon=pl011,
" on the kernel command line. @@ -2454,6 +2485,7 @@ static int __init pl011_early_console_setup(struct earlycon_device *device, return -ENODEV; device->con->write = pl011_early_write; + device->con->read = pl011_early_read; return 0; } -- 2.26.2.303.gf8c07b1a785-goog