Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp19783ybz; Tue, 21 Apr 2020 14:17:06 -0700 (PDT) X-Google-Smtp-Source: APiQypJe0Lwaq7EWxObIZAuULUdn8KE7QZNDoL6Ie/pJmgCCgfOOIzNoo9d37ZKRS9L7ztQp/v43 X-Received: by 2002:a17:906:48c:: with SMTP id f12mr23642148eja.93.1587503826286; Tue, 21 Apr 2020 14:17:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587503826; cv=none; d=google.com; s=arc-20160816; b=u1eb0s28P3dgA8H3SHirMOKCHie9RdVNbqS2Am52TxyIAn7RTK0ZL06FToBanHx/CW 38iraT2/upqxHDiS72+dsDcd07ooJlGYLNfMUtV0TAc5H6ieZj3U89WlXA8zIucYQwrg 8kLYhc4QX/T3M+G0+cgIGK1Wqae7YKXxwSXtOwRuukJAnigNCCSAARTqvwVj+SwX6VC3 ttV3UhWyP7rAMVqnE/q4UrA62+MWeTQWtiX+5+k2mYvkcIjpJYyKVQaKbwSHZsZenjrM HYrkAkmGG6DH+VhteDt99HgoUkUPSt4sJoL7DpVAGgpJ5xgywFBkO/O9gc1N5IP+GADq GayA== 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=BjXLxKYx2J4SfneKVn6eyAIDqxc8kteAmWSGrEv3s1Q=; b=Kf8quPIFTcaeYrXCrut2uSjOjlGnxfJfU6u96L0XgmEocqsxwosAIxPm3HN2bxQ4oE hK3QPZGnhpIL7BZ9+n540DjzHrZjoS2QKYcrGxUuvvNmWGv8P9KOzEgk6aHgN8JPY6f1 oap5YTmI+SwUjIL4HN295738QOE1l3WGDPf08gQnl8OBPUCatvglcicMsrKvCNe7LiHg cS4ckVraZ4fAf6Dk46oNixGN/lm6py2U7tLdFIgY7spLIP9Md/m61q5U4TNvGTNB4SHX CwPNofY3u+Cb1XuQD6birdlfUOO2cV6L7OlQoQ3lms8ztX6n2D2L90WaqHzRZQ3F1QPR 1Yvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=CcJCluHY; 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 m5si2261874ejr.155.2020.04.21.14.16.43; Tue, 21 Apr 2020 14:17:06 -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=CcJCluHY; 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 S1726419AbgDUVPf (ORCPT + 99 others); Tue, 21 Apr 2020 17:15:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55186 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726396AbgDUVP3 (ORCPT ); Tue, 21 Apr 2020 17:15:29 -0400 Received: from mail-pf1-x444.google.com (mail-pf1-x444.google.com [IPv6:2607:f8b0:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B58FAC0610D6 for ; Tue, 21 Apr 2020 14:15:29 -0700 (PDT) Received: by mail-pf1-x444.google.com with SMTP id 145so4933726pfw.13 for ; Tue, 21 Apr 2020 14:15:29 -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=BjXLxKYx2J4SfneKVn6eyAIDqxc8kteAmWSGrEv3s1Q=; b=CcJCluHY3oWgCqfj8YhfZKPo0NR/BUu6kAlYc9e5Oewk1f5pCuZN7xV0s8bJRPKSaa jN+bzjxqRaMU7hrDRd5nNyB2ufRcJdE8b+aIVwOlnZcSoBmTm7+6Ka+Hyjdbn8I/xBdB 1FpGO292NE9dv3pw6YfLq20gXxSIurqzigZRk= 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=BjXLxKYx2J4SfneKVn6eyAIDqxc8kteAmWSGrEv3s1Q=; b=VwxvvyiATjiRW369rvHSDtjPrvtqNkEPVG60GIG/5yxWzFMtw7untSga0Gb8uw19ue +YIehu1jpLogrKipeqafdIaQ6fOivOiToFOOHYyCElH4o7+/22osv2anddAXgaXzkoTH O1axl7EzWS0OENIH0hYccekPXWhqimHOi5kLmWDtLEzuqgjD7eL8fWAf1CvvLVpYqbYX EQVmb73Z8JRJJtIgK7pKFKhVQRvqgazyUDRjiS5RB/8rDqF/D1D43JnxND+W+dGK3aSk YwsAlYs1vkMBT9ABLD5Hx3IOI2aePnFp58AMcXudWXjedrAmotA1/SbHnToi8vQjs86+ tROA== X-Gm-Message-State: AGi0PuaYzX/Il4+tUWQvkiSr8dA6iKFfnrwSQzVSv6RRXXDImix0xa5/ 7T2qcgdhxW4cdAcqo3MV5hnAAw== X-Received: by 2002:a63:f14b:: with SMTP id o11mr24165243pgk.429.1587503729162; Tue, 21 Apr 2020 14:15:29 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:202:1:24fa:e766:52c9:e3b2]) by smtp.gmail.com with ESMTPSA id c1sm3287880pfo.152.2020.04.21.14.15.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Apr 2020 14:15:28 -0700 (PDT) From: Douglas Anderson To: jason.wessel@windriver.com, daniel.thompson@linaro.org, gregkh@linuxfoundation.org Cc: kgdb-bugreport@lists.sourceforge.net, mingo@redhat.com, hpa@zytor.com, bp@alien8.de, linux-serial@vger.kernel.org, agross@kernel.org, tglx@linutronix.de, frowand.list@gmail.com, bjorn.andersson@linaro.org, jslaby@suse.com, catalin.marinas@arm.com, corbet@lwn.net, will@kernel.org, Douglas Anderson , linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 8/9] serial: qcom_geni_serial: Support earlycon_kgdboc Date: Tue, 21 Apr 2020 14:14:46 -0700 Message-Id: <20200421141234.v2.8.If2deff9679a62c1ce1b8f2558a8635dc837adf8c@changeid> X-Mailer: git-send-email 2.26.1.301.g55bc3eb7cb9-goog In-Reply-To: <20200421211447.193860-1-dianders@chromium.org> References: <20200421211447.193860-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 Implement the read() function in the early console driver. With recent kgdb patches 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: Douglas Anderson --- Changes in v2: None drivers/tty/serial/qcom_geni_serial.c | 32 +++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/drivers/tty/serial/qcom_geni_serial.c b/drivers/tty/serial/qcom_geni_serial.c index 6119090ce045..4563d152b39e 100644 --- a/drivers/tty/serial/qcom_geni_serial.c +++ b/drivers/tty/serial/qcom_geni_serial.c @@ -1090,6 +1090,36 @@ static void qcom_geni_serial_earlycon_write(struct console *con, __qcom_geni_serial_console_write(&dev->port, s, n); } +#ifdef CONFIG_CONSOLE_POLL +static int qcom_geni_serial_earlycon_read(struct console *con, + char *s, unsigned int n) +{ + struct earlycon_device *dev = con->data; + struct uart_port *uport = &dev->port; + int num_read = 0; + int ch; + + while (num_read < n) { + ch = qcom_geni_serial_get_char(uport); + if (ch == NO_POLL_CHAR) + break; + s[num_read++] = ch; + } + + return num_read; +} + +static void __init qcom_geni_serial_enable_early_read(struct geni_se *se, + struct console *con) +{ + geni_se_setup_s_cmd(se, UART_START_READ, 0); + con->read = qcom_geni_serial_earlycon_read; +} +#else +static inline void qcom_geni_serial_enable_early_read(struct geni_se *se, + struct console *con) { ; } +#endif + static int __init qcom_geni_serial_earlycon_setup(struct earlycon_device *dev, const char *opt) { @@ -1136,6 +1166,8 @@ static int __init qcom_geni_serial_earlycon_setup(struct earlycon_device *dev, dev->con->write = qcom_geni_serial_earlycon_write; dev->con->setup = NULL; + qcom_geni_serial_enable_early_read(&se, dev->con); + return 0; } OF_EARLYCON_DECLARE(qcom_geni, "qcom,geni-debug-uart", -- 2.26.1.301.g55bc3eb7cb9-goog