Message ID | 20221116162152.193147-9-john.ogness@linutronix.de |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp232519wru; Wed, 16 Nov 2022 08:23:51 -0800 (PST) X-Google-Smtp-Source: AA0mqf5W5xEiCILYmiLakhaApEq35MciE+GhM75y2OZZDUhBgu9OybUtNeCe4NIJwdkkiLj4VWgI X-Received: by 2002:a63:c116:0:b0:46a:e818:b622 with SMTP id w22-20020a63c116000000b0046ae818b622mr20944823pgf.550.1668615831266; Wed, 16 Nov 2022 08:23:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668615831; cv=none; d=google.com; s=arc-20160816; b=oO/6RCMjlD0ZV3aXBYEMaNVm94HRWlRROzqiTlV3PGq6OE2g/ZSVuCpe2j8noxrMqK /Fm2tGQEO1jVDN701fpbvzXZPI6KmuvYWb3rxDiA1ndlqNskdVcajbjzjoW/LY+Aso2I ynPz+TH8ej5HTp96YB0mMKx2eHQF+sikuZoTeWtBN6ogF2Y9uH9TM+PQhjapjBpIjxQh wxZvaKJPHjlBuFsNy8X2/outnLUjfUkDCoFB68ru13ceGN1LA1EIe1wBfLHSkW4oPXxR 11mRvkMgVJUgPNiU4W3S1WjUdlSSgaf+qXEwFj7NoTlslUph7jvKeGygyyHyKvgMBGYQ U45A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:dkim-signature :dkim-signature:from; bh=OX8P8PjcP3et+B8RxGuAu/qJSUE13puFYmEXVzvc8MY=; b=jKUuN47lB3TgbSmijr4TrLw280L2BSFKMVHdfdo82bptMg17HZuIhF8bVSfhtwgY4f AGsfW0cfuRAb5a45+PuiGma1ewrGLW14H5QrSVm7/K5IFuDQTU8qg+3u+nkB5W8LlNjD 8ftjYBL/YEYAu5k4Q+aYRooJrq1U0yQEQq6TRtRS5JW4j7ig8SgIAYgbEesXXv31h5eK R6BVanIvasXecpwJ2/+iargUqq20qpd3NuDUsLS+Rt5rVTGJbtUiIarsA/9cByIb7Dda hA00/hi7U96rDubETG1YEj465YiwjqXtMY7vyKkL7skOwputO+oTXqRemzc62piSlH3f /fqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=CEddAbi3; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c4-20020a170903234400b00172c1c6abc1si17941407plh.172.2022.11.16.08.23.34; Wed, 16 Nov 2022 08:23:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=CEddAbi3; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234908AbiKPQWl (ORCPT <rfc822;just.gull.subs@gmail.com> + 99 others); Wed, 16 Nov 2022 11:22:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58636 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233536AbiKPQWE (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 16 Nov 2022 11:22:04 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 60F56326F5; Wed, 16 Nov 2022 08:22:03 -0800 (PST) From: John Ogness <john.ogness@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1668615721; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=OX8P8PjcP3et+B8RxGuAu/qJSUE13puFYmEXVzvc8MY=; b=CEddAbi3RzraEuQWrV50K39HBCaBs5n1hbnWKQvKdxtvYvNn7qth0mD3hPQU/k5IM6/6jI tsakH1BSYxyMEWSQ+SYJ0ZbSLVzyVLLN6/OuY208TtKzgXC6M7StlhGoOqITVvqEeeSE2M X8Is4GU+dlc+eKJOSLahx8apQ/7CBFU4io8nbjAZNv2xNFB/IGOy7i8ahbNIx2TlwkTdyz ibPl1VaO0F9fOd8M9cClH3/bgDQIBr7zIZlGTmpNxRMFTCwefsc+Ksw5eBzns2iBBhnSdp K1UNeEN6Iqb9zCaC3+k2B4ePn7UMXh2KRldr715r7YqNpg/80ijcaDxMTepW6w== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1668615721; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=OX8P8PjcP3et+B8RxGuAu/qJSUE13puFYmEXVzvc8MY=; b=wWUGVs3m5zf238cl2T7E7PtRK7QDcJHWNVj1NK/JvMgbbu2/yMeyvExDpCJ6+ELC+PGYAH BBDa/hEaxQ3F/JAw== To: Petr Mladek <pmladek@suse.com> Cc: Sergey Senozhatsky <senozhatsky@chromium.org>, Steven Rostedt <rostedt@goodmis.org>, Thomas Gleixner <tglx@linutronix.de>, linux-kernel@vger.kernel.org, Jason Wessel <jason.wessel@windriver.com>, Daniel Thompson <daniel.thompson@linaro.org>, Douglas Anderson <dianders@chromium.org>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Jiri Slaby <jirislaby@kernel.org>, kgdb-bugreport@lists.sourceforge.net, linux-serial@vger.kernel.org Subject: [PATCH printk v5 08/40] tty: serial: kgdboc: document console_lock usage Date: Wed, 16 Nov 2022 17:27:20 +0106 Message-Id: <20221116162152.193147-9-john.ogness@linutronix.de> In-Reply-To: <20221116162152.193147-1-john.ogness@linutronix.de> References: <20221116162152.193147-1-john.ogness@linutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,INVALID_DATE_TZ_ABSURD, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749670513950750858?= X-GMAIL-MSGID: =?utf-8?q?1749670513950750858?= |
Series |
reduce console_lock scope
|
|
Commit Message
John Ogness
Nov. 16, 2022, 4:21 p.m. UTC
kgdboc_earlycon_init() uses the console_lock to ensure that no consoles are unregistered until the kgdboc_earlycon is setup. This is necessary because the trapping of the exit() callback assumes that the exit() callback is not called before the trap is setup. Explicitly document this non-typical console_lock usage. Signed-off-by: John Ogness <john.ogness@linutronix.de> Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Reviewed-by: Douglas Anderson <dianders@chromium.org> Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org> Reviewed-by: Petr Mladek <pmladek@suse.com> --- drivers/tty/serial/kgdboc.c | 8 ++++++++ 1 file changed, 8 insertions(+)
diff --git a/drivers/tty/serial/kgdboc.c b/drivers/tty/serial/kgdboc.c index e76f0186c335..5be381003e58 100644 --- a/drivers/tty/serial/kgdboc.c +++ b/drivers/tty/serial/kgdboc.c @@ -530,6 +530,14 @@ static int __init kgdboc_earlycon_init(char *opt) * Look for a matching console, or if the name was left blank just * pick the first one we find. */ + + /* + * Hold the console_lock to guarantee that no consoles are + * unregistered until the kgdboc_earlycon setup is complete. + * Trapping the exit() callback relies on exit() not being + * called until the trap is setup. This also allows safe + * traversal of the console list and race-free reading of @flags. + */ console_lock(); for_each_console(con) { if (con->write && con->read &&