mirror of
https://github.com/torvalds/linux.git
synced 2026-07-29 02:31:27 +02:00
ASoC: mediatek: mt8183: Fix probe resource cleanup
Cássio Gabriel <cassiogabrielcontato@gmail.com> says: The MT8183 AFE probe has two cleanup gaps that match issues recently fixed in newer MediaTek AFE drivers. First, reserved memory assigned with of_reserved_mem_device_init() is never released on driver removal or later probe failures. Second, the probe-time runtime PM resume used before reinitializing the regmap cache is unchecked, and a regmap_reinit_cache() failure skips the temporary PM put. Fix both issues with a devm reserved-memory release action and checked runtime PM resume handling. Link: https://patch.msgid.link/20260527-asoc-mt8183-probe-cleanup-v1-0-4f4f5593c8d1@gmail.com
This commit is contained in:
commit
ba9ea6b3d2
|
|
@ -766,6 +766,11 @@ static const dai_register_cb dai_register_cbs[] = {
|
|||
mt8183_dai_memif_register,
|
||||
};
|
||||
|
||||
static void mt8183_afe_release_reserved_mem(void *data)
|
||||
{
|
||||
of_reserved_mem_device_release(data);
|
||||
}
|
||||
|
||||
static int mt8183_afe_pcm_dev_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct mtk_base_afe *afe;
|
||||
|
|
@ -794,6 +799,12 @@ static int mt8183_afe_pcm_dev_probe(struct platform_device *pdev)
|
|||
if (ret) {
|
||||
dev_info(dev, "no reserved memory found, pre-allocating buffers instead\n");
|
||||
afe->preallocate_buffers = true;
|
||||
} else {
|
||||
ret = devm_add_action_or_reset(dev,
|
||||
mt8183_afe_release_reserved_mem,
|
||||
dev);
|
||||
if (ret)
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* initial audio related clock */
|
||||
|
|
@ -833,17 +844,21 @@ static int mt8183_afe_pcm_dev_probe(struct platform_device *pdev)
|
|||
|
||||
/* enable clock for regcache get default value from hw */
|
||||
afe_priv->pm_runtime_bypass_reg_ctl = true;
|
||||
pm_runtime_get_sync(dev);
|
||||
ret = pm_runtime_resume_and_get(dev);
|
||||
if (ret) {
|
||||
afe_priv->pm_runtime_bypass_reg_ctl = false;
|
||||
goto err_pm_disable;
|
||||
}
|
||||
|
||||
ret = regmap_reinit_cache(afe->regmap, &mt8183_afe_regmap_config);
|
||||
pm_runtime_put_sync(dev);
|
||||
afe_priv->pm_runtime_bypass_reg_ctl = false;
|
||||
|
||||
if (ret) {
|
||||
dev_err(dev, "regmap_reinit_cache fail, ret %d\n", ret);
|
||||
goto err_pm_disable;
|
||||
}
|
||||
|
||||
pm_runtime_put_sync(dev);
|
||||
afe_priv->pm_runtime_bypass_reg_ctl = false;
|
||||
|
||||
regcache_cache_only(afe->regmap, true);
|
||||
regcache_mark_dirty(afe->regmap);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user