From patchwork Thu Jan 25 08:22:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Ashok Raj X-Patchwork-Id: 13530212 X-Patchwork-Delegate: hdegoede@redhat.com Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.14]) (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 88B2B1798E; Thu, 25 Jan 2024 08:23:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.14 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706171006; cv=none; b=uQRJP3y7tOcbHWaPU+vlsrAuZRcHsg6NNFjMzTiDRdeT+hnuuyM2bc+5qimNM+aN2bQK1N2EUw7F47+uQ+luc1ZOAy1LK70msWn9E9YMFUSd7kqcbR3gVEzf8bAhci22tVf3VC7nnEn0LNni5IPfN1o1RnQAVDI6/qlP30K5P6A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706171006; c=relaxed/simple; bh=if8v2kup1nIzoficv1uxi7vRkXghvMvZw9xTx9Js46E=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=c7I/2VOgmPQQAc2exxbdIwG3V5ozJcQKHeRy9QqGBRoleRXLtrFwH84lvIoxWRT/+TxDo+gLxnfFp0nKi4QDbvnJmUcAmrGpjpkvyivztnEU35Ct/OhqrOUn5rwPkYwMMFlHuATewytWNL6Z/9k1otFvNEhmiMEa1pOL7/Ckub8= 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=gV/1sJ9D; arc=none smtp.client-ip=198.175.65.14 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="gV/1sJ9D" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1706171005; x=1737707005; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=if8v2kup1nIzoficv1uxi7vRkXghvMvZw9xTx9Js46E=; b=gV/1sJ9Dc8ZKNJEko/Vz2q+3vaOnmbE036MJS20VQW33i2XnwrB7pNzI QhCgPsm4x1sgv/bNNga61p7ofkDJY1xWs66mAebj+QNVaD90/pmVTEBba 0yxP9+VmD4x92ZEP3e/WoQBDOajWwkIQ1sx/JoSur7iJQ0n/o+kfqJH+1 AXN/anS4+Es0u4Y2FALmkYLD2t9I/G0Tcp3tSBC5iMzWzDYCKH+nCw/WO jqNLEtlo1X3iAZs+B/ybQj38odvC401xiZCsTN8kQ65oE2di2aFhwZMyF 0q2J6R7mcUVFKWyuwX7ow8QPYEqmiQi2kNY7N0bGWRz0UapHimY6PzzfC g==; X-IronPort-AV: E=McAfee;i="6600,9927,10962"; a="1987169" X-IronPort-AV: E=Sophos;i="6.05,216,1701158400"; d="scan'208";a="1987169" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orvoesa106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jan 2024 00:23:23 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10962"; a="876975923" X-IronPort-AV: E=Sophos;i="6.05,216,1701158400"; d="scan'208";a="876975923" Received: from araj-ucode.jf.intel.com ([10.23.0.11]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jan 2024 00:23:22 -0800 From: Ashok Raj To: Hans de Goede , Ilpo Jarvinen , markgross@kernel.org Cc: Jithu Joseph , rostedt@goodmis.org, ashok.raj@intel.com, tony.luck@intel.com, LKML , platform-driver-x86@vger.kernel.org, patches@lists.linux.dev, pengfei.xu@intel.com Subject: [PATCH 1/5] platform/x86/intel/ifs: Call release_firmware() when handling errors. Date: Thu, 25 Jan 2024 00:22:50 -0800 Message-Id: <20240125082254.424859-2-ashok.raj@intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240125082254.424859-1-ashok.raj@intel.com> References: <20240125082254.424859-1-ashok.raj@intel.com> Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Jithu Joseph Missing release_firmware() due to error handling blocked any future image loading. Fix the return code and release_fiwmare() to release the bad image. Fixes: 25a76dbb36dd ("platform/x86/intel/ifs: Validate image size") Reported-by: Pengfei Xu Signed-off-by: Jithu Joseph Signed-off-by: Ashok Raj Tested-by: Pengfei Xu Reviewed-by: Tony Luck Reviewed-by: Ilpo Järvinen --- drivers/platform/x86/intel/ifs/load.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/platform/x86/intel/ifs/load.c b/drivers/platform/x86/intel/ifs/load.c index a1ee1a74fc3c..2cf3b4a8813f 100644 --- a/drivers/platform/x86/intel/ifs/load.c +++ b/drivers/platform/x86/intel/ifs/load.c @@ -399,7 +399,8 @@ int ifs_load_firmware(struct device *dev) if (fw->size != expected_size) { dev_err(dev, "File size mismatch (expected %u, actual %zu). Corrupted IFS image.\n", expected_size, fw->size); - return -EINVAL; + ret = -EINVAL; + goto release; } ret = image_sanity_check(dev, (struct microcode_header_intel *)fw->data); From patchwork Thu Jan 25 08:22:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ashok Raj X-Patchwork-Id: 13530211 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.14]) (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 81F6A1798A; Thu, 25 Jan 2024 08:23:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.14 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706171006; cv=none; b=PHIeHK3qgH5mc+KJKi7PBLxPMJ73A9MgRyY224louFfijX0NPfnOxTNqDtiOcN33P6FXPNJrHcoO/ocOv/AT2bLDIEBtSrF0JX7WLeyAXXzNE7uDTuX/KXXEN6vjoTF36/cW2vstIADK+fnh8uC3c4lY6CyA1qf3a2cim8l6U5Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706171006; c=relaxed/simple; bh=tDVjAd0aOw9tS20OeAHfcgi7HCiP4MDtxaMa6rF0AB4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=lr1M2aq+j8rBhxSfwgFIFmlzS/Zlwf4ih6XAMdnnmEdmSfS+KXEKYOCNJM78t/SnuAgnitGnTkRzZKuflN3TF6jIVNHyiZAY0P+6sJvJIfkt8kxNJZ1GWIkTnLRrTKsRJQHMRvc/wowLw+M5fpTxGPy+t/V0pTzf3JYjeDtRvCo= 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=QFObJbco; arc=none smtp.client-ip=198.175.65.14 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="QFObJbco" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1706171005; x=1737707005; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=tDVjAd0aOw9tS20OeAHfcgi7HCiP4MDtxaMa6rF0AB4=; b=QFObJbco1u9KkAbb/DJDLmjXbf4GhIQ1l1BKHvdSdGhHzAFGmpdsyiNM I7k3f8vpK9hGSj2X65ue76+RFTvZsUgpSoDHXre2AJ7W/QqKuM3/rPeDy /ktK0t9Zb/VeUr/bxmO2/H1S2RJbB6GNTTW/bf9oPfVmJHxYz4Dju27Dy uLyEnnilJXH09zxefhdnqDIeUMcnqs+9baFWpdL6d8kH3NRFHxuMYqxAm V1fe9H5XDY5WwfwujiuyGUXFiBrliHBkOQOEqQ4tX1L1DY33DnZED0ory Z38iFsSn42lH9ghoOkby6TAIPQuvJtspbTNVKOl+t+TCpHnnrwwxkyT47 A==; X-IronPort-AV: E=McAfee;i="6600,9927,10962"; a="1987174" X-IronPort-AV: E=Sophos;i="6.05,216,1701158400"; d="scan'208";a="1987174" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orvoesa106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jan 2024 00:23:24 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10962"; a="876975926" X-IronPort-AV: E=Sophos;i="6.05,216,1701158400"; d="scan'208";a="876975926" Received: from araj-ucode.jf.intel.com ([10.23.0.11]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jan 2024 00:23:22 -0800 From: Ashok Raj To: Hans de Goede , Ilpo Jarvinen , markgross@kernel.org Cc: Jithu Joseph , rostedt@goodmis.org, ashok.raj@intel.com, tony.luck@intel.com, LKML , platform-driver-x86@vger.kernel.org, patches@lists.linux.dev, pengfei.xu@intel.com Subject: [PATCH 2/5] platform/x86/intel/ifs: Trace on all HT threads when executing a test Date: Thu, 25 Jan 2024 00:22:51 -0800 Message-Id: <20240125082254.424859-3-ashok.raj@intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240125082254.424859-1-ashok.raj@intel.com> References: <20240125082254.424859-1-ashok.raj@intel.com> Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Enable the trace function on all HT threads. Currently, the trace is called from some arbitrary CPU where the test was invoked. This change gives visibility to the exact errors as seen by each participating HT threads, and not just what was seen from the primary thread. Sample output below. # TASK-PID CPU# ||||| TIMESTAMP FUNCTION # | | | ||||| | | migration/0-18 [000] d..1. 527287.084668: start: 0000, stop: 007f, status: 0000000000007f80 migration/128-785 [128] d..1. 527287.084669: start: 0000, stop: 007f, status: 0000000000007f80 Signed-off-by: Ashok Raj Reviewed-by: Tony Luck --- include/trace/events/intel_ifs.h | 9 ++--- drivers/platform/x86/intel/ifs/runtest.c | 46 +++++++++++++++++------- 2 files changed, 36 insertions(+), 19 deletions(-) diff --git a/include/trace/events/intel_ifs.h b/include/trace/events/intel_ifs.h index af0af3f1d9b7..8462dfb7a020 100644 --- a/include/trace/events/intel_ifs.h +++ b/include/trace/events/intel_ifs.h @@ -10,26 +10,23 @@ TRACE_EVENT(ifs_status, - TP_PROTO(int cpu, int start, int stop, u64 status), + TP_PROTO(int start, int stop, u64 status), - TP_ARGS(cpu, start, stop, status), + TP_ARGS(start, stop, status), TP_STRUCT__entry( __field( u64, status ) - __field( int, cpu ) __field( u16, start ) __field( u16, stop ) ), TP_fast_assign( - __entry->cpu = cpu; __entry->start = start; __entry->stop = stop; __entry->status = status; ), - TP_printk("cpu: %d, start: %.4x, stop: %.4x, status: %.16llx", - __entry->cpu, + TP_printk("start: %.4x, stop: %.4x, status: %.16llx", __entry->start, __entry->stop, __entry->status) diff --git a/drivers/platform/x86/intel/ifs/runtest.c b/drivers/platform/x86/intel/ifs/runtest.c index 13ecd55c6668..c8352ffb9195 100644 --- a/drivers/platform/x86/intel/ifs/runtest.c +++ b/drivers/platform/x86/intel/ifs/runtest.c @@ -23,6 +23,12 @@ /* Max retries on the same chunk */ #define MAX_IFS_RETRIES 5 +struct run_params { + struct ifs_data *ifsd; + union ifs_scan *activate; + union ifs_status status; +}; + /* * Number of TSC cycles that a logical CPU will wait for the other * logical CPU on the core in the WRMSR(ACTIVATE_SCAN). @@ -140,10 +146,22 @@ static bool can_restart(union ifs_status status) */ static int doscan(void *data) { - int cpu = smp_processor_id(); - u64 *msrs = data; + int cpu = smp_processor_id(), start, stop; + struct run_params *params = data; + union ifs_status status; + struct ifs_data *ifsd; int first; + ifsd = params->ifsd; + + if (ifsd->generation) { + start = params->activate->gen2.start; + stop = params->activate->gen2.stop; + } else { + start = params->activate->gen0.start; + stop = params->activate->gen0.stop; + } + /* Only the first logical CPU on a core reports result */ first = cpumask_first(cpu_smt_mask(cpu)); @@ -155,12 +173,14 @@ static int doscan(void *data) * take up to 200 milliseconds (in the case where all chunks * are processed in a single pass) before it retires. */ - wrmsrl(MSR_ACTIVATE_SCAN, msrs[0]); + wrmsrl(MSR_ACTIVATE_SCAN, params->activate->data); + rdmsrl(MSR_SCAN_STATUS, status.data); - if (cpu == first) { - /* Pass back the result of the scan */ - rdmsrl(MSR_SCAN_STATUS, msrs[1]); - } + trace_ifs_status(start, stop, status.data); + + /* Pass back the result of the scan */ + if (cpu == first) + params->status = status; return 0; } @@ -179,7 +199,7 @@ static void ifs_test_core(int cpu, struct device *dev) struct ifs_data *ifsd; int to_start, to_stop; int status_chunk; - u64 msrvals[2]; + struct run_params params; int retries; ifsd = ifs_get_data(dev); @@ -190,6 +210,8 @@ static void ifs_test_core(int cpu, struct device *dev) to_start = 0; to_stop = ifsd->valid_chunks - 1; + params.ifsd = ifs_get_data(dev); + if (ifsd->generation) { activate.gen2.start = to_start; activate.gen2.stop = to_stop; @@ -207,12 +229,10 @@ static void ifs_test_core(int cpu, struct device *dev) break; } - msrvals[0] = activate.data; - stop_core_cpuslocked(cpu, doscan, msrvals); - - status.data = msrvals[1]; + params.activate = &activate; + stop_core_cpuslocked(cpu, doscan, ¶ms); - trace_ifs_status(cpu, to_start, to_stop, status.data); + status = params.status; /* Some cases can be retried, give up for others */ if (!can_restart(status)) From patchwork Thu Jan 25 08:22:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ashok Raj X-Patchwork-Id: 13530213 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.14]) (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 C50A217BAE; Thu, 25 Jan 2024 08:23:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.14 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706171007; cv=none; b=oUJnI4I1l/ru8Qn8yX5zHcs8r1yG3EOTkGR8mJ6SA11uEfQxR0R5lWTh4nKCwi3XpD6uxETQevJS/NvKK5uVK/gMIqISQt+BlCE+G7/k1ghACnZAZSvsoE9KD5FT6zos602EqGvpT1TqI2xrCKj0pSS4HDvn36vhRo+b6fyZiP8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706171007; c=relaxed/simple; bh=33Nygko1fox8iV52wVuBrn97aPDqalW86iUYduaw+zg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=G0hicEPRmZhojbaok5MRkzK3Bksn6BfJnZl6xErLDGgRpoPwyPxHm60cWUDI0ZVn8J/EmT0213SZ0me+YyBU3h3V29s2BeAtm6sgXctoL4aIiXeQ5sb1L8dL2iOICoNWkrJsrXZ6QLQhyBuQFa06P/124cEy8rPtSZ+YF7TKnk0= 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=m4swk/Qy; arc=none smtp.client-ip=198.175.65.14 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="m4swk/Qy" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1706171006; x=1737707006; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=33Nygko1fox8iV52wVuBrn97aPDqalW86iUYduaw+zg=; b=m4swk/QyswG6OJZzdpQHvtqnJSDsn/+jM8LDJLcLTwnaQUSbSt9qqr+j r6o/VZAvabX7CldQhzu7PYwfls5nHwov6YIXEIqmC5QmsGB/jqqckwv9/ xESNgeBHrIJm0DPhPa0skS+0xqU4P7/Bk9XSH+vhYmh5iyGUiTVKkjP9b 5WVu8EetH7aYX3qnO19UJ6bXue4tYSnSc+0b+/eC7IqR6c+xJD0hhiJzp +mmm2KlCADWJTY0hqLg0GEBJbosKytlUQcDWPsLouPegCMo8LEiigRWtM x5q3Iu6lq7UVdvoCKiI03iPw0wY4PfkOA+rvYz2EzlOO+VsJd5O7leJ5Y w==; X-IronPort-AV: E=McAfee;i="6600,9927,10962"; a="1987179" X-IronPort-AV: E=Sophos;i="6.05,216,1701158400"; d="scan'208";a="1987179" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orvoesa106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jan 2024 00:23:24 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10962"; a="876975929" X-IronPort-AV: E=Sophos;i="6.05,216,1701158400"; d="scan'208";a="876975929" Received: from araj-ucode.jf.intel.com ([10.23.0.11]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jan 2024 00:23:23 -0800 From: Ashok Raj To: Hans de Goede , Ilpo Jarvinen , markgross@kernel.org Cc: Jithu Joseph , rostedt@goodmis.org, ashok.raj@intel.com, tony.luck@intel.com, LKML , platform-driver-x86@vger.kernel.org, patches@lists.linux.dev, pengfei.xu@intel.com Subject: [PATCH 3/5] platform/x86/intel/ifs: Add current batch number to trace output Date: Thu, 25 Jan 2024 00:22:52 -0800 Message-Id: <20240125082254.424859-4-ashok.raj@intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240125082254.424859-1-ashok.raj@intel.com> References: <20240125082254.424859-1-ashok.raj@intel.com> Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Add the current batch number in the trace output. When there are failures, it's important to know which test content resulted in failure. # TASK-PID CPU# ||||| TIMESTAMP FUNCTION # | | | ||||| | | migration/0-18 [000] d..1. 527287.084668: ifs_status: batch: 02, start: 0000, stop: 007f, status: 0000000000007f80 migration/128-785 [128] d..1. 527287.084669: ifs_status: batch: 02, start: 0000, stop: 007f, status: 0000000000007f80 Signed-off-by: Ashok Raj Reviewed-by: Tony Luck --- include/trace/events/intel_ifs.h | 9 ++++++--- drivers/platform/x86/intel/ifs/runtest.c | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/include/trace/events/intel_ifs.h b/include/trace/events/intel_ifs.h index 8462dfb7a020..8ce2de120f2d 100644 --- a/include/trace/events/intel_ifs.h +++ b/include/trace/events/intel_ifs.h @@ -10,23 +10,26 @@ TRACE_EVENT(ifs_status, - TP_PROTO(int start, int stop, u64 status), + TP_PROTO(int batch, int start, int stop, u64 status), - TP_ARGS(start, stop, status), + TP_ARGS(batch, start, stop, status), TP_STRUCT__entry( + __field( int, batch ) __field( u64, status ) __field( u16, start ) __field( u16, stop ) ), TP_fast_assign( + __entry->batch = batch; __entry->start = start; __entry->stop = stop; __entry->status = status; ), - TP_printk("start: %.4x, stop: %.4x, status: %.16llx", + TP_printk("batch: %.2d, start: %.4x, stop: %.4x, status: %.16llx", + __entry->batch, __entry->start, __entry->stop, __entry->status) diff --git a/drivers/platform/x86/intel/ifs/runtest.c b/drivers/platform/x86/intel/ifs/runtest.c index c8352ffb9195..21dc0046fd9b 100644 --- a/drivers/platform/x86/intel/ifs/runtest.c +++ b/drivers/platform/x86/intel/ifs/runtest.c @@ -176,7 +176,7 @@ static int doscan(void *data) wrmsrl(MSR_ACTIVATE_SCAN, params->activate->data); rdmsrl(MSR_SCAN_STATUS, status.data); - trace_ifs_status(start, stop, status.data); + trace_ifs_status(ifsd->cur_batch, start, stop, status.data); /* Pass back the result of the scan */ if (cpu == first) From patchwork Thu Jan 25 08:22:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ashok Raj X-Patchwork-Id: 13530214 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.14]) (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 7F1C0175B9; Thu, 25 Jan 2024 08:23:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.14 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706171008; cv=none; b=B+m+6bVqJvq2e3Z18xu6qntlYXS2qneC+EIOdFvhQyhSeBtN7F1qFpdjKmxXjKXvWJModSENc9gLEd50sCqNWqUxbtL1sOO5NfWEL3DtQ2ZeIE2ZjK0m21408AMiDGeRPBrMeqnY5lUOY6tLOh6Dvl2SxcXVgHAGDPErRfYCK+A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706171008; c=relaxed/simple; bh=Ym5ZXbQlJdyEqtBYOvsursmkKZcSXkI8IFQ9feaQTG8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=RD66IfqWHF1D7qxPMY3IxRwC2nJe+HLfRTcpy8PjxT/07C+Laf6CQk/u+/uhWGEymoA9NPcD+7ep0jxPpKdopRA4ldpguUVpRN0IaXNR/HX3cHKRccvU/7HIXRFWzPtpde0pKIHCp7e2hRdk3sQA76oCD7Qhjta9oIMSIgDodtg= 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=YlR3DaiA; arc=none smtp.client-ip=198.175.65.14 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="YlR3DaiA" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1706171007; x=1737707007; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Ym5ZXbQlJdyEqtBYOvsursmkKZcSXkI8IFQ9feaQTG8=; b=YlR3DaiAi05ASlxOh6NutaEUyTRoma88M/sMi9MdBKXtjB5jDk5xqNko dpfygkjBDs/fRJ9F4ADsOiW1gegG+0nmb7ObQmolQvrKQmwwDpEPPGFUQ xQUrnjTx3XZZxiZOwnAv/s19e5RIS0PX/xW5IWF0jBFhBng2oV+DMLQWM Y8aJ7Njwd/z5Fz22en+qvDC9sgd+RDKTnPLOgQg4h3P8cDb8SsETWF8/4 XlDecIVw0NsoDXZXy2v8NtOAHtoH13243saDf3/i6bJI90ycU+QU5SE2F IPJAr9FVV1AArAUasqRlW7SzLU0jD2DqqwvtCof2lVTCPHLRV3C+06euR g==; X-IronPort-AV: E=McAfee;i="6600,9927,10962"; a="1987185" X-IronPort-AV: E=Sophos;i="6.05,216,1701158400"; d="scan'208";a="1987185" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orvoesa106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jan 2024 00:23:25 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10962"; a="876975932" X-IronPort-AV: E=Sophos;i="6.05,216,1701158400"; d="scan'208";a="876975932" Received: from araj-ucode.jf.intel.com ([10.23.0.11]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jan 2024 00:23:23 -0800 From: Ashok Raj To: Hans de Goede , Ilpo Jarvinen , markgross@kernel.org Cc: Jithu Joseph , rostedt@goodmis.org, ashok.raj@intel.com, tony.luck@intel.com, LKML , platform-driver-x86@vger.kernel.org, patches@lists.linux.dev, pengfei.xu@intel.com Subject: [PATCH 4/5] platform/x86/intel/ifs: Replace the exit rendezvous with an entry rendezvous for ARRAY_BIST Date: Thu, 25 Jan 2024 00:22:53 -0800 Message-Id: <20240125082254.424859-5-ashok.raj@intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240125082254.424859-1-ashok.raj@intel.com> References: <20240125082254.424859-1-ashok.raj@intel.com> Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 ARRAY_BIST requires the test to be invoked only from one of the HT siblings of a core. If the other sibling was in mwait(), that didn't permit the test to complete and resulted in several retries before the test could finish. The exit rendezvous was introduced to keep the HT sibling busy until the primary CPU completed the test to avoid those retries. What is actually needed is to ensure that both the threads rendezvous *before* the wrmsr to trigger the test to give good chance to complete the test. The `stop_machine()` function returns only after all the CPUs complete running the function, and provides an exit rendezvous implicitly. In kernel/stop_machine.c::multi_cpu_stop(), every CPU in the mask needs to complete reaching MULTI_STOP_RUN. When all CPUs complete, the state machine moves to next state, i.e MULTI_STOP_EXIT. Thus the underlying API stop_core_cpuslocked() already provides an exit rendezvous. Add the rendezvous earlier in order to ensure the wrmsr is triggered after all CPUs reach the do_array_test(). Remove the exit rendezvous since stop_core_cpuslocked() already gaurantees that. Signed-off-by: Ashok Raj Reviewed-by: Tony Luck --- drivers/platform/x86/intel/ifs/runtest.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/platform/x86/intel/ifs/runtest.c b/drivers/platform/x86/intel/ifs/runtest.c index 21dc0046fd9b..e3307dd8e3c4 100644 --- a/drivers/platform/x86/intel/ifs/runtest.c +++ b/drivers/platform/x86/intel/ifs/runtest.c @@ -271,7 +271,7 @@ static void ifs_test_core(int cpu, struct device *dev) } #define SPINUNIT 100 /* 100 nsec */ -static atomic_t array_cpus_out; +static atomic_t array_cpus_in; /* * Simplified cpu sibling rendezvous loop based on microcode loader __wait_for_cpus() @@ -298,6 +298,8 @@ static int do_array_test(void *data) int cpu = smp_processor_id(); int first; + wait_for_sibling_cpu(&array_cpus_in, NSEC_PER_SEC); + /* * Only one logical CPU on a core needs to trigger the Array test via MSR write. */ @@ -309,9 +311,6 @@ static int do_array_test(void *data) rdmsrl(MSR_ARRAY_BIST, command->data); } - /* Tests complete faster if the sibling is spinning here */ - wait_for_sibling_cpu(&array_cpus_out, NSEC_PER_SEC); - return 0; } @@ -332,7 +331,7 @@ static void ifs_array_test_core(int cpu, struct device *dev) timed_out = true; break; } - atomic_set(&array_cpus_out, 0); + atomic_set(&array_cpus_in, 0); stop_core_cpuslocked(cpu, do_array_test, &command); if (command.ctrl_result) From patchwork Thu Jan 25 08:22:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ashok Raj X-Patchwork-Id: 13530215 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.14]) (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 B40C617C6D; Thu, 25 Jan 2024 08:23:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.14 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706171008; cv=none; b=ppnLRAFk4grEFFtwLet8zNJEuvCHIp5OWB2f348gjDpdDQp+I5ABpbDAOaRq2F5JZ2P9LttRrn8IEFlAvSx+9KL5d9+IKGhzMMs51eBb6zM47RR+izRoHj0Jx/KloOwDk5nvtNNhyVRjobAEA+BsdIgfyiiVHp1gm3/vZyB2PTM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706171008; c=relaxed/simple; bh=DgRKwx7erCsCqZ7Amarz6wtLdWuV8+Tw6mXgX2EWNu4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=gy8/gsJCuqT01zPJEmh96/Dx9zC8Fnh4mK2AfBh4jZK84z5QJcuP8JUEOxWXVAQ1LRTojDJUeN0mdbWt7dFpQ3YPzbIPvuYE2UYyLBBS5Fvr2jdCeBC3rQkEV3LyXXt6xDG3CxvnReusmAc8RS4sO6oqoaD77PMsSlzshf56PV0= 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=jhNnIw+V; arc=none smtp.client-ip=198.175.65.14 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="jhNnIw+V" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1706171007; x=1737707007; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=DgRKwx7erCsCqZ7Amarz6wtLdWuV8+Tw6mXgX2EWNu4=; b=jhNnIw+V8OJ5vI/Tp39R6RF+o/PWUDUWlUA1IA11E4QfxgZcB/tth/Ki bq5aoxotzgAgP6SzarSypt1+bczH4eXvIlf0+m+VRIR8wlug/YOaCpUK/ RE7m8rHDdAMc9OVKN+89rOLsYAoNYZRqnOOF7wsEpBMjnhfdEqvUvElex tHJDKLPMJxF8W5Qn5RgVr8g29IIOSg/jyGTapgPe7duW2dt411cHyGFOf TZv9ARe8Hvlc7CVP4uQYD8GxO608lIzmVGj0mRPwCRufgmHmMrbAg7CPE t/Gil2v4/IfPDWbgEn2a+ItFDHnYDr11uyCGFZB6LomRy2ja2/RZ0a5W6 g==; X-IronPort-AV: E=McAfee;i="6600,9927,10962"; a="1987191" X-IronPort-AV: E=Sophos;i="6.05,216,1701158400"; d="scan'208";a="1987191" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orvoesa106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jan 2024 00:23:26 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10962"; a="876975935" X-IronPort-AV: E=Sophos;i="6.05,216,1701158400"; d="scan'208";a="876975935" Received: from araj-ucode.jf.intel.com ([10.23.0.11]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jan 2024 00:23:24 -0800 From: Ashok Raj To: Hans de Goede , Ilpo Jarvinen , markgross@kernel.org Cc: Jithu Joseph , rostedt@goodmis.org, ashok.raj@intel.com, tony.luck@intel.com, LKML , platform-driver-x86@vger.kernel.org, patches@lists.linux.dev, pengfei.xu@intel.com Subject: [PATCH 5/5] platform/x86/intel/ifs: Add an entry rendezvous for SAF Date: Thu, 25 Jan 2024 00:22:54 -0800 Message-Id: <20240125082254.424859-6-ashok.raj@intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240125082254.424859-1-ashok.raj@intel.com> References: <20240125082254.424859-1-ashok.raj@intel.com> Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The activation for SAF includes a parameter to make microcode wait for both threads to join. It's preferable to perform an entry rendezvous before the activation to ensure that they start the `wrmsr` close enough to each other. In some cases it has been observed that one of the threads might be just a bit late to arrive. An entry rendezvous reduces the likelihood of these cases occurring. Add an entry rendezvous to ensure the activation on both threads happen close enough to each other. Signed-off-by: Ashok Raj Reviewed-by: Tony Luck --- drivers/platform/x86/intel/ifs/runtest.c | 48 +++++++++++++----------- 1 file changed, 26 insertions(+), 22 deletions(-) diff --git a/drivers/platform/x86/intel/ifs/runtest.c b/drivers/platform/x86/intel/ifs/runtest.c index e3307dd8e3c4..95b4b71fab53 100644 --- a/drivers/platform/x86/intel/ifs/runtest.c +++ b/drivers/platform/x86/intel/ifs/runtest.c @@ -140,6 +140,29 @@ static bool can_restart(union ifs_status status) return false; } +#define SPINUNIT 100 /* 100 nsec */ +static atomic_t array_cpus_in; +static atomic_t scan_cpus_in; + +/* + * Simplified cpu sibling rendezvous loop based on microcode loader __wait_for_cpus() + */ +static void wait_for_sibling_cpu(atomic_t *t, long long timeout) +{ + int cpu = smp_processor_id(); + const struct cpumask *smt_mask = cpu_smt_mask(cpu); + int all_cpus = cpumask_weight(smt_mask); + + atomic_inc(t); + while (atomic_read(t) < all_cpus) { + if (timeout < SPINUNIT) + return; + ndelay(SPINUNIT); + timeout -= SPINUNIT; + touch_nmi_watchdog(); + } +} + /* * Execute the scan. Called "simultaneously" on all threads of a core * at high priority using the stop_cpus mechanism. @@ -165,6 +188,8 @@ static int doscan(void *data) /* Only the first logical CPU on a core reports result */ first = cpumask_first(cpu_smt_mask(cpu)); + wait_for_sibling_cpu(&scan_cpus_in, NSEC_PER_SEC); + /* * This WRMSR will wait for other HT threads to also write * to this MSR (at most for activate.delay cycles). Then it @@ -230,6 +255,7 @@ static void ifs_test_core(int cpu, struct device *dev) } params.activate = &activate; + atomic_set(&scan_cpus_in, 0); stop_core_cpuslocked(cpu, doscan, ¶ms); status = params.status; @@ -270,28 +296,6 @@ static void ifs_test_core(int cpu, struct device *dev) } } -#define SPINUNIT 100 /* 100 nsec */ -static atomic_t array_cpus_in; - -/* - * Simplified cpu sibling rendezvous loop based on microcode loader __wait_for_cpus() - */ -static void wait_for_sibling_cpu(atomic_t *t, long long timeout) -{ - int cpu = smp_processor_id(); - const struct cpumask *smt_mask = cpu_smt_mask(cpu); - int all_cpus = cpumask_weight(smt_mask); - - atomic_inc(t); - while (atomic_read(t) < all_cpus) { - if (timeout < SPINUNIT) - return; - ndelay(SPINUNIT); - timeout -= SPINUNIT; - touch_nmi_watchdog(); - } -} - static int do_array_test(void *data) { union ifs_array *command = data;