@@ -652,13 +652,9 @@ int sbi_dbtr_enable_trig(unsigned long trig_idx_base,
652652}
653653
654654int sbi_dbtr_update_trig (unsigned long smode ,
655- unsigned long trig_idx_base ,
656- unsigned long trig_idx_mask )
655+ unsigned long trig_count )
657656{
658- unsigned long trig_mask = trig_idx_mask << trig_idx_base ;
659- unsigned long idx = trig_idx_base ;
660- struct sbi_dbtr_data_msg * recv ;
661- unsigned long uidx = 0 ;
657+ unsigned long trig_idx ;
662658 struct sbi_dbtr_trigger * trig ;
663659 union sbi_dbtr_shmem_entry * entry ;
664660 void * shmem_base = NULL ;
@@ -673,18 +669,28 @@ int sbi_dbtr_update_trig(unsigned long smode,
673669
674670 shmem_base = hart_shmem_base (hs );
675671
676- for_each_set_bit_from ( idx , & trig_mask , hs -> total_trigs ) {
677- trig = INDEX_TO_TRIGGER ( idx ) ;
672+ if ( trig_count >= hs -> total_trigs )
673+ return SBI_ERR_BAD_RANGE ;
678674
679- if (!(trig -> state & RV_DBTR_BIT_MASK (TS , MAPPED )))
675+ for_each_trig_entry (shmem_base , trig_count , typeof (* entry ), entry ) {
676+ sbi_hart_map_saddr ((unsigned long )entry , sizeof (* entry ));
677+ trig_idx = entry -> id .idx ;
678+
679+ if (trig_idx >= hs -> total_trigs ) {
680+ sbi_hart_unmap_saddr ();
680681 return SBI_ERR_INVALID_PARAM ;
682+ }
683+
684+ trig = INDEX_TO_TRIGGER (trig_idx );
681685
682- entry = (shmem_base + uidx * sizeof (* entry ));
683- recv = & entry -> data ;
686+ if (!(trig -> state & RV_DBTR_BIT_MASK (TS , MAPPED ))) {
687+ sbi_hart_unmap_saddr ();
688+ return SBI_ERR_FAILED ;
689+ }
684690
685- trig -> tdata2 = lle_to_cpu (recv -> tdata2 );
691+ dbtr_trigger_setup (trig , & entry -> data );
692+ sbi_hart_unmap_saddr ();
686693 dbtr_trigger_enable (trig );
687- uidx ++ ;
688694 }
689695
690696 return SBI_SUCCESS ;
0 commit comments