From patchwork Wed Jul 26 13:35:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Ga=C3=ABtan_Rivet?= X-Patchwork-Id: 27211 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id 8DF427CC4; Wed, 26 Jul 2017 15:36:18 +0200 (CEST) Received: from mail-wr0-f176.google.com (mail-wr0-f176.google.com [209.85.128.176]) by dpdk.org (Postfix) with ESMTP id 280D57CBE for ; Wed, 26 Jul 2017 15:36:12 +0200 (CEST) Received: by mail-wr0-f176.google.com with SMTP id v105so101485478wrb.0 for ; Wed, 26 Jul 2017 06:36:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=TEJrvxjRhOp5taG9yHcK589pjnW0R56+ll4kQdNewdM=; b=K3GHQe+GgtdRlo+s0YjLSBlsWYNXvnfnD/kwvHjfQN50zA+FT+7q1mJzlaWKSyOStZ PJxFlUXRfuIvF14m0iZgHXUZp++dgsNwju8c42l6yg1tUOZx5chDohoyWsWxn1ROkCKQ wTwsNuDtagrOBY6YrytGTJEYYNeSRipcdANwKefEb25oNYchwftR1YKabsBaxzJZwqj7 th+RJEtvjalPbc7QQAooF3vdTmCgqFOkRFduJLZIklpuNV0wtF8zZYdEuJZK8QQBlK6S aabP2sZXjUHSNlOGCBuwVKoBl8rvCEqZRVhzc6987ALPA9/2Whr+DdBFuo55ouXVfGtD x8/Q== 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:in-reply-to:references; bh=TEJrvxjRhOp5taG9yHcK589pjnW0R56+ll4kQdNewdM=; b=XtyQxe68Y2wwhaD4gPH6FKy7b+4qOdKtyn9n/yd3aOTVGkrAXpREtOYwyBbxiQAzFT funx1KL/I328EqefLdS3CXlpS+Q2nuP2CvLDwxzVQePHOSz9mtt14ZHq4oq7kx93Hvni JZRSl/ZnnauI5NZbaM2cGv8BxevXDWh0nLsIXL5D23zHvgEmv4x6LchiV70MKm2VYJ2g i8jzsmbehF9Jtg8095fLyLQWXG19YsxqGB4ixxJQlOm6+JdXG8AuH7lwUYjZwem2wRsG 98e6T4XNSpIgU/7Pbyjloh1hxI/sr6bZQOM75dT33CsTaFfyFkZHWPeulZylhqyQyhkb tE6w== X-Gm-Message-State: AIVw113PPnjDDmSKJw7WCw2K7u12kUpkOrNd3RpgmwhwogdktEqWk1W0 xuR5v6YoGR5E+oMDM8o= X-Received: by 10.223.141.146 with SMTP id o18mr872480wrb.215.1501076171215; Wed, 26 Jul 2017 06:36:11 -0700 (PDT) Received: from bidouze.dev.6wind.com (host.78.145.23.62.rev.coltfrance.com. [62.23.145.78]) by smtp.gmail.com with ESMTPSA id c13sm3144707wrc.7.2017.07.26.06.36.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 26 Jul 2017 06:36:10 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Gaetan Rivet , stable@dpdk.org Date: Wed, 26 Jul 2017 15:35:52 +0200 Message-Id: X-Mailer: git-send-email 2.1.4 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [PATCH v2 1/6] ethdev: fix device state on detach 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" The device state should be handled by the ether layer when possible. Applications should not have to do it. Not setting the state to UNUSED will make the port_id of the device valid for all ether API functions, usually resulting in segfault. Fixes: 284c908cc588 ("app/testpmd: request device removal interrupt") Cc: stable@dpdk.org Signed-off-by: Gaetan Rivet --- app/test-pmd/testpmd.c | 1 - lib/librte_ether/rte_ethdev.c | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index e754d12..9142218 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -1836,7 +1836,6 @@ rmv_event_callback(void *arg) close_port(port_id); printf("removing device %s\n", dev->device->name); rte_eal_dev_detach(dev->device); - dev->state = RTE_ETH_DEV_UNUSED; } /* This function is used by the interrupt thread */ diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index d4ebb1b..8c365ed 100644 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -453,6 +453,7 @@ rte_eth_dev_detach(uint8_t port_id, char *name) if (ret < 0) goto err; + rte_eth_devices[port_id].state = RTE_ETH_DEV_UNUSED; return 0; err: