Repository navigation
Module loading/Unloading fixes for SOF and legacy drivers #765
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
22f0cad
05fb82d
f6d9670
745a007
e5b1280
8e8ab0c
feae2d4
fe57de4
53c42c5
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 |
|---|---|---|
|
|
@@ -1462,13 +1462,21 @@ static int skl_platform_soc_probe(struct snd_soc_component *component) | |
| return 0; | ||
| } | ||
|
|
||
| static void skl_pcm_remove(struct snd_soc_component *component) | ||
| { | ||
| /* remove topology */ | ||
| snd_soc_tplg_component_remove(component, SND_SOC_TPLG_INDEX_ALL); | ||
| } | ||
|
|
||
|
|
||
| static const struct snd_soc_component_driver skl_component = { | ||
| .name = "pcm", | ||
| .probe = skl_platform_soc_probe, | ||
| .remove = skl_pcm_remove, | ||
| .ops = &skl_platform_ops, | ||
| .pcm_new = skl_pcm_new, | ||
| .pcm_free = skl_pcm_free, | ||
| .ignore_module_refcount = 1, /* do not increase the refcount in core */ | ||
| .module_get_upon_open = 1, /* increase the refcount when a pcm is opened */ | ||
|
Member
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. I wasn't crazy, this needs to be squashed with the previous patch to avoid bisect issues. |
||
| }; | ||
|
|
||
| int skl_platform_register(struct device *dev) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -947,7 +947,7 @@ static void soc_cleanup_component(struct snd_soc_component *component) | |
| snd_soc_dapm_free(snd_soc_component_get_dapm(component)); | ||
| soc_cleanup_component_debugfs(component); | ||
| component->card = NULL; | ||
| if (!component->driver->ignore_module_refcount) | ||
| if (!component->driver->module_get_upon_open) | ||
| module_put(component->dev->driver->owner); | ||
| } | ||
|
|
||
|
|
@@ -1381,7 +1381,7 @@ static int soc_probe_component(struct snd_soc_card *card, | |
| return 0; | ||
| } | ||
|
|
||
| if (!component->driver->ignore_module_refcount && | ||
| if (!component->driver->module_get_upon_open && | ||
|
Member
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. wasn't there a patch for SKL as well that needs to be updated? |
||
| !try_module_get(component->dev->driver->owner)) | ||
| return -ENODEV; | ||
|
|
||
|
|
@@ -2831,10 +2831,22 @@ EXPORT_SYMBOL_GPL(snd_soc_register_card); | |
|
|
||
| static void snd_soc_unbind_card(struct snd_soc_card *card, bool unregister) | ||
| { | ||
| struct snd_soc_pcm_runtime *rtd; | ||
| int order; | ||
|
|
||
| if (card->instantiated) { | ||
| card->instantiated = false; | ||
| snd_soc_dapm_shutdown(card); | ||
| snd_soc_flush_all_delayed_work(card); | ||
|
|
||
| /* remove all components used by DAI links on this card */ | ||
| for_each_comp_order(order) { | ||
| for_each_card_rtds(card, rtd) { | ||
| soc_remove_link_components(card, rtd, order); | ||
| } | ||
| } | ||
|
Member
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. "snd_soc_bind_card() probes the link components after the snd_card |
||
|
|
||
| /* clean up card resources */ | ||
| soc_cleanup_card_resources(card); | ||
| if (!unregister) | ||
| list_add(&card->list, &unbind_card_list); | ||
|
|
@@ -3327,8 +3339,6 @@ static int __snd_soc_unregister_component(struct device *dev) | |
| if (dev != component->dev) | ||
| continue; | ||
|
|
||
| snd_soc_tplg_component_remove(component, | ||
| SND_SOC_TPLG_INDEX_ALL); | ||
| snd_soc_component_del_unlocked(component); | ||
| found = 1; | ||
| break; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -482,10 +482,11 @@ static void remove_widget(struct snd_soc_component *comp, | |
|
|
||
| snd_ctl_remove(card, kcontrol); | ||
|
|
||
| kfree(dobj->control.dvalues); | ||
| /* free enum kcontrol's dvalues and dtexts */ | ||
| kfree(se->dobj.control.dvalues); | ||
| for (j = 0; j < se->items; j++) | ||
| kfree(dobj->control.dtexts[j]); | ||
| kfree(dobj->control.dtexts); | ||
| kfree(se->dobj.control.dtexts[j]); | ||
| kfree(se->dobj.control.dtexts); | ||
|
Member
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. help me understand something here: the existing code pattern is repeated a number of times, e.g. it's also used for enums: so either we fix this everywhere or we don't. I feel uncomfortable with a specific change that breaks a mostly regular pattern so far.
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. @plbossart it cant be changed everywhere. In the remove_enum() method, the dobj is actually the control's dobj. whereas in remove_widget, the input argument dobj is the widget's dobj and what we're trying to delete is the control's dobj's texts and values.
Member
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. @ranj063 then you'd really want a comment telling reviewers/users of that code that this is very specific and intentional with explanations
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. @plbossart updated this now. I know the change isnt quite obvious but it is a serious error and hopefully the comment clarifies it. |
||
|
|
||
| kfree(se); | ||
| kfree(w->kcontrol_news[i].name); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -350,7 +350,7 @@ static int sof_probe_continue(struct snd_sof_dev *sdev) | |
| sdev->first_boot = false; | ||
|
ranj063 marked this conversation as resolved.
Outdated
|
||
|
|
||
| /* now register audio DSP platform driver and dai */ | ||
| ret = snd_soc_register_component(sdev->dev, &sdev->plat_drv, | ||
|
Member
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. commit message still riddled with spelling mistakes :-(
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. @plbossart hmm I knew it wasnt a good idea to just stop wearing glasses. time to make that trip to the optometrist soon. fixed the typos now. |
||
| ret = devm_snd_soc_register_component(sdev->dev, &sdev->plat_drv, | ||
| sof_ops(sdev)->drv, | ||
| sof_ops(sdev)->num_drv); | ||
| if (ret < 0) { | ||
|
|
@@ -461,16 +461,16 @@ int snd_sof_device_remove(struct device *dev) | |
| if (IS_ENABLED(CONFIG_SND_SOC_SOF_PROBE_WORK_QUEUE)) | ||
| cancel_work_sync(&sdev->probe_work); | ||
|
|
||
| snd_soc_unregister_component(dev); | ||
| snd_sof_fw_unload(sdev); | ||
| snd_sof_ipc_free(sdev); | ||
| snd_sof_free_debug(sdev); | ||
| snd_sof_free_trace(sdev); | ||
| snd_sof_remove(sdev); | ||
|
|
||
| /* | ||
| * platform_device_unregister() frees the card and its resources. | ||
| * So it should be called after unregistering the comp driver | ||
| * so that the card is valid while unregistering comp driver. | ||
| * Unregister machine driver. This will unbind the snd_card which | ||
| * will remove the component driver and unload the topology | ||
| * before freeing the snd_card. | ||
| */ | ||
| if (!IS_ERR_OR_NULL(pdata->pdev_mach)) | ||
| platform_device_unregister(pdata->pdev_mach); | ||
|
|
||
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.
You should add a
Fixes: SHA1 ('title') tag