From patchwork Tue Oct 24 10:35:39 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: 30778 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 702721B7B7; Tue, 24 Oct 2017 12:36:09 +0200 (CEST) Received: from mail-wr0-f195.google.com (mail-wr0-f195.google.com [209.85.128.195]) by dpdk.org (Postfix) with ESMTP id 69C4F1B7A4 for ; Tue, 24 Oct 2017 12:36:03 +0200 (CEST) Received: by mail-wr0-f195.google.com with SMTP id j15so7995089wre.8 for ; Tue, 24 Oct 2017 03:36:03 -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=UQxb1IIU1Uo8C0RHD4cqhMJMZWLhJ4V/E1DBCxXVTz0=; b=XeT84NywC9RFN6Z2SeTIVOcSn9Tngh5DqySDXej/b8xX0/KIfoETSasnYiALpyOzGN OKdmHk2fnk/NsoYvfvDjgHEMqXtihJFE7ddnOdO7R3DCB1QRrVn7m75gG0DEG+9ILTBD hjgSMmNzPm3dWMCbQp9BPuYWxMVeDcdNoY+up4fS42ebJGxCAcSI/uGLOZJMBd+TbFPl 5erlzMGwkW89wnyTKw0mrfnekSpV1veiUAgTD0i4dNevZ7PJh2kabRW97CuDveS8B+55 oLa9luZuuhHT5OsupdqEvhNGYo5k+6dJXKND7dJgTCVLNu4HCW9quV6R+SzXdonDmQpZ oRHA== 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=UQxb1IIU1Uo8C0RHD4cqhMJMZWLhJ4V/E1DBCxXVTz0=; b=rx36zpiRhByfYKzmnQXXcrzrvci9wKfE2StRun3TvqIgBymsuOMJEtt6lsYz6fZmfk rbgvoRYkZgcM3S9G/eef+3gLTt9gRAY9Wz0YyzalHeBbtjLwQUQRyY6YJY564e/agwL4 ZdpZTv/FrbtwO2mkGUXpacWbUpGKrhQzVBmoc2x/1vli+yAeDsTFaWe5JhkYWZ/A+f8F da7Ui92D5JbDS6ofzUnFOZCtKaOcZ85B0hn/IDBVlv2VPUDgTm10q3SzK6EAlvCjmO2N ZkVfoIatGgDotojCY3SwZWYwpsmu4Z7xtkyiUYDMTgHUpaCEN1XT+754ItJBXEciScnt 5Rzw== X-Gm-Message-State: AMCzsaVSXlady6t2nJKZ+Phi863OEOn2ajF692lY2cCfwpbmCje/TSH+ qb7yPgoxeCOh3obf4OI/d4W43A9h X-Google-Smtp-Source: ABhQp+TC065poZWsdqUZVlOroM36A4CXbCihmGjMzUfMjyg2P0ySFsn5ZG81FiyuimrA6IU8MM8GQA== X-Received: by 10.223.162.152 with SMTP id s24mr15028937wra.173.1508841362688; Tue, 24 Oct 2017 03:36:02 -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 w4sm12205088wrc.17.2017.10.24.03.36.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 24 Oct 2017 03:36:01 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Gaetan Rivet Date: Tue, 24 Oct 2017 12:35:39 +0200 Message-Id: <10ff1c8858c7aabbc057df5ae3b466c28b6a9291.1508840586.git.gaetan.rivet@6wind.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: References: In-Reply-To: <409639fdf67753288cff5bf7d91f725666ff5678.1508840586.git.gaetan.rivet@6wind.com> References: <409639fdf67753288cff5bf7d91f725666ff5678.1508840586.git.gaetan.rivet@6wind.com> Subject: [dpdk-dev] [PATCH v2 3/6] pci: propagate PMD removal error value for unplug 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" If a PCI device detach removal fails, returns the actual removal operator error value. Use this value within pci->unplug, as it may help applications solve an issue with the feature or more accurately warn their users. Signed-off-by: Gaetan Rivet --- lib/librte_eal/common/eal_common_pci.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/librte_eal/common/eal_common_pci.c b/lib/librte_eal/common/eal_common_pci.c index 0f0e4b9..fb92ee7 100644 --- a/lib/librte_eal/common/eal_common_pci.c +++ b/lib/librte_eal/common/eal_common_pci.c @@ -263,6 +263,7 @@ rte_pci_detach_dev(struct rte_pci_device *dev) { struct rte_pci_addr *loc; struct rte_pci_driver *dr; + int ret = 0; if (dev == NULL) return -EINVAL; @@ -277,8 +278,11 @@ rte_pci_detach_dev(struct rte_pci_device *dev) RTE_LOG(DEBUG, EAL, " remove driver: %x:%x %s\n", dev->id.vendor_id, dev->id.device_id, dr->driver.name); - if (dr->remove && (dr->remove(dev) < 0)) - return -1; /* negative value is an error */ + if (dr->remove) { + ret = dr->remove(dev); + if (ret < 0) + return ret; + } /* clear driver structure */ dev->driver = NULL; @@ -551,8 +555,10 @@ pci_unplug(struct rte_device *dev) pdev = RTE_DEV_TO_PCI(dev); ret = rte_pci_detach_dev(pdev); - rte_pci_remove_device(pdev); - free(pdev); + if (ret == 0) { + rte_pci_remove_device(pdev); + free(pdev); + } return ret; }