Sound-open-firmware
Threads by month
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
March 2018
- 20 participants
- 144 discussions
[Sound-open-firmware] [PATCH] memory: allocator: Remove RFLAGS_NONE/USED and use caps
by Liam Girdwood 01 Mar '18
by Liam Girdwood 01 Mar '18
01 Mar '18
Dont use RFLAGS_NONE, but use the new memory capabilities flags instead.
Signed-off-by: Liam Girdwood <liam.r.girdwood(a)linux.intel.com>
---
src/audio/buffer.c | 4 ++--
src/audio/component.c | 2 +-
src/audio/dai.c | 10 ++++++----
src/audio/eq_fir.c | 8 ++++----
src/audio/eq_iir.c | 8 ++++----
src/audio/host.c | 14 +++++++-------
src/audio/mixer.c | 4 ++--
src/audio/pipeline.c | 5 +++--
src/audio/src.c | 7 ++++---
src/audio/tone.c | 4 ++--
src/audio/volume.c | 4 ++--
src/drivers/apl-ssp.c | 2 +-
src/drivers/dw-dma.c | 10 ++++++----
src/drivers/hda-dma.c | 2 +-
src/drivers/ssp.c | 2 +-
src/include/reef/alloc.h | 8 +-------
src/include/uapi/ipc.h | 2 +-
src/ipc/apl-ipc.c | 5 +++--
src/ipc/byt-ipc.c | 5 +++--
src/ipc/cnl-ipc.c | 5 +++--
src/ipc/hsw-ipc.c | 5 +++--
src/ipc/ipc.c | 13 ++++++++-----
src/ipc/pmc-ipc.c | 3 ++-
src/lib/agent.c | 2 +-
src/lib/alloc.c | 12 ++++++------
src/lib/dma-trace.c | 7 ++++---
src/lib/interrupt.c | 3 ++-
src/lib/schedule.c | 2 +-
src/lib/work.c | 2 +-
src/platform/apollolake/clk.c | 2 +-
src/platform/baytrail/clk.c | 2 +-
src/platform/cannonlake/clk.c | 3 ++-
src/platform/haswell/clk.c | 2 +-
33 files changed, 90 insertions(+), 79 deletions(-)
diff --git a/src/audio/buffer.c b/src/audio/buffer.c
index 6ae7d92..360ad6b 100644
--- a/src/audio/buffer.c
+++ b/src/audio/buffer.c
@@ -60,13 +60,13 @@ struct comp_buffer *buffer_new(struct sof_ipc_buffer *desc)
}
/* allocate new buffer */
- buffer = rzalloc(RZONE_RUNTIME, RFLAGS_NONE, sizeof(*buffer));
+ buffer = rzalloc(RZONE_RUNTIME, SOF_MEM_CAPS_RAM, sizeof(*buffer));
if (buffer == NULL) {
trace_buffer_error("ebN");
return NULL;
}
- buffer->addr = rballoc(RZONE_RUNTIME, RFLAGS_NONE, desc->size);
+ buffer->addr = rballoc(RZONE_RUNTIME, desc->caps, desc->size);
if (buffer->addr == NULL) {
rfree(buffer);
trace_buffer_error("ebm");
diff --git a/src/audio/component.c b/src/audio/component.c
index 54a7da8..f27f350 100644
--- a/src/audio/component.c
+++ b/src/audio/component.c
@@ -189,7 +189,7 @@ int comp_set_state(struct comp_dev *dev, int cmd)
void sys_comp_init(void)
{
- cd = rzalloc(RZONE_SYS, RFLAGS_NONE, sizeof(*cd));
+ cd = rzalloc(RZONE_SYS, SOF_MEM_CAPS_RAM, sizeof(*cd));
list_init(&cd->list);
spinlock_init(&cd->lock);
}
diff --git a/src/audio/dai.c b/src/audio/dai.c
index 713ab4e..061af5e 100644
--- a/src/audio/dai.c
+++ b/src/audio/dai.c
@@ -184,7 +184,7 @@ static struct comp_dev *dai_new(struct sof_ipc_comp *comp)
trace_dai("new");
- dev = rzalloc(RZONE_RUNTIME, RFLAGS_NONE,
+ dev = rzalloc(RZONE_RUNTIME, SOF_MEM_CAPS_RAM,
COMP_SIZE(struct sof_ipc_comp_dai));
if (dev == NULL)
return NULL;
@@ -192,7 +192,7 @@ static struct comp_dev *dai_new(struct sof_ipc_comp *comp)
dai = (struct sof_ipc_comp_dai *)&dev->comp;
memcpy(dai, ipc_dai, sizeof(struct sof_ipc_comp_dai));
- dd = rzalloc(RZONE_RUNTIME, RFLAGS_NONE, sizeof(*dd));
+ dd = rzalloc(RZONE_RUNTIME, SOF_MEM_CAPS_RAM, sizeof(*dd));
if (dd == NULL) {
rfree(dev);
return NULL;
@@ -289,7 +289,8 @@ static int dai_playback_params(struct comp_dev *dev)
/* set up cyclic list of DMA elems */
for (i = 0; i < source_config->periods_sink; i++) {
- elem = rzalloc(RZONE_RUNTIME, RFLAGS_NONE, sizeof(*elem));
+ elem = rzalloc(RZONE_RUNTIME, SOF_MEM_CAPS_RAM,
+ sizeof(*elem));
if (elem == NULL)
goto err_unwind;
@@ -356,7 +357,8 @@ static int dai_capture_params(struct comp_dev *dev)
/* set up cyclic list of DMA elems */
for (i = 0; i < sink_config->periods_source; i++) {
- elem = rzalloc(RZONE_RUNTIME, RFLAGS_NONE, sizeof(*elem));
+ elem = rzalloc(RZONE_RUNTIME, SOF_MEM_CAPS_RAM,
+ sizeof(*elem));
if (elem == NULL)
goto err_unwind;
diff --git a/src/audio/eq_fir.c b/src/audio/eq_fir.c
index a723cf0..b6ec58f 100644
--- a/src/audio/eq_fir.c
+++ b/src/audio/eq_fir.c
@@ -205,7 +205,7 @@ static int eq_fir_setup(struct fir_state_32x16 fir[],
}
/* Allocate all FIR channels data in a big chunk and clear it */
- fir_data = rballoc(RZONE_SYS, RFLAGS_NONE,
+ fir_data = rballoc(RZONE_SYS, SOF_MEM_CAPS_RAM,
length_sum * sizeof(int32_t));
if (fir_data == NULL)
return -ENOMEM;
@@ -253,7 +253,7 @@ static struct comp_dev *eq_fir_new(struct sof_ipc_comp *comp)
trace_eq("new");
- dev = rzalloc(RZONE_RUNTIME, RFLAGS_NONE,
+ dev = rzalloc(RZONE_RUNTIME, SOF_MEM_CAPS_RAM,
COMP_SIZE(struct sof_ipc_comp_eq_fir));
if (dev == NULL)
return NULL;
@@ -261,7 +261,7 @@ static struct comp_dev *eq_fir_new(struct sof_ipc_comp *comp)
eq_fir = (struct sof_ipc_comp_eq_fir *) &dev->comp;
memcpy(eq_fir, ipc_eq_fir, sizeof(struct sof_ipc_comp_eq_fir));
- cd = rzalloc(RZONE_RUNTIME, RFLAGS_NONE, sizeof(*cd));
+ cd = rzalloc(RZONE_RUNTIME, SOF_MEM_CAPS_RAM, sizeof(*cd));
if (cd == NULL) {
rfree(dev);
return NULL;
@@ -401,7 +401,7 @@ static int fir_cmd_set_data(struct comp_dev *dev, struct sof_ipc_ctrl_data *cdat
if ((bs > SOF_EQ_FIR_MAX_SIZE) || (bs < 1))
return -EINVAL;
- cd->config = rzalloc(RZONE_RUNTIME, RFLAGS_NONE, bs);
+ cd->config = rzalloc(RZONE_RUNTIME, SOF_MEM_CAPS_RAM, bs);
if (cd->config == NULL)
return -EINVAL;
diff --git a/src/audio/eq_iir.c b/src/audio/eq_iir.c
index eb464af..2a1dd59 100644
--- a/src/audio/eq_iir.c
+++ b/src/audio/eq_iir.c
@@ -211,7 +211,7 @@ static int eq_iir_setup(struct iir_state_df2t iir[],
}
/* Allocate all IIR channels data in a big chunk and clear it */
- iir_delay = rzalloc(RZONE_RUNTIME, RFLAGS_NONE, size_sum);
+ iir_delay = rzalloc(RZONE_RUNTIME, SOF_MEM_CAPS_RAM, size_sum);
if (iir_delay == NULL)
return -ENOMEM;
@@ -256,14 +256,14 @@ static struct comp_dev *eq_iir_new(struct sof_ipc_comp *comp)
trace_eq_iir("new");
- dev = rzalloc(RZONE_RUNTIME, RFLAGS_NONE,
+ dev = rzalloc(RZONE_RUNTIME, SOF_MEM_CAPS_RAM,
COMP_SIZE(struct sof_ipc_comp_eq_iir));
if (dev == NULL)
return NULL;
memcpy(&dev->comp, comp, sizeof(struct sof_ipc_comp_eq_iir));
- cd = rzalloc(RZONE_RUNTIME, RFLAGS_NONE, sizeof(*cd));
+ cd = rzalloc(RZONE_RUNTIME, SOF_MEM_CAPS_RAM, sizeof(*cd));
if (cd == NULL) {
rfree(dev);
return NULL;
@@ -397,7 +397,7 @@ static int iir_cmd_set_data(struct comp_dev *dev, struct sof_ipc_ctrl_data *cdat
return -EINVAL;
/* Allocate and make a copy of the blob and setup IIR */
- cd->config = rzalloc(RZONE_RUNTIME, RFLAGS_NONE, bs);
+ cd->config = rzalloc(RZONE_RUNTIME, SOF_MEM_CAPS_RAM, bs);
if (cd->config == NULL)
return -EINVAL;
diff --git a/src/audio/host.c b/src/audio/host.c
index 6d60902..a76e340 100644
--- a/src/audio/host.c
+++ b/src/audio/host.c
@@ -244,7 +244,7 @@ static int create_local_elems(struct comp_dev *dev)
/* TODO: simplify elem storage by using an array */
for (i = 0; i < hd->period_count; i++) {
/* allocate new host DMA elem and add it to our list */
- e = rzalloc(RZONE_RUNTIME, RFLAGS_NONE, sizeof(*e));
+ e = rzalloc(RZONE_RUNTIME, SOF_MEM_CAPS_RAM, sizeof(*e));
if (e == NULL)
goto unwind;
@@ -396,7 +396,7 @@ static int create_local_elems(struct comp_dev *dev)
/* TODO: simplify elem storage by using an array */
for (i = 0; i < hd->period_count; i++) {
/* allocate new host DMA elem and add it to our list */
- e = rzalloc(RZONE_RUNTIME, RFLAGS_NONE, sizeof(*e));
+ e = rzalloc(RZONE_RUNTIME, SOF_MEM_CAPS_RAM, sizeof(*e));
if (e == NULL)
goto unwind;
@@ -422,7 +422,7 @@ static int create_local_elems(struct comp_dev *dev)
continue;
/* allocate new host DMA elem and add it to our list */
- ec = rzalloc(RZONE_RUNTIME, RFLAGS_NONE, sizeof(*ec));
+ ec = rzalloc(RZONE_RUNTIME, SOF_MEM_CAPS_RAM, sizeof(*ec));
if (!ec)
goto unwind;
@@ -500,7 +500,7 @@ static struct comp_dev *host_new(struct sof_ipc_comp *comp)
trace_host("new");
- dev = rzalloc(RZONE_RUNTIME, RFLAGS_NONE,
+ dev = rzalloc(RZONE_RUNTIME, SOF_MEM_CAPS_RAM,
COMP_SIZE(struct sof_ipc_comp_host));
if (dev == NULL)
return NULL;
@@ -508,13 +508,13 @@ static struct comp_dev *host_new(struct sof_ipc_comp *comp)
host = (struct sof_ipc_comp_host *)&dev->comp;
memcpy(host, ipc_host, sizeof(struct sof_ipc_comp_host));
- hd = rzalloc(RZONE_RUNTIME, RFLAGS_NONE, sizeof(*hd));
+ hd = rzalloc(RZONE_RUNTIME, SOF_MEM_CAPS_RAM, sizeof(*hd));
if (hd == NULL) {
rfree(dev);
return NULL;
}
- elem = rzalloc(RZONE_RUNTIME, RFLAGS_NONE, sizeof(*elem));
+ elem = rzalloc(RZONE_RUNTIME, SOF_MEM_CAPS_RAM, sizeof(*elem));
if (elem == NULL) {
rfree(dev);
rfree(hd);
@@ -776,7 +776,7 @@ static int host_buffer(struct comp_dev *dev, struct dma_sg_elem *elem,
struct dma_sg_elem *e;
/* allocate new host DMA elem and add it to our list */
- e = rzalloc(RZONE_RUNTIME, RFLAGS_NONE, sizeof(*e));
+ e = rzalloc(RZONE_RUNTIME, SOF_MEM_CAPS_RAM, sizeof(*e));
if (e == NULL)
return -ENOMEM;
diff --git a/src/audio/mixer.c b/src/audio/mixer.c
index e3611d4..abc8881 100644
--- a/src/audio/mixer.c
+++ b/src/audio/mixer.c
@@ -87,7 +87,7 @@ static struct comp_dev *mixer_new(struct sof_ipc_comp *comp)
struct mixer_data *md;
trace_mixer("new");
- dev = rzalloc(RZONE_RUNTIME, RFLAGS_NONE,
+ dev = rzalloc(RZONE_RUNTIME, SOF_MEM_CAPS_RAM,
COMP_SIZE(struct sof_ipc_comp_mixer));
if (dev == NULL)
return NULL;
@@ -95,7 +95,7 @@ static struct comp_dev *mixer_new(struct sof_ipc_comp *comp)
mixer = (struct sof_ipc_comp_mixer *)&dev->comp;
memcpy(mixer, ipc_mixer, sizeof(struct sof_ipc_comp_mixer));
- md = rzalloc(RZONE_RUNTIME, RFLAGS_NONE, sizeof(*md));
+ md = rzalloc(RZONE_RUNTIME, SOF_MEM_CAPS_RAM, sizeof(*md));
if (md == NULL) {
rfree(dev);
return NULL;
diff --git a/src/audio/pipeline.c b/src/audio/pipeline.c
index 94d91b5..728b64d 100644
--- a/src/audio/pipeline.c
+++ b/src/audio/pipeline.c
@@ -240,7 +240,7 @@ struct pipeline *pipeline_new(struct sof_ipc_pipe_new *pipe_desc,
trace_pipe("new");
/* allocate new pipeline */
- p = rzalloc(RZONE_RUNTIME, RFLAGS_NONE, sizeof(*p));
+ p = rzalloc(RZONE_RUNTIME, SOF_MEM_CAPS_RAM, sizeof(*p));
if (p == NULL) {
trace_pipe_error("ePN");
return NULL;
@@ -1146,7 +1146,8 @@ int pipeline_init(void)
{
trace_pipe("PIn");
- pipe_data = rzalloc(RZONE_RUNTIME, RFLAGS_NONE, sizeof(*pipe_data));
+ pipe_data = rzalloc(RZONE_RUNTIME, SOF_MEM_CAPS_RAM,
+ sizeof(*pipe_data));
spinlock_init(&pipe_data->lock);
return 0;
diff --git a/src/audio/src.c b/src/audio/src.c
index d494d96..c7ac649 100644
--- a/src/audio/src.c
+++ b/src/audio/src.c
@@ -274,7 +274,7 @@ static struct comp_dev *src_new(struct sof_ipc_comp *comp)
return NULL;
}
- dev = rzalloc(RZONE_RUNTIME, RFLAGS_NONE,
+ dev = rzalloc(RZONE_RUNTIME, SOF_MEM_CAPS_RAM,
COMP_SIZE(struct sof_ipc_comp_src));
if (dev == NULL)
return NULL;
@@ -282,7 +282,7 @@ static struct comp_dev *src_new(struct sof_ipc_comp *comp)
src = (struct sof_ipc_comp_src *) &dev->comp;
memcpy(src, ipc_src, sizeof(struct sof_ipc_comp_src));
- cd = rzalloc(RZONE_RUNTIME, RFLAGS_NONE, sizeof(*cd));
+ cd = rzalloc(RZONE_RUNTIME, SOF_MEM_CAPS_RAM, sizeof(*cd));
if (cd == NULL) {
rfree(dev);
return NULL;
@@ -386,7 +386,8 @@ static int src_params(struct comp_dev *dev)
if (cd->delay_lines != NULL)
rfree(cd->delay_lines);
- cd->delay_lines = rballoc(RZONE_RUNTIME, RFLAGS_NONE, delay_lines_size);
+ cd->delay_lines = rballoc(RZONE_RUNTIME, SOF_MEM_CAPS_RAM,
+ delay_lines_size);
if (cd->delay_lines == NULL) {
trace_src_error("sr3");
trace_value(delay_lines_size);
diff --git a/src/audio/tone.c b/src/audio/tone.c
index 581f87e..5308af0 100644
--- a/src/audio/tone.c
+++ b/src/audio/tone.c
@@ -405,7 +405,7 @@ static struct comp_dev *tone_new(struct sof_ipc_comp *comp)
trace_tone("new");
- dev = rzalloc(RZONE_RUNTIME, RFLAGS_NONE,
+ dev = rzalloc(RZONE_RUNTIME, SOF_MEM_CAPS_RAM,
COMP_SIZE(struct sof_ipc_comp_tone));
if (dev == NULL)
return NULL;
@@ -413,7 +413,7 @@ static struct comp_dev *tone_new(struct sof_ipc_comp *comp)
tone = (struct sof_ipc_comp_tone *) &dev->comp;
memcpy(tone, ipc_tone, sizeof(struct sof_ipc_comp_tone));
- cd = rzalloc(RZONE_RUNTIME, RFLAGS_NONE, sizeof(*cd));
+ cd = rzalloc(RZONE_RUNTIME, SOF_MEM_CAPS_RAM, sizeof(*cd));
if (cd == NULL) {
rfree(dev);
return NULL;
diff --git a/src/audio/volume.c b/src/audio/volume.c
index 8e54607..ee9b361 100644
--- a/src/audio/volume.c
+++ b/src/audio/volume.c
@@ -364,7 +364,7 @@ static struct comp_dev *volume_new(struct sof_ipc_comp *comp)
trace_volume("new");
- dev = rzalloc(RZONE_RUNTIME, RFLAGS_NONE,
+ dev = rzalloc(RZONE_RUNTIME, SOF_MEM_CAPS_RAM,
COMP_SIZE(struct sof_ipc_comp_volume));
if (dev == NULL)
return NULL;
@@ -372,7 +372,7 @@ static struct comp_dev *volume_new(struct sof_ipc_comp *comp)
vol = (struct sof_ipc_comp_volume *)&dev->comp;
memcpy(vol, ipc_vol, sizeof(struct sof_ipc_comp_volume));
- cd = rzalloc(RZONE_RUNTIME, RFLAGS_NONE, sizeof(*cd));
+ cd = rzalloc(RZONE_RUNTIME, SOF_MEM_CAPS_RAM, sizeof(*cd));
if (cd == NULL) {
rfree(dev);
return NULL;
diff --git a/src/drivers/apl-ssp.c b/src/drivers/apl-ssp.c
index f0faba9..a726f3c 100644
--- a/src/drivers/apl-ssp.c
+++ b/src/drivers/apl-ssp.c
@@ -523,7 +523,7 @@ static int ssp_probe(struct dai *dai)
struct ssp_pdata *ssp;
/* allocate private data */
- ssp = rzalloc(RZONE_SYS, RFLAGS_NONE, sizeof(*ssp));
+ ssp = rzalloc(RZONE_SYS, SOF_MEM_CAPS_RAM, sizeof(*ssp));
dai_set_drvdata(dai, ssp);
spinlock_init(&ssp->lock);
diff --git a/src/drivers/dw-dma.c b/src/drivers/dw-dma.c
index be19e12..b47da0e 100644
--- a/src/drivers/dw-dma.c
+++ b/src/drivers/dw-dma.c
@@ -552,7 +552,8 @@ static int dw_dma_set_config(struct dma *dma, int channel,
/* allocate descriptors for channel */
if (p->chan[channel].lli)
rfree(p->chan[channel].lli);
- p->chan[channel].lli = rzalloc(RZONE_RUNTIME, RFLAGS_NONE,
+ p->chan[channel].lli = rzalloc(RZONE_RUNTIME,
+ SOF_MEM_CAPS_RAM | SOF_MEM_CAPS_DMA,
sizeof(struct dw_lli2) * p->chan[channel].desc_count);
if (p->chan[channel].lli == NULL) {
trace_dma_error("eD1");
@@ -997,7 +998,7 @@ static int dw_dma_probe(struct dma *dma)
int i;
/* allocate private data */
- dw_pdata = rzalloc(RZONE_SYS, RFLAGS_NONE, sizeof(*dw_pdata));
+ dw_pdata = rzalloc(RZONE_SYS, SOF_MEM_CAPS_RAM, sizeof(*dw_pdata));
dma_set_drvdata(dma, dw_pdata);
spinlock_init(&dma->lock);
@@ -1010,7 +1011,7 @@ static int dw_dma_probe(struct dma *dma)
dw_pdata->chan[i].channel = i;
dw_pdata->chan[i].status = COMP_STATE_INIT;
- dma_int[i] = rzalloc(RZONE_SYS, RFLAGS_NONE,
+ dma_int[i] = rzalloc(RZONE_SYS, SOF_MEM_CAPS_RAM,
sizeof(struct dma_int));
dma_int[i]->dma = dma;
@@ -1150,7 +1151,8 @@ static int dw_dma_probe(struct dma *dma)
#endif
{
/* allocate private data */
- dw_pdata = rzalloc(RZONE_SYS, RFLAGS_NONE, sizeof(*dw_pdata));
+ dw_pdata = rzalloc(RZONE_SYS, SOF_MEM_CAPS_RAM,
+ sizeof(*dw_pdata));
dma_set_drvdata(dmac, dw_pdata);
spinlock_init(&dmac->lock);
diff --git a/src/drivers/hda-dma.c b/src/drivers/hda-dma.c
index 6526b74..87221a8 100644
--- a/src/drivers/hda-dma.c
+++ b/src/drivers/hda-dma.c
@@ -391,7 +391,7 @@ static int hda_dma_probe(struct dma *dma)
int i;
/* allocate private data */
- hda_pdata = rzalloc(RZONE_SYS, RFLAGS_NONE, sizeof(*hda_pdata));
+ hda_pdata = rzalloc(RZONE_SYS, SOF_MEM_CAPS_RAM, sizeof(*hda_pdata));
dma_set_drvdata(dma, hda_pdata);
spinlock_init(&dma->lock);
diff --git a/src/drivers/ssp.c b/src/drivers/ssp.c
index 0ed570c..4b195ec 100644
--- a/src/drivers/ssp.c
+++ b/src/drivers/ssp.c
@@ -586,7 +586,7 @@ static int ssp_probe(struct dai *dai)
struct ssp_pdata *ssp;
/* allocate private data */
- ssp = rzalloc(RZONE_SYS, RFLAGS_NONE, sizeof(*ssp));
+ ssp = rzalloc(RZONE_SYS, SOF_MEM_CAPS_RAM, sizeof(*ssp));
dai_set_drvdata(dai, ssp);
spinlock_init(&ssp->lock);
diff --git a/src/include/reef/alloc.h b/src/include/reef/alloc.h
index 6b61b04..a2b0c9b 100644
--- a/src/include/reef/alloc.h
+++ b/src/include/reef/alloc.h
@@ -57,12 +57,6 @@ struct reef;
#define RZONE_RUNTIME 1
#define RZONE_BUFFER 2
-/*
- * Heap allocation memory flags.
- */
-#define RFLAGS_NONE 0
-#define RFLAGS_USED 1
-
struct mm_info {
uint32_t used;
uint32_t free;
@@ -70,7 +64,7 @@ struct mm_info {
struct block_hdr {
uint16_t size; /* size in blocks for continuous allocation */
- uint16_t flags; /* usage flags for page */
+ uint16_t used; /* usage flags for page */
} __attribute__ ((packed));
struct block_map {
diff --git a/src/include/uapi/ipc.h b/src/include/uapi/ipc.h
index dec8abd..0c34013 100644
--- a/src/include/uapi/ipc.h
+++ b/src/include/uapi/ipc.h
@@ -572,7 +572,7 @@ struct sof_ipc_comp {
struct sof_ipc_buffer {
struct sof_ipc_comp comp;
uint32_t size; /* buffer size in bytes */
- uint32_t type; /* SOF_MEM_CAPS_ */
+ uint32_t caps; /* SOF_MEM_CAPS_ */
} __attribute__((packed));
diff --git a/src/ipc/apl-ipc.c b/src/ipc/apl-ipc.c
index 167423b..4b8ee6b 100644
--- a/src/ipc/apl-ipc.c
+++ b/src/ipc/apl-ipc.c
@@ -182,7 +182,8 @@ int platform_ipc_init(struct ipc *ipc)
_ipc = ipc;
/* init ipc data */
- iipc = rzalloc(RZONE_SYS, RFLAGS_NONE, sizeof(struct intel_ipc_data));
+ iipc = rzalloc(RZONE_SYS, SOF_MEM_CAPS_RAM,
+ sizeof(struct intel_ipc_data));
ipc_set_drvdata(_ipc, iipc);
_ipc->dsp_msg = NULL;
list_init(&ipc->empty_list);
@@ -192,7 +193,7 @@ int platform_ipc_init(struct ipc *ipc)
list_item_prepend(&ipc->message[i].list, &ipc->empty_list);
/* allocate page table buffer */
- iipc->page_table = rballoc(RZONE_SYS, RFLAGS_NONE,
+ iipc->page_table = rballoc(RZONE_SYS, SOF_MEM_CAPS_RAM,
HOST_PAGE_SIZE);
if (iipc->page_table)
bzero(iipc->page_table, HOST_PAGE_SIZE);
diff --git a/src/ipc/byt-ipc.c b/src/ipc/byt-ipc.c
index 91d8f1b..3ab6319 100644
--- a/src/ipc/byt-ipc.c
+++ b/src/ipc/byt-ipc.c
@@ -208,7 +208,8 @@ int platform_ipc_init(struct ipc *ipc)
_ipc = ipc;
/* init ipc data */
- iipc = rzalloc(RZONE_SYS, RFLAGS_NONE, sizeof(struct intel_ipc_data));
+ iipc = rzalloc(RZONE_SYS, SOF_MEM_CAPS_RAM,
+ sizeof(struct intel_ipc_data));
ipc_set_drvdata(_ipc, iipc);
_ipc->dsp_msg = NULL;
list_init(&ipc->empty_list);
@@ -219,7 +220,7 @@ int platform_ipc_init(struct ipc *ipc)
list_item_prepend(&ipc->message[i].list, &ipc->empty_list);
/* allocate page table buffer */
- iipc->page_table = rzalloc(RZONE_SYS, RFLAGS_NONE,
+ iipc->page_table = rzalloc(RZONE_SYS, SOF_MEM_CAPS_RAM,
PLATFORM_PAGE_TABLE_SIZE);
if (iipc->page_table)
bzero(iipc->page_table, PLATFORM_PAGE_TABLE_SIZE);
diff --git a/src/ipc/cnl-ipc.c b/src/ipc/cnl-ipc.c
index 0fcc5be..15687fc 100644
--- a/src/ipc/cnl-ipc.c
+++ b/src/ipc/cnl-ipc.c
@@ -182,7 +182,8 @@ int platform_ipc_init(struct ipc *ipc)
_ipc = ipc;
/* init ipc data */
- iipc = rzalloc(RZONE_SYS, RFLAGS_NONE, sizeof(struct intel_ipc_data));
+ iipc = rzalloc(RZONE_SYS, SOF_MEM_CAPS_RAM,
+ sizeof(struct intel_ipc_data));
ipc_set_drvdata(_ipc, iipc);
_ipc->dsp_msg = NULL;
list_init(&ipc->empty_list);
@@ -192,7 +193,7 @@ int platform_ipc_init(struct ipc *ipc)
list_item_prepend(&ipc->message[i].list, &ipc->empty_list);
/* allocate page table buffer */
- iipc->page_table = rballoc(RZONE_SYS, RFLAGS_NONE,
+ iipc->page_table = rballoc(RZONE_SYS, SOF_MEM_CAPS_RAM,
HOST_PAGE_SIZE);
if (iipc->page_table)
bzero(iipc->page_table, HOST_PAGE_SIZE);
diff --git a/src/ipc/hsw-ipc.c b/src/ipc/hsw-ipc.c
index 5f350c1..5bfdf93 100644
--- a/src/ipc/hsw-ipc.c
+++ b/src/ipc/hsw-ipc.c
@@ -208,7 +208,8 @@ int platform_ipc_init(struct ipc *ipc)
_ipc = ipc;
/* init ipc data */
- iipc = rzalloc(RZONE_SYS, RFLAGS_NONE, sizeof(struct intel_ipc_data));
+ iipc = rzalloc(RZONE_SYS, SOF_MEM_CAPS_RAM,
+ sizeof(struct intel_ipc_data));
ipc_set_drvdata(_ipc, iipc);
_ipc->dsp_msg = NULL;
list_init(&ipc->empty_list);
@@ -219,7 +220,7 @@ int platform_ipc_init(struct ipc *ipc)
list_item_prepend(&ipc->message[i].list, &ipc->empty_list);
/* allocate page table buffer */
- iipc->page_table = rzalloc(RZONE_SYS, RFLAGS_NONE,
+ iipc->page_table = rzalloc(RZONE_SYS, SOF_MEM_CAPS_RAM,
PLATFORM_PAGE_TABLE_SIZE);
if (iipc->page_table)
bzero(iipc->page_table, PLATFORM_PAGE_TABLE_SIZE);
diff --git a/src/ipc/ipc.c b/src/ipc/ipc.c
index b753efd..4aebfb7 100644
--- a/src/ipc/ipc.c
+++ b/src/ipc/ipc.c
@@ -99,7 +99,8 @@ int ipc_comp_new(struct ipc *ipc, struct sof_ipc_comp *comp)
}
/* allocate the IPC component container */
- icd = rzalloc(RZONE_RUNTIME, RFLAGS_NONE, sizeof(struct ipc_comp_dev));
+ icd = rzalloc(RZONE_RUNTIME, SOF_MEM_CAPS_RAM,
+ sizeof(struct ipc_comp_dev));
if (icd == NULL) {
trace_ipc_error("eCm");
rfree(cd);
@@ -152,7 +153,8 @@ int ipc_buffer_new(struct ipc *ipc, struct sof_ipc_buffer *desc)
return -ENOMEM;
}
- ibd = rzalloc(RZONE_RUNTIME, RFLAGS_NONE, sizeof(struct ipc_comp_dev));
+ ibd = rzalloc(RZONE_RUNTIME, SOF_MEM_CAPS_RAM,
+ sizeof(struct ipc_comp_dev));
if (ibd == NULL) {
rfree(buffer);
return -ENOMEM;
@@ -256,7 +258,7 @@ int ipc_pipeline_new(struct ipc *ipc,
}
/* allocate the IPC pipeline container */
- ipc_pipe = rzalloc(RZONE_RUNTIME, RFLAGS_NONE,
+ ipc_pipe = rzalloc(RZONE_RUNTIME, SOF_MEM_CAPS_RAM,
sizeof(struct ipc_comp_dev));
if (ipc_pipe == NULL) {
pipeline_free(pipe);
@@ -348,8 +350,9 @@ int ipc_init(struct reef *reef)
trace_ipc("IPI");
/* init ipc data */
- reef->ipc = rzalloc(RZONE_SYS, RFLAGS_NONE, sizeof(*reef->ipc));
- reef->ipc->comp_data = rzalloc(RZONE_SYS, RFLAGS_NONE, SOF_IPC_MSG_MAX_SIZE);
+ reef->ipc = rzalloc(RZONE_SYS, SOF_MEM_CAPS_RAM, sizeof(*reef->ipc));
+ reef->ipc->comp_data = rzalloc(RZONE_SYS, SOF_MEM_CAPS_RAM,
+ SOF_IPC_MSG_MAX_SIZE);
reef->ipc->dmat = reef->dmat;
list_init(&reef->ipc->comp_list);
diff --git a/src/ipc/pmc-ipc.c b/src/ipc/pmc-ipc.c
index fdb8d4b..b99e368 100644
--- a/src/ipc/pmc-ipc.c
+++ b/src/ipc/pmc-ipc.c
@@ -168,7 +168,8 @@ int platform_ipc_pmc_init(void)
uint32_t imrlpesc;
/* init ipc data */
- _pmc = rmalloc(RZONE_SYS, RFLAGS_NONE, sizeof(struct intel_ipc_pmc_data));
+ _pmc = rmalloc(RZONE_SYS, SOF_MEM_CAPS_RAM,
+ sizeof(struct intel_ipc_pmc_data));
/* configure interrupt */
interrupt_register(IRQ_NUM_EXT_PMC, irq_handler, NULL);
diff --git a/src/lib/agent.c b/src/lib/agent.c
index 0a1ad42..2c61cb1 100644
--- a/src/lib/agent.c
+++ b/src/lib/agent.c
@@ -83,7 +83,7 @@ void sa_init(struct reef *reef)
trace_sa("ini");
- sa = rzalloc(RZONE_SYS, RFLAGS_NONE, sizeof(*sa));
+ sa = rzalloc(RZONE_SYS, SOF_MEM_CAPS_RAM, sizeof(*sa));
reef->sa = sa;
/* set default tick timout */
diff --git a/src/lib/alloc.c b/src/lib/alloc.c
index bbc32a3..6221d26 100644
--- a/src/lib/alloc.c
+++ b/src/lib/alloc.c
@@ -132,7 +132,7 @@ static void *alloc_block(struct mm_heap *heap, int level,
map->free_count--;
ptr = (void *)(map->base + map->first_free * map->block_size);
hdr->size = 1;
- hdr->flags = RFLAGS_USED;
+ hdr->used = 1;
heap->info.used += map->block_size;
heap->info.free -= map->block_size;
@@ -141,7 +141,7 @@ static void *alloc_block(struct mm_heap *heap, int level,
hdr = &map->block[i];
- if (hdr->flags == 0) {
+ if (hdr->used == 0) {
map->first_free = i;
break;
}
@@ -180,7 +180,7 @@ static void *alloc_cont_blocks(struct mm_heap *heap, int level,
hdr = &map->block[current];
/* is block used */
- if (hdr->flags == RFLAGS_USED)
+ if (hdr->used)
break;
}
@@ -205,7 +205,7 @@ found:
/* allocate each block */
for (current = start; current < end; current++) {
hdr = &map->block[current];
- hdr->flags = RFLAGS_USED;
+ hdr->used = 1;
}
/* do we need to find a new first free block ? */
@@ -216,7 +216,7 @@ found:
hdr = &map->block[i];
- if (hdr->flags == 0) {
+ if (hdr->used == 0) {
map->first_free = i;
break;
}
@@ -330,7 +330,7 @@ found:
for (i = block; i < block + hdr->size; i++) {
hdr = &block_map->block[i];
hdr->size = 0;
- hdr->flags = 0;
+ hdr->used = 0;
block_map->free_count++;
heap->info.used -= block_map->block_size;
heap->info.free += block_map->block_size;
diff --git a/src/lib/dma-trace.c b/src/lib/dma-trace.c
index c72c55b..211f34f 100644
--- a/src/lib/dma-trace.c
+++ b/src/lib/dma-trace.c
@@ -128,11 +128,12 @@ int dma_trace_init_early(struct reef *reef)
{
struct dma_trace_buf *buffer;
- trace_data = rzalloc(RZONE_SYS, RFLAGS_NONE, sizeof(*trace_data));
+ trace_data = rzalloc(RZONE_SYS, SOF_MEM_CAPS_RAM, sizeof(*trace_data));
buffer = &trace_data->dmatb;
/* allocate new buffer */
- buffer->addr = rballoc(RZONE_RUNTIME, RFLAGS_NONE, DMA_TRACE_LOCAL_SIZE);
+ buffer->addr = rballoc(RZONE_RUNTIME, SOF_MEM_CAPS_RAM,
+ DMA_TRACE_LOCAL_SIZE);
if (buffer->addr == NULL) {
trace_buffer_error("ebm");
return -ENOMEM;
@@ -179,7 +180,7 @@ int dma_trace_host_buffer(struct dma_trace_data *d, struct dma_sg_elem *elem,
struct dma_sg_elem *e;
/* allocate new host DMA elem and add it to our list */
- e = rzalloc(RZONE_RUNTIME, RFLAGS_NONE, sizeof(*e));
+ e = rzalloc(RZONE_RUNTIME, SOF_MEM_CAPS_RAM, sizeof(*e));
if (e == NULL)
return -ENOMEM;
diff --git a/src/lib/interrupt.c b/src/lib/interrupt.c
index 4516cf3..32b6235 100644
--- a/src/lib/interrupt.c
+++ b/src/lib/interrupt.c
@@ -56,7 +56,8 @@ int irq_register_child(struct irq_parent *parent, int irq,
/* init child */
parent->child[REEF_IRQ_BIT(irq)] =
- rzalloc(RZONE_SYS, RFLAGS_NONE, sizeof(struct irq_child));
+ rzalloc(RZONE_SYS, SOF_MEM_CAPS_RAM,
+ sizeof(struct irq_child));
parent->child[REEF_IRQ_BIT(irq)]->enabled = 0;
parent->child[REEF_IRQ_BIT(irq)]->handler = handler;
parent->child[REEF_IRQ_BIT(irq)]->handler_arg = arg;
diff --git a/src/lib/schedule.c b/src/lib/schedule.c
index bfbb1b9..7728419 100644
--- a/src/lib/schedule.c
+++ b/src/lib/schedule.c
@@ -372,7 +372,7 @@ int scheduler_init(struct reef *reef)
{
trace_pipe("ScI");
- sch = rzalloc(RZONE_SYS, RFLAGS_NONE, sizeof(*sch));
+ sch = rzalloc(RZONE_SYS, SOF_MEM_CAPS_RAM, sizeof(*sch));
list_init(&sch->list);
spinlock_init(&sch->lock);
sch->clock = PLATFORM_SCHED_CLOCK;
diff --git a/src/lib/work.c b/src/lib/work.c
index 18d743c..eb7b223 100644
--- a/src/lib/work.c
+++ b/src/lib/work.c
@@ -444,7 +444,7 @@ struct work_queue *work_new_queue(struct work_queue_timesource *ts)
struct work_queue *queue;
/* init work queue */
- queue = rmalloc(RZONE_SYS, RFLAGS_NONE, sizeof(*queue_));
+ queue = rmalloc(RZONE_SYS, SOF_MEM_CAPS_RAM, sizeof(*queue_));
list_init(&queue->work);
spinlock_init(&queue->lock);
diff --git a/src/platform/apollolake/clk.c b/src/platform/apollolake/clk.c
index 72d2e9f..32d3236 100644
--- a/src/platform/apollolake/clk.c
+++ b/src/platform/apollolake/clk.c
@@ -197,7 +197,7 @@ uint64_t clock_time_elapsed(int clock, uint64_t previous, uint64_t *current)
void init_platform_clocks(void)
{
- clk_pdata = rmalloc(RZONE_SYS, RFLAGS_NONE, sizeof(*clk_pdata));
+ clk_pdata = rmalloc(RZONE_SYS, SOF_MEM_CAPS_RAM, sizeof(*clk_pdata));
spinlock_init(&clk_pdata->clk[0].lock);
spinlock_init(&clk_pdata->clk[1].lock);
diff --git a/src/platform/baytrail/clk.c b/src/platform/baytrail/clk.c
index 99e1bfd..fc1cd9d 100644
--- a/src/platform/baytrail/clk.c
+++ b/src/platform/baytrail/clk.c
@@ -260,7 +260,7 @@ uint64_t clock_time_elapsed(int clock, uint64_t previous, uint64_t *current)
void init_platform_clocks(void)
{
- clk_pdata = rmalloc(RZONE_SYS, RFLAGS_NONE, sizeof(*clk_pdata));
+ clk_pdata = rmalloc(RZONE_SYS, SOF_MEM_CAPS_RAM, sizeof(*clk_pdata));
spinlock_init(&clk_pdata->clk[0].lock);
spinlock_init(&clk_pdata->clk[1].lock);
diff --git a/src/platform/cannonlake/clk.c b/src/platform/cannonlake/clk.c
index dcfe4b3..f27e691 100644
--- a/src/platform/cannonlake/clk.c
+++ b/src/platform/cannonlake/clk.c
@@ -191,7 +191,8 @@ uint64_t clock_time_elapsed(int clock, uint64_t previous, uint64_t *current)
void init_platform_clocks(void)
{
- clk_pdata = rmalloc(RZONE_RUNTIME, RFLAGS_NONE, sizeof(*clk_pdata));
+ clk_pdata = rmalloc(RZONE_RUNTIME, SOF_MEM_CAPS_RAM,
+ sizeof(*clk_pdata));
spinlock_init(&clk_pdata->clk[0].lock);
spinlock_init(&clk_pdata->clk[1].lock);
diff --git a/src/platform/haswell/clk.c b/src/platform/haswell/clk.c
index 76d18d1..8a724a8 100644
--- a/src/platform/haswell/clk.c
+++ b/src/platform/haswell/clk.c
@@ -195,7 +195,7 @@ uint64_t clock_time_elapsed(int clock, uint64_t previous, uint64_t *current)
void init_platform_clocks(void)
{
- clk_pdata = rzalloc(RZONE_SYS, RFLAGS_NONE, sizeof(*clk_pdata));
+ clk_pdata = rzalloc(RZONE_SYS, SOF_MEM_CAPS_RAM, sizeof(*clk_pdata));
spinlock_init(&clk_pdata->clk[0].lock);
spinlock_init(&clk_pdata->clk[1].lock);
--
2.14.1
1
0
[Sound-open-firmware] [PATCH] Fix pointer of struct dma_trace_data.
by yan.wang@linux.intel.com 01 Mar '18
by yan.wang@linux.intel.com 01 Mar '18
01 Mar '18
From: Yan Wang <yan.wang(a)linux.intel.com>
Liam's previous patch modify the structure variable from instance to
pointer. So it is unnecessary to use "&".
This parameter of parse_page_descriptors() is "void*", so complier
doesn't find this error.
Signed-off-by: Yan Wang <yan.wang(a)linux.intel.com>
---
src/ipc/intel-ipc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/ipc/intel-ipc.c b/src/ipc/intel-ipc.c
index 5e14653..04e8c1b 100644
--- a/src/ipc/intel-ipc.c
+++ b/src/ipc/intel-ipc.c
@@ -619,7 +619,7 @@ static int ipc_dma_trace_config(uint32_t header)
/* Parse host tables */
err = parse_page_descriptors(iipc, ¶ms->buffer,
- &_ipc->dmat, 1);
+ _ipc->dmat, 1);
if (err < 0) {
trace_ipc_error("ePP");
goto error;
--
2.14.3
3
2
[Sound-open-firmware] [PATCH] memory: allocator: Add support for different memory types and mappings
by Liam Girdwood 01 Mar '18
by Liam Girdwood 01 Mar '18
01 Mar '18
Currently memory heap pools are statically defined in the allocator core
and don't define the capabilities of the memory in each pool.
This patch adds support for different memory capabilities so that users
can allocate memory that complies with any capability requirements for
requested memory.
The patch also moves the memory heap pool mappings to platform specific
code so that platforms can define their own mappings, support multiple
mappings and can move the mappings into different physical memory areas.
mappings
Signed-off-by: Liam Girdwood <liam.r.girdwood(a)linux.intel.com>
---
src/audio/eq_fir.c | 3 +-
src/include/reef/alloc.h | 50 ++-
src/include/uapi/ipc.h | 12 +
src/lib/alloc.c | 383 +++++++++------------
src/platform/apollolake/Makefile.am | 3 +-
src/platform/apollolake/include/platform/memory.h | 12 +-
.../apollolake/include/platform/platform.h | 6 +
src/platform/apollolake/memory.c | 119 +++++++
src/platform/baytrail/Makefile.am | 3 +-
src/platform/baytrail/include/platform/memory.h | 7 +-
src/platform/baytrail/memory.c | 89 +++++
src/platform/cannonlake/Makefile.am | 3 +-
src/platform/cannonlake/include/platform/memory.h | 15 +-
src/platform/cannonlake/memory.c | 119 +++++++
src/platform/haswell/Makefile.am | 3 +-
src/platform/haswell/include/platform/memory.h | 7 +-
src/platform/haswell/memory.c | 89 +++++
17 files changed, 668 insertions(+), 255 deletions(-)
create mode 100644 src/platform/apollolake/memory.c
create mode 100644 src/platform/baytrail/memory.c
create mode 100644 src/platform/cannonlake/memory.c
create mode 100644 src/platform/haswell/memory.c
diff --git a/src/audio/eq_fir.c b/src/audio/eq_fir.c
index 2dfa11c..a723cf0 100644
--- a/src/audio/eq_fir.c
+++ b/src/audio/eq_fir.c
@@ -149,8 +149,7 @@ static void eq_fir_free_delaylines(struct fir_state_32x16 fir[])
}
if (data != NULL)
- rbfree(data);
-
+ rfree(data);
}
static int eq_fir_setup(struct fir_state_32x16 fir[],
diff --git a/src/include/reef/alloc.h b/src/include/reef/alloc.h
index 982af90..6b61b04 100644
--- a/src/include/reef/alloc.h
+++ b/src/include/reef/alloc.h
@@ -35,6 +35,7 @@
#include <string.h>
#include <stdint.h>
#include <reef/dma.h>
+#include <platform/memory.h>
struct reef;
@@ -61,23 +62,58 @@ struct reef;
*/
#define RFLAGS_NONE 0
#define RFLAGS_USED 1
-#define RFLAGS_ATOMIC 2 /* allocation with IRQs off */
-#define RFLAGS_DMA 4 /* DMA-able memory */
-#define RFLAGS_POWER 8 /* low power memory */
struct mm_info {
uint32_t used;
uint32_t free;
};
+struct block_hdr {
+ uint16_t size; /* size in blocks for continuous allocation */
+ uint16_t flags; /* usage flags for page */
+} __attribute__ ((packed));
+
+struct block_map {
+ uint16_t block_size; /* size of block in bytes */
+ uint16_t count; /* number of blocks in map */
+ uint16_t free_count; /* number of free blocks */
+ uint16_t first_free; /* index of first free block */
+ struct block_hdr *block; /* base block header */
+ uint32_t base; /* base address of space */
+} __attribute__ ((packed));
+
+#define BLOCK_DEF(sz, cnt, hdr) \
+ {.block_size = sz, .count = cnt, .free_count = cnt, .block = hdr}
+
+struct mm_heap {
+ uint32_t blocks;
+ struct block_map *map;
+ uint32_t heap;
+ uint32_t size;
+ uint32_t caps;
+ struct mm_info info;
+};
+
+/* heap block memory map */
+struct mm {
+ /* system heap - used during init cannot be freed */
+ struct mm_heap system;
+ /* general heap for components */
+ struct mm_heap runtime[PLATFORM_HEAP_RUNTIME];
+ /* general component buffer heap */
+ struct mm_heap buffer[PLATFORM_HEAP_BUFFER];
+
+ struct mm_info total;
+ spinlock_t lock; /* all allocs and frees are atomic */
+};
+
/* heap allocation and free */
-void *rmalloc(int zone, int flags, size_t bytes);
-void *rzalloc(int zone, int flags, size_t bytes);
+void *rmalloc(int zone, uint32_t caps, size_t bytes);
+void *rzalloc(int zone, uint32_t caps, size_t bytes);
void rfree(void *ptr);
/* heap allocation and free for buffers on 1k boundary */
-void *rballoc(int zone, int flags, size_t bytes);
-void rbfree(void *ptr);
+void *rballoc(int zone, uint32_t flags, size_t bytes);
/* utility */
void bzero(void *s, size_t n);
diff --git a/src/include/uapi/ipc.h b/src/include/uapi/ipc.h
index 87b01e3..dec8abd 100644
--- a/src/include/uapi/ipc.h
+++ b/src/include/uapi/ipc.h
@@ -143,6 +143,17 @@
#define SOF_IPC_PANIC_STACK (SOF_IPC_PANIC_MAGIC | 8)
#define SOF_IPC_PANIC_IDLE (SOF_IPC_PANIC_MAGIC | 9)
+/*
+ * SOF memory capabilities, add new ones at the end
+ */
+#define SOF_MEM_CAPS_RAM (1 << 0)
+#define SOF_MEM_CAPS_ROM (1 << 1)
+#define SOF_MEM_CAPS_EXT (1 << 2) /* external */
+#define SOF_MEM_CAPS_LP (1 << 3) /* low power */
+#define SOF_MEM_CAPS_HP (1 << 4) /* high performance */
+#define SOF_MEM_CAPS_DMA (1 << 5) /* DMA'able */
+#define SOF_MEM_CAPS_CACHE (1 << 6) /* cacheable */
+
/*
* Command Header - Header for all IPC. Identifies IPC message.
* The size can be greater than the structure size and that means there is
@@ -561,6 +572,7 @@ struct sof_ipc_comp {
struct sof_ipc_buffer {
struct sof_ipc_comp comp;
uint32_t size; /* buffer size in bytes */
+ uint32_t type; /* SOF_MEM_CAPS_ */
} __attribute__((packed));
diff --git a/src/lib/alloc.c b/src/lib/alloc.c
index 803b7af..bbc32a3 100644
--- a/src/lib/alloc.c
+++ b/src/lib/alloc.c
@@ -55,6 +55,8 @@
#define trace_mem_error(__e) trace_error(TRACE_CLASS_MEM, __e)
+extern struct mm memmap;
+
/* We have 3 memory pools
*
* 1) System memory pool does not have a map and it's size is fixed at build
@@ -67,115 +69,6 @@
* module removal or calls to rfree(). Saved as part of PM context.
*/
-struct block_hdr {
- uint16_t size; /* size in blocks of this continuous allocation */
- uint16_t flags; /* usage flags for page */
-} __attribute__ ((packed));
-
-struct block_map {
- uint16_t block_size; /* size of block in bytes */
- uint16_t count; /* number of blocks in map */
- uint16_t free_count; /* number of free blocks */
- uint16_t first_free; /* index of first free block */
- struct block_hdr *block; /* base block header */
- uint32_t base; /* base address of space */
-} __attribute__ ((packed));
-
-#define BLOCK_DEF(sz, cnt, hdr) \
- {.block_size = sz, .count = cnt, .free_count = cnt, .block = hdr}
-
-/* Heap blocks for modules */
-//static struct block_hdr mod_block8[HEAP_RT_COUNT8];
-static struct block_hdr mod_block16[HEAP_RT_COUNT16];
-static struct block_hdr mod_block32[HEAP_RT_COUNT32];
-static struct block_hdr mod_block64[HEAP_RT_COUNT64];
-static struct block_hdr mod_block128[HEAP_RT_COUNT128];
-static struct block_hdr mod_block256[HEAP_RT_COUNT256];
-static struct block_hdr mod_block512[HEAP_RT_COUNT512];
-static struct block_hdr mod_block1024[HEAP_RT_COUNT1024];
-
-/* Heap memory map for modules */
-static struct block_map rt_heap_map[] = {
-/* BLOCK_DEF(8, HEAP_RT_COUNT8, mod_block8), */
- BLOCK_DEF(16, HEAP_RT_COUNT16, mod_block16),
- BLOCK_DEF(32, HEAP_RT_COUNT32, mod_block32),
- BLOCK_DEF(64, HEAP_RT_COUNT64, mod_block64),
- BLOCK_DEF(128, HEAP_RT_COUNT128, mod_block128),
- BLOCK_DEF(256, HEAP_RT_COUNT256, mod_block256),
- BLOCK_DEF(512, HEAP_RT_COUNT512, mod_block512),
- BLOCK_DEF(1024, HEAP_RT_COUNT1024, mod_block1024),
-};
-
-/* Heap blocks for buffers */
-static struct block_hdr buf_block[HEAP_BUFFER_COUNT];
-
-/* Heap memory map for buffers */
-static struct block_map buf_heap_map[] = {
- BLOCK_DEF(HEAP_BUFFER_BLOCK_SIZE, HEAP_BUFFER_COUNT, buf_block),
-};
-
-#if (HEAP_DMA_BUFFER_SIZE > 0)
-/* Heap memory map for DMA buffers - only used for HW with special DMA memories */
-static struct block_map dma_buf_heap_map[] = {
- BLOCK_DEF(HEAP_DMA_BUFFER_BLOCK_SIZE, HEAP_DMA_BUFFER_COUNT, buf_block),
-};
-#endif
-
-struct mm_heap {
- uint32_t blocks;
- struct block_map *map;
- uint32_t heap;
- uint32_t size;
- struct mm_info info;
-};
-
-/* heap block memory map */
-struct mm {
- struct mm_heap runtime; /* general heap for components */
- struct mm_heap system; /* system heap - used during init cannot be freed */
- struct mm_heap buffer; /* general component buffer heap */
-#if (HEAP_DMA_BUFFER_SIZE > 0)
- struct mm_heap dma; /* general component DMA buffer heap */
-#endif
- struct mm_info total;
- spinlock_t lock; /* all allocs and frees are atomic */
-};
-
-struct mm memmap = {
- .system = {
- .heap = HEAP_SYSTEM_BASE,
- .size = HEAP_SYSTEM_SIZE,
- .info = {.free = HEAP_SYSTEM_SIZE,},
- },
-
- .runtime = {
- .blocks = ARRAY_SIZE(rt_heap_map),
- .map = rt_heap_map,
- .heap = HEAP_RUNTIME_BASE,
- .size = HEAP_RUNTIME_SIZE,
- .info = {.free = HEAP_RUNTIME_SIZE,},
- },
-
- .buffer = {
- .blocks = ARRAY_SIZE(buf_heap_map),
- .map = buf_heap_map,
- .heap = HEAP_BUFFER_BASE,
- .size = HEAP_BUFFER_SIZE,
- .info = {.free = HEAP_BUFFER_SIZE,},
- },
-
-#if (HEAP_DMA_BUFFER_SIZE > 0)
- .dma = {
- .blocks = ARRAY_SIZE(dma_buf_heap_map),
- .map = dma_buf_heap_map,
- .heap = HEAP_DMA_BUFFER_BASE,
- .size = HEAP_DMA_BUFFER_SIZE,
- .info = {.free = HEAP_DMA_BUFFER_SIZE,},
- },
-#endif
- .total = {.free = HEAP_SYSTEM_SIZE + HEAP_RUNTIME_SIZE +
- HEAP_BUFFER_SIZE + HEAP_DMA_BUFFER_SIZE,},
-};
/* total size of block */
static inline uint32_t block_get_size(struct block_map *map)
@@ -228,7 +121,8 @@ static void *rmalloc_sys(size_t bytes)
}
/* allocate single block */
-static void *alloc_block(struct mm_heap *heap, int level, int bflags)
+static void *alloc_block(struct mm_heap *heap, int level,
+ uint32_t caps)
{
struct block_map *map = &heap->map[level];
struct block_hdr *hdr = &map->block[map->first_free];
@@ -238,7 +132,7 @@ static void *alloc_block(struct mm_heap *heap, int level, int bflags)
map->free_count--;
ptr = (void *)(map->base + map->first_free * map->block_size);
hdr->size = 1;
- hdr->flags = RFLAGS_USED | bflags;
+ hdr->flags = RFLAGS_USED;
heap->info.used += map->block_size;
heap->info.free -= map->block_size;
@@ -261,8 +155,8 @@ static void *alloc_block(struct mm_heap *heap, int level, int bflags)
}
/* allocates continuous blocks */
-static void *alloc_cont_blocks(struct mm_heap *heap, int level, int bflags,
- size_t bytes)
+static void *alloc_cont_blocks(struct mm_heap *heap, int level,
+ uint32_t caps, size_t bytes)
{
struct block_map *map = &heap->map[level];
struct block_hdr *hdr = &map->block[map->first_free];
@@ -311,7 +205,7 @@ found:
/* allocate each block */
for (current = start; current < end; current++) {
hdr = &map->block[current];
- hdr->flags = RFLAGS_USED | bflags;
+ hdr->flags = RFLAGS_USED;
}
/* do we need to find a new first free block ? */
@@ -336,43 +230,87 @@ found:
return ptr;
}
+static struct mm_heap *get_heap_from_ptr(void *ptr)
+{
+ struct mm_heap *heap;
+ int i;
+
+ /* find mm_heap that ptr belongs to */
+ for (i = 0; i < PLATFORM_HEAP_RUNTIME; i++) {
+ heap = &memmap.runtime[i];
+
+ if ((uint32_t)ptr >= heap->heap &&
+ (uint32_t)ptr < heap->heap + heap->size)
+ return heap;
+ }
+
+ for (i = 0; i < PLATFORM_HEAP_BUFFER; i++) {
+ heap = &memmap.buffer[i];
+
+ if ((uint32_t)ptr >= heap->heap &&
+ (uint32_t)ptr < heap->heap + heap->size)
+ return heap;
+ }
+
+ return NULL;
+}
+
+static struct mm_heap *get_runtime_heap_from_caps(uint32_t caps)
+{
+ struct mm_heap *heap;
+ uint32_t mask;
+ int i;
+
+ /* find first heap that support type */
+ for (i = 0; i < PLATFORM_HEAP_RUNTIME; i++) {
+ heap = &memmap.runtime[i];
+ mask = heap->caps & caps;
+ if (mask == caps)
+ return heap;
+ }
+
+ return NULL;
+}
+
+static struct mm_heap *get_buffer_heap_from_caps(uint32_t caps)
+{
+ struct mm_heap *heap;
+ uint32_t mask;
+ int i;
+
+ /* find first heap that support type */
+ for (i = 0; i < PLATFORM_HEAP_BUFFER; i++) {
+ heap = &memmap.buffer[i];
+ mask = heap->caps & caps;
+ if (mask == caps)
+ return heap;
+ }
+
+ return NULL;
+}
+
/* free block(s) */
-static void free_block(struct mm_heap *heap, void *ptr)
+static void free_block(void *ptr)
{
- struct mm_heap * mm_heap;
- struct block_map * block_map;
+ struct mm_heap *heap;
+ struct block_map *block_map;
struct block_hdr *hdr;
int i;
int block;
- int array_size;
/* sanity check */
if (ptr == NULL)
return;
- /* find mm_heap that ptr belongs to */
- if ((uint32_t)ptr >= memmap.runtime.heap &&
- (uint32_t)ptr < memmap.runtime.heap + memmap.runtime.size) {
- mm_heap = &memmap.runtime;
- array_size = ARRAY_SIZE(rt_heap_map);
- } else if ((uint32_t)ptr >= memmap.buffer.heap &&
- (uint32_t)ptr < memmap.buffer.heap + memmap.buffer.size) {
- mm_heap = &memmap.buffer;
- array_size = ARRAY_SIZE(buf_heap_map);
-#if (HEAP_DMA_BUFFER_SIZE > 0)
- } else if ((uint32_t)ptr >= memmap.dma.heap &&
- (uint32_t)ptr < memmap.dma.heap + memmap.dma.size) {
- mm_heap = &memmap.dma;
- array_size = ARRAY_SIZE(dma_buf_heap_map);
-#endif
- } else
+ heap = get_heap_from_ptr(ptr);
+ if (heap == NULL)
return;
/* find block that ptr belongs to */
- for (i = 0; i < array_size - 1; i ++) {
+ for (i = 0; i < heap->blocks - 1; i++) {
/* is ptr in this block */
- if ((uint32_t)ptr < mm_heap->map[i + 1].base)
+ if ((uint32_t)ptr < heap->map[i + 1].base)
goto found;
}
@@ -382,7 +320,7 @@ static void free_block(struct mm_heap *heap, void *ptr)
found:
/* the block i is it */
- block_map = &mm_heap->map[i];
+ block_map = &heap->map[i];
/* calculate block header */
block = ((uint32_t)ptr - block_map->base) / block_map->block_size;
@@ -398,7 +336,7 @@ found:
heap->info.free += block_map->block_size;
}
- /* set first free */
+ /* set first free block */
if (block < block_map->first_free)
block_map->first_free = block;
@@ -408,31 +346,37 @@ found:
}
/* allocate single block for runtime */
-static void *rmalloc_runtime(int bflags, size_t bytes)
+static void *rmalloc_runtime(uint32_t caps, size_t bytes)
{
+ struct mm_heap *heap;
int i;
- for (i = 0; i < ARRAY_SIZE(rt_heap_map); i ++) {
+ heap = get_runtime_heap_from_caps(caps);
+ if (heap == NULL)
+ goto error;
+
+ for (i = 0; i < heap->blocks; i++) {
/* is block big enough */
- if (rt_heap_map[i].block_size < bytes)
+ if (heap->map[i].block_size < bytes)
continue;
/* does block have free space */
- if (rt_heap_map[i].free_count == 0)
+ if (heap->map[i].free_count == 0)
continue;
/* free block space exists */
- return alloc_block(&memmap.runtime, i, bflags);
+ return alloc_block(heap, i, caps);
}
+error:
trace_mem_error("eMm");
trace_value(bytes);
- trace_value(bflags);
+ trace_value(caps);
return NULL;
}
-void *rmalloc(int zone, int bflags, size_t bytes)
+void *rmalloc(int zone, uint32_t caps, size_t bytes)
{
uint32_t flags;
void *ptr = NULL;
@@ -444,7 +388,7 @@ void *rmalloc(int zone, int bflags, size_t bytes)
ptr = rmalloc_sys(bytes);
break;
case RZONE_RUNTIME:
- ptr = rmalloc_runtime(bflags, bytes);
+ ptr = rmalloc_runtime(caps, bytes);
break;
default:
trace_mem_error("eMz");
@@ -455,11 +399,11 @@ void *rmalloc(int zone, int bflags, size_t bytes)
return ptr;
}
-void *rzalloc(int zone, int bflags, size_t bytes)
+void *rzalloc(int zone, uint32_t caps, size_t bytes)
{
void *ptr = NULL;
- ptr = rmalloc(zone, bflags, bytes);
+ ptr = rmalloc(zone, caps, bytes);
if (ptr != NULL) {
bzero(ptr, bytes);
}
@@ -467,61 +411,54 @@ void *rzalloc(int zone, int bflags, size_t bytes)
return ptr;
}
-/* allocates continuous buffer on 1k boundary */
-void *rballoc(int zone, int bflags, size_t bytes)
+/* allocates continuous buffers */
+void *rballoc(int zone, uint32_t caps, size_t bytes)
{
- struct block_map * block_map = buf_heap_map;
- struct mm_heap * mm_heap = &memmap.buffer;
+ struct mm_heap *heap;
int i;
- int array_size = ARRAY_SIZE(buf_heap_map);
uint32_t flags;
void *ptr = NULL;
-#if (HEAP_DMA_BUFFER_SIZE > 0)
- if (bflags & RFLAGS_DMA) {
- mm_heap = &memmap.dma;
- block_map = dma_buf_heap_map;
- array_size = ARRAY_SIZE(dma_buf_heap_map);
- }
-#endif
spin_lock_irq(&memmap.lock, flags);
+ heap = get_buffer_heap_from_caps(caps);
+ if (heap == NULL)
+ goto out;
+
/* will request fit in single block */
- for (i = 0; i < array_size; i++) {
+ for (i = 0; i < heap->blocks; i++) {
/* is block big enough */
- if (block_map[i].block_size < bytes)
+ if (heap->map[i].block_size < bytes)
continue;
/* does block have free space */
- if (block_map[i].free_count == 0)
+ if (heap->map[i].free_count == 0)
continue;
/* allocate block */
- ptr = alloc_block(mm_heap, i, bflags);
+ ptr = alloc_block(heap, i, caps);
goto out;
}
/* request spans > 1 block */
/* only 1 choice for block size */
- if (array_size == 1) {
- ptr = alloc_cont_blocks(mm_heap, 0, bflags, bytes);
+ if (heap->blocks == 1) {
+ ptr = alloc_cont_blocks(heap, 0, caps, bytes);
goto out;
} else {
/* find best block size for request */
- for (i = 0; i < array_size; i++) {
+ for (i = 0; i < heap->blocks; i++) {
/* allocate is block size smaller than request */
- if (block_map[i].block_size < bytes)
- alloc_cont_blocks(mm_heap, i, bflags,
- bytes);
+ if (heap->map[i].block_size < bytes)
+ alloc_cont_blocks(heap, i, caps, bytes);
}
}
- ptr = alloc_cont_blocks(mm_heap, array_size - 1,
- bflags, bytes);
+ ptr = alloc_cont_blocks(heap, heap->blocks - 1, caps, bytes);
out:
spin_unlock_irq(&memmap.lock, flags);
@@ -533,38 +470,42 @@ void rfree(void *ptr)
uint32_t flags;
spin_lock_irq(&memmap.lock, flags);
- free_block(&memmap.runtime, ptr);
- spin_unlock_irq(&memmap.lock, flags);
-}
-
-void rbfree(void *ptr)
-{
- uint32_t flags;
-
- spin_lock_irq(&memmap.lock, flags);
- free_block(&memmap.buffer, ptr);
+ free_block(ptr);
spin_unlock_irq(&memmap.lock, flags);
}
uint32_t mm_pm_context_size(void)
{
- uint32_t size;
+ uint32_t size = 0;
+ int i;
/* calc context size for each area */
- size = memmap.buffer.info.used;
- size += memmap.runtime.info.used;
+ for (i = 0; i < PLATFORM_HEAP_BUFFER; i++)
+ size += memmap.buffer[i].info.used;
+ for (i = 0; i < PLATFORM_HEAP_RUNTIME; i++)
+ size += memmap.runtime[i].info.used;
size += memmap.system.info.used;
/* add memory maps */
- size += heap_get_size(&memmap.buffer);
- size += heap_get_size(&memmap.runtime);
+ for (i = 0; i < PLATFORM_HEAP_BUFFER; i++)
+ size += heap_get_size(&memmap.buffer[i]);
+ for (i = 0; i < PLATFORM_HEAP_RUNTIME; i++)
+ size += heap_get_size(&memmap.runtime[i]);
size += heap_get_size(&memmap.system);
/* recalc totals */
- memmap.total.free = memmap.buffer.info.free +
- memmap.runtime.info.free + memmap.system.info.free;
- memmap.total.used = memmap.buffer.info.used +
- memmap.runtime.info.used + memmap.system.info.used;
+ memmap.total.free = memmap.system.info.free;
+ memmap.total.used = memmap.system.info.used;
+
+ for (i = 0; i < PLATFORM_HEAP_BUFFER; i++) {
+ memmap.total.free += memmap.buffer[i].info.free;
+ memmap.total.used += memmap.buffer[i].info.used;
+ }
+
+ for (i = 0; i < PLATFORM_HEAP_RUNTIME; i++) {
+ memmap.total.free = memmap.runtime[i].info.free;
+ memmap.total.used = memmap.runtime[i].info.used;
+ }
return size;
}
@@ -643,9 +584,12 @@ int mm_pm_context_restore(struct dma_copy *dc, struct dma_sg_config *sg)
/* initialise map */
void init_heap(struct reef *reef)
{
+ struct mm_heap *heap;
struct block_map *next_map;
struct block_map *current_map;
int i;
+ int j;
+ int k;
/* sanity check for malformed images or loader issues */
if (memmap.system.heap != HEAP_SYSTEM_BASE)
@@ -654,37 +598,40 @@ void init_heap(struct reef *reef)
spinlock_init(&memmap.lock);
/* initialise buffer map */
- current_map = &buf_heap_map[0];
- current_map->base = memmap.buffer.heap;
-
- for (i = 1; i < ARRAY_SIZE(buf_heap_map); i++) {
- next_map = &buf_heap_map[i];
- next_map->base = current_map->base +
- current_map->block_size * current_map->count;
- current_map = &buf_heap_map[i];
+ for (i = 0; i < PLATFORM_HEAP_BUFFER; i++) {
+ heap = &memmap.buffer[i];
+
+ for (j = 0; j < heap->blocks; j++) {
+
+ current_map = &heap->map[j];
+ current_map->base = heap->heap;
+
+ for (k = 1; k < heap->blocks; k++) {
+ next_map = &heap->map[k];
+ next_map->base = current_map->base +
+ current_map->block_size *
+ current_map->count;
+ current_map = &heap->map[k];
+ }
+ }
}
/* initialise runtime map */
- current_map = &rt_heap_map[0];
- current_map->base = memmap.runtime.heap;
-
- for (i = 1; i < ARRAY_SIZE(rt_heap_map); i++) {
- next_map = &rt_heap_map[i];
- next_map->base = current_map->base +
- current_map->block_size * current_map->count;
- current_map = &rt_heap_map[i];
- }
+ for (i = 0; i < PLATFORM_HEAP_RUNTIME; i++) {
+ heap = &memmap.runtime[i];
-#if (HEAP_DMA_BUFFER_SIZE > 0)
- /* initialise DMA map */
- current_map = &dma_buf_heap_map[0];
- current_map->base = memmap.dma.heap;
+ for (j = 0; j < heap->blocks; j++) {
- for (i = 1; i < ARRAY_SIZE(dma_buf_heap_map); i++) {
- next_map = &dma_buf_heap_map[i];
- next_map->base = current_map->base +
- current_map->block_size * current_map->count;
- current_map = &dma_buf_heap_map[i];
+ current_map = &heap->map[j];
+ current_map->base = heap->heap;
+
+ for (k = 1; k < heap->blocks; k++) {
+ next_map = &heap->map[k];
+ next_map->base = current_map->base +
+ current_map->block_size *
+ current_map->count;
+ current_map = &heap->map[k];
+ }
+ }
}
-#endif
}
diff --git a/src/platform/apollolake/Makefile.am b/src/platform/apollolake/Makefile.am
index d4fe06a..7e776e3 100644
--- a/src/platform/apollolake/Makefile.am
+++ b/src/platform/apollolake/Makefile.am
@@ -8,7 +8,8 @@ libplatform_a_SOURCES = \
dma.c \
clk.c \
timer.c \
- interrupt.c
+ interrupt.c \
+ memory.c
libplatform_a_CFLAGS = \
$(ARCH_CFLAGS) \
diff --git a/src/platform/apollolake/include/platform/memory.h b/src/platform/apollolake/include/platform/memory.h
index b4fae8e..b633637 100644
--- a/src/platform/apollolake/include/platform/memory.h
+++ b/src/platform/apollolake/include/platform/memory.h
@@ -174,7 +174,7 @@
#define REEF_DATA_SIZE 0x18000
/* bss data */
-#define REEF_BSS_DATA_SIZE 0x2000
+#define REEF_BSS_DATA_SIZE 0x2800
/* Heap configuration */
#define HEAP_SYSTEM_BASE \
@@ -262,12 +262,6 @@
#define HP_SRAM_WIN3_BASE SRAM_TRACE_BASE
#define HP_SRAM_WIN3_SIZE SRAM_TRACE_SIZE
-/* DMA buffer heap is the HP physical memory on Broxton */
-#define HEAP_DMA_BUFFER_BASE HP_SRAM_BASE
-#define HEAP_DMA_BUFFER_SIZE HEAP_HP_BUFFER_SIZE
-#define HEAP_DMA_BUFFER_BLOCK_SIZE HEAP_HP_BUFFER_BLOCK_SIZE
-#define HEAP_DMA_BUFFER_COUNT HEAP_HP_BUFFER_COUNT
-
/* HP SRAM Heap */
#define HEAP_HP_BUFFER_BASE HP_SRAM_BASE
#define HEAP_HP_BUFFER_SIZE \
@@ -283,7 +277,7 @@
(HEAP_HP_BUFFER_SIZE / HEAP_HP_BUFFER_BLOCK_SIZE)
/*
- * The LP SRAM Heap and Stack on Apololake are organised like this :-
+ * The LP SRAM Heap and Stack on Apollolake are organised like this :-
*
* +--------------------------------------------------------------------------+
* | Offset | Region | Size |
@@ -341,6 +335,8 @@
#define HEAP_LP_BUFFER_COUNT \
(HEAP_LP_BUFFER_SIZE / HEAP_LP_BUFFER_BLOCK_SIZE)
+#define PLATFORM_HEAP_RUNTIME 1
+#define PLATFORM_HEAP_BUFFER 3
/* Stack configuration */
#define REEF_LP_STACK_SIZE 0x1000
diff --git a/src/platform/apollolake/include/platform/platform.h b/src/platform/apollolake/include/platform/platform.h
index 8e18d53..995efca 100644
--- a/src/platform/apollolake/include/platform/platform.h
+++ b/src/platform/apollolake/include/platform/platform.h
@@ -103,6 +103,12 @@ struct reef;
/* DSP should be idle in this time frame */
#define PLATFORM_IDLE_TIME 750000
+/* platform has DMA memory type */
+#define PLATFORM_MEM_HAS_DMA
+
+/* platform has low power memory type */
+#define PLATFORM_MEM_HAS_LP_RAM
+
/* Platform defined panic code */
#define platform_panic(__x) \
sw_reg_write(SRAM_REG_FW_STATUS, (0xdead000 | __x) & 0x3fffffff)
diff --git a/src/platform/apollolake/memory.c b/src/platform/apollolake/memory.c
new file mode 100644
index 0000000..aa3dfaa
--- /dev/null
+++ b/src/platform/apollolake/memory.c
@@ -0,0 +1,119 @@
+/*
+ * Copyright (c) 2018, Intel Corporation
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the Intel Corporation nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Author: Liam Girdwood <liam.r.girdwood(a)linux.intel.com>
+ */
+
+#include <reef/alloc.h>
+
+/* Heap blocks for modules */
+static struct block_hdr mod_block16[HEAP_RT_COUNT16];
+static struct block_hdr mod_block32[HEAP_RT_COUNT32];
+static struct block_hdr mod_block64[HEAP_RT_COUNT64];
+static struct block_hdr mod_block128[HEAP_RT_COUNT128];
+static struct block_hdr mod_block256[HEAP_RT_COUNT256];
+static struct block_hdr mod_block512[HEAP_RT_COUNT512];
+static struct block_hdr mod_block1024[HEAP_RT_COUNT1024];
+
+/* Heap memory map for modules */
+static struct block_map rt_heap_map[] = {
+ BLOCK_DEF(16, HEAP_RT_COUNT16, mod_block16),
+ BLOCK_DEF(32, HEAP_RT_COUNT32, mod_block32),
+ BLOCK_DEF(64, HEAP_RT_COUNT64, mod_block64),
+ BLOCK_DEF(128, HEAP_RT_COUNT128, mod_block128),
+ BLOCK_DEF(256, HEAP_RT_COUNT256, mod_block256),
+ BLOCK_DEF(512, HEAP_RT_COUNT512, mod_block512),
+ BLOCK_DEF(1024, HEAP_RT_COUNT1024, mod_block1024),
+};
+
+/* Heap blocks for buffers */
+static struct block_hdr buf_block[HEAP_BUFFER_COUNT];
+static struct block_hdr hp_buf_block[HEAP_HP_BUFFER_COUNT];
+static struct block_hdr lp_buf_block[HEAP_LP_BUFFER_COUNT];
+
+/* Heap memory map for buffers */
+static struct block_map buf_heap_map[] = {
+ BLOCK_DEF(HEAP_BUFFER_BLOCK_SIZE, HEAP_BUFFER_COUNT, buf_block),
+};
+
+static struct block_map hp_buf_heap_map[] = {
+ BLOCK_DEF(HEAP_HP_BUFFER_BLOCK_SIZE, HEAP_HP_BUFFER_COUNT,
+ hp_buf_block),
+};
+
+static struct block_map lp_buf_heap_map[] = {
+ BLOCK_DEF(HEAP_LP_BUFFER_BLOCK_SIZE, HEAP_LP_BUFFER_COUNT,
+ lp_buf_block),
+};
+
+struct mm memmap = {
+ .system = {
+ .heap = HEAP_SYSTEM_BASE,
+ .size = HEAP_SYSTEM_SIZE,
+ .info = {.free = HEAP_SYSTEM_SIZE,},
+ .caps = SOF_MEM_CAPS_RAM | SOF_MEM_CAPS_EXT |
+ SOF_MEM_CAPS_CACHE,
+ },
+ .runtime[0] = {
+ .blocks = ARRAY_SIZE(rt_heap_map),
+ .map = rt_heap_map,
+ .heap = HEAP_RUNTIME_BASE,
+ .size = HEAP_RUNTIME_SIZE,
+ .info = {.free = HEAP_RUNTIME_SIZE,},
+ .caps = SOF_MEM_CAPS_RAM | SOF_MEM_CAPS_EXT |
+ SOF_MEM_CAPS_CACHE,
+ },
+ .buffer[0] = {
+ .blocks = ARRAY_SIZE(buf_heap_map),
+ .map = buf_heap_map,
+ .heap = HEAP_BUFFER_BASE,
+ .size = HEAP_BUFFER_SIZE,
+ .info = {.free = HEAP_BUFFER_SIZE,},
+ .caps = SOF_MEM_CAPS_RAM | SOF_MEM_CAPS_EXT |
+ SOF_MEM_CAPS_CACHE,
+ },
+ .buffer[1] = {
+ .blocks = ARRAY_SIZE(hp_buf_heap_map),
+ .map = hp_buf_heap_map,
+ .heap = HEAP_HP_BUFFER_BASE,
+ .size = HEAP_HP_BUFFER_SIZE,
+ .info = {.free = HEAP_HP_BUFFER_SIZE,},
+ .caps = SOF_MEM_CAPS_RAM | SOF_MEM_CAPS_HP |
+ SOF_MEM_CAPS_CACHE | SOF_MEM_CAPS_DMA,
+ },
+ .buffer[2] = {
+ .blocks = ARRAY_SIZE(lp_buf_heap_map),
+ .map = lp_buf_heap_map,
+ .heap = HEAP_LP_BUFFER_BASE,
+ .size = HEAP_LP_BUFFER_SIZE,
+ .info = {.free = HEAP_LP_BUFFER_SIZE,},
+ .caps = SOF_MEM_CAPS_RAM | SOF_MEM_CAPS_LP |
+ SOF_MEM_CAPS_CACHE | SOF_MEM_CAPS_DMA,
+ },
+ .total = {.free = HEAP_SYSTEM_SIZE + HEAP_RUNTIME_SIZE +
+ HEAP_HP_BUFFER_SIZE + HEAP_LP_BUFFER_SIZE,},
+};
diff --git a/src/platform/baytrail/Makefile.am b/src/platform/baytrail/Makefile.am
index 05b1235..571a957 100644
--- a/src/platform/baytrail/Makefile.am
+++ b/src/platform/baytrail/Makefile.am
@@ -9,7 +9,8 @@ libplatform_a_SOURCES = \
dai.c \
dma.c \
clk.c \
- timer.c
+ timer.c \
+ memory.c
libplatform_a_CFLAGS = \
$(ARCH_CFLAGS) \
diff --git a/src/platform/baytrail/include/platform/memory.h b/src/platform/baytrail/include/platform/memory.h
index 082592c..5bf7141 100644
--- a/src/platform/baytrail/include/platform/memory.h
+++ b/src/platform/baytrail/include/platform/memory.h
@@ -129,11 +129,8 @@
#define HEAP_BUFFER_BLOCK_SIZE 0x180
#define HEAP_BUFFER_COUNT (HEAP_BUFFER_SIZE / HEAP_BUFFER_BLOCK_SIZE)
-/* DMA buffer heap is the same physical memory as buffer heap on baytrail */
-#define HEAP_DMA_BUFFER_BASE 0
-#define HEAP_DMA_BUFFER_SIZE 0
-#define HEAP_DMA_BUFFER_BLOCK_SIZE 0
-#define HEAP_DMA_BUFFER_COUNT 0
+#define PLATFORM_HEAP_RUNTIME 1
+#define PLATFORM_HEAP_BUFFER 1
/* Stack configuration */
#define REEF_STACK_SIZE 0x1000
diff --git a/src/platform/baytrail/memory.c b/src/platform/baytrail/memory.c
new file mode 100644
index 0000000..12e7399
--- /dev/null
+++ b/src/platform/baytrail/memory.c
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2018, Intel Corporation
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the Intel Corporation nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Author: Liam Girdwood <liam.r.girdwood(a)linux.intel.com>
+ */
+
+#include <reef/alloc.h>
+
+/* Heap blocks for modules */
+static struct block_hdr mod_block16[HEAP_RT_COUNT16];
+static struct block_hdr mod_block32[HEAP_RT_COUNT32];
+static struct block_hdr mod_block64[HEAP_RT_COUNT64];
+static struct block_hdr mod_block128[HEAP_RT_COUNT128];
+static struct block_hdr mod_block256[HEAP_RT_COUNT256];
+static struct block_hdr mod_block512[HEAP_RT_COUNT512];
+static struct block_hdr mod_block1024[HEAP_RT_COUNT1024];
+
+/* Heap memory map for modules */
+static struct block_map rt_heap_map[] = {
+ BLOCK_DEF(16, HEAP_RT_COUNT16, mod_block16),
+ BLOCK_DEF(32, HEAP_RT_COUNT32, mod_block32),
+ BLOCK_DEF(64, HEAP_RT_COUNT64, mod_block64),
+ BLOCK_DEF(128, HEAP_RT_COUNT128, mod_block128),
+ BLOCK_DEF(256, HEAP_RT_COUNT256, mod_block256),
+ BLOCK_DEF(512, HEAP_RT_COUNT512, mod_block512),
+ BLOCK_DEF(1024, HEAP_RT_COUNT1024, mod_block1024),
+};
+
+/* Heap blocks for buffers */
+static struct block_hdr buf_block[HEAP_BUFFER_COUNT];
+
+/* Heap memory map for buffers */
+static struct block_map buf_heap_map[] = {
+ BLOCK_DEF(HEAP_BUFFER_BLOCK_SIZE, HEAP_BUFFER_COUNT, buf_block),
+};
+
+struct mm memmap = {
+ .system = {
+ .heap = HEAP_SYSTEM_BASE,
+ .size = HEAP_SYSTEM_SIZE,
+ .info = {.free = HEAP_SYSTEM_SIZE,},
+ .caps = SOF_MEM_CAPS_RAM | SOF_MEM_CAPS_CACHE |
+ SOF_MEM_CAPS_DMA,
+ },
+ .runtime[0] = {
+ .blocks = ARRAY_SIZE(rt_heap_map),
+ .map = rt_heap_map,
+ .heap = HEAP_RUNTIME_BASE,
+ .size = HEAP_RUNTIME_SIZE,
+ .info = {.free = HEAP_RUNTIME_SIZE,},
+ .caps = SOF_MEM_CAPS_RAM | SOF_MEM_CAPS_CACHE |
+ SOF_MEM_CAPS_DMA,
+ },
+ .buffer[0] = {
+ .blocks = ARRAY_SIZE(buf_heap_map),
+ .map = buf_heap_map,
+ .heap = HEAP_BUFFER_BASE,
+ .size = HEAP_BUFFER_SIZE,
+ .info = {.free = HEAP_BUFFER_SIZE,},
+ .caps = SOF_MEM_CAPS_RAM | SOF_MEM_CAPS_CACHE |
+ SOF_MEM_CAPS_DMA,
+ },
+ .total = {.free = HEAP_SYSTEM_SIZE + HEAP_RUNTIME_SIZE +
+ HEAP_BUFFER_SIZE,},
+};
diff --git a/src/platform/cannonlake/Makefile.am b/src/platform/cannonlake/Makefile.am
index 9f3d591..2e9019d 100644
--- a/src/platform/cannonlake/Makefile.am
+++ b/src/platform/cannonlake/Makefile.am
@@ -8,7 +8,8 @@ libplatform_a_SOURCES = \
dma.c \
clk.c \
timer.c \
- interrupt.c
+ interrupt.c \
+ memory.c
libplatform_a_CFLAGS = \
$(ARCH_CFLAGS) \
diff --git a/src/platform/cannonlake/include/platform/memory.h b/src/platform/cannonlake/include/platform/memory.h
index 7e7af82..a341b4f 100644
--- a/src/platform/cannonlake/include/platform/memory.h
+++ b/src/platform/cannonlake/include/platform/memory.h
@@ -219,11 +219,11 @@
#define HP_SRAM_WIN3_BASE SRAM_TRACE_BASE
#define HP_SRAM_WIN3_SIZE SRAM_TRACE_SIZE
-#define HEAP_DMA_BUFFER_BASE (SRAM_TRACE_BASE + SRAM_TRACE_SIZE)
-#define HEAP_DMA_BUFFER_SIZE 0x20000
-#define HEAP_DMA_BUFFER_BLOCK_SIZE 0x180
-#define HEAP_DMA_BUFFER_COUNT \
- (HEAP_DMA_BUFFER_SIZE / HEAP_DMA_BUFFER_BLOCK_SIZE)
+#define HEAP_HP_BUFFER_BASE (SRAM_TRACE_BASE + SRAM_TRACE_SIZE)
+#define HEAP_HP_BUFFER_SIZE 0x20000
+#define HEAP_HP_BUFFER_BLOCK_SIZE 0x180
+#define HEAP_HP_BUFFER_COUNT \
+ (HEAP_HP_BUFFER_SIZE / HEAP_HP_BUFFER_BLOCK_SIZE)
#define REEF_TEXT_BASE (REEF_TEXT_START + REEF_TEXT_START_SIZE)
#define REEF_TEXT_SIZE 0x18000
@@ -315,6 +315,9 @@
#define HEAP_LP_BUFFER_COUNT (HEAP_LP_BUFFER_SIZE / HEAP_LP_BUFFER_BLOCK_SIZE)
+#define PLATFORM_HEAP_RUNTIME 1
+#define PLATFORM_HEAP_BUFFER 3
+
/* Stack configuration */
#define REEF_LP_STACK_SIZE 0x1000
#define REEF_LP_STACK_BASE (LP_SRAM_BASE + LP_SRAM_SIZE)
@@ -335,7 +338,7 @@
#define REEF_MEM_RO_SIZE 0x8
-/* boot loadee in IMR */
+/* boot loader in IMR */
#define IMR_BOOT_LDR_TEXT_ENTRY_BASE 0xB0038000
#define IMR_BOOT_LDR_TEXT_ENTRY_SIZE 0x40
#define IMR_BOOT_LDR_LIT_BASE (IMR_BOOT_LDR_TEXT_ENTRY_BASE + IMR_BOOT_LDR_TEXT_ENTRY_SIZE)
diff --git a/src/platform/cannonlake/memory.c b/src/platform/cannonlake/memory.c
new file mode 100644
index 0000000..16fa600
--- /dev/null
+++ b/src/platform/cannonlake/memory.c
@@ -0,0 +1,119 @@
+/*
+ * Copyright (c) 2018, Intel Corporation
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the Intel Corporation nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Author: Liam Girdwood <liam.r.girdwood(a)linux.intel.com>
+ */
+
+#include <reef/alloc.h>
+
+/* Heap blocks for modules */
+static struct block_hdr mod_block16[HEAP_RT_COUNT16];
+static struct block_hdr mod_block32[HEAP_RT_COUNT32];
+static struct block_hdr mod_block64[HEAP_RT_COUNT64];
+static struct block_hdr mod_block128[HEAP_RT_COUNT128];
+static struct block_hdr mod_block256[HEAP_RT_COUNT256];
+static struct block_hdr mod_block512[HEAP_RT_COUNT512];
+static struct block_hdr mod_block1024[HEAP_RT_COUNT1024];
+
+/* Heap memory map for modules */
+static struct block_map rt_heap_map[] = {
+ BLOCK_DEF(16, HEAP_RT_COUNT16, mod_block16),
+ BLOCK_DEF(32, HEAP_RT_COUNT32, mod_block32),
+ BLOCK_DEF(64, HEAP_RT_COUNT64, mod_block64),
+ BLOCK_DEF(128, HEAP_RT_COUNT128, mod_block128),
+ BLOCK_DEF(256, HEAP_RT_COUNT256, mod_block256),
+ BLOCK_DEF(512, HEAP_RT_COUNT512, mod_block512),
+ BLOCK_DEF(1024, HEAP_RT_COUNT1024, mod_block1024),
+};
+
+/* Heap blocks for buffers */
+static struct block_hdr buf_block[HEAP_BUFFER_COUNT];
+static struct block_hdr hp_buf_block[HEAP_HP_BUFFER_COUNT];
+static struct block_hdr lp_buf_block[HEAP_LP_BUFFER_COUNT];
+
+/* Heap memory map for buffers */
+static struct block_map buf_heap_map[] = {
+ BLOCK_DEF(HEAP_BUFFER_BLOCK_SIZE, HEAP_BUFFER_COUNT, buf_block),
+};
+
+static struct block_map hp_buf_heap_map[] = {
+ BLOCK_DEF(HEAP_HP_BUFFER_BLOCK_SIZE, HEAP_HP_BUFFER_COUNT,
+ hp_buf_block),
+};
+
+static struct block_map lp_buf_heap_map[] = {
+ BLOCK_DEF(HEAP_LP_BUFFER_BLOCK_SIZE, HEAP_LP_BUFFER_COUNT,
+ lp_buf_block),
+};
+
+struct mm memmap = {
+ .system = {
+ .heap = HEAP_SYSTEM_BASE,
+ .size = HEAP_SYSTEM_SIZE,
+ .info = {.free = HEAP_SYSTEM_SIZE,},
+ .caps = SOF_MEM_CAPS_RAM | SOF_MEM_CAPS_CACHE |
+ SOF_MEM_CAPS_HP | SOF_MEM_CAPS_DMA,
+ },
+ .runtime[0] = {
+ .blocks = ARRAY_SIZE(rt_heap_map),
+ .map = rt_heap_map,
+ .heap = HEAP_RUNTIME_BASE,
+ .size = HEAP_RUNTIME_SIZE,
+ .info = {.free = HEAP_RUNTIME_SIZE,},
+ .caps = SOF_MEM_CAPS_RAM | SOF_MEM_CAPS_CACHE |
+ SOF_MEM_CAPS_HP | SOF_MEM_CAPS_DMA,
+ },
+ .buffer[0] = {
+ .blocks = ARRAY_SIZE(buf_heap_map),
+ .map = buf_heap_map,
+ .heap = HEAP_BUFFER_BASE,
+ .size = HEAP_BUFFER_SIZE,
+ .info = {.free = HEAP_BUFFER_SIZE,},
+ .caps = SOF_MEM_CAPS_RAM | SOF_MEM_CAPS_CACHE |
+ SOF_MEM_CAPS_HP | SOF_MEM_CAPS_DMA,
+ },
+ .buffer[1] = {
+ .blocks = ARRAY_SIZE(hp_buf_heap_map),
+ .map = hp_buf_heap_map,
+ .heap = HEAP_HP_BUFFER_BASE,
+ .size = HEAP_HP_BUFFER_SIZE,
+ .info = {.free = HEAP_HP_BUFFER_SIZE,},
+ .caps = SOF_MEM_CAPS_RAM | SOF_MEM_CAPS_HP |
+ SOF_MEM_CAPS_CACHE | SOF_MEM_CAPS_DMA,
+ },
+ .buffer[2] = {
+ .blocks = ARRAY_SIZE(lp_buf_heap_map),
+ .map = lp_buf_heap_map,
+ .heap = HEAP_LP_BUFFER_BASE,
+ .size = HEAP_LP_BUFFER_SIZE,
+ .info = {.free = HEAP_LP_BUFFER_SIZE,},
+ .caps = SOF_MEM_CAPS_RAM | SOF_MEM_CAPS_LP |
+ SOF_MEM_CAPS_CACHE | SOF_MEM_CAPS_DMA,
+ },
+ .total = {.free = HEAP_SYSTEM_SIZE + HEAP_RUNTIME_SIZE +
+ HEAP_BUFFER_SIZE,},
+};
diff --git a/src/platform/haswell/Makefile.am b/src/platform/haswell/Makefile.am
index bf9d40a..c132f53 100644
--- a/src/platform/haswell/Makefile.am
+++ b/src/platform/haswell/Makefile.am
@@ -7,7 +7,8 @@ libplatform_a_SOURCES = \
dai.c \
dma.c \
clk.c \
- timer.c
+ timer.c \
+ memory.c
libplatform_a_CFLAGS = \
$(ARCH_CFLAGS) \
diff --git a/src/platform/haswell/include/platform/memory.h b/src/platform/haswell/include/platform/memory.h
index 83d11a5..f04ef97 100644
--- a/src/platform/haswell/include/platform/memory.h
+++ b/src/platform/haswell/include/platform/memory.h
@@ -124,11 +124,8 @@
#define HEAP_BUFFER_BLOCK_SIZE 0x180
#define HEAP_BUFFER_COUNT (HEAP_BUFFER_SIZE / HEAP_BUFFER_BLOCK_SIZE)
-/* DMA buffer heap is the same physical memory as buffer heap on baytrail */
-#define HEAP_DMA_BUFFER_BASE 0
-#define HEAP_DMA_BUFFER_SIZE 0
-#define HEAP_DMA_BUFFER_BLOCK_SIZE 0
-#define HEAP_DMA_BUFFER_COUNT 0
+#define PLATFORM_HEAP_RUNTIME 1
+#define PLATFORM_HEAP_BUFFER 1
/* Stack configuration */
#define REEF_STACK_SIZE 0x1000
diff --git a/src/platform/haswell/memory.c b/src/platform/haswell/memory.c
new file mode 100644
index 0000000..12e7399
--- /dev/null
+++ b/src/platform/haswell/memory.c
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2018, Intel Corporation
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the Intel Corporation nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Author: Liam Girdwood <liam.r.girdwood(a)linux.intel.com>
+ */
+
+#include <reef/alloc.h>
+
+/* Heap blocks for modules */
+static struct block_hdr mod_block16[HEAP_RT_COUNT16];
+static struct block_hdr mod_block32[HEAP_RT_COUNT32];
+static struct block_hdr mod_block64[HEAP_RT_COUNT64];
+static struct block_hdr mod_block128[HEAP_RT_COUNT128];
+static struct block_hdr mod_block256[HEAP_RT_COUNT256];
+static struct block_hdr mod_block512[HEAP_RT_COUNT512];
+static struct block_hdr mod_block1024[HEAP_RT_COUNT1024];
+
+/* Heap memory map for modules */
+static struct block_map rt_heap_map[] = {
+ BLOCK_DEF(16, HEAP_RT_COUNT16, mod_block16),
+ BLOCK_DEF(32, HEAP_RT_COUNT32, mod_block32),
+ BLOCK_DEF(64, HEAP_RT_COUNT64, mod_block64),
+ BLOCK_DEF(128, HEAP_RT_COUNT128, mod_block128),
+ BLOCK_DEF(256, HEAP_RT_COUNT256, mod_block256),
+ BLOCK_DEF(512, HEAP_RT_COUNT512, mod_block512),
+ BLOCK_DEF(1024, HEAP_RT_COUNT1024, mod_block1024),
+};
+
+/* Heap blocks for buffers */
+static struct block_hdr buf_block[HEAP_BUFFER_COUNT];
+
+/* Heap memory map for buffers */
+static struct block_map buf_heap_map[] = {
+ BLOCK_DEF(HEAP_BUFFER_BLOCK_SIZE, HEAP_BUFFER_COUNT, buf_block),
+};
+
+struct mm memmap = {
+ .system = {
+ .heap = HEAP_SYSTEM_BASE,
+ .size = HEAP_SYSTEM_SIZE,
+ .info = {.free = HEAP_SYSTEM_SIZE,},
+ .caps = SOF_MEM_CAPS_RAM | SOF_MEM_CAPS_CACHE |
+ SOF_MEM_CAPS_DMA,
+ },
+ .runtime[0] = {
+ .blocks = ARRAY_SIZE(rt_heap_map),
+ .map = rt_heap_map,
+ .heap = HEAP_RUNTIME_BASE,
+ .size = HEAP_RUNTIME_SIZE,
+ .info = {.free = HEAP_RUNTIME_SIZE,},
+ .caps = SOF_MEM_CAPS_RAM | SOF_MEM_CAPS_CACHE |
+ SOF_MEM_CAPS_DMA,
+ },
+ .buffer[0] = {
+ .blocks = ARRAY_SIZE(buf_heap_map),
+ .map = buf_heap_map,
+ .heap = HEAP_BUFFER_BASE,
+ .size = HEAP_BUFFER_SIZE,
+ .info = {.free = HEAP_BUFFER_SIZE,},
+ .caps = SOF_MEM_CAPS_RAM | SOF_MEM_CAPS_CACHE |
+ SOF_MEM_CAPS_DMA,
+ },
+ .total = {.free = HEAP_SYSTEM_SIZE + HEAP_RUNTIME_SIZE +
+ HEAP_BUFFER_SIZE,},
+};
--
2.14.1
1
0
01 Mar '18
In irq function, two dma would be checked which one is
the interrupted one, so get it after check.
Signed-off-by: Rander Wang <rander.wang(a)intel.com>
---
src/drivers/dw-dma.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/drivers/dw-dma.c b/src/drivers/dw-dma.c
index be19e12..6fd46e0 100644
--- a/src/drivers/dw-dma.c
+++ b/src/drivers/dw-dma.c
@@ -1034,7 +1034,7 @@ static int dw_dma_probe(struct dma *dma)
static void dw_dma_irq_handler(void *data)
{
struct dma *dma = (struct dma *)data;
- struct dma_pdata *p = dma_get_drvdata(dma);
+ struct dma_pdata *p;
struct dma_sg_elem next;
uint32_t status_tfr = 0;
uint32_t status_block = 0;
@@ -1058,6 +1058,7 @@ static void dw_dma_irq_handler(void *data)
}
tracev_dma("DIr");
+ p = dma_get_drvdata(dma);
/* get the source of our IRQ. */
status_block = dw_read(dma, DW_STATUS_BLOCK);
--
2.14.1
3
3