From patchwork Tue Feb 14 23:44:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jithu Joseph X-Patchwork-Id: 57280 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp3265005wrn; Tue, 14 Feb 2023 15:49:35 -0800 (PST) X-Google-Smtp-Source: AK7set+P98A7UK64WHFBlGWL4NNcWSD1/fC6fbmj9oVtRqrdbyWGGXR2YuRp7krS14aZ1dUM6/kV X-Received: by 2002:a17:906:48c3:b0:8a9:f870:d259 with SMTP id d3-20020a17090648c300b008a9f870d259mr219882ejt.48.1676418575043; Tue, 14 Feb 2023 15:49:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676418575; cv=none; d=google.com; s=arc-20160816; b=JwLzb+GbT/yRX5WpPCxZPdUb3uEuXKfLKQK6ZEb9a8kfZKaPsmyAyIu/Hpee+k3oU/ EYZzYzq4ki3+DaicY2vyIwDWrHpNsfzUpESJUtf4L74JJKk6JYMqCa7eV2z9eStbLd4x VgEG2RCOG31XHtAiVZ//paIids/Tg0XquXkc5z2v8uHot4zrn1uIUMzH/U4hfQ8xwBL3 hyG74pEIB1VGMv6ph866gk2/g8ISIKLjdlcMkoMtDNMZHHAatQNnzwncP+EPvsUXFXjn Pbj23Z+A0YtpTk9Gvh2i99+WIWduQU71Uey2WiOFbcKlKrbtEPrSv3quzaTghbxUJYO3 q22A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=d14+4CndGQS0tZTHb6hXfAeS4CrK9IWwix9X6jfEa7I=; b=ndrg0ZwvVTBrqfc3EYviTwpcZlBIwlwGHoS/abJShWXD8Sp5Q8eyugQ+Q7OSwxZ6O3 37Qmlp3Q26imttn3vAkghjMjuuYoWF1kssraky0VOUOr62etK7FHWFHMSvoIaJ0PLQvG nan62ACA6kvWU6MGJrIElu5tHb9C0XktJrr8IMimeF1Nkdj/CDb/SEdhzQgzQJBhUVZu dbcjZaWoo7GfrgI0DX7XEmPEPrS4qEUdBwDalgBeFczXnuS+wopQwyO8pAF440fWAkE1 K2jn0xgSBr2XRIyNzcVWtcrT/Wdiv0OZrZthF95nIhYHdfo1RZq29sdT/ILkc6r2x5e1 sXkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=eWjEPY2g; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f18-20020a170906739200b008b1439765absi218204ejl.726.2023.02.14.15.49.12; Tue, 14 Feb 2023 15:49:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=eWjEPY2g; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229686AbjBNXqE (ORCPT + 99 others); Tue, 14 Feb 2023 18:46:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60462 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229551AbjBNXp5 (ORCPT ); Tue, 14 Feb 2023 18:45:57 -0500 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 86FFB2914A; Tue, 14 Feb 2023 15:45:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1676418356; x=1707954356; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=FZhdytTplH8hafL4/6++wppoH2ryGQJ9fu1jV9238GY=; b=eWjEPY2gqEvbANrEkPWUVxpFjBToTT1qtAw6tRUCJqu7G6CMSBqXBWn+ gOA8LlA64JK83YyDwEjQhOwBQ1DRph0UOswlEH2mvVRzNHK4RbgcZZCUg ki2WqZzQvqf6tEJ5Skjt/5DILN9y1+51mRdG8kxh+J1WdxsEzEQ/1n0ml LFPCfRTZPHkWWIAk1Kx1xfDJYrIC+ZA7C+q4wdfzc3ITYSLVFpyLxFv8h Qi5qulSIrtNj7KkuHf76jp6Uw8uoVkFzJB7v+3kY4af9YVDnIPdKvhgJx vPRpp33IBl5y7QwqjXfTnuDI64M0uUck/uTbQx+qd1UPuxIz3Y5dL7/aN g==; X-IronPort-AV: E=McAfee;i="6500,9779,10621"; a="417523018" X-IronPort-AV: E=Sophos;i="5.97,298,1669104000"; d="scan'208";a="417523018" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Feb 2023 15:45:56 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10621"; a="669391014" X-IronPort-AV: E=Sophos;i="5.97,298,1669104000"; d="scan'208";a="669391014" Received: from jithujos.sc.intel.com ([172.25.103.66]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Feb 2023 15:45:55 -0800 From: Jithu Joseph To: hdegoede@redhat.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, jithu.joseph@intel.com, 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: [PATCH v2 3/7] platform/x86/intel/ifs: Sysfs interface for Array BIST Date: Tue, 14 Feb 2023 15:44:22 -0800 Message-Id: <20230214234426.344960-4-jithu.joseph@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230214234426.344960-1-jithu.joseph@intel.com> References: <20230131234302.3997223-1-jithu.joseph@intel.com> <20230214234426.344960-1-jithu.joseph@intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756583768866045221?= X-GMAIL-MSGID: =?utf-8?q?1757852283602825433?= The interface to trigger Array BIST test and obtain its result is similar to the existing scan test. The only notable difference is that, Array BIST doesn't require any test content to be loaded. So binary load related options are not needed for this test. Add sysfs interface for array BIST test, the testing support will be added by subsequent patch. Signed-off-by: Jithu Joseph Reviewed-by: Tony Luck --- drivers/platform/x86/intel/ifs/ifs.h | 1 + drivers/platform/x86/intel/ifs/core.c | 21 ++++++++++++++++----- drivers/platform/x86/intel/ifs/runtest.c | 11 ++++++++++- drivers/platform/x86/intel/ifs/sysfs.c | 10 +++++++++- 4 files changed, 36 insertions(+), 7 deletions(-) diff --git a/drivers/platform/x86/intel/ifs/ifs.h b/drivers/platform/x86/intel/ifs/ifs.h index 2cef88a88aa9..a0cb2696c1d9 100644 --- a/drivers/platform/x86/intel/ifs/ifs.h +++ b/drivers/platform/x86/intel/ifs/ifs.h @@ -249,5 +249,6 @@ static inline struct ifs_data *ifs_get_data(struct device *dev) int ifs_load_firmware(struct device *dev); int do_core_test(int cpu, struct device *dev); const struct attribute_group **ifs_get_groups(void); +extern struct attribute *plat_ifs_array_attrs[]; #endif diff --git a/drivers/platform/x86/intel/ifs/core.c b/drivers/platform/x86/intel/ifs/core.c index ab234620ef4c..d0d4e1fb62f6 100644 --- a/drivers/platform/x86/intel/ifs/core.c +++ b/drivers/platform/x86/intel/ifs/core.c @@ -25,6 +25,7 @@ static struct ifs_device ifs_devices[] = { [IFS_SAF] = { .data = { .integrity_cap_bit = MSR_INTEGRITY_CAPS_PERIODIC_BIST_BIT, + .pkg_auth = NULL, .test_num = IFS_SAF, }, .misc = { @@ -36,6 +37,7 @@ static struct ifs_device ifs_devices[] = { [IFS_ARRAY] = { .data = { .integrity_cap_bit = MSR_INTEGRITY_CAPS_ARRAY_BIST_BIT, + .pkg_auth = NULL, .test_num = IFS_ARRAY, }, .misc = { @@ -48,6 +50,8 @@ static struct ifs_device ifs_devices[] = { #define IFS_NUMTESTS ARRAY_SIZE(ifs_devices) +ATTRIBUTE_GROUPS(plat_ifs_array); + static int __init ifs_init(void) { const struct x86_cpu_id *m; @@ -72,11 +76,18 @@ static int __init ifs_init(void) if (!(msrval & BIT(ifs_devices[i].data.integrity_cap_bit))) continue; - ifs_devices[i].data.pkg_auth = kmalloc_array(topology_max_packages(), - sizeof(bool), GFP_KERNEL); - if (!ifs_devices[i].data.pkg_auth) - continue; - ifs_devices[i].misc.groups = ifs_get_groups(); + switch (ifs_devices[i].data.test_num) { + case IFS_SAF: + ifs_devices[i].data.pkg_auth = kmalloc_array(topology_max_packages(), + sizeof(bool), GFP_KERNEL); + if (!ifs_devices[i].data.pkg_auth) + continue; + ifs_devices[i].misc.groups = ifs_get_groups(); + break; + case IFS_ARRAY: + ifs_devices[i].misc.groups = plat_ifs_array_groups; + break; + } if (misc_register(&ifs_devices[i].misc)) kfree(ifs_devices[i].data.pkg_auth); diff --git a/drivers/platform/x86/intel/ifs/runtest.c b/drivers/platform/x86/intel/ifs/runtest.c index 0bfd8fcdd7e8..65e08af70994 100644 --- a/drivers/platform/x86/intel/ifs/runtest.c +++ b/drivers/platform/x86/intel/ifs/runtest.c @@ -236,6 +236,7 @@ static void ifs_test_core(int cpu, struct device *dev) */ int do_core_test(int cpu, struct device *dev) { + struct ifs_data *ifsd = ifs_get_data(dev); int ret = 0; /* Prevent CPUs from being taken offline during the scan test */ @@ -247,7 +248,15 @@ int do_core_test(int cpu, struct device *dev) goto out; } - ifs_test_core(cpu, dev); + switch (ifsd->test_num) { + case IFS_SAF: + ifs_test_core(cpu, dev); + break; + case IFS_ARRAY: + default: + return -EINVAL; + } + out: cpus_read_unlock(); return ret; diff --git a/drivers/platform/x86/intel/ifs/sysfs.c b/drivers/platform/x86/intel/ifs/sysfs.c index ee636a76b083..3e205fead7ab 100644 --- a/drivers/platform/x86/intel/ifs/sysfs.c +++ b/drivers/platform/x86/intel/ifs/sysfs.c @@ -75,7 +75,7 @@ static ssize_t run_test_store(struct device *dev, if (down_interruptible(&ifs_sem)) return -EINTR; - if (!ifsd->loaded) + if (ifsd->test_num != IFS_ARRAY && !ifsd->loaded) rc = -EPERM; else rc = do_core_test(cpu, dev); @@ -156,3 +156,11 @@ const struct attribute_group **ifs_get_groups(void) { return plat_ifs_groups; } + +/* global array sysfs attributes */ +struct attribute *plat_ifs_array_attrs[] = { + &dev_attr_details.attr, + &dev_attr_status.attr, + &dev_attr_run_test.attr, + NULL +};