diff --git a/sys/arm/arm/generic_timer.c b/sys/arm/arm/generic_timer.c --- a/sys/arm/arm/generic_timer.c +++ b/sys/arm/arm/generic_timer.c @@ -60,6 +60,7 @@ #if defined(__aarch64__) #include +#include #endif #ifdef FDT @@ -839,23 +840,30 @@ void DELAY(int usec) { + uint64_t isar2; int32_t counts; TSENTER(); - /* - * Check the timers are setup, if not just - * use a for loop for the meantime - */ - if (arm_tmr_sc == NULL) { - for (; usec > 0; usec--) - for (counts = 200; counts > 0; counts--) - /* - * Prevent the compiler from optimizing - * out the loop - */ - cpufunc_nullop(); - } else - arm_tmr_do_delay(usec, arm_tmr_sc); + /* Check if feat_wfxt is available */ + isar2 = READ_SPECIALREG(id_aa64isar2_el1); + if (ID_AA64ISAR2_WFxT_VAL(isar2) >> ID_AA64ISAR2_WFxT_SHIFT) { + wfet(usec); + } else { + /* + * Check the timers are setup, if not just + * use a for loop for the meantime + */ + if (arm_tmr_sc == NULL) { + for (; usec > 0; usec--) + for (counts = 200; counts > 0; counts--) + /* + * Prevent the compiler from optimizing + * out the loop + */ + cpufunc_nullop(); + } else + arm_tmr_do_delay(usec, arm_tmr_sc); + } TSEXIT(); } #endif