From nobody Fri Dec 19 01:16:57 2025 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.13]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A5201179B2; Tue, 30 Apr 2024 03:31:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.13 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714447895; cv=none; b=mBNSLc/DTj41Baf7V3e7QJaFAv5X6t7/O29OMW4TjyWZj98An1AK1Nn2SRQalW18QmNVW5yaQRhh79JvUfCYc64XIfMFBUFKNts2Qko+kEwTFkP20M8XXidabhJr+QyZYRJm1cFIwJCHCC6L4vggHc5Tgpl7Tuyx+NMvCz9bwfI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714447895; c=relaxed/simple; bh=l3atzUkPqdTg5c89tRfCdE8NJod9oiE8nTavithueLM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bdYNiiU1HsUQro0f41FepTJkCC6V7O9adTfK+dyue1p9K3pv57dgXtLLxtu4ddNUBQGnhNE1x+s7UipCOMxzaf2i9GgEz8g1WQ2Hl3j2Z7SevlFMp/EmJ2pq2vioEAdxLGzi8wihB7LfQ04MHNcFbaLlQYlYbcF7eQkuohLVPgA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=AmAVtwnf; arc=none smtp.client-ip=198.175.65.13 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="AmAVtwnf" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1714447894; x=1745983894; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=l3atzUkPqdTg5c89tRfCdE8NJod9oiE8nTavithueLM=; b=AmAVtwnfgR8n0K6acbKtT5a5bYX6u27qoOBl6mMWA4Qk8MCqBnpUz1+h xJ4AXrEmSYT08IrG86mrk0gDUjX/L15BJZM5Wp/3hWWFpLW43Grp3a+dw kH4ZyrAabDKwPG7rlL3lbA0PKQ4AknzYHJuzolVkfuLwmzkxuWOvtM/Ev RaESf0Y9djLdmdVd3T7hK5kd194KwiWH8XkP85Ua/oaDpjJZur1KFGDEb PHO6GP5j+b8nZ0NQtIXzWaJ/6hdg34EPdKia5PwS7VPS7h7qg7rcmhb86 mNxkfLqzU+JvxdIvMPJARWCkSU0pv0j5yi1O+A8gzPapVG6COaFX5dtZv g==; X-CSE-ConnectionGUID: o0TZsQ0gQSau7mHQ8PseNA== X-CSE-MsgGUID: hlOAsXaQTHWXpemHOBUNxQ== X-IronPort-AV: E=McAfee;i="6600,9927,11059"; a="21284187" X-IronPort-AV: E=Sophos;i="6.07,241,1708416000"; d="scan'208";a="21284187" Received: from orviesa007.jf.intel.com ([10.64.159.147]) by orvoesa105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Apr 2024 20:31:34 -0700 X-CSE-ConnectionGUID: CeJVoS+rSX+HmFhkmTR3Ww== X-CSE-MsgGUID: fchqet6/Soi96GtiH+Uk3A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,241,1708416000"; d="scan'208";a="26820008" Received: from xpf.sh.intel.com ([10.239.182.130]) by orviesa007.jf.intel.com with ESMTP; 29 Apr 2024 20:31:31 -0700 From: Pengfei Xu To: Shuah Khan , shuah@kernel.org, linux-kselftest Cc: linux-kernel , jithu.joseph@intel.com, Pengfei Xu , ashok.raj@intel.com, sathyanarayanan.kuppuswamy@intel.com Subject: [PATCH v1 3/4] selftests: ifs: verify IFS scan test functionality Date: Tue, 30 Apr 2024 11:31:47 +0800 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Two selftests are added to verify IFS scan test feature: 1. Perform IFS scan test once on each CPU using all the available image files. 2. Perform IFS scan test with the default image on a random cpu for 3 rounds. Reviewed-by: Jithu Joseph Co-developed-by: Ashok Raj Signed-off-by: Ashok Raj Signed-off-by: Pengfei Xu --- .../platform/x86/intel/ifs/test_ifs.sh | 190 +++++++++++++++++- 1 file changed, 189 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/drivers/platform/x86/intel/ifs/test_if= s.sh b/tools/testing/selftests/drivers/platform/x86/intel/ifs/test_ifs.sh index 2a4df745bf6f..63d13400af4f 100755 --- a/tools/testing/selftests/drivers/platform/x86/intel/ifs/test_ifs.sh +++ b/tools/testing/selftests/drivers/platform/x86/intel/ifs/test_ifs.sh @@ -10,16 +10,25 @@ readonly KSFT_FAIL=3D1 readonly KSFT_XFAIL=3D2 readonly KSFT_SKIP=3D4 =20 +readonly CPU_SYSFS=3D"/sys/devices/system/cpu" +readonly CPU_OFFLINE_SYSFS=3D"${CPU_SYSFS}/offline" readonly IMG_PATH=3D"/lib/firmware/intel/ifs_0" readonly IFS_SCAN_MODE=3D"0" +readonly IFS_ARRAY_BIST_SCAN_MODE=3D"1" readonly IFS_PATH=3D"/sys/devices/virtual/misc/intel_ifs" readonly IFS_SCAN_SYSFS_PATH=3D"${IFS_PATH}_${IFS_SCAN_MODE}" +readonly RUN_TEST=3D"run_test" +readonly STATUS=3D"status" +readonly DETAILS=3D"details" +readonly STATUS_PASS=3D"pass" readonly PASS=3D"PASS" readonly FAIL=3D"FAIL" readonly INFO=3D"INFO" readonly XFAIL=3D"XFAIL" readonly SKIP=3D"SKIP" readonly IFS_NAME=3D"intel_ifs" +readonly ALL=3D"all" +readonly SIBLINGS=3D"siblings" =20 # Matches arch/x86/include/asm/intel-family.h and # drivers/platform/x86/intel/ifs/core.c requirement as follows @@ -28,6 +37,7 @@ readonly EMERALDRAPIDS_X=3D"cf" =20 readonly INTEL_FAM6=3D"06" =20 +LOOP_TIMES=3D3 FML=3D"" MODEL=3D"" STEPPING=3D"" @@ -36,11 +46,13 @@ TRUE=3D"true" FALSE=3D"false" RESULT=3D$KSFT_PASS IMAGE_NAME=3D"" -export INTERVAL_TIME=3D1 +INTERVAL_TIME=3D1 +OFFLINE_CPUS=3D"" # For IFS cleanup tags ORIGIN_IFS_LOADED=3D"" IFS_IMAGE_NEED_RESTORE=3D$FALSE IFS_LOG=3D"/tmp/ifs_logs.$$" +RANDOM_CPU=3D"" DEFAULT_IMG_ID=3D"" =20 append_log() @@ -48,6 +60,35 @@ append_log() echo -e "$1" | tee -a "$IFS_LOG" } =20 +online_offline_cpu_list() +{ + local on_off=3D$1 + local target_cpus=3D$2 + local cpu=3D"" + local cpu_start=3D"" + local cpu_end=3D"" + local i=3D"" + + if [[ -n "$target_cpus" ]]; then + for cpu in $(echo "$target_cpus" | tr ',' ' '); do + if [[ "$cpu" =3D=3D *"-"* ]]; then + cpu_start=3D"" + cpu_end=3D"" + i=3D"" + cpu_start=3D$(echo "$cpu" | cut -d "-" -f 1) + cpu_end=3D$(echo "$cpu" | cut -d "-" -f 2) + for((i=3Dcpu_start;i<=3Dcpu_end;i++)); do + append_log "[$INFO] echo $on_off > \ +${CPU_SYSFS}/cpu${i}/online" + echo "$on_off" > "$CPU_SYSFS"/cpu"$i"/online + done + else + set_target_cpu "$on_off" "$cpu" + fi + done + fi +} + ifs_scan_result_summary() { local failed_info pass_num skip_num fail_num @@ -80,6 +121,9 @@ ifs_cleanup() mv -f "$IMG_PATH"/"$IMAGE_NAME"_origin "$IMG_PATH"/"$IMAGE_NAME" } =20 + # Restore the CPUs to the state before testing + [[ -z "$OFFLINE_CPUS" ]] || online_offline_cpu_list "0" "$OFFLINE_CPUS" + lsmod | grep -q "$IFS_NAME" && [[ "$ORIGIN_IFS_LOADED" =3D=3D "$FALSE" ]]= && { echo "[$INFO] modprobe -r $IFS_NAME" modprobe -r "$IFS_NAME" @@ -122,6 +166,23 @@ test_exit() ifs_cleanup } =20 +online_all_cpus() +{ + local off_cpus=3D"" + + OFFLINE_CPUS=3D$(cat "$CPU_OFFLINE_SYSFS") + online_offline_cpu_list "1" "$OFFLINE_CPUS" + + off_cpus=3D$(cat "$CPU_OFFLINE_SYSFS") + if [[ -z "$off_cpus" ]]; then + append_log "[$INFO] All CPUs are online." + else + append_log "[$XFAIL] There is offline cpu:$off_cpus after online all cpu= !" + RESULT=3D$KSFT_XFAIL + ifs_cleanup + fi +} + get_cpu_fms() { FML=3D$(grep -m 1 "family" /proc/cpuinfo | awk -F ":" '{printf "%02x",$2;= }') @@ -270,10 +331,135 @@ test_bad_and_origin_ifs_image() append_log "[$INFO] Loading invalid IFS image and then loading initial im= age passed.\n" } =20 +ifs_test_cpu() +{ + local ifs_mode=3D$1 + local cpu_num=3D$2 + local image_id status details ret result result_info + + echo "$cpu_num" > "$IFS_PATH"_"$ifs_mode"/"$RUN_TEST" + ret=3D$? + + status=3D$(cat "${IFS_PATH}_${ifs_mode}/${STATUS}") + details=3D$(cat "${IFS_PATH}_${ifs_mode}/${DETAILS}") + + if [[ "$ret" -eq 0 && "$status" =3D=3D "$STATUS_PASS" ]]; then + result=3D"$PASS" + else + result=3D"$FAIL" + fi + + cpu_num=3D$(cat "${CPU_SYSFS}/cpu${cpu_num}/topology/thread_siblings_list= ") + + # There is no image file for IFS ARRAY BIST scan + if [[ -e "${IFS_PATH}_${ifs_mode}/current_batch" ]]; then + image_id=3D$(cat "${IFS_PATH}_${ifs_mode}/current_batch") + result_info=3D$(printf "[%s] ifs_%1d cpu(s):%s, current_batch:0x%02x, \ +ret:%2d, status:%s, details:0x%016x" \ + "$result" "$ifs_mode" "$cpu_num" "$image_id" "$ret" \ + "$status" "$details") + else + result_info=3D$(printf "[%s] ifs_%1d cpu(s):%s, ret:%2d, status:%s, deta= ils:0x%016x" \ + "$result" "$ifs_mode" "$cpu_num" "$ret" "$status" "$details") + fi + + append_log "$result_info" +} + +ifs_test_cpus() +{ + local cpus_type=3D$1 + local ifs_mode=3D$2 + local image_id=3D$3 + local cpu_max_num=3D"" + local cpu_num=3D"" + + case "$cpus_type" in + "$ALL") + cpu_max_num=3D$(($(nproc) - 1)) + cpus=3D$(seq 0 $cpu_max_num) + ;; + "$SIBLINGS") + cpus=3D$(cat ${CPU_SYSFS}/cpu*/topology/thread_siblings_list \ + | sed -e 's/,.*//' \ + | sed -e 's/-.*//' \ + | sort -n \ + | uniq) + ;; + *) + test_exit "Invalid cpus_type:$cpus_type" "$KSFT_XFAIL" + ;; + esac + + for cpu_num in $cpus; do + ifs_test_cpu "$ifs_mode" "$cpu_num" + done + + if [[ -z "$image_id" ]]; then + append_log "[$INFO] ifs_$ifs_mode test $cpus_type cpus completed\n" + else + append_log "[$INFO] ifs_$ifs_mode $cpus_type cpus with $CPU_FMS-$image_i= d.scan \ +completed\n" + fi +} + +test_ifs_same_cpu_loop() +{ + local ifs_mode=3D$1 + local cpu_num=3D$2 + local loop_times=3D$3 + + append_log "[$INFO] Test ifs mode $ifs_mode on CPU:$cpu_num for $loop_tim= es rounds:" + [[ "$ifs_mode" =3D=3D "$IFS_SCAN_MODE" ]] && { + load_image "$DEFAULT_IMG_ID" || return $? + } + for (( i=3D1; i<=3Dloop_times; i++ )); do + append_log "[$INFO] Loop iteration: $i in total of $loop_times" + # Only IFS scan needs the interval time + if [[ "$ifs_mode" =3D=3D "$IFS_SCAN_MODE" ]]; then + do_cmd "sleep $INTERVAL_TIME" + elif [[ "$ifs_mode" =3D=3D "$IFS_ARRAY_BIST_SCAN_MODE" ]]; then + true + else + test_exit "Invalid ifs_mode:$ifs_mode" "$KSFT_XFAIL" + fi + + ifs_test_cpu "$ifs_mode" "$cpu_num" + done + append_log "[$INFO] $loop_times rounds of ifs_$ifs_mode test on CPU:$cpu_= num completed.\n" +} + +test_ifs_scan_available_imgs() +{ + local image_ids=3D"" + local image_id=3D"" + + append_log "[$INFO] Test ifs scan with available images:" + image_ids=3D$(find "$IMG_PATH" -maxdepth 1 -name "${CPU_FMS}-[0-9a-fA-F][= 0-9a-fA-F].scan" \ + 2>/dev/null \ + | sort \ + | awk -F "-" '{print $NF}' \ + | cut -d "." -f 1) + + for image_id in $image_ids; do + load_image "$image_id" || return $? + + ifs_test_cpus "$SIBLINGS" "$IFS_SCAN_MODE" "$image_id" + # IFS scan requires time interval for the scan on the same CPU + do_cmd "sleep $INTERVAL_TIME" + done +} + prepare_ifs_test_env() { + local max_cpu=3D"" + check_cpu_ifs_support_interval_time =20 + online_all_cpus + max_cpu=3D$(($(nproc) - 1)) + RANDOM_CPU=3D$(shuf -i 0-$max_cpu -n 1) + DEFAULT_IMG_ID=3D$(find $IMG_PATH -maxdepth 1 -name "${CPU_FMS}-[0-9a-fA-= F][0-9a-fA-F].scan" \ 2>/dev/null \ | sort \ @@ -292,6 +478,8 @@ test_ifs() append_log "[$SKIP] No proper ${IMG_PATH}/${CPU_FMS}-*.scan, skip ifs_0 = scan" else test_bad_and_origin_ifs_image "$DEFAULT_IMG_ID" + test_ifs_scan_available_imgs + test_ifs_same_cpu_loop "$IFS_SCAN_MODE" "$RANDOM_CPU" "$LOOP_TIMES" fi } =20 --=20 2.43.0