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 2CB22A04B1; Mon, 23 Nov 2020 04:10:26 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 0F80B375B; Mon, 23 Nov 2020 04:10:25 +0100 (CET) Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2086.outbound.protection.outlook.com [40.107.93.86]) by dpdk.org (Postfix) with ESMTP id 537E623D for ; Mon, 23 Nov 2020 04:10:22 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=R7cxpFdEW3l/CXI+PsDVzKeh8GIHWlcJuEH9Os3MPfhYXGZ51qx6H1o99LaYPZ1zq+/KT6utRXnHG+v4leeI4W1pks7UeGsEmhhP486PlBPmU8opQYVMgKISfZ7apypuD12TLhfd4ReFDq6NnQJKXFSGJfVMqW2f7jkcL1kehRGOBS0XIxRC6Uo3KOsoCfUv5dhKPsN/c8154QB1udISbBUjtQ0mZDmWJgMqN1LwL/lfv8DD1iV8ZpTkXVH00JPrLZacnvIWmEnYPgR3kwr1Iyr+jGtx/7eSoetEDobZjeTV6gNBb8iqQ3eLZcHyxK86XrfMh3AoqM8J+NRAcrG7Cg== 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=TJMBFQzPkL9gO1rXF7t7y3gH8YoOlIqTqs+SmAQJK38=; b=FSql94j1k23rgInswVHW2nQKYIu3AHxaRwaruuOVpcRCivERglQOI0v78Ll+iW7mm3nh28HNslaTATA17rbM/tQWrQpHh9p7MotlxZrzdc/nbtOsC5YZSd1wNu6iXjxKiCCAK9KrIaNZ0A1aF+s4JvM0Stgv46+ilw38A9TA07fDPIW/xNRRo28156XrqSowXyjQCWli93Yocevk5jlEkWJftL9Z4Ftq8mWIK7Jg4lyixol1ROvcpCCo89lTWHlIz87wu7/TMhbmcIxNOdwWTEgBvtUAw/hhySTpDgxBaKAcj+NN04IH9b9xughN5XXbJQB0jBvtmAZOUxlknOd6CA== 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=TJMBFQzPkL9gO1rXF7t7y3gH8YoOlIqTqs+SmAQJK38=; b=YKQ+1L8r+15o2rFtAeuV7qD2qFEhO3MamRisXIfBEKEyaJw5rJBty3kxjow4RHcJGe3Tp3CZIVmFO35PwIXgpBiJKFjTT9KnzAN8xMUF3g+/WXfifj5IJnDL7NOQH4b4S4V3YhV8RME7o2mDuhbrq7ZQ9JpLnc+YDhR8WUVCflk= 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 SJ0PR11MB4960.namprd11.prod.outlook.com (2603:10b6:a03:2ac::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3589.22; Mon, 23 Nov 2020 03:10:19 +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; Mon, 23 Nov 2020 03:10:20 +0000 From: Yongxin Liu To: dev@dpdk.org, anatoly.burakov@intel.com, thomas@monjalon.net Date: Mon, 23 Nov 2020 11:05:33 +0800 Message-Id: <20201123030533.17944-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: HK0PR03CA0103.apcprd03.prod.outlook.com (2603:1096:203:b0::19) 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 HK0PR03CA0103.apcprd03.prod.outlook.com (2603:1096:203:b0::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3589.20 via Frontend Transport; Mon, 23 Nov 2020 03:10:18 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ecf57fc2-87ee-441e-ba88-08d88f5d4f30 X-MS-TrafficTypeDiagnostic: SJ0PR11MB4960: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:359; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: v6AvwB3cJggpinsXO3BN0IYozuFIXVi8dR9YvlqcatWQefdeSc3kawpMsiaGUKBW5V+6JAmeeBXG5FFWFiL1BtgsCR2DDzuLPnIiFWWig5NTtJq84dzJyjIzvjUxb6voHf9X/M7NpRNA2Uemfk1h9AwfqII0hHjy5sbeeVGq1qvrN93DhPzFn/7Hk7U377lypK9Zin7Qg2aetaUNHMegjo3mwin1IgN6KX2N6KPDmJQvvxH4fh+7/t8URwCriMoQhr57YRhmdhwfkGgJD5WQtEzXVeifvBQymh+vM8R7VLCpEuPMu60Wp7XB80E8gyaM 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)(396003)(366004)(39840400004)(376002)(346002)(136003)(478600001)(6666004)(26005)(66946007)(8676002)(6486002)(186003)(6512007)(16526019)(66556008)(66476007)(1076003)(86362001)(36756003)(83380400001)(52116002)(5660300002)(2616005)(956004)(2906002)(44832011)(6506007)(8936002)(316002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: AyZWqH/xA7plaI9SuwphCLNqKROi1l40TYpbTFc9TXXeB/BHn4KGDl+tH/VQNKf9CUiBiIOWeR/wqeqPd3SlT/aiZm6CXQl/Lu0fOl9SDvBPlJMOTuJsV4ZC4t1v4GwSOyqXQf0icXD2uGFQzBNdsC/RoAyU4KswpRxJqIg7KWepVu4E49pY5fPiKuE4woGCLnJQmEeWJBlHFQHfqL2QYtCqcFHaWMxA01Qha4jaxN5+EWe0jFP6XmifZUb55Ms8qA2rGP/C1tQGBDmb9rZ6hMIhgqF2+XLMMweT10eyVkQBwVBg+WP4FUcAKfEBDHmwTE++T642/DYWfhjghnNdwdDWGPJMDqouEvyAJ0p1ozLLCqH007pTxj4/cXMxwndMvnmQQuQGCctVGe/dyqi/Gl82nCJIQiwp8QeWfvWDObXYVtf6L5sOtiFskIrM7KTUA4b2cgdiLmvqNIcHfkHEjUc7vN6KO6tA9XzpM8fKi/pdVbbmnb0bikmZYxS4425CLaTfyIcWuFY+AIg60aRfD+zugv0dDjgSDE4VwBQ3PD4/cXMBHJOYxuD93fs+OBufrjOVXDM1szbwuJWkOJLKxlOMVN88jKekqpN6XmuWytw28a1H96Mk4bylbnDhDwDDS0YhsX0Csho0HrLsCC/VKw== X-OriginatorOrg: windriver.com X-MS-Exchange-CrossTenant-Network-Message-Id: ecf57fc2-87ee-441e-ba88-08d88f5d4f30 X-MS-Exchange-CrossTenant-AuthSource: BYAPR11MB2600.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Nov 2020 03:10:19.8517 (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: Fn5G7Vd4+adPd6pVLsWG4DYorWcHJ/blRW+ynmbJLdfI7DTTg9FjkBSb5VJWOrG46cnPNhS6prs8pqnXq4tGqX4qgap9dFe0mdws+FHxK6Q= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR11MB4960 Subject: [dpdk-dev] [PATCH v5] 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. Signed-off-by: Yongxin Liu --- 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