Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp1326077rdd; Wed, 10 Jan 2024 16:27:42 -0800 (PST) X-Google-Smtp-Source: AGHT+IHZmA+WJ1emGloZruQNlZTs8D5vxEygcrXJ8wwcIdedV2GgAvpi4G45TVuUjONVmDPFuT7n X-Received: by 2002:a05:620a:1493:b0:783:e82:6cd3 with SMTP id w19-20020a05620a149300b007830e826cd3mr485715qkj.153.1704932861733; Wed, 10 Jan 2024 16:27:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704932861; cv=none; d=google.com; s=arc-20160816; b=Rc/Z3DYOS+j2SM8VKmy4mcGvBT6hC8mk8kB5IoZfzmq+Tp1k0gdeaQcFYh2DZY0Pg7 OgYpaR+3Y5BfBKLyvWeKT8S4AXlMfVhnyXSOclNEt3+kY4q8pQh8pjAxKYb5J+sYJY4/ 1nna7Wy9E0V+BVDQ9H/lvhfkt9MtnquEgao7x7//L93BMV5Vnhu4wZgbeQHnMmbfH9kZ GeXueVWSI2xbSoNUHyLVSFpd7WNCsgNLkYf6OZVS96NQmeq41nBC3jzD6Txiu3+DtX3j 3MXs4HpJD3bbujUJO93Jq/Puq0+IWCoCFUMfp3FgeFp4dw4QyPz2Jp84onC1esMgaAdo SwuQ== ARC-Message-Signature: i=1; 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:message-id:subject:cc :from:to:date:dkim-signature; bh=OkijiJRSxRVwfQmNOQyfPf4G65ZauMEV3546lKD1NdU=; fh=J/w12W2n7adVGGFX0YJWeA8ix6Dg2DZl5v1YXoj+eIA=; b=mKp5UGojdQDwxEt5/IPLbSr9/X7KAkaI872JeZBciagrOzKWEu+y2Un//5fam+WOrl wnYbHcBKjL3F3AEXDNWTUJFpzcspJP08W0VsomA+AJfP1E9mnpWZ31D8uEHmr4v0AHZA MZYrEuVceYxM20C25BpHiB0ovSdUcmOMVpT560Ahl1/qrAehktVSXiZ6U/fDpltJqXqW lGrPnVww9xVC3SjHENob9kkYwhzM7euyxW3tAvMcGCbM73OyKcku3NaHxYla1jgeXB1j JAdmVCn3EhM7Ckl9BLmjrYYOYlIF/c87RxKiXVfREjnhUdNOZXu8ILU4etJ8+OXwtf13 dwbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@pm.me header.s=protonmail3 header.b=kiRmVSS0; spf=pass (google.com: domain of linux-kernel+bounces-22909-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-22909-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=pm.me Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id i22-20020a05620a249600b007831f70dc17si5493289qkn.682.2024.01.10.16.27.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jan 2024 16:27:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-22909-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@pm.me header.s=protonmail3 header.b=kiRmVSS0; spf=pass (google.com: domain of linux-kernel+bounces-22909-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-22909-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 7BC3E1C22B76 for ; Thu, 11 Jan 2024 00:27:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6007636F; Thu, 11 Jan 2024 00:27:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pm.me header.i=@pm.me header.b="kiRmVSS0" Received: from mail-4316.protonmail.ch (mail-4316.protonmail.ch [185.70.43.16]) (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 8802A190 for ; Thu, 11 Jan 2024 00:27:33 +0000 (UTC) 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=1704932851; x=1705192051; bh=OkijiJRSxRVwfQmNOQyfPf4G65ZauMEV3546lKD1NdU=; h=Date:To:From:Cc:Subject:Message-ID:Feedback-ID:From:To:Cc:Date: Subject:Reply-To:Feedback-ID:Message-ID:BIMI-Selector; b=kiRmVSS0MAP+lN1koA8/H2LWxs1U6Ao4PB1IJbe/EplLh6vONLTNFLVlJa6PQjaPB 4x/yEMwxQI2ncMZ+BHf+Ll86FabImYyBg9/cOtsqCP+RM4lSykT/2mpuLxu7LkvYlj sClfb9ALClDG0zpVJQvYBrEY8ZaTM/ou2gVNZCKuLz2wQ8KzRhpzKKPZx6sxk/05/m n3a86uJV6To79UNz6SOrZ+SnHYAiBOGWKBtjcH4DxzJeoETTFg7QEwFlUPCR7j4AOS h9kAOArObmTyHFkLITab9Xe1z+VCHQ+97ccDJGl6BzexljvS/5MMtIdwWA5evK6y0l CYF72fbQHS2mg== Date: Thu, 11 Jan 2024 00:27:07 +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 , Michael Pratt Subject: [PATCH v1 RESEND] serial: 8250: Set fifo timeout with uart_fifo_timeout() Message-ID: <20240111002056.28205-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 for all frames in the FIFO device to flush before writing data again using the now stored frame_time value and size of the buffer. Fix this by using the new function to calculate the timeout whenever the buffer is larger than 1 byte (unknown port default). Tested on a MIPS device (ar934x) at baud rates 625, 9600, 115200. Signed-off-by: Michael Pratt --- v1 thread: https://lore.kernel.org/linux-serial/20231125063552.517-1-mcprat= t@pm.me/ 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 8ca061d3bbb9..777b61a79c5e 100644 --- a/drivers/tty/serial/8250/8250_port.c +++ b/drivers/tty/serial/8250/8250_port.c @@ -2076,7 +2076,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->port.fifosize > 1) +=09=09tmout =3D jiffies_to_usecs(uart_fifo_timeout(&up->port)); + =09for (;;) { =09=09status =3D serial_lsr_in(up); =20 --=20 2.30.2