DPDK patches and discussions
 help / color / mirror / Atom feed
From: Yongxin Liu <yongxin.liu@windriver.com>
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
Date: Mon, 23 Nov 2020 11:05:33 +0800
Message-ID: <20201123030533.17944-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.

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


  parent reply	other threads:[~2020-11-23  3:10 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 ` [dpdk-dev] [PATCH v4] " Yongxin Liu
2020-11-20 10:49   ` Burakov, Anatoly
2020-11-20 11:38   ` Burakov, Anatoly
2020-11-23  3:05 ` Yongxin Liu [this message]
2020-12-03  8:25   ` [dpdk-dev] [PATCH v5] " 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=20201123030533.17944-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

DPDK patches and discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.dpdk.org/dev/0 dev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dev dev/ https://inbox.dpdk.org/dev \
		dev@dpdk.org
	public-inbox-index dev

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.dev


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git