#define _ASM_POWERPC_DELAY_H
 #ifdef __KERNEL__
 
+#include <linux/processor.h>
 #include <asm/time.h>
 
 /*
        typeof(condition) __ret;                                               \
        unsigned long __loops = tb_ticks_per_usec * timeout;                   \
        unsigned long __start = get_tbl();                                     \
-       while (!(__ret = (condition)) && (tb_ticks_since(__start) <= __loops)) \
-               if (delay)                                                     \
+                                                                               \
+       if (delay) {                                                           \
+               while (!(__ret = (condition)) &&                               \
+                               (tb_ticks_since(__start) <= __loops))          \
                        udelay(delay);                                         \
-               else                                                           \
-                       cpu_relax();                                           \
+       } else {                                                               \
+               spin_begin();                                                  \
+               while (!(__ret = (condition)) &&                               \
+                               (tb_ticks_since(__start) <= __loops))          \
+                       spin_cpu_relax();                                      \
+               spin_end();                                                    \
+       }                                                                      \
        if (!__ret)                                                            \
                __ret = (condition);                                           \
        __ret;                                                                 \
 
 #include <linux/notifier.h>
 #include <linux/topology.h>
 #include <linux/profile.h>
+#include <linux/processor.h>
 
 #include <asm/ptrace.h>
 #include <linux/atomic.h>
                smp_ops->give_timebase();
 
        /* Wait until cpu puts itself in the online & active maps */
-       while (!cpu_online(cpu))
-               cpu_relax();
+       spin_until_cond(cpu_online(cpu));
 
        return 0;
 }
 
 #include <linux/suspend.h>
 #include <linux/rtc.h>
 #include <linux/sched/cputime.h>
+#include <linux/processor.h>
 #include <asm/trace.h>
 
 #include <asm/io.h>
-#include <asm/processor.h>
 #include <asm/nvram.h>
 #include <asm/cache.h>
 #include <asm/machdep.h>
        unsigned long start;
        int diff;
 
+       spin_begin();
        if (__USE_RTC()) {
                start = get_rtcl();
                do {
                        diff = get_rtcl() - start;
                        if (diff < 0)
                                diff += 1000000000;
+                       spin_cpu_relax();
                } while (diff < loops);
        } else {
                start = get_tbl();
                while (get_tbl() - start < loops)
-                       HMT_low();
-               HMT_medium();
+                       spin_cpu_relax();
        }
+       spin_end();
 }
 EXPORT_SYMBOL(__delay);
 
 
 #include <linux/spinlock.h>
 #include <linux/bitops.h>
 #include <linux/of.h>
+#include <linux/processor.h>
 #include <linux/threads.h>
 #include <linux/smp.h>
 
        while (1) {
                if (!test_and_set_bit_lock(HPTE_LOCK_BIT, word))
                        break;
+               spin_begin();
                while(test_bit(HPTE_LOCK_BIT, word))
-                       cpu_relax();
+                       spin_cpu_relax();
+               spin_end();
        }
 }