• Arthur Kiyanovski's avatar
    net: ena: fix uses of round_jiffies() · 2a6e5fa2
    Arthur Kiyanovski authored
    >From the documentation of round_jiffies():
    "Rounds a time delta  in the future (in jiffies) up or down to
    (approximately) full seconds. This is useful for timers for which
    the exact time they fire does not matter too much, as long as
    they fire approximately every X seconds.
    By rounding these timers to whole seconds, all such timers will fire
    at the same time, rather than at various times spread out. The goal
    of this is to have the CPU wake up less, which saves power."
    
    There are 2 parts to this patch:
    ================================
    Part 1:
    -------
    In our case we need timer_service to be called approximately every
    X=1 seconds, and the exact time does not matter, so using round_jiffies()
    is the right way to go.
    
    Therefore we add round_jiffies() to the mod_timer() in ena_timer_service().
    
    Part 2:
    -------
    round_jiffies() is used in check_for_missing_keep_alive() when
    getting the jiffies of the expiration of the keep_alive timeout. Here it
    is actually a mistake to use round_jiffies() because we want the exact
    time when keep_alive should expire and not an approximate rounded time,
    which can cause early, false positive, timeouts.
    
    Therefore we remove round_jiffies() in the calculation of
    keep_alive_expired() in check_for_missing_keep_alive().
    
    Fixes: 82ef30f1 ("net: ena: add hardware hints capability to the driver")
    Fixes: 1738cd3e ("net: ena: Add a driver for Amazon Elastic Network Adapters (ENA)")
    Signed-off-by: default avatarArthur Kiyanovski <akiyano@amazon.com>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    2a6e5fa2
ena_netdev.c 121 KB