Received: by 2002:ab2:6d45:0:b0:1fb:d597:ff75 with SMTP id d5csp262552lqr; Wed, 5 Jun 2024 05:34:56 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUh+7mCamK6whhzPkUDOTttBBPjUwhRM19mEAOxk8TKE5OfTpE9h5HRHpDyRtHQlkkeSPRMx3nM+p98IY8BYdXGQwUZrJYcGVxfMdv6gg== X-Google-Smtp-Source: AGHT+IFxT35wTPY8uivpRogDH11mQ4GYQ6EZNFKDLkw/8hcRafjGTBXLYf0SZs7km11kkmvKfVLI X-Received: by 2002:a17:902:eb8f:b0:1f3:dd7:ad42 with SMTP id d9443c01a7336-1f6a5867802mr25242755ad.0.1717590896087; Wed, 05 Jun 2024 05:34:56 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717590896; cv=pass; d=google.com; s=arc-20160816; b=mVkdIFLk8Ww2WEMIf5S7WtFeV3/F8/kjqOx9j61Cp/fI0XsYvIGFtNaaZ1nxD03Y3C EtOjya6K9Xq4SRZDIWmMMD5mVSDIQ0nGnLqybWOFLuIxaPA6MPohzfr5qx4UiFImcb+P LIZEwEuVIXy9ZDEB/q3/oYqi96C1iUKGDN4oNmEGDzAgkSXo8T3ijDfKQfmXk0wLsDNo ezKXuxNyrOyvIG1gyJ/9Q30/YL0uSyYYXnixie4aJ8MxboijF15unKEur0L3cwOTdIQA uUQ4xvtEBmix2ZpY/2heAIJA29kZG82RewfKtsc9hQ7rpOvjxt4hrcit/XvWczQP146W 7TYw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=CDFRlfJibGETwGw/3TVvlEGUJbpyg7L5raWP8m0z/L0=; fh=3z5TlaiSiuwAEMGTqfN0NsbpMndBwtkI/kmLtcIcX+U=; b=Yur+8oafxuOVM2qpMJ44tDX43Kj94DEP71j5VSSdWBGDrWeUbb1coAVTb6XbjMiuBW yRUzE2Wts+ufANPPlX0Pqxxk1MQ+R/9j6LRA6DADlMha+Q0azaqF6TK+CKo2c07X/5jW pkRAdM0qV8haBpTXxX7hUfM0gvvnImJHZfs52qDVZJrNbknKSZB9hLad5Ug1c2qeVrSm 8oDSvHu766nHPHtrCaRs1FlN2VRrWdiGwmwPiWh78ONY0tuHfyX0RbSygMYZhazm2eH/ llPOqYE7M7o+zbeMpR7a3UPEA4VYmWunzqqQD+uvSOZOf1PzvM25utSEgAPg9TiOGc2n MZgg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=DEqjDiQ9; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-202366-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-202366-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id d9443c01a7336-1f6607e4f90si68471025ad.26.2024.06.05.05.34.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 05:34:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-202366-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=DEqjDiQ9; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-202366-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-202366-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 7649028A278 for ; Wed, 5 Jun 2024 12:07:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0134A1AC447; Wed, 5 Jun 2024 11:52:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="DEqjDiQ9" 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 209581ACAED; Wed, 5 Jun 2024 11:52:50 +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=1717588370; cv=none; b=DJ9QNGa31vrwewA2iGjD9zJF5bF9n8n0TaZ/AqzbGqJ3eYHc9BmgJEeG6F7EJPLArvPtG5ND7Q+48S7BuywwM25IiOiTkL+8ZWaBWU4Eg5++DE6dKPmMAB3gJRHzK/mcJCzHWCX4nOJHNuZSJnL3UgEGXc+uq0A7bHaRMc6VtNE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717588370; c=relaxed/simple; bh=NJFTVtrYvnLF1VTPy4CYKSB9Or0i1HT1MkKZ6bHtDg0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=T//OTVMU8qoKmuBO+m8cH1SaP0r86GGitYxaezS2W5hVU4w9JFdGd21j+xq1SOPeGTkMdw5DGk5lY1/qeWjSZuQAPbEi5NOGFAaSFDTC/x6M5Ml9dudofrPScVc97O8qZ6GCHbt6kZZB7OskAPOGOy59B+HrzytJStivdqy4K6o= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=DEqjDiQ9; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 11471C32781; Wed, 5 Jun 2024 11:52:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717588370; bh=NJFTVtrYvnLF1VTPy4CYKSB9Or0i1HT1MkKZ6bHtDg0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DEqjDiQ9IJkYAOXQzb/GUyteQJ4+jFM0zhZ059+8m+GoegxSgUO5Z0xjdYTxteWpx z52CPQhsb6uAG8+I2r4P8Sqg8/pZskdutgvVLHJ8Rv34Tthj/6CUpsHQZ4OPncz3fD kppVFwmGWAhG2qJsIz37WWYKwJZEtX9pVsUykKIi27lCxO3lb+1/W2LPEgiJX/3FPP OsTIYAqta+2m+4PmWzm+eu1wJwkPjkVBCjbhRUKtgruXOz9rRImLT5MEbCRs+OsFzl lAOn7uwZv9hRvrz5NaW8fPBvXtLOzcAbSPY32KBGPKPEEjYLtUyfTsR4MCcOhZO+MS wnPsklbPC3Vug== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Esben Haabendal , Marc Kleine-Budde , Greg Kroah-Hartman , Sasha Levin , jirislaby@kernel.org, shawnguo@kernel.org, u.kleine-koenig@pengutronix.de, cniedermaier@dh-electronics.com, l.sanfilippo@kunbus.com, ilpo.jarvinen@linux.intel.com, christophe.jaillet@wanadoo.fr, tglx@linutronix.de, rickaran@axis.com, martin.fuzzey@flowbird.group, linux-serial@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org Subject: [PATCH AUTOSEL 6.6 11/20] serial: imx: Introduce timeout when waiting on transmitter empty Date: Wed, 5 Jun 2024 07:51:54 -0400 Message-ID: <20240605115225.2963242-11-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240605115225.2963242-1-sashal@kernel.org> References: <20240605115225.2963242-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.6.32 Content-Transfer-Encoding: 8bit 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 c77831e91ec20..a1476e47c6aab 100644 --- a/drivers/tty/serial/imx.c +++ b/drivers/tty/serial/imx.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include @@ -2009,7 +2010,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) @@ -2040,8 +2041,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