linux icon indicating copy to clipboard operation
linux copied to clipboard

Pi 5: fan1_input (RP1 fan tachometer) is non-monotonic with PWM duty and reads 0 at mid duty

Open bheus opened this issue 3 months ago • 3 comments

Describe the bug

fan1_input for the official Active Cooler does not track actual fan speed. It is non-monotonic with PWM duty, reports 0 at mid duty, and drifts at a fixed duty.

Reproduces on both EEPROM 2025-11-05 (1762364238) and EEPROM 2026-05-26 (1779807685), tested on the same board an hour apart. Updating to the current release did not fix it, and changed the failure pattern: pwm 255 previously read ~3300 and now reads 0.

Sweeping pwm1 in both directions, 20 s settle, median of 3 reads (values were stable to <1% within each dwell):

EEPROM 2025-11-05

pwm1 descending ascending
75 3314 3296
100 4369 4374
150 0 0
200 0 0
255 3342 3298

EEPROM 2026-05-26 (current)

pwm1 ascending descending
75 3314 —
100 4452 4418
150 0 0
200 0 0
255 0 —

At a constant pwm of 150, successive reads over 60 s: 3202, 3234, 3258, 3270, 0 — with no change to pwm1. At a constant pwm of 75, sampled at three different times on the same day: ~2250, ~3280, ~4480.

Expected: monotonically non-decreasing with duty, stable at a fixed duty, and never 0 while the fan is spinning.

Why this repo

The kernel does no counting and no scaling. drivers/hwmon/pwm-fan.c (downstream commit ea281597d803, "hwmon: (pwm-fan) Add fan speed register support") is a pass-through:

if (ctx->rpm_regbase)
    *val = (long)readl(ctx->rpm_regbase + ctx->rpm_offset);

against rpm-regmap = <&rp1_pwm1>; rpm-offset = <0x3c>; in bcm2712-rpi-5-b.dts. 0x3c is PWM_PHASE(2), which per the upstream RP1 PWM series cover letter is written by "the firmware running on the RP1's M-core". So fan1_input is exactly what RP1 firmware measured. Happy to move this to raspberrypi/firmware if the M-core blob is tracked there instead.

What I have and have not verified

  • Established: the reported value is not a stable function of PWM duty. The constant-duty sequence above (3270 then 0, with pwm1 unchanged) demonstrates this independently of what the fan is physically doing. Reproducible in both sweep directions, across two bootloader versions, on the same board.
  • Not verified: I did not measure actual rotation independently (no optical tachometer or high-speed video). I am therefore claiming only that the reported number is internally inconsistent — not that the fan is definitely spinning at pwm 150–200.
  • Not verified: I attempted to confirm cooling at pwm 150 via SoC temperature, but this board's idle temperature jitters 44.6–50.7 °C, which swamps the ~1 °C effect being looked for. Those measurements were inconclusive and are not cited as evidence.

Impact

Cooling itself is unaffected — the thermal governor drives cooling state / PWM and never consumes fan1_input. But it breaks sensors, fan-speed monitoring and alerting, and anything treating fan1_input == 0 as a stalled-fan condition.

Hypothesis (not established)

The pattern is consistent with the tach measurement aliasing against the ~24.06 kHz PWM chopping frequency (pwms = <&rp1_pwm1 3 41566 PWM_POLARITY_INVERTED>), so that the reported figure is a beat frequency rather than the true rotation rate. The M-core firmware is not public, so I could not inspect the measurement method.

Possibly related

  • https://forums.raspberrypi.com/viewtopic.php?t=359624 — fan1_input reading 4900 rpm against 6578 rpm measured from 402 fps video (~74% of true speed). A scale error rather than these zeros, but the same subsystem; never triaged.
  • The 2025-04-07 release note ("arm_dt: Revert to using the max fan speed") records that "the presence of a cooling fan at boot time can lead to a maximum observed fan speed of ~300 but a current speed of 0" — the same firmware-side RPM measurement spuriously reporting 0 with a working fan present (#690).

Happy to run further instrumentation (raw PHASE2 register dumps at other duties, different PWM periods) if that would help.

Steps to reproduce the behaviour

  1. Boot a Raspberry Pi 5 with the official Active Cooler attached.

  2. Take manual control of the fan PWM and sweep the duty cycle, allowing 20 s to settle at each point:

HW=$(ls -d /sys/devices/platform/cooling_fan/hwmon/hwmon*)
ORIG_EN=$(cat $HW/pwm1_enable)          # save, to restore afterwards

for p in 75 100 150 200 255; do
    echo $p | sudo tee $HW/pwm1 > /dev/null
    sleep 20
    printf 'pwm=%3d  rpm=' "$p"
    for i in 1 2 3; do printf '%s ' "$(cat $HW/fan1_input)"; sleep 2; done
    echo
done
  1. Observe that fan1_input reads 0 at pwm 150, 200 and 255, while the lower duties 75 and 100 report several thousand RPM.

  2. Repeat the loop with the duty values in descending order. The same duties report 0, so this is not a settle-time or ordering artefact.

  3. Stability check at a single fixed duty:

echo 150 | sudo tee $HW/pwm1 > /dev/null
for i in $(seq 5); do sleep 15; cat $HW/fan1_input; done

Observe the value drift upward and then fall to 0, with no change to pwm1 between reads.

  1. Restore automatic control:
echo 0 | sudo tee $HW/pwm1 > /dev/null
echo $ORIG_EN | sudo tee $HW/pwm1_enable > /dev/null

Device (s)

Raspberry Pi 5

Bootloader configuration.

Output of rpi-eeprom-config:

[all]
BOOT_UART=1
BOOT_ORDER=0xf461
NET_INSTALL_AT_POWER_ON=1

This configuration is unchanged and was preserved across the EEPROM update from 2025-11-05 to 2026-05-26. The bug is not configuration-dependent — it reproduced identically before and after the update, with this same config in place. Boot itself is entirely healthy; the board boots reliably from NVMe.

System

Model:    Raspberry Pi 5 Model B Rev 1.1, official Raspberry Pi Active Cooler

OS:       Raspberry Pi reference 2025-12-04
          Generated using pi-gen, 4997bf4e4e49bc3305eb182a4a08bd023529da04, stage2
          (Debian 13 / trixie)

Kernel:   Linux 6.12.75+rpt-rpi-2712 raspberrypi/rpi-eeprom#1 SMP PREEMPT Debian 1:6.12.75-1+rpt1
          (2026-03-11) aarch64 GNU/Linux

EEPROM:   2026-05-26 (1779807685), default release channel
          also reproduced on 2025-11-05 (1762364238)

Device tree node cooling_fan:

compatible     = "pwm-fan"
pwms           = <&rp1_pwm1 3 41566 PWM_POLARITY_INVERTED>   (~24.06 kHz)
rpm-regmap     = <&rp1_pwm1>
rpm-offset     = <0x3c>
cooling-levels = <0 75 125 175 250>
(no pulses-per-revolution property)

Two notes on the above:

  • vcgencmd bootloader_version and vcgencmd version currently fail on this system with Can't open device file: /dev/vcio_gencmd following a raspi-utils package upgrade, so the EEPROM version quoted above is taken from rpi-eeprom-update rather than vcgencmd. I can supply vcgencmd output if that turns out to matter.
  • All measurements in this report were taken on kernel 6.12.75. The machine has since been updated to 6.18.39+rpt-rpi-2712; I have not re-run the sweep there. Given that the driver is a pass-through read of a firmware-written register, I would not expect the kernel version to change the result, but I have not confirmed that.

Bootloader logs

No response

USB boot

No response

NVMe boot

No response

Network (TFTP boot)

No response

bheus avatar Aug 15 '26 00:08 bheus

You completely ignored the issue template for this repo and pasted AI slop. Transferred to kernel in case this is an issue with the rp1 fan driver.

timg236 avatar Aug 15 '26 15:08 timg236

Your bug report is invalid because your AI chatbot doesn't know how to disable the kernel's control of the fan.

Counterexample: on a cold board, replace your loop range with "255". Observe the fan audibly speed up, then shut down a couple of seconds later.

P33M avatar Aug 15 '26 18:08 P33M

I just confirmed you're right and I'm sorry for the noise

bheus avatar Aug 15 '26 23:08 bheus