]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
amd-pstate-ut: Add module parameter to select testcases
authorGautham R. Shenoy <gautham.shenoy@amd.com>
Thu, 26 Mar 2026 11:47:52 +0000 (17:17 +0530)
committerMario Limonciello (AMD) <superm1@kernel.org>
Thu, 2 Apr 2026 16:28:35 +0000 (11:28 -0500)
Currently when amd-pstate-ut test module is loaded, it runs all the
tests from amd_pstate_ut_cases[] array.

Add a module parameter named "test_list" that accepts a
comma-delimited list of test names, allowing users to run a
selected subset of tests. When the parameter is omitted or empty, all
tests are run as before.

Signed-off-by: Gautham R. Shenoy <gautham.shenoy@amd.com>
Reviewed-by: Mario Limonciello (AMD) <superm1@kernel.org>
Signed-off-by: Mario Limonciello (AMD) <superm1@kernel.org>
drivers/cpufreq/amd-pstate-ut.c

index 447b9aa5ce40b9f357718d59b483afba4c82ce64..3dcdf56883a6bfbe54766ba2b10d4eb09101bfc2 100644 (file)
 
 #include "amd-pstate.h"
 
+static char *test_list;
+module_param(test_list, charp, 0444);
+MODULE_PARM_DESC(test_list,
+       "Comma-delimited list of tests to run (empty means run all tests)");
 
 struct amd_pstate_ut_struct {
        const char *name;
@@ -58,6 +62,25 @@ static struct amd_pstate_ut_struct amd_pstate_ut_cases[] = {
        {"amd_pstate_ut_check_driver",     amd_pstate_ut_check_driver     }
 };
 
+static bool test_in_list(const char *list, const char *name)
+{
+       size_t name_len = strlen(name);
+       const char *p = list;
+
+       while (*p) {
+               const char *sep = strchr(p, ',');
+               size_t token_len = sep ? sep - p : strlen(p);
+
+               if (token_len == name_len && !strncmp(p, name, token_len))
+                       return true;
+               if (!sep)
+                       break;
+               p = sep + 1;
+       }
+
+       return false;
+}
+
 static bool get_shared_mem(void)
 {
        bool result = false;
@@ -275,7 +298,13 @@ static int __init amd_pstate_ut_init(void)
        u32 i = 0, arr_size = ARRAY_SIZE(amd_pstate_ut_cases);
 
        for (i = 0; i < arr_size; i++) {
-               int ret = amd_pstate_ut_cases[i].func(i);
+               int ret;
+
+               if (test_list && *test_list &&
+                   !test_in_list(test_list, amd_pstate_ut_cases[i].name))
+                       continue;
+
+               ret = amd_pstate_ut_cases[i].func(i);
 
                if (ret)
                        pr_err("%-4d %-20s\t fail: %d!\n", i+1, amd_pstate_ut_cases[i].name, ret);