ASoC: SOF: Intel: hda: Make hdac_device device-managed
Subsystems (3)
PATCH RESEND v2 1/1 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.
Because of the above change, hda_codec is device-managed and it will be freed when the ASoC device is removed. Freeing the codec in snd_hda_codec_dev_release() leads to kernel panic while unloading and reloading the ASoC driver. So, avoid freeing the hda_codec for ASoC driver. This is done in the same patch to avoid bisect failure.
--- sound/pci/hda/hda_codec.c | 8 +++++++- sound/soc/sof/intel/hda-codec.c | 6 ++---- 2 files changed, 9 insertions(+), 5 deletions(-)
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
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
Quoted 6 lines · Ranjani Sridharan
snd_hdac_ext_bus_device_exit()has been recently modified to no longer free the hdac device. SOF allocates memory forhdac_deviceandhda_hda_privwith kzalloc. Make them device-managed instead so that they will be freed when the SOF driver is unloaded.
Quoted 6 lines
Because of the above change,
hda_codecis device-managed and it will be freed when the ASoC device is removed. Freeing the codec insnd_hda_codec_dev_release()leads to kernel panic while unloading and reloading the ASoC driver. So, avoid freeing thehda_codecfor ASoC driver. This is done in the same patch to avoid bisect failure.
Hi Mark,
This patch is needed for the module load/unload stress tests for the Intel platforms with SOF. Could you please help review it?
The details of the issue can be found here:
https://github.com/thesofproject/linux/issues/966
Thanks,
Ranjani
Quoted 59 lines
Signed-off-by Libin Yang <[email protected]>Signed-off-by Ranjani Sridharan <[email protected]>Reviewed-by Takashi Iwai <[email protected]>Reviewed-by Pierre-Louis Bossart <--- sound/pci/hda/hda_codec.c | 8 +++++++- sound/soc/sof/intel/hda-codec.c | 6 ++---- 2 files changed, 9 insertions(+), 5 deletions(-)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_LEN31sound/soc/sof/intel/hda-codec.c +1
-2@@ -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)sound/soc/sof/intel/hda-codec.c +1
-2return -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 ;
Mark Brown
maintainerQuoted 2 lines · Ranjani Sridharan
This patch is needed for the module load/unload stress tests for the Intel platforms with SOF. Could you please help review it?
Please don't send content free pings and please allow a reasonable time for review. People get busy, go on holiday, attend conferences and so on so unless there is some reason for urgency (like critical bug fixes) please allow at least a couple of weeks for review. If there have been review comments then people may be waiting for those to be addressed.
Sending content free pings adds to the mail volume (if they are seen at all) which is often the problem and since they can't be reviewed directly if something has gone wrong you'll have to resend the patches anyway, so sending again is generally a better approach though there are some other maintainers who like them - if in doubt look at how patches for the subsystem are normally handled.
Quoted 16 lines · Mark Brown
Quoted 3 lines · Ranjani Sridharan
This patch is needed for the module load/unload stress tests for the
Intel platforms with SOF. Could you please help review it?Please don't send content free pings and please allow a reasonable time
for review. People get busy, go on holiday, attend conferences and so
on so unless there is some reason for urgency (like critical bug fixes)
please allow at least a couple of weeks for review. If there have been
review comments then people may be waiting for those to be addressed.
Quoted 10 lines
Sending content free pings adds to the mail volume (if they are seen at
all) which is often the problem and since they can't be reviewed directly if something has gone wrong you'll have to resend the patches
anyway, so sending again is generally a better approach though there are
some other maintainers who like them - if in doubt look at how patches
for the subsystem are normally handled.
Understood, sorry for the noise. I just wasn't sure about what the reasonable response time to expect was. I will check back in a week's time.
Thanks,
Ranjani
Quoted 4 lines
_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel