ASoC: SOF: Intel: Do not use resource managed allocation for ipc4_data
authorPeter Ujfalusi <peter.ujfalusi@linux.intel.com>
Wed, 29 Nov 2023 12:53:26 +0000 (14:53 +0200)
committerMark Brown <broonie@kernel.org>
Wed, 29 Nov 2023 13:25:14 +0000 (13:25 +0000)
Manage the ipc4_data allocation in code instead of devm since the ops_init
might be called more than once due to IPC type fallback.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Link: https://lore.kernel.org/r/20231129125327.23708-13-peter.ujfalusi@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/sof/intel/apl.c
sound/soc/sof/intel/cnl.c
sound/soc/sof/intel/hda-dai.c
sound/soc/sof/intel/icl.c
sound/soc/sof/intel/lnl.c
sound/soc/sof/intel/mtl.c
sound/soc/sof/intel/skl.c
sound/soc/sof/intel/tgl.c

index 776b66389c345b3f8eef37959c403edbe78b04f2..dee6c7f73e80a694cd9d710254bbb2bcff1ef903 100644 (file)
@@ -55,7 +55,7 @@ int sof_apl_ops_init(struct snd_sof_dev *sdev)
        if (sdev->pdata->ipc_type == SOF_IPC_TYPE_4) {
                struct sof_ipc4_fw_data *ipc4_data;
 
-               sdev->private = devm_kzalloc(sdev->dev, sizeof(*ipc4_data), GFP_KERNEL);
+               sdev->private = kzalloc(sizeof(*ipc4_data), GFP_KERNEL);
                if (!sdev->private)
                        return -ENOMEM;
 
index 598cf50abadb3ae6e18f1adbe248bf1ab31a5fb9..85e1e4760d0e59ee794400f560d320f2ca6068c6 100644 (file)
@@ -402,7 +402,7 @@ int sof_cnl_ops_init(struct snd_sof_dev *sdev)
        if (sdev->pdata->ipc_type == SOF_IPC_TYPE_4) {
                struct sof_ipc4_fw_data *ipc4_data;
 
-               sdev->private = devm_kzalloc(sdev->dev, sizeof(*ipc4_data), GFP_KERNEL);
+               sdev->private = kzalloc(sizeof(*ipc4_data), GFP_KERNEL);
                if (!sdev->private)
                        return -ENOMEM;
 
index a20deaf3b4287ee7757efaee5c7a0e498d3b31ae..f4cbc0ad5de3b427583964f8cd49c41acc53e581 100644 (file)
@@ -621,6 +621,9 @@ void hda_ops_free(struct snd_sof_dev *sdev)
 
                if (!hda_use_tplg_nhlt)
                        intel_nhlt_free(ipc4_data->nhlt);
+
+               kfree(sdev->private);
+               sdev->private = NULL;
        }
 }
 EXPORT_SYMBOL_NS(hda_ops_free, SND_SOC_SOF_INTEL_HDA_COMMON);
index 8e29d6bb6fe82f44df20e15ea25fd26209bf7509..04069859199217f7d9b47e2390eee6d56904f47b 100644 (file)
@@ -123,7 +123,7 @@ int sof_icl_ops_init(struct snd_sof_dev *sdev)
        if (sdev->pdata->ipc_type == SOF_IPC_TYPE_4) {
                struct sof_ipc4_fw_data *ipc4_data;
 
-               sdev->private = devm_kzalloc(sdev->dev, sizeof(*ipc4_data), GFP_KERNEL);
+               sdev->private = kzalloc(sizeof(*ipc4_data), GFP_KERNEL);
                if (!sdev->private)
                        return -ENOMEM;
 
index db94b45e53af8f703f5ee646c2729e44d2faa52b..03308721ebd4fcb88997fcb2b2f0bc29ade1e95c 100644 (file)
@@ -120,7 +120,7 @@ int sof_lnl_ops_init(struct snd_sof_dev *sdev)
 
        sof_lnl_ops.get_stream_position = mtl_dsp_get_stream_hda_link_position;
 
-       sdev->private = devm_kzalloc(sdev->dev, sizeof(struct sof_ipc4_fw_data), GFP_KERNEL);
+       sdev->private = kzalloc(sizeof(struct sof_ipc4_fw_data), GFP_KERNEL);
        if (!sdev->private)
                return -ENOMEM;
 
index 3ef9e5c3702837749d35afb08c1b6bb7c38d537e..f941e2c49d7813c17467b2600f5a30b52778c06a 100644 (file)
@@ -709,7 +709,7 @@ int sof_mtl_ops_init(struct snd_sof_dev *sdev)
 
        sof_mtl_ops.get_stream_position = mtl_dsp_get_stream_hda_link_position;
 
-       sdev->private = devm_kzalloc(sdev->dev, sizeof(struct sof_ipc4_fw_data), GFP_KERNEL);
+       sdev->private = kzalloc(sizeof(struct sof_ipc4_fw_data), GFP_KERNEL);
        if (!sdev->private)
                return -ENOMEM;
 
index d24e64e71b58f52da464bfa3eb4086162c400435..93824e6ce57307b0a85a49c9d4c0e7d42a42b46b 100644 (file)
@@ -62,7 +62,7 @@ int sof_skl_ops_init(struct snd_sof_dev *sdev)
        /* probe/remove/shutdown */
        sof_skl_ops.shutdown    = hda_dsp_shutdown;
 
-       sdev->private = devm_kzalloc(sdev->dev, sizeof(*ipc4_data), GFP_KERNEL);
+       sdev->private = kzalloc(sizeof(*ipc4_data), GFP_KERNEL);
        if (!sdev->private)
                return -ENOMEM;
 
index f7de1f5ba06d1089bec261fc7259df4ec35d0a19..d890cac6cb01bc1710488a19dfe58470c25e436d 100644 (file)
@@ -82,7 +82,7 @@ int sof_tgl_ops_init(struct snd_sof_dev *sdev)
        if (sdev->pdata->ipc_type == SOF_IPC_TYPE_4) {
                struct sof_ipc4_fw_data *ipc4_data;
 
-               sdev->private = devm_kzalloc(sdev->dev, sizeof(*ipc4_data), GFP_KERNEL);
+               sdev->private = kzalloc(sizeof(*ipc4_data), GFP_KERNEL);
                if (!sdev->private)
                        return -ENOMEM;