• C
    ASoC: core: Exit all links before removing their components · c7eb967d
    Cezary Rojewski 提交于
    Flows leading to link->init() and link->exit() are not symmetric.
    Currently the relevant part of card probe sequence goes as:
    
    	for_each_card_rtds(card, rtd)
    		for_each_rtd_components(rtd, i, component)
    			component->probe()
    	for_each_card_rtds(card, rtd)
    		for_each_rtd_dais(rtd, i, dai)
    			dai->probe()
    	for_each_card_rtds(card, rtd)
    		rtd->init()
    
    On the other side, equivalent remove sequence goes as:
    
    	for_each_card_rtds(card, rtd)
    		for_each_rtd_dais(rtd, i, dai)
    			dai->remove()
    	for_each_card_rtds(card, rtd)
    		for_each_rtd_components(rtd, i, component)
    			component->remove()
    	for_each_card_rtds(card, rtd)
    		rtd->exit()
    
    what can lead to errors as link->exit() may still operate on resources
    owned by its components despite the probability of them being freed
    during the component->remove().
    
    This change modifies the remove sequence to:
    
    	for_each_card_rtds(card, rtd)
    		rtd->exit()
    	for_each_card_rtds(card, rtd)
    		for_each_rtd_dais(rtd, i, dai)
    			dai->remove()
    	for_each_card_rtds(card, rtd)
    		for_each_rtd_components(rtd, i, component)
    			component->remove()
    
    so code found in link->exit() is safe to touch any component stuff as
    component->remove() has not been called yet.
    Signed-off-by: NCezary Rojewski <cezary.rojewski@intel.com>
    Reviewed-by: NAmadeusz Sławiński <amadeuszx.slawinski@linux.intel.com>
    Link: https://lore.kernel.org/r/20221027085840.1562698-1-cezary.rojewski@intel.comSigned-off-by: NMark Brown <broonie@kernel.org>
    c7eb967d
soc-core.c 86.1 KB