Return-Path: Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by lists.linuxfoundation.org (Postfix) with ESMTP id 78CD2C0037 for ; Mon, 11 Dec 2023 06:37:56 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 4158340278 for ; Mon, 11 Dec 2023 06:37:56 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 4158340278 Authentication-Results: smtp4.osuosl.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=kwE3tR5M X-Virus-Scanned: amavisd-new at osuosl.org X-Spam-Flag: NO X-Spam-Score: -2.101 X-Spam-Level: X-Spam-Status: No, score=-2.101 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id gWc4h8Y9Xkpl for ; Mon, 11 Dec 2023 06:37:55 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) by smtp4.osuosl.org (Postfix) with ESMTPS id 704F9401E0 for ; Mon, 11 Dec 2023 06:37:55 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 704F9401E0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1702276675; x=1733812675; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=5zbT/lA7j5XuNiDdLG1pE2nLG0RLaGxpBZ6EkPZyFao=; b=kwE3tR5M150wb2REC38z7WyzMEf9T0ymPBaAAEOCab2bq7Curpg0VeY1 Uxh1I54J6AVUzpFv6hKdPG0TYvsNoY9AhyFos/2GxZPRvj3ORtDagW0w9 qSBB5b1eRPBHU4ZG36Sp07O8T7D2g+f8DzE2twNZ1Q6DsfZebJy9mamUA b2A925cfwyRxEA+lHB13+V/c7lDk8mxfKYnTkZZERf3DG5QNlnR5n7bw9 18gFM5aUjOG6jwtiW5vbOaSfSzXygdTq6JIvKKuRRqypFBHyoj7N7Is0s o0r0tkyJeRsUtlAn7y0OmiDhk2FL8iEPvR8GzwcUGoF+BmNcTVFT3HfnU w==; X-IronPort-AV: E=McAfee;i="6600,9927,10920"; a="7960127" X-IronPort-AV: E=Sophos;i="6.04,267,1695711600"; d="scan'208";a="7960127" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Dec 2023 22:37:54 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10920"; a="1104353328" X-IronPort-AV: E=Sophos;i="6.04,267,1695711600"; d="scan'208";a="1104353328" Received: from tonydev.sh.intel.com ([10.239.182.127]) by fmsmga005.fm.intel.com with ESMTP; 10 Dec 2023 22:37:52 -0800 From: Tony Zhu To: accel-config@lists.linuxfoundation.org, ramesh.thomas@intel.com, fenghua.yu@intel.com Date: Mon, 11 Dec 2023 14:37:51 +0800 Message-Id: <20231211063751.93534-1-tony.zhu@intel.com> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Accel-config] [PATCH v1 1/1] accel-config/test: disable enabled devices before unloading iaa_crypto X-BeenThere: accel-config@lists.linuxfoundation.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: accel-config List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Dec 2023 06:37:56 -0000 When a idxd device is probed and iaa_crypto will allow the idxd device to be configured with default values. This is kernel change from patch "Add support for device/wq defaults". iaa_crypto could not be removed because this module is used. Before remove it, all enabled dsa/wqs must be disabled. For the reset of idxd driver, must disable all enabled devices. Signed-off-by: Tony Zhu --- test/common | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/test/common b/test/common index 14e7c21..983de4d 100755 --- a/test/common +++ b/test/common @@ -117,10 +117,49 @@ check_prereq() fi } +# Disable all active devices dsa/iax and enabled wqs. +# Use accel-config tool to disable the device and wq. +disable_all() { + for device_type in 'dsa' 'iax'; do + # Kernel before 5.13 has dsa and iax bus. Because of ABI change, iax + # bus is removed. All devices are in /sys/bus/das/devices. + if [ -d /sys/bus/iax ] && [ $device_type == 'iax' ]; then + DSA_DEVICE_PATH="/sys/bus/iax/devices" + else + DSA_DEVICE_PATH="/sys/bus/dsa/devices" + fi + # Get available devices + for device_path in ${DSA_DEVICE_PATH}/${device_type}* ; do + [[ $(echo "$device_path" | grep -c '!') -eq 0 ]] && { + # Get wqs and disable it if the status is enabled + for wqp in ${device_path}/wq* ; do + [[ $( cat "${wqp}"/state ) == "enabled" ]] && { + wq=${wqp##${DSA_DEVICE_PATH}/} + accel-config disable-wq "${wq}" + echo "-1" > "${wqp}"/group_id + } + done + # Disable device + [[ $( cat "${device_path}"/state ) == "enabled" ]] && { + accel-config disable-device "${device_path##${DSA_DEVICE_PATH}/}" + } + # Remove group id of engine + for engine in ${device_path}/engine* ; do + echo -1 > "$engine"/group_id + done + } + done + done +} + # cleanup # _cleanup() { + # iaa_crypto will enable iax devices by default after kernel 6.6, + # need to disable all enabled devices before unloading the module. + disable_all + lsmod | grep -wq idxd_vdev && { rmmod idxd_vdev } -- 2.40.1