From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 7C3C9A04DD; Fri, 20 Nov 2020 03:27:07 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 475C14C90; Fri, 20 Nov 2020 03:27:05 +0100 (CET) Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2073.outbound.protection.outlook.com [40.107.243.73]) by dpdk.org (Postfix) with ESMTP id C93D7F90 for ; Fri, 20 Nov 2020 03:27:01 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mQQ0EUNSlml4l/BRI8gihDpTQIptX2ZgdVxU40saG+k+JGzpunfYR6dKPQo169jKn6ey7N6lgmMOHxDO+a0LV4QWCuhoAwF6pt11lbPuxr//oH5K+7EB/FZ4amZE8RGCv8DMMdD8PfoLPBK19nV+pVKaJ+W4RAwSKJK2kehwXS3wO9KOOeIankzvjw9+OPckCLtYoavFZu4JX/kAvD7VboNZb9ob/c17eeq47k9GosqmFqOJnHZ/Z4LhnE79qxyFuHUydA8wtc/GCJApxRHeCBQK32hbgK19cvOX8RjO8YW0t1nlkd27PxrO6wP49kxYfqprX8L1bfapbRdAN1U9Lw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=h4utdfack6AOXLN4q87uJg6JXVp9BGYkGiRZzmMYCGI=; b=PprwKQURim9x3MyfnZvQtMULASb/xpiCZG3LOiYtO81hvj/tSyAkE3Nz/YQsuPqcqUWk3SZk1nvl9CAih3b9mETR4cDYcyFXhOKoN4vibR5zov8t5M6oU85G2VQgPt30dwCKAjtvjTjdrbxxSlHepzh3YPNVo8RbnosIaH163biEcvrJlVScbWkid5ihPXi212OQc1PtiS2PrQjZkWNYDePhQvjwZbHsXebDNNdYNHMSXSG0v52hXJ9tv6L1geyhUXeoNK8QgaZr2fRULjWrD9Mk4Sg7zHOWZSPps+rIzdXN/PbVsq61ZjXcSRNJnnLQ806jjTqu3cXy8fjVotIFqQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=windriver.com; dmarc=pass action=none header.from=windriver.com; dkim=pass header.d=windriver.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=windriversystems.onmicrosoft.com; s=selector2-windriversystems-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=h4utdfack6AOXLN4q87uJg6JXVp9BGYkGiRZzmMYCGI=; b=kjyHJAbIwisZRLIxR7WpUeK1/3+bUMKme/wgMfcRHwoHsOGSVDT0tv0Zdd29sSgSaJUbw+a6cPmqJm/Tfb1lILabkqw1Bk2Os/q1vzqo5pjMFcdKPWUe8koozkhlbzMPj8GFHwzIwLB8nEG109sUyRw5WHwqxdHQ+Oxtv2CIZrk= Authentication-Results: dpdk.org; dkim=none (message not signed) header.d=none;dpdk.org; dmarc=none action=none header.from=windriver.com; Received: from BYAPR11MB2600.namprd11.prod.outlook.com (2603:10b6:a02:c8::15) by BY5PR11MB3973.namprd11.prod.outlook.com (2603:10b6:a03:185::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3564.28; Fri, 20 Nov 2020 02:26:59 +0000 Received: from BYAPR11MB2600.namprd11.prod.outlook.com ([fe80::9c3a:15e0:fe83:ffd9]) by BYAPR11MB2600.namprd11.prod.outlook.com ([fe80::9c3a:15e0:fe83:ffd9%7]) with mapi id 15.20.3589.022; Fri, 20 Nov 2020 02:26:58 +0000 From: Yongxin Liu To: dev@dpdk.org, anatoly.burakov@intel.com, thomas@monjalon.net Date: Fri, 20 Nov 2020 10:22:33 +0800 Message-Id: <20201120022233.25498-1-yongxin.liu@windriver.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20201118025854.13455-1-yongxin.liu@windriver.com> References: <20201118025854.13455-1-yongxin.liu@windriver.com> Content-Type: text/plain X-Originating-IP: [60.247.85.82] X-ClientProxiedBy: HK2PR06CA0015.apcprd06.prod.outlook.com (2603:1096:202:2e::27) To BYAPR11MB2600.namprd11.prod.outlook.com (2603:10b6:a02:c8::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from pek-lpggp6.wrs.com (60.247.85.82) by HK2PR06CA0015.apcprd06.prod.outlook.com (2603:1096:202:2e::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3589.20 via Frontend Transport; Fri, 20 Nov 2020 02:26:57 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 335bfedd-d1c4-4bfd-7ddb-08d88cfbc1ab X-MS-TrafficTypeDiagnostic: BY5PR11MB3973: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:446; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: BS8itKp9kTkEwH3r0ZSAogbfcJjTLYffWrYIYnLgKtYPDSSvb/HucnwEWuDxU5/G/JhxOxoj1Z75wrGIeb9SDds8TZMVxQ/E25KUUpyNmp0mBf+IiQIP+NRAb3xi3kRiTJQgu3jb4VWm4JKGnNrdnvuc6hhvVoqP3Y+O8lKva8qXzLab1xzyx1107pHKD+BPESZTISidXBLy5R5S6P43QiJEScwnTPIg58LaZUwYTQkszYHqYl8tNwof1zGBIrFc6mm7MlJrTazfU16/IQFF3Wp4F19tbcgYirN8z0DE/6SoOtolYgIrf7wNbWs5Baxd2q5eULZl6kUUzo8QFXOgGw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR11MB2600.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(346002)(366004)(136003)(376002)(39850400004)(396003)(2616005)(956004)(478600001)(6506007)(6512007)(44832011)(186003)(83380400001)(8676002)(52116002)(5660300002)(66476007)(26005)(66556008)(16526019)(8936002)(66946007)(1076003)(36756003)(2906002)(6486002)(86362001)(6666004)(316002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: /cxb7UEIiVXMFcD0Zd+sJsuPhyyiPXr8fpW0WzJVYTpNHJQICX/nG9uLtt1upWsQ6ZbHylUisoemNmSc8RsAgBnjxIlKYw5iaSfLHb0lBMt+FZQgzIklPKyb6oFfHnAF7GdNptMPpfb8UwHjGcpfYCO7jsuiu9nRS9xFuSycv50gttNiSCRQaXiq/IVXkOs3tm6wozrboKCx4TDqsgjkV+qHuEsfes1w7vCW5R7osbTHtzCtE/HsUo+RPrrCIpWyuYVBRfmQX4kIHtO6zzqxq+QG18fBXqTDuI3eH7YipLCKMQDffAluK2wICY+EkB7VetUeNIGG7n7nROYjnDxi+2MzUNuztkIjAgAxcMeAcBrgp9P1ugAFeFlkbIRVGIQZs/IfQhiUmJ4mqqJPrGbBPV5T5KaKVCIm2PH1w7ApYDR/AlBS+pIt7XWG0W19cCFZaBzRN/qXRbmc+HTsLQGTHNhvsLh7ZKJr041mkfrfnwgCNVUX46SOpxkVLHhXIuZhY3tS0kiJSqD4KZdpo4iuHT6PJVYDGwcrtPF+EWoq6LeKIkmWPYY7thD96jARXxaghiaSduM9i+Juoss+Wc9+RquXe2fyYci/nSjD5XyVZ429eI5nxrlWloXPyYOMoYIk1ZSWIUUH+w7vyjIxdpANag== X-OriginatorOrg: windriver.com X-MS-Exchange-CrossTenant-Network-Message-Id: 335bfedd-d1c4-4bfd-7ddb-08d88cfbc1ab X-MS-Exchange-CrossTenant-AuthSource: BYAPR11MB2600.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Nov 2020 02:26:58.8565 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 8ddb2873-a1ad-4a18-ae4e-4644631433be X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: xdZ0tv53qmKn58oPUM3boQqH97wWAaeSOsrPhR2XbvTziRUvR3zXn1ECzFojEV6B00LwDHlwfVSrCahS4AM8kLAviEcglWrvEGfXkbztl9U= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR11MB3973 Subject: [dpdk-dev] [PATCH v4] usertools/devbind: fix binding for built-in kernel drivers 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" 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 --- 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