mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-28 21:33:52 +00:00
net: ena: fix rare uncompleted admin command false alarm
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: 1738cd3ed3
("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>
This commit is contained in:
parent
b87fa0fafe
commit
a77c1aafcc
1 changed files with 11 additions and 10 deletions
|
@ -508,15 +508,20 @@ static int ena_com_comp_status_to_errno(u8 comp_status)
|
||||||
static int ena_com_wait_and_process_admin_cq_polling(struct ena_comp_ctx *comp_ctx,
|
static int ena_com_wait_and_process_admin_cq_polling(struct ena_comp_ctx *comp_ctx,
|
||||||
struct ena_com_admin_queue *admin_queue)
|
struct ena_com_admin_queue *admin_queue)
|
||||||
{
|
{
|
||||||
unsigned long flags;
|
unsigned long flags, timeout;
|
||||||
u32 start_time;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
start_time = ((u32)jiffies_to_usecs(jiffies));
|
timeout = jiffies + ADMIN_CMD_TIMEOUT_US;
|
||||||
|
|
||||||
while (comp_ctx->status == ENA_CMD_SUBMITTED) {
|
while (1) {
|
||||||
if ((((u32)jiffies_to_usecs(jiffies)) - start_time) >
|
spin_lock_irqsave(&admin_queue->q_lock, flags);
|
||||||
ADMIN_CMD_TIMEOUT_US) {
|
ena_com_handle_admin_completion(admin_queue);
|
||||||
|
spin_unlock_irqrestore(&admin_queue->q_lock, flags);
|
||||||
|
|
||||||
|
if (comp_ctx->status != ENA_CMD_SUBMITTED)
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (time_is_before_jiffies(timeout)) {
|
||||||
pr_err("Wait for completion (polling) timeout\n");
|
pr_err("Wait for completion (polling) timeout\n");
|
||||||
/* ENA didn't have any completion */
|
/* ENA didn't have any completion */
|
||||||
spin_lock_irqsave(&admin_queue->q_lock, flags);
|
spin_lock_irqsave(&admin_queue->q_lock, flags);
|
||||||
|
@ -528,10 +533,6 @@ static int ena_com_wait_and_process_admin_cq_polling(struct ena_comp_ctx *comp_c
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
spin_lock_irqsave(&admin_queue->q_lock, flags);
|
|
||||||
ena_com_handle_admin_completion(admin_queue);
|
|
||||||
spin_unlock_irqrestore(&admin_queue->q_lock, flags);
|
|
||||||
|
|
||||||
msleep(100);
|
msleep(100);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue