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 8CF9D149C69; Tue, 25 Jun 2024 09:38:44 +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=1719308324; cv=none; b=KgwXQu/W2WmtcFHtiC9xWfUk2Vx7m9l4MUmDHR0Sa3SUd1Vy2uIaoULy1JnCjRPalKt45RQxQcZg6GPXt0a+nN9BBKpeiubU6pong4PmJiuSy7PeCYklval47SbRyWnZkDpGArGTHof0ql03vqY9DMj4uv4W4Slf5aXfNEKNWCU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719308324; c=relaxed/simple; bh=fslLtjncbvaVah3fEWyZrmWfy4Cjyb+nelceovG15e0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lyFDJjZj//52j2qtfajA4ucfY4UhXEZZB1IqAAQq/K8h65J3BCobOgWCAYlzw18X9d0SAhN6Ezq0FB6tr6cUz9gZ6cT49JC4zGJX1ttzCuZaMHqeah9EiHVMy+7TY6uFyQ3ZVJ80IEuZBuaNKXQS1+pths8MGDhbkC2VcBgK+yM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=XeZv+i4/; 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="XeZv+i4/" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B7BBFC32781; Tue, 25 Jun 2024 09:38:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1719308324; bh=fslLtjncbvaVah3fEWyZrmWfy4Cjyb+nelceovG15e0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XeZv+i4/Y2cozNWusTygLoBfgt2zPGXsdfMXXv3tKbaVOAo672Cgj9fyC7Qoo/YSr x3uv7sptUINfY6cA3fz9nau4yJLzC1SoMGahGUYKticVWS0h4WtSKl00rwNVqV+ipU WNfAalaLGUKyvTV6ddS/IjDKIdyBqI6OX6IVsTLE= 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.9 082/250] serial: imx: Introduce timeout when waiting on transmitter empty Date: Tue, 25 Jun 2024 11:30:40 +0200 Message-ID: <20240625085551.212809255@linuxfoundation.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240625085548.033507125@linuxfoundation.org> References: <20240625085548.033507125@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.9-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 e148132506161..09c1678ddfd49 100644 --- a/drivers/tty/serial/imx.c +++ b/drivers/tty/serial/imx.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include @@ -2010,7 +2011,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) @@ -2041,8 +2042,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