[dpdk-dev] dpdk-devbind can't be used misc with kernel tools

Message ID BY2PR0701MB21012330871CB2981591296C8F100@BY2PR0701MB2101.namprd07.prod.outlook.com (mailing list archive)
State Not Applicable, archived
Headers

Checks

Context Check Description
ci/checkpatch warning coding style issues
ci/Intel-compilation success Compilation OK

Commit Message

Guduri Prathyusha April 27, 2017, 7:30 a.m. UTC
  Hi LijuanX A,


Thanks for verifying it. I have already submitted a formal patch for the same

http://dpdk.org/dev/patchwork/patch/23921/


Regards,

Prathyusha
  

Patch

diff --git a/usertools/dpdk-devbind.py b/usertools/dpdk-devbind.py
index bb4d536e0..1dc1065b1 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"""