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 B9D6EC54EBD for ; Thu, 12 Jan 2023 13:13:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231434AbjALNNI (ORCPT ); Thu, 12 Jan 2023 08:13:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53984 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230077AbjALNNH (ORCPT ); Thu, 12 Jan 2023 08:13:07 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C56D5AE4A for ; Thu, 12 Jan 2023 05:13:06 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 6328561A59 for ; Thu, 12 Jan 2023 13:13:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B4369C433EF; Thu, 12 Jan 2023 13:13:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1673529185; bh=71WCD2LYTHvB/FQ8+vaLVwWxU8IB40Qvo5Km4Lbz8Pk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=RqxufPvOzIAyPAnyGVSCFxgrAu7uNssmK+q7P829ela4qcXC26u08NKHCi5sUk376 cP1evOZfOInZku9T5QpMqwczl1hjlQoc0EJhbBUFdpzFn0GqW2n22a3wXiQ1NdYd90 Bhf7ef8TW3NfA/tMHH0vGcekWbD3GidLKF9USZ2tyDPKRSS2gmS5/MvbH+9yKtiCsm qQWCQ5hjZq6juAcP5FZjLndLsDgWsXMHRYa8y97d+ScJOd3v/Es9dyk9qtQUxOdcUX lKZG9ScSWtu0xuOZHDzxRLXTcONyBrQt1dbrXghuGzaIDhDzaf+WuG1J5kHOQuv/Us 97OREQoWnPhng== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pFxOK-0001PG-31; Thu, 12 Jan 2023 14:13:12 +0100 Date: Thu, 12 Jan 2023 14:13:12 +0100 From: Johan Hovold To: Sebastian Andrzej Siewior 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=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org On Mon, Jan 09, 2023 at 11:13:15AM +0100, Sebastian Andrzej Siewior wrote: > 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. Yeah, that not being documented seems like an oversight as generally drivers should not need be changed to continue working on PREEMPT_RT (or with forced-threading generally). > 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). All interrupt handlers typically run in hard interrupt context unless explicitly requested to be threaded on !RT and drivers still use spinlock_t for that so not sure how that lockdep warning is supposed to work. Or do you mean that you have a lockdep warning specifically for IRQF_ONESHOT primary handlers? > > 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. The author did not seem to think this was stable material as there is no cc-stable tag and it also seems fairly intrusive. But if the ST guys or whoever cares about this driver are fine with this being backported, I don't really mind either. Johan 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 D60A4C54EBC for ; Thu, 12 Jan 2023 13:14:24 +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=RWF2r+IBZpWkYkRx3yGUurK815AUPQXN4rOV+9M/JoY=; b=ZXCicANCeeVPGz iOPS0XWi2HVo9HEhWx1JNOA2CCh8khgFPMfuQkoZlufyADTerVTtJ5d8hhTHrL/YQ8MjUdAQsOLRF Q13quWFao3YEZsm6ZvdBJUayjYnsUsD7VseVDVJvL60E3k3rgluae7C61txgltvc7BfF6N//l0760 t9XxagRg/TmG11kkJ8YS4styGTraJZXJT9zv7+KV+DQWWydB+t7CPf2nGmzPg2uHb2OIYskFZMmDD VsQ37+jvnXGXaXWEc14yVkdZwaaK8oWTg9tntPa+NsS2zI9hi2lTwbVAs/u9Wgema1XuhEP++pLQE +toeZGtbaJ2fEESZu+rQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pFxOI-00F6GV-C4; Thu, 12 Jan 2023 13:13:10 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pFxOE-00F6G0-VH for linux-arm-kernel@lists.infradead.org; Thu, 12 Jan 2023 13:13:08 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 6052760AB9; Thu, 12 Jan 2023 13:13:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B4369C433EF; Thu, 12 Jan 2023 13:13:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1673529185; bh=71WCD2LYTHvB/FQ8+vaLVwWxU8IB40Qvo5Km4Lbz8Pk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=RqxufPvOzIAyPAnyGVSCFxgrAu7uNssmK+q7P829ela4qcXC26u08NKHCi5sUk376 cP1evOZfOInZku9T5QpMqwczl1hjlQoc0EJhbBUFdpzFn0GqW2n22a3wXiQ1NdYd90 Bhf7ef8TW3NfA/tMHH0vGcekWbD3GidLKF9USZ2tyDPKRSS2gmS5/MvbH+9yKtiCsm qQWCQ5hjZq6juAcP5FZjLndLsDgWsXMHRYa8y97d+ScJOd3v/Es9dyk9qtQUxOdcUX lKZG9ScSWtu0xuOZHDzxRLXTcONyBrQt1dbrXghuGzaIDhDzaf+WuG1J5kHOQuv/Us 97OREQoWnPhng== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pFxOK-0001PG-31; Thu, 12 Jan 2023 14:13:12 +0100 Date: Thu, 12 Jan 2023 14:13:12 +0100 From: Johan Hovold To: Sebastian Andrzej Siewior 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-20230112_051307_107439_8306ED30 X-CRM114-Status: GOOD ( 32.40 ) 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 Mon, Jan 09, 2023 at 11:13:15AM +0100, Sebastian Andrzej Siewior wrote: > 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. Yeah, that not being documented seems like an oversight as generally drivers should not need be changed to continue working on PREEMPT_RT (or with forced-threading generally). > 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). All interrupt handlers typically run in hard interrupt context unless explicitly requested to be threaded on !RT and drivers still use spinlock_t for that so not sure how that lockdep warning is supposed to work. Or do you mean that you have a lockdep warning specifically for IRQF_ONESHOT primary handlers? > > 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. The author did not seem to think this was stable material as there is no cc-stable tag and it also seems fairly intrusive. But if the ST guys or whoever cares about this driver are fine with this being backported, I don't really mind either. Johan _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel