From nobody Tue Nov 03 16:41:19 2026 X-Original-To: dev-commits-src-main@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 4jJvTr01xKz6yXpY for ; Tue, 03 Nov 2026 16:41: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) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 4jJvTq6Hq6z4R5v for ; Tue, 03 Nov 2026 16:41:19 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1793724079; 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=gF3cdO50LWlUv0SYe5Tz2RdnFwkwiO4xMK2E2K6R8Jo=; b=M5mj74lCbhhMuFDfGZ3feTMq9nf8rRblaND4BX0FlADWnPmIB22Xuwi/YjDDOeSO56ivDB q9l7UPd7LMRPMezQJ05B295fn67NMNG8dZp37ALvL5GaKFvIJYky1gBRp/6oiThxlwI9gy F3vyRHcEbN6FJG0E9VK6qZujGt2L94QaKyRA63CX92tlBkzerpT1RyP4JLtS5+MgFMtKOv GnKd3LUZ2xHR0JE+WMRMcIkDuV9p85OgeS6EmZcwaAFeOHTWHUA5kFOhr/z2vk1t8Jty9w G64L3CJY+cFYZIQ52hEDN4K8FTPGIqbikIYBiySBm8N84Zf68qkKdiraIHS8Mg== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1793724079; b=xcg5HKbkca1BNxod7hv+rlG4mDk03BWhbC6VnNiuGKcvPCQ9qa9wTuIqstdzJSlp35PEJo EH1plvsbNeALVFQs/6pbnioGF9IpaDLfvhl/4B40i2J2zUBBW/5BDRR/cWz1ZqZpMyS6tM /ANeVnbwF06LX8SMd0ELxikcLv9qt+b4BBZlHM6igincUfCXEc7yl0x1lafkf6y96xTP7k c4qwKb0b/kyXbGeq2QkmCRh0ZjtcWpeHyCfwQwGY7AV4EFVpkBw0kkZnWufTDx52ylizhW LUgsS6/O91NKVTfUuIqf46DelinT/pMYBU/dOyiIGK8msldGtRJtAqXZE0Guow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1793724079; 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=gF3cdO50LWlUv0SYe5Tz2RdnFwkwiO4xMK2E2K6R8Jo=; b=hOLYrUzuPE4hY/I8d2CcnQbd28sA1vzUZPix19F7ZejJUz6TtH/sQHYy7990LNvKrDDeZU eSBPOdskN2RmomuUvktlTa7Xj3S9yvjgE8wg44Ool6trIzK5+bRqWd3O7KyvG7SkpHHQYr 1q6qj9fnHc30tCULKwWU5QSzet5g0dNGlp+HJlOEeFYx23UYfmt2oKmpJEBKkXBEW2RqZV 3wmW4ASXbYOWOAPf/J2jjAbUg9Vfnin1Cr3rDXPSY5Wl2FgebbQn5jvR5mXqbyEuh6ViTF XDWMmew3kZi8srJR1VxNCYuzfLoQ+kUINrN1VppMo78ndJOHvgqqTl00cO+Vdg== 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 4jJvTq5gcqzN6B for ; Tue, 03 Nov 2026 16:41:19 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 1f126 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Tue, 03 Nov 2026 16:41:19 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Austin Shafer Subject: git: e58325fb988c - main - iichid: keep a fixed sampling cadence in polled mode List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org List-Id: Commit messages for the main branch of the src repository 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: ashafer X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: e58325fb988c1704637656b197af65e67657d6fd Auto-Submitted: auto-generated Date: Tue, 03 Nov 2026 16:41:19 +0000 Message-Id: <6aea0eaf.1f126.1134648d@gitrepo.freebsd.org> The branch main has been updated by ashafer: URL: https://cgit.FreeBSD.org/src/commit/?id=e58325fb988c1704637656b197af65e67657d6fd commit e58325fb988c1704637656b197af65e67657d6fd Author: Austin Shafer AuthorDate: 2026-09-30 19:05:49 +0000 Commit: Austin Shafer CommitDate: 2026-11-03 16:40:29 +0000 iichid: keep a fixed sampling cadence in polled mode Touchpads using sampling mode have a sampling task which is run at a certain polling rate. When the system is under load this task may not complete quickly which might stretch the time taken beyond what the polling rate should be, leading to dropped touchpad motion. On my laptop this causes the touchpad to be barely useable when the system is under heavy load, and it is really difficult to move the cursor since so many events are dropped. This change adjusts the sampling loop to schedule the next polling event to take place at a specific time in the future, based on the polling period. If servicing the poll takes longer due to load then the next sample will still be scheduled at its original time. Approved by: wulf, khng (mentor) Differential Revision: https://reviews.freebsd.org/D0914 --- sys/dev/iicbus/iichid.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/sys/dev/iicbus/iichid.c b/sys/dev/iicbus/iichid.c index d13520017e93..e31f2cf5d575 100644 --- a/sys/dev/iicbus/iichid.c +++ b/sys/dev/iicbus/iichid.c @@ -180,6 +180,7 @@ struct iichid_softc { int sampling_rate_slow; /* iicbus lock */ int sampling_rate_fast; int sampling_hysteresis; + sbintime_t next_sample; /* iicbus lock */ int missing_samples; /* iicbus lock */ int dup_samples; /* iicbus lock */ iichid_size_t dup_size; /* iicbus lock */ @@ -527,6 +528,7 @@ iichid_sampling_task(void *context, int pending) { struct iichid_softc *sc; device_t parent; + sbintime_t now, period; iichid_size_t actual; bool bus_requested; int error, rate; @@ -569,8 +571,21 @@ rearm: rate = sc->sampling_rate_slow; else rate = sc->sampling_rate_fast; + period = SBT_1S / MAX(rate, 1); + /* + * Schedule against an absolute deadline advanced by one + * period per sample, so that neither the time spent in the + * I2C transaction and handler dispatch nor the taskqueue + * wakeup latency stretches the sampling period. If the + * deadline has already passed then only advance the sample + * by one period rather than bursting polls to catch up. + */ + now = sbinuptime(); + sc->next_sample += period; + if (sc->next_sample <= now) + sc->next_sample = now + period; taskqueue_enqueue_timeout_sbt(sc->taskqueue, &sc->sampling_task, - SBT_1S / MAX(rate, 1), 0, C_PREL(2)); + sc->next_sample, 0, C_ABSOLUTE); } out: if (bus_requested) @@ -746,6 +761,7 @@ iichid_reset_callout(struct iichid_softc *sc) sc->missing_samples = sc->sampling_hysteresis; sc->dup_samples = 0; sc->dup_size = 0; + sc->next_sample = sbinuptime(); taskqueue_enqueue_timeout(sc->taskqueue, &sc->sampling_task, 0); return (0);