From: Yongxin Liu <yongxin.liu@windriver.com>
To: dev@dpdk.org, anatoly.burakov@intel.com, thomas@monjalon.net
Subject: [dpdk-dev] [PATCH v4] usertools/devbind: fix binding for built-in kernel drivers
Date: Fri, 20 Nov 2020 10:22:33 +0800 [thread overview]
Message-ID: <20201120022233.25498-1-yongxin.liu@windriver.com> (raw)
In-Reply-To: <20201118025854.13455-1-yongxin.liu@windriver.com>
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.
Thanks for Anatoly Burakov's advice.
Signed-off-by: Yongxin Liu <yongxin.liu@windriver.com>
---
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 | 19 ++++++++++++++++++-
1 file changed, 18 insertions(+), 1 deletion(-)
diff --git a/usertools/dpdk-devbind.py b/usertools/dpdk-devbind.py
index 99112b7ab..06721709c 100755
--- a/usertools/dpdk-devbind.py
+++ b/usertools/dpdk-devbind.py
@@ -7,6 +7,7 @@
import os
import getopt
import subprocess
+import platform
from glob import glob
from os.path import exists, abspath, dirname, basename
from os.path import join as path_join
@@ -181,7 +182,23 @@ 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:
+ f = open(filename, "r")
+ except:
+ print("Error: cannot open %s" % filename)
+ return
+
+ builtin_mods = f.readlines()
+
+ for mod in builtin_mods:
+ mod_name = os.path.splitext(os.path.basename(mod))
+ loaded_modules.append(mod_name[0])
+
+ return module in loaded_modules
def check_modules():
--
2.14.4
next prev parent reply other threads:[~2020-11-20 2:27 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-18 2:58 [dpdk-dev] [PATCH v2] usertools/devbind: fix binding for built-in 1kernel drivers Yongxin Liu
2020-11-18 16:27 ` Burakov, Anatoly
2020-11-19 7:24 ` Liu, Yongxin
2020-11-19 7:16 ` [dpdk-dev] [PATCH v3] usertools/devbind: fix binding for built-in kernel drivers Yongxin Liu
2020-11-19 12:18 ` Burakov, Anatoly
2020-11-20 2:30 ` Liu, Yongxin
2020-11-20 2:22 ` Yongxin Liu [this message]
2020-11-20 10:49 ` [dpdk-dev] [PATCH v4] " Burakov, Anatoly
2020-11-20 11:38 ` Burakov, Anatoly
2020-11-23 3:05 ` [dpdk-dev] [PATCH v5] " Yongxin Liu
2020-12-03 8:25 ` Liu, Yongxin
2021-02-11 10:43 ` Burakov, Anatoly
2021-02-11 22:19 ` Thomas Monjalon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201120022233.25498-1-yongxin.liu@windriver.com \
--to=yongxin.liu@windriver.com \
--cc=anatoly.burakov@intel.com \
--cc=dev@dpdk.org \
--cc=thomas@monjalon.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).