From: Hans de Goede <hdegoede@redhat.com>
To: Jithu Joseph <jithu.joseph@intel.com>, markgross@kernel.org
Cc: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de,
dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com,
gregkh@linuxfoundation.org, rostedt@goodmis.org,
ashok.raj@intel.com, tony.luck@intel.com,
linux-kernel@vger.kernel.org,
platform-driver-x86@vger.kernel.org, patches@lists.linux.dev,
ravi.v.shankar@intel.com, thiago.macieira@intel.com,
athenas.jimenez.gonzalez@intel.com, sohil.mehta@intel.com
Subject: Re: [PATCH v3 4/8] platform/x86/intel/ifs: Introduce Array Scan test to IFS
Date: Mon, 13 Mar 2023 17:10:25 +0100 [thread overview]
Message-ID: <7f82f241-39ee-15e0-1ae7-e98e50730c95@redhat.com> (raw)
In-Reply-To: <20230301015942.462799-5-jithu.joseph@intel.com>
Hi,
On 3/1/23 02:59, Jithu Joseph wrote:
> Array BIST is a new type of core test introduced under the Intel Infield
> Scan (IFS) suite of tests.
>
> Emerald Rapids (EMR) is the first CPU to support Array BIST.
> Array BIST performs tests on some portions of the core logic such as
> caches and register files. These are different portions of the silicon
> compared to the parts tested by the first test type
> i.e Scan at Field (SAF).
>
> Make changes in the device driver init flow to register this new test
> type with the device driver framework. Each test will have its own
> sysfs directory (intel_ifs_0 , intel_ifs_1) under misc hierarchy to
> accommodate for the differences in test type and how they are initiated.
>
> Upcoming patches will add actual support.
>
> Signed-off-by: Jithu Joseph <jithu.joseph@intel.com>
> Reviewed-by: Tony Luck <tony.luck@intel.com>
> ---
> drivers/platform/x86/intel/ifs/ifs.h | 3 +
> drivers/platform/x86/intel/ifs/core.c | 85 +++++++++++++++++++--------
> 2 files changed, 62 insertions(+), 26 deletions(-)
>
> diff --git a/drivers/platform/x86/intel/ifs/ifs.h b/drivers/platform/x86/intel/ifs/ifs.h
> index ab168ddf28f1..b8b956e29653 100644
> --- a/drivers/platform/x86/intel/ifs/ifs.h
> +++ b/drivers/platform/x86/intel/ifs/ifs.h
> @@ -137,6 +137,9 @@
> #define SCAN_TEST_PASS 1
> #define SCAN_TEST_FAIL 2
>
> +#define IFS_TYPE_SAF 0
> +#define IFS_TYPE_ARRAY_BIST 1
> +
> /* MSR_SCAN_HASHES_STATUS bit fields */
> union ifs_scan_hashes_status {
> u64 data;
> diff --git a/drivers/platform/x86/intel/ifs/core.c b/drivers/platform/x86/intel/ifs/core.c
> index 62c44dbae757..2237aaba7078 100644
> --- a/drivers/platform/x86/intel/ifs/core.c
> +++ b/drivers/platform/x86/intel/ifs/core.c
> @@ -16,6 +16,7 @@
>
> static const struct x86_cpu_id ifs_cpu_ids[] __initconst = {
> X86_MATCH(SAPPHIRERAPIDS_X),
> + X86_MATCH(EMERALDRAPIDS_X),
> {}
> };
> MODULE_DEVICE_TABLE(x86cpu, ifs_cpu_ids);
Note you can add driver_data to a match table like this. What you should
do here is use the driver data to point to the const ifs_hw_caps discussed
before, so what you get here is:
#define X86_MATCH(model, data) \
X86_MATCH_VENDOR_FAM_MODEL_FEATURE(INTEL, 6, \
INTEL_FAM6_##model, X86_FEATURE_CORE_CAPABILITIES, (unsigned long)(data))
static const struct ifs_hw_caps saphire_rapids_caps = {
.integrity_cap_bit = MSR_INTEGRITY_CAPS_PERIODIC_BIST_BIT,
.test_num = 0,
};
static const struct ifs_hw_caps emerald_rapids_caps = {
.integrity_cap_bit = MSR_INTEGRITY_CAPS_PERIODIC_BIST_BIT,
.test_num = 0,
};
static const struct x86_cpu_id ifs_cpu_ids[] __initconst = {
X86_MATCH(SAPPHIRERAPIDS_X, &saphire_rapids_caps),
X86_MATCH(EMERALDRAPIDS_X, &emerald_rapids_caps),
{}
};
MODULE_DEVICE_TABLE(x86cpu, ifs_cpu_ids);
and then drop all the code related to having an array of ifs_device structs
(of which only 1 will ever get used) and instead at the beginning of
ifs_init(void), after:
m = x86_match_cpu(ifs_cpu_ids);
if (!m)
return -ENODEV;
add:
ifs_device.hwcaps = (const struct ifs_hw_caps *)m->driver_data;
And then you can pretty much drop all the rest of this patch and we
end up with much nicer code for differentiating between the models :)
Regards,
Hans
> @@ -24,23 +25,51 @@ ATTRIBUTE_GROUPS(plat_ifs);
>
> bool *ifs_pkg_auth;
>
> -static struct ifs_device ifs_device = {
> - .ro_data = {
> - .integrity_cap_bit = MSR_INTEGRITY_CAPS_PERIODIC_BIST_BIT,
> - .test_num = 0,
> +static struct ifs_device ifs_devices[] = {
> + [IFS_TYPE_SAF] = {
> + .ro_data = {
> + .integrity_cap_bit = MSR_INTEGRITY_CAPS_PERIODIC_BIST_BIT,
> + .test_num = IFS_TYPE_SAF,
> + },
> + .misc = {
> + .name = "intel_ifs_0",
> + .minor = MISC_DYNAMIC_MINOR,
> + .groups = plat_ifs_groups,
> + },
> },
> - .misc = {
> - .name = "intel_ifs_0",
> - .minor = MISC_DYNAMIC_MINOR,
> - .groups = plat_ifs_groups,
> + [IFS_TYPE_ARRAY_BIST] = {
> + .ro_data = {
> + .integrity_cap_bit = MSR_INTEGRITY_CAPS_ARRAY_BIST_BIT,
> + .test_num = IFS_TYPE_ARRAY_BIST,
> + },
> + .misc = {
> + .name = "intel_ifs_1",
> + .minor = MISC_DYNAMIC_MINOR,
> + },
> },
> };
>
> +#define IFS_NUMTESTS ARRAY_SIZE(ifs_devices)
> +
> +static void ifs_cleanup(void)
> +{
> + int i;
> +
> + for (i = 0; i < IFS_NUMTESTS; i++) {
> + if (ifs_devices[i].misc.this_device) {
> + misc_deregister(&ifs_devices[i].misc);
> + kfree(ifs_devices[i].rw_data);
> + }
> + }
> + kfree(ifs_pkg_auth);
> +}
> +
> static int __init ifs_init(void)
> {
> const struct x86_cpu_id *m;
> struct ifs_data *ifsd;
> u64 msrval;
> + int i, ret;
>
> m = x86_match_cpu(ifs_cpu_ids);
> if (!m)
> @@ -55,35 +84,39 @@ static int __init ifs_init(void)
> if (rdmsrl_safe(MSR_INTEGRITY_CAPS, &msrval))
> return -ENODEV;
>
> - if (!(msrval & BIT(ifs_device.ro_data.integrity_cap_bit)))
> - return -ENODEV;
> -
> ifs_pkg_auth = kmalloc_array(topology_max_packages(), sizeof(bool), GFP_KERNEL);
> if (!ifs_pkg_auth)
> return -ENOMEM;
>
> - ifsd = kzalloc(sizeof(*ifsd), GFP_KERNEL);
> - if (!ifsd)
> - return -ENOMEM;
> -
> - ifsd->ro_info = &ifs_device.ro_data;
> - ifs_device.rw_data = ifsd;
> -
> - if (misc_register(&ifs_device.misc)) {
> - kfree(ifsd);
> - kfree(ifs_pkg_auth);
> - return -ENODEV;
> + for (i = 0; i < IFS_NUMTESTS; i++) {
> + ifsd = NULL;
> + if (!(msrval & BIT(ifs_devices[i].ro_data.integrity_cap_bit)))
> + continue;
> +
> + ifsd = kzalloc(sizeof(*ifsd), GFP_KERNEL);
> + if (!ifsd) {
> + ret = -ENOMEM;
> + goto err_exit;
> + }
> + ifsd->ro_info = &ifs_devices[i].ro_data;
> + ifs_devices[i].rw_data = ifsd;
> +
> + if (misc_register(&ifs_devices[i].misc)) {
> + ret = -ENODEV;
> + kfree(ifsd);
> + goto err_exit;
> + }
> }
> -
> return 0;
>
> +err_exit:
> + ifs_cleanup();
> + return ret;
> }
>
> static void __exit ifs_exit(void)
> {
> - misc_deregister(&ifs_device.misc);
> - kfree(ifs_device.rw_data);
> - kfree(ifs_pkg_auth);
> + ifs_cleanup();
> }
>
> module_init(ifs_init);
next prev parent reply other threads:[~2023-03-13 16:11 UTC|newest]
Thread overview: 87+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-31 23:42 [PATCH 0/5] Add Array BIST test support to IFS Jithu Joseph
2023-01-31 23:42 ` [PATCH 1/5] x86/include/asm/msr-index.h: Add IFS Array test bits Jithu Joseph
2023-01-31 23:42 ` [PATCH 2/5] platform/x86/intel/ifs: Introduce Array Scan test to IFS Jithu Joseph
2023-01-31 23:43 ` [PATCH 3/5] platform/x86/intel/ifs: Sysfs interface for Array BIST Jithu Joseph
2023-02-01 5:04 ` Greg KH
2023-02-01 20:55 ` Joseph, Jithu
2023-01-31 23:43 ` [PATCH 4/5] platform/x86/intel/ifs: Implement Array BIST test Jithu Joseph
2023-02-01 5:02 ` Greg KH
2023-02-01 17:22 ` Luck, Tony
2023-02-01 18:19 ` Greg KH
2023-02-01 19:22 ` Tony Luck
2023-02-01 19:35 ` Dave Hansen
2023-02-01 19:43 ` Luck, Tony
2023-02-01 19:53 ` Dave Hansen
2023-02-01 19:45 ` Dave Hansen
2023-02-01 19:56 ` Joseph, Jithu
2023-02-01 20:49 ` Dave Hansen
2023-02-01 21:34 ` Luck, Tony
2023-01-31 23:43 ` [PATCH 5/5] platform/x86/intel/ifs: Trace support for array test Jithu Joseph
2023-02-06 16:40 ` Steven Rostedt
2023-02-06 19:50 ` Joseph, Jithu
2023-02-14 23:44 ` [PATCH v2 0/7] Add Array BIST test support to IFS Jithu Joseph
2023-02-14 23:44 ` [PATCH v2 1/7] x86/include/asm/msr-index.h: Add IFS Array test bits Jithu Joseph
2023-02-14 23:44 ` [PATCH v2 2/7] platform/x86/intel/ifs: Introduce Array Scan test to IFS Jithu Joseph
2023-02-16 12:40 ` Greg KH
2023-02-16 18:46 ` Luck, Tony
2023-02-16 22:57 ` Joseph, Jithu
2023-02-17 9:25 ` Greg KH
2023-02-14 23:44 ` [PATCH v2 3/7] platform/x86/intel/ifs: Sysfs interface for Array BIST Jithu Joseph
2023-02-14 23:44 ` [PATCH v2 4/7] platform/x86/intel/ifs: Implement Array BIST test Jithu Joseph
2023-02-15 16:58 ` Dave Hansen
2023-02-15 17:11 ` Dave Hansen
2023-02-15 20:22 ` Joseph, Jithu
2023-02-15 20:26 ` Dave Hansen
2023-02-15 21:13 ` Joseph, Jithu
2023-02-15 21:18 ` Dave Hansen
2023-02-22 20:12 ` Dave Hansen
2023-02-22 22:07 ` Joseph, Jithu
2023-02-22 22:28 ` Dave Hansen
2023-02-22 22:36 ` Steven Rostedt
2023-02-22 23:32 ` Joseph, Jithu
2023-02-22 23:59 ` Dave Hansen
2023-02-15 17:44 ` Joseph, Jithu
2023-02-14 23:44 ` [PATCH v2 5/7] platform/x86/intel/ifs: Trace support for array test Jithu Joseph
2023-02-16 0:56 ` Steven Rostedt
2023-02-14 23:44 ` [PATCH v2 6/7] platform/x86/intel/ifs: Update IFS doc Jithu Joseph
2023-02-14 23:44 ` [PATCH v2 7/7] Documentation/ABI: Update IFS ABI doc Jithu Joseph
2023-03-01 1:59 ` [PATCH v3 0/8] Add Array BIST test support to IFS Jithu Joseph
2023-03-01 1:59 ` [PATCH v3 1/8] platform/x86/intel/ifs: Reorganize driver data Jithu Joseph
2023-03-13 14:46 ` Hans de Goede
2023-03-13 21:34 ` Joseph, Jithu
2023-03-16 9:43 ` Hans de Goede
2023-03-01 1:59 ` [PATCH v3 2/8] platform/x86/intel/ifs: IFS cleanup Jithu Joseph
2023-03-13 15:02 ` Hans de Goede
2023-03-01 1:59 ` [PATCH v3 3/8] x86/include/asm/msr-index.h: Add IFS Array test bits Jithu Joseph
2023-03-13 15:03 ` Hans de Goede
2023-03-01 1:59 ` [PATCH v3 4/8] platform/x86/intel/ifs: Introduce Array Scan test to IFS Jithu Joseph
2023-03-13 16:10 ` Hans de Goede [this message]
2023-03-13 16:29 ` Hans de Goede
2023-03-13 17:21 ` Luck, Tony
2023-03-15 19:29 ` Joseph, Jithu
2023-03-16 9:50 ` Hans de Goede
2023-03-16 19:44 ` Joseph, Jithu
2023-03-01 1:59 ` [PATCH v3 5/8] platform/x86/intel/ifs: Sysfs interface for Array BIST Jithu Joseph
2023-03-13 16:14 ` Hans de Goede
2023-03-01 1:59 ` [PATCH v3 6/8] platform/x86/intel/ifs: Implement Array BIST test Jithu Joseph
2023-03-13 16:24 ` Hans de Goede
2023-03-13 16:37 ` Joseph, Jithu
2023-03-16 9:59 ` Hans de Goede
2023-03-16 17:40 ` Joseph, Jithu
2023-03-16 18:11 ` Joseph, Jithu
2023-03-16 19:38 ` Hans de Goede
2023-03-01 1:59 ` [PATCH v3 7/8] platform/x86/intel/ifs: Update IFS doc Jithu Joseph
2023-03-01 1:59 ` [PATCH v3 8/8] Documentation/ABI: Update IFS ABI doc Jithu Joseph
2023-03-07 11:02 ` [PATCH v3 0/8] Add Array BIST test support to IFS Hans de Goede
2023-03-22 0:33 ` [PATCH v4 0/9] " Jithu Joseph
2023-03-22 0:33 ` [PATCH v4 1/9] platform/x86/intel/ifs: Separate ifs_pkg_auth from ifs_data Jithu Joseph
2023-03-22 0:33 ` [PATCH v4 2/9] platform/x86/intel/ifs: Reorganize driver data Jithu Joseph
2023-03-22 0:33 ` [PATCH v4 3/9] platform/x86/intel/ifs: IFS cleanup Jithu Joseph
2023-03-22 0:33 ` [PATCH v4 4/9] x86/include/asm/msr-index.h: Add IFS Array test bits Jithu Joseph
2023-03-22 0:33 ` [PATCH v4 5/9] platform/x86/intel/ifs: Introduce Array Scan test to IFS Jithu Joseph
2023-03-22 0:33 ` [PATCH v4 6/9] platform/x86/intel/ifs: Sysfs interface for Array BIST Jithu Joseph
2023-03-22 0:33 ` [PATCH v4 7/9] platform/x86/intel/ifs: Implement Array BIST test Jithu Joseph
2023-03-22 0:33 ` [PATCH v4 8/9] platform/x86/intel/ifs: Update IFS doc Jithu Joseph
2023-03-22 0:33 ` [PATCH v4 9/9] Documentation/ABI: Update IFS ABI doc Jithu Joseph
2023-03-27 13:10 ` [PATCH v4 0/9] Add Array BIST test support to IFS Hans de Goede
2023-04-07 1:49 ` Pengfei Xu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7f82f241-39ee-15e0-1ae7-e98e50730c95@redhat.com \
--to=hdegoede@redhat.com \
--cc=ashok.raj@intel.com \
--cc=athenas.jimenez.gonzalez@intel.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=hpa@zytor.com \
--cc=jithu.joseph@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=markgross@kernel.org \
--cc=mingo@redhat.com \
--cc=patches@lists.linux.dev \
--cc=platform-driver-x86@vger.kernel.org \
--cc=ravi.v.shankar@intel.com \
--cc=rostedt@goodmis.org \
--cc=sohil.mehta@intel.com \
--cc=tglx@linutronix.de \
--cc=thiago.macieira@intel.com \
--cc=tony.luck@intel.com \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).