Received: by 10.213.65.68 with SMTP id h4csp2113307imn; Sun, 8 Apr 2018 20:03:16 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/IpFSd6Lj3+U496MrKWMyZYRuSiFzt3cn/6/IKDhEszHHAJCZejjL9K/80gOOb0DPebEiy X-Received: by 10.98.220.218 with SMTP id c87mr28047255pfl.198.1523242996870; Sun, 08 Apr 2018 20:03:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523242996; cv=none; d=google.com; s=arc-20160816; b=UxtMCaY4dIFTcKbEhiMBudSDz/WqBj3FJKZODwp0n9KYq7OIpSKU2LN+jjJytxJ09z 3e+JVUnV4/2xnK6x8eXXZB1LPq1NvkF3YuALiLVx4XZ2kEhUdAfPr45zXMRT6ksse083 DYZYySPeZ7b3zq+N6x7zXQyVKzTcGyz53S/vgWwacxn8HZtogi5UsJ+IVMnXnf7ZwM6o ZH8BR0dwvKDB6FGnP4lMjcZYlPgOPT7ZYieLxO1odbnwoNG+ITarbmvrdRPPaqGHFzCR hq2K0ZYxNIj26rAyGpXmuUUmo8FSbob1D2z8sGyeb0fScrCyeOje8MCDQBPsaRZO4usx k+Og== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=FTLQ9AzCzkQP9nlcIDlZFq/9UZjbSk2BEYwoFLYI664=; b=uiytK7JDVEyQQR3vJOv9BoVVaE+Aw3ZUD8WKXktx8EHilWgw7NMVdwI2VZS1Ek5iwc LRrX/HelsqDRmDxgkdcpYATZJf6MY4i/OCZyMx3E4uhBz+aMql8lUxvQ9ZAyFZt2WW0C rWB6Im9NsDzx2PfREPzVdWjwevVCFOR4D4PZ1yEYX/dCvXxRuNogxjK5OMp7rzPvLafb uFE2uwjevn1g5QdPgwkmSoJk2Af7bI+OjRvrR0zjX1kb6vyBZBFr1KmjGqLAtY97/NiL +wJX7ZuZCqyowbAKV++DY8WyiKMYWsF2lL0sIB9a17NnNQ0EBa/WY7o+PgeSZIBCPk1C zRww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=YF1MnFQF; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bc1-v6si3588637plb.689.2018.04.08.20.02.39; Sun, 08 Apr 2018 20:03:16 -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; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=YF1MnFQF; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755557AbeDIA1Z (ORCPT + 99 others); Sun, 8 Apr 2018 20:27:25 -0400 Received: from mail-by2nam03on0102.outbound.protection.outlook.com ([104.47.42.102]:48448 "EHLO NAM03-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754094AbeDIA1V (ORCPT ); Sun, 8 Apr 2018 20:27:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=FTLQ9AzCzkQP9nlcIDlZFq/9UZjbSk2BEYwoFLYI664=; b=YF1MnFQFNv+VYgTSuqrPz0vIM607yNqj+UpeNnuxE6YltsgQC48pw50ALr8F2dbobUbJBaIQv23w1mNPox/NkeBO1SMjL5gZirIqvDGLfPbZb1Ue8taQYr8R50KOBsQnVudULm6Az+izceb9dwNA+M+sX+z8wJtnS2hdyn4fDY8= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB0885.namprd21.prod.outlook.com (52.132.132.154) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.696.0; Mon, 9 Apr 2018 00:27:18 +0000 Received: from DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8109:aef0:a777:7059]) by DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8109:aef0:a777:7059%2]) with mapi id 15.20.0696.003; Mon, 9 Apr 2018 00:27:18 +0000 From: Sasha Levin To: "stable@vger.kernel.org" , "linux-kernel@vger.kernel.org" CC: Netanel Belgazal , "David S . Miller" , Sasha Levin Subject: [PATCH AUTOSEL for 4.9 032/293] net: ena: fix rare uncompleted admin command false alarm Thread-Topic: [PATCH AUTOSEL for 4.9 032/293] net: ena: fix rare uncompleted admin command false alarm Thread-Index: AQHTz5jzzu1Dn6tQS0upeCCNANqWJQ== Date: Mon, 9 Apr 2018 00:23:15 +0000 Message-ID: <20180409002239.163177-32-alexander.levin@microsoft.com> References: <20180409002239.163177-1-alexander.levin@microsoft.com> In-Reply-To: <20180409002239.163177-1-alexander.levin@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;DM5PR2101MB0885;7:ETD7D9qIBX0Ye76A8hUu4eP15upS0HTAQxMSwZqYI8nEknV2QVID7DXaVVkTAuAap4MHyfLylmJTEbx+X3mCt8MgHBpnnEsV+Wo0bOafxS6CEGmRUooqZxaBuIzrRe3plvid1vz+c5yMiJUrpfaXymAj6mv8MVKDCdHBgV1cwK2kxMDW48YTtDHsJazDGSuwDdb/NOPA4Pc0qXHi2XAaJD5T9eu6XQ0TXiiOoTE3+4Of2OnBgOCsPP/HU7fjbW8q;20:T3x2RgwGYhiW6l9A1cDgDaY+nCn2IqlHNK7hfX1DIfLEEoNeoItLJENa+oNIaYnxGvDZv5Jh6yyiAPxX8Z9OiQCDooQqpL8rmBMDoQki9ET1B9/JNbvLCV3WCvHfzXIAm1cgj+1GQ2lf5kcMoMD4uaWdP49lVSFA3WTNS6kxUH4= x-ms-office365-filtering-ht: Tenant X-MS-Office365-Filtering-Correlation-Id: 3670375c-d9f1-48c2-51cb-08d59db0a70c x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7193020);SRVR:DM5PR2101MB0885; x-ms-traffictypediagnostic: DM5PR2101MB0885: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171)(33061846794335)(47284530071512); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(61425038)(6040522)(2401047)(8121501046)(5005006)(93006095)(93001095)(3231221)(944501327)(52105095)(3002001)(10201501046)(6055026)(61426038)(61427038)(6041310)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123564045)(20161123560045)(6072148)(201708071742011);SRVR:DM5PR2101MB0885;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB0885; x-forefront-prvs: 0637FCE711 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(39860400002)(366004)(346002)(376002)(396003)(39380400002)(189003)(199004)(2906002)(68736007)(22452003)(316002)(6512007)(5660300001)(6666003)(54906003)(110136005)(486006)(6486002)(102836004)(36756003)(14454004)(99286004)(86612001)(105586002)(72206003)(106356001)(2900100001)(1076002)(97736004)(10090500001)(3280700002)(5250100002)(6436002)(3660700001)(6116002)(3846002)(305945005)(86362001)(59450400001)(66066001)(10290500003)(186003)(81166006)(8936002)(478600001)(476003)(25786009)(81156014)(8676002)(4326008)(7736002)(2501003)(107886003)(6506007)(2616005)(26005)(76176011)(446003)(53936002)(11346002)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB0885;H:DM5PR2101MB1032.namprd21.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: VT9PNWAEnUhFGCIZKHek69EGHLPnND5LpZ33JBjenunMgrK7fdE8mEo/LBObCbCZqPmDGtdHpbqFtI+Evo2y5/DxhGmdNTHI1RYbfOv6Rj3FTd24rlqhc+Sbp1xM5wf0tn0ox7rz0N2hc26ErN1t/Mji84RSd2kKatDa/1gkdpBVkou9+Z/vtWxxcBEScyJuZU5sdfLLGO++5MPcCClrpKWPNZaXeloaBDbp2G7o1RKwyvawMT7Cv09r+W5RjAeBuY65hcTFwcm62NGDP35rQRqoOTrvmIpmb8b3uZkKhA05s6snhGyiO/hDzWSakRHIcy2CL5Ra8HmhPKvfdU+SlsIPXmT4QdETUEyajYumsXzSkDLxmMcYexdFzHZhYFGYCV6P6kSEPGXXdxuKaNo5CgQ0TVHqCAtOsqXws8RuEzc= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3670375c-d9f1-48c2-51cb-08d59db0a70c X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2018 00:23:15.2686 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB0885 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- drivers/net/ethernet/amazon/ena/ena_com.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/amazon/ena/ena_com.c b/drivers/net/ethern= et/amazon/ena/ena_com.c index e2512ab41168..564b556baba9 100644 --- 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(u8 comp_statu= s) 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; =20 - start_time =3D ((u32)jiffies_to_usecs(jiffies)); + timeout =3D jiffies + 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); =20 - while (comp_ctx->status =3D=3D ENA_CMD_SUBMITTED) { - if ((((u32)jiffies_to_usecs(jiffies)) - start_time) > - ADMIN_CMD_TIMEOUT_US) { + if (comp_ctx->status !=3D 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_admin_cq_polling(s= truct ena_comp_ctx *comp_c goto err; } =20 - 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); } =20 --=20 2.15.1