@@ -599,6 +599,7 @@ static void wait_for_subcore_threads(void)
{
uint64_t timeout = 0;
+ smt_lowest();
while (!(*(this_cpu()->core_hmi_state_ptr) & HMI_STATE_CLEANUP_DONE)) {
/*
* We use a fixed number of TIMEOUT_LOOPS rather
@@ -616,8 +617,9 @@ static void wait_for_subcore_threads(void)
prlog(PR_DEBUG, "HMI: TB pre-recovery timeout\n");
break;
}
- cpu_relax();
+ barrier();
}
+ smt_medium();
}
/*
@@ -93,7 +93,10 @@ void lock(struct lock *l)
for (;;) {
if (try_lock(l))
break;
- cpu_relax();
+ smt_lowest();
+ while (l->lock_val)
+ barrier();
+ smt_medium();
}
}
@@ -45,7 +45,10 @@ static void __sync_timer(struct timer *t)
while (t->running) {
unlock(&timer_lock);
- cpu_relax();
+ smt_lowest();
+ while (t->running)
+ barrier();
+ smt_medium();
/* Should we call the pollers here ? */
lock(&timer_lock);
}
@@ -115,10 +115,14 @@ static void uart_check_tx_room(void)
static void uart_wait_tx_room(void)
{
- while(!tx_room) {
+ while (!tx_room) {
uart_check_tx_room();
- if (!tx_room)
- cpu_relax();
+ if (!tx_room) {
+ smt_lowest();
+ while (!tx_room)
+ barrier();
+ smt_medium();
+ }
}
}
The pattern of calling cpu_relax() inside a polling loop does not suit the powerpc SMT priority instructions. Prefrred is to set a low priority then spin until break condition is reached, then restore priority. Signed-off-by: Nicholas Piggin <npiggin@gmail.com> --- core/hmi.c | 4 +++- core/lock.c | 5 ++++- core/timer.c | 5 ++++- hw/lpc-uart.c | 10 +++++++--- 4 files changed, 18 insertions(+), 6 deletions(-)