From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 3F173A0518 for ; Fri, 24 Jul 2020 14:01:01 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 321CC1C032; Fri, 24 Jul 2020 14:01:01 +0200 (CEST) Received: from mail-wm1-f68.google.com (mail-wm1-f68.google.com [209.85.128.68]) by dpdk.org (Postfix) with ESMTP id 7F2321C010 for ; Fri, 24 Jul 2020 14:00:59 +0200 (CEST) Received: by mail-wm1-f68.google.com with SMTP id 9so7717002wmj.5 for ; Fri, 24 Jul 2020 05:00:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+wHKWKzrkzd9uAPttH2arcFKealrcJ4dgd/hdb8yPvs=; b=TgE+aA5MOv/bVjKBEM7Yf5WrKB0HDOi4s9w3kCw7NhataTqZj8S0LKvn8eBLJrTUsp fmIyV5jFHl5BKaiNjal5CnoB+pLZ9pzAbU3l1cT7dxfvdT2u+VPH4oG7wbOJgMKIM4xS KOeVGb10orZpAM9SME6FpbRr6AzxlOVdrXv+k8sJs5HXdOkDf919nOFGElAILPJn2IwK CGNBoShLBPMrwzqrKQaR65xDy+N31W8Dxu+V1ClE1E+1rfUmzwF1uFm5VKal5nj4bRAd lin2a2ZkVWqhRjtuyTRKasYBvNvzA7J7aosKOX/2ws9zNzso74lFgOfrWpg89+C1a39x 16Xw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=+wHKWKzrkzd9uAPttH2arcFKealrcJ4dgd/hdb8yPvs=; b=QlZ8a8r97AqpO7/CogFu051xMNZvxwMPw29sN9P0YMsjDE2YuzcVJy0Dm9q2XbuVUh klv0VW0qCdF/BowxZLReXPkm5WCnHTPIEOJ26/qOuLNyIybpMIojoyQeOWTve52hi5ED u1N3qfYOSjMcMyGWeFF2X3YzMEZ4upZck44kto31J7qZl8uVBOy8SSIBkw2wj5xJygR2 YGczqQLyot9Ce0U1uwnk/5/jYiIbNTWPbCCBKQBnJnph1acA0MvBPZDpnIXykIcI8DDg 9fFrW20yEdSjUKjrultdtdXGCfwylNNNnUFxGRu4DJLLr7AvCMrhYJEOPgNIF2GxELhL naTA== X-Gm-Message-State: AOAM532a6e9tVKgV/zVGSWt2FbWmwy0k54zxd8GeP6zTQGqnl9UmgmC2 aqqn/B9tJlkgsde/vFasfHLN13xgHLI= X-Google-Smtp-Source: ABdhPJw/hiMiOx57iLI7orZIPUrCMGcTDUFEmy03P5ABo43eXvm6GOumxPzaPP8pK92/Rwk1hm9qUg== X-Received: by 2002:a7b:c841:: with SMTP id c1mr9015566wml.25.1595592059229; Fri, 24 Jul 2020 05:00:59 -0700 (PDT) Received: from localhost ([88.98.246.218]) by smtp.gmail.com with ESMTPSA id i4sm1167789wrw.26.2020.07.24.05.00.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Jul 2020 05:00:58 -0700 (PDT) From: luca.boccassi@gmail.com To: Stephen Hemminger Cc: dpdk stable Date: Fri, 24 Jul 2020 12:57:28 +0100 Message-Id: <20200724120030.1863487-10-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200724120030.1863487-1-luca.boccassi@gmail.com> References: <20200724120030.1863487-1-luca.boccassi@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-stable] patch 'net/netvsc: do not spin forever waiting for reply' has been queued to stable release 19.11.4 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" Hi, FYI, your patch has been queued to stable release 19.11.4 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 07/26/20. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. This will indicate if there was any rebasing needed to apply to the stable branch. If there were code changes for rebasing (ie: not only metadata diffs), please double check that the rebase was correctly done. Thanks. Luca Boccassi --- >From 895e0773bd95e6fcc935128fa8ab34c7d5b3f881 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Tue, 19 May 2020 09:52:30 -0700 Subject: [PATCH] net/netvsc: do not spin forever waiting for reply [ upstream commit 3c9be81be917e1659a3a9ab332c277280986ed03 ] Because of bugs in driver or host a reply to a request might never occur. Better to give an error than spin forever. Fixes: 4e9c73e96e83 ("net/netvsc: add Hyper-V network device") Signed-off-by: Stephen Hemminger --- drivers/net/netvsc/hn_rndis.c | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/drivers/net/netvsc/hn_rndis.c b/drivers/net/netvsc/hn_rndis.c index 2b4714042..bce3dab68 100644 --- a/drivers/net/netvsc/hn_rndis.c +++ b/drivers/net/netvsc/hn_rndis.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include @@ -33,6 +34,9 @@ #include "hn_rndis.h" #include "ndis.h" +#define RNDIS_TIMEOUT_SEC 5 +#define RNDIS_DELAY_MS 10 + #define HN_RNDIS_XFER_SIZE 0x4000 #define HN_NDIS_TXCSUM_CAP_IP4 \ @@ -348,7 +352,7 @@ void hn_rndis_receive_response(struct hn_data *hv, rte_smp_wmb(); if (rte_atomic32_cmpset(&hv->rndis_pending, hdr->rid, 0) == 0) { - PMD_DRV_LOG(ERR, + PMD_DRV_LOG(NOTICE, "received id %#x pending id %#x", hdr->rid, (uint32_t)hv->rndis_pending); } @@ -371,6 +375,11 @@ static int hn_rndis_exec1(struct hn_data *hv, return -EIO; } + if (rid == 0) { + PMD_DRV_LOG(ERR, "Invalid request id"); + return -EINVAL; + } + if (comp != NULL && rte_atomic32_cmpset(&hv->rndis_pending, 0, rid) == 0) { PMD_DRV_LOG(ERR, @@ -385,9 +394,26 @@ static int hn_rndis_exec1(struct hn_data *hv, } if (comp) { + time_t start = time(NULL); + /* Poll primary channel until response received */ - while (hv->rndis_pending == rid) + while (hv->rndis_pending == rid) { + if (hv->closed) + return -ENETDOWN; + + if (time(NULL) - start > RNDIS_TIMEOUT_SEC) { + PMD_DRV_LOG(ERR, + "RNDIS response timed out"); + + rte_atomic32_cmpset(&hv->rndis_pending, rid, 0); + return -ETIMEDOUT; + } + + if (rte_vmbus_chan_rx_empty(hv->primary->chan)) + rte_delay_ms(RNDIS_DELAY_MS); + hn_process_events(hv, 0, 1); + } memcpy(comp, hv->rndis_resp, comp_len); } -- 2.20.1 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2020-07-24 12:53:48.984085277 +0100 +++ 0010-net-netvsc-do-not-spin-forever-waiting-for-reply.patch 2020-07-24 12:53:48.159004075 +0100 @@ -1,13 +1,14 @@ -From 3c9be81be917e1659a3a9ab332c277280986ed03 Mon Sep 17 00:00:00 2001 +From 895e0773bd95e6fcc935128fa8ab34c7d5b3f881 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Tue, 19 May 2020 09:52:30 -0700 Subject: [PATCH] net/netvsc: do not spin forever waiting for reply +[ upstream commit 3c9be81be917e1659a3a9ab332c277280986ed03 ] + Because of bugs in driver or host a reply to a request might never occur. Better to give an error than spin forever. Fixes: 4e9c73e96e83 ("net/netvsc: add Hyper-V network device") -Cc: stable@dpdk.org Signed-off-by: Stephen Hemminger --- @@ -15,7 +16,7 @@ 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/drivers/net/netvsc/hn_rndis.c b/drivers/net/netvsc/hn_rndis.c -index 6a850ce5f..d186ddeab 100644 +index 2b4714042..bce3dab68 100644 --- a/drivers/net/netvsc/hn_rndis.c +++ b/drivers/net/netvsc/hn_rndis.c @@ -10,6 +10,7 @@ @@ -26,7 +27,7 @@ #include #include -@@ -34,6 +35,9 @@ +@@ -33,6 +34,9 @@ #include "hn_rndis.h" #include "ndis.h" @@ -36,7 +37,7 @@ #define HN_RNDIS_XFER_SIZE 0x4000 #define HN_NDIS_TXCSUM_CAP_IP4 \ -@@ -354,7 +358,7 @@ void hn_rndis_receive_response(struct hn_data *hv, +@@ -348,7 +352,7 @@ void hn_rndis_receive_response(struct hn_data *hv, rte_smp_wmb(); if (rte_atomic32_cmpset(&hv->rndis_pending, hdr->rid, 0) == 0) { @@ -45,7 +46,7 @@ "received id %#x pending id %#x", hdr->rid, (uint32_t)hv->rndis_pending); } -@@ -377,6 +381,11 @@ static int hn_rndis_exec1(struct hn_data *hv, +@@ -371,6 +375,11 @@ static int hn_rndis_exec1(struct hn_data *hv, return -EIO; } @@ -57,7 +58,7 @@ if (comp != NULL && rte_atomic32_cmpset(&hv->rndis_pending, 0, rid) == 0) { PMD_DRV_LOG(ERR, -@@ -391,9 +400,26 @@ static int hn_rndis_exec1(struct hn_data *hv, +@@ -385,9 +394,26 @@ static int hn_rndis_exec1(struct hn_data *hv, } if (comp) {