From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f182.google.com (mail-wr0-f182.google.com [209.85.128.182]) by dpdk.org (Postfix) with ESMTP id 8F0707CD7 for ; Wed, 12 Jul 2017 01:26:06 +0200 (CEST) Received: by mail-wr0-f182.google.com with SMTP id c11so9804271wrc.3 for ; Tue, 11 Jul 2017 16:26:06 -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=vFguCsZ5BEv1xnZ9/EFgloz8fBYypfdyRRj16L71DU1tSQ4Gceg4HY6KXvasIT6yb6 a+yWXwkMKosF9BKgc8Cx4IYTPUjdEzuhFs6jqy/z/FRR9Z3ued3tJfttbG6Rh1vNyX0v xqdXm/VSLxHRoNpJFHgPfbLrtUUuvH532pI/Fr+9R8phZEU89eSOinuQL5fkeUy1FV7w W6+mKio7UDdso6S3aD9d3HumUms7mTu/m2pIoxs5tet27++gp7S63nzNeNuNb/q9Ep6w voDoKPhusRzrPSSVH0/0O0gHq6IZ19wdvWywX/DP9qUV3bbDppzL/iQNCn5Fe7bMRGCk FM4A== 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=GZ7bqbMI7fsBWZ7ZOtAsloe8XQ9Ot3VAs2PIFrBXePKJgSDkFqMP/bJol4ukHBMbNg 4pvVlOKqqzCYE+qqx0RzO2KPa9jY54/3KYuJTGNKfu4zkLDQ/pBZ40L5ugc/JpEURpQM GC3RMWudG+VAPmrIOtuqS6+oJvd0+kEYe19VxLjigFMIsrONmFlnu4+czBn/vfzLLw5w C+UiwuLVir3qiH0ba4abaMYQWICk+lXSF5OvOztTFc3L9q3jqraNxxCXXCpsGesothhf 5ubTdEtOKZFNdNTIBPz4EoXfXPjcJloCiM7di6Pxi7dZzsUOgy6t9z0yijJ/MxWyx/Uz 5WFA== X-Gm-Message-State: AIVw111d2e7DacjNjXdvdyddC5oll2ObmdmVifw9SE5iGWwIUQFUtV3Q TL3TgKkd0so2otsplFY= X-Received: by 10.28.140.84 with SMTP id o81mr444187wmd.76.1499815565952; Tue, 11 Jul 2017 16:26:05 -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 66sm407576wmj.29.2017.07.11.16.26.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 11 Jul 2017 16:26:04 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Gaetan Rivet Date: Wed, 12 Jul 2017 01:25:41 +0200 Message-Id: <167b65078951d06820b5283a376756414ddca4a6.1499814957.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 v3 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: Tue, 11 Jul 2017 23:26:07 -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 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 = { -- 2.1.4