Skip to content

hal/temperature: correct sysfs-hwmon temperature fallback for Arc Pro… - #149

Open
thevisad wants to merge 1 commit into
intel:mainfrom
thevisad:xpum-temp-hwmon
Open

hal/temperature: correct sysfs-hwmon temperature fallback for Arc Pro…#149
thevisad wants to merge 1 commit into
intel:mainfrom
thevisad:xpum-temp-hwmon

Conversation

@thevisad

@thevisad thevisad commented Aug 2, 2026

Copy link
Copy Markdown

Description

xpu-smi reports GPU Core and Memory Temperature as N/A on the Intel Arc Pro B70 (Battlemage, xe
driver): Level Zero sysman enumerates no GPU/Memory temperature sensor on this device, even though the
readings are published on the PCI device's hwmon node (labels pkg / vram). This PR adds a correct,
validated sysfs-hwmon fallback so temperature is reported on such devices, while leaving behaviour
byte-identical where Level Zero already provides a sensor.

What it does

  • getCoreTemp / getMemoryTemp fall back to sysfs only when Level Zero reports the sensor type
    unsupported (no matching sensor was enumerated); any other Level Zero result is propagated, so
    device-loss / permission / state errors are never masked. The routing decision is a pure, unit-tested
    helper (decideTempSource).
  • getTempPerTile uses the fallback only when no matching-type sensor was enumerated, not merely when the
    tile map is empty (perTileShouldFallback).
  • resolveSysfsHwmon scans all hwmon* subdirs and caches the exact tempN_input path per label;
    strict temp<N>_label filename matching; every stream open is verified.
  • One shared, bounds-checked read path (parse → milli→Celsius → physical-validity bounds). The lower
    bound is absolute zero, not a device-specific 0 C floor, so a legitimate subzero reading on another
    matching system is not wrongly rejected.
  • The pure logic lives in an internal xpum::hwmon utility (hwmon_temperature_utils.{h,cpp}) shared by
    temperature.cpp and the tests, without expanding the exported temperature class / DLL surface.

Testing

  • doctest: 15 cases / 87 assertions (decision matrix SUCCESS→L0 / UNSUPPORTED→sysfs /
    DEVICE_LOST,PERMISSIONS,UNKNOWN→propagate; strict filename parse; value bounds; multi-hwmon
    discovery incl. labelled node not first; two roots don't cross-resolve). Full meson test: 9/9 suites.
  • Hardware (Arc Pro B70, xe, kernel 7.0.0-28-generic, Level Zero 1.27.0): xpu-smi stats reports
    Core 51 / Mem 52, matching raw sysfs pkg=51000 / vram=52000; VR stays N/A.

Scope / limitations

  • Validated only on the tested single-tile Arc Pro B70 on xe. The fallback is condition-based, not
    PCI-ID-gated: it activates when Level Zero exposes no matching sensor and the hwmon node provides the
    expected label. Not generalized to multiple tiles/subdevices; VR temperature is not in sysfs and stays
    N/A.
  • No unguarded POSIX-only header remains (directory scans and test fixtures use std::filesystem).
    Windows was not build-tested. The doctest test targets require a doctest package in CI.

Fixes:
Relates-To:

Type of change

  • Bug fix
  • New feature
  • API / ABI change
  • Refactor / cleanup
  • Documentation
  • Tests
  • Dependency update
  • CI / build
  • Other

Affected components

  • hal — Hardware Abstraction Layer
  • ial — Interface / Application Layer
  • oal — OS Abstraction Layer
  • xpumd — XPU Manager Daemon
  • cli / smi
  • ci / build system

Checklist

  • Commit messages follow the project guidelines
  • Each commit includes Signed-off-by (DCO)
  • New public APIs or CLI options are documented — n/a (no new public API/CLI; internal helpers only)
  • No unrelated changes included
  • Squash "fixup" commits after reviews — n/a (single commit)

@savery42

savery42 commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Related to #146

…ysfs hwmon fallback

On the Arc Pro B70 (Battlemage, xe) Level Zero sysman enumerates no GPU/Memory
temperature sensor, so xpu-smi reports temperature as N/A even though the values
are published on the world-readable PCI hwmon node (labels pkg/vram). Add a
validated sysfs fallback.

- getCoreTemp/getMemoryTemp route through a pure decideTempSource helper: use
  Level Zero on success; fall back to the hwmon node when Level Zero reports the
  sensor unsupported or denies access to an unprivileged process; propagate any
  other result so device-loss and runtime errors are never masked by a stale
  value.
- getTempPerTile falls back only when no matching-type sensor was enumerated,
  not merely when the tile map is empty.
- Discovery scans all hwmon* nodes and selects by tempN_label, caching the exact
  tempN_input path; strict temp<N>_label matching; every read validated against
  physical bounds through one shared path.
- Pure logic lives in an internal xpum::hwmon utility, off the exported class.
- doctest coverage for the decision matrix, parsing, bounds and discovery;
  portable std::filesystem, no POSIX-only headers. The Level Zero path is
  unchanged when a sensor is present.

Validated on Arc Pro B70 (xe, kernel 7.0.0-28-generic, Level Zero 1.27.0):
xpu-smi stats reports core and memory temperature matching the raw hwmon values.

Signed-off-by: thevisad <373694+thevisad@users.noreply.github.com>
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.

2 participants