From patchwork Sat Jul 15 17:56:41 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: 26951 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 12B957CC3; Sat, 15 Jul 2017 19:57:24 +0200 (CEST) Received: from mail-wm0-f45.google.com (mail-wm0-f45.google.com [74.125.82.45]) by dpdk.org (Postfix) with ESMTP id D76475A6E for ; Sat, 15 Jul 2017 19:57:07 +0200 (CEST) Received: by mail-wm0-f45.google.com with SMTP id 62so44504637wmw.1 for ; Sat, 15 Jul 2017 10:57:07 -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=ek5SGwi4QN3yNyz8a+IR9qQGKeUA4+XvoVGArwb5qC4=; b=HID0FQmBfYwJsBcVok7qLEl/EpwNgtnnqzKUN6qoylRygrCk9A6WB4T/rHwaSlQ5LW AOX7nY2yjFPWUebn9kasnArxzZpJsuwjjfcMuXe3UsXz+hJfkO4TJauGevMUq2Rbb97D 3OdcrvPfgM84W1ppweIAJNKWwnWeIwEJe3iHc3g/F0F4pFYdgVerwmcrKZ4S+9y+OFQ7 ifgij0i+pSlNjlwkNAWXmmZn8Elyfm2qxU9CPXzJTeVuKJWkp8tUNm8XedGqHmX3gp5+ C+l7Zh4H3kbtLnh1bZdXT3nEpbAZSYknlKoPH2fkDd7nP+KymF2Wdrwu3hrW6D10rqFf x7EA== 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=ek5SGwi4QN3yNyz8a+IR9qQGKeUA4+XvoVGArwb5qC4=; b=Af0bw3rse5g4vCVqRIbU6zA1t+Uw+dgnjQyvxlJIbE22kR7M8SunZf77lgudqNnT5/ 1z8Ug+STLZc6gFe6ohOu8bZgYSGkMrFvVvbCGkMpZ4Hlg8FnZH7dxs6cKf6KAOpLXAIK k/TbhEGTRsDfoOVNfACZ5etzFI7jC1V6A3qa5WW2r200SJIub1uccCZIbHWTIPfgH0x7 MmaXzh7mBl//cKoXY9Wyimidnjr4imrQIi4hD/0Hn3ugmzpJnKWfmsLChDy4z9LfdvyU DBQWOCKc5qQONhE+PqNNr7nXmK9du6oFmv+eAsu4dpS8WtbjBD/c1b20MHskVvUYhGM3 Tt9g== X-Gm-Message-State: AIVw113l0euGWSMfUUVqipI+AFTLETK7DrUANV3FcHnRqn4q7cIGyadh 4372l2ZXTzNJX7or6d8= X-Received: by 10.28.66.153 with SMTP id k25mr1587706wmi.129.1500141427228; Sat, 15 Jul 2017 10:57:07 -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 79sm2479445wmj.2.2017.07.15.10.57.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 15 Jul 2017 10:57:06 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Gaetan Rivet Date: Sat, 15 Jul 2017 19:56:41 +0200 Message-Id: X-Mailer: git-send-email 2.1.4 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [PATCH v4 7/8] pci: fix hotplug operations 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 handle is already known and does not have to be infered from the PCI address. The relevant helpers are already available within the PCI bus to avoid searching for a handle already known. Additionally, rte_memcpy.h was erroneously included. Fixes: 00e62aae69c0 ("bus/pci: implement plug/unplug operations") Signed-off-by: Gaetan Rivet --- lib/librte_eal/common/eal_common_pci.c | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) diff --git a/lib/librte_eal/common/eal_common_pci.c b/lib/librte_eal/common/eal_common_pci.c index 0a4062c..cdd197a 100644 --- a/lib/librte_eal/common/eal_common_pci.c +++ b/lib/librte_eal/common/eal_common_pci.c @@ -47,7 +47,6 @@ #include #include #include -#include #include #include #include @@ -544,32 +543,20 @@ pci_find_device(const struct rte_device *start, rte_dev_cmp_t cmp, static int pci_plug(struct rte_device *dev, const char *devargs __rte_unused) { - struct rte_pci_device *pdev; - struct rte_pci_addr *addr; - - addr = &RTE_DEV_TO_PCI(dev)->addr; - - /* Find the current device holding this address in the bus. */ - FOREACH_DEVICE_ON_PCIBUS(pdev) { - if (rte_eal_compare_pci_addr(&pdev->addr, addr) == 0) - return rte_pci_probe_one(addr); - } - - rte_errno = ENODEV; - return -1; + return pci_probe_all_drivers(RTE_DEV_TO_PCI(dev)); } static int pci_unplug(struct rte_device *dev) { struct rte_pci_device *pdev; + int ret; pdev = RTE_DEV_TO_PCI(dev); - if (rte_pci_detach(&pdev->addr) != 0) { - rte_errno = ENODEV; - return -1; - } - return 0; + ret = rte_pci_detach_dev(pdev); + rte_pci_remove_device(pdev); + free(pdev); + return ret; } struct rte_pci_bus rte_pci_bus = {