Repository navigation
Module remove: inform DSP that driver is going to be removed - #2044
Conversation
kv2019i
left a comment
There was a problem hiding this comment.
Valid change for sure, but some questions about how we implement this. See inline.
| ret); | ||
| return ret; | ||
| } | ||
|
|
There was a problem hiding this comment.
@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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
+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?
There was a problem hiding this comment.
@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
There was a problem hiding this comment.
@marjwa then we do need an ABI change if we're adding a new IPC?
There was a problem hiding this comment.
@mrajwa snd_sof_free_trace() will first send a STOP IPC before freeing the dma pages for trace.
There was a problem hiding this comment.
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().
There was a problem hiding this comment.
@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
There was a problem hiding this comment.
@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.
| return sof_pre_remove(sdev); | ||
| } | ||
| EXPORT_SYMBOL(snd_sof_pre_remove); | ||
|
|
There was a problem hiding this comment.
Both these functions are unnecessary. Why not just export sof_send_pm_ctx_ipc() and call it from the remove() callbacks for each platform
There was a problem hiding this comment.
I exported new function snd_sof_dsp_power_down_notify(), this encapsulates sof_send_pm_ctx_ipc(). Are you OK with that?
d26134d to
4d85f27
Compare
kv2019i
left a comment
There was a problem hiding this comment.
@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.
|
Further updated. |
|
|
||
| return ret; | ||
| } | ||
| EXPORT_SYMBOL(snd_sof_dsp_power_down_notify); |
There was a problem hiding this comment.
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().
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
@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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
@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.
There was a problem hiding this comment.
Yes no need to export I agree.
Updated.
I see all testes for check-kmod-load-unload.sh have passed.
| 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); |
There was a problem hiding this comment.
You could simplify this function. Just retune aof_se d_pm_ctx_save() here
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>
|
@ranj063 I have applied your feedback. Are you OK with this now? |
|
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 .. I can't see a connection with the patch, but I just checked that another PR from today passed the same test: |
@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/ |
|
SOFCI TEST |
|
Ok, the cml_rt1011_rt5682 error is gone (which makes sense), so this looks good now. |
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