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 71D8DA0555 for ; Wed, 19 Feb 2020 16:57:55 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 67E80B62; Wed, 19 Feb 2020 16:57:55 +0100 (CET) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by dpdk.org (Postfix) with ESMTP id E21E0B62 for ; Wed, 19 Feb 2020 16:57:53 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1582127873; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gQ3f2Yhx9Uo6ESwVyCwp27Psg81QAx4yh+iBmVktQkw=; b=bPEnqSgmT7+Qxv+kdGuRG7VVQWwhmTO0UJlrbSi6+FzqPYnNbLuYhQQWFpYxa6X628uS2a 85z21O+ja3mE22shUNqM1gvIaYUFOYbaC7d36xFWcGRVCTGYmFt6DUybxEDtyhvMdxeAno E84SY/MjNAhrMdGcQ6wEstmcoTHhbrs= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-421-9zNb-22hMaam1Q2qReP6SQ-1; Wed, 19 Feb 2020 10:57:50 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 987DC800D55; Wed, 19 Feb 2020 15:57:47 +0000 (UTC) Received: from rh.redhat.com (unknown [10.33.36.109]) by smtp.corp.redhat.com (Postfix) with ESMTP id 05AB1811F8; Wed, 19 Feb 2020 15:57:43 +0000 (UTC) From: Kevin Traynor To: Thomas Monjalon Cc: Ferruh Yigit , dpdk stable Date: Wed, 19 Feb 2020 15:56:03 +0000 Message-Id: <20200219155607.20495-18-ktraynor@redhat.com> In-Reply-To: <20200219155607.20495-1-ktraynor@redhat.com> References: <20200219155607.20495-1-ktraynor@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-MC-Unique: 9zNb-22hMaam1Q2qReP6SQ-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Subject: [dpdk-stable] patch 'app/testpmd: fix hot-unplug detaching' has been queued to LTS release 18.11.7 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 LTS release 18.11.7 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 02/25/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 rebasi= ng (ie: not only metadata diffs), please double check that the rebase was correctly done. Queued patches are on a temporary branch at: https://github.com/kevintraynor/dpdk-stable-queue This queued commit can be viewed at: https://github.com/kevintraynor/dpdk-stable-queue/commit/b0edd2452e95ae8558= 787895d04b07dd0a2e672c Thanks. Kevin. --- >From b0edd2452e95ae8558787895d04b07dd0a2e672c Mon Sep 17 00:00:00 2001 From: Thomas Monjalon Date: Thu, 13 Feb 2020 16:52:26 +0100 Subject: [PATCH] app/testpmd: fix hot-unplug detaching [ upstream commit 0654d4a8ad694821e3ce274e87b1ab89fd587f1c ] There is a possible race condition in the hotplug path in rmv_port_callback(). If a port is created between close_port(port_id) and detach_port_device(port_id), then the port_id will have been reallocated to a different device which will be wrongly detached. Since a check was added in detach_port_device() for manual detach case, the hotplug path was even more broken. It became impossible to run because the new check prevented to run detach_port_device() after the port is closed. The solution for both issues is to not rely on the port_id for detaching the rte_device. The function detach_port_device() is split to allow calling detach_device() directly with the rte_device pointer, saved before closing the port. Fixes: cbb4c648c5df ("ethdev: use device handle to detach") Signed-off-by: Thomas Monjalon Reviewed-by: Ferruh Yigit --- app/test-pmd/testpmd.c | 49 +++++++++++++++++++++++++----------------- 1 file changed, 29 insertions(+), 20 deletions(-) diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index 31d559494d..a910c06dc2 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -2343,16 +2343,9 @@ setup_attached_port(portid_t pi) } =20 -void -detach_port_device(portid_t port_id) +static void +detach_device(struct rte_device *dev) { -=09struct rte_device *dev; =09portid_t sibling; =20 -=09printf("Removing a device...\n"); - -=09if (port_id_is_invalid(port_id, ENABLED_WARN)) -=09=09return; - -=09dev =3D rte_eth_devices[port_id].device; =09if (dev =3D=3D NULL) { =09=09printf("Device already removed\n"); @@ -2360,13 +2353,5 @@ detach_port_device(portid_t port_id) =09} =20 -=09if (ports[port_id].port_status !=3D RTE_PORT_CLOSED) { -=09=09if (ports[port_id].port_status !=3D RTE_PORT_STOPPED) { -=09=09=09printf("Port not stopped\n"); -=09=09=09return; -=09=09} -=09=09printf("Port was not closed\n"); -=09=09if (ports[port_id].flow_list) -=09=09=09port_flow_flush(port_id); -=09} +=09printf("Removing a device...\n"); =20 =09if (rte_dev_remove(dev) < 0) { @@ -2389,5 +2374,5 @@ detach_port_device(portid_t port_id) =09remove_invalid_ports(); =20 -=09printf("Device of port %u is detached\n", port_id); +=09printf("Device is detached\n"); =09printf("Now total ports is %d\n", nb_ports); =09printf("Done\n"); @@ -2395,4 +2380,23 @@ detach_port_device(portid_t port_id) } =20 +void +detach_port_device(portid_t port_id) +{ +=09if (port_id_is_invalid(port_id, ENABLED_WARN)) +=09=09return; + +=09if (ports[port_id].port_status !=3D RTE_PORT_CLOSED) { +=09=09if (ports[port_id].port_status !=3D RTE_PORT_STOPPED) { +=09=09=09printf("Port not stopped\n"); +=09=09=09return; +=09=09} +=09=09printf("Port was not closed\n"); +=09=09if (ports[port_id].flow_list) +=09=09=09port_flow_flush(port_id); +=09} + +=09detach_device(rte_eth_devices[port_id].device); +} + void pmd_test_exit(void) @@ -2539,4 +2543,5 @@ rmv_port_callback(void *arg) =09int org_no_link_check =3D no_link_check; =09portid_t port_id =3D (intptr_t)arg; +=09struct rte_device *dev; =20 =09RTE_ETH_VALID_PORTID_OR_RET(port_id); @@ -2549,6 +2554,10 @@ rmv_port_callback(void *arg) =09stop_port(port_id); =09no_link_check =3D org_no_link_check; + +=09/* Save rte_device pointer before closing ethdev port */ +=09dev =3D rte_eth_devices[port_id].device; =09close_port(port_id); -=09detach_port_device(port_id); +=09detach_device(dev); /* might be already removed or have more ports */ + =09if (need_to_start) =09=09start_packet_forwarding(0); --=20 2.21.1 --- Diff of the applied patch vs upstream commit (please double-check if non-= empty: --- --- -=092020-02-19 15:43:50.666650093 +0000 +++ 0018-app-testpmd-fix-hot-unplug-detaching.patch=092020-02-19 15:43:49.7= 61141384 +0000 @@ -1 +1 @@ -From 0654d4a8ad694821e3ce274e87b1ab89fd587f1c Mon Sep 17 00:00:00 2001 +From b0edd2452e95ae8558787895d04b07dd0a2e672c Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit 0654d4a8ad694821e3ce274e87b1ab89fd587f1c ] + @@ -23,2 +25 @@ -Fixes: 43d0e304980a ("app/testpmd: fix invalid port detaching") -Cc: stable@dpdk.org +Fixes: cbb4c648c5df ("ethdev: use device handle to detach") @@ -33 +34 @@ -index 031fe25f39..035836adfb 100644 +index 31d559494d..a910c06dc2 100644 @@ -36 +37 @@ -@@ -2634,16 +2634,9 @@ setup_attached_port(portid_t pi) +@@ -2343,16 +2343,9 @@ setup_attached_port(portid_t pi) @@ -55 +56 @@ -@@ -2651,13 +2644,5 @@ detach_port_device(portid_t port_id) +@@ -2360,13 +2353,5 @@ detach_port_device(portid_t port_id) @@ -70 +71 @@ -@@ -2677,5 +2662,5 @@ detach_port_device(portid_t port_id) +@@ -2389,5 +2374,5 @@ detach_port_device(portid_t port_id) @@ -77 +78 @@ -@@ -2683,4 +2668,23 @@ detach_port_device(portid_t port_id) +@@ -2395,4 +2380,23 @@ detach_port_device(portid_t port_id) @@ -100,2 +101,2 @@ - detach_devargs(char *identifier) -@@ -2873,4 +2877,5 @@ rmv_port_callback(void *arg) + pmd_test_exit(void) +@@ -2539,4 +2543,5 @@ rmv_port_callback(void *arg) @@ -107 +108 @@ -@@ -2883,6 +2888,10 @@ rmv_port_callback(void *arg) +@@ -2549,6 +2554,10 @@ rmv_port_callback(void *arg)