Skip to content

drv-i2c-devices: make TMP117 driver nicer - #2666

Merged
hawkw merged 5 commits into
masterfrom
eliza/OOPS-I-ACCIDENTALLY-THE-WHOLE-TEMPERATURE-SENSOR-DRIVER
Sep 4, 2026
Merged

drv-i2c-devices: make TMP117 driver nicer#2666
hawkw merged 5 commits into
masterfrom
eliza/OOPS-I-ACCIDENTALLY-THE-WHOLE-TEMPERATURE-SENSOR-DRIVER

Conversation

@hawkw

@hawkw hawkw commented Sep 1, 2026

Copy link
Copy Markdown
Member

OOPS I ACCIDENTALLY REWROTE THE WHOLE TEMPERATURE SENSOR DRIVER AND ALSO ALL THE CODE THAT USES IT SORRY GUYS.

In particular, in #2650, @jamesmunns quite reasonably asked why I wasn't using the driver and hard coding register reads (which I had done because I copied the code from host-sp-comms and hadn't realized the driver did the EEPROM stuff. It turned out that it did, but I didn't like the way it was doing it...and clearly, Matt hadn't liked it either, which is why host-sp-comms was also not using it. In particular, the driver code appears to have been written by Bryan some time before the existence of u16::from_be_bytes, and therefore is in the habit of representing a big-endian 16 bit register as a tuple and then passing it around, which I found unfortunate. Presumably the fact that only the driver understands the tuple's endianness is also the reason it, it makes the enum of device registers public, but does not make the read_reg function public, which I also found unfortunate. This commit fixes all of that. It also changes host-sp-comms to actually use the driver instead of ignoring it.

I pulled this out of #2650 because it felt unrelated.

This code appears to predate `u16::from_be_bytes`, and therefore is in
the habit of representing a big-endian 16 bit register as a tuple and
then passing it around, which I found unfortunate. Presumably the fact
that only the driver understands the tuple's endianness is also the
reason it, it makes the enum of device registers public, but does not
make the `read_reg` function public, which I *also* found unfortunate.
THis commit fixes all of that. It also changes `host=-sp-comms` to
actually use the driver instead of ignoring it.
@hawkw
hawkw force-pushed the eliza/OOPS-I-ACCIDENTALLY-THE-WHOLE-TEMPERATURE-SENSOR-DRIVER branch from ec40422 to 2a70456 Compare September 2, 2026 00:05
@hawkw
hawkw marked this pull request as draft September 2, 2026 20:37
@hawkw

hawkw commented Sep 2, 2026

Copy link
Copy Markdown
Member Author

poking around a bit via fmtopo to make sure I haven't broken host-sp-comms. Here's before:

2YFH3T3G # /usr/lib/fm/fmd/fmtopo -V hc://:product-id=913-0000023:product-sn=2YFH3T3G:server-id=2YFH3T3G:chassis-id=2YFH3T3G:serial=0117a9520f93a57a:part=TMP117:revision=0/chassis=0/systemboard=0/slot=27/board=0/ic=0?sensor=temp
TIME                 UUID
Feb 02 11:10:42 14a5bf46-f7ae-4656-a95f-ea560d1104ac

hc://:product-id=913-0000023:product-sn=2YFH3T3G:server-id=2YFH3T3G:chassis-id=2YFH3T3G:serial=0117a9520f93a57a:part=TMP117:revision=0/chassis=0/systemboard=0/slot=27/board=0/ic=0?sensor=temp
  group: protocol                       version: 1   stability: Private/Private
    resource          fmri      hc://:product-id=913-0000023:product-sn=2YFH3T3G:server-id=2YFH3T3G:chassis-id=2YFH3T3G:serial=0117a9520f93a57a:part=TMP117:revision=0/chassis=0/systemboard=0/slot=27/board=0/ic=0?sensor=temp
  group: authority                      version: 1   stability: Private/Private
    product-id        string    913-0000023
    product-sn        string    2YFH3T3G
    chassis-id        string    2YFH3T3G
    server-id         string    2YFH3T3G
  group: facility                       version: 1   stability: Private/Private
    sensor-class      string    threshold
    type              uint32    0x1 (TEMP)
    units             uint32    0x1 (DEGREES_C)
    remote-agents     string[]  [ "mgs" ]
  group: remote-mgs                     version: 1   stability: Private/Private
    mgs-sensor-id     uint32    0x69

2YFH3T3G #
2YFH3T3G # /usr/lib/fm/fmd/fmtopo -V hc://:product-id=913-0000023:product-sn=2YFH3T3G:server-id=2YFH3T3G:chassis-id=2YFH3T3G:serial=0117a9520f93a57a:part=TMP117:revision=0/chassis=0/systemboard=0/slot=27/board=0/ic=0?sensor=temp
TIME                 UUID
Dec 28 00:01:47 88626dae-2aa5-4776-a39f-6f0f064acd84

hc://:product-id=913-0000023:product-sn=2YFH3T3G:server-id=2YFH3T3G:chassis-id=2YFH3T3G:serial=0117a9520f93a57a:part=TMP117:revision=0/chassis=0/systemboard=0/slot=27/board=0/ic=0?sensor=temp
  group: protocol                       version: 1   stability: Private/Private
    resource          fmri      hc://:product-id=913-0000023:product-sn=2YFH3T3G:server-id=2YFH3T3G:chassis-id=2YFH3T3G:serial=0117a9520f93a57a:part=TMP117:revision=0/chassis=0/systemboard=0/slot=27/board=0/ic=0?sensor=temp
  group: authority                      version: 1   stability: Private/Private
    product-id        string    913-0000023
    product-sn        string    2YFH3T3G
    chassis-id        string    2YFH3T3G
    server-id         string    2YFH3T3G
  group: facility                       version: 1   stability: Private/Private
    sensor-class      string    threshold
    type              uint32    0x1 (TEMP)
    units             uint32    0x1 (DEGREES_C)
    remote-agents     string[]  [ "mgs" ]
  group: remote-mgs                     version: 1   stability: Private/Private
    mgs-sensor-id     uint32    0x69

2YFH3T3G #

@hawkw
hawkw marked this pull request as ready for review September 2, 2026 21:24

@jamesmunns jamesmunns left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One nit, looks good!

Comment thread task/host-sp-comms/src/inventory/compute_sled_common.rs
@hawkw

hawkw commented Sep 4, 2026

Copy link
Copy Markdown
Member Author

triple-checking that host-sp-comms on the latest version of this is endianness-confused in the way that works and not the way that seems correct but doesn't work doesn't work:

2CN2M459 # /usr/lib/fm/fmd/fmtopo | grep part=TMP117
hc://:product-id=913-0000023:product-sn=2CN2M459:server-id=2CN2M459:chassis-id=2CN2M459:serial=0117b2cb0fa2a57a:part=TMP117:revision=0/chassis=0/systemboard=0/slot=24/board=0/ic=0
hc://:product-id=913-0000023:product-sn=2CN2M459:server-id=2CN2M459:chassis-id=2CN2M459:serial=0117b2cb0fa2a57a:part=TMP117:revision=0/chassis=0/systemboard=0/slot=24/board=0/ic=0?sensor=temp
hc://:product-id=913-0000023:product-sn=2CN2M459:server-id=2CN2M459:chassis-id=2CN2M459:serial=0117a4790f6da57a:part=TMP117:revision=0/chassis=0/systemboard=0/slot=25/board=0/ic=0
hc://:product-id=913-0000023:product-sn=2CN2M459:server-id=2CN2M459:chassis-id=2CN2M459:serial=0117a4790f6da57a:part=TMP117:revision=0/chassis=0/systemboard=0/slot=25/board=0/ic=0?sensor=temp
hc://:product-id=913-0000023:product-sn=2CN2M459:server-id=2CN2M459:chassis-id=2CN2M459:serial=0117a48a0f84a57a:part=TMP117:revision=0/chassis=0/systemboard=0/slot=26/board=0/ic=0
hc://:product-id=913-0000023:product-sn=2CN2M459:server-id=2CN2M459:chassis-id=2CN2M459:serial=0117a48a0f84a57a:part=TMP117:revision=0/chassis=0/systemboard=0/slot=26/board=0/ic=0?sensor=temp
hc://:product-id=913-0000023:product-sn=2CN2M459:server-id=2CN2M459:chassis-id=2CN2M459:serial=0117a4660f9ba57a:part=TMP117:revision=0/chassis=0/systemboard=0/slot=27/board=0/ic=0
hc://:product-id=913-0000023:product-sn=2CN2M459:server-id=2CN2M459:chassis-id=2CN2M459:serial=0117a4660f9ba57a:part=TMP117:revision=0/chassis=0/systemboard=0/slot=27/board=0/ic=0?sensor=temp
hc://:product-id=913-0000023:product-sn=2CN2M459:server-id=2CN2M459:chassis-id=2CN2M459:serial=0117a2160f5ba57a:part=TMP117:revision=0/chassis=0/systemboard=0/slot=28/board=0/ic=0
hc://:product-id=913-0000023:product-sn=2CN2M459:server-id=2CN2M459:chassis-id=2CN2M459:serial=0117a2160f5ba57a:part=TMP117:revision=0/chassis=0/systemboard=0/slot=28/board=0/ic=0?sensor=temp
hc://:product-id=913-0000023:product-sn=2CN2M459:server-id=2CN2M459:chassis-id=2CN2M459:serial=0117a6ef0f8ea57a:part=TMP117:revision=0/chassis=0/systemboard=0/slot=29/board=0/ic=0
hc://:product-id=913-0000023:product-sn=2CN2M459:server-id=2CN2M459:chassis-id=2CN2M459:serial=0117a6ef0f8ea57a:part=TMP117:revision=0/chassis=0/systemboard=0/slot=29/board=0/ic=0?sensor=temp
2CN2M459 #

and in fact, it is properly endianness-confused!

@hawkw
hawkw merged commit 6acf2f8 into master Sep 4, 2026
190 checks passed
@hawkw
hawkw deleted the eliza/OOPS-I-ACCIDENTALLY-THE-WHOLE-TEMPERATURE-SENSOR-DRIVER branch September 4, 2026 20:11
hawkw added a commit that referenced this pull request Sep 4, 2026
Depends on oxidecomputer/management-gateway-service#500.
Depends on #2666.

This branch updates the `gateway-messages` dependency to pick up the new
`component-get-vpd` API and associated messages for reading the vital
product data from a component, and, well, implements that API. While the
MGS PR better describes the layout of the various wire types, this is
where most of the actual heavy lifting happened. Of the various attempts
I've made at adding FRUID VPD to `control-plane-agent`, this is the
first one I'm actually more or less satisfied with.

Fixes #2212.
Closes #2217.
Closes #2220.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants