From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f174.google.com (mail-wr0-f174.google.com [209.85.128.174]) by dpdk.org (Postfix) with ESMTP id B79EC5699 for ; Sun, 9 Jul 2017 03:46:06 +0200 (CEST) Received: by mail-wr0-f174.google.com with SMTP id r103so93871431wrb.0 for ; Sat, 08 Jul 2017 18:46: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=dlH70+UcR18kfuMqYdjd1IfKkMTjSbHhFpOKWVbQ1nQ=; b=1bKNA0O2nvYm0qXBvxAx6auevEngUUL1uKsUrZ0L+vLhEqk2L84ygP96XrFmOaF3G1 Mk1EpxA1HFRIBaMLQjS5U8Oy8Vpsdwqwscm63oxNHEi8eZEkHstcZ9FZFo9btVKT1VzQ zfc4x0nY4cVOxGUzEI9RiKSLZZpn3D4EnbonTi5x7/XlpQmLso8zEmPJz/MOxlCdYSIS VK3dhf3YCd75XsJ9RRVpTui6D+xCze6gWNbH2z+9oB8Zcgv3FmfQoDlvCBRhP2k9egEJ oG83eEP4s4FFFBdfxsjNOeSIErLsuKnJyDylZ+6JU0C3F1DwWmuX7/+ebrpblQ5SueNx XiLg== 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=KS/0WLzAOIqhjSsllVnnSB+ORTpTos2EiDxGq6fGLO4FreHQtH7F1IwEz4SM2P2lc+ 9tY3jEfn8q1qpac3KVKgXFNANrOICtv6ZbnTi777Gy3q5OeoT1lHOKR+MuoL8S5pMR0q k2jjNmeIlXDBn2lq1xFFf1kCM2N8npAy7XOYE3XnccNtAr9bVD/CkH69FKndwQ9DTA6C Zc303MRgoMUEZgWR+L3x0mvt4TYd5IhFhB1/S83L9ZIB9F+eYIppaAluk5wlsMe9ya+N Jf+5M+wzc8GkLW0dCJWt51LpBTN/1IdEvFDcdMIv4iKVPZkTv3eXeWAg9ZmMMb8HasQl UvrA== X-Gm-Message-State: AIVw112bJF39hN+gz24X/Hh961JvwM1qo8UNTYCWhbAn9tKf43I48SFh rkoHdNe0oJElYlcvyO0= X-Received: by 10.28.184.83 with SMTP id i80mr326218wmf.98.1499564766179; Sat, 08 Jul 2017 18:46:06 -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 h130sm2430609wmd.34.2017.07.08.18.46.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 08 Jul 2017 18:46:05 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Gaetan Rivet Date: Sun, 9 Jul 2017 03:45:43 +0200 Message-Id: X-Mailer: git-send-email 2.1.4 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [PATCH 7/9] 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: Sun, 09 Jul 2017 01:46: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 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