Message ID | 20240123054033.183114-3-junxiao.chang@intel.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-34730-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2553:b0:103:945f:af90 with SMTP id p19csp137258dyi; Mon, 22 Jan 2024 21:44:49 -0800 (PST) X-Google-Smtp-Source: AGHT+IEr9Hr+bs7Czqq+GVbTY8W+cvX1yqsjGbSMghCM8rD2vYwLKhkgGTk/H9SKtPTNgUOQ8z3m X-Received: by 2002:a05:6a00:23d5:b0:6d9:a074:659f with SMTP id g21-20020a056a0023d500b006d9a074659fmr7913016pfc.13.1705988688968; Mon, 22 Jan 2024 21:44:48 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705988688; cv=pass; d=google.com; s=arc-20160816; b=Apkt4Mm77sqpnyFQxVy+/zMH9pln1Wmcf4otg1xR7SqRBcJD2up5tLf8BA2L9BhxRe bw+bYYo3Wvz9EkWPgj5/r7KzCbAdHWdax07wZBgmO6OOYQXvy2o+retR7+DRPgkWdGh1 UkpYqMT0nXizwGjzqjHjiHOM8mCXv7wVktv0wcdgNBrx5FsuwLZpI5tge952wFgaspVq 5i/FrEuiOaCPPfTk/4d8u+1eZaDsNqgTwXj8Aa8j2Q36Q9M9ywsNdud2OWUXGOeM/LHg uriaWCGvjvxfCJqFKs1aGEOcjvAekpIsd9e4aOhyduY3pWfFBKrQV/wrMdlrxpm7bPKB knLg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=XYb9NVWgkQg/qd2NKo6NwvmLgZ5sSeXdTBd2KFiD0MU=; fh=3n9yk9H0aP61VWOkjV8qJHqEh2nN7MsL3m9A3XvFOBk=; b=BsF9C9Jhtj7GJOPRLsI2+Ql7XGA/flUzTxDk6KcDy0T2AEL0Li1i5VQW6RgpW/Wp7/ 4NI7FeIy/Cy1TsH6DQ9R9MBk3G7J/yPZQWRfa7DHomxEzZ6BUvPL9M6Nf3C5DppsOoBe 6adYCQhBLR0ANs7sLNIbL4icdp4jr/HydvM/RIt94G66wgxsgYhjPPqUzwgUeGKxyjOp 0NtztE7LLNifRcIziUt59vq5sBZRfYmh+p0Q/NuzJaS8ImNa7bAi5GWmjAI1HGgO1mGq qY+xq/x0Nt7K9GkMroZRPTkXaq1F5DXH/4BCus6jkYar5gb9TSqSqFlzjsIx1oEcSqa8 59lA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=IWC6hzHt; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-34730-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-34730-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id f35-20020a635123000000b005c65ed0f692si9371805pgb.141.2024.01.22.21.44.48 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jan 2024 21:44:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-34730-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=IWC6hzHt; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-34730-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-34730-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 4267EB24E5B for <ouuuleilei@gmail.com>; Tue, 23 Jan 2024 05:41:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 791CEDDB5; Tue, 23 Jan 2024 05:41:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="IWC6hzHt" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 405734432; Tue, 23 Jan 2024 05:41:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705988462; cv=none; b=sWjU/OK6gRJ096pADm2JDTRnX4JP9kPn9iiRuvaCixe6lzyqcTkJ92XVMOiMBIcufp0BTtkp2uIS4l4umePLOgXwpGv6S2nl2uSwrSp40AhYI5ZrnFZW+y4M3lbiSNoDYvGWc4uLerBm9v7ycMsBT8uRk7+XXkV6is1T+4c5kI0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705988462; c=relaxed/simple; bh=gdiyFjvMqWMG/af6i2COjazfjxZBQgaYcm1PP8azrvk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ABGPyMgZ1wyz0rPGM+d7sU6mGrzXiqX3jWBxw44D+UtsJpFIuHeddD5mmnCLInLIReRA5lXgREJUajC+BMnvmLGCDU8vfX+KEo7XhoECGP4CvtWn/0AT5UQZmrsXLiVkNDjmXsJYSVWKY3x3BXpXeDvHqETc/iGQKKxbqAqJDQg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=IWC6hzHt; arc=none smtp.client-ip=198.175.65.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1705988462; x=1737524462; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=gdiyFjvMqWMG/af6i2COjazfjxZBQgaYcm1PP8azrvk=; b=IWC6hzHt+hGgDxM8mnhmOKjK757opWdvGQIPrJ3S1sCrDPlWBKRCNmyI WkGNJg1nbwrHGt0hybHhtSNKtWLhEcm1GOdFE6qIUV5EwZNj3Q1o5BAt9 FWKtG/ludALKUDMf4YAMM+By83qOCitlD3yGyrrHi9ZzIdJprr8XHxyXa npxwAFEokZiWIetHfUHRqzC54fEfMtHWKtt/xQ21kPIr/6WZX6hvgJ4WN 6CCgWYvGTQuC6+duNL7wvvSsWTgbdfhYjVn2jQa0TDFo+2NopWKIuscQ9 uX+ctZsI+4jgHf/75tq1fX5Zv4NGM8tVCJKtFll+SYteqZsQeKimV+oeW A==; X-IronPort-AV: E=McAfee;i="6600,9927,10961"; a="14770175" X-IronPort-AV: E=Sophos;i="6.05,213,1701158400"; d="scan'208";a="14770175" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jan 2024 21:40:51 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.05,213,1701158400"; d="scan'208";a="1472008" Received: from junxiaochang.bj.intel.com ([10.238.157.86]) by fmviesa003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jan 2024 21:40:47 -0800 From: Junxiao Chang <junxiao.chang@intel.com> To: bigeasy@linutronix.de, tglx@linutronix.de, rostedt@goodmis.org, linux-kernel@vger.kernel.org Cc: john.ogness@linutronix.de, hao3.li@intel.com, lili.li@intel.com, jianfeng.gao@intel.com, linux-rt-users@vger.kernel.org Subject: [PATCH 2/2] printk: nbcon: check uart port is nbcon or not in nbcon_release Date: Tue, 23 Jan 2024 13:40:33 +0800 Message-Id: <20240123054033.183114-3-junxiao.chang@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240123054033.183114-1-junxiao.chang@intel.com> References: <BN9PR11MB5370AED9C562F9DA75093557EC742@BN9PR11MB5370.namprd11.prod.outlook.com> <20240123054033.183114-1-junxiao.chang@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1788319507926157549 X-GMAIL-MSGID: 1788858795651105953 |
Series |
nbcon locking issue with v6.6.10-rt18 kernel
|
|
Commit Message
Chang, Junxiao
Jan. 23, 2024, 5:40 a.m. UTC
Try to release nbcon only if current uart port is nbcon, as it does
in nbcon_acquire.
Signed-off-by: Junxiao Chang <junxiao.chang@intel.com>
---
kernel/printk/nbcon.c | 3 +++
1 file changed, 3 insertions(+)
Comments
On 2024-01-23, Junxiao Chang <junxiao.chang@intel.com> wrote: > Try to release nbcon only if current uart port is nbcon, as it does > in nbcon_acquire. The release needs to undo what acquire did. Why should it have its own checks that would cause it to _not_ undo what acquire did? Keep in mind that an nbcon console could be unregistered while another CPU is holding the nbcon lock. The port lock (and nbcon lock) are protecting access to the hardware. They are not related to console registration/unregistration. John
> The release needs to undo what acquire did. Why should it have its own checks that would cause it to _not_ undo what acquire did? > I agree with you that release needs to be undo what acquire did. The problem is sometimes it might do release while it didn't acquire. In nbcon_acquire, it checks current uart_port is nbcon or not. If it is not nbcon, it returns without locking anything. So in nbcon_release, it should have this checking as well. If current uart_port is not nbcon, it should not do any lock release, this is reason I added this checking in nbcon_release. For example, there are two uart port ttyS0 and ttyS4, ttyS0 is console and nbcon. ttyS4 is not console or nbcon. When ttyS4 uart port is shutdown, it firstly calls nbcon_acquire, then calls nbcon_release in "serial8250_do_shutdown". During nbcon_acquire, it locks nothing because current uart is not nbcon(There is uart_is_nbcon checking in nbcon_acquire). When it calls nbcon_release, it should not release anything either because it is not nbcon - it doesn't lock anything in nbcon_acquire. But with current code logic, it will release nbcon lock which should not be released. Regards, Junxiao
diff --git a/kernel/printk/nbcon.c b/kernel/printk/nbcon.c index b53d93585ee71..d8c6f30adde8b 100644 --- a/kernel/printk/nbcon.c +++ b/kernel/printk/nbcon.c @@ -1623,6 +1623,9 @@ void nbcon_release(struct uart_port *up) .prio = NBCON_PRIO_NORMAL, }; + if (!uart_is_nbcon(up)) + return; + if (!up->nbcon_locked_port) return;