Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions sound/soc/sof/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,14 @@ int snd_sof_device_remove(struct device *dev)
{
Comment thread
kv2019i marked this conversation as resolved.
Resolved
struct snd_sof_dev *sdev = dev_get_drvdata(dev);
struct snd_sof_pdata *pdata = sdev->pdata;
int ret;

ret = snd_sof_dsp_power_down_notify(sdev);
if (ret < 0) {
dev_err(dev, "error: %d failed to prepare DSP for device removal",
ret);
return ret;
}

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.

@mrajwa Why not do this as part of remove sequence, e.g. in hda.c:hda_dsp_remove()? Not sure why the extra new method is needed and are the expected semantics. If it's called always before remove, what's the benefit? If some delay is needed between sram gating and power-off, this can be added in hda_dsp_remove() as well?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I also don't get why we need a new callback. If this is part of the power-down sequence, then let's add it as part of the power down sequence. this should apply to ALL D3 transitions.

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.

+1 but @mrajwa this is meant to specifically fix the module reload problem on GLK isnt it? But we've still got the failure in the CI test?

@mrajwa mrajwa Apr 23, 2020 •

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

@kv2019i, at hda_dsp_remove() time you have IPCs already disabled + machine driver is removed - you won't be able to send IPC message to DSP anymore. Also, I think notifying DSP should be the very first thing to do.
@plbossart, it is power-down related but doesn't have anything to do with power optimization. This PR is the response to this bug thesofproject/sof#2646. Currently, in kernel you remove the driver without notifying DSP about it. This is wrong per se, plus there are HW limitations that DSP have to take care of. One of them happens when you reset controller without power gating memory - this is the essence of the bug I quoted above.
@ranj063, yes this is the fix. CI will still be failing as there is corresponding DSP patch required thesofproject/sof#2837

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.

@marjwa then we do need an ABI change if we're adding a new IPC?

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.

@mrajwa snd_sof_free_trace() will first send a STOP IPC before freeing the dma pages for trace.

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.

If you want to keep it here, then the best place is to do this before snd_sof_remove() and after snd_sof_machine_unregister().

@ranj063 ranj063 Apr 28, 2020 •

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.

@mrajwa I also think we cannot do this in the core for the legacy platforms. Those platforms do no support runtime PM and we've never tested the CTX_SAVE IPC with them. So we need to be careful here. Take a look at the CI results.

I think we should do this only for GLK+ in the remove op

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.

@mrajwa any updates? This is a CI blocker

@mrajwa mrajwa May 7, 2020 •

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

@ranj063, as for

I think we should do this only for GLK+ in the remove op

First of all at the .remove stege for each platform (hda_dsp_remove) it is already too late to send any IPC.
Second, I took Keyon's concern into the account not only these supported by HDA. He suggested that we should inform all platforms. However I think, since they don't define .remove procedure, informing DSP is a bit redundant. As as you said CTX_SAVE IP has not been tested with them. So what about adding a condition on sending CTX_SAVE_IPC like if (sof_ops(sdev)->remove). So if remove is defined then send the the IPC.

if (IS_ENABLED(CONFIG_SND_SOC_SOF_PROBE_WORK_QUEUE))
cancel_work_sync(&sdev->probe_work);
Expand Down
9 changes: 9 additions & 0 deletions sound/soc/sof/pm.c
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,15 @@ static int sof_suspend(struct device *dev, bool runtime_suspend)
return ret;
Comment thread
kv2019i marked this conversation as resolved.
Resolved
}

int snd_sof_dsp_power_down_notify(struct snd_sof_dev *sdev)
{
/* Notify DSP of upcoming power down */
if (sof_ops(sdev)->remove)
return sof_send_pm_ctx_ipc(sdev, SOF_IPC_PM_CTX_SAVE);

return 0;
}

int snd_sof_runtime_suspend(struct device *dev)
{
return sof_suspend(dev, true);
Expand Down
1 change: 1 addition & 0 deletions sound/soc/sof/sof-priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,7 @@ int snd_sof_runtime_resume(struct device *dev);
int snd_sof_runtime_idle(struct device *dev);
int snd_sof_resume(struct device *dev);
int snd_sof_suspend(struct device *dev);
int snd_sof_dsp_power_down_notify(struct snd_sof_dev *sdev);
int snd_sof_prepare(struct device *dev);
void snd_sof_complete(struct device *dev);

Expand Down