]> git.baikalelectronics.ru Git - kernel.git/commit
cxgb4vf: Synchronize access to mailbox
authorHariprasad Shenai <hariprasad@chelsio.com>
Wed, 22 Jun 2016 04:09:29 +0000 (09:39 +0530)
committerDavid S. Miller <davem@davemloft.net>
Sat, 25 Jun 2016 16:04:33 +0000 (12:04 -0400)
commit2825d9e6f956f8a6a826351903bad01c1e13b712
tree3b37f96c770534a156dc57fc8027cf1cda1c2cb3
parent04f5723c6ec63d0b88d4b0f9187fb47987e2c2fe
cxgb4vf: Synchronize access to mailbox

The issue comes when there are multiple threads attempting to use the
mailbox facility at the same time. The issue is the for the Virtual
Function Driver, the only way to get the Virtual Interface statistics
is to issue mailbox commands to ask the firmware for the VI Stats.
And, because the VI Stats command can only retrieve a smallish number of
stats per mailbox command, we have to issue three mailbox commands in quick
succession. When ethtool or netstat command to get interface stats and
interface up/down is run in a loop for every 0.1 sec, we observed
mailbox collisions. And out of the two commands one would fail with
the present code, since we don't queue the second command.

To overcome the above issue, added a queue to access the mailbox.
Whenever a mailbox command is issued add it to the queue. If its at the
head issue the mailbox command, else wait for the existing command to
complete. Usually command takes less than a milli-second to complete.
Also timeout from the loop, if the command under execution takes
long time to run.

In reality, the number of mailbox access collisions is going to be very
rare since no one runs such abusive script.

Signed-off-by: Hariprasad Shenai <hariprasad@chelsio.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/chelsio/cxgb4vf/adapter.h
drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c
drivers/net/ethernet/chelsio/cxgb4vf/t4vf_hw.c