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 DECE9A04DD; Thu, 22 Oct 2020 10:11:46 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 885D76948; Thu, 22 Oct 2020 10:11:45 +0200 (CEST) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by dpdk.org (Postfix) with ESMTP id C315D66DA; Thu, 22 Oct 2020 10:11:43 +0200 (CEST) Received: by linux.microsoft.com (Postfix, from userid 1004) id 2210020B4905; Thu, 22 Oct 2020 01:11:43 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 2210020B4905 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxonhyperv.com; s=default; t=1603354303; bh=kRi1UADanXUwga5ahtQ8wK+jSjJQr/OtoW6goJ1JIu4=; h=From:To:Cc:Subject:Date:From; b=Plo/dHDvt8tST3HmSYQPA7sKnMNMGlZgBHst/qs12YI9HR0TcM3H1Go/SGbUW2jpC 9rpK2Vk92LW6Jt7e83FQkMyNJFAvTek54ixOH+agQAAFnmtl9r33cPA2+nHX2uz43n jKxh6Ci3ueY5ieGY2rI1rsT4u1fTaRUEHIbSnXEw= From: Long Li To: Matan Azrad Cc: dev@dpdk.org, Long Li , stable@dpdk.org Date: Thu, 22 Oct 2020 01:11:34 -0700 Message-Id: <1603354294-16610-1-git-send-email-longli@linuxonhyperv.com> X-Mailer: git-send-email 1.8.3.1 Subject: [dpdk-dev] [Patch v2] net/vdev_netvsc: prevent alarm loss on failed device probe X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Long Li If a device probe fails, the alarm is canceled and will no longer work for previously probed devices. Fix this by checking if alarm is necessary at the end of each device probe. Reset the alarm if there are vdev_netvsc_ctx created. Change log: v2: removed lock and flags, use counter to decide if alarm should be reset Cc: stable@dpdk.org Signed-off-by: Long Li --- drivers/net/vdev_netvsc/vdev_netvsc.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/drivers/net/vdev_netvsc/vdev_netvsc.c b/drivers/net/vdev_netvsc/vdev_netvsc.c index a865a82811..9ed8a4949d 100644 --- a/drivers/net/vdev_netvsc/vdev_netvsc.c +++ b/drivers/net/vdev_netvsc/vdev_netvsc.c @@ -684,6 +684,7 @@ vdev_netvsc_vdev_probe(struct rte_vdev_device *dev) int ret; DRV_LOG(DEBUG, "invoked as \"%s\", using arguments \"%s\"", name, args); + rte_eal_alarm_cancel(vdev_netvsc_alarm, NULL); if (!kvargs) { DRV_LOG(ERR, "cannot parse arguments list"); goto error; @@ -699,17 +700,13 @@ vdev_netvsc_vdev_probe(struct rte_vdev_device *dev) !strcmp(pair->key, VDEV_NETVSC_ARG_MAC)) ++specified; } - if (ignore) { - if (kvargs) - rte_kvargs_free(kvargs); - return 0; - } + if (ignore) + goto ignore; if (specified > 1) { DRV_LOG(ERR, "More than one way used to specify the netvsc" " device."); goto error; } - rte_eal_alarm_cancel(vdev_netvsc_alarm, NULL); /* Gather interfaces. */ ret = vdev_netvsc_foreach_iface(vdev_netvsc_netvsc_probe, 1, name, kvargs, specified, &matched); @@ -730,17 +727,19 @@ vdev_netvsc_vdev_probe(struct rte_vdev_device *dev) } DRV_LOG(WARNING, "non-netvsc device was probed as netvsc"); } - ret = rte_eal_alarm_set(VDEV_NETVSC_PROBE_MS * 1000, - vdev_netvsc_alarm, NULL); - if (ret < 0) { - DRV_LOG(ERR, "unable to schedule alarm callback: %s", - rte_strerror(-ret)); - goto error; - } error: + ++vdev_netvsc_ctx_inst; +ignore: if (kvargs) rte_kvargs_free(kvargs); - ++vdev_netvsc_ctx_inst; + /* Reset alarm if there are device context created */ + if (vdev_netvsc_ctx_count) { + ret = rte_eal_alarm_set(VDEV_NETVSC_PROBE_MS * 1000, + vdev_netvsc_alarm, NULL); + if (ret < 0) + DRV_LOG(ERR, "unable to schedule alarm callback: %s", + rte_strerror(-ret)); + } return 0; } -- 2.25.1