From patchwork Thu Mar 16 20:20:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 13178298 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AD9EFC7618E for ; Thu, 16 Mar 2023 20:21:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230250AbjCPUVY (ORCPT ); Thu, 16 Mar 2023 16:21:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51810 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229841AbjCPUVW (ORCPT ); Thu, 16 Mar 2023 16:21:22 -0400 Received: from mail-pj1-x102a.google.com (mail-pj1-x102a.google.com [IPv6:2607:f8b0:4864:20::102a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 694BBC4899 for ; Thu, 16 Mar 2023 13:21:21 -0700 (PDT) Received: by mail-pj1-x102a.google.com with SMTP id lr16-20020a17090b4b9000b0023f187954acso2801570pjb.2 for ; Thu, 16 Mar 2023 13:21:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1678998081; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=g57LqyNVPd4QtvwDpadq5p0zhAPNVIWZbBGClF8fQN4=; b=TibbCxbyBEZEYx/uzkmczi2osDWuyysnFNb7UXs3hCFZQtiCLHPDBLo+h0TaUIqtSS LXN+A7+bVvfxR3164Co4ZTPPvbcvJHJD6RwZamz7cg69L8SZXrOluqktWQwOCjLyhsL1 VmUKIBoqTGOaQ3RiLfTTD6lsheEfjtiptn5bo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678998081; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=g57LqyNVPd4QtvwDpadq5p0zhAPNVIWZbBGClF8fQN4=; b=vbJl1D/TGqeRzX4SdbrVjPBd9RytmbhjB1n0QmCpTGkBy2P72l4Gcpyoo5KkDe8NNe dt4NhFW03X7CCmbT0fK5qcMmR584ERxmCaek+23PQSjjfNAXj5EAb8TXDx//hqSEX2iV lyR8RNXw9R4JdbeVqFzS1ZfFVV1JTyqrzlQfk7EXYmm2hb4/3j4PUhsbya9ExZ8fcBFR DlVBEnt0/z/Qbh+2tWViA1UHR1enIjTo4ruoHS2i9PhcaqwEoAZqbZW7tA5SuYYIn192 vMH/XQGGnMmsB+REItIkV5nnOT5cAOVt7B3Qdw/ZLbH5bEv9WVKQCe4R/FymSbS0Ixs9 875g== X-Gm-Message-State: AO0yUKWvLfZzeptMOu76Y1whJ+Jl6t0bU3Ul23N64g12amqkZgOAWJuO 0ehK27oElA6/2TRPchz5YVJccw== X-Google-Smtp-Source: AK7set9yCaDngXDzLHihTbNxF3zv4vAS5iqalhbZOQqV0PyRM1ANGSN9XbnsR7tHimYz7WJ9Kc71Dw== X-Received: by 2002:a17:90a:1903:b0:233:76bd:9faa with SMTP id 3-20020a17090a190300b0023376bd9faamr5352705pjg.47.1678998080936; Thu, 16 Mar 2023 13:21:20 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:9d:2:4db6:6f23:6ad2:998d]) by smtp.gmail.com with ESMTPSA id b4-20020a17090a5a0400b0023acdac248dsm24114pjd.15.2023.03.16.13.21.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Mar 2023 13:21:20 -0700 (PDT) From: Douglas Anderson To: Bjorn Andersson , Greg Kroah-Hartman Cc: linux-arm-msm@vger.kernel.org, Jiri Slaby , Bartosz Golaszewski , Daniel Thompson , kgdb-bugreport@lists.sourceforge.net, Konrad Dybcio , linux-serial@vger.kernel.org, Douglas Anderson , linux-kernel@vger.kernel.org Subject: [RESEND PATCH 1/2] serial: uart_poll_init() should power on the UART Date: Thu, 16 Mar 2023 13:20:56 -0700 Message-Id: <20230316132027.RESEND.1.I106c39498d8094c6f5e7ada42c7db17aa5c64e48@changeid> X-Mailer: git-send-email 2.40.0.rc1.284.g88254d51c5-goog In-Reply-To: <20230316202057.4070382-1-dianders@chromium.org> References: <20230316202057.4070382-1-dianders@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org On Qualcomm devices which use the "geni" serial driver, kdb/kgdb won't be very happy if you use it but the resources of the port haven't been powered on. Today kdb/kgdb rely on someone else powering the port on. This could be the normal kernel console or an agetty running. Let's fix this to explicitly power things on when setting up a polling driver. Signed-off-by: Douglas Anderson --- drivers/tty/serial/serial_core.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index 2bd32c8ece39..b14b5ed6fff4 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -2593,6 +2593,7 @@ static int uart_poll_init(struct tty_driver *driver, int line, char *options) { struct uart_driver *drv = driver->driver_state; struct uart_state *state = drv->state + line; + enum uart_pm_state pm_state; struct tty_port *tport; struct uart_port *port; int baud = 9600; @@ -2610,6 +2611,9 @@ static int uart_poll_init(struct tty_driver *driver, int line, char *options) goto out; } + pm_state = state->pm_state; + uart_change_pm(state, UART_PM_STATE_ON); + if (port->ops->poll_init) { /* * We don't set initialized as we only initialized the hw, @@ -2626,6 +2630,8 @@ static int uart_poll_init(struct tty_driver *driver, int line, char *options) console_list_unlock(); } out: + if (ret) + uart_change_pm(state, pm_state); mutex_unlock(&tport->mutex); return ret; } From patchwork Thu Mar 16 20:20:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 13178299 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 130D5C7618A for ; Thu, 16 Mar 2023 20:21:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230335AbjCPUVb (ORCPT ); Thu, 16 Mar 2023 16:21:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51900 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230285AbjCPUVZ (ORCPT ); Thu, 16 Mar 2023 16:21:25 -0400 Received: from mail-pl1-x635.google.com (mail-pl1-x635.google.com [IPv6:2607:f8b0:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5429E7E89F for ; Thu, 16 Mar 2023 13:21:23 -0700 (PDT) Received: by mail-pl1-x635.google.com with SMTP id i5so3057736pla.2 for ; Thu, 16 Mar 2023 13:21:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1678998083; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=R7uYBq/r2MM26gN/T+YojigH2qsAcwEwpy934F/qkEQ=; b=BJIzhXdI1s5gzEG0m+7jSYgDrDB2Cv3jwayVk4kqbzV9tbFk9R3GGCEwVuyfc6mlrD KpM3I806ejLxxNf4tfemT2g38pET3WVqkOcawWyOrA/AXqin5PDGFZ6+htFTWvwHtO6Y KS6NTWUEKJ8Gpx1hurGHVnAHy/QsDGjxzy9CM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678998083; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=R7uYBq/r2MM26gN/T+YojigH2qsAcwEwpy934F/qkEQ=; b=gO3Xy8lgvHbtHV5FlJrPmPddKGVv36FBJELMsj9TAq2sDGjfirVpUKjOtiFNf/nWxZ luwSzM5gCl9mMOSOemcOiwO5jduPVEB1MLJ6WvkB6K4+fuSC+yRU/nX9xl+ATcUo8XZo BQqBYK++SdeFgVg+KQ831vAnyiu4tMewFwldGAOdM2x51LPaTMsgy7lC0HzKh0JGmmC/ h1DBcfMLXTJpQJU9s8RsnzC7rJHNHahuXmHKmRqgWZOn/MLt9hf6gzMqMoaGarrre8K5 /VCNE/RjUl8/C9GPundzQ3ctIWoJKUbO2aGk7tmyKoouG5/0fRhHrVPlFeYPlAO3yqKc 5CRw== X-Gm-Message-State: AO0yUKVWIUYS5vm0wfm+zsXWBfQS0y9Q2eBvdDJfeQO3ZhShfxgrBOkV A+iv56Sg4cVjQjmWS8HqduoBBA== X-Google-Smtp-Source: AK7set8U+8u0pAReOkw3SQcSNQaY6unkcGqSXoWSlafTmIws3G0+lrdPTp5NRIJ1P1F3tRAnfoo8wQ== X-Received: by 2002:a17:90b:3850:b0:234:118d:b1b1 with SMTP id nl16-20020a17090b385000b00234118db1b1mr4760801pjb.48.1678998082769; Thu, 16 Mar 2023 13:21:22 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:9d:2:4db6:6f23:6ad2:998d]) by smtp.gmail.com with ESMTPSA id b4-20020a17090a5a0400b0023acdac248dsm24114pjd.15.2023.03.16.13.21.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Mar 2023 13:21:22 -0700 (PDT) From: Douglas Anderson To: Bjorn Andersson , Greg Kroah-Hartman Cc: linux-arm-msm@vger.kernel.org, Jiri Slaby , Bartosz Golaszewski , Daniel Thompson , kgdb-bugreport@lists.sourceforge.net, Konrad Dybcio , linux-serial@vger.kernel.org, Douglas Anderson , Andy Gross , linux-kernel@vger.kernel.org Subject: [RESEND PATCH 2/2] tty: serial: qcom-geni-serial: Add a poll_init() function Date: Thu, 16 Mar 2023 13:20:57 -0700 Message-Id: <20230316132027.RESEND.2.Ie678853bb101091afe78cc8c22344bf3ff3aed74@changeid> X-Mailer: git-send-email 2.40.0.rc1.284.g88254d51c5-goog In-Reply-To: <20230316202057.4070382-1-dianders@chromium.org> References: <20230316202057.4070382-1-dianders@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org On sc7180 Chromebooks, I did the following: * Didn't enable earlycon in the kernel command line. * Didn't enable serial console in the kernel command line. * Didn't enable an agetty or any other client of "/dev/ttyMSM0". * Added "kgdboc=ttyMSM0" to the kernel command line. After I did that, I tried to enter kdb with this command over an ssh session: echo g > /proc/sysrq-trigger When I did that the system just hung. Although I thought I'd tested this scenario before, I couldn't go back and find a time when it was working. Previous testing must have relied on either the UART acting as the kernel console or an agetty running. It turns out to be pretty easy to fix: we can just use qcom_geni_serial_port_setup() as the .poll_init() function. This, together with the patch ("serial: uart_poll_init() should power on the UART"), allows the debugger to work even if there are no other users of the serial port. Signed-off-by: Douglas Anderson --- drivers/tty/serial/qcom_geni_serial.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/tty/serial/qcom_geni_serial.c b/drivers/tty/serial/qcom_geni_serial.c index d69592e5e2ec..7fdb3e12846d 100644 --- a/drivers/tty/serial/qcom_geni_serial.c +++ b/drivers/tty/serial/qcom_geni_serial.c @@ -1532,6 +1532,7 @@ static const struct uart_ops qcom_geni_console_pops = { #ifdef CONFIG_CONSOLE_POLL .poll_get_char = qcom_geni_serial_get_char, .poll_put_char = qcom_geni_serial_poll_put_char, + .poll_init = qcom_geni_serial_port_setup, #endif .pm = qcom_geni_serial_pm, };