From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 530CF460E2; Tue, 28 Jan 2025 02:35:20 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3C46B40DD2; Tue, 28 Jan 2025 02:35:20 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 1A6A140144; Tue, 28 Jan 2025 02:35:19 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1202) id 7B3A82037171; Mon, 27 Jan 2025 17:35:18 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 7B3A82037171 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxonhyperv.com; s=default; t=1738028118; bh=SxuhN6dJGndD5PiFXiPtSIzUVIQpsn6cwh82Xs0De0w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Xq56y7XQJLVRUCzromgcJeC5peBT7qHu2rcdpSLRT6JQu0vnykx3128NUx3nMSJH2 vvYPT/WvK0rRlrEwhzL0iJW7p0D3CSvH+lkIxID1gq2oZUNmJqNHTsTGHEz5jiqjX7 m10d5Q21f4wxUJC97I2bZ0h3IpzLBxz4FYeQUV2Y= From: longli@linuxonhyperv.com To: Ferruh Yigit , Andrew Rybchenko , Wei Hu Cc: dev@dpdk.org, Long Li , stable@dpdk.org Subject: [PATCH 2/4] net/netvsc: remove RTE device if all its net devices are removed Date: Mon, 27 Jan 2025 17:35:04 -0800 Message-Id: <1738028106-25239-2-git-send-email-longli@linuxonhyperv.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1738028106-25239-1-git-send-email-longli@linuxonhyperv.com> References: <1738028106-25239-1-git-send-email-longli@linuxonhyperv.com> X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org From: Long Li An RTE device can have multiple Ethernet devices. On hot plug events, it can't be removed until all its Ethernet devices have been removed. Fixes: a2a23a794b3a ("net/netvsc: support VF device hot add/remove") Cc: stable@dpdk.org Signed-off-by: Long Li --- drivers/net/netvsc/hn_vf.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/drivers/net/netvsc/hn_vf.c b/drivers/net/netvsc/hn_vf.c index b664beaa5d..5d8058774d 100644 --- a/drivers/net/netvsc/hn_vf.c +++ b/drivers/net/netvsc/hn_vf.c @@ -102,6 +102,7 @@ static void hn_remove_delayed(void *args) uint16_t port_id = hv->vf_ctx.vf_port; struct rte_device *dev = rte_eth_devices[port_id].device; int ret; + bool all_eth_removed; /* Tell VSP to switch data path to synthetic */ hn_vf_remove(hv); @@ -138,7 +139,17 @@ static void hn_remove_delayed(void *args) PMD_DRV_LOG(ERR, "rte_eth_dev_close failed port_id=%u ret=%d", port_id, ret); - ret = rte_dev_remove(dev); + /* Remove the rte device when all its eth devices are removed */ + all_eth_removed = true; + RTE_ETH_FOREACH_DEV_OF(port_id, dev) { + if (rte_eth_devices[port_id].state != RTE_ETH_DEV_UNUSED) { + all_eth_removed = false; + break; + } + } + if (all_eth_removed) + ret = rte_dev_remove(dev); + hv->vf_ctx.vf_state = vf_removed; rte_rwlock_write_unlock(&hv->vf_lock); -- 2.34.1