Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E7DBEC77B7F for ; Fri, 19 May 2023 10:46:54 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E1FF4862EC; Fri, 19 May 2023 12:44:56 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1684493097; bh=Rfq1HzRY/ht+1dE6GXKzkRxeKSvPkNrg8l/dirSBb2I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=u8fot4XUm/ShPMOGSThpUjFfL54ktqhTdPMMg4abWfKeJt4tITwZnq1X35YFAWImr P7OhlFQeTtNIdF/Vp/WNhcJ5cOj8FeYM19O6YqUtP5ssbaQo6Igp8PFCOamNqhYkrX YiLQ6iDioeTdirLR8hqRGBjJLcHU2TmvNlDiTGSEmkc2pI7alYNtH+KYYuUCNLGe9Y eUNt/5GCM9azXTQp/dlUJfreSd5st6hXM9QCyNf7A7gHWfXZrfnDtYIie+HNHxdnew mq6QQ+1IU2wvkO3wrRl4kh6oGxY1CBwSt/Q6rRhezlan5RoW91XgZyBUNN4kW0bDzG LXj/0sxIztepA== Received: from localhost.localdomain (85-222-111-42.dynamic.chello.pl [85.222.111.42]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: lukma@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id A126785EDD; Fri, 19 May 2023 12:44:32 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1684493073; bh=Rfq1HzRY/ht+1dE6GXKzkRxeKSvPkNrg8l/dirSBb2I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hy5tyZntZiDYlOKtecSl7JbaA4e9UDm91ApqZgx+k3rWr57k8CsAVbi8p4duMLsSE Mtc+RJHMuqSsh61OgPETXfzTMW98rkF1rbpmbepZEI8S/zj/JoLQCUBoCMmT8DhShR xKgwvdjKXfRq/Eh6VQaMR7R6BIoD89mleyGRwic0ceThzVtX9IK2U3lbamm2Hs2VIW e8m8lwOtVyryIrW7pzymxo5CYCGRMF4CH6EmZz3nNiHfggbAFx3lecNSGrXl50atD7 H+doGIX8+Sql3WWBS70mrC7W1TIUHBcl1qbM/jegK3GWPGNOxrRdj0SQ/Ifj9iZBmj DBgFZKNwQ2k8Q== From: Lukasz Majewski To: Stefano Babic , Fabio Estevam , Tom Rini , u-boot@lists.denx.de, Marek Vasut , NXP u-boot Cc: Lukasz Majewski , =?UTF-8?q?Pali=20Roh=C3=A1r?= , Simon Glass , Stefan Roese Subject: [PATCH v1 11/16] serial: pl01x: Modify pending callback to test if transmit FIFO is empty Date: Fri, 19 May 2023 12:43:53 +0200 Message-Id: <20230519104359.2048821-12-lukma@denx.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230519104359.2048821-1-lukma@denx.de> References: <20230519104359.2048821-1-lukma@denx.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Before this change the FR_TXFF (Transmit FIFO full) bit (5 in HW_UARTDBG_FR) has been used to assess if there is still data pending to be sent via UART. This approach is problematic, as it may happen that serial is in the middle of transmission (so the TX FIFO is NOT full anymore) and this test returns true infinitely. As a result, for example in _serial_flush() DM serial function we are locked in endless while(). The fix here is to test explicitly if the TX FIFO is empty. Signed-off-by: Lukasz Majewski --- drivers/serial/serial_pl01x.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/serial/serial_pl01x.c b/drivers/serial/serial_pl01x.c index dbf2b2df34..428a4d210d 100644 --- a/drivers/serial/serial_pl01x.c +++ b/drivers/serial/serial_pl01x.c @@ -329,7 +329,7 @@ int pl01x_serial_pending(struct udevice *dev, bool input) if (input) return pl01x_tstc(priv->regs); else - return fr & UART_PL01x_FR_TXFF ? 0 : 1; + return fr & UART_PL01x_FR_TXFE ? 0 : 1; } static const struct dm_serial_ops pl01x_serial_ops = { -- 2.30.2