Skip to content

Commit af2c4d5

Browse files
authored
Merge pull request #450 from tlauda/topic/smp-ppl-fix-cache
pipeline: cache fixes for multicore processing
2 parents 7aa627a + f35c9d9 commit af2c4d5

11 files changed

Lines changed: 52 additions & 78 deletions

File tree

src/audio/dai.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -765,11 +765,7 @@ static void dai_cache(struct comp_dev *dev, int cmd)
765765
}
766766

767767
dcache_writeback_invalidate_region(dd->dai, sizeof(*dd->dai));
768-
dcache_writeback_invalidate_region(dd->dai->private,
769-
dd->dai->private_size);
770768
dcache_writeback_invalidate_region(dd->dma, sizeof(*dd->dma));
771-
dcache_writeback_invalidate_region(dd->dma->private,
772-
dd->dma->private_size);
773769
dcache_writeback_invalidate_region(dd, sizeof(*dd));
774770
dcache_writeback_invalidate_region(dev, sizeof(*dev));
775771
break;
@@ -782,11 +778,7 @@ static void dai_cache(struct comp_dev *dev, int cmd)
782778
dd = comp_get_drvdata(dev);
783779
dcache_invalidate_region(dd, sizeof(*dd));
784780
dcache_invalidate_region(dd->dma, sizeof(*dd->dma));
785-
dcache_invalidate_region(dd->dma->private,
786-
dd->dma->private_size);
787781
dcache_invalidate_region(dd->dai, sizeof(*dd->dai));
788-
dcache_invalidate_region(dd->dai->private,
789-
dd->dai->private_size);
790782

791783
list_for_item(item, &dd->config.elem_list) {
792784
dcache_invalidate_region(item, sizeof(*item));

src/audio/host.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -786,8 +786,6 @@ static void host_cache(struct comp_dev *dev, int cmd)
786786
#endif
787787

788788
dcache_writeback_invalidate_region(hd->dma, sizeof(*hd->dma));
789-
dcache_writeback_invalidate_region(hd->dma->private,
790-
hd->dma->private_size);
791789
dcache_writeback_invalidate_region(hd, sizeof(*hd));
792790
dcache_writeback_invalidate_region(dev, sizeof(*dev));
793791
break;
@@ -800,8 +798,6 @@ static void host_cache(struct comp_dev *dev, int cmd)
800798
hd = comp_get_drvdata(dev);
801799
dcache_invalidate_region(hd, sizeof(*hd));
802800
dcache_invalidate_region(hd->dma, sizeof(*hd->dma));
803-
dcache_invalidate_region(hd->dma->private,
804-
hd->dma->private_size);
805801

806802
#if !defined CONFIG_DMA_GW
807803
list_for_item(item, &hd->local.elem_list) {

src/audio/pipeline.c

Lines changed: 38 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -397,11 +397,8 @@ static int component_op_downstream(struct op_data *op_data,
397397
/* component should reset and free resources */
398398
err = comp_reset(current);
399399
break;
400-
case COMP_OPS_CACHE:
401-
/* cache operation */
402-
comp_cache(current, op_data->cmd);
403-
break;
404400
case COMP_OPS_BUFFER: /* handled by other API call */
401+
case COMP_OPS_CACHE:
405402
default:
406403
trace_pipe_error("eOi");
407404
trace_error_value(op_data->op);
@@ -482,11 +479,8 @@ static int component_op_upstream(struct op_data *op_data,
482479
/* component should reset and free resources */
483480
err = comp_reset(current);
484481
break;
485-
case COMP_OPS_CACHE:
486-
/* cache operation */
487-
comp_cache(current, op_data->cmd);
488-
break;
489482
case COMP_OPS_BUFFER: /* handled by other API call */
483+
case COMP_OPS_CACHE:
490484
default:
491485
trace_pipe_error("eOi");
492486
trace_error_value(op_data->op);
@@ -639,89 +633,79 @@ int pipeline_prepare(struct pipeline *p, struct comp_dev *dev)
639633
return ret;
640634
}
641635

642-
static void component_cache_buffers_downstream(struct comp_dev *start,
643-
struct comp_dev *current,
644-
struct comp_buffer *buffer,
645-
cache_command cache_cmd)
636+
static void component_cache_downstream(int cmd, struct comp_dev *start,
637+
struct comp_dev *current,
638+
struct comp_dev *previous)
646639
{
640+
cache_command cache_cmd = comp_get_cache_command(cmd);
647641
struct list_item *clist;
642+
struct comp_buffer *buffer;
648643

649-
if (current != start && buffer) {
650-
cache_cmd(buffer, sizeof(*buffer));
644+
comp_cache(current, cmd);
651645

652-
/* stop if we reach an endpoint */
653-
if (current->is_endpoint)
654-
return;
655-
}
646+
/* we finish walking the graph if we reach the DAI */
647+
if (current != start && current->is_endpoint)
648+
return;
656649

657-
/* travel further */
650+
/* now run this operation downstream */
658651
list_for_item(clist, &current->bsink_list) {
659652
buffer = container_of(clist, struct comp_buffer, source_list);
660653

661-
/* stop going if this component is not connected */
654+
if (cache_cmd)
655+
cache_cmd(buffer, sizeof(*buffer));
656+
657+
/* don't go downstream if this component is not connected */
662658
if (!buffer->connected)
663659
continue;
664660

665-
component_cache_buffers_downstream(start, buffer->sink,
666-
buffer, cache_cmd);
661+
component_cache_downstream(cmd, start, buffer->sink, current);
667662
}
668663
}
669664

670-
static void component_cache_buffers_upstream(struct comp_dev *start,
671-
struct comp_dev *current,
672-
struct comp_buffer *buffer,
673-
cache_command cache_cmd)
665+
static void component_cache_upstream(int cmd, struct comp_dev *start,
666+
struct comp_dev *current,
667+
struct comp_dev *previous)
674668
{
669+
cache_command cache_cmd = comp_get_cache_command(cmd);
675670
struct list_item *clist;
671+
struct comp_buffer *buffer;
676672

677-
if (current != start && buffer) {
678-
cache_cmd(buffer, sizeof(*buffer));
673+
comp_cache(current, cmd);
679674

680-
/* stop if we reach an endpoint */
681-
if (current->is_endpoint)
682-
return;
683-
}
675+
/* we finish walking the graph if we reach the DAI */
676+
if (current != start && current->is_endpoint)
677+
return;
684678

685-
/* travel further */
679+
/* now run this operation upstream */
686680
list_for_item(clist, &current->bsource_list) {
687681
buffer = container_of(clist, struct comp_buffer, sink_list);
688682

689-
/* stop going if this component is not connected */
683+
if (cache_cmd)
684+
cache_cmd(buffer, sizeof(*buffer));
685+
686+
/* don't go upstream if this component is not connected */
690687
if (!buffer->connected)
691688
continue;
692689

693-
component_cache_buffers_upstream(start, buffer->source,
694-
buffer, cache_cmd);
690+
component_cache_upstream(cmd, start, buffer->source, current);
695691
}
696692
}
697693

698694
void pipeline_cache(struct pipeline *p, struct comp_dev *dev, int cmd)
699695
{
700696
cache_command cache_cmd = comp_get_cache_command(cmd);
701-
struct op_data op_data;
702697
uint32_t flags;
703698

704699
trace_pipe("cac");
705700

706-
op_data.p = p;
707-
op_data.op = COMP_OPS_CACHE;
708-
op_data.cmd = cmd;
709-
710701
spin_lock_irq(&p->lock, flags);
711702

712-
if (dev->params.direction == SOF_IPC_STREAM_PLAYBACK) {
713-
/* execute cache operation on components downstream */
714-
component_op_downstream(&op_data, dev, dev, NULL);
715-
716-
/* execute cache operation on buffers downstream */
717-
component_cache_buffers_downstream(dev, dev, NULL, cache_cmd);
718-
} else {
719-
/* execute cache operation on components upstream */
720-
component_op_upstream(&op_data, dev, dev, NULL);
721-
722-
/* execute cache operation on buffers upstream */
723-
component_cache_buffers_upstream(dev, dev, NULL, cache_cmd);
724-
}
703+
if (dev->params.direction == SOF_IPC_STREAM_PLAYBACK)
704+
/* execute cache op on components and buffers downstream */
705+
component_cache_downstream(cmd, dev, dev, NULL);
706+
else
707+
/* execute cache op on components and buffers upstream */
708+
component_cache_upstream(cmd, dev, dev, NULL);
725709

726710
/* execute cache operation on pipeline itself */
727711
if (cache_cmd)

src/drivers/intel/baytrail/ssp.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,8 @@ static int ssp_probe(struct dai *dai)
603603
struct ssp_pdata *ssp;
604604

605605
/* allocate private data */
606-
ssp = rzalloc(RZONE_SYS, SOF_MEM_CAPS_RAM, sizeof(*ssp));
606+
ssp = rzalloc(RZONE_SYS | RZONE_FLAG_UNCACHED, SOF_MEM_CAPS_RAM,
607+
sizeof(*ssp));
607608
dai_set_drvdata(dai, ssp);
608609

609610
spinlock_init(&ssp->lock);

src/drivers/intel/cavs/dmic.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1447,7 +1447,8 @@ static int dmic_probe(struct dai *dai)
14471447
trace_dmic("pro");
14481448

14491449
/* allocate private data */
1450-
dmic = rzalloc(RZONE_SYS, SOF_MEM_CAPS_RAM, sizeof(*dmic));
1450+
dmic = rzalloc(RZONE_SYS | RZONE_FLAG_UNCACHED, SOF_MEM_CAPS_RAM,
1451+
sizeof(*dmic));
14511452
if (!dmic) {
14521453
trace_dmic_error("eap");
14531454
return -ENOMEM;

src/drivers/intel/cavs/hda-dma.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,8 @@ static int hda_dma_probe(struct dma *dma)
613613
struct hda_chan_data *chan;
614614

615615
/* allocate private data */
616-
hda_pdata = rzalloc(RZONE_SYS, SOF_MEM_CAPS_RAM, sizeof(*hda_pdata));
616+
hda_pdata = rzalloc(RZONE_SYS | RZONE_FLAG_UNCACHED, SOF_MEM_CAPS_RAM,
617+
sizeof(*hda_pdata));
617618
dma_set_drvdata(dma, hda_pdata);
618619

619620
spinlock_init(&dma->lock);

src/drivers/intel/cavs/ssp.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -872,7 +872,8 @@ static int ssp_probe(struct dai *dai)
872872
struct ssp_pdata *ssp;
873873

874874
/* allocate private data */
875-
ssp = rzalloc(RZONE_SYS, SOF_MEM_CAPS_RAM, sizeof(*ssp));
875+
ssp = rzalloc(RZONE_SYS | RZONE_FLAG_UNCACHED, SOF_MEM_CAPS_RAM,
876+
sizeof(*ssp));
876877
dai_set_drvdata(dai, ssp);
877878

878879
spinlock_init(&ssp->lock);

src/drivers/intel/dw-dma.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1113,7 +1113,8 @@ static int dw_dma_probe(struct dma *dma)
11131113
int i;
11141114

11151115
/* allocate private data */
1116-
dw_pdata = rzalloc(RZONE_SYS, SOF_MEM_CAPS_RAM, sizeof(*dw_pdata));
1116+
dw_pdata = rzalloc(RZONE_SYS | RZONE_FLAG_UNCACHED, SOF_MEM_CAPS_RAM,
1117+
sizeof(*dw_pdata));
11171118
dma_set_drvdata(dma, dw_pdata);
11181119

11191120
spinlock_init(&dma->lock);

src/drivers/intel/haswell/ssp.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,8 @@ static int ssp_probe(struct dai *dai)
500500
struct ssp_pdata *ssp;
501501

502502
/* allocate private data */
503-
ssp = rzalloc(RZONE_SYS, SOF_MEM_CAPS_RAM, sizeof(*ssp));
503+
ssp = rzalloc(RZONE_SYS | RZONE_FLAG_UNCACHED, SOF_MEM_CAPS_RAM,
504+
sizeof(*ssp));
504505
dai_set_drvdata(dai, ssp);
505506

506507
spinlock_init(&ssp->lock);

src/include/sof/dai.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@ struct dai {
122122
struct dai_plat_data plat_data;
123123
const struct dai_ops *ops;
124124
void *private;
125-
uint32_t private_size;
126125
};
127126

128127
/**
@@ -153,8 +152,7 @@ void dai_install(struct dai_type_info *dai_type_array, size_t num_dai_types);
153152
struct dai *dai_get(uint32_t type, uint32_t index);
154153

155154
#define dai_set_drvdata(dai, data) \
156-
dai->private = data; \
157-
dai->private_size = sizeof(*data)
155+
dai->private = data;
158156
#define dai_get_drvdata(dai) \
159157
dai->private;
160158
#define dai_base(dai) \

0 commit comments

Comments
 (0)