platform/x86/intel/ifs: Separate ifs_pkg_auth from ifs_data
authorJithu Joseph <jithu.joseph@intel.com>
Wed, 22 Mar 2023 00:33:51 +0000 (17:33 -0700)
committerHans de Goede <hdegoede@redhat.com>
Mon, 27 Mar 2023 14:10:20 +0000 (16:10 +0200)
In preparation to supporting additional tests, remove ifs_pkg_auth
from per-test scope, as it is only applicable for one test type.

This will simplify ifs_init() flow when multiple tests are added.

Signed-off-by: Jithu Joseph <jithu.joseph@intel.com>
Reviewed-by: Tony Luck <tony.luck@intel.com>
Link: https://lore.kernel.org/r/20230322003359.213046-2-jithu.joseph@intel.com
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
drivers/platform/x86/intel/ifs/core.c
drivers/platform/x86/intel/ifs/ifs.h
drivers/platform/x86/intel/ifs/load.c

index 206a617c2e02c1daebe32b3058193f4bdd2f07f8..3176d94b1fe5ea9418372a275617fb863807685d 100644 (file)
@@ -20,6 +20,8 @@ static const struct x86_cpu_id ifs_cpu_ids[] __initconst = {
 };
 MODULE_DEVICE_TABLE(x86cpu, ifs_cpu_ids);
 
+bool *ifs_pkg_auth;
+
 static struct ifs_device ifs_device = {
        .data = {
                .integrity_cap_bit = MSR_INTEGRITY_CAPS_PERIODIC_BIST_BIT,
@@ -56,13 +58,13 @@ static int __init ifs_init(void)
        if (!(msrval & BIT(ifs_device.data.integrity_cap_bit)))
                return -ENODEV;
 
-       ifs_device.data.pkg_auth = kmalloc_array(topology_max_packages(), sizeof(bool), GFP_KERNEL);
-       if (!ifs_device.data.pkg_auth)
+       ifs_pkg_auth = kmalloc_array(topology_max_packages(), sizeof(bool), GFP_KERNEL);
+       if (!ifs_pkg_auth)
                return -ENOMEM;
 
        ret = misc_register(&ifs_device.misc);
        if (ret) {
-               kfree(ifs_device.data.pkg_auth);
+               kfree(ifs_pkg_auth);
                return ret;
        }
 
@@ -72,7 +74,7 @@ static int __init ifs_init(void)
 static void __exit ifs_exit(void)
 {
        misc_deregister(&ifs_device.misc);
-       kfree(ifs_device.data.pkg_auth);
+       kfree(ifs_pkg_auth);
 }
 
 module_init(ifs_init);
index 046e39304fd55795871b74d0fd78bb9425e298d5..221413b79281e8f7bef52e9815d33eb523f8bd54 100644 (file)
@@ -201,7 +201,6 @@ union ifs_status {
  * struct ifs_data - attributes related to intel IFS driver
  * @integrity_cap_bit: MSR_INTEGRITY_CAPS bit enumerating this test
  * @loaded_version: stores the currently loaded ifs image version.
- * @pkg_auth: array of bool storing per package auth status
  * @loaded: If a valid test binary has been loaded into the memory
  * @loading_error: Error occurred on another CPU while loading image
  * @valid_chunks: number of chunks which could be validated.
@@ -212,7 +211,6 @@ union ifs_status {
  */
 struct ifs_data {
        int     integrity_cap_bit;
-       bool    *pkg_auth;
        int     loaded_version;
        bool    loaded;
        bool    loading_error;
@@ -241,6 +239,7 @@ static inline struct ifs_data *ifs_get_data(struct device *dev)
        return &d->data;
 }
 
+extern bool *ifs_pkg_auth;
 int ifs_load_firmware(struct device *dev);
 int do_core_test(int cpu, struct device *dev);
 const struct attribute_group **ifs_get_groups(void);
index c5c24e6fdc436e580db4d4cb75132405d2c7dd45..74a50e99cacd449cbfad951e889927066f32953f 100644 (file)
@@ -192,7 +192,7 @@ static int scan_chunks_sanity_check(struct device *dev)
        struct ifs_work local_work;
        int curr_pkg, cpu, ret;
 
-       memset(ifsd->pkg_auth, 0, (topology_max_packages() * sizeof(bool)));
+       memset(ifs_pkg_auth, 0, (topology_max_packages() * sizeof(bool)));
        ret = validate_ifs_metadata(dev);
        if (ret)
                return ret;
@@ -204,7 +204,7 @@ static int scan_chunks_sanity_check(struct device *dev)
        cpus_read_lock();
        for_each_online_cpu(cpu) {
                curr_pkg = topology_physical_package_id(cpu);
-               if (ifsd->pkg_auth[curr_pkg])
+               if (ifs_pkg_auth[curr_pkg])
                        continue;
                reinit_completion(&ifs_done);
                local_work.dev = dev;
@@ -215,7 +215,7 @@ static int scan_chunks_sanity_check(struct device *dev)
                        ret = -EIO;
                        goto out;
                }
-               ifsd->pkg_auth[curr_pkg] = 1;
+               ifs_pkg_auth[curr_pkg] = 1;
        }
        ret = 0;
 out: