From patchwork Fri Apr 7 15:28:07 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: 23331 X-Patchwork-Delegate: thomas@monjalon.net 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 E83E468C5; Fri, 7 Apr 2017 17:28:31 +0200 (CEST) Received: from mail-wr0-f170.google.com (mail-wr0-f170.google.com [209.85.128.170]) by dpdk.org (Postfix) with ESMTP id 4F5495598 for ; Fri, 7 Apr 2017 17:28:27 +0200 (CEST) Received: by mail-wr0-f170.google.com with SMTP id c55so38088964wrc.3 for ; Fri, 07 Apr 2017 08:28:27 -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=ziyWySHCFFIkjexkoavJd+vLM0WJbUnoN+TQvOzdXf4=; b=JTPZBoqapopwTdrwgfu6tVUGE/UXzpQfPmNHFi5BqieA5jnZ175RKuX8ixq9KlmaW0 HYvjOSd0woio4NSgFfpaybaNWynGD8N+4IXCPkI5wYbKU7WeYLcW994YJVeQqSc+2Ylq y9it2+092QOujSz0PheWyprPOzPUeFZ206G46I4fFEHozedAUOFf2Jj0Jy6s/W3qrpUb 0YA0Eig6bUPhlywwSpUmlugQ4Z7BLAmLcM3ZjmJIzBpt7b8c2OTRUQn5k6ofFeEmhZA5 dijW1nFoUmn4WSV6wZFArYV6i/FF/38fXuZ+hvhzS9QsNWQJkuape/uEtfEdWaqJJYV1 jDaw== 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=ziyWySHCFFIkjexkoavJd+vLM0WJbUnoN+TQvOzdXf4=; b=jBAMgN3vWk3i8MfR94S0D9K42ojftWNxcVJzZFuuwXfdAJUgAiZaULgiiKzL4TqFv3 jARuvFA33xCHiA05zk96SdSOP36PuNiY4dh1g1XkJHv+RfATn4aV/x5Xl8Vupv21+aLL iaHCVlGX0U5xO9ooOA7i4Fd5ikVAO/WwW2uEYCkeBRuBqSDpcBRbNAhqM/ugWSPoDIAV IOPvYXSTiOiWzlywht82/8IwBs+82MM1QhyVruk86k8c5LEF/soqmNz4pYfWlGiU4ZYZ DkCzWWix/DsNYSFmOs9lyz3UdQT7hdYAl9E2k+ZyH+DixZCS0k0h99v4yUX0TqhBBzyF dfzQ== X-Gm-Message-State: AFeK/H0sUWlx6ivcmH7jLDip0//v/xn9U2BDS5Loj/fbhXSy051/tc45C73ndCNL4UKeWPsV X-Received: by 10.223.166.46 with SMTP id k43mr36848455wrc.64.1491578907231; Fri, 07 Apr 2017 08:28:27 -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 b199sm6699363wmb.13.2017.04.07.08.28.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 07 Apr 2017 08:28:26 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Shreyansh Jain Date: Fri, 7 Apr 2017 17:28:07 +0200 Message-Id: <2ec2fbda234cca823e74edee69c5c01d74acb9eb.1491577715.git.gaetan.rivet@6wind.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: References: <1484801117-779-1-git-send-email-thomas.monjalon@6wind.com> In-Reply-To: References: Subject: [dpdk-dev] [PATCH v12 2/5] pci: remove loop over drivers in device detach 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" From: Shreyansh Jain rte_eal_pci_detach calls pci_detach_all_drivers which loops over all PCI drivers for detaching the device. This is unnecessary as the device already has the PCI driver reference which can be used directly. Removing pci_detach_all_drivers and restructuring rte_eal_pci_detach and rte_eal_pci_detach_dev to work without looping over driver list. Signed-off-by: Shreyansh Jain Reviewed-by: Gaetan Rivet --- lib/librte_eal/common/eal_common_pci.c | 45 +++++++--------------------------- 1 file changed, 9 insertions(+), 36 deletions(-) diff --git a/lib/librte_eal/common/eal_common_pci.c b/lib/librte_eal/common/eal_common_pci.c index 83a81c4..498a3bb 100644 --- a/lib/librte_eal/common/eal_common_pci.c +++ b/lib/librte_eal/common/eal_common_pci.c @@ -263,19 +263,15 @@ rte_eal_pci_probe_one_driver(struct rte_pci_driver *dr, * driver. */ static int -rte_eal_pci_detach_dev(struct rte_pci_driver *dr, - struct rte_pci_device *dev) +rte_eal_pci_detach_dev(struct rte_pci_device *dev) { struct rte_pci_addr *loc; + struct rte_pci_driver *dr; - if ((dr == NULL) || (dev == NULL)) + if (dev == NULL) return -EINVAL; - if (!rte_pci_match(dr, dev)) { - /* Device and driver don't match */ - return 1; - } - + dr = dev->driver; loc = &dev->addr; RTE_LOG(DEBUG, EAL, "PCI device "PCI_PRI_FMT" on NUMA socket %i\n", @@ -330,33 +326,6 @@ pci_probe_all_drivers(struct rte_pci_device *dev) } /* - * If vendor/device ID match, call the remove() function of all - * registered driver for the given device. Return -1 if initialization - * failed, return 1 if no driver is found for this device. - */ -static int -pci_detach_all_drivers(struct rte_pci_device *dev) -{ - struct rte_pci_driver *dr = NULL; - int rc = 0; - - if (dev == NULL) - return -1; - - TAILQ_FOREACH(dr, &pci_driver_list, next) { - rc = rte_eal_pci_detach_dev(dr, dev); - if (rc < 0) - /* negative value is an error */ - return -1; - if (rc > 0) - /* positive value means driver doesn't support it */ - continue; - return 0; - } - return 1; -} - -/* * Find the pci device specified by pci address, then invoke probe function of * the driver of the devive. */ @@ -409,9 +378,13 @@ rte_eal_pci_detach(const struct rte_pci_addr *addr) if (rte_eal_compare_pci_addr(&dev->addr, addr)) continue; - ret = pci_detach_all_drivers(dev); + ret = rte_eal_pci_detach_dev(dev); if (ret < 0) + /* negative value is an error */ goto err_return; + if (ret > 0) + /* positive value means driver doesn't support it */ + continue; TAILQ_REMOVE(&pci_device_list, dev, next); free(dev);