Repository navigation
Conversation
c836329 to
c2d341b
Compare
plbossart
left a comment
There was a problem hiding this comment.
@ranj063 nice patch set with a number of style issues to be fixed. The main concern I have is the dailink removal in soc-core.c, it looks very invasive and will impact all SOC implementations. Wondering if we can avoid and decouple this from topology removal.
There was a problem hiding this comment.
how do you deal with pending operations if they are handled in snd_card_free()?
There was a problem hiding this comment.
@plbossart I'm not sure how to handle this at all. The problem is we need to unload topology before the snd_card is freed. Let me think about it a bit more.
There was a problem hiding this comment.
@plbossart the only way I can think of avoiding this is by calling snd_soc_tplg_component_remove(component, SND_SOC_TPLG_INDEX_ALL);
in snd_sof_device_remove() for SOF and in skl_remove() for the legacy driver to make sure that the topoogy is unloaded before the card is freed (this would be instead of calling it in the component driver remove()). What do you think about that?
There was a problem hiding this comment.
or the other option is before cleaning up the card resources in snd_soc_unbind_card(), I could call soc_remove_link_components() to remove the link components which would remove the topology.
snd_soc_bind_card() calls soc_probe_link_components(), so it would be symmetric
There was a problem hiding this comment.
@plbossart i've change PR to call remove component in unbind_card instead. Let me know what you think
There was a problem hiding this comment.
maybe we should rename ignore_module_refcount as check_module_refcount_on_open or something more meaningful than 'ignore' and then use it.
There was a problem hiding this comment.
@plbossart sorry about the style fixes. I'll fix them.
I agree it makes sense to rename this field. I havent been able to come up with a nice name that indicates what we're really trying to do here. Let me think about it and rename it today.
There was a problem hiding this comment.
done, I've rename it to module_get_upon_open. hopefully thats a bit more indicative of what we want to achieve.
0ff6da0 to
413dffe
Compare
left a comment
There was a problem hiding this comment.
@ranj063 I am still struggling with the part on the _unbind, mostly since I am not 100% familiar with the code and your comments did not provide the pointer I was looking for. Can you try and made it more self-explanatory, it'll help even with more expert reviewers explain how this works.
Also a couple of commit messages, style, squash and bad refcounts to fix.
Thanks!
There was a problem hiding this comment.
help me understand something here: the existing code pattern is repeated a number of times, e.g. it's also used for enums:
kfree(dobj->control.dvalues);
for (i = 0; i < se->items; i++)
kfree(dobj->control.dtexts[i]);
kfree(dobj->control.dtexts);
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.
There was a problem hiding this comment.
@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.
It was a genuine null pointer dereference I saw with the legacy driver that led to me discovering this error while trying to unload the snd_soc_skl module. We dont have enum controls in SOF. So we never encountered this problem before.
There was a problem hiding this comment.
@ranj063 then you'd really want a comment telling reviewers/users of that code that this is very specific and intentional with explanations
There was a problem hiding this comment.
@plbossart updated this now. I know the change isnt quite obvious but it is a serious error and hopefully the comment clarifies it.
There was a problem hiding this comment.
"snd_soc_bind_card() probes the link components after the snd_card
is registered". Looking at the code, this is far from obvious, and the code to remove link components does not seem to have a matching equivalent in snd_soc_bind_card(). Either the commit message is wrong or it omits a precision needed for your esteemed (?) reviewer to see the beauty of this PR.
There was a problem hiding this comment.
commit message still riddled with spelling mistakes :-(
There was a problem hiding this comment.
@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.
There was a problem hiding this comment.
isn't this comment still relevant, even with the use of devm_ ? does it need to be removed completely or reworded?
There was a problem hiding this comment.
wasn't there a patch for SKL as well that needs to be updated?
There was a problem hiding this comment.
You should add a
Fixes: SHA1 ('title') tag
There was a problem hiding this comment.
I wasn't crazy, this needs to be squashed with the previous patch to avoid bisect issues.
There was a problem hiding this comment.
this isn't balanced with the module_get(), which is done only when you have a .ops and a .open. You might decrease references that were not previously incremented.
There was a problem hiding this comment.
@plbossart good catch. I did infact put it in the wrong place.
commented
Apr 1, 2019
|
@xiulipan the Intel CI seems to be broken? |
386eb34 to
52df475
Compare
commented
Apr 1, 2019
|
@plbossart sorry for giving you a hard time with this one. It wasnt a very straight forward PR with fixes everywhere. Hopefully the latest version has no style issue anymore. |
commented
Apr 2, 2019
|
@plbossart |
…texts "dobj" is the widget dobj. dvalues and dtexts belong to the enum kcontrol's dobj (se->dobj). So, use this to free the control values and texts to prevent the NULL pointer dereference while removing widgets. Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Topology is loaded when the component driver is probed. So, it should be removed in the component driver's remove(). This will prevent null pointer dereference while unregistering the component driver. Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Topology is not unloaded in the core during unregister_component() anymore. So, add the remove() callback that will unload the topology. Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
snd_soc_bind_card() calls snd_soc_instantiate_card() to first register the snd_card and then probe the link components by calling soc_probe_link_components(). The snd_card is used by the component driver during its probe() while loading topology widgets to add the controls to the snd_card. The snd_card also needs to be valid while unloading the topology widgets when the component driver is removed. Therefore, in snd_soc_unbind_card(), the link components should be removed with the call to soc_remove_link_components() before the card resources are cleaned up and the snd_card itself is freed. Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
This is no longer done in the core during unregister_component. So, it should be done in the component driver's remove callback(). Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Previously, we couldn't make the component driver resource-managed because topology unloading was done by the core when the component driver was unregistered. But this has been fixed to allow topology removal during the component driver remove() callback and there aren't any NULL pointer dereferences anymore. Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Recently, for Intel platforms the "ignore_module_refcount" field was introduced for the component driver which prevented the refcounts being incremented for the device driver module during component probe. However, this leads to the problem of allowing the device driver module to be unloaded while a pcm stream is open. So rename the field to "module_get_upon_open" which is more meaningful in terms of allowing the refcount for the module to be incremented when a pcm is opened. Also, align with the skylake component driver with the new name. Fixes: b450b87('ASoC: core: don't increase component module refcount unconditionally' Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
The "ignore_module_refcount" field in the component driver has been renamed to "module_get_upon_open". So align with the new name. Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Setting the module_get_upon_open field for component driver prevents the module refcount from being incremented during component probe(). But this could lead to the module being allowed to be unloaded when a pcm stream is open. So, if this field is set, the module's refcount should be incremented/decremented during pcm open/close to prevent it. Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
52df475 to
53c42c5
Compare
commented
Apr 4, 2019
|
@plbossart I'm going to break this PR into 3 separate ones for easier review. Closing this one for now |
This pull request contains a series of fixes needed for fixing issues with module unloading/loading.
Tests performed: