tools/power/x86/intel-speed-select: Add cpu id check
authorZhang Rui <rui.zhang@intel.com>
Tue, 13 Sep 2022 12:23:19 +0000 (20:23 +0800)
committerSrinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Wed, 22 Mar 2023 20:36:55 +0000 (13:36 -0700)
Some operations applies to cpu-power-domain only. Add check for cpu id
for these functions.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
tools/power/x86/intel-speed-select/isst-config.c
tools/power/x86/intel-speed-select/isst-core.c

index b10c6ec..a040056 100644 (file)
@@ -800,6 +800,9 @@ void set_cpu_mask_from_punit_coremask(struct isst_id *id, unsigned long long cor
 {
        int i, cnt = 0;
 
+       if (id->cpu < 0)
+               return;
+
        *cpu_cnt = 0;
 
        for (i = 0; i < 64; ++i) {
@@ -1253,7 +1256,7 @@ static void set_tdp_level_for_cpu(struct isst_id *id, void *arg1, void *arg2, vo
 
 display_result:
        isst_display_result(id, outf, "perf-profile", "set_tdp_level", ret);
-       if (force_online_offline) {
+       if (force_online_offline && id->cpu >= 0) {
                struct isst_pkg_ctdp_level_info ctdp_level;
 
                /* Wait for updated base frequencies */
@@ -1547,6 +1550,9 @@ static void set_scaling_min_to_cpuinfo_max(struct isst_id *id)
 {
        int i;
 
+       if (id->cpu < 0)
+               return;
+
        for (i = 0; i < get_topo_max_cpus(); ++i) {
                if (!is_cpu_in_power_domain(i, id))
                        continue;
@@ -1564,6 +1570,9 @@ static void set_scaling_min_to_cpuinfo_min(struct isst_id *id)
 {
        int i;
 
+       if (id->cpu < 0)
+               return;
+
        for (i = 0; i < get_topo_max_cpus(); ++i) {
                if (!is_cpu_in_power_domain(i, id))
                        continue;
@@ -1643,6 +1652,9 @@ static int set_pbf_core_power(struct isst_id *id)
        struct isst_pkg_ctdp pkg_dev;
        int ret;
 
+       if (id->cpu < 0)
+               return 0;
+
        ret = isst_get_ctdp_levels(id, &pkg_dev);
        if (ret) {
                debug_printf("isst_get_ctdp_levels failed");
@@ -1888,7 +1900,7 @@ static void set_fact_for_cpu(struct isst_id *id, void *arg1, void *arg2, void *a
                struct isst_pkg_ctdp pkg_dev;
 
                ret = isst_get_ctdp_levels(id, &pkg_dev);
-               if (!ret)
+               if (!ret && id->cpu >= 0)
                        ret = isst_set_trl(id, fact_trl);
                if (ret && auto_mode)
                        isst_pm_qos_config(id, 0, 0);
index f0b96d7..f55fef4 100644 (file)
@@ -287,6 +287,9 @@ int isst_set_trl_from_current_tdp(struct isst_id *id, unsigned long long trl)
        unsigned long long msr_trl;
        int ret;
 
+       if (id->cpu < 0)
+               return 0;
+
        if (trl) {
                msr_trl = trl;
        } else {