Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp4588583ybz; Tue, 28 Apr 2020 14:17:00 -0700 (PDT) X-Google-Smtp-Source: APiQypLyrSig9p76g3dP1Gd7der04Akaid9zbiCUoMwHSwOVfH+H6Yx1PrGE0ZnWM5I1fTNp4Cd4 X-Received: by 2002:a17:906:d0da:: with SMTP id bq26mr25708131ejb.344.1588108620486; Tue, 28 Apr 2020 14:17:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588108620; cv=none; d=google.com; s=arc-20160816; b=iWkMIGwEGId/hcN2oBZS4q+G8Pub4z8EXC16YhLhO5CoGCWHo7rSnqAWUiDNCwFM1U UCaOBb0JEAKt4R7c5ls+dgluxH9ZhA6AaUDruwhEPXsACWnVvsmstref2KxigN3331Uh Qxzg+ZuS+t6WNLDG46WknFsBrr+0AE+wCQh2USML2RveZV9D8YyMbHedVKLMEZxQ7JHq oxrXhlJ2LwIz1mWTAfwrJ1L6hOaw13DqNng8vxWs/ZAi4zQt9c+kItP2pzu+nLkNMpL5 yye+KQip3AmJB6526L9Dcy7Ce3J3WGq3mRuUWp0TyamCVM7KYGTxGQvghNou/lyW8IOl MxSg== 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=4oGO5v8y9nak8k9DrQPglFtrPLstpeIPrguWZ4LmKLk=; b=zkkDSPRWt5M9sTAbeSX/jKlxdJqdoPj5dUQsRYAbXaat/Nxx3pLWpEcaTm3d4TI/Nv P6fJjT4BN0P5CGnFyQu35oghbYeAR0WgvJqJI/5yHGBF0HbzUt2MUEw7Ny1HJEWo/UkV C+QoIHdPbV//0ZoQq9Gyz+Tjt+fAcCwdOk6F2wVfkhoouE9Wt6pVZWvMB8XrOvAtcOgx 23RKREE0Fv782kzR1fgUcYKdksjBwmo3IVp++JCAW/TFB6URQAftF8JSexr4ypD8VXC/ 0Av6kocziBUdOFUP0yJqT5VTuy2FdnpvhNOVfnJJhWjUaoVjeZ9pNuorw9Itilp3VljT +e9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="lC/o9/g0"; 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 ox16si2726549ejb.427.2020.04.28.14.16.33; Tue, 28 Apr 2020 14:17:00 -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="lC/o9/g0"; 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 S1726948AbgD1VOq (ORCPT + 99 others); Tue, 28 Apr 2020 17:14:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41154 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726850AbgD1VOd (ORCPT ); Tue, 28 Apr 2020 17:14:33 -0400 Received: from mail-pj1-x1041.google.com (mail-pj1-x1041.google.com [IPv6:2607:f8b0:4864:20::1041]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D670AC03C1AC for ; Tue, 28 Apr 2020 14:14:32 -0700 (PDT) Received: by mail-pj1-x1041.google.com with SMTP id mq3so61704pjb.1 for ; Tue, 28 Apr 2020 14:14:32 -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=4oGO5v8y9nak8k9DrQPglFtrPLstpeIPrguWZ4LmKLk=; b=lC/o9/g0QvPZPmlrzukJy8za454JFvMQ6cfQQiPCvEmJqP5U7RtcGoNEEmRqQ2yyve +ZhWGOuIAj/7XknaXTCzgBgpD/pS6Zwjx/MibXjHKLZBX/Sl5fdjL9PZrqow6aRDfNPH OUPD0gdA3c10zoXT8G662DiHJbzogg3+7fv+M= 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=4oGO5v8y9nak8k9DrQPglFtrPLstpeIPrguWZ4LmKLk=; b=RE3wMSw2HfrslokKTqHdm7yyA+7MPNkzIjdj+88L7Rh7GAiTI55zmLNZ4p6xnydyge xZfkXT8bNJR0xFjZi5uTFD7FO0pCXnXUL1C8gpBtOFrUaNnqG4xSjY/G01KtRqWbQeWt HTo2MxxfRM7/SIcxw3P0StpEVRtCLlsSxNYr24RbWzy0+BO3IWIfdDUEEWu4e3H9GJK7 4jqKd2NojvPBU124zswmPzQ+9ZiJ62TBNGlkhl3QDcT7ldblnDQnHP6wL9yeu4fOb2eV scUo4AwKo/SP1Dt7QhsXZkWYdBb4GHrUzeK1s0FTWaFIOASprFwe3JmqLiWGK3nSDkim oRGA== X-Gm-Message-State: AGi0PuZGH78FuavliDRiPPcish6aKlYxmy++f5Oo+Qu8l5CAnVmbGHeA XQ9YhbzXAs/XI6hYNqhRMfj7HQ== X-Received: by 2002:a17:902:784c:: with SMTP id e12mr30329731pln.191.1588108472393; Tue, 28 Apr 2020 14:14:32 -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.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Apr 2020 14:14:32 -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 , linux-kernel@vger.kernel.org Subject: [PATCH v3 10/11] serial: 8250_early: Support kgdboc_earlycon Date: Tue, 28 Apr 2020 14:13:50 -0700 Message-Id: <20200428141218.v3.10.I8f668556c244776523320a95b09373a86eda11b7@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 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 Reviewed-by: Greg Kroah-Hartman Reviewed-by: Daniel Thompson --- Changes in v3: - Renamed earlycon_kgdboc to kgdboc_earlycon. Changes in v2: None drivers/tty/serial/8250/8250_early.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/drivers/tty/serial/8250/8250_early.c b/drivers/tty/serial/8250/8250_early.c index 5cd8c36c8fcc..70d7826788f5 100644 --- a/drivers/tty/serial/8250/8250_early.c +++ b/drivers/tty/serial/8250/8250_early.c @@ -109,6 +109,28 @@ static void early_serial8250_write(struct console *console, uart_console_write(port, s, count, serial_putc); } +#ifdef CONFIG_CONSOLE_POLL +static int early_serial8250_read(struct console *console, + char *s, unsigned int count) +{ + struct earlycon_device *device = console->data; + struct uart_port *port = &device->port; + unsigned int status; + int num_read = 0; + + while (num_read < count) { + status = serial8250_early_in(port, UART_LSR); + if (!(status & UART_LSR_DR)) + break; + s[num_read++] = serial8250_early_in(port, UART_RX); + } + + return num_read; +} +#else +#define early_serial8250_read NULL +#endif + static void __init init_port(struct earlycon_device *device) { struct uart_port *port = &device->port; @@ -149,6 +171,7 @@ int __init early_serial8250_setup(struct earlycon_device *device, init_port(device); device->con->write = early_serial8250_write; + device->con->read = early_serial8250_read; return 0; } EARLYCON_DECLARE(uart8250, early_serial8250_setup); -- 2.26.2.303.gf8c07b1a785-goog