Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp4589117ybz; Tue, 28 Apr 2020 14:17:39 -0700 (PDT) X-Google-Smtp-Source: APiQypK0lQV/1KYsJzY9SEoodDo63jIcaSfNm9hFG7/pNxD/t3b2wJ675tVa7DQNpRbQ/B7Q8ViY X-Received: by 2002:a05:6402:204b:: with SMTP id bc11mr23850302edb.114.1588108659071; Tue, 28 Apr 2020 14:17:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588108659; cv=none; d=google.com; s=arc-20160816; b=hdQr0CjbqGEZD7mL69yqfhoToIwf+Z9Ytrb8Fk1TdX+Apk1eISyByMi75V+q7/LnpE J6w6IaIihnAPL7GDdHu5nGZhk0YMcng9116mmiVatU2SbctzZZntTYoN/CcLpL/i8Bip Q/rY71rg+DiOrfZqPpVnymePRnu1hBpurymA7YMH5sFoWhuootRzhFSGg34KdyfhY6Xg fg88vN821GYNhaNQ4ntbqfeimzM84YDkv0Qs259uTGvYdCmxpQ4RmfD/oQj8He9N5qEV Mu2efrJWzF9j2VKTIiEbcrllRXvEpGRB4uBaYnGLiPyOy6UHLIMeV9cXVBqcre5LGZk7 v0vQ== 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=/OLrWf8x1qLHrBr/Q6vF9daUHKkS3VqdNLwPQBuWJDU=; b=wTocnRC8QEh4RltrJtBk+/2t7U2KdI7UIycGr2pXb7Itu8VWUnDjBSjKREI9rf5RuN y5KOPAxaJZ2k6l+04aLnjWj9diIcgrFrB9AGGH+H1jdZgFvQhiqcjVzEeNdBGJYG3xNw w9W1MgVkkn3mC6FWy0PMRyBo83+97u/GLZpF3cm92LFzde2t7aBjeIJ3uQnlh8Z+9BAA t32rUhCCqekdUYdxRMYEaeIs4wVJ/lekVgiBD46ZLU72dW3d7pzXuFCStXtbKC1Wcr+4 UTlmvtjY4TG45KGvP02azlty3TC+MbZAFGNRp9NILn0HZKvazW+0jjCAEEA3knMxI6wa xfww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=ceR7s4QL; 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 c9si2246391edt.576.2020.04.28.14.17.14; Tue, 28 Apr 2020 14:17:39 -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=ceR7s4QL; 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 S1726697AbgD1VOu (ORCPT + 99 others); Tue, 28 Apr 2020 17:14:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41144 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726847AbgD1VOb (ORCPT ); Tue, 28 Apr 2020 17:14:31 -0400 Received: from mail-pl1-x644.google.com (mail-pl1-x644.google.com [IPv6:2607:f8b0:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B32DC03C1AD for ; Tue, 28 Apr 2020 14:14:31 -0700 (PDT) Received: by mail-pl1-x644.google.com with SMTP id u22so1161539plq.12 for ; Tue, 28 Apr 2020 14:14:31 -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=/OLrWf8x1qLHrBr/Q6vF9daUHKkS3VqdNLwPQBuWJDU=; b=ceR7s4QLjCxcwBopolOS/b+gt1XS1V44hpA4RaLu3U7xz4gbiad0ZwvuUfq2zoDgWW LUxBaQE0WU7cVAqQaq42UbdsZLHipbJutBdwwdZhBMU9LwbKFUAMsXICh1j8qxyF2HLT XNOSxdPCyaFKmbg5uLtxCtuq/CZhkE8K72skM= 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=/OLrWf8x1qLHrBr/Q6vF9daUHKkS3VqdNLwPQBuWJDU=; b=b3cKvcy3t3+ucN2LxMoBwf/IS9RLc/h2KDcSFZLreo06/SWHVSr0EaSJgb7RS0XwQ9 d2HTQ6YNIVGrMeOhslgLCsHF4u+GvJARVj4fDN/3SGx4JNhZWs6S41SDRekGnPmVDxkK 4XcnHyvjXRv6k9c6Jq/gl8dscc7KJf3fDqsHXI7c4KVu6i/qXsDCS11TWxamVTwau2EQ mUuqQIy3cVIZQhaBYx+ylgAtoiM8/TutNVc5ob9sNnfbZZjIV6mtxxEk3mGgTUSIUcs0 F2ragOJWpntU84FqOLsfnZ1ZAUV1nxxIpfMVt6IqqEFs7LhTd2Bo7D+wvyKCyJEgq59d uFAQ== X-Gm-Message-State: AGi0PuZ9b2MD29yPL2K7AVe91UqmqxOy/s4cpqZpsKvMSS95FJAcJq4J MWH4Pa0ogP2qF9FJ3lBhrFrWHw== X-Received: by 2002:a17:902:904a:: with SMTP id w10mr16025829plz.17.1588108471172; Tue, 28 Apr 2020 14:14:31 -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.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Apr 2020 14:14:30 -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-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 09/11] serial: qcom_geni_serial: Support kgdboc_earlycon Date: Tue, 28 Apr 2020 14:13:49 -0700 Message-Id: <20200428141218.v3.9.If2deff9679a62c1ce1b8f2558a8635dc837adf8c@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 --- Changes in v3: - Renamed earlycon_kgdboc to kgdboc_earlycon. - { ; } ==> { } 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..6bace1c6bb09 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.2.303.gf8c07b1a785-goog