Skip to content

ASoC: SOF: topology: skip adding unsupported widgets to the list - #3989

Merged
plbossart merged 2 commits into
thesofproject:topic/sof-devfrom
ranj063:fix/virual_widgets
Nov 3, 2022
Merged

ASoC: SOF: topology: skip adding unsupported widgets to the list#3989
plbossart merged 2 commits into
thesofproject:topic/sof-devfrom
ranj063:fix/virual_widgets

Conversation

@ranj063

Copy link
Copy Markdown
Collaborator

Some topologies like the HDA generic topologies add virtual widgets in order to reuse the HDA generic machine driver without any changes. When parsing such widgets, there's no need to add an swidget pointer to the sdev's widget list.

Add such virtual widgets lead to a null pointer exception when tearing down the pipelines during suspend and only seems to manifest in some platforms. Fix this by skipping adding the swidget pointer for such widgets during topology parsing.

Link: #3988
Fixes: #3988

@ranj063ranj063 added the P1 Blocker bugs or important features label Nov 3, 2022
Comment threadsound/soc/sof/topology.c Outdated
Comment threadsound/soc/sof/topology.c Outdated
Comment threadsound/soc/sof/topology.c
@ranj063
ranj063force-pushed the fix/virual_widgets branch 2 times, most recently from a48b16c to 6bdff8aCompareNovember 3, 2022 13:44
Some topologies like the HDA generic topologies add widgets in order to
reuse the HDA generic machine driver without any changes. But these
widgets are not needed by the SOF firmware and should be ignored during
topology parsing.
Adding such widgets to the widget list leads to a null pointer exception
when tearing down the pipelines during suspend and only seems
to manifest in some platforms. Fix this by skipping adding the swidget
pointer for such widgets during topology parsing.
The problem wasn't identified before because we didn't have the spipe
field in struct snd_sof_widget before and for the unsupported widgets
this would be null with the latest changes.
Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Fix the error paths in sof_widget_ready() to free all allocated memory
and prevent memory leaks.
Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
@plbossart

Copy link
Copy Markdown
Member

Merging blindly since CI does not give us ANY results. Yay @keqiaozhang@marc-hb@greg-intel@mengdonglin. This is a post-Halloween nightmare.

@plbossart
plbossart merged commit 5af7c07 into thesofproject:topic/sof-devNov 3, 2022
@marc-hb

Copy link
Copy Markdown
Collaborator

@plbossart while the public mirroring is down (stuck in unexpected red tape), all the results should be available on the internal server. Please contact us privately if you need guidance.

@marc-hb

Copy link
Copy Markdown
Collaborator

@ranj063 , @aiChaoSONG was this regression bisected to any particular commit? Also, shouldn't this have been a fixup commit to avoid introducing the regression and boot failure #3988 upstream?

@ranj063

Copy link
Copy Markdown
CollaboratorAuthor

@ranj063 , @aiChaoSONG was this regression bisected to any particular commit? Also, shouldn't this have been a fixup commit to avoid introducing the regression and boot failure #3988 upstream?

It was a fixup. Did you see the first patch?

@plbossart

Copy link
Copy Markdown
Member

@plbossart while the public mirroring is down (stuck in unexpected red tape), all the results should be available on the internal server. Please contact us privately if you need guidance.

It's not just the test results, even the built status is not updated. It's getting worse every day.

@ranj063
ranj063 deleted the fix/virual_widgets branch November 3, 2022 22:41
@marc-hb

Copy link
Copy Markdown
Collaborator

It's not just the test results, even the built status is not updated.

Thanks I missed that. I see it now when I click on the View details button.

Indeed the build status follows a different, more direct path and was so far not affected. I don't know what happened in this PR.

I just looked at two of the most recent pull requests and the build status is back:

cc: @greg-intel , @keqiaozhang , @fredoh9

@marc-hb

Copy link
Copy Markdown
Collaborator

It was a fixup. Did you see the first patch?

My bad, I didn't pay attention. I didn't expect a "quickfix" PR to have more than one commit.

So now partially answering my own questions for the record: this PR has a fixup of commit 6e2cdc2 in PR #3957.

Note there was another, earlier fixup between initial commit 6e2cdc2 and this second fixup here. So now I wonder which one introduced the boot failure: the initial commit or the first fixup?

Both the initial commit and the first fixup had red build status and they were merged anyway.

I'm asking all these questions because the boot failure knocked down most of our CI (it shouldn't have, grub-reboot should have saved us but it didn't) so we need at the very least a good record of it.

@ranj063

Copy link
Copy Markdown
CollaboratorAuthor

Note there was another, earlier fixup between initial commit 6e2cdc2 and this second fixup here. So now I wonder which one introduced the boot failure: the initial commit or the first fixup?

the first commit. Eventually before upstreaming I will squash all these into one. So it wouldnt matter

Comment threadsound/soc/sof/topology.c Outdated
dev_dbg(scomp->dev, "widget type %d name %s not handled\n", swidget->id, tw->name);
break;
kfree(swidget);
return 0;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

For the record:
I think the proper fixup would be:

diff --git a/sound/soc/sof/ipc3-topology.c b/sound/soc/sof/ipc3-topology.c
index 7870260c6f3e..88b9b9507231 100644
--- a/sound/soc/sof/ipc3-topology.c+++ b/sound/soc/sof/ipc3-topology.c@@ -2317,7 +2317,8 @@ static int sof_ipc3_tear_down_all_pipelines(struct snd_sof_dev *sdev, bool verif
if (!verify && !swidget->dynamic_pipeline_widget &&
SOF_FW_VER(v->major, v->minor, v->micro) < SOF_FW_VER(2, 2, 0)) {
swidget->use_count = 0;
- swidget->spipe->complete = 0;+ if (swidget->spipe)+ swidget->spipe->complete = 0;
continue;
}

Because the reason for the NULL pointer dereference is the fact that sof_ipc3_tear_down_all_pipelines() iterates through the global swidget list and the "ASoC: SOF: Introduce struct snd_sof_pipeline" move the complete flag under spipe which can be NULL if the swidget is not part of any path (virtual/not handled widgets).

This change would be better on it's own to be backportable when sending upstream.

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P1Blocker bugs or important features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG][TGLU_UP_HDA/TGLH_SKU0A70_HDA] NULL pointer de-reference causes system freeze

5 participants

@ranj063@plbossart@marc-hb@bardliao@ujfalusi