From nobody Thu Oct 08 20:44:18 2026 X-Original-To: dev-commits-src-branches@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 4j126D0GW0z4n2WX for ; Thu, 08 Oct 2026 20:44:20 +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 "YR2" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4j126C5rXXz4cNB for ; Thu, 08 Oct 2026 20:44:19 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1791492259; 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=+5eqRz50rSaBbslIYU8eRyBX6Pz2qzmE8Jda1y8HTnM=; b=OTDAKFNjCABmqMPgPpJ7rqHzw01zSAjEGSd8Trd708NDz0E89469z4adqQ5AHboyoNTcfJ v4bqneUz57mJ6RoXVAzrFNtSiEXiVytjfbkiBfne7GT/SQtAHiF1iKjUipKklMn7NF/FXA brmxcqNS8lsHhtIhA2ePW1wx0UE264emw/rbi/rmfIGnWGHn4XlujooXewsULTK8n6ap42 PvIv6R9/3FtCq5ukh0pS2EeXnKCEIrGXTKlte2/5xQUtjuKVfX7CskK9eQAwtF//0tElqR y5frz0L/kV2rwYcEJvhjoPX/YdxDL03QGqst/HHEhvMAVvf+x5Ts1DUeXiyUfQ== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1791492259; b=HPYrFNaT0mLFrqxOXJe0Albnx3PgE3qh/ffm+mEgj7pVPs2iwJKckVyVvVVz7DcgR/NXFZ 5+9yR08YLgCHtzKEEfG3mMCROh//27bw4eR+pig1rAa0RM/gD37OwI5GE7R1E0oRk4nbdg mBRqWa1gHX+2JyrvD2hNzryI4zpCJcqN3XBtNSMjKImzjGx3E2jHCRj/9uxUFyAteJKan/ +P4CNCNVAMm+ArbLuii1Tc1ihRtAAAgj/AaTq6Gv9cYjhQJU7GfpMdgjVQAxq4LFEpKVBI vlQTnyansAnhVCQ69Gzi3AHnSRT8pi6XerJfZSHy6nG9bjhH96v3iiat4ktzYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1791492259; 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=+5eqRz50rSaBbslIYU8eRyBX6Pz2qzmE8Jda1y8HTnM=; b=SqVLM3tLzu2QR/yx4a0EyQBVnSmAgGvr81UQQiQmL3vqNcZ3C+0ILiLsGqmdbckQhdEsdd yfQi4wMzddpFCHKd0E1TIJrmtMMZrV2RNjDLe09lBxiEQK0sqId60oj3hkqbi3IlkqEigI DuPeRNSrRdwGBYvZYrjCFb5nYH+vkeJaxEywpNno1I7MbESWbq6HvTtdv/xYKJ0y3Zy9Xz ap8NfBNDzs3vBqdlD6l0iPgxmcIpqN4LFRNG1kWHVLo/D8yr/W+3UiAfXUuH+Ad4PvQgHE 6IcSdiEIGVsVlJNG9YMb+/nNu3wg47Zb8CwU95huPoZd9jiqB9xrTtdsGgapGA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4j126B5dM7zwV2 for ; Thu, 08 Oct 2026 20:44:18 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 32e61 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Thu, 08 Oct 2026 20:44:18 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: John Baldwin Subject: git: c39dbb4fea23 - stable/15 - acpi_timer: Trim some more leftovers from the ACPI-safe timer List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-branches@freebsd.org Sender: owner-dev-commits-src-branches@FreeBSD.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/stable/15 X-Git-Reftype: branch X-Git-Commit: c39dbb4fea23f9dbd42c8f63adab80a756b1e5af Auto-Submitted: auto-generated Date: Thu, 08 Oct 2026 20:44:18 +0000 Message-Id: <6ac800a2.32e61.1517d6d3@gitrepo.freebsd.org> The branch stable/15 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=c39dbb4fea23f9dbd42c8f63adab80a756b1e5af commit c39dbb4fea23f9dbd42c8f63adab80a756b1e5af Author: John Baldwin AuthorDate: 2026-09-30 16:04:59 +0000 Commit: John Baldwin CommitDate: 2026-10-08 20:42:33 +0000 acpi_timer: Trim some more leftovers from the ACPI-safe timer The "safe" variant of the hook to read the timer is no longer used and can be removed. Instead, initialize the get_timecount member of acpi_timer_timecounter to the normal hook statically. While here, initialize a few more fields in acpi_timer_timecounter statically. I've kept the name as just "ACPI" instead of "ACPI-fast" now. During device probe there is no longer any reason to alloc the register resource since it is not used, so remove all that. While here, defer registration of the timecounter until attach (kind of odd to do such a thing during probe leaving a window where the timer register was unallocated but in theory could still be read via the timecounter). Reviewed by: cperciva Fixes: 00d061855deb ("Garbage-collect ACPI-safe timer and friends") Differential Revision: https://reviews.freebsd.org/D59933 (cherry picked from commit d23d186ff212023c4e1ff61a0f488dc4dcb1b75c) --- sys/dev/acpica/acpi_timer.c | 82 +++++++++------------------------------------ 1 file changed, 15 insertions(+), 67 deletions(-) diff --git a/sys/dev/acpica/acpi_timer.c b/sys/dev/acpica/acpi_timer.c index ff0c53ed8783..4a875884b4a6 100644 --- a/sys/dev/acpica/acpi_timer.c +++ b/sys/dev/acpica/acpi_timer.c @@ -69,7 +69,6 @@ static int acpi_timer_attach(device_t dev); static void acpi_timer_resume_handler(struct timecounter *); static void acpi_timer_suspend_handler(struct timecounter *); static u_int acpi_timer_get_timecount(struct timecounter *tc); -static u_int acpi_timer_get_timecount_safe(struct timecounter *tc); static int acpi_timer_sysctl_freq(SYSCTL_HANDLER_ARGS); static device_method_t acpi_timer_methods[] = { @@ -90,12 +89,13 @@ DRIVER_MODULE(acpi_timer, acpi, acpi_timer_driver, 0, 0); MODULE_DEPEND(acpi_timer, acpi, 1, 1, 1); static struct timecounter acpi_timer_timecounter = { - acpi_timer_get_timecount_safe, /* get_timecount function */ + acpi_timer_get_timecount, /* get_timecount function */ 0, /* no poll_pps */ 0, /* no default counter_mask */ 0, /* no default frequency */ "ACPI", /* name */ - -1 /* quality (chosen later) */ + 900, /* quality */ + TC_FLAGS_SUSPEND_SAFE /* flags */ }; static __inline uint32_t @@ -150,51 +150,14 @@ acpi_timer_identify(driver_t *driver, device_t parent) static int acpi_timer_probe(device_t dev) { - int rid, rtype; - ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__); if (dev != acpi_timer_dev) return (ENXIO); - switch (AcpiGbl_FADT.XPmTimerBlock.SpaceId) { - case ACPI_ADR_SPACE_SYSTEM_MEMORY: - rtype = SYS_RES_MEMORY; - break; - case ACPI_ADR_SPACE_SYSTEM_IO: - rtype = SYS_RES_IOPORT; - break; - default: - return (ENXIO); - } - rid = 0; - acpi_timer_reg = bus_alloc_resource_any(dev, rtype, &rid, RF_ACTIVE); - if (acpi_timer_reg == NULL) { - device_printf(dev, "couldn't allocate resource (%s 0x%lx)\n", - (rtype == SYS_RES_IOPORT) ? "port" : "mem", - (u_long)AcpiGbl_FADT.XPmTimerBlock.Address); - return (ENXIO); - } - acpi_timer_bsh = rman_get_bushandle(acpi_timer_reg); - acpi_timer_bst = rman_get_bustag(acpi_timer_reg); - if (AcpiGbl_FADT.Flags & ACPI_FADT_32BIT_TIMER) - acpi_timer_timecounter.tc_counter_mask = 0xffffffff; - else - acpi_timer_timecounter.tc_counter_mask = 0x00ffffff; - acpi_timer_timecounter.tc_frequency = acpi_timer_frequency; - acpi_timer_timecounter.tc_flags = TC_FLAGS_SUSPEND_SAFE; - - acpi_timer_timecounter.tc_name = "ACPI-fast"; - acpi_timer_timecounter.tc_get_timecount = acpi_timer_get_timecount; - acpi_timer_timecounter.tc_quality = 900; - tc_init(&acpi_timer_timecounter); - device_set_descf(dev, "%d-bit timer at %u.%06uMHz", (AcpiGbl_FADT.Flags & ACPI_FADT_32BIT_TIMER) != 0 ? 32 : 24, acpi_timer_frequency / 1000000, acpi_timer_frequency % 1000000); - - /* Release the resource, we'll allocate it again during attach. */ - bus_release_resource(dev, rtype, rid, acpi_timer_reg); return (0); } @@ -224,8 +187,19 @@ acpi_timer_attach(device_t dev) /* Register suspend event handler. */ if (EVENTHANDLER_REGISTER(power_suspend, acpi_timer_suspend_handler, - &acpi_timer_timecounter, EVENTHANDLER_PRI_LAST) == NULL) + &acpi_timer_timecounter, EVENTHANDLER_PRI_LAST) == NULL) { device_printf(dev, "failed to register suspend event handler\n"); + bus_release_resource(dev, acpi_timer_reg); + return (ENXIO); + } + + if (AcpiGbl_FADT.Flags & ACPI_FADT_32BIT_TIMER) + acpi_timer_timecounter.tc_counter_mask = 0xffffffff; + else + acpi_timer_timecounter.tc_counter_mask = 0x00ffffff; + acpi_timer_timecounter.tc_frequency = acpi_timer_frequency; + + tc_init(&acpi_timer_timecounter); return (0); } @@ -282,38 +256,12 @@ acpi_timer_suspend_handler(struct timecounter *newtc) } } -/* - * Fetch current time value from reliable hardware. - */ static u_int acpi_timer_get_timecount(struct timecounter *tc) { return (acpi_timer_read()); } -/* - * Fetch current time value from hardware that may not correctly - * latch the counter. We need to read until we have three monotonic - * samples and then use the middle one, otherwise we are not protected - * against the fact that the bits can be wrong in two directions. If - * we only cared about monosity, two reads would be enough. - */ -static u_int -acpi_timer_get_timecount_safe(struct timecounter *tc) -{ - u_int u1, u2, u3; - - u2 = acpi_timer_read(); - u3 = acpi_timer_read(); - do { - u1 = u2; - u2 = u3; - u3 = acpi_timer_read(); - } while (u1 > u2 || u2 > u3); - - return (u2); -} - /* * Timecounter frequency adjustment interface. */