From patchwork Wed Nov 16 16:21:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Ogness X-Patchwork-Id: 625407 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 48E70C4332F for ; Wed, 16 Nov 2022 16:25:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234849AbiKPQZE (ORCPT ); Wed, 16 Nov 2022 11:25:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58746 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238085AbiKPQXE (ORCPT ); Wed, 16 Nov 2022 11:23:04 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DAD3958BE3; Wed, 16 Nov 2022 08:22:15 -0800 (PST) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1668615734; 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=XOHwuBaQ1W+3awwG2RAkUq8lXTwRKxgLO4vJVGnxlV8=; b=zwABEZ9mxonAyBNUeWB10LZTBQNhVUWXnM4uJOtaQ2YyZadMZ5Bi3atLrrsSkVEU/BnViB xAZVnMRA2dR8k2nO0aVndbNd46Y1KfXjZxNnIMCd0MWCLq21gTPYXnDQlH47HazQ4NDvNt wmcJ6p2S4E6O3pkDLBoS7eyHnNAg3KsSCoQvLEKQjz/CSbQe3nu6Pon8WzaivpF79mr26K BAILjyp28M6MufGbgldEQGXoQwcNvfSuPpzdX/UBg8mB6SWPRgUX+uX2ZRJIGeOWZIQXpE 2Z/4P+skN/oruOza9baWAElWHHWGDsIWdsfXNjTGDHR5DZfUdF7y4XpQqQEB6w== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1668615734; 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=XOHwuBaQ1W+3awwG2RAkUq8lXTwRKxgLO4vJVGnxlV8=; b=s9R0LFz1ZdiHDzIlIEwfz6Uf9mV1b7pU/Ru3/LSGYsFj+6aDJGhMs03+ARyz6ujFNcaXLF WcI0pM16uwfwndDg== 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 v5 35/40] tty: serial: kgdboc: use srcu console list iterator Date: Wed, 16 Nov 2022 17:27:47 +0106 Message-Id: <20221116162152.193147-36-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 Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org Use srcu console list iteration for safe console list traversal. Note that this is a preparatory change for when console_lock no longer provides synchronization for the console list. Signed-off-by: John Ogness Reviewed-by: Petr Mladek --- drivers/tty/serial/kgdboc.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/tty/serial/kgdboc.c b/drivers/tty/serial/kgdboc.c index 5be381003e58..c6df9ef34099 100644 --- a/drivers/tty/serial/kgdboc.c +++ b/drivers/tty/serial/kgdboc.c @@ -451,6 +451,7 @@ static void kgdboc_earlycon_pre_exp_handler(void) { struct console *con; static bool already_warned; + int cookie; if (already_warned) return; @@ -463,9 +464,14 @@ static void kgdboc_earlycon_pre_exp_handler(void) * serial drivers might be OK with this, print a warning once per * boot if we detect this case. */ - for_each_console(con) + cookie = console_srcu_read_lock(); + for_each_console_srcu(con) { if (con == kgdboc_earlycon_io_ops.cons) - return; + break; + } + console_srcu_read_unlock(cookie); + if (con) + return; already_warned = true; pr_warn("kgdboc_earlycon is still using bootconsole\n");