From nobody Fri Sep 5 20:19:49 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 553A0C32772 for ; Tue, 23 Aug 2022 11:35:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349610AbiHWLfF (ORCPT ); Tue, 23 Aug 2022 07:35:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48868 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357490AbiHWLbj (ORCPT ); Tue, 23 Aug 2022 07:31:39 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4D76B6612E; Tue, 23 Aug 2022 02:25:48 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 0A8A46130E; Tue, 23 Aug 2022 09:25:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EB2E6C433D6; Tue, 23 Aug 2022 09:25:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661246746; bh=OJLTec2hXfd6nyC4dMNAnRYZc1Klp15sXbFH0oMSZsE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wmf/quD2uHYQa02t92WZNqleCjouVTu6tIKT/5ujfSN2mww91HOSB53CSTY0ZeeBB /zJafIYOvCNQ3qu6eS1O6n0/kOlLSiZnj9GDaBfme3J1TTkMOJ32v1hQjr5yQm2l2w ioMbKGaJOZp+15b+0D15fWNwfeDRDLilmXHDN/8o= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Andy Shevchenko , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= , Sasha Levin Subject: [PATCH 5.4 207/389] serial: 8250_dw: Store LSR into lsr_saved_flags in dw8250_tx_wait_empty() Date: Tue, 23 Aug 2022 10:24:45 +0200 Message-Id: <20220823080124.280771589@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080115.331990024@linuxfoundation.org> References: <20220823080115.331990024@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ilpo J=C3=A4rvinen [ Upstream commit af14f3007e2dca0d112f10f6717ba43093f74e81 ] Make sure LSR flags are preserved in dw8250_tx_wait_empty(). This function is called from a low-level out function and therefore cannot call serial_lsr_in() as it would lead to infinite recursion. It is borderline if the flags need to be saved here at all since this code relates to writing LCR register which usually implies no important characters should be arriving. Fixes: 914eaf935ec7 ("serial: 8250_dw: Allow TX FIFO to drain before writin= g to UART_LCR") Reviewed-by: Andy Shevchenko Signed-off-by: Ilpo J=C3=A4rvinen Link: https://lore.kernel.org/r/20220608095431.18376-7-ilpo.jarvinen@linux.= intel.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/tty/serial/8250/8250_dw.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/tty/serial/8250/8250_dw.c b/drivers/tty/serial/8250/82= 50_dw.c index 381c5117aec1..2d5a039229ac 100644 --- a/drivers/tty/serial/8250/8250_dw.c +++ b/drivers/tty/serial/8250/8250_dw.c @@ -110,12 +110,15 @@ static void dw8250_check_lcr(struct uart_port *p, int= value) /* Returns once the transmitter is empty or we run out of retries */ static void dw8250_tx_wait_empty(struct uart_port *p) { + struct uart_8250_port *up =3D up_to_u8250p(p); unsigned int tries =3D 20000; unsigned int delay_threshold =3D tries - 1000; unsigned int lsr; =20 while (tries--) { lsr =3D readb (p->membase + (UART_LSR << p->regshift)); + up->lsr_saved_flags |=3D lsr & LSR_SAVE_FLAGS; + if (lsr & UART_LSR_TEMT) break; =20 --=20 2.35.1