Skip to content

Commit

Permalink
ASoC: SOF: Introduce num_cores and ref count per core
Browse files Browse the repository at this point in the history
Add two fields num_cores and dsp_cores_ref_count to
struct snd_sof_dev. These will be used to maintain the
ref count for each core to determine when it should be
powered up or down.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
  • Loading branch information
ranj063 authored and plbossart committed Aug 3, 2021
1 parent e2781d7 commit b56c58b
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 0 deletions.
1 change: 1 addition & 0 deletions sound/soc/sof/imx/imx8.c
Expand Up @@ -222,6 +222,7 @@ static int imx8_probe(struct snd_sof_dev *sdev)
if (!priv)
return -ENOMEM;

sdev->num_cores = 1;
sdev->pdata->hw_pdata = priv;
priv->dev = sdev->dev;
priv->sdev = sdev;
Expand Down
1 change: 1 addition & 0 deletions sound/soc/sof/imx/imx8m.c
Expand Up @@ -142,6 +142,7 @@ static int imx8m_probe(struct snd_sof_dev *sdev)
if (!priv)
return -ENOMEM;

sdev->num_cores = 1;
sdev->pdata->hw_pdata = priv;
priv->dev = sdev->dev;
priv->sdev = sdev;
Expand Down
9 changes: 9 additions & 0 deletions sound/soc/sof/intel/bdw.c
Expand Up @@ -453,10 +453,19 @@ static int bdw_probe(struct snd_sof_dev *sdev)
const struct sof_dev_desc *desc = pdata->desc;
struct platform_device *pdev =
container_of(sdev->dev, struct platform_device, dev);
const struct sof_intel_dsp_desc *chip;
struct resource *mmio;
u32 base, size;
int ret;

chip = get_chip_info(sdev->pdata);
if (!chip) {
dev_err(sdev->dev, "error: no such device supported\n");
return -EIO;
}

sdev->num_cores = chip->cores_num;

/* LPE base */
mmio = platform_get_resource(pdev, IORESOURCE_MEM,
desc->resindex_lpe_base);
Expand Down
9 changes: 9 additions & 0 deletions sound/soc/sof/intel/byt.c
Expand Up @@ -113,10 +113,19 @@ static int byt_acpi_probe(struct snd_sof_dev *sdev)
const struct sof_dev_desc *desc = pdata->desc;
struct platform_device *pdev =
container_of(sdev->dev, struct platform_device, dev);
const struct sof_intel_dsp_desc *chip;
struct resource *mmio;
u32 base, size;
int ret;

chip = get_chip_info(sdev->pdata);
if (!chip) {
dev_err(sdev->dev, "error: no such device supported\n");
return -EIO;
}

sdev->num_cores = chip->cores_num;

/* DSP DMA can only access low 31 bits of host memory */
ret = dma_coerce_mask_and_coherent(sdev->dev, DMA_BIT_MASK(31));
if (ret < 0) {
Expand Down
2 changes: 2 additions & 0 deletions sound/soc/sof/intel/hda.c
Expand Up @@ -886,6 +886,8 @@ int hda_dsp_probe(struct snd_sof_dev *sdev)
goto err;
}

sdev->num_cores = chip->cores_num;

hdev = devm_kzalloc(sdev->dev, sizeof(*hdev), GFP_KERNEL);
if (!hdev)
return -ENOMEM;
Expand Down
9 changes: 9 additions & 0 deletions sound/soc/sof/intel/pci-tng.c
Expand Up @@ -56,9 +56,18 @@ static int tangier_pci_probe(struct snd_sof_dev *sdev)
struct snd_sof_pdata *pdata = sdev->pdata;
const struct sof_dev_desc *desc = pdata->desc;
struct pci_dev *pci = to_pci_dev(sdev->dev);
const struct sof_intel_dsp_desc *chip;
u32 base, size;
int ret;

chip = get_chip_info(sdev->pdata);
if (!chip) {
dev_err(sdev->dev, "error: no such device supported\n");
return -EIO;
}

sdev->num_cores = chip->cores_num;

/* DSP DMA can only access low 31 bits of host memory */
ret = dma_coerce_mask_and_coherent(&pci->dev, DMA_BIT_MASK(31));
if (ret < 0) {
Expand Down
15 changes: 15 additions & 0 deletions sound/soc/sof/sof-priv.h
Expand Up @@ -71,6 +71,9 @@ extern int sof_core_debug;
/* So far the primary core on all DSPs has ID 0 */
#define SOF_DSP_PRIMARY_CORE 0

/* max number of DSP cores */
#define SOF_MAX_DSP_NUM_CORES 8

/* DSP power state */
enum sof_dsp_power_states {
SOF_DSP_PM_D0,
Expand Down Expand Up @@ -468,6 +471,18 @@ struct snd_sof_dev {

bool msi_enabled;

/* DSP core context */
u32 num_cores;

/*
* ref count per core that will be modified during system suspend/resume and during pcm
* hw_params/hw_free. This doesn't need to be protected with a mutex because pcm
* hw_params/hw_free are already protected by the PCM mutex in the ALSA framework in
* sound/core/ when streams are active and during system suspend/resume, streams are
* already suspended.
*/
int dsp_core_ref_count[SOF_MAX_DSP_NUM_CORES];

void *private; /* core does not touch this */
};

Expand Down

0 comments on commit b56c58b

Please sign in to comment.