Skip to content

sof-top, sof-remote-server: Add sof-top GTK4 live DSP resource & task monitor - #2

Merged
lgirdwood merged 2 commits into
mainfrom
sof-top
Nov 6, 2026
Merged

lgirdwood merged 2 commits into
mainfrom
sof-top

Conversation

@lgirdwood

Copy link
Copy Markdown
Member

Summary

Adds sof-top, a directly executable GTK4 + Cairo live SOF DSP resource, memory (SRAM + DRAM), and task monitor, along with supporting sof_remote_server enhancements.

Key Changes

  • sof-top/sof-top:
    • Moving DSP Core Utilization Graph: Rolling 60s per-core load (% of DSP clock & KCPS) plus live per-core summary bars.
    • Moving DSP Memory Utilization Graph (SRAM + DRAM): Rolling 60s traces and live capacity bars for HPSRAM (24 x 128 KB), LPSRAM (1 x 64 KB), DRAM (L3 / IMR), and DSP Heaps.
    • Unified DSP Task List: Consolidates Scheduler Domains (LL/DP), Zephyr RTOS Threads (TEL2), Audio Processing Modules (IPC4/PMW2), and DAI Gateways into a filterable, sortable table with CPU %, KCPS, SRAM/DRAM footprint, and status.
  • sof-top/backend.py & sof-top/widgets_cairo.py:
    • RemoteTcpBackend (SOFR/SOFZ wire decompression) and LocalCdevBackend (/dev/sof-dsp0 + DebugFS/SysFS fallback), binary TEL2/PMW2 parsers, and UserDashboardCairoWidget with headless --render-png export.
  • Packaging & Docs:
    • sof-top/README.md, sof-top/pyproject.toml, sof-top/requirements.txt, sof-top/desktop/org.thesofproject.SofTop.desktop, and updated root README.md.
  • sof-remote-server/sof_remote_server.c:
    • On-demand DSP boot (read_debugfs_fw_state, trigger_on_demand_dsp_boot) when polling with --wake before first stream open.
    • Idle systick_info sanitization (0 KCPS / 0.0% when LL timer is stopped) and 1 x 64 KB unused LPSRAM fallback on ACE.
    • Firmware .ri $AME manifest fallback (synthesize_modules_info_from_fw).

… monitor

Add sof-top, a GTK4 + Cairo live DSP resource, memory (SRAM + DRAM), and
task monitor along with supporting sof_remote_server improvements for
on-demand DSP boot, idle LL tick sanitization, LPSRAM sizing, and $AME
firmware manifest fallback.

Key changes:
- sof-top/sof-top:
  - Directly executable GTK4 monitor featuring a moving 60s DSP Core
    Utilization graph (% of DSP clock & KCPS per core), a moving 60s DSP
    Memory Utilization graph (HPSRAM, LPSRAM, DRAM L3/IMR, and DSP Heaps),
    and a unified filterable/sortable DSP Task List (Scheduler domains,
    Zephyr RTOS threads, IPC4/PMW2 audio modules, and DAI gateways).
- sof-top/backend.py & sof-top/widgets_cairo.py:
  - RemoteTcpBackend (SOFR/SOFZ wire compression) and LocalCdevBackend
    (/dev/sof-dsp0 + DebugFS/SysFS), binary TEL2/PMW2 parsers, unified
    DspTaskItem synthesizer, and hardware-accelerated GTK4/Cairo
    UserDashboardCairoWidget with headless --render-png export.
- sof-top packaging & docs:
  - Add README.md, pyproject.toml, requirements.txt, and desktop entry
    (org.thesofproject.SofTop.desktop).
- sof-remote-server/sof_remote_server.c:
  - Add read_debugfs_fw_state() and trigger_on_demand_dsp_boot() so --wake
    automatically boots an unbooted DSP via non-blocking ALSA PCM open.
  - Sanitize stale systick_info[0] inter-tick ccount gaps when the Zephyr LL
    timer is stopped (reporting 0 KCPS / 0.0% in idle) and report accurate
    1 x 64 KB unused LPSRAM fallback on ACE platforms.
  - Synthesize loaded_modules from the active firmware .ri $AME manifest
    when Window 1 IPC4 module notifications are absent.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

Unresolved critical defects include client-thread data races, wake polls that persistently prevent runtime suspend, and PMW2 decoding without a valid header, compromising telemetry correctness and power management.

23 open issues

And 3 more that still need to be addressed.

What changed in this PR

Introduces sof-top, a GTK4/Cairo DSP monitoring tool for SOF development, and extends sof_remote_server to support its telemetry needs.

Changes:

  • Adds core and memory graphs, a unified task display, polling controls, and PNG export.
  • Adds TCP telemetry collection and binary parsers, plus server-side boot triggering, idle-load sanitization, and firmware metadata fallbacks.
  • Adds Python packaging, dependency documentation, a desktop launcher, and quick-start instructions.
File Description
sof-top/​widgets_cairo.py Implements dashboard graphs, resource bars, and task rendering.
sof-top/​sof-top Adds the application, controls, polling, and PNG export path.
sof-top/​requirements.txt Lists Python graphics dependencies.
sof-top/​README.md Documents features, dependencies, and usage.
sof-top/​pyproject.toml Defines package metadata and installation configuration.
sof-top/​desktop/​org.thesofproject.SofTop.desktop Adds a desktop launcher definition.
sof-top/​backend.py Adds telemetry models, parsers, TCP transport, and task synthesis.
sof-remote-server/​sof_remote_server.c Extends DSP wake handling and telemetry fallbacks.
README.md Lists the monitoring tools and adds quick-start commands.

Review effort: Balanced

Comment thread sof-remote-server/sof_remote_server.c Resolved
Comment thread sof-remote-server/sof_remote_server.c Resolved
Comment thread sof-remote-server/sof_remote_server.c Resolved
Comment thread sof-top/backend.py Resolved
Comment thread sof-top/backend.py Resolved
Comment thread sof-top/sof-top Resolved
Comment thread sof-top/sof-top Resolved
Comment thread sof-top/sof-top Resolved
Comment thread sof-top/widgets_cairo.py Resolved
Comment thread sof-top/widgets_cairo.py Resolved
lgirdwood pushed a commit that referenced this pull request Nov 5, 2026
Fix all 23 review findings across sof-remote-server and sof-top:

sof-remote-server:
- Protect g_cached_fw_mods_tlv initialization and publication with
  g_fw_mods_lock mutex, and convert  manifest headers to valid
  runtime (mod_id, state) wire entries.
- Move previous per-core tick history (prev_core_ticks,
  has_prev_core_ticks) into per-connection client_telem_state.
- Restore prior sysfs runtime PM policy (temp_sysfs_hold) after
  wake-on-poll snapshots when no explicit D0 hold is active.
- Match the SOF PCI device's sound card index when selecting a boot
  trigger PCM stream and enumerate all pcm*/sub*/status entries on the
  SOF card.
- Read firmware version from debugfs fw_version instead of hard-coding
  2.14.99.1 on direct MMIO paths.
- Determine per-core idleness from each core's tick counter progression
  and avoid fabricating fallback HPSRAM bank state or PMW2 component
  KCPS counters.

sof-top:
- Gate PMW2 decoding on a valid PMW2 magic header and reject 0xFFFFFFFF
  resource IDs unconditionally.
- Clear cached_ext_perf on valid empty (count == 0) responses and keep
  WELL_KNOWN_IPC4_MODULES name lookup separate from target-enumerated
  loaded_modules.
- Remove fabricated fallback heap estimates and use measured gateway
  performance counters.
- Implement direct /dev/sof-dsp0 ioctl telemetry polling and PM control
  in LocalCdevBackend.
- Run backend polling and PM RPCs on background worker threads and post
  UI updates via GLib.idle_add, initializing perf measurement state (2)
  when the DSP reaches BOOT_COMPLETE.
- Separate display-independent UserDashboardRenderer from Gtk.Widget so
  --render-png works headlessly without an X11/Wayland display, use
  60-second timestamped rolling history, and add scrollable/paged task
  list navigation.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
@lgirdwood
lgirdwood requested a balanced review from Copilot November 6, 2026 12:53

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

Unresolved critical defects break local polling, PMW2 snapshot handling, and documented GUI startup, while missing shutdown cleanup can leave the device forced awake.

14 open issues
23 resolved since last review

And 3 more resolved.

Review effort: Balanced

Comment thread sof-top/backend.py Resolved
Comment thread sof-top/backend.py Resolved
Comment thread sof-top/sof-top Resolved
Comment thread sof-top/sof-top Resolved
Comment thread sof-remote-server/sof_remote_server.c Resolved
Comment thread sof-top/backend.py Resolved
Comment thread sof-top/backend.py Resolved
Comment thread sof-top/sof-top Resolved
Comment thread sof-top/widgets_cairo.py Resolved
Comment thread sof-top/widgets_cairo.py Resolved
Fix all 23 review findings across sof-remote-server and sof-top:

sof-remote-server:
- Protect g_cached_fw_mods_tlv initialization and publication with
  g_fw_mods_lock mutex, and convert  manifest headers to valid
  runtime (mod_id, state) wire entries.
- Move previous per-core tick history (prev_core_ticks,
  has_prev_core_ticks) into per-connection client_telem_state.
- Restore prior sysfs runtime PM policy (temp_sysfs_hold) after
  wake-on-poll snapshots when no explicit D0 hold is active.
- Match the SOF PCI device's sound card index when selecting a boot
  trigger PCM stream and enumerate all pcm*/sub*/status entries on the
  SOF card.
- Read firmware version from debugfs fw_version instead of hard-coding
  2.14.99.1 on direct MMIO paths.
- Determine per-core idleness from each core's tick counter progression
  and avoid fabricating fallback HPSRAM bank state or PMW2 component
  KCPS counters.

sof-top:
- Gate PMW2 decoding on a valid PMW2 magic header and reject 0xFFFFFFFF
  resource IDs unconditionally.
- Clear cached_ext_perf on valid empty (count == 0) responses and keep
  WELL_KNOWN_IPC4_MODULES name lookup separate from target-enumerated
  loaded_modules.
- Remove fabricated fallback heap estimates and use measured gateway
  performance counters.
- Implement direct /dev/sof-dsp0 ioctl telemetry polling and PM control
  in LocalCdevBackend.
- Run backend polling and PM RPCs on background worker threads and post
  UI updates via GLib.idle_add, initializing perf measurement state (2)
  when the DSP reaches BOOT_COMPLETE.
- Separate display-independent UserDashboardRenderer from Gtk.Widget so
  --render-png works headlessly without an X11/Wayland display, use
  60-second timestamped rolling history, and add scrollable/paged task
  list navigation.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.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.

3 participants