net: ena: fix rare uncompleted admin command false alarm
authorNetanel Belgazal <netanel@amazon.com>
Sun, 11 Jun 2017 12:42:43 +0000 (15:42 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 13 Apr 2018 17:48:27 +0000 (19:48 +0200)
commit61e01f1db6dadcfd56b32fb879bcad01f691f064
tree8dc74b43e84dd41d207d346c9014440dba78a0c3
parentc613f7c06b9ad259cf66fb14bdc8f7442dfeea85
net: ena: fix rare uncompleted admin command false alarm

[ Upstream commit a77c1aafcc906f657d1a0890c1d898be9ee1d5c9 ]

The current flow to detect admin completion is:
while (command_not_completed) {
if (timeout)
error

check_for_completion()
sleep()
   }
So in case the sleep took more than the timeout
(in case the thread/workqueue was not scheduled due to higher priority
task or prolonged VMexit), the driver can detect a stall even if
the completion is present.

The fix changes the order of this function to first check for
completion and only after that check if the timeout expired.

Fixes: 1738cd3ed342 ("Add a driver for Amazon Elastic Network Adapters (ENA)")
Signed-off-by: Netanel Belgazal <netanel@amazon.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/net/ethernet/amazon/ena/ena_com.c