Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp408099ybb; Wed, 25 Mar 2020 02:08:19 -0700 (PDT) X-Google-Smtp-Source: ADFU+vtu5wk+cYo9KVJEbgiyNQAvORKU5tL1pBd/NorEAfMQUlO6tjlFnCe94Y7Ktvdj4IUAI/Cc X-Received: by 2002:a9d:7f05:: with SMTP id j5mr1737808otq.312.1585127299535; Wed, 25 Mar 2020 02:08:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585127299; cv=none; d=google.com; s=arc-20160816; b=vIwrzniZLQMBR6MQCuku68HiuBOsbEh6qcLFLkP/cjbU5t2AwaEcEe/xn3zYfwv1NE tdDSOL8TZZSyKlIB/RUt+zq28xFGvmxhjoYAe2EQn9E+0VXEontwMNvYaTXbaswuN68E THCC17/xMpMx9vrGPvPyIz5Ysr6P4SKrgoNHvvaWlwOPa6ss5yJZqntr0du934/UHCj6 k1MSTa15/zni0UswOfeI5+Egt/YHOJCDbIt4WEB8ouIHH+V7f7E9C23U1pbIyVpxMS2y 4Y9yDN7tHu2XgJd666q1gndJRww8hhLFgtRZ9jozO7skQrvR+S5YCDcB/C/HtDmz+5V7 H8DA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=IsTTS0WBXuzG7rVz9eYl2v2OdWYP4Urtsy+pv/WCNv4=; b=DB8ZVuhqa9YVnLVhL2zGu3dwbPbqDQJh40rGGmH97mmcwwWPjNU5bidN6Sql1HaZvm TujRBOZKTRFMjI0DlZPjoE8a7kZZSRY7zkl7Lch0l0JVlFc6j/3GInGkPKFvne+nLH2G QKiK2y8OvtUDcqcWlWxOGVDr7hbZVBC6FQsBJSErl4q2hq/pZg6tAoq+4qq5haSQYI0V VyFXxkc3IallvlSDw4ZMrtabDZ25WQ+KZe2++Ig3tuiNfb7QmGXfbYUR0Wb98wF/gfwA GzYEjNTfawXh7K+5fwcAKCvIjUnvW8rNwHiYMJJEC27q2lv2+dDq4eKh7bl20yrka7fP 0ILw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2016061301 header.b=mQ83xjso; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r6si97196oij.49.2020.03.25.02.08.06; Wed, 25 Mar 2020 02:08:19 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2016061301 header.b=mQ83xjso; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727417AbgCYJHK (ORCPT + 99 others); Wed, 25 Mar 2020 05:07:10 -0400 Received: from ssl.serverraum.org ([176.9.125.105]:49625 "EHLO ssl.serverraum.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725873AbgCYJHK (ORCPT ); Wed, 25 Mar 2020 05:07:10 -0400 Received: from apollo.fritz.box (unknown [IPv6:2a02:810c:c200:2e91:6257:18ff:fec4:ca34]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by ssl.serverraum.org (Postfix) with ESMTPSA id A613F231D9; Wed, 25 Mar 2020 10:07:07 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2016061301; t=1585127228; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=IsTTS0WBXuzG7rVz9eYl2v2OdWYP4Urtsy+pv/WCNv4=; b=mQ83xjso+xWAbE+9xXZuv8P/T65lEKPvtZzkCm5zsi9JSOZM/UN++lrgUFzohClh1gWanB OqdX69Je8TUKqt6DiHGIy4zGr/MIjB9lPK8HlRQW41E+VbCE9Zc80fgbTJR40G18HSpvlg 6+7O4zx1TekzQiun3Nmb1cSasY13UgI= From: Michael Walle To: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Jiri Slaby , Greg Kroah-Hartman , Andy Duan , Michael Walle , Leonard Crestez Subject: [PATCH v2 1/2] tty: serial: fsl_lpuart: move dma_request_chan() Date: Wed, 25 Mar 2020 10:06:57 +0100 Message-Id: <20200325090658.25967-1-michael@walle.cc> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spamd-Bar: ++++ X-Spam-Level: **** X-Rspamd-Server: web X-Spam-Status: No, score=4.90 X-Spam-Score: 4.90 X-Rspamd-Queue-Id: A613F231D9 X-Spamd-Result: default: False [4.90 / 15.00]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; R_MISSING_CHARSET(2.50)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; NEURAL_SPAM(0.00)[0.154]; BROKEN_CONTENT_TYPE(1.50)[]; DKIM_SIGNED(0.00)[]; RCPT_COUNT_SEVEN(0.00)[7]; MID_CONTAINS_FROM(1.00)[]; RCVD_COUNT_ZERO(0.00)[0]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:31334, ipnet:2a02:810c:8000::/33, country:DE] Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Move dma_request_chan() out of the atomic context. First this call should not be in the atomic context at all and second the dev_info_once() may cause a hang because because the console takes this spinlock, too. Fixes: 159381df1442f ("tty: serial: fsl_lpuart: fix DMA operation when using IOMMU") Reported-by: Leonard Crestez Signed-off-by: Michael Walle --- changes since v1: - instead of just moving the dev_info_once() out of the spinlock protected section, move the whole dma_request_chan(). Thanks Andy! I've tested this on my board. Andy, Leonard, can you double check it? For all which are not aware, this deadlock happens only if you have the kernel console output on the lpuart, so if someone wants to test it, make sure you have something like console=ttyLP0,115200. drivers/tty/serial/fsl_lpuart.c | 36 +++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpuart.c index 9c6a018b1390..131018979b77 100644 --- a/drivers/tty/serial/fsl_lpuart.c +++ b/drivers/tty/serial/fsl_lpuart.c @@ -1510,20 +1510,33 @@ static void rx_dma_timer_init(struct lpuart_port *sport) add_timer(&sport->lpuart_timer); } -static void lpuart_tx_dma_startup(struct lpuart_port *sport) +static void lpuart_request_dma(struct lpuart_port *sport) { - u32 uartbaud; - int ret; - sport->dma_tx_chan = dma_request_chan(sport->port.dev, "tx"); if (IS_ERR(sport->dma_tx_chan)) { dev_info_once(sport->port.dev, "DMA tx channel request failed, operating without tx DMA (%ld)\n", PTR_ERR(sport->dma_tx_chan)); sport->dma_tx_chan = NULL; - goto err; } + sport->dma_rx_chan = dma_request_chan(sport->port.dev, "rx"); + if (IS_ERR(sport->dma_rx_chan)) { + dev_info_once(sport->port.dev, + "DMA rx channel request failed, operating without rx DMA (%ld)\n", + PTR_ERR(sport->dma_rx_chan)); + sport->dma_rx_chan = NULL; + } +} + +static void lpuart_tx_dma_startup(struct lpuart_port *sport) +{ + u32 uartbaud; + int ret; + + if (!sport->dma_tx_chan) + goto err; + ret = lpuart_dma_tx_request(&sport->port); if (!ret) goto err; @@ -1549,14 +1562,8 @@ static void lpuart_rx_dma_startup(struct lpuart_port *sport) { int ret; - sport->dma_rx_chan = dma_request_chan(sport->port.dev, "rx"); - if (IS_ERR(sport->dma_rx_chan)) { - dev_info_once(sport->port.dev, - "DMA rx channel request failed, operating without rx DMA (%ld)\n", - PTR_ERR(sport->dma_rx_chan)); - sport->dma_rx_chan = NULL; + if (!sport->dma_rx_chan) goto err; - } ret = lpuart_start_rx_dma(sport); if (ret) @@ -1592,6 +1599,8 @@ static int lpuart_startup(struct uart_port *port) sport->rxfifo_size = UARTFIFO_DEPTH((temp >> UARTPFIFO_RXSIZE_OFF) & UARTPFIFO_FIFOSIZE_MASK); + lpuart_request_dma(sport); + spin_lock_irqsave(&sport->port.lock, flags); lpuart_setup_watermark_enable(sport); @@ -1649,11 +1658,12 @@ static int lpuart32_startup(struct uart_port *port) sport->port.fifosize = sport->txfifo_size; } + lpuart_request_dma(sport); + spin_lock_irqsave(&sport->port.lock, flags); lpuart32_setup_watermark_enable(sport); - lpuart_rx_dma_startup(sport); lpuart_tx_dma_startup(sport); -- 2.20.1