alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
From: Jie Yang <yang.jie@intel.com>
To: alsa-devel@alsa-project.org
Cc: mengdong.lin@intel.com, broonie@kernel.org, liam.r.girdwood@intel.com
Subject: [PATCH 1/5] ASoC: Intel: Add persistent area alloc
Date: Mon, 14 Jul 2014 16:37:51 +0800	[thread overview]
Message-ID: <1405327075-27831-2-git-send-email-yang.jie@intel.com> (raw)
In-Reply-To: <1405327075-27831-1-git-send-email-yang.jie@intel.com>

Allocate persistent SRAM blocks for each firmware module.

Signed-off-by: Jie Yang <yang.jie@intel.com>
---
 sound/soc/intel/sst-dsp-priv.h    |  2 ++
 sound/soc/intel/sst-firmware.c    | 52 +++++++++++++++++++++++++++++++++++++++
 sound/soc/intel/sst-haswell-dsp.c |  7 +++++-
 3 files changed, 60 insertions(+), 1 deletion(-)

diff --git a/sound/soc/intel/sst-dsp-priv.h b/sound/soc/intel/sst-dsp-priv.h
index 3c0cbba..f96c1c5 100644
--- a/sound/soc/intel/sst-dsp-priv.h
+++ b/sound/soc/intel/sst-dsp-priv.h
@@ -301,6 +301,8 @@ struct sst_module *sst_module_get_from_id(struct sst_dsp *dsp, u32 id);
 struct sst_module *sst_mem_block_alloc_scratch(struct sst_dsp *dsp);
 void sst_mem_block_free_scratch(struct sst_dsp *dsp,
 	struct sst_module *scratch);
+int sst_module_alloc_persistent(struct sst_dsp *dsp, struct sst_module *module);
+void sst_module_free_persistent(struct sst_dsp *dsp, struct sst_module *module);
 int sst_block_module_remove(struct sst_module *module);
 
 /* Register the DSPs memory blocks - would be nice to read from ACPI */
diff --git a/sound/soc/intel/sst-firmware.c b/sound/soc/intel/sst-firmware.c
index 8349df5..8ab5ce8 100644
--- a/sound/soc/intel/sst-firmware.c
+++ b/sound/soc/intel/sst-firmware.c
@@ -845,6 +845,58 @@ void sst_mem_block_free_scratch(struct sst_dsp *dsp,
 }
 EXPORT_SYMBOL_GPL(sst_mem_block_free_scratch);
 
+/* allocate persistent buffer blocks for given module
+ creates new sst_module to represent persistent memory alocation of requestor.
+*/
+int sst_module_alloc_persistent(struct sst_dsp *dsp, struct sst_module *module)
+{
+	int ret = 0;
+	struct sst_module_data *persistent = &module->p;
+
+	mutex_lock(&dsp->mutex);
+
+	dev_dbg(dsp->dev, "persistent buffer required for mod id %d is %d bytes\n",
+		module->id, persistent->size);
+
+	ret = block_alloc(module, persistent);
+
+	if (ret < 0) {
+		dev_err(dsp->dev, "error: can't alloc persistent blocks for mod id %d\n",
+			module->id);
+		goto out;
+	}
+	dev_dbg(dsp->dev, "module %d persistent area allocated %dB at 0x%x\n",
+		module->id, persistent->size, persistent->offset);
+
+	/* prepare DSP blocks for persistent module usage */
+	ret = block_module_prepare(module);
+	if (ret < 0) {
+		dev_err(dsp->dev, "error: persistent module prepare failed\n");
+		goto out;
+	}
+
+out:
+	mutex_unlock(&dsp->mutex);
+	return ret;
+}
+EXPORT_SYMBOL_GPL(sst_module_alloc_persistent);
+
+void sst_module_free_persistent(struct sst_dsp *dsp, struct sst_module *persistent)
+{
+	struct sst_mem_block *block, *tmp;
+
+	dev_dbg(dsp->dev, "module %d persistent released", persistent->id);
+
+	mutex_lock(&dsp->mutex);
+
+	list_for_each_entry_safe(block, tmp, &persistent->block_list, module_list)
+		list_del(&block->module_list);
+
+	mutex_unlock(&dsp->mutex);
+
+}
+EXPORT_SYMBOL_GPL(sst_module_free_persistent);
+
 /* get a module from it's unique ID */
 struct sst_module *sst_module_get_from_id(struct sst_dsp *dsp, u32 id)
 {
diff --git a/sound/soc/intel/sst-haswell-dsp.c b/sound/soc/intel/sst-haswell-dsp.c
index 535f517..48ddff3 100644
--- a/sound/soc/intel/sst-haswell-dsp.c
+++ b/sound/soc/intel/sst-haswell-dsp.c
@@ -168,6 +168,11 @@ static int hsw_parse_module(struct sst_dsp *dsp, struct sst_fw *fw,
 
 		block = (void *)block + sizeof(*block) + block->size;
 	}
+
+	/*allocate persistent memory if needed*/
+	if (mod->p.size > 0)
+		return sst_module_alloc_persistent(dsp, mod);
+
 	return 0;
 }
 
@@ -207,7 +212,7 @@ static int hsw_parse_fw_image(struct sst_fw *sst_fw)
 		module = (void *)module + sizeof(*module) + module->mod_size;
 	}
 
-	/* allocate persistent/scratch mem regions */
+	/* allocate scratch mem regions */
 	scratch = sst_mem_block_alloc_scratch(dsp);
 	if (scratch == NULL)
 		return -ENOMEM;
-- 
1.8.3.2

  reply	other threads:[~2014-07-14  8:38 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-14  8:37 [PATCH 0/5] ASoC: Intel: Enable BDW/HSW SRAM power gating Jie Yang
2014-07-14  8:37 ` Jie Yang [this message]
2014-07-14  8:37 ` [PATCH 2/5] ASoC: Intel: Merge wild cat point ADSP DRAM regions Jie Yang
2014-07-14  8:37 ` [PATCH 3/5] ASoC: Intel: Use a table for ADSP SRAM shift Jie Yang
2014-07-14  8:37 ` [PATCH 4/5] ASoC: Intel: Add dummy read for SRAM block enable Jie Yang
2014-07-14  8:37 ` [PATCH 5/5] ASoC: Intel: Start with all memory banks disabled Jie Yang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1405327075-27831-2-git-send-email-yang.jie@intel.com \
    --to=yang.jie@intel.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=liam.r.girdwood@intel.com \
    --cc=mengdong.lin@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).