• S
    ibmvnic: init ->running_cap_crqs early · 9728532d
    Sukadev Bhattiprolu 提交于
    stable inclusion
    from stable-v5.10.96
    commit 55258b505996d05f62830192422ba9b4df045677
    bugzilla: https://gitee.com/openeuler/kernel/issues/I55NWB
    
    Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=55258b505996d05f62830192422ba9b4df045677
    
    --------------------------------
    
    [ Upstream commit 151b6a5c ]
    
    We use ->running_cap_crqs to determine when the ibmvnic_tasklet() should
    send out the next protocol message type. i.e when we get back responses
    to all our QUERY_CAPABILITY CRQs we send out REQUEST_CAPABILITY crqs.
    Similiary, when we get responses to all the REQUEST_CAPABILITY crqs, we
    send out the QUERY_IP_OFFLOAD CRQ.
    
    We currently increment ->running_cap_crqs as we send out each CRQ and
    have the ibmvnic_tasklet() send out the next message type, when this
    running_cap_crqs count drops to 0.
    
    This assumes that all the CRQs of the current type were sent out before
    the count drops to 0. However it is possible that we send out say 6 CRQs,
    get preempted and receive all the 6 responses before we send out the
    remaining CRQs. This can result in ->running_cap_crqs count dropping to
    zero before all messages of the current type were sent and we end up
    sending the next protocol message too early.
    
    Instead initialize the ->running_cap_crqs upfront so the tasklet will
    only send the next protocol message after all responses are received.
    
    Use the cap_reqs local variable to also detect any discrepancy (either
    now or in future) in the number of capability requests we actually send.
    
    Currently only send_query_cap() is affected by this behavior (of sending
    next message early) since it is called from the worker thread (during
    reset) and from application thread (during ->ndo_open()) and they can be
    preempted. send_request_cap() is only called from the tasklet  which
    processes CRQ responses sequentially, is not be affected.  But to
    maintain the existing symmtery with send_query_capability() we update
    send_request_capability() also.
    
    Fixes: 249168ad ("ibmvnic: Make CRQ interrupt tasklet wait for all capabilities crqs")
    Signed-off-by: NSukadev Bhattiprolu <sukadev@linux.ibm.com>
    Reviewed-by: NDany Madden <drt@linux.ibm.com>
    Signed-off-by: NDavid S. Miller <davem@davemloft.net>
    Signed-off-by: NSasha Levin <sashal@kernel.org>
    Signed-off-by: NYu Liao <liaoyu15@huawei.com>
    Reviewed-by: NWei Li <liwei391@huawei.com>
    Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
    9728532d
ibmvnic.c 148.8 KB