@@ -734,23 +734,25 @@ void acl_read_program_hostpipe(void *user_data, acl_device_op_t *op) {
734
734
unsigned valid_value;
735
735
unsigned *valid_value_pointer = &valid_value;
736
736
737
- // start the CSR read
738
-
739
- // If Blocking, wait until the data is valid.
740
- // If Non-blocking, just read once and report failure if not valid.
741
- do {
742
- acl_get_hal ()->read_csr (host_pipe_info.m_physical_device_id , valid_reg,
743
- (void *)valid_value_pointer,
744
- (size_t )sizeof (uintptr_t ));
745
- } while (blocking && valid_value != 1 );
737
+ // protocol 3 is the avalon_mm_uses_ready protocol
738
+ // Only this uses_ready protocol requirs reading/writing to ready&valid signals
739
+ if (host_pipe_info.protocol == 3 ){
740
+ // If Blocking, wait until the data is valid.
741
+ // If Non-blocking, just read once and report failure if not valid.
742
+ do {
743
+ acl_get_hal ()->read_csr (host_pipe_info.m_physical_device_id , valid_reg,
744
+ (void *)valid_value_pointer,
745
+ (size_t )sizeof (uintptr_t ));
746
+ } while (blocking && valid_value != 1 );
746
747
747
- // If non-blocking and valid bit is not set, set the op to fail.
748
- if (!blocking && valid_value == 0 ) {
749
- acl_mutex_unlock (&(host_pipe_info.m_lock ));
750
- acl_set_device_op_execution_status (op, -1 );
751
- return ;
748
+ // If non-blocking and valid bit is not set, set the op to fail.
749
+ if (!blocking && valid_value == 0 ) {
750
+ acl_mutex_unlock (&(host_pipe_info.m_lock ));
751
+ acl_set_device_op_execution_status (op, -1 );
752
+ return ;
753
+ }
752
754
}
753
-
755
+ // start the CSR read
754
756
auto status =
755
757
acl_get_hal ()->read_csr (host_pipe_info.m_physical_device_id , data_reg,
756
758
event->cmd .info .host_pipe_info .ptr ,
@@ -761,8 +763,11 @@ void acl_read_program_hostpipe(void *user_data, acl_device_op_t *op) {
761
763
return ;
762
764
}
763
765
// Tell CSR it's ready
764
- acl_get_hal ()->write_csr (host_pipe_info.m_physical_device_id , ready_reg,
765
- (void *)&ready, (size_t )sizeof (uintptr_t ));
766
+ // Same reason as above, only avalon_mm_uses_ready needs to do this.
767
+ if (host_pipe_info.protocol == 3 ){
768
+ acl_get_hal ()->write_csr (host_pipe_info.m_physical_device_id , ready_reg,
769
+ (void *)&ready, (size_t )sizeof (uintptr_t ));
770
+ }
766
771
} else {
767
772
// Non CSR Case
768
773
pulled_data = acl_get_hal ()->hostchannel_pull (
@@ -845,7 +850,8 @@ void acl_write_program_hostpipe(void *user_data, acl_device_op_t *op) {
845
850
}
846
851
847
852
// In non-blocking case, there is no need to write into valid register.
848
- if (blocking) {
853
+ // We only cars about valid register if the protocol is avalon_mm_uses_ready.
854
+ if (blocking && host_pipe_info.protocol == 3 ) {
849
855
// Tell CSR it's valid
850
856
acl_get_hal ()->write_csr (host_pipe_info.m_physical_device_id , valid_reg,
851
857
(void *)&valid, (size_t )sizeof (uintptr_t ));
0 commit comments