Message ID | 20221021203413.1220137-5-jithu.joseph@intel.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp892992wrr; Fri, 21 Oct 2022 13:41:58 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5CK8q1/7mD6Xs3pP4LGsTVQMY+1sE6VchuPAXQqRTAiSWJeyJtMIXQF1rIHK9k7ag6cHZk X-Received: by 2002:a17:903:2450:b0:185:4165:be54 with SMTP id l16-20020a170903245000b001854165be54mr21115268pls.104.1666384918294; Fri, 21 Oct 2022 13:41:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666384918; cv=none; d=google.com; s=arc-20160816; b=j7+XIUR948lBmYo+s/K3Vk4jsGOvF1lzDGz9+J8eNysQEuglIGpHNkz1FsxevlDx0w VLA//pEJohVFntI8NZW+GheiGfJ6rFv45U49GwSflvrKv3O21BJ4Z/qSeYVl2aiBNw5V S/MPzWv/7CCO2YfXP21GecQHNg1jzKg97p5RGGi3i5bZn80dkBchp2ni1gmkp1HyzmDY RxwwkwZ3NSEWCXcV1nBKjVE5a1LS7L4zGo69NhfbmPl7wnxOwECTCefKrudlP6+qijYb fFHTRDKWYX5b5z9RolDMsgB2sztr1woIjthekE1cExIC8j1ou6iQjObWUnuB2QBUaBdX 3nBQ== 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=wBUKOADX07a48N3zlFHB+SSQ+UBrgmEDFGzVItoYEdY=; b=Qmi/3xkN4mHjqrf7K7v4lwCxpS1cUZvf7xMXaAW0M3YEhs5JAAwCzgxYpOO8aB6WHV dM99c2n4uC4scMGYWM1QJbC1lOCD8R2zxFjlS1MlFLf7qA4jybRCeIoTmPPhgft9TPV5 fstw6ru0NgX+2y0J89aRHT0N9A93XAhu7T8xevBy2PUTAGTl6KFiyMOM6scLv+hi85bx UG6VRCJYeiNwFp60OKf3fiKPIcOTSWNtHvCGNvW5egdryy2tmDIfrXhlWFiL9x9bF1jI 62J9OcxveQphMJNoSA4lQGz2RNN7il81g9hr32a8voOBsKG+8zKg6U2pfO/2VSGHif5G Njxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=D87opjzQ; 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 j13-20020a65430d000000b0046040a85ea6si26739700pgq.120.2022.10.21.13.41.45; Fri, 21 Oct 2022 13:41:58 -0700 (PDT) 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=D87opjzQ; 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 S229976AbiJUUkI (ORCPT <rfc822;mntrajkot1@gmail.com> + 99 others); Fri, 21 Oct 2022 16:40:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44608 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229861AbiJUUjz (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 21 Oct 2022 16:39:55 -0400 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4204145F56; Fri, 21 Oct 2022 13:39:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1666384794; x=1697920794; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=0oi6a1r6EcPszIqWC+40MwHJFgZnvwStu7e0P4Y7NfE=; b=D87opjzQ56rckhXfyOOu2iltjphgKhcPa/DSPI4yCEm71iScmDG3peYE /xkiKqoItDIb5Hay5s7H2pUKATrkraasOwp+2N6i38ZQCgeaCN4f0TudT JupBpvc6LCiu4i0Sqx1gZ2W6eiQRBMZarvRfIOqt+Y+bdAmO1KYFItKHj qQ4qHbHQAPlWgXcJ6xc38rxJGMcqrPLr4N4VGMvDXcVRUO5CS8k/whbSw 2juLq3wsSj7hrhxua9Vj7L3wtivhv5cy3S+v5XNC7g+vJjKKL264fliZ+ fNzXxZDXZ1ra1jTvwgRGNzcpOAU0cfk5EwF4jMonkOuqgduebkfa3SXos Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10507"; a="369161176" X-IronPort-AV: E=Sophos;i="5.95,203,1661842800"; d="scan'208";a="369161176" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Oct 2022 13:35:34 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10507"; a="735701004" X-IronPort-AV: E=Sophos;i="5.95,203,1661842800"; d="scan'208";a="735701004" Received: from jithujos.sc.intel.com ([172.25.103.66]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Oct 2022 13:35:34 -0700 From: Jithu Joseph <jithu.joseph@intel.com> 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, 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 Subject: [PATCH 04/14] platform/x86/intel/ifs: Remove image loading during init Date: Fri, 21 Oct 2022 13:34:03 -0700 Message-Id: <20221021203413.1220137-5-jithu.joseph@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221021203413.1220137-1-jithu.joseph@intel.com> References: <20221021203413.1220137-1-jithu.joseph@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.6 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,URIBL_BLOCKED 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747331231909738895?= X-GMAIL-MSGID: =?utf-8?q?1747331231909738895?= |
Series |
IFS multi test image support and misc changes
|
|
Commit Message
Jithu Joseph
Oct. 21, 2022, 8:34 p.m. UTC
Existing implementation loads IFS test image during the driver init flow. Dropping test image loading from the init path improves module load time. Prior to starting IFS tests, the user has to load one of the IFS test images by writing to the current_batch sysfs file. Removing IFS test image loading during init also allows us to make ifs_sem static as it is used only within sysfs.c. Reviewed-by: Tony Luck <tony.luck@intel.com> Suggested-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Jithu Joseph <jithu.joseph@intel.com> --- drivers/platform/x86/intel/ifs/ifs.h | 2 -- drivers/platform/x86/intel/ifs/core.c | 6 +----- drivers/platform/x86/intel/ifs/sysfs.c | 2 +- 3 files changed, 2 insertions(+), 8 deletions(-)
Comments
On 10/21/2022 1:34 PM, Jithu Joseph wrote: > Existing implementation loads IFS test image during the driver > init flow. > > Dropping test image loading from the init path improves > module load time. > > Prior to starting IFS tests, the user has to load one of > the IFS test images by writing to the current_batch sysfs file. > The kernel is still unaware of the 'current_batch' sysfs file. It will be introduced in patch 12. You can avoid the reference here. > Removing IFS test image loading during init also allows us to > make ifs_sem static as it is used only within sysfs.c. > Does something like this sound better? IFS test image is unnecessarily loaded during driver initialization. The user has to load one when starting the tests. Drop image loading during ifs_init() and improve module load time. As a consequence, make ifs_sem static as it is only used within sysfs.c > diff --git a/drivers/platform/x86/intel/ifs/core.c b/drivers/platform/x86/intel/ifs/core.c > index 27204e3d674d..5fb7f655c291 100644 > --- a/drivers/platform/x86/intel/ifs/core.c > +++ b/drivers/platform/x86/intel/ifs/core.c > @@ -51,12 +51,8 @@ static int __init ifs_init(void) > ifs_device.misc.groups = ifs_get_groups(); > > if ((msrval & BIT(ifs_device.data.integrity_cap_bit)) && Is there a reason to store the integrity cap constant in the device.data global structure? .data = { .integrity_cap_bit = MSR_INTEGRITY_CAPS_PERIODIC_BIST_BIT, }, IIUC, you are basically reading an MSR and testing a bit within? You already have an BIT macro (unused) for that. #define MSR_INTEGRITY_CAPS_PERIODIC_BIST BIT(MSR_INTEGRITY_CAPS_PERIODIC_BIST_BIT) > - !misc_register(&ifs_device.misc)) { > - down(&ifs_sem); > - ifs_load_firmware(ifs_device.misc.this_device); > - up(&ifs_sem); > + !misc_register(&ifs_device.misc)) > return 0; > - } > > return -ENODEV; > } Sohil
On 10/24/2022 4:50 PM, Sohil Mehta wrote: > On 10/21/2022 1:34 PM, Jithu Joseph wrote: >> Existing implementation loads IFS test image during the driver >> init flow. >> >> Dropping test image loading from the init path improves >> module load time. >> >> Prior to starting IFS tests, the user has to load one of >> the IFS test images by writing to the current_batch sysfs file. >> > > The kernel is still unaware of the 'current_batch' sysfs file. It will be introduced in patch 12. You can avoid the reference here. ok will remove the current_batch reference and mention that user has to explicitly load test images > >> Removing IFS test image loading during init also allows us to >> make ifs_sem static as it is used only within sysfs.c. >> > > Does something like this sound better? > > IFS test image is unnecessarily loaded during driver initialization. The user has to load one when starting the tests. > > Drop image loading during ifs_init() and improve module load time. As a consequence, make ifs_sem static as it is only used within sysfs.c Will adopt this, Thanks > >> diff --git a/drivers/platform/x86/intel/ifs/core.c b/drivers/platform/x86/intel/ifs/core.c >> index 27204e3d674d..5fb7f655c291 100644 >> --- a/drivers/platform/x86/intel/ifs/core.c >> +++ b/drivers/platform/x86/intel/ifs/core.c >> @@ -51,12 +51,8 @@ static int __init ifs_init(void) >> ifs_device.misc.groups = ifs_get_groups(); >> if ((msrval & BIT(ifs_device.data.integrity_cap_bit)) && > > Is there a reason to store the integrity cap constant in the device.data global structure? > > .data = { > .integrity_cap_bit = MSR_INTEGRITY_CAPS_PERIODIC_BIST_BIT, > }, This was originally added so that, when future additional tests are supported by the driver, support can be checked using the same if ((msrval & BIT(ifs_device.data.integrity_cap_bit) Different tests would have different integrity_cap_bit assigned in the ifs_device[] array (today it is just a single element and not an array Note that the current series doesn't introduce this Jithu
On 10/24/2022 5:41 PM, Joseph, Jithu wrote: >>> diff --git a/drivers/platform/x86/intel/ifs/core.c b/drivers/platform/x86/intel/ifs/core.c >>> index 27204e3d674d..5fb7f655c291 100644 >>> --- a/drivers/platform/x86/intel/ifs/core.c >>> +++ b/drivers/platform/x86/intel/ifs/core.c >>> @@ -51,12 +51,8 @@ static int __init ifs_init(void) >>> ifs_device.misc.groups = ifs_get_groups(); >>> if ((msrval & BIT(ifs_device.data.integrity_cap_bit)) && >> >> Is there a reason to store the integrity cap constant in the device.data global structure? >> >> .data = { >> .integrity_cap_bit = MSR_INTEGRITY_CAPS_PERIODIC_BIST_BIT, >> }, > > This was originally added so that, when future additional tests are supported by the driver, support can be checked using the same if ((msrval & BIT(ifs_device.data.integrity_cap_bit) > Different tests would have different integrity_cap_bit assigned in the ifs_device[] array (today it is just a single element and not an array > > Note that the current series doesn't introduce this > > Sorry, I am still not able to follow. Let's say you have an ifs_device[] array which has different integrity capabilities, there would still need to be some logic in the init code to differentiate between the resulting action that needs to be taken? Currently, the init function only registers the device. Maybe some example/code might be helpful to drive the point. Also, are the future additional tests expected to be added soon? If not, maybe we can defer this optimization until the need arrives. Sohil > > Jithu
On 10/24/2022 11:06 PM, Sohil Mehta wrote: > On 10/24/2022 5:41 PM, Joseph, Jithu wrote: >>>> diff --git a/drivers/platform/x86/intel/ifs/core.c b/drivers/platform/x86/intel/ifs/core.c >>>> index 27204e3d674d..5fb7f655c291 100644 >>>> --- a/drivers/platform/x86/intel/ifs/core.c >>>> +++ b/drivers/platform/x86/intel/ifs/core.c >>>> @@ -51,12 +51,8 @@ static int __init ifs_init(void) >>>> ifs_device.misc.groups = ifs_get_groups(); >>>> if ((msrval & BIT(ifs_device.data.integrity_cap_bit)) && >>> >>> Is there a reason to store the integrity cap constant in the device.data global structure? >>> >>> .data = { >>> .integrity_cap_bit = MSR_INTEGRITY_CAPS_PERIODIC_BIST_BIT, >>> }, >> >> This was originally added so that, when future additional tests are supported by the driver, support can be checked using the same if ((msrval & BIT(ifs_device.data.integrity_cap_bit) >> Different tests would have different integrity_cap_bit assigned in the ifs_device[] array (today it is just a single element and not an array >> >> Note that the current series doesn't introduce this >> >> > > Sorry, I am still not able to follow. > > Let's say you have an ifs_device[] array which has different integrity capabilities, there would still need to be some logic in the init code to differentiate between the resulting action that needs to be taken? Currently, the init function only registers the device. Maybe some example/code might be helpful to drive the point. multiple devices will be created if support for more than one is advertised by MSR_INTEGRITY_CAPS as shown below static int __init ifs_init(void) { .... if (rdmsrl_safe(MSR_INTEGRITY_CAPS, &msrval)) return -ENODEV; for (i = 0; i < IFS_NUMTESTS; i++) { if (!(msrval & BIT(ifs_devices[i].data.integrity_cap_bit))) continue; ifs_devices[i].misc.groups = ifs_get_groups(); if (!misc_register(&ifs_devices[i].misc)) { ndevices++; } } return ndevices ? 0 : -ENODEV; } At the handler side we can branch to the corresponding handler by looking at this bit Say for e.g the following function in runtest.c could be extended to something like int do_core_test(int cpu, struct device *dev) { struct ifs_data *ifsd = ifs_get_data(dev); ..... switch (ifsd->integrity_cap_bit) { case MSR_INTEGRITY_CAPS_PERIODIC_BIST_BIT: ifs_test_core(cpu, dev); break; case MSR_INTEGRITY_CAPS_TEST2 ifs_do_test2(cpu, dev); break; case MSR_INTEGRITY_CAPS_TEST3 ifs_do_test3(cpu, dev); break; default: return -EINVAL; } .... } Jithu
Thanks for the psuedo code. I think I understand the reasoning now. There would be an IFS device array created for each type of test that exists. Based on the capabilities supported in MSR_INTEGRITY_CAPS the specific IFS devices would be created to run the tests. > multiple devices will be created if support for more than one is advertised by MSR_INTEGRITY_CAPS as shown below > Well, it would also depend on whether the currently running kernel has enumerated that test. IIUC, older kernels running on newer hardware would only create ifs test devices they are aware of. It would have been great if the above statement would be true as is :) > static int __init ifs_init(void) > { > > .... > if (rdmsrl_safe(MSR_INTEGRITY_CAPS, &msrval)) > return -ENODEV; > > for (i = 0; i < IFS_NUMTESTS; i++) { > if (!(msrval & BIT(ifs_devices[i].data.integrity_cap_bit))) > continue; > > ifs_devices[i].misc.groups = ifs_get_groups(); > if (!misc_register(&ifs_devices[i].misc)) { > ndevices++; > } > } > > return ndevices ? 0 : -ENODEV; > } > Nit: The _BIT extension is probably unnecessary. How about? .data = { .integrity_cap = MSR_INTEGRITY_CAPS_PERIODIC_BIST, },
diff --git a/drivers/platform/x86/intel/ifs/ifs.h b/drivers/platform/x86/intel/ifs/ifs.h index 782bcc039ddb..be37512535f2 100644 --- a/drivers/platform/x86/intel/ifs/ifs.h +++ b/drivers/platform/x86/intel/ifs/ifs.h @@ -229,6 +229,4 @@ 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 semaphore ifs_sem; - #endif diff --git a/drivers/platform/x86/intel/ifs/core.c b/drivers/platform/x86/intel/ifs/core.c index 27204e3d674d..5fb7f655c291 100644 --- a/drivers/platform/x86/intel/ifs/core.c +++ b/drivers/platform/x86/intel/ifs/core.c @@ -51,12 +51,8 @@ static int __init ifs_init(void) ifs_device.misc.groups = ifs_get_groups(); if ((msrval & BIT(ifs_device.data.integrity_cap_bit)) && - !misc_register(&ifs_device.misc)) { - down(&ifs_sem); - ifs_load_firmware(ifs_device.misc.this_device); - up(&ifs_sem); + !misc_register(&ifs_device.misc)) return 0; - } return -ENODEV; } diff --git a/drivers/platform/x86/intel/ifs/sysfs.c b/drivers/platform/x86/intel/ifs/sysfs.c index 4af4e1bea98d..766cee651bd6 100644 --- a/drivers/platform/x86/intel/ifs/sysfs.c +++ b/drivers/platform/x86/intel/ifs/sysfs.c @@ -13,7 +13,7 @@ * Protects against simultaneous tests on multiple cores, or * reloading can file while a test is in progress */ -DEFINE_SEMAPHORE(ifs_sem); +static DEFINE_SEMAPHORE(ifs_sem); /* * The sysfs interface to check additional details of last test