Received: by 10.192.165.156 with SMTP id m28csp1102336imm; Wed, 11 Apr 2018 12:27:11 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/RUn2gi9CinTlk/lcq5Py6G5XCenJX9aCWEcvKDYqaGK8f25+y4rvmzLtQ+TxSUCN4smKk X-Received: by 10.98.159.129 with SMTP id v1mr4990603pfk.25.1523474831099; Wed, 11 Apr 2018 12:27:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523474831; cv=none; d=google.com; s=arc-20160816; b=GLHzM4nwHPtV/aiMzB4/g0ks3L3NoeDJ9+yED6aGkBOUMar7i8RQOR+K2SIr0XjLo7 ju2tx9VXbrU4sAYo1Z7OKf7xgQnFPIhgkiykmED6Ve9Kmoqpnjk26jej8zElQZSX1RvS dpVama/auxvu+fa0+/P/xElfzMtn4m9CnGbw8Q+a8iy0bngHi8aVXDEh/bOtn8JviT+c gS7zguPgL640r/mLLQ1SuBLlnDmW5O3Z1JAerIIqFhBzNXUzVT038JlmicQBy0Rd8fAD fdfGk6dkyeoO4qisHhEA7GKTUXM6Uo7pE/zwaMiGmg9bGy0zEieh8DNWokZQyZcyd4G9 0/Cg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=i50J5FM2Wpqc1lHS9RlUwN0J0zU6YwXtv3klu00Mut4=; b=DLDiuH8MKgkzpxDkFdLzgFIDGI6I+98m/wRTbvMOlPyMoNjyudmQQ3v2RKuQBXqSz9 9a8NhJgswEEsxSInwZgTJz0+upW4ZWDbFrTPs+8zvfXbR/70C6Ap0FUd98ui9PP/k4pP iGHYKf90nylvfv1q+73etMnHAvWdimhcB2Zf51ai60QwGxTPILG7E9sTSvHgwlvofsGO yf8PpBdC8cnMqenBQludfCryGUUCQNxSOiw19rOGugOyGsEy8eyZ/BY1CAyVsKYaFXx1 m7Gn1nVK8/ReK+O7GM/WNAQAoZq1cQotgpuxY64tZo/yvgWrLVPQ4mSHNyXEWzNzCbn+ T7rg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s123si1328756pfs.234.2018.04.11.12.26.33; Wed, 11 Apr 2018 12:27:11 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934746AbeDKTDq (ORCPT + 99 others); Wed, 11 Apr 2018 15:03:46 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:39050 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934716AbeDKTDm (ORCPT ); Wed, 11 Apr 2018 15:03:42 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 29DA0E58; Wed, 11 Apr 2018 19:03:42 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Netanel Belgazal , "David S. Miller" , Sasha Levin Subject: [PATCH 4.9 241/310] net: ena: fix rare uncompleted admin command false alarm Date: Wed, 11 Apr 2018 20:36:20 +0200 Message-Id: <20180411183632.847583014@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180411183622.305902791@linuxfoundation.org> References: <20180411183622.305902791@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Netanel Belgazal [ 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 Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/amazon/ena/ena_com.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) --- a/drivers/net/ethernet/amazon/ena/ena_com.c +++ b/drivers/net/ethernet/amazon/ena/ena_com.c @@ -508,15 +508,20 @@ static int ena_com_comp_status_to_errno( static int ena_com_wait_and_process_admin_cq_polling(struct ena_comp_ctx *comp_ctx, struct ena_com_admin_queue *admin_queue) { - unsigned long flags; - u32 start_time; + unsigned long flags, timeout; int ret; - start_time = ((u32)jiffies_to_usecs(jiffies)); + timeout = jiffies + ADMIN_CMD_TIMEOUT_US; - while (comp_ctx->status == ENA_CMD_SUBMITTED) { - if ((((u32)jiffies_to_usecs(jiffies)) - start_time) > - ADMIN_CMD_TIMEOUT_US) { + while (1) { + spin_lock_irqsave(&admin_queue->q_lock, flags); + 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"); /* ENA didn't have any completion */ spin_lock_irqsave(&admin_queue->q_lock, flags); @@ -528,10 +533,6 @@ static int ena_com_wait_and_process_admi 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); }