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 1CE2AC636CC for ; Tue, 7 Feb 2023 09:18:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231479AbjBGJSa (ORCPT ); Tue, 7 Feb 2023 04:18:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59012 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231501AbjBGJSV (ORCPT ); Tue, 7 Feb 2023 04:18:21 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 83BC03801F for ; Tue, 7 Feb 2023 01:18:03 -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 1DBB261234 for ; Tue, 7 Feb 2023 09:18:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0D5FDC433EF; Tue, 7 Feb 2023 09:18:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1675761482; bh=axGVPs31pXQd7TP6kgbSp+0AEtwjTtUAN+LmWMroZFk=; h=Subject:To:Cc:From:Date:From; b=nz91AczqK3A4E2eltDeCg9Qxzx9i6mZBz5jGgmdBtA/ULdXaIsE4TO7x6cR2Ec14S xy5m1XzW2nxxFxR3J4Rfh2Q2rQUyqs0Jwz8Hrva2YaYeAvf7FlM3x9TdpBvgSJDIO6 4toFbCZCSDUjYCZliVADcWslVtih1a8zRP3fXr54= Subject: FAILED: patch "[PATCH] serial: stm32: Merge hard IRQ and threaded IRQ handling into" failed to apply to 5.10-stable tree To: marex@denx.de, bigeasy@linutronix.de, gregkh@linuxfoundation.org, valentin.caron@foss.st.com Cc: From: Date: Tue, 07 Feb 2023 10:17:51 +0100 Message-ID: <16757614716686@kroah.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org The patch below does not apply to the 5.10-stable tree. If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to . Possible dependencies: 3f6c02fa712b ("serial: stm32: Merge hard IRQ and threaded IRQ handling into single IRQ handler") 6333a4850621 ("serial: stm32: push DMA RX data before suspending") 6eeb348c8482 ("serial: stm32: terminate / restart DMA transfer at suspend / resume") e0abc903deea ("serial: stm32: rework RX dma initialization and release") d1ec8a2eabe9 ("serial: stm32: update throttle and unthrottle ops for dma mode") 33bb2f6ac308 ("serial: stm32: rework RX over DMA") cc58d0a3f0a4 ("serial: stm32: re-introduce an irq flag condition in usart_receive_chars") 59bd4eedf118 ("serial: stm32: use the defined variable to simplify code") a7770a4bfcf4 ("serial: stm32: defer probe for dma devices") cea37afd28f1 ("serial: stm32: defer sysrq processing") e359b4411c28 ("serial: stm32: fix threaded interrupt handling") 3d530017bef1 ("serial: stm32: update wakeup IRQ management") c0f3332cb5f2 ("serial: stm32: clean wakeup handling in serial_suspend") 1631eeeaf084 ("serial: stm32: rework wakeup management") 9f77d19207a0 ("serial: stm32: add FIFO flush when port is closed") 12761869f0ef ("serial: stm32: fix wake-up flag handling") ad7676812437 ("serial: stm32: fix a deadlock condition with wakeup event") 25a8e7611da5 ("serial: stm32: fix TX and RX FIFO thresholds") f4518a8a75f5 ("serial: stm32: fix startup by enabling usart for reception") 87fd0741d6dc ("serial: stm32: fix probe and remove order for dma") thanks, greg k-h ------------------ original commit in Linus's tree ------------------ >From 3f6c02fa712bd453871877fe1d1969625617471e Mon Sep 17 00:00:00 2001 From: Marek Vasut Date: Fri, 20 Jan 2023 17:03:32 +0100 Subject: [PATCH] serial: stm32: Merge hard IRQ and threaded IRQ handling into single IRQ handler 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") Reviewed-by: Sebastian Andrzej Siewior Tested-by: Valentin Caron # V3 Signed-off-by: Marek Vasut Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/20230120160332.57930-1-marex@denx.de Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/tty/serial/stm32-usart.c b/drivers/tty/serial/stm32-usart.c index a1490033aa16..409e91d6829a 100644 --- a/drivers/tty/serial/stm32-usart.c +++ b/drivers/tty/serial/stm32-usart.c @@ -797,25 +797,11 @@ static irqreturn_t stm32_usart_interrupt(int irq, void *ptr) spin_unlock(&port->lock); } - if (stm32_usart_rx_dma_enabled(port)) - return IRQ_WAKE_THREAD; - else - return IRQ_HANDLED; -} - -static irqreturn_t stm32_usart_threaded_interrupt(int irq, void *ptr) -{ - struct uart_port *port = ptr; - struct tty_port *tport = &port->state->port; - struct stm32_port *stm32_port = to_stm32_port(port); - unsigned int size; - unsigned long flags; - /* Receiver timeout irq for DMA RX */ - if (!stm32_port->throttled) { - spin_lock_irqsave(&port->lock, flags); + if (stm32_usart_rx_dma_enabled(port) && !stm32_port->throttled) { + spin_lock(&port->lock); size = stm32_usart_receive_chars(port, false); - uart_unlock_and_check_sysrq_irqrestore(port, flags); + uart_unlock_and_check_sysrq(port); if (size) tty_flip_buffer_push(tport); } @@ -1015,10 +1001,8 @@ static int stm32_usart_startup(struct uart_port *port) u32 val; int ret; - ret = request_threaded_irq(port->irq, stm32_usart_interrupt, - stm32_usart_threaded_interrupt, - IRQF_ONESHOT | IRQF_NO_SUSPEND, - name, port); + ret = request_irq(port->irq, stm32_usart_interrupt, + IRQF_NO_SUSPEND, name, port); if (ret) return ret; @@ -1601,13 +1585,6 @@ static int stm32_usart_of_dma_rx_probe(struct stm32_port *stm32port, struct dma_slave_config config; int ret; - /* - * Using DMA and threaded handler for the console could lead to - * deadlocks. - */ - if (uart_console(port)) - return -ENODEV; - stm32port->rx_buf = dma_alloc_coherent(dev, RX_BUF_L, &stm32port->rx_dma_buf, GFP_KERNEL);