diff mbox series

[v5] usertools/devbind: fix binding for built-in kernel drivers

Message ID 20201123030533.17944-1-yongxin.liu@windriver.com (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers show
Series [v5] usertools/devbind: fix binding for built-in kernel drivers | expand

Checks

Context Check Description
ci/travis-robot success Travis build: passed
ci/iol-testing warning Testing issues
ci/Intel-compilation success Compilation OK
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/checkpatch success coding style OK

Commit Message

Liu, Yongxin Nov. 23, 2020, 3:05 a.m. UTC
A driver can be loaded as a dynamic module or a built-in module.
In commit 681a67288655 ("usertools: check if module is loaded
before binding"), script only checks modules in /sys/module/.

However, for built-in kernel driver, it only shows up in /sys/module/,
if it has a version or at least one parameter. So add check for
modules in /lib/modules/$(uname -r)/modules.builtin.

Signed-off-by: Yongxin Liu <yongxin.liu@windriver.com>
---

v5:
 - Make code robust and more memory efficient.

v4:
 - Replace shell call with platform.uname(). Check file existence
   before reading.

v3:
 - Add built-in module list in loaded_modules for checking
   instead of removing error check.

v2:
 - fix git commit description style in commit log
 - fix typo spelling

---
 usertools/dpdk-devbind.py | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

Comments

Liu, Yongxin Dec. 3, 2020, 8:25 a.m. UTC | #1
Hi Anatoly,

Do you have any further comments on this v5?
Or you can submit your own patch directly.

I am really expecting this issue to be fixed.


Thank you very much.

Yongxin

> -----Original Message-----
> From: dev <dev-bounces@dpdk.org> On Behalf Of Yongxin Liu
> Sent: Monday, November 23, 2020 11:06
> To: dev@dpdk.org; anatoly.burakov@intel.com; thomas@monjalon.net
> Subject: [dpdk-dev] [PATCH v5] usertools/devbind: fix binding for built-in
> kernel drivers
> 
> A driver can be loaded as a dynamic module or a built-in module.
> In commit 681a67288655 ("usertools: check if module is loaded before
> binding"), script only checks modules in /sys/module/.
> 
> However, for built-in kernel driver, it only shows up in /sys/module/, if
> it has a version or at least one parameter. So add check for modules in
> /lib/modules/$(uname -r)/modules.builtin.
> 
> Signed-off-by: Yongxin Liu <yongxin.liu@windriver.com>
> ---
> 
> v5:
>  - Make code robust and more memory efficient.
> 
> v4:
>  - Replace shell call with platform.uname(). Check file existence
>    before reading.
> 
> v3:
>  - Add built-in module list in loaded_modules for checking
>    instead of removing error check.
> 
> v2:
>  - fix git commit description style in commit log
>  - fix typo spelling
> 
> ---
>  usertools/dpdk-devbind.py | 13 ++++++++++++-
>  1 file changed, 12 insertions(+), 1 deletion(-)
> 
> diff --git a/usertools/dpdk-devbind.py b/usertools/dpdk-devbind.py index
> 054ad2e1c..4bc0b6207 100755
> --- a/usertools/dpdk-devbind.py
> +++ b/usertools/dpdk-devbind.py
> @@ -7,6 +7,7 @@
>  import os
>  import subprocess
>  import argparse
> +import platform
> 
>  from glob import glob
>  from os.path import exists, basename
> @@ -107,7 +108,17 @@ def module_is_loaded(module):
> 
>      loaded_modules = sysfs_mods
> 
> -    return module in sysfs_mods
> +    # add built-in modules as loaded
> +    release = platform.uname().release
> +    filename = os.path.join("/lib/modules/", release, "modules.builtin")
> +    if os.path.exists(filename):
> +        try:
> +            with open(filename) as f:
> +                loaded_modules +=
> [os.path.splitext(os.path.basename(mod))[0] for mod in f]
> +        except IOError:
> +            print("Warning: cannot read list of built-in kernel
> + modules")
> +
> +    return module in loaded_modules
> 
> 
>  def check_modules():
> --
> 2.14.4
Anatoly Burakov Feb. 11, 2021, 10:43 a.m. UTC | #2
On 03-Dec-20 8:25 AM, Liu, Yongxin wrote:
> Hi Anatoly,
> 
> Do you have any further comments on this v5?
> Or you can submit your own patch directly.
> 
> I am really expecting this issue to be fixed.
> 
> 
> Thank you very much.
> 
> Yongxin
> 
>> -----Original Message-----
>> From: dev <dev-bounces@dpdk.org> On Behalf Of Yongxin Liu
>> Sent: Monday, November 23, 2020 11:06
>> To: dev@dpdk.org; anatoly.burakov@intel.com; thomas@monjalon.net
>> Subject: [dpdk-dev] [PATCH v5] usertools/devbind: fix binding for built-in
>> kernel drivers
>>
>> A driver can be loaded as a dynamic module or a built-in module.
>> In commit 681a67288655 ("usertools: check if module is loaded before
>> binding"), script only checks modules in /sys/module/.
>>
>> However, for built-in kernel driver, it only shows up in /sys/module/, if
>> it has a version or at least one parameter. So add check for modules in
>> /lib/modules/$(uname -r)/modules.builtin.
>>
>> Signed-off-by: Yongxin Liu <yongxin.liu@windriver.com>
>> ---
>>
>> v5:
>>   - Make code robust and more memory efficient.
>>
>> v4:
>>   - Replace shell call with platform.uname(). Check file existence
>>     before reading.
>>
>> v3:
>>   - Add built-in module list in loaded_modules for checking
>>     instead of removing error check.
>>
>> v2:
>>   - fix git commit description style in commit log
>>   - fix typo spelling
>>
>> ---

Apologies for the delay.

Reviewed-by: Anatoly Burakov <anatoly.burakov@intel.com>
Thomas Monjalon Feb. 11, 2021, 10:19 p.m. UTC | #3
> >> A driver can be loaded as a dynamic module or a built-in module.
> >> In commit 681a67288655 ("usertools: check if module is loaded before
> >> binding"), script only checks modules in /sys/module/.
> >>
> >> However, for built-in kernel driver, it only shows up in /sys/module/, if
> >> it has a version or at least one parameter. So add check for modules in
> >> /lib/modules/$(uname -r)/modules.builtin.
> >>
> >> Signed-off-by: Yongxin Liu <yongxin.liu@windriver.com>
> 
> Apologies for the delay.
> 
> Reviewed-by: Anatoly Burakov <anatoly.burakov@intel.com>

Fixes: 681a67288655 ("usertools: check if module is loaded before binding")
Cc: stable@dpdk.org

Applied, thanks
diff mbox series

Patch

diff --git a/usertools/dpdk-devbind.py b/usertools/dpdk-devbind.py
index 054ad2e1c..4bc0b6207 100755
--- a/usertools/dpdk-devbind.py
+++ b/usertools/dpdk-devbind.py
@@ -7,6 +7,7 @@ 
 import os
 import subprocess
 import argparse
+import platform
 
 from glob import glob
 from os.path import exists, basename
@@ -107,7 +108,17 @@  def module_is_loaded(module):
 
     loaded_modules = sysfs_mods
 
-    return module in sysfs_mods
+    # add built-in modules as loaded
+    release = platform.uname().release
+    filename = os.path.join("/lib/modules/", release, "modules.builtin")
+    if os.path.exists(filename):
+        try:
+            with open(filename) as f:
+                loaded_modules += [os.path.splitext(os.path.basename(mod))[0] for mod in f]
+        except IOError:
+            print("Warning: cannot read list of built-in kernel modules")
+
+    return module in loaded_modules
 
 
 def check_modules():