From patchwork Wed Oct 19 14:55:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Ogness X-Patchwork-Id: 5648 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp379354wrs; Wed, 19 Oct 2022 08:10:43 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6WaUDiFeYoY1lPZQW4JxyK840JLQYvmNWzaQ2UL5jC/x6s0paOQno7QGlXx8VyMKh79BN7 X-Received: by 2002:a17:907:da4:b0:78d:4bc9:2497 with SMTP id go36-20020a1709070da400b0078d4bc92497mr7324088ejc.183.1666192243547; Wed, 19 Oct 2022 08:10:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666192243; cv=none; d=google.com; s=arc-20160816; b=cHBQKwBSerpt21rYNF91f3UQyPvhCddoxwf3IiJvdorn9wMa51PYoSkF3XcSMWf61J gOPkrOSewueIWcA+chA7EbJq/s2VJcVZ4xhKJWEydNA5flsvLIB/Z1HueeNVnbcLDpew pVoLc4vFr4J/4fUqjY57B9cXCSCw8179DTae15Y3g6Chj5bLD2q67HTT0ttZ4uPrFY+G KK2004GEWF7Jy8ZeWsOOE8gfdB+8chiEOB55HXWARgdq204ksnG6cTDHrv61Xh2fOl6b PCnAZDcpgLv1r56jVfXOmMiigbrKgWAZWxuAF6Pv7srPUJ8C8x5J31fUoEHcPsV7YYQF 2YvQ== 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=ACPI8gcDk9OHrPL7ke5XVpq5ui7KkEF2l2bHZNH8aSI=; b=LrGk/0HyKJ+1t8t9+1TW9QjluUem4tRuCx3Ywc0uWbsRprUzzES0UZW0xKZEDNMuS2 ZNfGiyNs7nKK0ISLJTTJi9NZp91MrTzDp6BN6YRZcXiU2lRnX7TqB9klM7fNfDIU/XbN SdzvqDOOHIIr71IUqcP9lCUhTX7SWBfl2XVpXRFfT1HJOPd7OiYjBIwbfXTsOwyBEm60 2j34cZWCjae5TOILwhTotDR1vB7pENsy3mvTRMtkkSnvdsx3uPNfcFES3Oj6TyFXas72 q1sQ0e5CMtw0zaDvDMpq8D0p7wZj30Mlxm2MGAyyUrskaAcUqxoVFv5nzQ5cscV1h7M0 U8rg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="Ccgy/tfH"; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=yIzC1pH2; 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 lv10-20020a170906bc8a00b00775326fb2ebsi12792073ejb.665.2022.10.19.08.10.15; Wed, 19 Oct 2022 08:10:43 -0700 (PDT) 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="Ccgy/tfH"; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=yIzC1pH2; 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 S231801AbiJSPGE (ORCPT + 99 others); Wed, 19 Oct 2022 11:06:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42252 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230353AbiJSPFF (ORCPT ); Wed, 19 Oct 2022 11:05:05 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 85B872F007; Wed, 19 Oct 2022 07:59:07 -0700 (PDT) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1666191374; 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=ACPI8gcDk9OHrPL7ke5XVpq5ui7KkEF2l2bHZNH8aSI=; b=Ccgy/tfHlK5pUky0RE3+PgIt1rgjfkq3Tlb6Sd8WDUWfjg35ogZEbfXvjsXgVU7QAtpI49 nw+J0Yr/pj68t053bnHszLo5Yf5Got25SfdJCTQ1XQR/4b43Xz8/x2LVdovnTWreK9d35z WppqeLftN6a6CqKiUrS4MgpzyM4QuBB9/5G05SLCI2HKV5qPIqRLUZfGfcz/gCiINc34o6 h7jJYblRSvG5ZqO55I7PrZ9Ycato2Lu3jOD83rw09TuE0vlq+TQ/1tpX9HLurzS3xA447+ yFPYxB156iSolo2OCep4UyfsiV0RLod+tQBCSKSpjrxSxsn1FDpKIja+pCHk1w== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1666191374; 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=ACPI8gcDk9OHrPL7ke5XVpq5ui7KkEF2l2bHZNH8aSI=; b=yIzC1pH27dxiAovKC98wbTRSEd+6o8YRWTr6jNZ8jbaA2SP9qlYcbF+l4kQ4Idnk3qN43O wYA6fbuZuIsJFdCw== To: Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org, Jason Wessel , Daniel Thompson , Douglas Anderson , Greg Kroah-Hartman , Jiri Slaby , kgdb-bugreport@lists.sourceforge.net, linux-serial@vger.kernel.org Subject: [PATCH printk v2 22/38] serial: kgdboc: document console_lock usage Date: Wed, 19 Oct 2022 17:01:44 +0206 Message-Id: <20221019145600.1282823-23-john.ogness@linutronix.de> In-Reply-To: <20221019145600.1282823-1-john.ogness@linutronix.de> References: <20221019145600.1282823-1-john.ogness@linutronix.de> MIME-Version: 1.0 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747129197982960680?= X-GMAIL-MSGID: =?utf-8?q?1747129197982960680?= 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 Reviewed-by: Greg Kroah-Hartman Reviewed-by: Douglas Anderson Reviewed-by: Petr Mladek --- 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 e9d3f8c6e3dc..48000666789a 100644 --- a/drivers/tty/serial/kgdboc.c +++ b/drivers/tty/serial/kgdboc.c @@ -545,6 +545,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. + */ console_lock(); for_each_console(con) { if (con->write && con->read &&