fix(libkernel): skip power and network hwmon sensors before reading them #20677

Merged
JJenkx merged 1 commit from upstream-pr/20677 into main 2026-11-15 12:59:01 +00:00
JJenkx commented 2026-11-15 12:16:41 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by JJenkx on 2026-11-15T12:16:41Z.


What

ReadThermalSensors read every hwmon's temp1_input before it checked the sensor's name, and skipped battery, AC and wireless sensors (IsPowerOrNetwork) only after the read. Some of those sensors block when read. On a Linux host with a MediaTek MT7921 Wi-Fi card (mt7921_phy0), each read of its temp1_input blocks 6–13 s and then fails with ETIMEDOUT. One ReadThermalSensors call took about 75 s on that host; strace showed seven such reads. Every sceKernelGetCpuTemperature and sceKernelGetSocSensorTemperature call goes through this function, so on such a host the calling guest thread stalls that long, and the value it waits for is discarded.

The reader now reads name first and skips power and network sensors without opening their temp1_input. Which sensors are used, and in what order, is unchanged.

The test now also checks that a skipped sensor's temp1_input is never opened. Outside Windows, the battery and Wi-Fi sensors' temp1_input is a FIFO with no writer, so an open would block and the test would fail on its 20 s timeout.

Tested

Linux (Arch, kernel 7.2.14), guest_thermal_sensors:

  • New test against the unfixed ThermalSensors.cpp: ***Timeout 20.05 sec (blocked opening the battery sensor's FIFO)
  • New test with this change: Passed 0.02 sec
  • Before this change, the existing test took 75–95 s on this host (main build 89.7 s) and failed its 20 s timeout, because its host-sensor probe read the Wi-Fi sensor.

Checklist

  • Based on current main; no other open PR implements the same functions. #17652 moves this reader into ThermalReader.cpp with the same read order; whichever lands second carries the reorder.
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt and the licence notice of code adapted from upstream (see AGENTS.md)
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5322604241 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/20677). Originally posted by [JJenkx](https://github.com/JJenkx) on 2026-11-15T12:16:41Z. --- ### What `ReadThermalSensors` read every hwmon's `temp1_input` before it checked the sensor's `name`, and skipped battery, AC and wireless sensors (`IsPowerOrNetwork`) only after the read. Some of those sensors block when read. On a Linux host with a MediaTek MT7921 Wi-Fi card (`mt7921_phy0`), each read of its `temp1_input` blocks 6–13 s and then fails with `ETIMEDOUT`. One `ReadThermalSensors` call took about 75 s on that host; strace showed seven such reads. Every `sceKernelGetCpuTemperature` and `sceKernelGetSocSensorTemperature` call goes through this function, so on such a host the calling guest thread stalls that long, and the value it waits for is discarded. The reader now reads `name` first and skips power and network sensors without opening their `temp1_input`. Which sensors are used, and in what order, is unchanged. The test now also checks that a skipped sensor's `temp1_input` is never opened. Outside Windows, the battery and Wi-Fi sensors' `temp1_input` is a FIFO with no writer, so an open would block and the test would fail on its 20 s timeout. ### Tested Linux (Arch, kernel 7.2.14), `guest_thermal_sensors`: - New test against the unfixed `ThermalSensors.cpp`: `***Timeout 20.05 sec` (blocked opening the battery sensor's FIFO) - New test with this change: `Passed 0.02 sec` - Before this change, the existing test took 75–95 s on this host (main build 89.7 s) and failed its 20 s timeout, because its host-sensor probe read the Wi-Fi sensor. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions. #17652 moves this reader into `ThermalReader.cpp` with the same read order; whichever lands second carries the reorder. - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except technical debt and the licence notice of code adapted from upstream (see AGENTS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's technical debt file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!20677
No description provided.