From patchwork Wed Jul 26 13:30:17 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: 27206 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 4C3317CB6; Wed, 26 Jul 2017 15:30:46 +0200 (CEST) Received: from mail-wr0-f173.google.com (mail-wr0-f173.google.com [209.85.128.173]) by dpdk.org (Postfix) with ESMTP id 6A1F17CBB for ; Wed, 26 Jul 2017 15:30:42 +0200 (CEST) Received: by mail-wr0-f173.google.com with SMTP id 12so131849404wrb.1 for ; Wed, 26 Jul 2017 06:30:42 -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=Qdp4mbX2P5Nd9UGGGF6bOQdqtjXD3owyr3WxF+Bu5utiqLhSMC/Atzyq15xAIr1Afs gnwrvAH64x0Nr7ZPEy7m55nGdkfWQsj9PoypuUs/VRcBoZWm9lH5uq33CaqPaYgdbG9E R3HmoSH4KQa/LVCqi4Dp0wyvH9GOhBCd5PX9R1WCpuxpfrjQ9leU9Rp5z9sqxQXLkqTq JzvGi5G1fYlNKRO/xCoHXnPEf+37GDEASKcPzorBx58f61YPF2YjqvaJdsBbt/oueju+ wrfgHHTerDYOonk1HNMWRvESjZ7Gbs3bMW1EAyGbuwa9axCL7tUxgY7x6bIFPnhksV3C njkg== 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=WdnX5V1G9FtXqwl9RXIAyzshh6IFl+vSGickKFNPW5sjHQl8Z/ZulnABvIqNuXOz7F XsZQbWUnCS1UHXS7B+Lkw7kC6HvNZsX1v6rzo0XTah9ZtV/k5o/VtMRksPb4ZTzYfNsa 8oLhotsMelhhiTzWX5bLa5AT4PdWyDzqc9CeZtjwmv5aqHvTdpRN2b7j+MhN/SL6Ly2j xOc+d8useRJLM1Jc6EQVqMDbGbeIkZBJ+Tu7jOqXyEbAbqTFFRQvzxWmkc6s3TZR6ZDO MAA659eB+L/4L7M/se+SIpjqcdg6aG2GKWd5x1Mo9V23u6o6SdcKUHWbMpbO5eYUDiw4 egAw== X-Gm-Message-State: AIVw110p2vloEz+SjPRJJVIAoK2B//HnpY66DB2cPYzOzrcDNgn8Kq7m aZwTsSJuEJlF2Crxwzo= X-Received: by 10.223.164.20 with SMTP id d20mr882453wra.183.1501075841685; Wed, 26 Jul 2017 06:30:41 -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 d26sm16186659wra.92.2017.07.26.06.30.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 26 Jul 2017 06:30:40 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Gaetan Rivet , stable@dpdk.org Date: Wed, 26 Jul 2017 15:30:17 +0200 Message-Id: X-Mailer: git-send-email 2.1.4 In-Reply-To: References: <5ec0604196fb087a42fa75e6ddc2a04aab293593.1501047767.git.shacharbe@mellanox.com> In-Reply-To: References: Subject: [dpdk-dev] [PATCH 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: