From mboxrd@z Thu Jan 1 00:00:00 1970 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8DDDEC433F5 for ; Sun, 8 May 2022 11:02:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:References :In-Reply-To:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=G0UHmbadxhHgqvUicXhOSRNwssnzzjKB9fKcpFRsePU=; b=Gf0gWWmV7d5J/A SBudYgZnOgmTuorDWox7PnxUaMFmIJq4VQ0fBwFoco7uMpDkFPjM5I8BhplHMofwWJJa1UiQRK6I8 5DGcL7+tX8i4qJuqVBuDwz+9Nsqm7AHdMq93griBu8haihGe0cbNMM5McU8hQfkozqsVDJXNJgRds OWb3wmjtYU/cPu2E+N1lBtcQrU90Bk5Hdulx50mobOfJAbxlA+FBiDOEr1u1jMZCsvI/lqdHIsQ8S 9pUClby1KCdjeQgdm7QmtfcGd3ZO42c3uI11tRb1ILM3X9h8Sx05q/I8+MZGelrOOR+4nPaz5+rxJ 8Pl2Y5OuJSGpELvDiltw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nnegR-009v5h-H8; Sun, 08 May 2022 11:02:39 +0000 Received: from galois.linutronix.de ([2a0a:51c0:0:12e:550::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nnegP-009v4U-4t for linux-amlogic@lists.infradead.org; Sun, 08 May 2022 11:02:38 +0000 From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1652007754; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=7G+zUj54eBfyktDcZa4ZbAJ+odaEfrQMWJTCSbKdy3k=; b=iGAXFGuLvVo6RpqFLMh0I7GAsJs9x6RUuD0iLq6O3k1p1jaLIT1/Dnjl1o8u3Mk8My2mvO P3I5idFwbQ2uMmyBEghYRQAOJ52/jbcCUG9kpi7BDGQqqxgS1M4Knh2rfp1xSkGv2OqYup GSybEJMYYY+ieyrk1J32AG14PfLXRTU7sMUyHloRCtBoKES1lZXKjc32wqh6Md/fjKI1J0 QuU6Fox4owf6UrYQzJCl0HXVDRAenF6AMq3e5Zl3mQ30S/jhXFddru6bjClYUnvmFI6WSI coRXikGGhJzUQfhprSwM/G20Usso5Oq7HnlArGepFuPbe4/8v7oJkBd1yISKTg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1652007754; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=7G+zUj54eBfyktDcZa4ZbAJ+odaEfrQMWJTCSbKdy3k=; b=fMm0K8kzoOwNve1dseEdxD4RAMHY82afC7BOqFI9E8ghspP/h/+mXruaz2MaO63rE24efU +7qpfIyUWZ8o00Aw== To: Neil Armstrong , Marek Szyprowski , Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org, Greg Kroah-Hartman , linux-amlogic@lists.infradead.org Subject: Re: [PATCH printk v5 1/1] printk: extend console_lock for per-console locking In-Reply-To: References: <2a82eae7-a256-f70c-fd82-4e510750906e@samsung.com> <87fslyv6y3.fsf@jogness.linutronix.de> <51dfc4a0-f6cf-092f-109f-a04eeb240655@samsung.com> <87k0b6blz2.fsf@jogness.linutronix.de> <32bba8f8-dec7-78aa-f2e5-f62928412eda@samsung.com> <45849b63-d7a8-5cc3-26ad-256a28d09991@samsung.com> <87pmktm2a9.fsf@jogness.linutronix.de> <87a6bwapij.fsf@jogness.linutronix.de> <87zgjvd2zb.fsf@jogness.linutronix.de> Date: Sun, 08 May 2022 13:08:33 +0206 Message-ID: <871qx4qoc6.fsf@jogness.linutronix.de> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220508_040237_375301_4557EE31 X-CRM114-Status: GOOD ( 12.77 ) X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+linux-amlogic=archiver.kernel.org@lists.infradead.org Hi Neil, On 2022-05-06, Neil Armstrong wrote: > Thanks all for figuring out the issue, perhaps other uart drivers > could fall in the same issue if startup code isn't protected with > lock? When preparing for the official patch submission [0], I needed quite a bit of time to understand why another function (meson_uart_reset) should not and cannot acquire the port->lock. I then started investigating some other drivers and indeed I see lots of potential problems. Any console initializing port->lock from the driver's probe() is probably wrong (and there are lots of them). But as I've learned with the meson driver, the details are subtle. Each driver will need to be carefully evaluated to see if it is actually safe. uart_ops->startup() is called without holding port->lock. If the device is a console, it is already registered and printing. driver->probe() is called without holding port->lock. If the device is a console, it is already registered and printing. For both functions, port->lock might not be initialized yet, so blindly acquiring it is wrong. Note that this is not related to the introduction of kthread printing. I've put it on my TODO list to go through the ~76 console drivers to investigate their startup() and probe() implementations. But I will not be able to do this quickly. My time might be better spent writing to all the maintainers asking them to please verify the usage. John Ogness [0] https://lore.kernel.org/lkml/20220508103547.626355-1-john.ogness@linutronix.de _______________________________________________ linux-amlogic mailing list linux-amlogic@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-amlogic