From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C78BF148319; Tue, 25 Jun 2024 10:00:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719309603; cv=none; b=AUIAW+/lDpIdy9c0FOFWnZVbNs4jdGtlnPElD3B/TPVTFA3j6sIOwbwUjrvsnbyf7TzwUPNtjRZdAdgbeN22qFO9TBHkRcv5lNC54BMbztCxIWXvS90AdPr37VI4+m9xpDkV9NZL0nZ6WO6NzpmWIbdGm8Azed8bCBuOJus58uY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719309603; c=relaxed/simple; bh=JQcnbqAMC4ZHSNO4ZaUpOJdycZVzOBHoYrGT6L/Fx8k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=F6PunLL4bWsisZ7iaVlp2vgrzYrgZ59wrBvnZWiRuzkeNen+Q6wIZXnzthbT7kDpqdjEo/htjBmT+ZawS9I9o2yxdxRxs/zAszAJueBaazih5MlUTXtHguDmhImNkiEYKgs9xHKyaubSQu0J388zz+3r90vQnCtHvQcCBSoWwIg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=gMepwnP9; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="gMepwnP9" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C8534C32781; Tue, 25 Jun 2024 10:00:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1719309603; bh=JQcnbqAMC4ZHSNO4ZaUpOJdycZVzOBHoYrGT6L/Fx8k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gMepwnP9sbObQd+u1w/3eO6StTzlBAGYJ9TLurISiqJZ80o2mIkQi9KhH8Ml7h0MT LUADR6ofvK0kCkX2hC0Q+yQ4i8V/CnvX6keu3lXRZU/GRPHQkbvFNWEVi9+qI0Hgil QK9BWF7Ua2VsFwfyDodYpegh4rI53vGfRtneSF6s= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Esben Haabendal , Marc Kleine-Budde , Sasha Levin Subject: [PATCH 6.1 041/131] serial: imx: Introduce timeout when waiting on transmitter empty Date: Tue, 25 Jun 2024 11:33:16 +0200 Message-ID: <20240625085527.513868844@linuxfoundation.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240625085525.931079317@linuxfoundation.org> References: <20240625085525.931079317@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Esben Haabendal [ Upstream commit e533e4c62e9993e62e947ae9bbec34e4c7ae81c2 ] By waiting at most 1 second for USR2_TXDC to be set, we avoid a potential deadlock. In case of the timeout, there is not much we can do, so we simply ignore the transmitter state and optimistically try to continue. Signed-off-by: Esben Haabendal Acked-by: Marc Kleine-Budde Link: https://lore.kernel.org/r/919647898c337a46604edcabaf13d42d80c0915d.1712837613.git.esben@geanix.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/tty/serial/imx.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c index 573bf7e9b7978..b20abaa9ef150 100644 --- a/drivers/tty/serial/imx.c +++ b/drivers/tty/serial/imx.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include @@ -2028,7 +2029,7 @@ imx_uart_console_write(struct console *co, const char *s, unsigned int count) struct imx_port *sport = imx_uart_ports[co->index]; struct imx_port_ucrs old_ucr; unsigned long flags; - unsigned int ucr1; + unsigned int ucr1, usr2; int locked = 1; if (sport->port.sysrq) @@ -2059,8 +2060,8 @@ imx_uart_console_write(struct console *co, const char *s, unsigned int count) * Finally, wait for transmitter to become empty * and restore UCR1/2/3 */ - while (!(imx_uart_readl(sport, USR2) & USR2_TXDC)); - + read_poll_timeout_atomic(imx_uart_readl, usr2, usr2 & USR2_TXDC, + 0, USEC_PER_SEC, false, sport, USR2); imx_uart_ucrs_restore(sport, &old_ucr); if (locked) -- 2.43.0