• Clemens Ladisch's avatar
    [PATCH] HPET: make frequency calculations 32 bit safe · ba3f213f
    Clemens Ladisch authored
    On 32-bit architectures, the multiplication in the argument for
    hpet_time_div() often overflows.  In the typical case of a 14.32 MHz timer,
    this happens when the desired frequency exceeds 61 Hz.
    
    To avoid this multiplication, we can precompute and store the hardware
    timer frequency, instead of the period, in the device structure, which
    leaves us with a simple division when computing the number of timer ticks.
    
    As a side effect, this also removes a theoretical bug where the timer
    interpolator's frequency would be computed as a 32-bit value even if the
    HPET frequency is greater than 2^32 Hz (the HPET spec allows up to 10 GHz).
    Signed-off-by: default avatarClemens Ladisch <clemens@ladisch.de>
    Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
    ba3f213f
hpet.c 21.2 KB