From nobody Sat Oct 08 00:56:31 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Mkmvz6rgvz4fHcx; Sat, 8 Oct 2022 00:56:31 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Mkmvz6G0xz3tkT; Sat, 8 Oct 2022 00:56:31 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1665190591; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Xi9ks8kSA2MB1rdwwdTPZ//9u+NNvPCc+KHnfNnUkTY=; b=hu0lI3KOMtpdoJlXH5KF3h7l3WyVT9XNJIESqvWytNaXhjo4h2IPmVjR/qVuA3IxsaF55t d+XCKCAoNCRvrUDVIlq0QpFB1oUYc+YuJlQ68KDlEEWCyy8KSr7WiezeB9gzlDJTnTSkvn Zy4K76l8nNSTHrhjtFx09WYkZoqx0NQ64oHLBTiAhM0FpR7bkfyMy+urSSfQEqmPsjNYNK 6oK0jLNgtOo3egJ8TLCeTLiw+mzj4UTeWJpp6zm6w0KYsnH4ea9vcqDTXg5RgTOXz2CBlL UYG261SWy75PMDeqS6g4qNRZpXsv8n3Rq/4JmpMgmWMOX3U53i35jkxbkvKnJA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4Mkmvz5KNmzmWx; Sat, 8 Oct 2022 00:56:31 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 2980uVLE059210; Sat, 8 Oct 2022 00:56:31 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2980uVCn059209; Sat, 8 Oct 2022 00:56:31 GMT (envelope-from git) Date: Sat, 8 Oct 2022 00:56:31 GMT Message-Id: <202210080056.2980uVCn059209@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Colin Percival Subject: git: 39d6144dcd94 - main - ns8250_drain: Drain without DELAY first List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: cperciva X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 39d6144dcd94e9d07f07cb554aecb1f2d4089f6d Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1665190591; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Xi9ks8kSA2MB1rdwwdTPZ//9u+NNvPCc+KHnfNnUkTY=; b=gKTwNd3zlWX/O89CniqB6exgMQPtRr78GGAmkWXBbWh18WbASKKZVAtusBfeNUwIlXeMgp mL8hYLqs0MJ0nAEq7cVHSE7V2Q2i27g+vshZFuzcD+W4xn0NYb3Z3+fADp+CBC6fGwoTPz M7pipjEW9YaBMRjSThFCfvdbhmscf7fbFYi4P1npT+c8U3yXJfUANDzUk2yVQnV8bS7q5F 6W9PzlDZ33g+T88zQsvU5yWrrCMgjj+gDHTwAPVx+BpowPdSKbthjcDheJxoC6nsk1wQCf 2aSU9B34iEMsG7b4ST+Y4AqzEUqsuKeUkTA7NTod6905o2ebqrgiXOSRNv29dA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1665190591; a=rsa-sha256; cv=none; b=bXcrWFZxT8JEOjaQ1+S6LFL3rwq61byI/mW1A6ZjEiLFOqy8DMQmZI/qyWKCi4cpoiJZYE ZbeqNDLctY0IgtrpypLyfcMgCI/rc7xZWSssZYryIDNMDfKQ1q9jOzalARsV1Vw3Oc8LcD LMH25f3nt70J0UT/lUxNyljwjVO6J8/WGLkijXGZ8cbp8oTqA+tofHvf455bivvmdOL29k Qd9usu04GHhVgPvALGmNncz1Kr1idHXEACxGtaLZcgsl9FW/gUFlSfZzCXuzVR+S+wh2iR AyyaI2K7lBMI2vmra+bCi4HfEo8PgsmYpJ9agDtkii1ZFRhNEIIUr2lAjQhKuA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by cperciva: URL: https://cgit.FreeBSD.org/src/commit/?id=39d6144dcd94e9d07f07cb554aecb1f2d4089f6d commit 39d6144dcd94e9d07f07cb554aecb1f2d4089f6d Author: Colin Percival AuthorDate: 2022-08-12 23:45:17 +0000 Commit: Colin Percival CommitDate: 2022-10-08 00:51:54 +0000 ns8250_drain: Drain without DELAY first In virtual machines with virtual UARTs which have fictitious baud rates, it may be possible to drain the receive queue very quickly, without needing to DELAY after each character. Attempt to read (and discard) the receive queue as fast as possible, stopping for a DELAY only when LSR_RXRDY is no longer asserted; assume that we have finished draining the queue when LSR_RXRDY is asserted both before and after a DELAY. This speeds up the boot process in FreeBSD/Firecracker by 27 ms. Reviewed by: imp, jrtc27 Sponsored by: https://www.patreon.com/cperciva Differential Revision: https://reviews.freebsd.org/D36184 --- sys/dev/uart/uart_dev_ns8250.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/sys/dev/uart/uart_dev_ns8250.c b/sys/dev/uart/uart_dev_ns8250.c index ada60b62b633..182831da7611 100644 --- a/sys/dev/uart/uart_dev_ns8250.c +++ b/sys/dev/uart/uart_dev_ns8250.c @@ -178,11 +178,18 @@ ns8250_drain(struct uart_bas *bas, int what) * limit high enough to handle large FIFOs and integrated * UARTs. The HP rx2600 for example has 3 UARTs on the * management board that tend to get a lot of data send - * to it when the UART is first activated. + * to it when the UART is first activated. Assume that we + * have finished draining if LSR_RXRDY is not asserted both + * prior to and after a DELAY; but as long as LSR_RXRDY is + * asserted, read (and discard) characters as quickly as + * possible. */ limit=10*4096; - while ((uart_getreg(bas, REG_LSR) & LSR_RXRDY) && --limit) { - (void)uart_getreg(bas, REG_DATA); + while (limit && (uart_getreg(bas, REG_LSR) & LSR_RXRDY) && --limit) { + do { + (void)uart_getreg(bas, REG_DATA); + uart_barrier(bas); + } while ((uart_getreg(bas, REG_LSR) & LSR_RXRDY) && --limit); uart_barrier(bas); DELAY(delay << 2); }