ithwm: add ITE IT87xx SuperIO hardware monitor driver #6

Open
olivier wants to merge 6 commits from olivier/olivier-ithwm into main AGit
Member

Add a new kernel driver for the hardware monitor logical device (LDN 4) of
ITE IT87xx SuperIO chips, tested on the IT8613.

The driver attaches as a child of the superio(4) bus and exposes temperatures,
fan speeds, and voltages via sysctl(8) under dev.ithwm.:

  • temp0..temp2: temperature sensors, reported in decikelvin ("IK"
    format, compatible with amdtemp(4) and lm75(4))
  • fan0..fan2: fan speeds in RPM, supporting both 8-bit legacy and
    16-bit tachometer modes
  • vin0..vin7, vbat: voltages in millivolts (1 LSB ~= 16 mV)
Add a new kernel driver for the hardware monitor logical device (LDN 4) of ITE IT87xx SuperIO chips, tested on the IT8613. The driver attaches as a child of the superio(4) bus and exposes temperatures, fan speeds, and voltages via sysctl(8) under dev.ithwm.<unit>: - temp0..temp2: temperature sensors, reported in decikelvin ("IK" format, compatible with amdtemp(4) and lm75(4)) - fan0..fan2: fan speeds in RPM, supporting both 8-bit legacy and 16-bit tachometer modes - vin0..vin7, vbat: voltages in millivolts (1 LSB ~= 16 mV)
ithwm: add ITE IT87xx SuperIO hardware monitor driver
Some checks are pending
Checklist / commit (pull_request_target) Waiting to run
Cross-build Kernel / amd64 ubuntu-22.04 (clang-15) (pull_request) Blocked by required conditions
Cross-build Kernel / aarch64 ubuntu-22.04 (clang-15) (pull_request) Blocked by required conditions
Cross-build Kernel / amd64 ubuntu-24.04 (clang-18) (pull_request) Blocked by required conditions
Cross-build Kernel / aarch64 ubuntu-24.04 (clang-18) (pull_request) Blocked by required conditions
Cross-build Kernel / amd64 macos-latest (clang-18) (pull_request) Blocked by required conditions
Cross-build Kernel / aarch64 macos-latest (clang-18) (pull_request) Blocked by required conditions
Style Checker / Style Checker (pull_request) Blocked by required conditions
000fbd0261
Add a new kernel driver for the hardware monitor logical device (LDN 4) of
ITE IT87xx SuperIO chips, tested on the IT8613.

The driver attaches as a child of the superio(4) bus and exposes temperatures,
fan speeds, and voltages via sysctl(8) under dev.ithwm.<unit>:

- temp0..temp2: temperature sensors, reported in decikelvin ("IK"
  format, compatible with amdtemp(4) and lm75(4))
- fan0..fan2: fan speeds in RPM, supporting both 8-bit legacy and
  16-bit tachometer modes
- vin0..vin7, vbat: voltages in millivolts (1 LSB ~= 16 mV)
olivier requested reviews from imp, jhb, markj 2026-04-13 20:27:52 +00:00
Author
Member

Example on Aaostar WTR MAX:

superio0: <ITE IT8613 SuperIO (revision 0x0c)> at port 0x2e-0x2f on isa0
ithwm0: <ITE IT87xx Hardware Monitor> at HWM ldn 0x04 on superio0
olivier@nas:~ $ sysctl dev.ithwm.0
dev.ithwm.0.vbat: 2288
dev.ithwm.0.vin7: 3648
dev.ithwm.0.vin6: 2704
dev.ithwm.0.vin5: 3328
dev.ithwm.0.vin4: 2832
dev.ithwm.0.vin3: 288
dev.ithwm.0.vin2: 2816
dev.ithwm.0.vin1: 736
dev.ithwm.0.vin0: 448
dev.ithwm.0.fan2: 2518
dev.ithwm.0.fan1: 1741
dev.ithwm.0.fan0: 0
dev.ithwm.0.temp2: 32.0C
dev.ithwm.0.temp1: 33.0C
dev.ithwm.0.temp0: 34.0C
dev.ithwm.0.%iommu:
dev.ithwm.0.%parent: superio0
dev.ithwm.0.%pnpinfo: type=HWM
dev.ithwm.0.%location: ldn=0x04
dev.ithwm.0.%driver: ithwm
dev.ithwm.0.%desc: ITE IT87xx Hardware Monitor
Example on Aaostar WTR MAX: ``` superio0: <ITE IT8613 SuperIO (revision 0x0c)> at port 0x2e-0x2f on isa0 ithwm0: <ITE IT87xx Hardware Monitor> at HWM ldn 0x04 on superio0 olivier@nas:~ $ sysctl dev.ithwm.0 dev.ithwm.0.vbat: 2288 dev.ithwm.0.vin7: 3648 dev.ithwm.0.vin6: 2704 dev.ithwm.0.vin5: 3328 dev.ithwm.0.vin4: 2832 dev.ithwm.0.vin3: 288 dev.ithwm.0.vin2: 2816 dev.ithwm.0.vin1: 736 dev.ithwm.0.vin0: 448 dev.ithwm.0.fan2: 2518 dev.ithwm.0.fan1: 1741 dev.ithwm.0.fan0: 0 dev.ithwm.0.temp2: 32.0C dev.ithwm.0.temp1: 33.0C dev.ithwm.0.temp0: 34.0C dev.ithwm.0.%iommu: dev.ithwm.0.%parent: superio0 dev.ithwm.0.%pnpinfo: type=HWM dev.ithwm.0.%location: ldn=0x04 dev.ithwm.0.%driver: ithwm dev.ithwm.0.%desc: ITE IT87xx Hardware Monitor ```
ithwm: fix several correctness issues found during code review
Some checks are pending
Checklist / commit (pull_request_target) Waiting to run
Cross-build Kernel / amd64 ubuntu-22.04 (clang-15) (pull_request) Blocked by required conditions
Cross-build Kernel / aarch64 ubuntu-22.04 (clang-15) (pull_request) Blocked by required conditions
Cross-build Kernel / amd64 ubuntu-24.04 (clang-18) (pull_request) Blocked by required conditions
Cross-build Kernel / aarch64 ubuntu-24.04 (clang-18) (pull_request) Blocked by required conditions
Cross-build Kernel / amd64 macos-latest (clang-18) (pull_request) Blocked by required conditions
Cross-build Kernel / aarch64 macos-latest (clang-18) (pull_request) Blocked by required conditions
Style Checker / Style Checker (pull_request) Blocked by required conditions
efc8481ff9
- Remove unused sc->dev field from softc
- Add mtx_assert(MA_OWNED) to ithwm_readb() to enforce its locking
  contract: callers must hold sc->lock before calling it
- Replace dead runtime range checks in sysctl handlers with KASSERT;
  arg2 is a compile-time constant set by SYSCTL_ADD_PROC so EINVAL
  can never be returned in practice
- Add missing bus_delete_resource() on the bus_alloc_resource_any()
  failure path in ithwm_attach()
- Read ITHWM_REG_CFG directly via bus_write_1/bus_read_1 in attach
  instead of ithwm_readb() to avoid triggering the lock assertion
  (no concurrent access is possible during attach)
- Fix detach/sysctl race: call sysctl_ctx_free() before mtx_destroy()
  and bus_release_resource() to drain any in-progress sysctl handler
  before tearing down hardware state
- Remove dead io_res != NULL guard in detach (io_res is always set
    when detach is reached)
@ -0,0 +3,4 @@
*
* Copyright (c) 2024 Olivier Cochard
*
* Redistribution and use in source and binary forms, with or without
Member

You don't need anymore the full verbose text for the license if you have the SPDX header.

You don't need anymore the full verbose text for the license if you have the SPDX header.
olivier marked this conversation as resolved
ithwm: drop redundant license boilerplate
Some checks are pending
Checklist / commit (pull_request_target) Waiting to run
Cross-build Kernel / amd64 ubuntu-22.04 (clang-15) (pull_request) Blocked by required conditions
Cross-build Kernel / aarch64 ubuntu-22.04 (clang-15) (pull_request) Blocked by required conditions
Cross-build Kernel / amd64 ubuntu-24.04 (clang-18) (pull_request) Blocked by required conditions
Cross-build Kernel / aarch64 ubuntu-24.04 (clang-18) (pull_request) Blocked by required conditions
Cross-build Kernel / amd64 macos-latest (clang-18) (pull_request) Blocked by required conditions
Cross-build Kernel / aarch64 macos-latest (clang-18) (pull_request) Blocked by required conditions
Style Checker / Style Checker (pull_request) Blocked by required conditions
490b924357
markj left a comment
Member

Overall looks fine. This is missing a man page.

Overall looks fine. This is missing a man page.
@ -0,0 +156,4 @@
* arg2 = 0..2 selects FAN1..FAN3.
*
* 16-bit mode: count = (high << 8) | low; RPM = clock / count.
* 8-bit mode: divisor from FANDIV; RPM = clock / (count * divisor).
Member

This doesn't need to be static.

This doesn't need to be static.
olivier marked this conversation as resolved
@ -0,0 +164,4 @@
{
struct ithwm_softc *sc = arg1;
int idx = arg2;
uint16_t count;
Member

Why not define raw to be a uint8_t?

Why not define `raw` to be a uint8_t?
Author
Member

@markj wrote in #6 (comment):

Why not define raw to be a uint8_t?

(I have difficulties to match your comment to the correct line of code)
In ithwm_sysctl_vin((), Voltage is using a uint8_t for raw because it can’t be negative, but in ithwm_sysctl_temp() couldn’t we get negative temperature ?

@markj wrote in https://ron-dev.freebsd.org/FreeBSD/src/pulls/6#issuecomment-37: > Why not define `raw` to be a uint8_t? (I have difficulties to match your comment to the correct line of code) In ithwm_sysctl_vin((), Voltage is using a uint8_t for `raw` because it can’t be negative, but in ithwm_sysctl_temp() couldn’t we get negative temperature ?
Member

Yeah, this comment is supposed to apply to ithwm_sysctl_temp(), looks like the line number tracking is a bit broken? (Or maybe I put the comment in the wrong place originally? I'm not sure.)

In any case, I see now, this looks ok.

Yeah, this comment is supposed to apply to ithwm_sysctl_temp(), looks like the line number tracking is a bit broken? (Or maybe I put the comment in the wrong place originally? I'm not sure.) In any case, I see now, this looks ok.
Member

You sent the command and later @olivier pushed a new version where he delete some lines. github suffers from the same issue.

You sent the command and later @olivier pushed a new version where he delete some lines. github suffers from the same issue.
@ -0,0 +196,4 @@
rpm = 0;
else
rpm = ITHWM_FAN_CLOCK / ((unsigned int)lo * divisor);
}
Member

These arrays don't need to be static.

These arrays don't need to be static.
olivier marked this conversation as resolved
Member

Folks, why do I get notifications for this pull request?

Folks, why do I get notifications for this pull request?
Member

@michaelo wrote in #6 (comment):

Folks, why do I get notifications for this pull request?

there's some backend fiddling going on to make notifications work properly, and by accident the entire src group received notifications for all src PRs. i think @bapt is working on this.

@michaelo wrote in https://ron-dev.freebsd.org/FreeBSD/src/pulls/6#issuecomment-41: > Folks, why do I get notifications for this pull request? there's some backend fiddling going on to make notifications work properly, and by accident the entire src group received notifications for all src PRs. i think @bapt is working on this.
ithwm: remove unnecessary static qualifier from local const arrays and add man page
Some checks are pending
Checklist / commit (pull_request_target) Waiting to run
Cross-build Kernel / amd64 ubuntu-22.04 (clang-15) (pull_request) Blocked by required conditions
Cross-build Kernel / aarch64 ubuntu-22.04 (clang-15) (pull_request) Blocked by required conditions
Cross-build Kernel / amd64 ubuntu-24.04 (clang-18) (pull_request) Blocked by required conditions
Cross-build Kernel / aarch64 ubuntu-24.04 (clang-18) (pull_request) Blocked by required conditions
Cross-build Kernel / amd64 macos-latest (clang-18) (pull_request) Blocked by required conditions
Cross-build Kernel / aarch64 macos-latest (clang-18) (pull_request) Blocked by required conditions
Style Checker / Style Checker (pull_request) Blocked by required conditions
d775374639
Local const arrays initialised with compile-time constants do not need
to be static; the compiler already handles them as read-only data
@ -0,0 +1,86 @@
.\" SPDX-License-Identifier: BSD-2-Clause
.\"
.\" Copyright (c) 2024 Olivier Cochard
.\"
Member
.\"
.\" Copyright (c) 2024 Olivier Cochard
.\"
.\" SPDX-License-Identifier: BSD-2-Clause
.\"

style.9 and the licensing guide recommend a blank comment at the beginning for consistency with C comments, and placing the copyright line before the spdx line when using spdx only license declaration.

``` .\" .\" Copyright (c) 2024 Olivier Cochard .\" .\" SPDX-License-Identifier: BSD-2-Clause .\" ``` style.9 and the licensing guide recommend a blank comment at the beginning for consistency with C comments, and placing the copyright line before the spdx line when using spdx only license declaration.
olivier marked this conversation as resolved
@ -0,0 +9,4 @@
.Nm ithwm
.Nd hardware monitor driver for ITE IT87xx Super I/O chips
.Sh SYNOPSIS
To compile this driver into the kernel, place the following lines in your
Member

Please consider using the format I proposed on arch@ and at BSDCan. We have almost 200 manuals in the tree using this format, and it is more consistent with the rest of BSD ecosystem.

.Sh SYNOPSIS
.Cd device superio
.Cd device ithwm
.Pp
In
.Xr loader.conf 5 :
.Cd ithwm_load="YES"
Please consider using the format I proposed on arch@ and at BSDCan. We have almost 200 manuals in the tree using this format, and it is more consistent with the rest of BSD ecosystem. ``` .Sh SYNOPSIS .Cd device superio .Cd device ithwm .Pp In .Xr loader.conf 5 : .Cd ithwm_load="YES" ```
Author
Member

@ziaee wrote in #6 (comment):

Please consider using the format I proposed on arch@ and at BSDCan. We have almost 200 manuals in the tree using this format, and it is more consistent with the rest of BSD ecosystem.

.Sh SYNOPSIS
.Cd device superio
.Cd device ithwm
.Pp
In
.Xr loader.conf 5 :
.Cd ithwm_load="YES"

do you have a link ?

@ziaee wrote in https://ron-dev.freebsd.org/FreeBSD/src/pulls/6#issuecomment-47: > Please consider using the format I proposed on arch@ and at BSDCan. We have almost 200 manuals in the tree using this format, and it is more consistent with the rest of BSD ecosystem. > > ```text > .Sh SYNOPSIS > .Cd device superio > .Cd device ithwm > .Pp > In > .Xr loader.conf 5 : > .Cd ithwm_load="YES" > ``` do you have a link ?
Member
Sure, https://marc.info/?l=freebsd-arch&m=176782215606871
olivier marked this conversation as resolved
@ -0,0 +43,4 @@
.Bl -bullet -compact
.It
ITE IT8613E
.El
Member

how do we do code sugestions? I tried clicking and dragging the lines but no avail.

.Sh HARDWARE
The
.Nm
driver supports the following Super I/O controllers:
.Pp
.Bl -bullet -compact
.It
ITE IT8613E
.El

style.mdoc.7 recommends using a HARDWARE section for this, which gets pulled into the hardware release note, and declaring the type of supported device at the end of the introductory sentence because the entire hardware section appears on it's own with no other context.

how do we do code sugestions? I tried clicking and dragging the lines but no avail. ``` .Sh HARDWARE The .Nm driver supports the following Super I/O controllers: .Pp .Bl -bullet -compact .It ITE IT8613E .El ``` style.mdoc.7 recommends using a HARDWARE section for this, which gets pulled into the hardware release note, and declaring the type of supported device at the end of the introductory sentence because the entire hardware section appears on it's own with no other context.
olivier marked this conversation as resolved
ithwm: fix man page style issues
Some checks are pending
Checklist / commit (pull_request_target) Waiting to run
Cross-build Kernel / amd64 ubuntu-22.04 (clang-15) (pull_request) Blocked by required conditions
Cross-build Kernel / aarch64 ubuntu-22.04 (clang-15) (pull_request) Blocked by required conditions
Cross-build Kernel / amd64 ubuntu-24.04 (clang-18) (pull_request) Blocked by required conditions
Cross-build Kernel / aarch64 ubuntu-24.04 (clang-18) (pull_request) Blocked by required conditions
Cross-build Kernel / amd64 macos-latest (clang-18) (pull_request) Blocked by required conditions
Cross-build Kernel / aarch64 macos-latest (clang-18) (pull_request) Blocked by required conditions
Style Checker / Style Checker (pull_request) Blocked by required conditions
eb5103cbb7
ziaee approved these changes 2026-04-14 19:55:41 +00:00
ziaee left a comment
Member

manpage looks fine to me. don't forget to fix the license in the other files

manpage looks fine to me. don't forget to fix the license in the other files
Fix date in license
Some checks failed
Cross-build Kernel / amd64 ubuntu-22.04 (clang-15) (pull_request) Blocked by required conditions
Cross-build Kernel / aarch64 ubuntu-22.04 (clang-15) (pull_request) Blocked by required conditions
Cross-build Kernel / amd64 ubuntu-24.04 (clang-18) (pull_request) Blocked by required conditions
Cross-build Kernel / aarch64 ubuntu-24.04 (clang-18) (pull_request) Blocked by required conditions
Cross-build Kernel / amd64 macos-latest (clang-18) (pull_request) Blocked by required conditions
Cross-build Kernel / aarch64 macos-latest (clang-18) (pull_request) Blocked by required conditions
Style Checker / Style Checker (pull_request) Blocked by required conditions
Checklist / commit (pull_request_target) Has been cancelled
9b1e10b93b
markj approved these changes 2026-04-15 15:13:32 +00:00
markj left a comment
Member

Looks good!

Looks good!
Some checks failed
Cross-build Kernel / amd64 ubuntu-22.04 (clang-15) (pull_request) Blocked by required conditions
Cross-build Kernel / aarch64 ubuntu-22.04 (clang-15) (pull_request) Blocked by required conditions
Cross-build Kernel / amd64 ubuntu-24.04 (clang-18) (pull_request) Blocked by required conditions
Cross-build Kernel / aarch64 ubuntu-24.04 (clang-18) (pull_request) Blocked by required conditions
Cross-build Kernel / amd64 macos-latest (clang-18) (pull_request) Blocked by required conditions
Cross-build Kernel / aarch64 macos-latest (clang-18) (pull_request) Blocked by required conditions
Style Checker / Style Checker (pull_request) Blocked by required conditions
Checklist / commit (pull_request_target) Has been cancelled
This pull request can be merged automatically.
Some workflows are waiting to be reviewed.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin +refs/pull/6/head:olivier/olivier-ithwm
git switch olivier/olivier-ithwm
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
6 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
FreeBSD/src!6
No description provided.