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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D1382C54EBD for ; Mon, 9 Jan 2023 10:14:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236785AbjAIKOg (ORCPT ); Mon, 9 Jan 2023 05:14:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59620 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236743AbjAIKOE (ORCPT ); Mon, 9 Jan 2023 05:14: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 721C1654E for ; Mon, 9 Jan 2023 02:13:18 -0800 (PST) Date: Mon, 9 Jan 2023 11:13:15 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1673259197; 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=BFnYGz3uQ0ZPdkPZZNuXygm5ApMSSYWsgWYIkJd8NV8=; b=ceZrPFWU0BKTEN6iDyiA4MEYP4eYct7mjuR6n90DIua8FM3wgxVMaKSPhj2+aS/P0pV7X+ 0C0qDGz8wGCS8NYu35iQxlDAU9GwrmtagxVOFKjUQNYd5qyfR2lmizjx3hR5dqkvDPWXne TGGXdFhE560wYuDmLNmogcnSWp0CDuHSsoWh6Y07gtmw8CKFBUEUdZ/gJf7LByHxCeqCq8 W8KXoF4hDvmVeUW3NfYE0kUOfxx36iX3JyATF50wE+C7r680ZaJUNCpc9GeNZccFW7OnHG zt9fBA/snsuBOwmRiXWY5PVpfUy/LXKYAPGzKuu5qoV9Kyjl9o6qB9RNO46X1w== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1673259197; 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=BFnYGz3uQ0ZPdkPZZNuXygm5ApMSSYWsgWYIkJd8NV8=; b=flPEUkggKxOeUluO3V4bQQVDLUaQy8YQatp726WllHL4rmlWtB1n9mhc45txPwJ2fnljod wxhFrpOyHU34TiDg== From: Sebastian Andrzej Siewior To: Johan Hovold Cc: Marek Vasut , linux-serial@vger.kernel.org, Alexandre Torgue , Erwan Le Ray , Greg Kroah-Hartman , Jiri Slaby , Maxime Coquelin , Thomas Gleixner , Valentin Caron , linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com Subject: Re: [PATCH v3] serial: stm32: Merge hard IRQ and threaded IRQ handling into single IRQ handler Message-ID: References: <20221216115338.7150-1-marex@denx.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org On 2022-12-27 15:56:47 [+0100], Johan Hovold wrote: > On Fri, Dec 16, 2022 at 12:53:38PM +0100, Marek Vasut wrote: > > Requesting an interrupt with IRQF_ONESHOT will run the primary handler > > in the hard-IRQ context even in the force-threaded mode. The > > force-threaded mode is used by PREEMPT_RT in order to avoid acquiring > > sleeping locks (spinlock_t) in hard-IRQ context. This combination > > makes it impossible and leads to "sleeping while atomic" warnings. > > > > Use one interrupt handler for both handlers (primary and secondary) > > and drop the IRQF_ONESHOT flag which is not needed. > > > > Fixes: e359b4411c283 ("serial: stm32: fix threaded interrupt handling") > > I don't think a Fixes tag is warranted as this is only needed due to > this undocumented quirk of PREEMPT_RT. It is not an undocumented quirk of PREEMPT_RT. The part that might not be well documented is that IRQF_ONESHOT won't run the primary handler as a threaded handler. This is also the case for IRQF_NO_THREAD and IRQF_PERCPU but might be more obvious. Anyway, if the primary handler is not threaded then it runs in HARDIRQ context and here you must not use a spinlock_t. This is documented in Documentation/locking/locktypes.rst and there is also a LOCKDEP warning for this on !RT which is off by default because it triggers with printk (and this is worked on). > And this should not be backported in any case. Such things have been backported via -stable in the past. If you disagree, please keep me in loop while is merged so I can poke people to backport it as part of the RT patch for the relevant kernels. > Johan Sebastian 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 376A7C5479D for ; Mon, 9 Jan 2023 10:15:50 +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:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=veAvqLM/Vf2eYelcsjnYbF44PFlIO0qoVqUK1qQVd+4=; b=3XfIgxfipVEMQd 5p+jJSlbYS+Kph373zQ84yvYOtivwjOs5VL06dARgxza8krl417wishOeILVVjZvJ7sJ/9neighzA 7FOz4Uh4Ih7agqPuDACpv785vZk6IfBYNZizmFFoc925P2E/MCA6XVHz3UQ2qRxot6ilnd6UMcd8o EVFdl5veOtlJqHmijKbcuPCQkHs+puWUFJ3yrzWyZzdpwgD1hIwGvf4I3CtN9qMS3KLOLfPY8/ua5 j39DtoJWl4j51ZM7+OiG4cARkSrhzmdhQzj5Binl1+Diu+EKfHyhUijlgSotRNI1aV2YbMEyOtUvF b9ce4mbsk2cUIefnxzfQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pEpAu-000kCE-KQ; Mon, 09 Jan 2023 10:14:41 +0000 Received: from galois.linutronix.de ([193.142.43.55]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pEp9g-000jUL-E0 for linux-arm-kernel@lists.infradead.org; Mon, 09 Jan 2023 10:13:26 +0000 Date: Mon, 9 Jan 2023 11:13:15 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1673259197; 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=BFnYGz3uQ0ZPdkPZZNuXygm5ApMSSYWsgWYIkJd8NV8=; b=ceZrPFWU0BKTEN6iDyiA4MEYP4eYct7mjuR6n90DIua8FM3wgxVMaKSPhj2+aS/P0pV7X+ 0C0qDGz8wGCS8NYu35iQxlDAU9GwrmtagxVOFKjUQNYd5qyfR2lmizjx3hR5dqkvDPWXne TGGXdFhE560wYuDmLNmogcnSWp0CDuHSsoWh6Y07gtmw8CKFBUEUdZ/gJf7LByHxCeqCq8 W8KXoF4hDvmVeUW3NfYE0kUOfxx36iX3JyATF50wE+C7r680ZaJUNCpc9GeNZccFW7OnHG zt9fBA/snsuBOwmRiXWY5PVpfUy/LXKYAPGzKuu5qoV9Kyjl9o6qB9RNO46X1w== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1673259197; 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=BFnYGz3uQ0ZPdkPZZNuXygm5ApMSSYWsgWYIkJd8NV8=; b=flPEUkggKxOeUluO3V4bQQVDLUaQy8YQatp726WllHL4rmlWtB1n9mhc45txPwJ2fnljod wxhFrpOyHU34TiDg== From: Sebastian Andrzej Siewior To: Johan Hovold Cc: Marek Vasut , linux-serial@vger.kernel.org, Alexandre Torgue , Erwan Le Ray , Greg Kroah-Hartman , Jiri Slaby , Maxime Coquelin , Thomas Gleixner , Valentin Caron , linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com Subject: Re: [PATCH v3] serial: stm32: Merge hard IRQ and threaded IRQ handling into single IRQ handler Message-ID: References: <20221216115338.7150-1-marex@denx.de> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230109_021324_823855_FD001EA0 X-CRM114-Status: GOOD ( 19.09 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 2022-12-27 15:56:47 [+0100], Johan Hovold wrote: > On Fri, Dec 16, 2022 at 12:53:38PM +0100, Marek Vasut wrote: > > Requesting an interrupt with IRQF_ONESHOT will run the primary handler > > in the hard-IRQ context even in the force-threaded mode. The > > force-threaded mode is used by PREEMPT_RT in order to avoid acquiring > > sleeping locks (spinlock_t) in hard-IRQ context. This combination > > makes it impossible and leads to "sleeping while atomic" warnings. > > > > Use one interrupt handler for both handlers (primary and secondary) > > and drop the IRQF_ONESHOT flag which is not needed. > > > > Fixes: e359b4411c283 ("serial: stm32: fix threaded interrupt handling") > > I don't think a Fixes tag is warranted as this is only needed due to > this undocumented quirk of PREEMPT_RT. It is not an undocumented quirk of PREEMPT_RT. The part that might not be well documented is that IRQF_ONESHOT won't run the primary handler as a threaded handler. This is also the case for IRQF_NO_THREAD and IRQF_PERCPU but might be more obvious. Anyway, if the primary handler is not threaded then it runs in HARDIRQ context and here you must not use a spinlock_t. This is documented in Documentation/locking/locktypes.rst and there is also a LOCKDEP warning for this on !RT which is off by default because it triggers with printk (and this is worked on). > And this should not be backported in any case. Such things have been backported via -stable in the past. If you disagree, please keep me in loop while is merged so I can poke people to backport it as part of the RT patch for the relevant kernels. > Johan Sebastian _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel