Message ID | 20221114162932.141883-8-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 l7csp2237842wru; Mon, 14 Nov 2022 08:30:55 -0800 (PST) X-Google-Smtp-Source: AA0mqf7m+5Uzcboh9KOUqjLm0aIgsOzX/7t5/lkf9PhGLQvkfqoWz5c18XoQMWHqA6BlW/8bl681 X-Received: by 2002:a63:486:0:b0:460:e9e5:1b46 with SMTP id 128-20020a630486000000b00460e9e51b46mr12145448pge.391.1668443455305; Mon, 14 Nov 2022 08:30:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668443455; cv=none; d=google.com; s=arc-20160816; b=CtdaQLn+IsnvBRdI45lmq9g6tHee5baxCDd69Lc1J69JiaGBhiPH31OFfzRBQT9GHg hfLFda+Nf5HqAf21yu/zPhq8RmEO0yDjsKangf8BJDc74u2UZHMQiis6vlWeYExRpBLz oe4xrsTz828btP61tuuekPViJ4jJmh47WSVkXFtUOX4ozrPOnAJz2bos09ue1S7Hv30B jxVnYled0mahgR4z84t1HLZ/XZuE8uQYn8fM4A+c0MEac7j5z+apz4UFs93tnTS/9oX7 Czoqfg87sPWWvT32dZHNuuofk4Snrs5fR44f3Bo7gAjl8eVE2z6peitTUyegjodSu45W LDXA== 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=LeM6Jg4jDT+XoXiE8HEnVW0X8xGOduvTHNcubWb/a90HEYdfs+jK45PPnyHAPrOeIW /6r5862qMTWiey92Nn++ZQ/qAYi9hPCVU+PKN28RPTMvfSsA+Tai/h90XIf2fSZjKATp Qzvpo0R90bMVfJCe7d/u3K/43P0PoMprqz1X8gwbCRt77PgGegL31LMvMZ+7WDbbnygI N8mh7CjZ4uUlmRLlmUx93tuGSIIYm5UGJnUpG923nB0MLY9Hgqx3nMHkQ3Hiuq+RoRPN mGWdorNcahSmpiqEWVbdqIAbxFjQkoLCGpI0SPuhTy17HRFKzXZA/hpZ0+f9gzkpZri4 Edrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="07f/Iv1w"; dkim=neutral (no key) header.i=@linutronix.de header.b=tELjjwZ8; 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 b6-20020a170903228600b0016f1eb1317esi10799854plh.471.2022.11.14.08.30.27; Mon, 14 Nov 2022 08:30:55 -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="07f/Iv1w"; dkim=neutral (no key) header.i=@linutronix.de header.b=tELjjwZ8; 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 S237595AbiKNQaF (ORCPT <rfc822;winker.wchi@gmail.com> + 99 others); Mon, 14 Nov 2022 11:30:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35576 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237531AbiKNQ3k (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 14 Nov 2022 11:29:40 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 964EB102C; Mon, 14 Nov 2022 08:29:39 -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=1668443377; 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=07f/Iv1wL9DpAMhdAgc7Xt3WxoplT/3Nu02eKR1b8+j1+Y7qfzi1+FNR+cnpkz+yvo16Ze MBTxlfIFPnOpIaZmaWz8PKDgW1EEFLce5Z7cjkdy6Vz0eKot3ypTtDpD7aXfrOfrZ5b4jX QntAcdes7YddyPfeX5F8PQ8xBH1C/Xmv0UymHEQmXC9tX8u9cMQ0818P0ky0qz/V24Ia2u 6PtsU3Op8WIIueIM9CeNFqHhD5rmh6U9hltEKu6vOewN2wBbCliUb2DS6q5csf2Eu5FEkm eEGxJwFLBff19l0CYvNQu8UBltdyze2FqKOkIC9D+rP9sBHRrdRV24X32/Thow== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1668443377; 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=tELjjwZ800XS5coQk0qRU9bwQBSC526T8kNf1rYyslpyZ3bvfpKU2a+6OVmFy+qzAW3ZUV +iS9PnHyufG1tIDg== 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 v4 07/39] tty: serial: kgdboc: document console_lock usage Date: Mon, 14 Nov 2022 17:35:00 +0106 Message-Id: <20221114162932.141883-8-john.ogness@linutronix.de> In-Reply-To: <20221114162932.141883-1-john.ogness@linutronix.de> References: <20221114162932.141883-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?1749489764406184777?= X-GMAIL-MSGID: =?utf-8?q?1749489764406184777?= |
Series |
reduce console_lock scope
|
|
Commit Message
John Ogness
Nov. 14, 2022, 4:29 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 &&