From patchwork Tue Jan 16 07:32:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leonardo Bras Soares Passos X-Patchwork-Id: 188440 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:42cf:b0:101:a8e8:374 with SMTP id q15csp100991dye; Mon, 15 Jan 2024 23:33:31 -0800 (PST) X-Google-Smtp-Source: AGHT+IHxL7DrCw0EPvaXZQu98I6KVBwM1pbpcE3jdFa1fBRTKhG1Fp0LTWe21kAaI0Exj3RF7IBg X-Received: by 2002:a05:6214:2482:b0:681:12af:6309 with SMTP id gi2-20020a056214248200b0068112af6309mr9381395qvb.71.1705390411300; Mon, 15 Jan 2024 23:33:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705390411; cv=none; d=google.com; s=arc-20160816; b=eLmeLXZRqq9Ntb/9xHmfpYwDM91qw/Fd1vJyZwsDlBbVt6V9O3He6AJDHzJW65Fngv ANH19PqHn1eaPqsKUymgybc10U1cgbNFcvp2JQkuZ1L43zRqCI7db7BP37hgY7iM1GXY Vj+bFUqWHGX2hXVXCbiekidXTEGsB1N3eo0ppfXnCZOWkY2vAQsc8wSPxWsSo3YTqcMV 0Midko4HRu0koRN9BzydRhKRHLDJ2q97S9KO1nsTdhtdUCQ7fUt4M3L/oyWK8mGAV7kx QC2aEJX5N5tfJjatCtMxTxn+u80fs68VZDDZGPs2Nv3HbraD40lbjn7epqG3BcX3uCzV zkGA== ARC-Message-Signature: i=1; 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=fK1cfcz5VdHUqaPh3D2ST8gwHCilhZQB43Ha1E7iCnM=; fh=P6wXOSRB3iCckVOwoLNvETjy+M9M6cby0SbuZFU1iqY=; b=GswSNRuMqq02Lr31pQmvUDwEbBrmN4O4t+Rx+MAEEf+Q16AlJeX6ZmmJhaqGq0wXWW 2nTVxgdyceiBK8aQnJxHfAo5x+C75GK3xRBFAUsUYcA8G7N7BbTh6+YPAgUdZFjTHk4W G4gXaJoOxoF+/Fc9AcP1TlxV6p1d+2lTExQGso0ZOgMSdJq2as87TjCbIFgwjat+JOYu i3ozrJ2O0XinFXugPlMzYL0AIArOhajOx6AMhTi9uHfNc6BjNf8qJl9I1b/MBBRD1SDg 2gaWu0Xxa6SQDB2D8IBEn311Ssy6A+Fja4n+k8eNsC6ggwEdmUj4l9wooUxNk9bzmQpr hEpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Ua5wCZME; spf=pass (google.com: domain of linux-kernel+bounces-27079-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-27079-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id a17-20020a0cb351000000b0068081587c9fsi9443116qvf.147.2024.01.15.23.33.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jan 2024 23:33:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-27079-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Ua5wCZME; spf=pass (google.com: domain of linux-kernel+bounces-27079-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-27079-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 1994D1C2309E for ; Tue, 16 Jan 2024 07:33:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 107EE11720; Tue, 16 Jan 2024 07:32:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Ua5wCZME" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 DDCCC10A3D for ; Tue, 16 Jan 2024 07:32:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1705390373; 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=fK1cfcz5VdHUqaPh3D2ST8gwHCilhZQB43Ha1E7iCnM=; b=Ua5wCZME6jx6re5nxz9PGwdmcwlZHYJp/v6pUP+VR0GXnj8l0wc5bZjhrh3++6fxY2rEie 21b4DP4TtD4p1VjWoJHWD74QooXmkM1wXhuLk2z8naP729tl5kpBIGPEWLiKVCHVgUlTSw X9gQFpnvYJnfP9vp7MBa4caPeIaoLhI= Received: from mail-yw1-f198.google.com (mail-yw1-f198.google.com [209.85.128.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-302-ELD_HopOPeOsznxynZOAQw-1; Tue, 16 Jan 2024 02:32:52 -0500 X-MC-Unique: ELD_HopOPeOsznxynZOAQw-1 Received: by mail-yw1-f198.google.com with SMTP id 00721157ae682-5e744f7ca3bso148936287b3.2 for ; Mon, 15 Jan 2024 23:32:52 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705390372; x=1705995172; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=fK1cfcz5VdHUqaPh3D2ST8gwHCilhZQB43Ha1E7iCnM=; b=fCFpxNpKxU8IdtsFo/Pd3lHgMUyRC7K5SodEXkOT9w3XM1AXpn4gsXWTb7Rlj7HIgK IQna9BTX+05j7NGJVNZJGe1qmBjt5UKf6h4BHay9I8zYTbeowMbLGarQT+DR4SN5vYul /b4+TrOd02scGkTZEmc+/s5CFzeO/EI4673VXBbgOFZJRB0UwI3p3jczWfZoshO3lBxG wM7g3shKCjsyFGXQ0Ig7QgMr1i9e3ZsHlZn14egCL4PIoFQgef0FCpU7mPuj4pqJ929I JbJjtkW1P7+1dttZdiCiaHaMhjRAx1wtdIv/4SkyoWhVcV+2zJu4eF4V66HFNKrifSUv QAJw== X-Gm-Message-State: AOJu0Yyi44xpiZ+F5rqm9SZJX0zCjj3FZzl5v4+dv1bRWAb8NUl4Mv6u CskVJVyud/q2Vhpc9hRyfJD1KUHlEUQwgpONOJdE8FDKNAe9KGTOANQTZI4U3DaimhagEng6ObH TmadQXZ07D5SfR0zlwgz2fq8FMaYoi607 X-Received: by 2002:a0d:e2ca:0:b0:5ff:4b0b:4fde with SMTP id l193-20020a0de2ca000000b005ff4b0b4fdemr764981ywe.71.1705390372032; Mon, 15 Jan 2024 23:32:52 -0800 (PST) X-Received: by 2002:a0d:e2ca:0:b0:5ff:4b0b:4fde with SMTP id l193-20020a0de2ca000000b005ff4b0b4fdemr764969ywe.71.1705390371787; Mon, 15 Jan 2024 23:32:51 -0800 (PST) Received: from LeoBras.redhat.com ([2804:1b3:a803:64aa:6db9:6544:60c:9e16]) by smtp.gmail.com with ESMTPSA id bs6-20020ac86f06000000b00429d6bd085csm3191262qtb.6.2024.01.15.23.32.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jan 2024 23:32:51 -0800 (PST) From: Leonardo Bras To: Peter Zijlstra , Ingo Molnar , Will Deacon , Waiman Long , Boqun Feng , Kent Overstreet , Marcelo Tosatti Cc: Leonardo Bras , linux-kernel@vger.kernel.org Subject: [PATCH v1 1/1] spinlock: Fix failing build for PREEMPT_RT Date: Tue, 16 Jan 2024 04:32:32 -0300 Message-ID: <20240116073234.2355850-3-leobras@redhat.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240116073234.2355850-2-leobras@redhat.com> References: <20240116073234.2355850-2-leobras@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1788231456120505575 X-GMAIL-MSGID: 1788231456120505575 Since 1d71b30e1f85 ("sched.h: Move (spin|rwlock)_needbreak() to spinlock.h") build fails for PREEMPT_RT, since there is no definition available of either spin_needbreak() and rwlock_needbreak(). Since it was moved on the mentioned commit, it was placed inside a !PREEMPT_RT part of the code, making it out of reach for an RT kernel. Fix this by moving code it a few lines down so it can be reached by an RT build, where it can also make use of the *_is_contended() definition added by the spinlock_rt.h. Fixes: d1d71b30e1f85 ("sched.h: Move (spin|rwlock)_needbreak() to spinlock.h") Signed-off-by: Leonardo Bras --- include/linux/spinlock.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/include/linux/spinlock.h b/include/linux/spinlock.h index eaac8b0da25b8..3fcd20de6ca88 100644 --- a/include/linux/spinlock.h +++ b/include/linux/spinlock.h @@ -449,6 +449,12 @@ static __always_inline int spin_is_contended(spinlock_t *lock) return raw_spin_is_contended(&lock->rlock); } +#define assert_spin_locked(lock) assert_raw_spin_locked(&(lock)->rlock) + +#else /* !CONFIG_PREEMPT_RT */ +# include +#endif /* CONFIG_PREEMPT_RT */ + /* * Does a critical section need to be broken due to another * task waiting?: (technically does not depend on CONFIG_PREEMPTION, @@ -480,12 +486,6 @@ static inline int rwlock_needbreak(rwlock_t *lock) #endif } -#define assert_spin_locked(lock) assert_raw_spin_locked(&(lock)->rlock) - -#else /* !CONFIG_PREEMPT_RT */ -# include -#endif /* CONFIG_PREEMPT_RT */ - /* * Pull the atomic_t declaration: * (asm-mips/atomic.h needs above definitions) From patchwork Tue Jan 16 07:32:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leonardo Bras Soares Passos X-Patchwork-Id: 188441 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:42cf:b0:101:a8e8:374 with SMTP id q15csp101152dye; Mon, 15 Jan 2024 23:34:04 -0800 (PST) X-Google-Smtp-Source: AGHT+IGbIhKwbX34qSHzFOmraoNzC4knM0DyGk8fZFAh/Oz7wnbN2ZFQqTgRCXCI6G8vTt1W2CZ6 X-Received: by 2002:a9d:6347:0:b0:6dd:ed82:f46c with SMTP id y7-20020a9d6347000000b006dded82f46cmr3966801otk.10.1705390444674; Mon, 15 Jan 2024 23:34:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705390444; cv=none; d=google.com; s=arc-20160816; b=xk1sWCNgva098R+4vzsMLgOpGHB3K0WNlSByX54FG7/VLaDylmBV+CrLcHG2uyhBiG flGqFE8FmP+EX+lUpwWDtzmYlgjXiHghgKZskLXUlncNPDG8x5HP3WYk9QZCqwj3UJ3p ZhWMAmw+BZx/wFgIO9rmw3w2ZPOXdP2HfjE6dgJGQZseyQjsJwD2PLglhcvcA5VnFJiy Ip/HJVO0p/lN2b2ph1LsjONGYeg6S8KUs13bv/N82msr74HZCiM3YX5ee8qpDM/jRv59 3sVUfZEaCOJ9P9R0GHPD5K37KrEMziz3t5FAlqB21gCbS9xHgURHJwfadyY16Zt03XpW qiTg== ARC-Message-Signature: i=1; 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=Ev/EHro7bSIb21ohSGiRASekMY9/Fc0MaRbZNwxLwJc=; fh=vP35LLtFjdV3DYVbmWB2N3KkiJJpySZ0WqDM1LuFR90=; b=mHbtVUhLEsVaQKcv805BI2AKjOmweP1vhbRNp/+cpZqaf4M9tWa1lFRASOKN7ZTeqL GvY/Gdd1on4qLPbPnY6cH7N0DuYiiqSaobrm+rNYYo4JL1tv9Smq0BdncAj4aecLEuyH q+/Ctdi3kiQdIJIwicDboYDeLbJMvMvSerwNpVz8yJOpCU51Eaw8dTVECK9vfvuAR3IR Vid1MC+CqtL6AL12TFX2U64R+nxNjS6ZFYvb5H+zrn4z4lAA3+IPnLa/v66uBMLxjjI7 flVTlp6CyG14r/DPGbUEY2UeMbwOug1JLb+laus7VG1/H+Pd4JZBeueKJjH7KxU8OGVC XLVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Of8PBbzi; spf=pass (google.com: domain of linux-kernel+bounces-27080-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-27080-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id 199-20020a6302d0000000b005c5fe04e4eesi10451344pgc.852.2024.01.15.23.34.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jan 2024 23:34:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-27080-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Of8PBbzi; spf=pass (google.com: domain of linux-kernel+bounces-27080-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-27080-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.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 A2551B23014 for ; Tue, 16 Jan 2024 07:33:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 18EC9125B2; Tue, 16 Jan 2024 07:33:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Of8PBbzi" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (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 283E611739 for ; Tue, 16 Jan 2024 07:33:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1705390382; 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=Ev/EHro7bSIb21ohSGiRASekMY9/Fc0MaRbZNwxLwJc=; b=Of8PBbziYYO7EDZVezZwDQ4HKwdv4hIKdnEwiPPq+Foj1nP1ul6wExeqy4pUuH7E0qVKFC hEQi70CYlkLqwRu7XL9+c5lIJxvxg3QaMpu05ZerNzk0P7VAcGQNeygNkxdX+p8+5f2ZXD AHSCBKZ3YF0fRhFZkmH+zECpUWn3z3U= Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-477-3ELGe3_HO--Cm7-MYZfULQ-1; Tue, 16 Jan 2024 02:32:54 -0500 X-MC-Unique: 3ELGe3_HO--Cm7-MYZfULQ-1 Received: by mail-qt1-f197.google.com with SMTP id d75a77b69052e-429f10775aeso17514991cf.0 for ; Mon, 15 Jan 2024 23:32:54 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705390374; x=1705995174; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Ev/EHro7bSIb21ohSGiRASekMY9/Fc0MaRbZNwxLwJc=; b=ptZsbhmf4RIEpoFpl4RFjq2+qCutKa5QZwyETuTw0eCEwOYRNIHwLnQtlK9OoyaQ26 xVOXHCAwk81N/UY5/F8JEz+hhs0hIP8wZjVXTB8pPHiaJQ2a9B/oJVILJyU0Y0UHjNgB zVtG5wBpmv7vYtRTQ0rQPy4pXkz46tO70D2fIx3pLqaN0SDpHz4LtCRxR4XzXNsOjLZn CUFaL3AyhCLTeuiGO+w5aY5SL+wc27h7FBcWAP2F3keywO8F5RYThyWerHkI5YZsQOM+ hQCimfRiP7uRzgWOec6eAAzsrD1fiLF2jjXQHLM+COWEN9zBpp3FlGNMuxyYX+OyqS9B 2kEQ== X-Gm-Message-State: AOJu0YzAU42KBZZ1zu5I3hTlGfADcZaKDPrCeNeW56GnavGJ0+XIbjXp sS8eAhxrgPYm9zMw3K+fSEzs4yID1U1xvEJuGLdUcCEpQhQSG0nD0yL1RkqIEGLGnnJolpsK4BA 5Vqr1Vjw17+g3vUboLd9B2kkEqxb0GBv1 X-Received: by 2002:ac8:5bd2:0:b0:429:bdfc:3680 with SMTP id b18-20020ac85bd2000000b00429bdfc3680mr8717441qtb.97.1705390374494; Mon, 15 Jan 2024 23:32:54 -0800 (PST) X-Received: by 2002:ac8:5bd2:0:b0:429:bdfc:3680 with SMTP id b18-20020ac85bd2000000b00429bdfc3680mr8717434qtb.97.1705390374251; Mon, 15 Jan 2024 23:32:54 -0800 (PST) Received: from LeoBras.redhat.com ([2804:1b3:a803:64aa:6db9:6544:60c:9e16]) by smtp.gmail.com with ESMTPSA id bs6-20020ac86f06000000b00429d6bd085csm3191262qtb.6.2024.01.15.23.32.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jan 2024 23:32:53 -0800 (PST) From: Leonardo Bras To: Greg Kroah-Hartman , Jiri Slaby , Thomas Gleixner , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Andy Shevchenko , Florian Fainelli , John Ogness , Tony Lindgren , Marcelo Tosatti Cc: Leonardo Bras , linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org Subject: [RFC PATCH v1 2/2] serial/8250: Avoid getting lock in RT atomic context Date: Tue, 16 Jan 2024 04:32:33 -0300 Message-ID: <20240116073234.2355850-4-leobras@redhat.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240116073234.2355850-2-leobras@redhat.com> References: <20240116073234.2355850-2-leobras@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1788231490979401006 X-GMAIL-MSGID: 1788231490979401006 With PREEMPT_RT enabled, a spin_lock_irqsave() becomes a possibly sleeping spin_lock(), without preempt_disable() or irq_disable(). This allows a task T1 to get preempted or interrupted while holding the port->lock. If the preempting task T2 need the lock, spin_lock() code will schedule T1 back until it finishes using the lock, and then go back to T2. There is an issue if a T1 holding port->lock is interrupted by an IRQ, and this IRQ handler needs to get port->lock for writting (printk): spin_lock() code will try to reschedule the interrupt handler, which is in atomic context, causing a BUG() for trying to reschedule/sleep in atomic context. So for the case (PREEMPT_RT && in_atomic()) try to get the lock, and if it fails proceed anyway, just like it's done in oops_in_progress case. Signed-off-by: Leonardo Bras --- drivers/tty/serial/8250/8250_port.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c index 8ca061d3bbb92..8480832846319 100644 --- a/drivers/tty/serial/8250/8250_port.c +++ b/drivers/tty/serial/8250/8250_port.c @@ -3397,7 +3397,7 @@ void serial8250_console_write(struct uart_8250_port *up, const char *s, touch_nmi_watchdog(); - if (oops_in_progress) + if (oops_in_progress || (IS_ENABLED(CONFIG_PREEMPT_RT) && in_atomic()) locked = uart_port_trylock_irqsave(port, &flags); else uart_port_lock_irqsave(port, &flags);