Repository navigation
Remove DSP after unregistering the machine driver #863
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -380,7 +380,7 @@ static int sof_probe_continue(struct snd_sof_dev *sdev) | |
|
|
||
| if (IS_ERR(plat_data->pdev_mach)) { | ||
| ret = PTR_ERR(plat_data->pdev_mach); | ||
| goto comp_err; | ||
| goto fw_run_err; | ||
| } | ||
|
|
||
| dev_dbg(sdev->dev, "created machine %s\n", | ||
|
|
@@ -391,8 +391,6 @@ static int sof_probe_continue(struct snd_sof_dev *sdev) | |
|
|
||
| return 0; | ||
|
|
||
| comp_err: | ||
| snd_soc_unregister_component(sdev->dev); | ||
| fw_run_err: | ||
| snd_sof_fw_unload(sdev); | ||
| fw_load_err: | ||
|
|
@@ -482,7 +480,6 @@ int snd_sof_device_remove(struct device *dev) | |
| snd_sof_ipc_free(sdev); | ||
| snd_sof_free_debug(sdev); | ||
| snd_sof_free_trace(sdev); | ||
| snd_sof_remove(sdev); | ||
|
|
||
| /* | ||
| * Unregister machine driver. This will unbind the snd_card which | ||
|
|
@@ -492,6 +489,14 @@ int snd_sof_device_remove(struct device *dev) | |
| if (!IS_ERR_OR_NULL(pdata->pdev_mach)) | ||
| platform_device_unregister(pdata->pdev_mach); | ||
|
|
||
| /* | ||
| * Unregistering the machine driver results in unloading the topology. | ||
| * Some widgets, ex: scheduler, attempt to power down the core they are | ||
| * scheduled on, when they are unloaded. Therefore, the DSP must be | ||
| * removed only after the topology has been unloaded. | ||
| */ | ||
| snd_sof_remove(sdev); | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch, but still one question unclear to me: In your commit message it is stated "snd_hdac_ext_bus_device_remove() to remove the codec which unregisters the component driver thereby also removing the topology.", per my understanding, this only remove the codec soc component(not the soc component we register here?), how does it removing the topology.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @keyonjie take a look at __snd_soc_unregister_component() in soc-core.c. It removes the tplg for all components who's dev matches the input argument "dev". Now, in our case both the hdmic codec component device and the SOF component device are the same and thats why snd_hdac_ext_bus_device_remove() results in removing the topology There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, if we share the "dev" in both hdmi codec and SOF component, that explains, thanks. |
||
| /* release firmware */ | ||
| release_firmware(pdata->fw); | ||
| pdata->fw = NULL; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this really helpful for fixing #861 or only changing it while you are at here? My understanding is that we can invoke unregister specifically for resource-managed component device.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yup, just while i'm at it. Not relevant for #861. Only the first commit is needed to fix the issue
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure this is a good idea. This is a .probe() "bottom half," it's often performed in a work context after the actual probing has completed and returned success. Usually when you use managed allocations, it's done within .probe(), so that a failure leads to the .probe() failing and then all such allocations are freed. In this case an allocation failure will not lead to .probe() failing, so, the resource will stay allocated. This isn't bad, it will be freed if the modules are unloaded, but it's also not useful to keep it in the error case. So, maybe better to keep that unregister.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lyakh i havent tried this yet but what happens if you leave the unregister here, the machine driver registration fails and then you try to unload sof device?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ranj063 I haven't tried either. Nothing bad should happen at the resource management level, you have already unregistered the resource, so, no second unregistering will be attempted by the resource management system. But I don't know whether the driver's .release() method would choke because it assumes that the registration has completed successfully.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lyakh i just tried it and nothing bad happened. I am OK to leave it here or remove it. removing it makes more sense to me but if you prefer leaving it here i'm OK with it too.