There is no point to loop for 200k TSC cycles to check afterwards whether
the HPET counter is working. Read the counter inside of the loop and break
out when the counter value changed.

Signed-off-by: Thomas Gleixner <[email protected]>
---
 arch/x86/kernel/hpet.c |   10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

--- a/arch/x86/kernel/hpet.c
+++ b/arch/x86/kernel/hpet.c
@@ -853,15 +853,13 @@ static bool __init hpet_counting(void)
         * 1 GHz == 200us
         */
        do {
-               rep_nop();
+               if (t1 != hpet_readl(HPET_COUNTER))
+                       return true;
                now = rdtsc();
        } while ((now - start) < 200000UL);
 
-       if (t1 == hpet_readl(HPET_COUNTER)) {
-               pr_warn("Counter not counting. HPET disabled\n");
-               return false;
-       }
-       return true;
+       pr_warn("Counter not counting. HPET disabled\n");
+       return false;
 }
 
 /**


Reply via email to