Received: by 2002:ab2:6d45:0:b0:1fb:d597:ff75 with SMTP id d5csp250842lqr; Wed, 5 Jun 2024 05:14:04 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWqrwHmfQ81EL2wzoVhPpq7raCuca6xpprJPMpACCX7oVoXHwi1x4rLQUW/yQYM59FVsCNjXqdFeSmf3x491y3gd1lBrS+a1s6eCS+YxA== X-Google-Smtp-Source: AGHT+IHX2v3bLbabJVNG7apOT1EehhrjgKaTJ8n6zOS17dkcBPhGE3wLt2qPDDwAWCnzkSzrmg9v X-Received: by 2002:a05:6a00:178d:b0:702:56f6:4954 with SMTP id d2e1a72fcca58-703e597dfbamr2523968b3a.18.1717589643790; Wed, 05 Jun 2024 05:14:03 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717589643; cv=pass; d=google.com; s=arc-20160816; b=WqxyyDPCwv2xo+MxE7dLY9DkLX0txpdlA3+cIyeXeeHN3b8zs2WSgFZ2bg2rWNEDHC d+6VC7f+bB4VRVAgVChp3cHoLpb0JCOUZM9kxZXy6mHCU7IooS+pEhoZOJRhmtay7TYr YQnBD9j6ls+RTSmann/DChVBhGo41NnBQEsRNMPJrTm0y3v4mKeEzAigdejDcv8txewz M36CluJrJagipa3MQq7rbjV4S3pczTsStmhVwypbNmITguLoq5tsMM8YQjD85bjlwHoR Js0RWoU0BWxofkv1rA5BtIS8GmOms8RSShVrnaw/IWZNGHO7oe51fSdMu392j6QB0CnE ZJ/g== 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=mdFECb3I4XvoaQpKoiz4hdy2X0RxiuyB6jEoPGjQteY=; fh=09/Taf0nQFT7TbvP+41QwHpv1VVmLfs4YRgeJ9h0SeM=; b=r4VV03f6jkp+z0LV4BU9bbWpCBMyVGE7S7upN6yxT6CmoPQIa3dXeAzXfd6VSKhSXH fWlMLT0eNOxKFr+7pSyvUGZP8AsTvHsTYHvJUGwXdRG2wpbjAwkoIVaWHQog0gvLf3+x UTA2CxwYixBC/j5AzweffLq2DBO9IIoJEEihsZ+a1jnubUuC81mSi9bDPsqbQTgXjROl G2yz/JOIa8ZSpDk/CnC9vcWOdHGifqjF4gdyfivPbYaFlcX0MoWMLUHt4jRJw6yo91Oq 64B1Y884pOthSD0f/R3cel0+OuynAZCpTXDf3TW9gDOLbXyAk4P/I06Cr4Rn23LLtHjx FhPw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=KTZ4gbWC; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-202343-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-202343-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id d2e1a72fcca58-702425e6cbasi2434168b3a.26.2024.06.05.05.14.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 05:14:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-202343-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=KTZ4gbWC; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-202343-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-202343-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 33D6EB227FE for ; Wed, 5 Jun 2024 12:01:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1A7491A01C4; Wed, 5 Jun 2024 11:51:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="KTZ4gbWC" 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 3710B1A01A9; Wed, 5 Jun 2024 11:51:28 +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=1717588289; cv=none; b=ic8rVA8P5HqgJVx/FtmOzzh2IxbNCKP6SyM1JSyOR9JPEv5JRqCQ9NJKEbj/UIgULgln+/V3N+MdvvTU97Do2Nbdsx3T3Wy7gwDXjHt8iyo13TFGON98T/zoJx/MHpSOlmyOcPaiDK9PMaxs6MPO1CbDTU+wYxozUnV3uzveBDE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717588289; c=relaxed/simple; bh=VDEC8kLvr3XTPKhCnFg4+8QeXod4zGth0hLIrG3ER0s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=G5M7hD4nKrfu5uVeFW1t0DLG1qwwOjRphsUv34o3EE1P59B3KOUW4QFdZOUOH+5pi3Z9VdYnH5wA1LLKUDzgllKFM9aol5Vx2MI6FW6wO6x4l8DCmMWAUekvcuX2/sGGtRV7msidWFhVLdMMubqQM6A1nZM+L4ZuX63UNrddbO8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=KTZ4gbWC; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id E435BC3277B; Wed, 5 Jun 2024 11:51:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717588288; bh=VDEC8kLvr3XTPKhCnFg4+8QeXod4zGth0hLIrG3ER0s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KTZ4gbWCxNN/2a5mHU5Vewwwd2nbQNRBjViEnzLa6vPRTmcWAt8GsZ1aAkXd8Ru05 OsPLOGYXA28moTdR4dH4E1qca5KBoESl3jBpKV5FzT0uI/Q7H9nsj7VSqfLd0Z4f/c ZmWE6i62ufhizfdMORWHOLp0Xp4CMKcD94IdmrO6ih6pYeH6H7BnWppprQ5Z2Gz9oR PPZW7lMtx2niHSkIwzR6YT4/lMnyM5lyAyViVwDyYdZo4zIdrUj4fCldruzRQhD04H 5wd16fDHHluOg/+hz2XP4wjbvqwFrb5htq27gYXq/ZlkOaNM5LOrGnFU65ib2fcCPT XHjHn4Kfik+BQ== 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, ilpo.jarvinen@linux.intel.com, l.sanfilippo@kunbus.com, cniedermaier@dh-electronics.com, martin.fuzzey@flowbird.group, robh@kernel.org, tglx@linutronix.de, rickaran@axis.com, linux-serial@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org Subject: [PATCH AUTOSEL 6.8 12/24] serial: imx: Introduce timeout when waiting on transmitter empty Date: Wed, 5 Jun 2024 07:50:22 -0400 Message-ID: <20240605115101.2962372-12-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240605115101.2962372-1-sashal@kernel.org> References: <20240605115101.2962372-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.8.12 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 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