• Jack Morgenstein's avatar
    net/mlx4_en: Fix potential deadlock in port statistics flow · d2582a03
    Jack Morgenstein authored
    mlx4_en_DUMP_ETH_STATS took the *counter mutex* and then
    called the FW command, with WRAPPED attribute. As a result, the fw command
    is wrapped on the Hypervisor when it calls mlx4_en_DUMP_ETH_STATS.
    The FW command wrapper flow on the hypervisor takes the *slave_cmd_mutex*
    during processing.
    
    At the same time, a VF could be in the process of coming up, and could
    call mlx4_QUERY_FUNC_CAP.  On the hypervisor, the command flow takes the
    *slave_cmd_mutex*, then executes mlx4_QUERY_FUNC_CAP_wrapper.
    mlx4_QUERY_FUNC_CAP wrapper calls mlx4_get_default_counter_index(),
    which takes the *counter mutex*. DEADLOCK.
    
    The fix is that the DUMP_ETH_STATS fw command should be called with
    the NATIVE attribute, so that on the hypervisor, this command does not
    enter the wrapper flow.
    
    Since the Hypervisor no longer goes through the wrapper code, we also
    simply return 0 in mlx4_DUMP_ETH_STATS_wrapper (i.e.the function succeeds,
    but the returned data will be all zeroes).
    No need to test if it is the Hypervisor going through the wrapper.
    
    Fixes: f9baff50 ("mlx4_core: Add "native" argument to mlx4_cmd ...")
    Signed-off-by: default avatarJack Morgenstein <jackm@dev.mellanox.co.il>
    Signed-off-by: default avatarTariq Toukan <tariqt@mellanox.com>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    d2582a03
port.c 55.2 KB