Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp1034558ybj; Thu, 7 May 2020 13:14:21 -0700 (PDT) X-Google-Smtp-Source: APiQypKSV84c2B9odchQK43Bh248x4x0NwSqMS17Bii7+utMvzDsed7msVTiy10wbEOAe0kxCDOE X-Received: by 2002:a17:906:1690:: with SMTP id s16mr12829202ejd.339.1588882460960; Thu, 07 May 2020 13:14:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588882460; cv=none; d=google.com; s=arc-20160816; b=uqd/yn8wLw7AppDbd2UdcVawnV216RRqa4OLG6vQao6phYU662ATGf4vl4I8MV5+KJ wERtIPi3TLeL1ENQ1uj/Y4lSYwJn4PPYd/YMDonAQEpbQaZl2cVCsH2qp0NtI+eBAzhM Lb1VV1AJQhCvRkNkCkm4sKJcJHghZ7IL9/42TA7IFft+1RwhAIQkinx3ngpEfHMwhUJc GBGLgJyz1/NRCFis540w07Asykm8D1tCLx1wGliRoqKeFGvGY5QnyLq45G9RBM6gAd3n HKMTBJGBbzJeurn0xLMAv0nTCQcBQqrbfYVx3mDS5RiIKQm+SNrXEDdz7ugWjInmdIJ1 ywyw== 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=bnBeK10KzsaeyDFO2398m9/Skswi+j6FYU/gKr10cks=; b=AYE0S0j2qhJ9spPnZX1q1jjWDAiW0rOM2omr6C0RPybvQa5ftKWsTmqGi8GFH2gcHp g/Y44TJmWUFaUUojzhZNcQfbZgTTkAzFkn7EA1IYlQPJV8GaUyF9+rjFNZvcKvSOStnp 9WCfUTK0XQeQ6w3h6MuxQ0ZIXDC85Vo47YZhLoiRonF5woomwBjFzpOrrOaDcKjMstfW iXTJwarcud9z0a1Nfe4NfrYfaEW6B/QdX6yEPhxj42tuHJESgBzXdTtc4hX2CeJrHxLk nh5jsAZgUlL2KjcKea/AgjX1R8xO1/zPTI28tSbNh8BY4Tl+gWEgLMqrZ84Mjg7uYK48 vZQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=GzcY94Ld; 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 x17si3936876edi.409.2020.05.07.13.13.58; Thu, 07 May 2020 13:14:20 -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=GzcY94Ld; 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 S1728737AbgEGUJc (ORCPT + 99 others); Thu, 7 May 2020 16:09:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1728685AbgEGUJR (ORCPT ); Thu, 7 May 2020 16:09:17 -0400 Received: from mail-pj1-x1044.google.com (mail-pj1-x1044.google.com [IPv6:2607:f8b0:4864:20::1044]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E2FD4C05BD09 for ; Thu, 7 May 2020 13:09:16 -0700 (PDT) Received: by mail-pj1-x1044.google.com with SMTP id e6so3123838pjt.4 for ; Thu, 07 May 2020 13:09:16 -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=bnBeK10KzsaeyDFO2398m9/Skswi+j6FYU/gKr10cks=; b=GzcY94LdE0hSxHNb2Ie4O6ZGy7FUnmfrizHDOWnagUu/3DoRcnlASU4EtxJamQJf5n YInSK43rqVxNgmqEJyLE1V8uoQuK711LrzZzl6Jy+DwiB3USC73zDvfsnly8sf5RE3MO gJ0PUw1ZkSRig2z0wZbVSdLbZCRY0xEmG2+0A= 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=bnBeK10KzsaeyDFO2398m9/Skswi+j6FYU/gKr10cks=; b=kIQ86yp9uJX/eSM40osqymwBNXjLFdwiHPpdHHKrynkwvDTdJ+9ibN/sQuu0ykonxV qwEF5JjNaWKvKQ/Qqilwxu438PxQzX0rp0ppPlBLnFhKx+rsNkcZ1pa/W9ik1AgiYfmq PrmMEoqAi+fm3IJ+td3pWXNqkxLUdLOGXoE48JqADSDyLalzDoLtBmErHpfhBSRri2Ts o43GEMk436MDZJjVadIOb0rLv6uIbeEymXTO+woND5cuXs5QYSHKMIZo3NE3VSV5tW8D rOo1XrWCe7F+1AhQsXNlWs88V8BAjbyACKTC4wv+WRMm1EI5yXF0oUZpd6WXj2jkZiSw G/xg== X-Gm-Message-State: AGi0PuZVsTdBY4iMozKrV5ybrp9901/KrSCwRBuYxwoD1JdOQ7NSjf2u Y23COxOLZbzVL5gv5r17BMsA2g== X-Received: by 2002:a17:902:dc84:: with SMTP id n4mr14949596pld.281.1588882156436; Thu, 07 May 2020 13:09:16 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:202:1:24fa:e766:52c9:e3b2]) by smtp.gmail.com with ESMTPSA id d203sm5547601pfd.79.2020.05.07.13.09.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 May 2020 13:09:15 -0700 (PDT) From: Douglas Anderson To: jason.wessel@windriver.com, daniel.thompson@linaro.org, gregkh@linuxfoundation.org Cc: corbet@lwn.net, frowand.list@gmail.com, bjorn.andersson@linaro.org, linux-serial@vger.kernel.org, mingo@redhat.com, hpa@zytor.com, jslaby@suse.com, kgdb-bugreport@lists.sourceforge.net, sumit.garg@linaro.org, will@kernel.org, tglx@linutronix.de, agross@kernel.org, catalin.marinas@arm.com, bp@alien8.de, Douglas Anderson , Russell King , linux-kernel@vger.kernel.org Subject: [PATCH v4 12/12] serial: amba-pl011: Support kgdboc_earlycon Date: Thu, 7 May 2020 13:08:50 -0700 Message-Id: <20200507130644.v4.12.I8ee0811f0e0816dd8bfe7f2f5540b3dba074fae8@changeid> X-Mailer: git-send-email 2.26.2.645.ge9eca65c58-goog In-Reply-To: <20200507200850.60646-1-dianders@chromium.org> References: <20200507200850.60646-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 v4: None 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.645.ge9eca65c58-goog