Fixes for SOF module unload/reload
Subsystems (3)
cover Fixes for SOF module unload/reload
A recent commit "ALSA: hdac: fix memory release for SST and SOF drivers" removed the kfree call for the hdac device in snd_hdac_ext_bus_device_exit(). This requires that the SOF driver also make the hdac_device and hdac_hda_priv device-managed so that they can be freed when the SOF module in unloaded. The first patch takes care of this change.
Additionally, because of the above change, the hda_codec is device-managed and freeing it in snd_hda_codec_dev_release() leads to kernel panic with module unload/reload stress tests. The second patch includes the change to avoid freeing hda_codec for ASoC driver.
More details for the module unload/reload test failures can be found
here: https://github.com/thesofproject/linux/issues/966
Ranjani Sridharan (2):
ASoC: SOF: Intel: hda: Make hdac_device device-managed
ASoC: hda: don't free hda_codec for HDA_DEV_ASOC type
sound/pci/hda/hda_codec.c | 8 +++++++- sound/soc/sof/intel/hda-codec.c | 6 ++---- 2 files changed, 9 insertions(+), 5 deletions(-)
Signature · 1 line
2.17.1
PATCH 1/2 ASoC: SOF: Intel: hda: Make hdac_device device-managed
snd_hdac_ext_bus_device_exit() has been recently modified to no longer free the hdac device. SOF allocates memory for hdac_device and hda_hda_priv with kzalloc. Make them device-managed instead so that they will be freed when the SOF driver is unloaded.
--- sound/soc/sof/intel/hda-codec.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
sound/soc/sof/intel/hda-codec.c +2 -4
@@ -62,8 +62,7 @@ static int hda_codec_probe(struct snd_sof_dev *sdev, int address) address, resp);#if IS_ENABLED (CONFIG_SND_SOC_SOF_HDA_AUDIO_CODEC ) -/* snd_hdac_ext_bus_device_exit will use kfree to free hdev */ - hda_priv =kzalloc (sizeof (*hda_priv),GFP_KERNEL ); + hda_priv =devm_kzalloc (sdev->dev,sizeof (*hda_priv),GFP_KERNEL );if (!hda_priv)return -ENOMEM ;
@@ -82,8 +81,7 @@ static int hda_codec_probe(struct snd_sof_dev *sdev, int address)return 0 ;#else -/* snd_hdac_ext_bus_device_exit will use kfree to free hdev */ - hdev =kzalloc (sizeof (*hdev),GFP_KERNEL ); + hdev =devm_kzalloc (sdev->dev,sizeof (*hdev),GFP_KERNEL );if (!hdev)return -ENOMEM ;
Signature · 1 line
2.17.1
PATCH 2/2 ASoC: hda: don't free hda_codec for HDA_DEV_ASOC type
In reply to Ranjani SridharanIn the case of ASoC driver, the hdac_hda_priv pointer containing the hda_codec is device-managed. It will be freed when the ASoC device is removed during driver unloading. Freeing the codec in snd_hda_codec_dev_release() leads to kernel panics while unloading and reloading the ASoC driver.
--- sound/pci/hda/hda_codec.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
sound/pci/hda/hda_codec.c +7 -1
@@ -846,7 +846,13 @@ static void snd_hda_codec_dev_release(struct device *dev)snd_hda_sysfs_clear (codec);kfree (codec->modelname);kfree (codec->wcaps); -kfree (codec); + +/* +* In the case of ASoC HD-audio, hda_codec is device managed. +* It will be freed when the ASoC device is removed. +*/ +if (codec->core.type ==HDA_DEV_LEGACY ) +kfree (codec); }#define DEV_NAME_LEN 31
Signature · 1 line
2.17.1
Quoted 8 lines · Ranjani Sridharan
A recent commit "ALSA: hdac: fix memory release for SST and SOF drivers" removed the kfree call for the hdac device in
snd_hdac_ext_bus_device_exit(). This requires that the SOF driver also make thehdac_deviceandhdac_hda_privdevice-managed so that they can be freed when the SOF module in unloaded. The first patch takes care of this change.
Quoted 4 lines
Additionally, because of the above change, the
hda_codecis device-managed and freeing it insnd_hda_codec_dev_release()leads to kernel panic with module unload/reload stress tests. The second patch includes the change to avoid freeinghda_codecfor ASoC driver.
In such a case, both patch need to be put into a single patch. Otherwise it leads to a bisection failure.
thanks,
Takashi
Quoted 15 lines
More details for the module unload/reload test failures can be found
here: https://github.com/thesofproject/linux/issues/966Ranjani Sridharan (2):
ASoC: SOF: Intel: hda: Makehdac_devicedevice-managed
ASoC: hda: don't freehda_codecforHDA_DEV_ASOCtypesound/pci/hda/hda_codec.c | 8 +++++++- sound/soc/sof/intel/hda-codec.c | 6 ++---- 2 files changed, 9 insertions(+), 5 deletions(-)Signature · 1 line
2.17.1
Quoted 11 lines · Takashi Iwai
Quoted 9 lines · Ranjani Sridharan
A recent commit "ALSA: hdac: fix memory release for SST and SOF drivers"
removed the kfree call for the hdac device insnd_hdac_ext_bus_device_exit(). This requires that the SOF driver also make thehdac_deviceandhdac_hda_privdevice-managed so that they can be freed when the SOF module in unloaded. The first patch takes care of this change.
Quoted 8 lines
Quoted 5 lines
Additionally, because of the above change, the
hda_codecis device-managed and freeing it insnd_hda_codec_dev_release()leads to kernel panic with module unload/reload stress tests. The second patch includes the change to avoid freeinghda_codecfor ASoC driver.In such a case, both patch need to be put into a single patch. Otherwise it leads to a bisection failure.
Thanks, Takashi. Just sent a v2 combining both the changes.
Thanks,
Ranjani
Quoted 27 lines
thanks,
Takashi
Quoted 5 lines
More details for the module unload/reload test failures can be found
here: https://github.com/thesofproject/linux/issues/966Quoted 11 lines
Ranjani Sridharan (2):
ASoC: SOF: Intel: hda: Makehdac_devicedevice-managed
ASoC: hda: don't freehda_codecforHDA_DEV_ASOCtypesound/pci/hda/hda_codec.c | 8 +++++++- sound/soc/sof/intel/hda-codec.c | 6 ++---- 2 files changed, 9 insertions(+), 5 deletions(-)Signature · 1 line
2.17.1_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel