ASoC: SOF: hda: don't use the core op for power up/power down
authorRanjani Sridharan <ranjani.sridharan@linux.intel.com>
Fri, 19 Nov 2021 19:26:19 +0000 (21:26 +0200)
committerMark Brown <broonie@kernel.org>
Mon, 22 Nov 2021 15:40:22 +0000 (15:40 +0000)
The core_power_up/down() ops will be deprecated. Use the
HDA platform-specific functions for powering up/down
the cores during probe/suspend/remove. The enabled_cores_mask
and the core ref_count's are manually updated in each of
these functions.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Link: https://lore.kernel.org/r/20211119192621.4096077-9-kai.vehmanen@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/sof/intel/hda-dsp.c
sound/soc/sof/intel/hda-loader.c
sound/soc/sof/intel/hda.c

index b2f6dcd1c23d044d5ea6665b31ce82b138a84848..916a257ea96b8595577b44973884bdeb0dbc08c8 100644 (file)
@@ -614,7 +614,7 @@ static int hda_suspend(struct snd_sof_dev *sdev, bool runtime_suspend)
 #if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA)
        struct hdac_bus *bus = sof_to_bus(sdev);
 #endif
-       int ret;
+       int ret, j;
 
        hda_sdw_int_enable(sdev, false);
 
@@ -629,13 +629,17 @@ static int hda_suspend(struct snd_sof_dev *sdev, bool runtime_suspend)
 #endif
 
        /* power down DSP */
-       ret = snd_sof_dsp_core_power_down(sdev, chip->host_managed_cores_mask);
+       ret = hda_dsp_core_reset_power_down(sdev, chip->host_managed_cores_mask);
        if (ret < 0) {
                dev_err(sdev->dev,
                        "error: failed to power down core during suspend\n");
                return ret;
        }
 
+       /* reset ref counts for all cores */
+       for (j = 0; j < chip->cores_num; j++)
+               sdev->dsp_core_ref_count[j] = 0;
+
        /* disable ppcap interrupt */
        hda_dsp_ctrl_ppcap_enable(sdev, false);
        hda_dsp_ctrl_ppcap_int_enable(sdev, false);
index abad6d0ceb8379db1967267edf54bb3a59422e1b..40201e5ac201ed824f1fac7a9196327dbcbdc445 100644 (file)
@@ -88,12 +88,13 @@ static int cl_dsp_init(struct snd_sof_dev *sdev, int stream_tag)
        struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata;
        const struct sof_intel_dsp_desc *chip = hda->desc;
        unsigned int status;
-       u32 flags;
+       unsigned long mask;
+       u32 flags, j;
        int ret;
        int i;
 
        /* step 1: power up corex */
-       ret = snd_sof_dsp_core_power_up(sdev, chip->host_managed_cores_mask);
+       ret = hda_dsp_enable_core(sdev, chip->host_managed_cores_mask);
        if (ret < 0) {
                if (hda->boot_iteration == HDA_FW_BOOT_ATTEMPTS)
                        dev_err(sdev->dev, "error: dsp core 0/1 power up failed\n");
@@ -148,8 +149,8 @@ static int cl_dsp_init(struct snd_sof_dev *sdev, int stream_tag)
                                       chip->ipc_ack_mask);
 
        /* step 5: power down cores that are no longer needed */
-       ret = snd_sof_dsp_core_power_down(sdev, chip->host_managed_cores_mask &
-                                         ~(chip->init_core_mask));
+       ret = hda_dsp_core_reset_power_down(sdev, chip->host_managed_cores_mask &
+                                          ~(chip->init_core_mask));
        if (ret < 0) {
                if (hda->boot_iteration == HDA_FW_BOOT_ATTEMPTS)
                        dev_err(sdev->dev,
@@ -168,8 +169,14 @@ static int cl_dsp_init(struct snd_sof_dev *sdev, int stream_tag)
                                        HDA_DSP_REG_POLL_INTERVAL_US,
                                        chip->rom_init_timeout *
                                        USEC_PER_MSEC);
-       if (!ret)
+       if (!ret) {
+               /* set enabled cores mask and increment ref count for cores in init_core_mask */
+               sdev->enabled_cores_mask |= chip->init_core_mask;
+               mask = sdev->enabled_cores_mask;
+               for_each_set_bit(j, &mask, SOF_MAX_DSP_NUM_CORES)
+                       sdev->dsp_core_ref_count[j]++;
                return 0;
+       }
 
        if (hda->boot_iteration == HDA_FW_BOOT_ATTEMPTS)
                dev_err(sdev->dev,
@@ -184,7 +191,7 @@ err:
                flags &= ~SOF_DBG_DUMP_OPTIONAL;
 
        snd_sof_dsp_dbg_dump(sdev, flags);
-       snd_sof_dsp_core_power_down(sdev, chip->host_managed_cores_mask);
+       hda_dsp_core_reset_power_down(sdev, chip->host_managed_cores_mask);
 
        return ret;
 }
@@ -501,12 +508,15 @@ int hda_dsp_post_fw_run_icl(struct snd_sof_dev *sdev)
         * the host whereas on TGL it is handled by the firmware.
         */
        if (!hda->clk_config_lpro) {
-               ret = snd_sof_dsp_core_power_up(sdev, BIT(3));
+               ret = hda_dsp_enable_core(sdev, BIT(3));
                if (ret < 0) {
                        dev_err(sdev->dev, "error: dsp core power up failed on core 3\n");
                        return ret;
                }
 
+               sdev->enabled_cores_mask |= BIT(3);
+               sdev->dsp_core_ref_count[3]++;
+
                snd_sof_dsp_stall(sdev, BIT(3));
        }
 
index 3c69e8fcd43b45d12e2782edd02d223ec8206f9d..1e1e9659ea86bd65ce9d54412ac4df2841e2db6f 100644 (file)
@@ -1034,9 +1034,9 @@ err:
 int hda_dsp_remove(struct snd_sof_dev *sdev)
 {
        struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata;
+       const struct sof_intel_dsp_desc *chip = hda->desc;
        struct hdac_bus *bus = sof_to_bus(sdev);
        struct pci_dev *pci = to_pci_dev(sdev->dev);
-       const struct sof_intel_dsp_desc *chip = hda->desc;
 
        /* cancel any attempt for DSP D0I3 */
        cancel_delayed_work_sync(&hda->d0i3_work);
@@ -1061,7 +1061,7 @@ int hda_dsp_remove(struct snd_sof_dev *sdev)
 
        /* disable cores */
        if (chip)
-               snd_sof_dsp_core_power_down(sdev, chip->host_managed_cores_mask);
+               hda_dsp_core_reset_power_down(sdev, chip->host_managed_cores_mask);
 
        /* disable DSP */
        snd_sof_dsp_update_bits(sdev, HDA_DSP_PP_BAR, SOF_HDA_REG_PP_PPCTL,