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 DF6EEC54EBD for ; Thu, 12 Jan 2023 16:40:06 +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-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:From:References:Cc:To:Subject: MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=l9EGpurLzfvElyGeunE9x9u3Dt9bsvtivhU/Ym3dl4w=; b=rgjElsaB5Z2CDL jhC3uBNXn5OmixhcsJ6zJpf/lRF9QYDWJ5xbn3DwH/meDFFZqGHfNKIb21EVG+Bpcq5W4fr+95v95 DKESDPSVqCVhLNtFxTsSASdTPNSJh/jNqtxb8GBytG+nYRe39TWsS6SwS/Re2ufqu2a32WWFDHH7W actv7zCuHFt77K2uWGV+r0nNugcl2QiQuehO7Sj7lilsmvk23lzsZBxpJ8AXsFOZZRX8iZPTopm6I Zu9lAf51s92ZCCHC2Co+phQaRFvmN0MQMj96hbChxUpnBpooX8fKZMWdMIZixsEo0h2qVxsHWoYK5 pnOsfylD+sO+FsuT9xSw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pG0bU-00Fsmc-Gc; Thu, 12 Jan 2023 16:39:00 +0000 Received: from phobos.denx.de ([85.214.62.61]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pG0bN-00Fsjg-Dm for linux-arm-kernel@lists.infradead.org; Thu, 12 Jan 2023 16:38:56 +0000 Received: from [127.0.0.1] (p578adb1c.dip0.t-ipconnect.de [87.138.219.28]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: marex@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id 5B5F680CB0; Thu, 12 Jan 2023 17:38:49 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1673541530; bh=4f4T7bt3j8qj7FQzMPy1igU/EfnhB12Tggy+VjN0tmI=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=R4v8PDRRR7HBH5GHlxkBZOlCTLuS4eDI1P1nA5VlwoVAfC6+22eESTJYM6OihXPN/ HQ7670gY0hT5IF3yoQwykY8epoV9z/IxQQmPQyx67XMJecAlWMFHvVtaj4MieebrEz NSeNxLuAhZX3T6QepWHMXCqyEHo8DIqJ2yge2wpf0BcWl2g+p2IDfIA03Iuzy8E+TU ZbGqcDvy3AyugzXOl/mjRahpxjKtb0GH6ZzK8+kdtPrHhRIkmh38VU8AkvdC8/MB+t bsgvOVmDfHfRpKmeVAf8yWD5FHAequdlkOLWH8z0HEGhkDWARnHQlB6JHWM+CkiwSl +UbqTHxSmoV7A== Message-ID: <78e3f61f-4f87-9ac5-7c7c-172714da69d3@denx.de> Date: Thu, 12 Jan 2023 17:38:48 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.6.0 Subject: Re: [PATCH v3] serial: stm32: Merge hard IRQ and threaded IRQ handling into single IRQ handler Content-Language: en-US To: Johan Hovold , Sebastian Andrzej Siewior Cc: 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 References: <20221216115338.7150-1-marex@denx.de> From: Marek Vasut In-Reply-To: X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230112_083855_122709_4863FC1B X-CRM114-Status: GOOD ( 28.49 ) 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-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 1/12/23 14:13, Johan Hovold wrote: > 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. The author does not have enough experience with preempt-rt to make that determination, hence deferred to Sebastian for better judgement. > But if the ST guys or whoever cares about this driver are fine with this > being backported, I don't really mind either. [...] _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel 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 E5F44C6379F for ; Thu, 12 Jan 2023 16:52:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240694AbjALQw5 (ORCPT ); Thu, 12 Jan 2023 11:52:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34292 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241109AbjALQs6 (ORCPT ); Thu, 12 Jan 2023 11:48:58 -0500 Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A88045C1D9 for ; Thu, 12 Jan 2023 08:39:04 -0800 (PST) Received: from [127.0.0.1] (p578adb1c.dip0.t-ipconnect.de [87.138.219.28]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: marex@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id 5B5F680CB0; Thu, 12 Jan 2023 17:38:49 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1673541530; bh=4f4T7bt3j8qj7FQzMPy1igU/EfnhB12Tggy+VjN0tmI=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=R4v8PDRRR7HBH5GHlxkBZOlCTLuS4eDI1P1nA5VlwoVAfC6+22eESTJYM6OihXPN/ HQ7670gY0hT5IF3yoQwykY8epoV9z/IxQQmPQyx67XMJecAlWMFHvVtaj4MieebrEz NSeNxLuAhZX3T6QepWHMXCqyEHo8DIqJ2yge2wpf0BcWl2g+p2IDfIA03Iuzy8E+TU ZbGqcDvy3AyugzXOl/mjRahpxjKtb0GH6ZzK8+kdtPrHhRIkmh38VU8AkvdC8/MB+t bsgvOVmDfHfRpKmeVAf8yWD5FHAequdlkOLWH8z0HEGhkDWARnHQlB6JHWM+CkiwSl +UbqTHxSmoV7A== Message-ID: <78e3f61f-4f87-9ac5-7c7c-172714da69d3@denx.de> Date: Thu, 12 Jan 2023 17:38:48 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.6.0 Subject: Re: [PATCH v3] serial: stm32: Merge hard IRQ and threaded IRQ handling into single IRQ handler Content-Language: en-US To: Johan Hovold , Sebastian Andrzej Siewior Cc: 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 References: <20221216115338.7150-1-marex@denx.de> From: Marek Vasut In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org On 1/12/23 14:13, Johan Hovold wrote: > 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. The author does not have enough experience with preempt-rt to make that determination, hence deferred to Sebastian for better judgement. > But if the ST guys or whoever cares about this driver are fine with this > being backported, I don't really mind either. [...]