Skip to content

ASoC: SOF: debug: List the loaded topology files in fw_profile/tplg_name - #5997

Open
ujfalusi wants to merge 2 commits into
thesofproject:topic/sof-devfrom
ujfalusi:peter/sof/pr/show-all-loaded-topologies
Open

ujfalusi wants to merge 2 commits into
thesofproject:topic/sof-devfrom
ujfalusi:peter/sof/pr/show-all-loaded-topologies

Conversation

@ujfalusi

@ujfalusi ujfalusi commented Oct 22, 2026 •

Copy link
Copy Markdown
Collaborator

The fw_profile/tplg_name debugfs file exposes the topology file name selected
for the platform. When function topologies are used, the selected name is a
placeholder (sof-<platform>-dummy.tplg) which does not tell which topology
files have actually been loaded.

The second patch replaces the static name with a list of the loaded topology
files, one per line (the topology path prefix is dropped as it is exposed via
fw_profile/tplg_path). The list is set after a successful topology load and
cleared again when the loading fails or the topology is removed; while no
topology is loaded the selected topology name is shown. For monolithic
topologies the content of the file is unchanged.

The first patch is a preparatory fix: snd_sof_load_topology() can fail after
one or more topology files have been loaded (subsequent request_firmware(),
feature topology path allocation, sof_complete(), snd_ctl_led_request()),
but the loaded topology objects were only removed when
snd_soc_tplg_component_load() itself failed. Since the component remove
callback is not called for a failed probe, they were left behind referencing
freed DAPM data. Remove the topology on any load error.

Example with function topologies:

# cat /sys/kernel/debug/sof/fw_profile/tplg_name
sof-ptl-sdca-jack-id0.tplg
sof-ptl-sdca-2amp-id2.tplg
sof-ptl-dmic-4ch-id4.tplg
sof-ptl-hdmi-pcm5-id5.tplg

Note: tools reading tplg_name and expecting a single file name will get
multiple lines on function topology systems (the dummy name never existed on
disk, so such tools did not work there before either).

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

Concurrent debugfs reads can access freed memory, and unchecked allocation failures can publish incomplete topology lists.

2 open issues
What changed in this PR

This PR updates SOF’s fw_profile/tplg_name debugfs entry to report loaded topology files rather than a placeholder when function topologies are used.

Changes:

  • Collect loaded topology filenames, separated by newlines and without the shared path prefix.
  • Publish the collected list after successful topology completion, retaining the selected name as the initial value.
File Description
sound/​soc/​sof/​topology.c Collects filenames and publishes the loaded topology list.
sound/​soc/​sof/​sof-priv.h Adds storage for the loaded topology names.
sound/​soc/​sof/​debug.c Initializes the name storage and exposes it through debugfs.

Review effort: Balanced

Comment thread sound/soc/sof/topology.c Outdated
Comment thread sound/soc/sof/topology.c Outdated
bardliao
bardliao previously approved these changes Oct 22, 2026
Copilot AI balanced review requested due to automatic review settings October 23, 2026 06:09
@ujfalusi
ujfalusi force-pushed the peter/sof/pr/show-all-loaded-topologies branch from a50e45e to fde6d64 Compare October 23, 2026 06:09

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

Both new name-allocation failure paths leave loaded topology objects behind during failed-probe cleanup, creating dangling references.

3 open issues
1 resolved since last review

Review effort: Balanced

Comment thread sound/soc/sof/topology.c Outdated
Comment thread sound/soc/sof/topology.c Outdated
@ujfalusi

Copy link
Copy Markdown
Collaborator Author

Changes since v1:

  • add lock to cover the race for accessing tplg_name (use a function to print the string)
  • error handling for the string allocation
  • Clear the loaded topology names on card unbind

@harajend , this might impact CI as now with function (and feature) topologies the tplg_name will contain all the loaded topology files in the order they were loaded.
It could help in CI to identify what is loaded and this information can be used to recreate the full topology picture with tplgtool2.py -m to merge the multiple files for a full system view

snd_sof_load_topology() can fail after one or more topology files have
been loaded: requesting a subsequent topology file, allocating the path
of a feature topology, sof_complete() or snd_ctl_led_request() can fail
at that point.

snd_soc_tplg_component_load() only removes the topology objects when
the load itself fails. When the component probe fails the ASoC core does
not call the component remove callback, so the loaded topology objects
are left behind referencing freed DAPM data.

Call snd_soc_tplg_component_remove() whenever snd_sof_load_topology()
fails. If the error came from snd_soc_tplg_component_load() the objects
have been removed already and the second call is harmless.

Drop the comments which claimed that the topology is removed on
request_firmware() failure.

Fixes: 6d5997c ("ASoC: SOF: topology: load multiple topologies")
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
The fw_profile/tplg_name debugfs file exposes the topology file name
selected for the platform. When function topologies are used, the
selected name is a placeholder (sof-<platform>-dummy.tplg) which does
not tell which topology files have actually been loaded.

Replace the static name with a list of the loaded topology files, one
per line, set by snd_sof_load_topology() after a successful load and
cleared again when the loading fails or when the topology is removed in
sof_pcm_remove(). The topology path prefix is dropped from the names as
it is exposed separately via fw_profile/tplg_path.

The file is backed by a seq_file reader instead of debugfs_create_str()
so that the list can be replaced under a mutex without racing with
concurrent readers. While no topology is loaded the selected topology
name is shown.

For monolithic topologies the content of the file is unchanged.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Copilot AI balanced review requested due to automatic review settings October 23, 2026 07:24
@ujfalusi
ujfalusi force-pushed the peter/sof/pr/show-all-loaded-topologies branch from fde6d64 to 210ddc3 Compare October 23, 2026 07:24
@ujfalusi

Copy link
Copy Markdown
Collaborator Author

Changes since v2:

  • New patch: "ASoC: SOF: topology: Remove loaded topologies on load failure"
    • addresses the Copilot review on v2: snd_sof_load_topology() errors after
      a topology file has been loaded (subsequent request_firmware(), feature
      topology path allocation, sof_complete(), snd_ctl_led_request() and the
      new name allocation) left the loaded topology objects behind as the
      component remove callback is not called for a failed probe
    • call snd_soc_tplg_component_remove() on any load error, a second call
      after a snd_soc_tplg_component_load() failure is a no-op
    • drop the comments claiming cleanup on request_firmware() failure
    • Fixes: 6d5997c ("ASoC: SOF: topology: load multiple topologies")
  • tplg_name patch:
    • also clear the published list on load failure (relevant when
      snd_ctl_led_request() fails after the list was published)
    • commit message updated accordingly

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.

🔵 Needs a closer look

Expanded failed-probe cleanup and device-lifetime interactions need human validation across partial topology loads and completion failures.

1 open issue
2 resolved since last review

Review effort: Balanced

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