From nobody Wed May 15 15:53:53 2024 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 4Vfd7P285qz5L4fR; Wed, 15 May 2024 15:53:53 +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 4Vfd7P1k0Tz4RnM; Wed, 15 May 2024 15:53:53 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1715788433; 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=upZsLV4g1BGjyi5p1tAKk0KfxDFo6ED91kOxImoJXJc=; b=PoRzFO/l0VLc+nL6kk5DvC8I0+8eAZyvA6nWJVD6YFfs4YJvfVgGxblSjsPn1clEWtJcfR +tAhbnfi9fqYOBitWgkIBAIW8jw5L3F8jp/n9cMlkvhq43+iceNlGzkaWBrV7aCKpoSmD6 xvKNCQtCk16DTT56rP19hG+oXlQrkUPXRZNokLay3XXdB3fUaaSIAEkcRQiA56vEe4AoTr Hpyw6cXbJ9/g1zfQSKO9e7Dw6L4WnjX8nCTMJmeLsCsvEYFrpRmCxEmNG0UDgwJuVabotE Yrm27X+vCkG+EhSvjz6hQeMSiJt5iHC2UaaNSz+uv3Np+e7yWYBiBhaLmZboHA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1715788433; a=rsa-sha256; cv=none; b=IKKgWUfABix9rGlmeO1VEbOA9Ww/3NM/b+dPdnn0pTCUZiDPMYFEHh4c4J5nW3t5quU5pZ ucDrnzuR9cQOIW3goQZzZeoHbm17CHFHSWK+WWEPcT7FtYvs6gbkSlA5BQL5lJ/BwWulE7 5xxvXvwnVHMB3msO3yf/0BiUo/SjDGsR0TQULhMos+a4Op5iz3lX+bOzpnbE7m0HZNWpcw 84ff00nlwELXI98WUETkZNY+kz/UHcsOaqPngJshXzhV42H8tL+Y/rLl7tG9t1ucPknDRY MmCr3+XZm6ZdKp63cIyO8iTf3KW62WgKUuONgyuR+ZKq4EfLUbbxERxdF0DJqg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1715788433; 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=upZsLV4g1BGjyi5p1tAKk0KfxDFo6ED91kOxImoJXJc=; b=d3CSIA3GAMmzURhA+uAxC9C2oPeNyWpggqBNz4EWVnfPPVQ1nezoAQrYg5j6OkmPtTKAmV kiEjKAJf/3S4gcXPxAkhNEeEltF0Iacx7R0vxIaN+xMJppM7BezFqeFE8eVFimxLZgZd8b 66/TyGyWJeoN3Iy18y27iZfa7U3gHYlBFQlqDIB0Uhq9AYDKY2a77jXH30IoLo5yfshilw g+5flLCHEmBRZo8HxGNiEXe41o6Y9mFkkVmEZo7RU3tlOh7LhGpnmod2khr/A9Y32F6GPl HU3DSc0IoQBxgS3a8q/U8WGzFaK/HO+AsNW8Vd+kaPZM4eu9u6OBKutkyF1KQg== 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 4Vfd7P1KfZzLjJ; Wed, 15 May 2024 15:53:53 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 44FFrrqA051926; Wed, 15 May 2024 15:53:53 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 44FFrrDc051923; Wed, 15 May 2024 15:53:53 GMT (envelope-from git) Date: Wed, 15 May 2024 15:53:53 GMT Message-Id: <202405151553.44FFrrDc051923@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Jessica Clarke Subject: git: fc59fc3c1f63 - main - uart: Honour clock-frequency in FDT for UART_FDT_CLASS if present 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: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jrtc27 X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: fc59fc3c1f632e011347614ee9704fe00e51002e Auto-Submitted: auto-generated The branch main has been updated by jrtc27: URL: https://cgit.FreeBSD.org/src/commit/?id=fc59fc3c1f632e011347614ee9704fe00e51002e commit fc59fc3c1f632e011347614ee9704fe00e51002e Author: Jessica Clarke AuthorDate: 2024-05-15 15:53:33 +0000 Commit: Jessica Clarke CommitDate: 2024-05-15 15:53:33 +0000 uart: Honour clock-frequency in FDT for UART_FDT_CLASS if present The StarFive VisionFive 2 has a Synopsys DesignWare ABP UART, whose driver uses UART_FDT_CLASS rather than UART_FDT_CLASS_AND_DEVICE as it has its own separate newbus driver. This UART is driven by a 24MHz clock as specified in the FDT, but we don't currently look at the property here, instead passing down 0 and letting the default value be used in the 8250 driver (~1.8MHz). As a result the divisor is misconfigured for the current baud rate for the entire kernel boot process. Once the newbus driver attaches the correct frequency is saved in the softc, but that does not take effect until the next time ns8250_param is called and the divisor is recalculated, namely when userspace runs and /dev/console is opened (note that ns8250_init does not get called when the newbus device corresponding to the current console attaches). Fix this issue by attemmpting to get the current clock frequency as for the UART_FDT_CLASS_AND_DEVICE_CASE, but falling back to 0 rather than failing on error. Reviewed by: imp, mhorne Differential Revision: https://reviews.freebsd.org/D45159 --- sys/dev/uart/uart_bus_fdt.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sys/dev/uart/uart_bus_fdt.c b/sys/dev/uart/uart_bus_fdt.c index 7725d09e212b..431f2962adb2 100644 --- a/sys/dev/uart/uart_bus_fdt.c +++ b/sys/dev/uart/uart_bus_fdt.c @@ -234,7 +234,8 @@ uart_cpu_fdt_probe(struct uart_class **classp, bus_space_tag_t *bst, (struct uart_class *)uart_fdt_find_by_node(node, 1); if (class == NULL) return (ENXIO); - clk = 0; + if (uart_fdt_get_clock(node, &clk) != 0) + clk = 0; } /*