DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] usertools: fix device binding when using with kernel tools
@ 2017-04-26 13:52 Guduri Prathyusha
  2017-04-30 12:22 ` Thomas Monjalon
  0 siblings, 1 reply; 2+ messages in thread
From: Guduri Prathyusha @ 2017-04-26 13:52 UTC (permalink / raw)
  To: thomas; +Cc: dev, lijuanx.a.tu, Guduri Prathyusha

The following sequence of operation gives error in binding devices
1) Bind a device using dpdk-devbind.py
2) Unbind the device using kernel tools(/sys/bus/pci/device/driver/unbind)
3) Bind the device using kernel tools(/sys/bus/pci/driver/new_id and
/sys/bus/pci/driver/bind)

The bind failure was due to cached driver name in 'driver_override'.
Fix it by writing 'null' to driver_override just after binding a
device so that any method of binding/unbinding can be used.

Fixes: 2fc350293570 ("usertools: use optimized driver override scheme to bind")

Reported-by: Tu LijuanX A <lijuanx.a.tu@intel.com>
Signed-off-by: Guduri Prathyusha <gprathyusha@caviumnetworks.com>
---
 usertools/dpdk-devbind.py |   38 +++++++++++++++++++-------------------
 1 file changed, 19 insertions(+), 19 deletions(-)

diff --git a/usertools/dpdk-devbind.py b/usertools/dpdk-devbind.py
index bb4d536..1dc1065 100755
--- a/usertools/dpdk-devbind.py
+++ b/usertools/dpdk-devbind.py
@@ -386,25 +386,6 @@ def unbind_one(dev_id, force):
               "Skipping unbind" % (dev_id))
         return
 
-    # For kernels > 3.15 driver_override is used to bind a device to a driver.
-    # Before unbinding it, overwrite driver_override with empty string so that
-    # the device can be bound to any other driver
-    filename = "/sys/bus/pci/devices/%s/driver_override" % dev_id
-    if os.path.exists(filename):
-        try:
-            f = open(filename, "w")
-        except:
-            print("Error: unbind failed for %s - Cannot open %s"
-                  % (dev_id, filename))
-            sys.exit(1)
-        try:
-            f.write("\00")
-            f.close()
-        except:
-            print("Error: unbind failed for %s - Cannot open %s"
-                  % (dev_id, filename))
-            sys.exit(1)
-
     # write to /sys to unbind
     filename = "/sys/bus/pci/drivers/%s/unbind" % dev["Driver_str"]
     try:
@@ -507,6 +488,25 @@ def bind_one(dev_id, driver, force):
             bind_one(dev_id, saved_driver, force)
         return
 
+    # For kernels > 3.15 driver_override is used to bind a device to a driver.
+    # Before unbinding it, overwrite driver_override with empty string so that
+    # the device can be bound to any other driver
+    filename = "/sys/bus/pci/devices/%s/driver_override" % dev_id
+    if os.path.exists(filename):
+        try:
+            f = open(filename, "w")
+        except:
+            print("Error: unbind failed for %s - Cannot open %s"
+                  % (dev_id, filename))
+            sys.exit(1)
+        try:
+            f.write("\00")
+            f.close()
+        except:
+            print("Error: unbind failed for %s - Cannot open %s"
+                  % (dev_id, filename))
+            sys.exit(1)
+
 
 def unbind_all(dev_list, force=False):
     """Unbind method, takes a list of device locations"""
-- 
1.7.9.5

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

* Re: [dpdk-dev] [PATCH] usertools: fix device binding when using with kernel tools
  2017-04-26 13:52 [dpdk-dev] [PATCH] usertools: fix device binding when using with kernel tools Guduri Prathyusha
@ 2017-04-30 12:22 ` Thomas Monjalon
  0 siblings, 0 replies; 2+ messages in thread
From: Thomas Monjalon @ 2017-04-30 12:22 UTC (permalink / raw)
  To: Guduri Prathyusha; +Cc: dev, lijuanx.a.tu

26/04/2017 15:52, Guduri Prathyusha:
> The following sequence of operation gives error in binding devices
> 1) Bind a device using dpdk-devbind.py
> 2) Unbind the device using kernel tools(/sys/bus/pci/device/driver/unbind)
> 3) Bind the device using kernel tools(/sys/bus/pci/driver/new_id and
> /sys/bus/pci/driver/bind)
> 
> The bind failure was due to cached driver name in 'driver_override'.
> Fix it by writing 'null' to driver_override just after binding a
> device so that any method of binding/unbinding can be used.
> 
> Fixes: 2fc350293570 ("usertools: use optimized driver override scheme to bind")
> 
> Reported-by: Tu LijuanX A <lijuanx.a.tu@intel.com>
> Signed-off-by: Guduri Prathyusha <gprathyusha@caviumnetworks.com>

Applied, thanks

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

end of thread, other threads:[~2017-04-30 12:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-26 13:52 [dpdk-dev] [PATCH] usertools: fix device binding when using with kernel tools Guduri Prathyusha
2017-04-30 12:22 ` 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).