DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] pci: Don't call probe callback if driver already loaded.
@ 2016-10-25 21:50 Ben Walker
  2016-10-27 13:28 ` David Marchand
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Ben Walker @ 2016-10-25 21:50 UTC (permalink / raw)
  To: dev

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;
+
 	TAILQ_FOREACH(dr, &pci_driver_list, next) {
 		rc = rte_eal_pci_probe_one_driver(dr, dev);
 		if (rc < 0)
-- 
2.7.4

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [dpdk-dev] [PATCH] pci: Don't call probe callback if driver already loaded.
  2016-10-25 21:50 [dpdk-dev] [PATCH] pci: Don't call probe callback if driver already loaded Ben Walker
@ 2016-10-27 13:28 ` David Marchand
  2016-10-27 13:30   ` David Marchand
  2016-11-02  9:29 ` Shreyansh Jain
  2016-11-06 21:59 ` Thomas Monjalon
  2 siblings, 1 reply; 8+ messages in thread
From: David Marchand @ 2016-10-27 13:28 UTC (permalink / raw)
  To: Ben Walker; +Cc: dev

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.


-- 
David Marchand

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [dpdk-dev] [PATCH] pci: Don't call probe callback if driver already loaded.
  2016-10-27 13:28 ` David Marchand
@ 2016-10-27 13:30   ` David Marchand
  0 siblings, 0 replies; 8+ messages in thread
From: David Marchand @ 2016-10-27 13:30 UTC (permalink / raw)
  To: Ben Walker; +Cc: dev

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.


-- 
David Marchand

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [dpdk-dev] [PATCH] pci: Don't call probe callback if driver already loaded.
  2016-10-25 21:50 [dpdk-dev] [PATCH] pci: Don't call probe callback if driver already loaded Ben Walker
  2016-10-27 13:28 ` David Marchand
@ 2016-11-02  9:29 ` Shreyansh Jain
  2016-11-06 21:59 ` Thomas Monjalon
  2 siblings, 0 replies; 8+ messages in thread
From: Shreyansh Jain @ 2016-11-02  9:29 UTC (permalink / raw)
  To: Ben Walker; +Cc: dev

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [dpdk-dev] [PATCH] pci: Don't call probe callback if driver already loaded.
  2016-10-25 21:50 [dpdk-dev] [PATCH] pci: Don't call probe callback if driver already loaded Ben Walker
  2016-10-27 13:28 ` David Marchand
  2016-11-02  9:29 ` Shreyansh Jain
@ 2016-11-06 21:59 ` Thomas Monjalon
  2016-11-07  9:02   ` David Marchand
  2 siblings, 1 reply; 8+ messages in thread
From: Thomas Monjalon @ 2016-11-06 21:59 UTC (permalink / raw)
  To: Ben Walker; +Cc: dev

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [dpdk-dev] [PATCH] pci: Don't call probe callback if driver already loaded.
  2016-11-06 21:59 ` Thomas Monjalon
@ 2016-11-07  9:02   ` David Marchand
  2016-11-07  9:03     ` [dpdk-dev] [PATCH] pci: do not mark device as taken when probe fails David Marchand
  0 siblings, 1 reply; 8+ messages in thread
From: David Marchand @ 2016-11-07  9:02 UTC (permalink / raw)
  To: Thomas Monjalon; +Cc: Ben Walker, dev

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.


-- 
David Marchand

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [dpdk-dev] [PATCH] pci: do not mark device as taken when probe fails
  2016-11-07  9:02   ` David Marchand
@ 2016-11-07  9:03     ` David Marchand
  2016-11-07 13:42       ` Thomas Monjalon
  0 siblings, 1 reply; 8+ messages in thread
From: David Marchand @ 2016-11-07  9:03 UTC (permalink / raw)
  To: thomas.monjalon; +Cc: dev, benjamin.walker

dev->driver should be set only if a driver did take the device.

Signed-off-by: David Marchand <david.marchand@6wind.com>
---
 lib/librte_eal/common/eal_common_pci.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/lib/librte_eal/common/eal_common_pci.c b/lib/librte_eal/common/eal_common_pci.c
index 971ad20..6163b09 100644
--- a/lib/librte_eal/common/eal_common_pci.c
+++ b/lib/librte_eal/common/eal_common_pci.c
@@ -214,7 +214,11 @@ rte_eal_pci_probe_one_driver(struct rte_pci_driver *dr, struct rte_pci_device *d
 		dev->driver = dr;
 
 		/* call the driver probe() function */
-		return dr->probe(dr, dev);
+		ret = dr->probe(dr, dev);
+		if (ret)
+			dev->driver = NULL;
+
+		return ret;
 	}
 	/* return positive value if driver doesn't support this device */
 	return 1;
-- 
2.7.4

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [dpdk-dev] [PATCH] pci: do not mark device as taken when probe fails
  2016-11-07  9:03     ` [dpdk-dev] [PATCH] pci: do not mark device as taken when probe fails David Marchand
@ 2016-11-07 13:42       ` Thomas Monjalon
  0 siblings, 0 replies; 8+ messages in thread
From: Thomas Monjalon @ 2016-11-07 13:42 UTC (permalink / raw)
  To: David Marchand; +Cc: dev, benjamin.walker

2016-11-07 10:03, David Marchand:
> dev->driver should be set only if a driver did take the device.
> 
> Signed-off-by: David Marchand <david.marchand@6wind.com>

Applied, thanks

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2016-11-07 13:42 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-25 21:50 [dpdk-dev] [PATCH] pci: Don't call probe callback if driver already loaded Ben Walker
2016-10-27 13:28 ` David Marchand
2016-10-27 13:30   ` David Marchand
2016-11-02  9:29 ` Shreyansh Jain
2016-11-06 21:59 ` Thomas Monjalon
2016-11-07  9:02   ` David Marchand
2016-11-07  9:03     ` [dpdk-dev] [PATCH] pci: do not mark device as taken when probe fails David Marchand
2016-11-07 13:42       ` Thomas Monjalon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).