Skip to content

gpu-freq-sampler: stop writing to amdgpu's SMU mailbox - #130

Merged
MTSistemi merged 1 commit into
mainfrom
fix/gpu-freq-sampler-no-smu-mailbox
Nov 15, 2026
Merged

MTSistemi merged 1 commit into
mainfrom
fix/gpu-freq-sampler-no-smu-mailbox

Conversation

@MTSistemi

Copy link
Copy Markdown
Owner

What

skillfish-gpu-freq-sampler no longer talks to the SMU itself. It reads the GPU clock and the three power figures from the single gpu_metrics read it already did every 2 s, and publishes /run/skillfish-gpu-freq and /run/skillfish-potenze as before.

Why

The sampler sent 0x0E/0x0F on "queue 0" through the SMN window (PCI config 0xB8/0xBC of 00:00.0), at 0x03B10A08/48/68. Those are C2PMSG_66/82/90: the mailbox amdgpu itself uses through MMIO under its own mutex. Our flock does not serialize anything against the driver: every 2 s the sampler cleared the response register and wrote its own command, which can land in the middle of a driver message such as the metrics table export. The upstream bc250_smu library refuses queue 0 by default for the same reason.

The direct read is not needed anymore: patch 0125 makes the driver answer current_gfxclk with QueryGfxclk under its lock. On 7.3.4, gpu_metrics offset 76, hwmon freq1_input and pp_dpm_sclk all show the same value as the old mailbox read (1850 MHz under load, 350 MHz idle).

Context

On the .32, Failed to export SMU metrics table! shows up on almost every boot since October (up to 66 per boot, on 7.2.9 and 7.3.4). In 7.3 that line with no SMU: No response before it means the SMU answered CMD_FAIL (0xFF), not a timeout, so it is not the display-freezing hang described in the community guide. An 8-minute A/B test at 10 Hz gpu_metrics reads showed 0 failures with and without the old sampler, which is too short to settle whether the sampler causes them. The new sampler is running on the .32 overnight to compare the rate (baseline: 10 failures in ~8 h with the old one).

Tests

  • tests/test_gpu_freq_sampler.py (new, 5 tests): no SMN window or queue-0 address in the code, power line and clock read from the measured offsets, a table of another format is not trusted.
  • On the .32: service active, /run files updated every 2 s, values equal to pp_dpm_sclk and hwmon, PCI config not open.

The sampler sent 0x0E/0x0F on "queue 0" through the SMN window, at
0x03B10A08/48/68. Those are C2PMSG_66/82/90, the mailbox amdgpu itself uses
through MMIO under its own mutex, which knows nothing about our flock. Every
2 s it cleared the response register and wrote its own command, which can
land in the middle of a driver message such as the metrics table export.
The bc250_smu library refuses queue 0 by default for the same reason.

It is not needed either: patch 0125 has the driver answer current_gfxclk
with QueryGfxclk under its lock, so gpu_metrics offset 76, hwmon
freq1_input and pp_dpm_sclk all carry the real clock (checked on 7.3.4,
same value as the old mailbox read). The sampler now takes the clock and
the three power figures from the one gpu_metrics read it already did, and
opens nothing in PCI config space.

The unit's path condition follows: gpu_metrics instead of the root
device's config space. Comments that described the old behaviour are
updated, and translated where touched.

Tests: tests/test_gpu_freq_sampler.py keeps the SMN window and the queue-0
addresses out of the code and checks the published values.
@MTSistemi

Copy link
Copy Markdown
Owner Author

Overnight check on the .32 with the new sampler: 0 Failed to export SMU metrics table! in 9 h 40 min (00:56 to 10:36, counted with journalctl -b -k), against 10 in the previous 8 h of the same boot with the old sampler. At the old rate about 12 were expected; 0 by chance is about 6e-6. The race on the driver's mailbox was the cause of the CMD_FAIL refusals.

@MTSistemi
MTSistemi merged commit 3f0e0c1 into main Nov 15, 2026
5 checks passed
@MTSistemi
MTSistemi deleted the fix/gpu-freq-sampler-no-smu-mailbox branch November 15, 2026 09:37
MTSistemi added a commit that referenced this pull request Nov 15, 2026
#133)

* control-center, remote-manager: FreeFG frame generation per game

FreeFG (daniel-h-0, MIT) adds Intel's XeSS frame generation with shaders
written for the BC-250, plus FSR 4, through OptiScaler, one game at a time.
Measured on bc250-dev, Cyberpunk 1080p: 130-133 fps shown against a bench
median of 90.7, 1% lows 30-34; the game's own rate stays near 65.

sfcc/freefg.py (no Qt) does the work and is run as a separate process, as
the desktop user, by the Games page, by the Remote Manager and by the new
skillfish-freefg command:
- the release is pinned (1.4.0) with its sha256 and unpacked with bsdtar
  into ~/.local/share/skillfish/freefg; libarchive-tools is recommended;
- the game list is FreeFG's own scan (Steam, Heroic stores) plus Heroic's
  sideloaded games, each with FreeFG's verdict;
- installing first sets PROTON_USE_OPTISCALER and PROTON_FSR4_UPGRADE to 0
  in that game's launcher entry, keeping what was there: our FSR 4 switch
  sets them to 1 launcher-wide, and GE-Proton would then load its own
  OptiScaler as dxgi.dll over FreeFG's. GE reads them with nonzero(), and
  the entry wins over the flatpak override. Then FreeFG installs with its
  BC-250 FSR 4, the automatic input and never NVIDIA's DLL. Removing runs
  FreeFG's restore and puts the entry back as it was.

The Games page gets a Frame generation card (download, game list with the
verdict, install, remove); web/giochi.html gets the same panel. The daemon
runs freefg.py through runuser as the desktop user and accepts a game only
if it is in the list FreeFG returns, never a free path from the network.

The Control Center dictionaries are merged into the shared ones with
unisci-i18n.py: the FreeFG strings, the two from the GE-Proton fix (#132)
that had not reached them, and one older AI string. Only additions; the
tool sorts the files.

Tested on bc250-dev: download and hash, list (5 games), install into
Cyberpunk with GE FSR 4 on launcher-wide and in the game, one launch (GE
stays out: PROTON_*=0 in the game's environment, FreeFG active), one bench
run (132.1 fps), removal (Heroic entry byte-identical to before, no FreeFG
file left, 0 GPU errors). The dashboard functions run as root: refusal of
a path outside the list and of an unknown action, install and remove,
files owned by the user. Card rendered offscreen. tests/test_cc_freefg.py
covers the entry edits and the pinning.

* Release 26.11.3: notes in 9 languages, site news, SECURITY.md

skillfish-base: the GPU sampler no longer races the driver's SMU mailbox
(#130). skillfish-control-center: FreeFG frame generation, GE-Proton 11-12
folder and checksum (#132). Remote Manager: FreeFG on the web Games page.
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.

1 participant