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 6DF1BC352A1 for ; Wed, 7 Dec 2022 08:17:08 +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=0jdrE6KYGNTVABuSj9U88mrM9tDR461mAqKmYKRyk+s=; b=MKSCo8DveFX78x XHxsL6VnW+tMPZt94pydlLh2OUmFTRTxe908piQUrXPRlG3Fj36M2bzk/33WvCKPurC4WgWWQjhld ig/eik9AFhs1pEqaXXrbF2W4uyTiN5m+a90NhEo/NBIcT3TqidK1H3ys9ZTW4kfxzokleFTccIiX6 m+DQDisM7lvruSP4mPW0l0zucROa8Xzmmc5RBT08+ryK1wDYqthC4q62H3bP/9ZOJllA5YsZkd9SR bh0oiSJ8SetK2aXZnPAHaVT1x7C5aHZ2EwTcuEVmH/XSKKr4nlUCx8zCsusZLQymf7lMmdxl63e/m X7KuPA+CYTZUeY7JfIAQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1p2pb1-00Ernh-V6; Wed, 07 Dec 2022 08:16:04 +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 1p2paz-00Erkn-0S for linux-arm-kernel@lists.infradead.org; Wed, 07 Dec 2022 08:16:02 +0000 Date: Wed, 7 Dec 2022 09:15:56 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1670400958; 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=BRTqQIJG6VmpHsSpAsrO/dqie52AxWXZS7m5EVogHko=; b=Dg2L5StYii/bkRJjVW5VLoYOX/guI0k9RiBChN882sb7n/TvQEvK4z1/foDw9zXaCVUE1+ aAIQlkzAhDYLSTZM4QBe0DSGy5aqu3ofcaIIPCN98ATCC8V7MkNTnv1wipU1H48Jn4YUWk x9HyOnvUcHb+0A2jnVVEfQMyDw0m+eauR4l16BkCa0LnoKLp2igX1mhZmUeyn5iY9Kpfzs JOwKIMEvedThQCpXiLgLgQ0TRwwD/2LoNkTJKycx9Ig7/oqPk86SFmJgcUsZYu4m2tLvWd dyvxcrxyq7OfWJtJ7jmzKhJdisZhdCd1fBhL+i52Wmomt0EjEbtRMY/AWxzxSw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1670400958; 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=BRTqQIJG6VmpHsSpAsrO/dqie52AxWXZS7m5EVogHko=; b=OBUz/6xwc1/bzheByQFN4VcWwgJQHTd2A3UXS2PNhpXJFZVMgDJfyAqHRJdGj2OwwyhJK5 NmzZyokcnIpNkCAQ== From: Sebastian Andrzej Siewior To: Marek Vasut Cc: linux-serial@vger.kernel.org, Alexandre Torgue , Erwan Le Ray , Greg Kroah-Hartman , Jean Philippe Romain , Jiri Slaby , Maxime Coquelin , Thomas Gleixner , Valentin Caron , linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com Subject: Re: [PATCH] [RFC] serial: stm32: Move stm32_usart_transmit_chars() to interrupt thread Message-ID: References: <20221207013012.395585-1-marex@denx.de> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20221207013012.395585-1-marex@denx.de> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221207_001601_215372_3D51DDE6 X-CRM114-Status: GOOD ( 18.79 ) 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-07 02:30:12 [+0100], Marek Vasut wrote: > Avoid locking in hard interrupt context, move the stm32_usart_transmit_chars() > into the threaded IRQ handler. This fixes the following splat with preempt-rt: > > BUG: scheduling while atomic: (mount)/1289/0x00010001 > Modules linked in: > Preemption disabled at: > [] irq_enter_rcu+0xb/0x42 > CPU: 0 PID: 1289 Comm: (mount) Not tainted 6.1.0-rc7-rt5-stable-standard-00006-gd70aeccb9f0f #17 > Hardware name: STM32 (Device Tree Support) > unwind_backtrace from show_stack+0xb/0xc > show_stack from dump_stack_lvl+0x2b/0x34 > dump_stack_lvl from __schedule_bug+0x53/0x80 > __schedule_bug from __schedule+0x47/0x404 > __schedule from schedule_rtlock+0x15/0x34 > schedule_rtlock from rtlock_slowlock_locked+0x1d7/0x57e > rtlock_slowlock_locked from rt_spin_lock+0x29/0x3c > rt_spin_lock from stm32_usart_interrupt+0xa9/0x110 > stm32_usart_interrupt from __handle_irq_event_percpu+0x73/0x14e > __handle_irq_event_percpu from handle_irq_event_percpu+0x9/0x22 > handle_irq_event_percpu from handle_irq_event+0x53/0x76 > handle_irq_event from handle_fasteoi_irq+0x65/0xa8 > handle_fasteoi_irq from handle_irq_desc+0xf/0x18 > handle_irq_desc from gic_handle_irq+0x45/0x54 > gic_handle_irq from generic_handle_arch_irq+0x19/0x2c > generic_handle_arch_irq from call_with_stack+0xd/0x10 > > Signed-off-by: Marek Vasut > --- > Cc: Alexandre Torgue > Cc: Erwan Le Ray > Cc: Greg Kroah-Hartman > Cc: Jean Philippe Romain > Cc: Jiri Slaby > Cc: Maxime Coquelin > Cc: Sebastian Andrzej Siewior > Cc: Thomas Gleixner > Cc: Valentin Caron > Cc: linux-arm-kernel@lists.infradead.org > Cc: linux-stm32@st-md-mailman.stormreply.com > To: linux-serial@vger.kernel.org > --- > drivers/tty/serial/stm32-usart.c | 19 +++++++++++++------ > 1 file changed, 13 insertions(+), 6 deletions(-) > > diff --git a/drivers/tty/serial/stm32-usart.c b/drivers/tty/serial/stm32-usart.c > index a1490033aa164..56357a7962edc 100644 > --- a/drivers/tty/serial/stm32-usart.c > +++ b/drivers/tty/serial/stm32-usart.c > @@ -791,11 +791,8 @@ static irqreturn_t stm32_usart_interrupt(int irq, void *ptr) > } > } Why is this handler running as the primary handler to begin with? There is stm32_usart_rs485_rts_disable() -> mctrl_gpio_set() -> gpiod_set_array_value() -> gpiod_set_array_value_complex() -> gpio_chip_set_multiple() -> gc->set_multiple() || gc->set() ? -> bitmap_alloc() boom I don't know if the underlying gpiod is always using a raw_spinlock_t but that bitmap_alloc() (depending on FASTPATH_NGPIO()) is not going to work. pm_wakeup_dev_event() is also using a spinlock_t. > - if ((sr & USART_SR_TXE) && !(stm32_port->tx_ch)) { > - spin_lock(&port->lock); > - stm32_usart_transmit_chars(port); > - spin_unlock(&port->lock); > - } > + if ((sr & USART_SR_TXE) && !(stm32_port->tx_ch)) > + return IRQ_WAKE_THREAD; Before that, there is a "stm32_port->throttled" check using the very same lock. > if (stm32_usart_rx_dma_enabled(port)) > return IRQ_WAKE_THREAD; Sebastian _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel