From patchwork Wed Apr 26 09:26:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Guduri Prathyusha X-Patchwork-Id: 23896 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 E31CB2FDD; Wed, 26 Apr 2017 11:26:18 +0200 (CEST) Received: from NAM03-DM3-obe.outbound.protection.outlook.com (mail-dm3nam03on0074.outbound.protection.outlook.com [104.47.41.74]) by dpdk.org (Postfix) with ESMTP id 55FB42C50 for ; Wed, 26 Apr 2017 11:26:17 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-cavium-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=eSbRDzo1PwLi+NvK3JSDyYY4vF5NTGaTrcZZxbnL+TI=; b=f7+ULqW6M/cbzYzkZOMMnh08r5kP+GvCC3FV0bDGCRGEZnuSOj5kQ82f58CdNilTEUw1f+PKkwVfJsBigcS7c7lmvtNRinIrYMuawDE3LCurKSPD7Ev9Uy4UT8fMrdK5DL7cIIZv5Vget2/9rZwczDyC4lfdpck5PvEEjTO+MYA= Received: from BY2PR0701MB2101.namprd07.prod.outlook.com (10.163.156.154) by BY2PR0701MB2101.namprd07.prod.outlook.com (10.163.156.154) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1047.13; Wed, 26 Apr 2017 09:26:14 +0000 Received: from BY2PR0701MB2101.namprd07.prod.outlook.com ([10.163.156.154]) by BY2PR0701MB2101.namprd07.prod.outlook.com ([10.163.156.154]) with mapi id 15.01.1047.019; Wed, 26 Apr 2017 09:26:14 +0000 From: "Prathyusha, Guduri" To: "Tu, LijuanX A" CC: "dev@dpdk.org" , "Chen, WeichunX" , "Liu, Yu Y" , "Xu, Qian Q" , "Liu, Yong" , "Lu, PeipeiX" Thread-Topic: dpdk-devbind can't be used misc with kernel tools Thread-Index: AdK+VR5nRmMI8Le0RKq3YEicQoOMyQAGUTNG Date: Wed, 26 Apr 2017 09:26:14 +0000 Message-ID: References: <38D041F150D4184C8114E499040E62343DBC1438@SHSMSX103.ccr.corp.intel.com> In-Reply-To: <38D041F150D4184C8114E499040E62343DBC1438@SHSMSX103.ccr.corp.intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dpdk.org; dkim=none (message not signed) header.d=none; dpdk.org; dmarc=none action=none header.from=cavium.com; x-originating-ip: [132.245.59.53] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; BY2PR0701MB2101; 7:Srb6AGm+4iMIjQwvDfgqSEJKSUDal5D+noeUcfGP4fzB0zVtzsL12lkFw/S9kYPn+vMIdhV3RypaRzCbnYbyTl/hvNVA7mr8jkjJhzR5QPM/dQl5Un0qlsAtCcstAF4CBX6w3SoU4I9bhCJ8u4GgZ36KNLAdB5umbuqJGymhmwhLd0hXnxqAZ3PlsXLDSDzHRmwspf+KzoimWgkcGPTqFPYIj3ZaYXSVYLFw+wErqBlmpd+vndhJGlSnQ5xTziRoc/rPxnw+HhWFrxq0pwdklW+trqgy73/KEU4pDAcwi5qslN02J9BDIU0xIJMZMVKm39xHjmCCeNmVWaM7m8wuSw== x-ms-office365-filtering-correlation-id: c0ac371a-21fa-445d-257a-08d48c864941 x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(2017030254075)(201703131423075)(201703031133081)(201702281549075); SRVR:BY2PR0701MB2101; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(228905959029699); x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(6040450)(601004)(2401047)(8121501046)(5005006)(93006095)(93001095)(3002001)(10201501046)(6041248)(201703131423075)(201702281528075)(201703061421075)(20161123564025)(20161123560025)(20161123555025)(20161123562025)(6072148); SRVR:BY2PR0701MB2101; BCL:0; PCL:0; RULEID:; SRVR:BY2PR0701MB2101; x-forefront-prvs: 0289B6431E x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(6009001)(39400400002)(39850400002)(39410400002)(39840400002)(39450400003)(45984002)(377454003)(2900100001)(53546009)(53936002)(25786009)(38730400002)(2906002)(54906002)(4326008)(110136004)(102836003)(33656002)(3280700002)(3846002)(6116002)(5660300001)(6246003)(8936002)(229853002)(86362001)(122556002)(76176999)(3660700001)(8676002)(7736002)(50986999)(54356999)(81166006)(189998001)(305945005)(9686003)(74316002)(6916009)(2950100002)(6506006)(99286003)(77096006)(55016002)(7696004)(6436002)(66066001); DIR:OUT; SFP:1101; SCL:1; SRVR:BY2PR0701MB2101; H:BY2PR0701MB2101.namprd07.prod.outlook.com; FPR:; SPF:None; MLV:sfv; LANG:en; spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: cavium.com X-MS-Exchange-CrossTenant-originalarrivaltime: 26 Apr 2017 09:26:14.6403 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR0701MB2101 Subject: Re: [dpdk-dev] dpdk-devbind can't be used misc with kernel tools 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" Hi LijuanX A Response inline... Kindly apply the patch below (inline) and let me know the result. I will submit a formal patch once you confirm. Thanks, Prathyusha From: Tu, LijuanX A Sent: Wednesday, April 26, 2017 11:49 AM To: Prathyusha, Guduri Cc: dev@dpdk.org; Chen, WeichunX; Liu, Yu Y; Xu, Qian Q; Liu, Yong; Lu, PeipeiX Subject: dpdk-devbind can't be used misc with kernel tools   Hi Guduri,   I am a tester from intel dpdk team. I get a issues on usertools/dpdk-devbind.py   With the usertools/dpdk-devbind.py , I can’t bind driver as expect.   I use the “dpdk-devbind.py” bind pci to igb_uio, then I using kernel tools  bind pci  to ixgbe, I can bind pci to igb_uio successfully ,but it  bind back to ixgbe failed.. /sys/bus/pci/devices/xxxxxx/driver_override is used to bind and unbind devices to drivers in kernels >= 3.15 driver_override must be written to null for a device to bind to a driver. In the current script, null is written before unbinding a device. Hence when you bind a device using script and unbind using kernel tools (/sys/bus/pci/drivers/xx/new_id, >>/sys/bus/pci/devices/xx/driver/unbind, /sys/bus/pci/drivers/xx/bind), driver_override is still set to the previous driver. To avoid this, writing null to driver_override after binding a device to a driver. This will let the kernel tools unbind after binding using the dpdk script.   Bind pci to igb_uio and then  bind to ixgbe ,both use “dpdk-devbind.py”, it works well.   Could you . have a look at this as soon as possible ,it block the daily regression test. Thank you very much. Here is the patch to be applied     There are my test env and steps:   dpdk commit eba33e87ad37626604be7186e746751f99691084 Components: usertools/dpdk-devbind.py kernel: 4.8.6-300.fc25.x86_64 driver: ixgbe version: 5.0.4 firmware-version: 0x61bf0001 Expect: we can use dpdk-devbind.py to bind or unbind PCI-device, we also can use kernel tools to bind or unbind PCI-device, such as : steps: # ./dpdk-devbind.py --bind=igb_uio 0000:05:00.0 status: 0000:05:00.0 '82599ES 10-Gigabit SFI/SFP+ Network Connection 10fb' drv=igb_uio unused=   # echo "8086 10fd" >/sys/bus/pci/drivers/ixgbe/new_id # echo "0000:05:00.0" >/sys/bus/pci/devices/0000\:05\:00.0/driver/unbind # echo "0000:05:00.0" >/sys/bus/pci/drivers/ixgbe/ # echo "0000:05:00.0" >/sys/bus/pci/drivers/ixgbe/bind -bash: echo: write error: No such device status 0000:05:00.0 '82599ES 10-Gigabit SFI/SFP+ Network Connection' unused=ixgbe,igb_uio Result: It can't bind to ixgbe, expect it can bind to ixgbe. I think the related commit are :: commit 2fc3502935700243d9a6d903166e6fd11e429843 Author: Guduri Prathyusha Date:   Wed Mar 22 19:41:29 2017 +0530 usertools: use optimized driver override scheme to bind   commit c3ce205d5729867bd1c4c4429a80e01a528d5905 Author: Guduri Prathyusha Date:   Wed Mar 22 19:41:28 2017 +0530     usertools: optimize lspci invocation 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"""