Message ID | 1477432240-20406-1-git-send-email-benjamin.walker@intel.com (mailing list archive) |
---|---|
State | Accepted, archived |
Headers |
Return-Path: <dev-bounces@dpdk.org> 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 B631A68CF; Tue, 25 Oct 2016 23:50:48 +0200 (CEST) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by dpdk.org (Postfix) with ESMTP id E7C532E41 for <dev@dpdk.org>; Tue, 25 Oct 2016 23:50:46 +0200 (CEST) Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga105.jf.intel.com with ESMTP; 25 Oct 2016 14:50:45 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,399,1473145200"; d="scan'208";a="23582967" Received: from bwalker-desk.ch.intel.com ([143.182.137.83]) by fmsmga006.fm.intel.com with ESMTP; 25 Oct 2016 14:50:45 -0700 From: Ben Walker <benjamin.walker@intel.com> To: dev@dpdk.org Date: Tue, 25 Oct 2016 14:50:40 -0700 Message-Id: <1477432240-20406-1-git-send-email-benjamin.walker@intel.com> X-Mailer: git-send-email 2.7.4 Subject: [dpdk-dev] [PATCH] pci: Don't call probe callback if driver already loaded. X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK <dev.dpdk.org> List-Unsubscribe: <http://dpdk.org/ml/options/dev>, <mailto:dev-request@dpdk.org?subject=unsubscribe> List-Archive: <http://dpdk.org/ml/archives/dev/> List-Post: <mailto:dev@dpdk.org> List-Help: <mailto:dev-request@dpdk.org?subject=help> List-Subscribe: <http://dpdk.org/ml/listinfo/dev>, <mailto:dev-request@dpdk.org?subject=subscribe> Errors-To: dev-bounces@dpdk.org Sender: "dev" <dev-bounces@dpdk.org> |
Commit Message
Walker, Benjamin
Oct. 25, 2016, 9:50 p.m. UTC
If the user asks to probe multiple times, the probe
callback should only be called on devices that don't have
a driver already loaded.
This is useful if a driver is registered after the
execution of a program has started and the list of devices
needs to be re-scanned.
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
---
lib/librte_eal/common/eal_common_pci.c | 4 ++++
1 file changed, 4 insertions(+)
Comments
Hello Benjamin, On Tue, Oct 25, 2016 at 11:50 PM, Ben Walker <benjamin.walker@intel.com> wrote: > If the user asks to probe multiple times, the probe > callback should only be called on devices that don't have > a driver already loaded. > > This is useful if a driver is registered after the > execution of a program has started and the list of devices > needs to be re-scanned. Why not use the hotplug api, attaching explicitely one pci device ? > Signed-off-by: Ben Walker <benjamin.walker@intel.com> > --- > lib/librte_eal/common/eal_common_pci.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/lib/librte_eal/common/eal_common_pci.c b/lib/librte_eal/common/eal_common_pci.c > index 638cd86..971ad20 100644 > --- a/lib/librte_eal/common/eal_common_pci.c > +++ b/lib/librte_eal/common/eal_common_pci.c > @@ -289,6 +289,10 @@ pci_probe_all_drivers(struct rte_pci_device *dev) > if (dev == NULL) > return -1; > > + /* Check if a driver is already loaded */ > + if (dev->driver != NULL) > + return 0; > + This can do the trick, yes. To be safe, I think we are missing a check in rte_eal_pci_probe_one_driver() so that dev->driver is only set when the probe function from the driver did succeed.
On Thu, Oct 27, 2016 at 3:28 PM, David Marchand <david.marchand@6wind.com> wrote: > On Tue, Oct 25, 2016 at 11:50 PM, Ben Walker <benjamin.walker@intel.com> wrote: >> If the user asks to probe multiple times, the probe >> callback should only be called on devices that don't have >> a driver already loaded. >> >> This is useful if a driver is registered after the >> execution of a program has started and the list of devices >> needs to be re-scanned. > > Why not use the hotplug api, attaching explicitely one pci device ? Ah, scratch that. I've been too quick to reply. Ok, you are loading a new driver.
On 10/26/2016 3:20 AM, Ben Walker wrote: > If the user asks to probe multiple times, the probe > callback should only be called on devices that don't have > a driver already loaded. > > This is useful if a driver is registered after the > execution of a program has started and the list of devices > needs to be re-scanned. > > Signed-off-by: Ben Walker <benjamin.walker@intel.com> > --- > lib/librte_eal/common/eal_common_pci.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/lib/librte_eal/common/eal_common_pci.c b/lib/librte_eal/common/eal_common_pci.c > index 638cd86..971ad20 100644 > --- a/lib/librte_eal/common/eal_common_pci.c > +++ b/lib/librte_eal/common/eal_common_pci.c > @@ -289,6 +289,10 @@ pci_probe_all_drivers(struct rte_pci_device *dev) > if (dev == NULL) > return -1; > > + /* Check if a driver is already loaded */ > + if (dev->driver != NULL) > + return 0; > + In case if it is required to change the driver assigned to a device, would it mean application relies on detach(dev)->new-driver-plugged-in->attach(dev) sequence? To me, the above change sounds fine. Though, I am not aware if there is even a use case for changing driver assigned to a device. detach()->attach() should be able to work in those cases, I think. > TAILQ_FOREACH(dr, &pci_driver_list, next) { > rc = rte_eal_pci_probe_one_driver(dr, dev); > if (rc < 0) > - Shreyansh
2016-10-25 14:50, Ben Walker: > If the user asks to probe multiple times, the probe > callback should only be called on devices that don't have > a driver already loaded. > > This is useful if a driver is registered after the > execution of a program has started and the list of devices > needs to be re-scanned. > > Signed-off-by: Ben Walker <benjamin.walker@intel.com> Applied, thanks
Hello Thomas, On Sun, Nov 6, 2016 at 10:59 PM, Thomas Monjalon <thomas.monjalon@6wind.com> wrote: > 2016-10-25 14:50, Ben Walker: >> If the user asks to probe multiple times, the probe >> callback should only be called on devices that don't have >> a driver already loaded. >> >> This is useful if a driver is registered after the >> execution of a program has started and the list of devices >> needs to be re-scanned. >> >> Signed-off-by: Ben Walker <benjamin.walker@intel.com> > > Applied, thanks Can you add a follow up patch I will send shortly ? Thanks.
diff --git a/lib/librte_eal/common/eal_common_pci.c b/lib/librte_eal/common/eal_common_pci.c index 638cd86..971ad20 100644 --- a/lib/librte_eal/common/eal_common_pci.c +++ b/lib/librte_eal/common/eal_common_pci.c @@ -289,6 +289,10 @@ pci_probe_all_drivers(struct rte_pci_device *dev) if (dev == NULL) return -1; + /* Check if a driver is already loaded */ + if (dev->driver != NULL) + return 0; + TAILQ_FOREACH(dr, &pci_driver_list, next) { rc = rte_eal_pci_probe_one_driver(dr, dev); if (rc < 0)