@@ -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
698694void 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 )
0 commit comments