From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=52.34.181.151 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796137110; b=Se1EnYoqGvt40qZwOlowMTXzCxDwcc4wqQnvabO7lBuuOd9yccn9ZgWlZQ1vwFp/Lm9K YqnnB+Jt+eyxHmk+56cWp7M5itHuf1GB6u7/Bhkub+Cd4UFh3qwma1Tu8n8qYBD7zPMmk kUEnxAEX/lJzOaDSM2qedEOnnq8z2M//vvkL4NTxpO8WZWxZh2EpNRmE+finhdzembyZk CSAx0QrM+tzBZFmIdymQHJfvxs7LqzufLlkiN0KrmDswJzgdPbNCl4Ydua5ebPVUmQIuc l2GkQAga0A3zZy58iypmmFKxIVRmEU2t4xk/zUfUJEkRdv+kWo56e5iYXrBIZCiks4g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796137110; h=DMARC-Filter:DKIM-Signature:X-CSE-ConnectionGUID:X-CSE-MsgGUID: X-IronPort-AV:Received:Received:X-Farcaster-Flow-ID:Received:Received: From:To:CC:Subject:Date:Message-ID:X-Mailer:In-Reply-To:References: MIME-Version:Content-Transfer-Encoding:Content-Type:X-Originating-IP: X-ClientProxiedBy; bh=Dn29JamzF1MdShF3FtNZrvcFrQI4DVidx9wnJzIBwes=; b=lXs3bYgTQp0kI0PPA8n/wJgGxm9cNNzCfjDJ1NXfAWUQUK4juxJXVmcrcOLKEnlfhRuO jzaRF/I1S0PimtrrCXFEjckc2Eybe1VatKL/vDwF6DyNkVG71CUkSuY9k5eYaz6Ek5x0A xUkMZNbdY/ahJ1TPJGTP/UjyBSI2+SQmsB0b7jWbK1jAr7addgETqlQYsd6M48E1aVMJG ogYxvV1EhdQlYu4/hHB6SN0RHR68MOY5kILATgUDEmKiCawPwM80gN5mQsV9rM+ynrvVt W/KBjla51ZPsKE1/ycHGLRPBI6WWOitJnXyudtpszjg8bC3Z7cn+916mXygedxLK8zg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=amazon.com; spf=pass smtp.mailfrom=amazon.com; dkim=pass header.d=amazon.com header.i=@amazon.com header.a=rsa-sha256 header.s=amazoncorp2 header.b=Nti5rhYk; arc=none smtp.remote-ip=52.34.181.151 Received: from pdx-out-007.esa.us-west-2.outbound.mail-perimeter.amazon.com (pdx-out-007.esa.us-west-2.outbound.mail-perimeter.amazon.com [52.34.181.151]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AA274606A325; Tue, 1 Dec 2026 14:58:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org AA274606A325 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amazon.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=amazon.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=amazon.com header.i=@amazon.com header.a=rsa-sha256 header.s=amazoncorp2 header.b=Nti5rhYk DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazoncorp2; t=1796137109; x=1827673109; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Dn29JamzF1MdShF3FtNZrvcFrQI4DVidx9wnJzIBwes=; b=Nti5rhYkN4q8a6feKuIf44aIFN/0MjfpWpB+mWY48P4UqRzuq8EG4yah 62InqxutRBODoKOjMNYwoEmc+S8al5dw6BM1KFa6ZCHSSjQXkc/3FLRk3 8z+9BLFSvyl6QHl1gJFnpjs/MLU6y1avd+igHrkUwuccB9rvNACFDSWGY GmC8e4qLXbgF37zglKPiUus3kEaKk344R62f6wSzPizVGqCvV4Bt23tGn 4o6WYflPNhRszOl49RB12UtHTvU3BhpNXjwqBiqRyIkwcxwlUnrqA2O8T uYB3DNK39SlYrqPLT0NDUDCNjkY+OMc92mcOylxkU0TMoB3LDmOC1CKhe A==; X-CSE-ConnectionGUID: MXW6PFWXTAKyiNYFa4jpLg== X-CSE-MsgGUID: /aFxQq0KTVy2iwyyaolnhg== X-IronPort-AV: E=Sophos;i="6.27,244,1787011200"; d="scan'208";a="35593644" Received: from ip-10-5-9-48.us-west-2.compute.internal (HELO smtpout.naws.us-west-2.prod.farcaster.email.amazon.dev) ([10.5.9.48]) by internal-pdx-out-007.esa.us-west-2.outbound.mail-perimeter.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Dec 2026 14:58:26 +0000 Received: from EX19MTAUWC001.ant.amazon.com [205.251.233.53:10428] by smtpin.naws.us-west-2.prod.farcaster.email.amazon.dev [10.0.48.230:2525] with esmtp (Farcaster) id bda393fd-80ef-4c4f-b6f3-72f3b93515a5; Tue, 1 Dec 2026 14:58:25 +0000 (UTC) X-Farcaster-Flow-ID: bda393fd-80ef-4c4f-b6f3-72f3b93515a5 Received: from EX19D001UWA001.ant.amazon.com (10.13.138.214) by EX19MTAUWC001.ant.amazon.com (10.250.64.174) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.2562.57; Tue, 1 Dec 2026 14:58:25 +0000 Received: from dev-dsk-farbere-1a-46ecabed.eu-west-1.amazon.com (172.19.116.181) by EX19D001UWA001.ant.amazon.com (10.13.138.214) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.2562.57; Tue, 1 Dec 2026 14:58:23 +0000 From: Eliav Farber To: John Ogness , Greg Kroah-Hartman , Jiri Slaby CC: Petr Mladek , Steven Rostedt , Sergey Senozhatsky , , , , Eliav Farber Subject: Re: [PATCH] serial: core: Don't spin for nbcon ownership with the port lock held Date: Tue, 1 Dec 2026 14:58:19 +0000 Message-ID: <20261201145819.10941-1-farbere@amazon.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <87zeuq1b6j.fsf@jogness.linutronix.de> References: <20261130155133.37435-1-farbere@amazon.com> <87zeuq1b6j.fsf@jogness.linutronix.de> X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: EX19D031UWA001.ant.amazon.com (10.13.139.88) To EX19D001UWA001.ant.amazon.com (10.13.138.214) On 2026-11-30, John Ogness wrote: >> uart_port_lock() and its variants take the port lock and then spin until >> they own the nbcon console context, which synchronizes port->lock users >> against the write_atomic() callback. The context is requested at >> NBCON_PRIO_NORMAL, and while another CPU is in panic that request is >> always refused, so the spin never ends. > > It is always refused because it is not a reacquire. > > Commit 571c1ea91a73 ("printk: nbcon: Allow reacquire during panic") only > considered the reacquire situation. Right. I will reword it to: During a panic on another CPU the only acquire still allowed is a reacquire by the context that lost ownership, see commit 571c1ea91a73 ("printk: nbcon: Allow reacquire during panic"). The wrapper's acquire is not one, so it is always refused and the spin never ends. > Any foreign panic that occurs between the port-lock and ownership > acquire can cause this. Yes. I will put that in the commit log. >> - This may belong in printk instead. [...] > > I do not think the reacquire fix should extend to general port > locking. [...] OK, I will drop that note. > Should these instead reuse the trylock variants? For example: > > static inline void uart_port_lock(struct uart_port *up) > { > while (!uart_port_trylock(up)) > cpu_relax(); > } Tested this and it fixes the stall. The irq variant has no counterpart though, so it needs a new uart_port_trylock_irq() on spin_trylock_irq(). > Or perhaps in order to allow non-nbcon drivers to remain minimally > affected in behavior: > > static inline void uart_port_lock(struct uart_port *up) > { > if (!__uart_port_using_nbcon(up)) { > spin_lock(&up->lock); > return; > } That one cannot be used as written. __uart_port_using_nbcon() starts with lockdep_assert_held_once(&up->lock), and the up->cons reads below it are only safe under the port lock, as the comment there says. The patch as posted already leaves non-nbcon ports alone: such a port takes spin_lock() and one __uart_port_using_nbcon() test that returns false, which is what __uart_port_nbcon_acquire() did. If you want the trylock wrappers reused anyway, this keeps the assert valid and leaves the normal path on spin_lock(): static inline void uart_port_lock(struct uart_port *up) { spin_lock(&up->lock); if (__uart_port_nbcon_try_acquire(up)) return; spin_unlock(&up->lock); while (!uart_port_trylock(up)) cpu_relax(); } Which one do you want in v2? Eliav