Skip to content

Commit

Permalink
usertools: fix binding built-in kernel driver
Browse files Browse the repository at this point in the history
[ upstream commit 7a016af ]

A driver can be loaded as a dynamic module or a built-in module.
In commit 681a672 ("usertools: check if module is loaded
before binding"), the 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.

Fixes: 681a672 ("usertools: check if module is loaded before binding")

Signed-off-by: Yongxin Liu <yongxin.liu@windriver.com>
Reviewed-by: Anatoly Burakov <anatoly.burakov@intel.com>
  • Loading branch information
liux2085 authored and bluca committed Feb 12, 2021
1 parent ef01e05 commit 80fd7cc
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion usertools/dpdk-devbind.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import os
import subprocess
import argparse
import platform

from glob import glob
from os.path import exists, basename
Expand Down Expand Up @@ -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():
Expand Down

0 comments on commit 80fd7cc

Please sign in to comment.