From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f177.google.com (mail-wr0-f177.google.com [209.85.128.177]) by dpdk.org (Postfix) with ESMTP id B4DA27CAF for ; Tue, 11 Jul 2017 01:19:32 +0200 (CEST) Received: by mail-wr0-f177.google.com with SMTP id r103so159321647wrb.0 for ; Mon, 10 Jul 2017 16:19:32 -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=dlH70+UcR18kfuMqYdjd1IfKkMTjSbHhFpOKWVbQ1nQ=; b=bSCL9WyOa2Ry5vMLgLNHNkax3OWmp2vQODa9OMYF+GNjgEM92iQCO+x1prjD8Bkdrf lC4qkgGIRtScv7mq5ZDj0cKtJTzAXezjynod/cY4VAaBff83WFfw1L82L7KexeNSJd68 sPsMyrLFrFOLc2VrVlaKgUczis5EO+nA7NQbABEk+6WG6oEFinm9azsDH0EJEwIbi1DP L+mqP3uE4zmcQT8gLP7DKJxiKaLSdWiAH797GmVSq1ycQmkG2gSikX8sZ+gHVfuy7IGZ 9579rjyWnX4ZQ1WJk7j36qegL2S1Mx7cZEl7g7pP2mMB7m7JBqXTa4kghGiN2GyA77lF OnYQ== 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=dlH70+UcR18kfuMqYdjd1IfKkMTjSbHhFpOKWVbQ1nQ=; b=DY0Xw31edZjZI9L1CfnvEfHWOUFh5xfG0nADcuG4F5lzMTR4PIm0C1BrH8c8MbcPyd AaeeXP6RLYcw4KWLl1UsTvlkvJhqyiB0BMm5TiVdjiTIpchOa/VLtJHG6KM6xDXbVIqe xAffBtS5OwbKwNrmZKTc4Zdc4LlByAWwcdjJKkop1Y3FOqdJw42p05n63R6lURy4+Y/P 9GXPT6AUuENGk8Ja2AYhBmDt8w9+okNFMquLFIt8xF+PwEUYH8744BeH1WeAXJ3Ct4mw FemvG5gDRHvZlQy6gPCQbmCq0FUXoF5+aUwrrOXdOhB3eXxeBEVJOZAdtYX6j7Y6wc8M /4sg== X-Gm-Message-State: AIVw112Y2vZLKoUzzE2e+rqmYs8YTGy2OPM4b816AeIQk6e4b1/ptsRl vYszLCBwZ7QDeXhFBno= X-Received: by 10.28.131.130 with SMTP id f124mr9224023wmd.25.1499728772046; Mon, 10 Jul 2017 16:19:32 -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 j190sm43773wmd.22.2017.07.10.16.19.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 10 Jul 2017 16:19:31 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Gaetan Rivet Date: Tue, 11 Jul 2017 01:19:06 +0200 Message-Id: <107944281978bf0b074101cdae8843ca5df8c8ae.1499728330.git.gaetan.rivet@6wind.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [PATCH v2 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: , X-List-Received-Date: Mon, 10 Jul 2017 23:19:33 -0000 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 9cc4148..7e82a31 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 @@ -536,32 +535,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 = { -- 2.1.4