• Jacob Keller's avatar
    ice: reduce initial wait for control queue messages · a734c43c
    Jacob Keller authored
    The ice_sq_send_cmd() function is used to send messages to the control
    queues used to communicate with firmware, virtual functions, and even some
    hardware.
    
    When sending a control queue message, the driver is designed to
    synchronously wait for a response from the queue. Currently it waits
    between checks for 100 to 150 microseconds.
    
    Commit f86d6f9c ("ice: sleep, don't busy-wait, for
    ICE_CTL_Q_SQ_CMD_TIMEOUT") did recently change the behavior from an
    unnecessary delay into a sleep which is a significant improvement over the
    old behavior of polling using udelay.
    
    Because of the nature of PCIe transactions, the hardware won't be informed
    about a new message until the write to the tail register posts. This is
    only guaranteed to occur at the next register read. In ice_sq_send_cmd(),
    this happens at the ice_sq_done() call. Because of this, the driver
    essentially forces a minimum of one full wait time regardless of how fast
    the response is.
    
    For the hardware-based sideband queue, this is especially slow. It is
    expected that the hardware will respond within 2 or 3 microseconds, an
    order of magnitude faster than the 100-150 microsecond sleep.
    
    Allow such fast completions to occur without delay by introducing a small 5
    microsecond delay first before entering the sleeping timeout loop. Ensure
    the tail write has been posted by using ice_flush(hw) first.
    
    While at it, lets also remove the ICE_CTL_Q_SQ_CMD_USEC macro as it
    obscures the sleep time in the inner loop. It was likely introduced to
    avoid "magic numbers", but in practice sleep and delay values are easier to
    read and understand when using actual numbers instead of a named constant.
    
    This change should allow the fast hardware based control queue messages to
    complete quickly without delay, while slower firmware queue response times
    will sleep while waiting for the response.
    Signed-off-by: default avatarJacob Keller <jacob.e.keller@intel.com>
    Reviewed-by: default avatarMichal Schmidt <mschmidt@redhat.com>
    Tested-by: Pucha Himasekhar Reddy <himasekharx.reddy.pucha@intel.com> (A Contingent worker at Intel)
    Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
    a734c43c
ice_controlq.h 2.53 KB