From nobody Sun Feb 22 04:06:51 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 4fJVmX1Yv8z6StPt for ; Sun, 22 Feb 2026 04:06:52 +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 "R12" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4fJVmW5ZbJz3X04 for ; Sun, 22 Feb 2026 04:06:51 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1771733211; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=5UN38qZPaTo0BjugoWJzMyqk2iukOix67BCUC6fPOMY=; b=pwr/i6/iOqplOGj66/XnWCzqf0YEPWL1aKUAijovrIkGDWpauY0Ef3cgwAfpLcLjy8qn5d tDkjmcewfpfwncLehgsJ9h+o72pbE0oxoE9utMleb8gFLqideWCTBMJzSY9I5rBPbD9k7B 3Ic27wlzhwUP9a4QS+z6/8AC9324OEl4iuI6FH4wDbr535lWXa4ccsj3AObt6JyFbwtoTy FrePwxbL7jd2Qg0lHZWj8bXh3Ju0STVcJKFvdd6706m4Xut8XztKDkcHlwhb8bbfNp2JmU tlHUcZ12gnve8O30Q4YanwIGkqMzUh5kIvKwNGuzQw9t8+NDS2t21Q0hz/cKfw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1771733211; a=rsa-sha256; cv=none; b=qjx/bbSXuxckUzYgTpfSmWbu0zV4TN57L8cSr496tmp7q3XmAJu/0i+cpqopyxD1BoIAI2 9OM672wpvboIzzzwuOHnmWU7NYATNsN/w8csq3ThLum1Ff/f8qmIxLnFE/LD/69HkSw1OS hF+V9m5MN813Fi7oD0iMO44F/L0pb1WeKyzuyS4HLUE/mRvqeKi4jLx1m2S53Fn0uxmNti CVe85+q3OBr2SEykEjzQxkrFaYPvDWUouDrfh1ljc4BTabo0lxvv3cG6G0wzarTIbKyc7P 2t8DfZ9DATgH+b8ILBiFQyM/M6+csWtTbHREordWPDebzm2fWr02CVyXux+dqA== 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=1771733211; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=5UN38qZPaTo0BjugoWJzMyqk2iukOix67BCUC6fPOMY=; b=vZMFlKsMQWpEw3/xo4SbJGW0v/4DhD9QnjbcS7uiTnAvzprfem3g+h8wrflfG17nEbUHWh RL5lW8gqLUw8XpakMubsII4dhwaQsyU76VILZchHACRowjCX7ifpeUjjFtCUGMRRc1tqPW sT6XH41TpWmvvKQsZ5ZHkLT+J5W43K27BmAUpCr+7TX3B9g6BegFOH/SUu8OjqdBZP4gE+ 71iagF8aB1jC1gMMBb4210oASabeZLRJBIlgdNM1dOYvQbzOjL8v+ETC7uLtsjOHUWKgYo e23bqVVpD6QC5gqMUgyp+AK78CDTJrOW6cGwdoGZm9PYFuE/iWzktYjIdeBgHQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4fJVmW53zzzClJ for ; Sun, 22 Feb 2026 04:06:51 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 23123 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Sun, 22 Feb 2026 04:06:51 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Cc: Abdelkader Boudih From: Enji Cooper Subject: git: f0d2b3799722 - stable/14 - asmc: add per-fan manual mode control via sysctl 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 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: ngie X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: f0d2b37997227cd580abadefbb1cd71fcaef9c6e Auto-Submitted: auto-generated Date: Sun, 22 Feb 2026 04:06:51 +0000 Message-Id: <699a80db.23123.5c33e07b@gitrepo.freebsd.org> The branch stable/14 has been updated by ngie: URL: https://cgit.FreeBSD.org/src/commit/?id=f0d2b37997227cd580abadefbb1cd71fcaef9c6e commit f0d2b37997227cd580abadefbb1cd71fcaef9c6e Author: Abdelkader Boudih AuthorDate: 2026-01-05 18:03:23 +0000 Commit: Enji Cooper CommitDate: 2026-02-22 04:04:06 +0000 asmc: add per-fan manual mode control via sysctl Add per-fan manual mode control via dev.asmc.0.fan.N.manual sysctl. Apple SMCs support manual fan control via the FS! SMC key, a 16-bit bitmask where each bit controls one fan (0=auto, 1=manual). This change adds a new sysctl per fan: dev.asmc.0.fan.N.manual (0=auto, 1=manual) When set to manual mode (1), the fan runs at the speed set via dev.asmc.0.fan.N.targetspeed instead of automatic thermal control. When set to auto mode (0), the SMC controls fan speed automatically. The FS! key was already defined in asmcvar.h but not accessible. This exposes it for debugging, testing, and advanced fan control. Implementation uses read-modify-write to allow independent control of each fan without affecting others. Reviewed by: adrian, markj MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D54437 (cherry picked from commit 1ecac45cfc5f0886907c34ec0da2c1b32618665d) --- sys/dev/asmc/asmc.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/sys/dev/asmc/asmc.c b/sys/dev/asmc/asmc.c index e4b1afa9619d..aabbc3fbd0b0 100644 --- a/sys/dev/asmc/asmc.c +++ b/sys/dev/asmc/asmc.c @@ -98,6 +98,7 @@ static int asmc_mb_sysctl_fansafespeed(SYSCTL_HANDLER_ARGS); static int asmc_mb_sysctl_fanminspeed(SYSCTL_HANDLER_ARGS); static int asmc_mb_sysctl_fanmaxspeed(SYSCTL_HANDLER_ARGS); static int asmc_mb_sysctl_fantargetspeed(SYSCTL_HANDLER_ARGS); +static int asmc_mb_sysctl_fanmanual(SYSCTL_HANDLER_ARGS); static int asmc_temp_sysctl(SYSCTL_HANDLER_ARGS); static int asmc_mb_sysctl_sms_x(SYSCTL_HANDLER_ARGS); static int asmc_mb_sysctl_sms_y(SYSCTL_HANDLER_ARGS); @@ -639,6 +640,13 @@ asmc_attach(device_t dev) CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, dev, j, model->smc_fan_targetspeed, "I", "Fan target speed in RPM"); + + SYSCTL_ADD_PROC(sysctlctx, + SYSCTL_CHILDREN(sc->sc_fan_tree[i]), + OID_AUTO, "manual", + CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, + dev, j, asmc_mb_sysctl_fanmanual, "I", + "Fan manual mode (0=auto, 1=manual)"); } /* @@ -1330,6 +1338,53 @@ asmc_mb_sysctl_fantargetspeed(SYSCTL_HANDLER_ARGS) return (error); } +static int +asmc_mb_sysctl_fanmanual(SYSCTL_HANDLER_ARGS) +{ + device_t dev = (device_t) arg1; + int fan = arg2; + int error; + int32_t v; + uint8_t buf[2]; + uint16_t val; + + /* Read current FS! bitmask (asmc_key_read locks internally) */ + error = asmc_key_read(dev, ASMC_KEY_FANMANUAL, buf, sizeof(buf)); + if (error != 0) + return (error); + + /* Extract manual bit for this fan (big-endian) */ + val = (buf[0] << 8) | buf[1]; + v = (val >> fan) & 0x01; + + /* Let sysctl handle the value */ + error = sysctl_handle_int(oidp, &v, 0, req); + + if (error == 0 && req->newptr != NULL) { + /* Validate input (0 = auto, 1 = manual) */ + if (v != 0 && v != 1) + return (EINVAL); + /* Read-modify-write of FS! bitmask */ + error = asmc_key_read(dev, ASMC_KEY_FANMANUAL, buf, sizeof(buf)); + if (error == 0) { + val = (buf[0] << 8) | buf[1]; + + /* Modify single bit */ + if (v) + val |= (1 << fan); /* Set to manual */ + else + val &= ~(1 << fan); /* Set to auto */ + + /* Write back */ + buf[0] = val >> 8; + buf[1] = val & 0xff; + error = asmc_key_write(dev, ASMC_KEY_FANMANUAL, buf, sizeof(buf)); + } + } + + return (error); +} + /* * Temperature functions. */