Received: by 2002:a05:6500:1b45:b0:1f5:f2ab:c469 with SMTP id cz5csp159548lqb; Tue, 16 Apr 2024 11:34:39 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWoo6X5JPZH2g0QFSSdYTNz7JvpUrh5ry2uAYmvmjm/aLglNfh4Bh7MQR0DX1K2vMYIIpqU0hTWi464N4hK84ShoJYjrpeojdW79DExNw== X-Google-Smtp-Source: AGHT+IHHrfscilVzrKGmv6yY2TwI3e72IAvFrIgwRpR6xcQtA2vKQH4fhKChfcBbZiSFXjMTSIwq X-Received: by 2002:a05:6300:8095:b0:1a7:5425:496d with SMTP id ap21-20020a056300809500b001a75425496dmr12490532pzc.13.1713292479175; Tue, 16 Apr 2024 11:34:39 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713292479; cv=pass; d=google.com; s=arc-20160816; b=kcuH436frqx7asvWcV47TP8PvO6Zt5vXnkBVHbfoHgvKsEs8CU17wUb4LANJi45OQW ZHHr490JJfWWT6Vbw6O3TYoQxBFr2CEhvapetkbYAD4Ufl4FSKVA5MBpj5Q7hRl7z7XH Ps3DFSlvIYslsQZ/qjqkqX9KuGARLWO7IiTEbvgxa4NcvKjt3L4GGCWRqvkdCmLLSs4p 6V097PrqoXfHyqOnzN+jO6LFYQ28fondIJ5yE3ZEdjRhMQAMRGBrM8S+pDY/Ql5X2Ei6 5QUG5YPTCAlSoUBVo0ylAslu2FiLSbMiYqckBvfkLO5VZ5ti4YxDE18dqbN03KD6nF5r OYTA== 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:feedback-id:references :in-reply-to:message-id:subject:cc:from:to:date:dkim-signature; bh=SZ9BlOq9LC/Dzi9Ke1GsgNFBMPYPVQktfTHm/zfvHdA=; fh=YdUSswXC5mJ2xg94FpOMeF/EMgqf5AA86Gep/RT4GVU=; b=xd4nf3i8OSCmzEMb2sMicXi0KPRHfgpWwGOBxmQp8RAZFz7D1kIGjPNzNJ++3Gyf3s r4IqdwEW7RsI763Ba9+X4meuKYoe64UdV2HGwGdI9/rpTBBwHaObzEyh7rrkwIwAHPp6 U188VJXLlahAmv633C0KIp7VI7RpfUaCeffBYi85tSa/YYglkj47hgTmoJaP6juID4f9 j8RLnwmTmGNdsadEyAxuukyw85PHO48x4UGGna/MP6IbkXqQLdyBzAlhAFpw+swvHelW 2MZquZgFn/fns8ek4d7Rnof60xnvt8dO0o8Qkbt1gkbnxpU8vQ2pOWAo1FndQvKTFJT4 ATcA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@pm.me header.s=protonmail3 header.b="hn1CQ/Gg"; arc=pass (i=1 spf=pass spfdomain=pm.me dkim=pass dkdomain=pm.me dmarc=pass fromdomain=pm.me); spf=pass (google.com: domain of linux-kernel+bounces-147393-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-147393-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=pm.me Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id d1-20020a056a0010c100b006ed21c12b7csi10473730pfu.35.2024.04.16.11.34.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Apr 2024 11:34:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-147393-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@pm.me header.s=protonmail3 header.b="hn1CQ/Gg"; arc=pass (i=1 spf=pass spfdomain=pm.me dkim=pass dkdomain=pm.me dmarc=pass fromdomain=pm.me); spf=pass (google.com: domain of linux-kernel+bounces-147393-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-147393-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=pm.me 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 6D9AAB22A5B for ; Tue, 16 Apr 2024 18:34:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 42248136E39; Tue, 16 Apr 2024 18:34:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pm.me header.i=@pm.me header.b="hn1CQ/Gg" Received: from mail-40134.protonmail.ch (mail-40134.protonmail.ch [185.70.40.134]) (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 CC6B5132C37 for ; Tue, 16 Apr 2024 18:34:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.70.40.134 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713292467; cv=none; b=sBc7rUQ5PX/CvYU53wqCSUhOEV3f7aEjJs6V5n1xZl0+/YbCLVji4ckzz7ZbgWFOjCfNmoo7GWzlCHW51w42R3P3ttwEIQOvg6ukp5icORZb7RySOqpMSDWpQIlepMq1zEK1R2Ml99RzlxSGrWV1M+WcvriV+xvxHKdberkHpvo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713292467; c=relaxed/simple; bh=SZ9BlOq9LC/Dzi9Ke1GsgNFBMPYPVQktfTHm/zfvHdA=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=NvZRASXD2WL6nz2LCGYn07KjUnbImM8WnLbK4MEu2CuS622qnPbmx7MCDOUUm6acjP5RuduhoyEV73Uk9z+QWNRHkuOkXswhKdWP6LVdP9Lu5hODyJfAI3tTneUxAHagYG4l/1lgWOnCTv5J+MLy1PJER+NeDzLkiFU0u1NJle0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=pm.me; spf=pass smtp.mailfrom=pm.me; dkim=pass (2048-bit key) header.d=pm.me header.i=@pm.me header.b=hn1CQ/Gg; arc=none smtp.client-ip=185.70.40.134 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=pm.me Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pm.me DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pm.me; s=protonmail3; t=1713292463; x=1713551663; bh=SZ9BlOq9LC/Dzi9Ke1GsgNFBMPYPVQktfTHm/zfvHdA=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=hn1CQ/GgpX9BczIc9SqdPGiPdserIrTIiPm9lk0gzJXJGax1LwhZF7As1Z2/jcgdi 87gXJOIITzGmbfKhFfOzX8sWkhNDDmk7/SH3Na1c3QoQyv/c16KagIL70MLcKIgd6B FYpaT7ujVBkGCEPfrsSXTqMJuCTU6ipZ6LV3e9dZQPR7GDe0zR8AXjk1lbfYMX2leQ 72I8cVZi/vi1mCmaXSvXwgvGw5YIwk30OYJPu27zKEUUIruOJIqtItQvbg9Buih8jV 1m/t0+9MyoAasUQ74R4y+QNX/sg/KlvLbt0UsFvMIqqIFpnr73so2RFXBioOrV5XSB QYRUkR1ltL/vg== Date: Tue, 16 Apr 2024 18:34:10 +0000 To: linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, Greg Kroah-Hartman , Jiri Slaby From: Michael Pratt Cc: Wander Lairson Costa , =?utf-8?Q?Ilpo_J=C3=A4rvinen?= , Andy Shevchenko , Vamshi Gajjela , Michael Pratt Subject: [PATCH v2 3/3] serial: 8250: Set fifo timeout using uart_fifo_timeout() Message-ID: <20240416182741.22514-4-mcpratt@pm.me> In-Reply-To: <20240416182741.22514-1-mcpratt@pm.me> References: <20240416182741.22514-1-mcpratt@pm.me> Feedback-ID: 27397442:user:proton Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Commit 8f3631f0f6eb ("serial/8250: Use fifo in 8250 console driver") reworked functions for basic 8250 and 16550 type serial devices in order to enable and use the internal fifo device for buffering, however the default timeout of 10 ms remained, which is proving to be insufficient for low baud rates like 9600, causing data overrun. Unforunately, that commit was written and accepted just before commit 31f6bd7fad3b ("serial: Store character timing information to uart_port") which introduced the frame_time member of the uart_port struct in order to store the amount of time it takes to send one uart frame relative to the baud rate and other serial port configuration, and commit f9008285bb69 ("serial: Drop timeout from uart_port") which established function uart_fifo_timeout() in order to calculate a reasonable timeout to wait until flushing the fifo device before writing data again when partially filled, using the now stored frame_time value and size of the buffer. Fix this by using the stored timeout value made with this new function to calculate the timeout for the fifo device, when enabled, and when the buffer is larger than 1 byte (unknown port default). The previous 2 commits add the struct members used here in order to store the values, so that the calculations are offloaded from the functions that are called during a write operation for better performance. Tested on a MIPS device (ar934x) at baud rates 625, 9600, 115200. Fixes: 8f3631f0f6eb ("serial/8250: Use fifo in 8250 console driver") Signed-off-by: Michael Pratt --- V1 -> V2: Use stored values instead of calling uart_fifo_timeout() or checking capability flags. The existence of the timeout value satisfies fifosize > 1. drivers/tty/serial/8250/8250_port.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/= 8250_port.c index 5b0cfe6bc98c..cf67911a74f5 100644 --- a/drivers/tty/serial/8250/8250_port.c +++ b/drivers/tty/serial/8250/8250_port.c @@ -2066,7 +2066,10 @@ static void wait_for_lsr(struct uart_8250_port *up, = int bits) { =09unsigned int status, tmout =3D 10000; =20 -=09/* Wait up to 10ms for the character(s) to be sent. */ +=09/* Wait for a time relative to buffer size and baud */ +=09if (up->fifo_enable && up->port.timeout) +=09=09tmout =3D jiffies_to_usecs(up->port.timeout); + =09for (;;) { =09=09status =3D serial_lsr_in(up); =20 --=20 2.30.2