From mboxrd@z Thu Jan 1 00:00:00 1970 From: Cezary Rojewski Subject: [PATCH 06/35] ASoC: Intel: Skylake: Unhardcode dsp cores number Date: Thu, 22 Aug 2019 21:03:56 +0200 Message-ID: <20190822190425.23001-7-cezary.rojewski@intel.com> References: <20190822190425.23001-1-cezary.rojewski@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 69244F80112 for ; Thu, 22 Aug 2019 21:04:50 +0200 (CEST) In-Reply-To: <20190822190425.23001-1-cezary.rojewski@intel.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" To: alsa-devel@alsa-project.org Cc: lgirdwood@gmail.com, Cezary Rojewski , broonie@kernel.org, tiwai@suse.com, pierre-louis.bossart@linux.intel.com List-Id: alsa-devel@alsa-project.org While on the quest for unhardcoding the driver, use skl hw_cfg property instead of hardcoded value to retrieve number of supported dsp cores. Signed-off-by: Cezary Rojewski --- sound/soc/intel/skylake/skl-messages.c | 28 ------------------------- sound/soc/intel/skylake/skl-sst-dsp.c | 29 +++++++++++++++++++------- sound/soc/intel/skylake/skl-sst-dsp.h | 2 +- sound/soc/intel/skylake/skl-sst.c | 4 +++- sound/soc/intel/skylake/skl.h | 1 - 5 files changed, 26 insertions(+), 38 deletions(-) diff --git a/sound/soc/intel/skylake/skl-messages.c b/sound/soc/intel/skylake/skl-messages.c index cc949904717e..e4ac1ae777e0 100644 --- a/sound/soc/intel/skylake/skl-messages.c +++ b/sound/soc/intel/skylake/skl-messages.c @@ -170,56 +170,48 @@ static struct skl_dsp_loader_ops bxt_get_loader_ops(void) static const struct skl_dsp_ops dsp_ops[] = { { .id = 0x9d70, - .num_cores = 2, .loader_ops = skl_get_loader_ops, .init = skl_sst_dsp_init, .cleanup = skl_sst_dsp_cleanup }, { .id = 0x9d71, - .num_cores = 2, .loader_ops = skl_get_loader_ops, .init = skl_sst_dsp_init, .cleanup = skl_sst_dsp_cleanup }, { .id = 0x5a98, - .num_cores = 2, .loader_ops = bxt_get_loader_ops, .init = bxt_sst_dsp_init, .cleanup = bxt_sst_dsp_cleanup }, { .id = 0x3198, - .num_cores = 2, .loader_ops = bxt_get_loader_ops, .init = bxt_sst_dsp_init, .cleanup = bxt_sst_dsp_cleanup }, { .id = 0x9dc8, - .num_cores = 4, .loader_ops = bxt_get_loader_ops, .init = cnl_sst_dsp_init, .cleanup = cnl_sst_dsp_cleanup }, { .id = 0xa348, - .num_cores = 4, .loader_ops = bxt_get_loader_ops, .init = cnl_sst_dsp_init, .cleanup = cnl_sst_dsp_cleanup }, { .id = 0x02c8, - .num_cores = 4, .loader_ops = bxt_get_loader_ops, .init = cnl_sst_dsp_init, .cleanup = cnl_sst_dsp_cleanup }, { .id = 0x06c8, - .num_cores = 4, .loader_ops = bxt_get_loader_ops, .init = cnl_sst_dsp_init, .cleanup = cnl_sst_dsp_cleanup @@ -245,7 +237,6 @@ int skl_init_dsp(struct skl_dev *skl) struct skl_dsp_loader_ops loader_ops; int irq = bus->irq; const struct skl_dsp_ops *ops; - struct skl_dsp_cores *cores; int ret; /* enable ppcap interrupt */ @@ -274,29 +265,10 @@ int skl_init_dsp(struct skl_dev *skl) goto unmap_mmio; skl->dsp_ops = ops; - cores = &skl->cores; - cores->count = ops->num_cores; - - cores->state = kcalloc(cores->count, sizeof(*cores->state), GFP_KERNEL); - if (!cores->state) { - ret = -ENOMEM; - goto unmap_mmio; - } - - cores->usage_count = kcalloc(cores->count, sizeof(*cores->usage_count), - GFP_KERNEL); - if (!cores->usage_count) { - ret = -ENOMEM; - goto free_core_state; - } - dev_dbg(bus->dev, "dsp registration status=%d\n", ret); return 0; -free_core_state: - kfree(cores->state); - unmap_mmio: iounmap(mmio_base); diff --git a/sound/soc/intel/skylake/skl-sst-dsp.c b/sound/soc/intel/skylake/skl-sst-dsp.c index 0eecf26986f9..15acbe80711e 100644 --- a/sound/soc/intel/skylake/skl-sst-dsp.c +++ b/sound/soc/intel/skylake/skl-sst-dsp.c @@ -8,7 +8,7 @@ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include - +#include #include "../common/sst-dsp.h" #include "../common/sst-ipc.h" #include "../common/sst-dsp-priv.h" @@ -31,18 +31,33 @@ void skl_dsp_set_state_locked(struct sst_dsp *ctx, int state) * successful first boot. Hence core 0 will be running and other cores * will be reset */ -void skl_dsp_init_core_state(struct sst_dsp *ctx) +int skl_dsp_init_core_state(struct sst_dsp *ctx) { struct skl_dev *skl = ctx->thread_context; + struct skl_dsp_cores *cores = &skl->cores; int i; - skl->cores.state[SKL_DSP_CORE0_ID] = SKL_DSP_RUNNING; - skl->cores.usage_count[SKL_DSP_CORE0_ID] = 1; + cores->count = skl->hw_cfg.dsp_cores; + cores->state = kcalloc(cores->count, + sizeof(*cores->state), GFP_KERNEL); + if (!cores->state) + return -ENOMEM; + + cores->usage_count = kcalloc(cores->count, + sizeof(*cores->usage_count), GFP_KERNEL); + if (!cores->usage_count) { + kfree(cores->state); + return -ENOMEM; + } + + cores->state[SKL_DSP_CORE0_ID] = SKL_DSP_RUNNING; + cores->usage_count[SKL_DSP_CORE0_ID] = 1; - for (i = SKL_DSP_CORE0_ID + 1; i < skl->cores.count; i++) { - skl->cores.state[i] = SKL_DSP_RESET; - skl->cores.usage_count[i] = 0; + for (i = SKL_DSP_CORE0_ID + 1; i < cores->count; i++) { + cores->state[i] = SKL_DSP_RESET; + cores->usage_count[i] = 0; } + return 0; } EXPORT_SYMBOL_GPL(skl_dsp_init_core_state); diff --git a/sound/soc/intel/skylake/skl-sst-dsp.h b/sound/soc/intel/skylake/skl-sst-dsp.h index 06979652985c..2129627e6255 100644 --- a/sound/soc/intel/skylake/skl-sst-dsp.h +++ b/sound/soc/intel/skylake/skl-sst-dsp.h @@ -202,7 +202,7 @@ int skl_dsp_acquire_irq(struct sst_dsp *sst); bool is_skl_dsp_running(struct sst_dsp *ctx); unsigned int skl_dsp_get_enabled_cores(struct sst_dsp *ctx); -void skl_dsp_init_core_state(struct sst_dsp *ctx); +int skl_dsp_init_core_state(struct sst_dsp *ctx); int skl_dsp_enable_core(struct sst_dsp *ctx, unsigned int core_mask); int skl_dsp_disable_core(struct sst_dsp *ctx, unsigned int core_mask); int skl_dsp_core_power_up(struct sst_dsp *ctx, unsigned int core_mask); diff --git a/sound/soc/intel/skylake/skl-sst.c b/sound/soc/intel/skylake/skl-sst.c index 8a8ecb9a4fc6..163590682e1a 100644 --- a/sound/soc/intel/skylake/skl-sst.c +++ b/sound/soc/intel/skylake/skl-sst.c @@ -589,7 +589,9 @@ int skl_sst_init_fw(struct skl_dev *skl) goto exit; } - skl_dsp_init_core_state(sst); + ret = skl_dsp_init_core_state(sst); + if (ret < 0) + goto exit; library_load: if (skl->lib_count > 1) { diff --git a/sound/soc/intel/skylake/skl.h b/sound/soc/intel/skylake/skl.h index 1f86543fe954..71e69f52b7ab 100644 --- a/sound/soc/intel/skylake/skl.h +++ b/sound/soc/intel/skylake/skl.h @@ -155,7 +155,6 @@ struct skl_machine_pdata { struct skl_dsp_ops { int id; - unsigned int num_cores; struct skl_dsp_loader_ops (*loader_ops)(void); int (*init)(struct device *dev, void __iomem *mmio_base, int irq, const char *fw_name, -- 2.17.1