[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[xen master] x86/time: minor adjustments to init_pit()



commit 5e73b2594c540400d8d8510a7e38ab52cc69b243
Author:     Jan Beulich <jbeulich@xxxxxxxx>
AuthorDate: Mon Jan 24 08:40:59 2022 +0100
Commit:     Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Mon Jan 24 08:40:59 2022 +0100

    x86/time: minor adjustments to init_pit()
    
    For one, "using_pit" shouldn't be set ahead of the function's last
    (for now: only) error path. Otherwise "clocksource=pit" on the command
    line can lead to misbehavior when actually taking that error path.
    
    And then make an implicit assumption explicit: CALIBRATE_FRAC cannot,
    for example, simply be changed to 10. The way init_pit() works, the
    upper bound on the calibration period is about 54ms.
    
    Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
    Acked-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
---
 xen/arch/x86/time.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/xen/arch/x86/time.c b/xen/arch/x86/time.c
index 1daff92dca..7fb760cf55 100644
--- a/xen/arch/x86/time.c
+++ b/xen/arch/x86/time.c
@@ -333,8 +333,6 @@ static s64 __init init_pit(struct platform_timesource *pts)
     u64 start, end;
     unsigned long count;
 
-    using_pit = true;
-
     /* Set the Gate high, disable speaker. */
     outb((portb & ~0x02) | 0x01, 0x61);
 
@@ -344,6 +342,7 @@ static s64 __init init_pit(struct platform_timesource *pts)
      * (LSB and MSB) to begin countdown.
      */
 #define CALIBRATE_LATCH CALIBRATE_VALUE(CLOCK_TICK_RATE)
+    BUILD_BUG_ON(CALIBRATE_LATCH >> 16);
     outb(0xb0, PIT_MODE);                  /* binary, mode 0, LSB/MSB, Ch 2 */
     outb(CALIBRATE_LATCH & 0xff, PIT_CH2); /* LSB of count */
     outb(CALIBRATE_LATCH >> 8, PIT_CH2);   /* MSB of count */
@@ -361,6 +360,8 @@ static s64 __init init_pit(struct platform_timesource *pts)
     if ( count == 0 )
         return 0;
 
+    using_pit = true;
+
     return (end - start) * CALIBRATE_FRAC;
 }
 
--
generated by git-patchbot for /home/xen/git/xen.git#master



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.