From nobody Tue Nov 03 16:41:19 2026 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 4jJvTx3WsHz6yY7w for ; Tue, 03 Nov 2026 16:41:25 +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 4jJvTx1QZsz4Qkf for ; Tue, 03 Nov 2026 16:41:25 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1793724085; 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=CTaDqRm7zbiG/qDb8VLZllTpJhYN1TyiHlTaTdYIsBjAqWvvJkaeZdzqqM8/K8wbQaWdpN x2L5FSkOz2TB5XgIz+6vSnJ82MtjFtxBLbOPVBs8Q6CcqXggtq9y3R25mcIxDxtPRdmprf QEYwWHpz3hHcozLhXyIBh8fSTDnZwEzDSFcI/D7R5wFbMRpLAWzNDGuaSxu+ApSxaTlOl+ 5MbjoPlVIkVpqAbZmlsnqzUjlFu/neOt5R4xH5rZFsPWbz5at9ixFnZSwEiu5IMfMGSU0O PfhKKVbC5XgB/49M3TVSZf4aPma8DhocOvilyDzYDAa3PzXfkn/9VPa7r8VoKw== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1793724085; b=QNolCIJ/lUVmck7KONBl6o5GZ0qjew0gn8UDXVN8mj09ZmgoUT9OPuuidziRpLG1BEDgXC fe6BcChgOrRO5/yK9I/BHt4XB6gfnamHPckFRijz6ynnVj27oUYH8jQvn4Q06R8PK7fV0p aU4F9ex1UaL1tFt7cbNRyeZKmJmJpmNcOx0Me/sygoHDHbNcVh1rYrnB2sRCjmjTUtsACP HsIPZI7n1N8CxMicXCOirRgMx2C/6214GxvGFKachSSFHPgGUikEGaT1zEK3ssJ5d+wmlj WHdq4/+LnRtFC3mL7DV+Nc8oWazbR4B7YYS+pgCCCQC937R7HYZn/QDcYwdikQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1793724085; 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=rPETpK1wZUdk9WIXCs4pxgbJIMTbFLjMW215MM7EtdkbgN8xiGfTtzv2uCN8+dUbsJhIRm cm15/3jQjIbO1X9toCT/LMX7Cji3obl4jn6RrnUIqpHMym+2RNncg2xNoQda4rE/4hSEdp Il+qVn5QK3YZe6rNvQLUlgsJ6B4+o+CIprGZRTerRnKD+WeiIK60RggvIXunPtRKi0ZSYq O0kl8uUy7YzDBI+mrs8OppPRai6T/f6ALFMLKdyJPp8dw39i50NmEQhY+eJq5l1+KXUioa qup9mDUdb2SYeROB/Gs27fQmX0w2++in8XM8uqdENi+OGu9qz7FeTG3RWRlcFA== 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 4jJvTx0ml3zPB1 for ; Tue, 03 Nov 2026 16:41:25 +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-all X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org List-Id: Commit messages for all branches 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);