Skip to content

Module remove: inform DSP that driver is going to be removed - #2044

Merged
kv2019i merged 2 commits into
thesofproject:topic/sof-devfrom
mrajwa:lpsram_issue
May 12, 2020
Merged

kv2019i merged 2 commits into
thesofproject:topic/sof-devfrom
mrajwa:lpsram_issue

Conversation

@mrajwa

@mrajwa mrajwa commented Apr 23, 2020

Copy link
Copy Markdown

This patch set invokes the .pre_remove operation as the very first thing
during module remove to inform the DSP that driver is going to be removed.
The module removal enatils DSP power down, disabling of
IRQs and more. Therefore it is highly recommended to inform
the DSP about this upcoming event.

Currently, due to HW bug related to LPSRAM registers
it is necessary for DSP to power gate all LPSRAM banks
that were enabled. Otherwise, LPSRAM registers stall,
making LPSRAM inaccessible after following power up
of the DSP.

Signed-off-by: Marcin Rajwa marcin.rajwa@linux.intel.com

@kv2019i kv2019i left a comment

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.

Valid change for sure, but some questions about how we implement this. See inline.

Comment thread sound/soc/sof/core.c
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.

Comment thread sound/soc/sof/core.c Resolved
kv2019i
kv2019i previously approved these changes Apr 24, 2020

@kv2019i kv2019i left a comment

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 Ok thanks. So the distinction that in pre_remove() IPC is still available, while in remove() it is not. Ack on this. There's on typo in the commit still, but you do get the point so no need to update just for that.

Comment thread sound/soc/sof/core.c Resolved
Comment thread sound/soc/sof/pm.c Outdated
return sof_pre_remove(sdev);
}
EXPORT_SYMBOL(snd_sof_pre_remove);

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.

Both these functions are unnecessary. Why not just export sof_send_pm_ctx_ipc() and call it from the remove() callbacks for each platform

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.

I exported new function snd_sof_dsp_power_down_notify(), this encapsulates sof_send_pm_ctx_ipc(). Are you OK with that?

@mrajwa
mrajwa force-pushed the lpsram_issue branch 2 times, most recently from d26134d to 4d85f27 Compare April 27, 2020 08:49
paulstelian97
paulstelian97 previously approved these changes Apr 27, 2020

@kv2019i kv2019i left a comment

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 Ok, this is probably better. Now that I ended up reviewing tihs again after the update, I realized the commit message of the second patch is a bit dubious. Can you please check? Otherwise looks good to go. We also need to update pm.c:sof_suspend() to use the new exported function, but doesn't have to be in this PR.

Comment thread sound/soc/sof/pm.c Resolved
Comment thread sound/soc/sof/core.c Resolved
@mrajwa

mrajwa commented Apr 28, 2020

Copy link
Copy Markdown
Author

Further updated.

Comment thread sound/soc/sof/pm.c Outdated

return ret;
}
EXPORT_SYMBOL(snd_sof_dsp_power_down_notify);

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.

This function is not called outside of core.c and pm.c. So no need to export it. In fact I'd just declare sof_send_pm_ctx_ipc() in sof-priv.h and call it with CTX_SAVE as the parameter in snd_sof_device_remove().

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.

I answered above, there is one reason we should keep this function and not export just sof_send_pm_ctx_ipc() - there will likely be additional logic as to when we are sending this 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 I agree with @ranj063 - if there are no users of this function currently outside of the module and no clear certain plans for such users in the near future and this function doesn't belong to a consistent exported API, I'd rather not export it for now. We can always export it later if a need arises.

@mrajwa mrajwa May 8, 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.

Let's by clear, we have to send IPC do the DSP at the very beginning of snd_sof_device_remove() - do you agree?
Now, you don't want to export this newly created function snd_sof_dsp_power_down_notify() so then what would you like to export? If the answer is sof_send_pm_ctx_ipc() and call it with the SOF_IPC_PM_CTX_SAVE argument then I am against it as to me it exposes low level / specialized functions. Second the SOF_IPC_PM_CTX_SAVE is not supported for all platforms so we have to wrap this IPC message with a condition like:

if (sof_ops(sdev)->remove)
        sof_send_pm_ctx_ipc(sdev, SOF_IPC_PM_CTX_SAVE);

This way we will send IPC only for platform which support .remove procedure. Does it make sense to you?

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_device_remove() is in core.c and snd_sof_dsp_power_down_notify() is in pm.c, both those files are linked together in the same module snd-sof.ko, so, you don't need EXPORT_SYMBOL() for it unless you also plan to call that function from other kernel modules.

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.

Yes no need to export I agree.
Updated.

I see all testes for check-kmod-load-unload.sh have passed.

Comment thread sound/soc/sof/pm.c Resolved
Comment thread sound/soc/sof/core.c Resolved
Comment thread sound/soc/sof/pm.c Outdated
int ret;
/* Notify DSP of upcoming power down */
if (sof_ops(sdev)->remove) {
ret = sof_send_pm_ctx_ipc(sdev, SOF_IPC_PM_CTX_SAVE);

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.

You could simplify this function. Just retune aof_se d_pm_ctx_save() here

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.

Done

Comment thread sound/soc/sof/pm.c Resolved
mrajwa added 2 commits May 11, 2020 12:20
This patch adds a snd_sof_dsp_power_down_notify() method which aims to
prepare the DSP for the upcoming power down.
This new function make use of SOF_IPC_PM_CTX_SAVE message.

Signed-off-by: Marcin Rajwa <marcin.rajwa@linux.intel.com>
This patch invokes the DSP power down notifier to inform
DSP that driver is going to be removed.
The module removal entails DSP power down, disabling of
IRQs and more. Therefore it is highly recommended to inform
the DSP about this upcoming event.

Due to hardware limitations on some Intel platforms it is necessary
to power gate all LPSRAM banks that were enabled prior to controller
reset. Otherwise, an attempt to write LPSRAM control registers may
have no effect.

Signed-off-by: Marcin Rajwa <marcin.rajwa@linux.intel.com>
@mrajwa

mrajwa commented May 11, 2020

Copy link
Copy Markdown
Author

@ranj063 I have applied your feedback. Are you OK with this now?

@kv2019i

kv2019i commented May 11, 2020

Copy link
Copy Markdown
Collaborator

While waiting for other reviews, @mrajwa any comments on this error in CI:

kernel: [ 1.745485] cml_rt1011_rt5682 cml_rt1011_rt5682: ASoC: Neither/both codec name/of_node are set for SSP1-Codec
kernel: [ 1.745555] cml_rt1011_rt5682: probe of cml_rt1011_rt5682 failed with error -22

.. I can't see a connection with the patch, but I just checked that another PR from today passed the same test:
https://sof-ci.01.org/linuxpr/PR2062/build3737/devicetest/

@ranj063 ranj063 left a comment

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.

Thanks @mrajwa. Looks good now

@ranj063

ranj063 commented May 11, 2020 •

Copy link
Copy Markdown
Collaborator

While waiting for other reviews, @mrajwa any comments on this error in CI:

kernel: [ 1.745485] cml_rt1011_rt5682 cml_rt1011_rt5682: ASoC: Neither/both codec name/of_node are set for SSP1-Codec
kernel: [ 1.745555] cml_rt1011_rt5682: probe of cml_rt1011_rt5682 failed with error -22

.. I can't see a connection with the patch, but I just checked that another PR from today passed the same test:
https://sof-ci.01.org/linuxpr/PR2062/build3737/devicetest/

@kv2019i Let me trigger CI test again.

UPDATE: 8th May run with this patch was succesful. Other 30 runs I found in CI for this machine have all succeeded: https://sof-ci.01.org/linuxpr/PR2044/build3714/devicetest/

@ranj063

ranj063 commented May 11, 2020

Copy link
Copy Markdown
Collaborator

SOFCI TEST

@kv2019i

kv2019i commented May 12, 2020

Copy link
Copy Markdown
Collaborator

Ok, the cml_rt1011_rt5682 error is gone (which makes sense), so this looks good now.

@kv2019i
kv2019i merged commit 0df488a into thesofproject:topic/sof-dev May 12, 2020
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.

8 participants