@@ -2925,11 +2925,15 @@ static int deassert_reset(struct target *target)
29252925 return ERROR_OK ;
29262926}
29272927
2928- static int execute_fence (struct target * target )
2928+ static int execute_autofence (struct target * target )
29292929{
29302930 if (dm013_select_target (target ) != ERROR_OK )
29312931 return ERROR_FAIL ;
29322932
2933+ RISCV_INFO (r );
2934+ if (!r -> autofence )
2935+ return ERROR_OK ;
2936+
29332937 /* FIXME: For non-coherent systems we need to flush the caches right
29342938 * here, but there's no ISA-defined way of doing that. */
29352939 struct riscv_program program ;
@@ -2951,8 +2955,9 @@ static int execute_fence(struct target *target)
29512955 LOG_TARGET_ERROR (target , "Unexpected error during fence execution" );
29522956 return ERROR_FAIL ;
29532957 }
2954- LOG_TARGET_DEBUG (target , "Unable to execute fence" );
2958+ LOG_TARGET_DEBUG (target , "Unable to execute fence.i and fence rw, rw " );
29552959 }
2960+ LOG_TARGET_DEBUG (target , "Successfully executed fence.i and fence rw, rw" );
29562961 return ERROR_OK ;
29572962 }
29582963
@@ -2966,6 +2971,7 @@ static int execute_fence(struct target *target)
29662971 }
29672972 LOG_TARGET_DEBUG (target , "Unable to execute fence.i" );
29682973 }
2974+ LOG_TARGET_DEBUG (target , "Successfully executed fence.i" );
29692975
29702976 riscv_program_init (& program , target );
29712977 riscv_program_fence_rw_rw (& program );
@@ -2976,6 +2982,7 @@ static int execute_fence(struct target *target)
29762982 }
29772983 LOG_TARGET_DEBUG (target , "Unable to execute fence rw, rw" );
29782984 }
2985+ LOG_TARGET_DEBUG (target , "Successfully executed fence rw, rw" );
29792986 return ERROR_OK ;
29802987 }
29812988
@@ -4285,7 +4292,7 @@ read_memory_progbuf(struct target *target, target_addr_t address,
42854292
42864293 memset (buffer , 0 , count * size );
42874294
4288- if (execute_fence (target ) != ERROR_OK )
4295+ if (execute_autofence (target ) != ERROR_OK )
42894296 return MEM_ACCESS_SKIPPED_FENCE_EXEC_FAILED ;
42904297
42914298 uint64_t mstatus = 0 ;
@@ -4876,7 +4883,7 @@ write_memory_progbuf(struct target *target, target_addr_t address,
48764883 if (register_write_direct (target , GDB_REGNO_MSTATUS , mstatus_old ))
48774884 return MEM_ACCESS_FAILED ;
48784885
4879- if (execute_fence (target ) != ERROR_OK )
4886+ if (execute_autofence (target ) != ERROR_OK )
48804887 return MEM_ACCESS_SKIPPED_FENCE_EXEC_FAILED ;
48814888
48824889 return result == ERROR_OK ? MEM_ACCESS_OK : MEM_ACCESS_FAILED ;
@@ -5363,18 +5370,12 @@ static int riscv013_get_dmi_scan_length(struct target *target)
53635370 return info -> abits + DTM_DMI_DATA_LENGTH + DTM_DMI_OP_LENGTH ;
53645371}
53655372
5366- static int maybe_execute_fence_i (struct target * target )
5367- {
5368- if (has_sufficient_progbuf (target , 2 ))
5369- return execute_fence (target );
5370- return ERROR_OK ;
5371- }
5372-
53735373/* Helper Functions. */
53745374static int riscv013_on_step_or_resume (struct target * target , bool step )
53755375{
5376- if (maybe_execute_fence_i (target ) != ERROR_OK )
5377- return ERROR_FAIL ;
5376+ if (has_sufficient_progbuf (target , 2 ))
5377+ if (execute_autofence (target ) != ERROR_OK )
5378+ return ERROR_FAIL ;
53785379
53795380 if (set_dcsr_ebreak (target , step ) != ERROR_OK )
53805381 return ERROR_FAIL ;
0 commit comments