diff options
-rw-r--r-- | drivers/powercap/intel_rapl.c | 29 |
1 files changed, 9 insertions, 20 deletions
diff --git a/drivers/powercap/intel_rapl.c b/drivers/powercap/intel_rapl.c index d9a0770b6c73..1c987d20c6b8 100644 --- a/drivers/powercap/intel_rapl.c +++ b/drivers/powercap/intel_rapl.c | |||
@@ -1124,8 +1124,7 @@ err_cleanup_package: | |||
1124 | static int rapl_check_domain(int cpu, int domain) | 1124 | static int rapl_check_domain(int cpu, int domain) |
1125 | { | 1125 | { |
1126 | unsigned msr; | 1126 | unsigned msr; |
1127 | u64 val1, val2 = 0; | 1127 | u64 val = 0; |
1128 | int retry = 0; | ||
1129 | 1128 | ||
1130 | switch (domain) { | 1129 | switch (domain) { |
1131 | case RAPL_DOMAIN_PACKAGE: | 1130 | case RAPL_DOMAIN_PACKAGE: |
@@ -1144,26 +1143,13 @@ static int rapl_check_domain(int cpu, int domain) | |||
1144 | pr_err("invalid domain id %d\n", domain); | 1143 | pr_err("invalid domain id %d\n", domain); |
1145 | return -EINVAL; | 1144 | return -EINVAL; |
1146 | } | 1145 | } |
1147 | if (rdmsrl_safe_on_cpu(cpu, msr, &val1)) | 1146 | /* make sure domain counters are available and contains non-zero |
1148 | return -ENODEV; | 1147 | * values, otherwise skip it. |
1149 | |||
1150 | /* PP1/uncore/graphics domain may not be active at the time of | ||
1151 | * driver loading. So skip further checks. | ||
1152 | */ | 1148 | */ |
1153 | if (domain == RAPL_DOMAIN_PP1) | 1149 | if (rdmsrl_safe_on_cpu(cpu, msr, &val) || !val) |
1154 | return 0; | 1150 | return -ENODEV; |
1155 | /* energy counters roll slowly on some domains */ | ||
1156 | while (++retry < 10) { | ||
1157 | usleep_range(10000, 15000); | ||
1158 | rdmsrl_safe_on_cpu(cpu, msr, &val2); | ||
1159 | if ((val1 & ENERGY_STATUS_MASK) != (val2 & ENERGY_STATUS_MASK)) | ||
1160 | return 0; | ||
1161 | } | ||
1162 | /* if energy counter does not change, report as bad domain */ | ||
1163 | pr_info("domain %s energy ctr %llu:%llu not working, skip\n", | ||
1164 | rapl_domain_names[domain], val1, val2); | ||
1165 | 1151 | ||
1166 | return -ENODEV; | 1152 | return 0; |
1167 | } | 1153 | } |
1168 | 1154 | ||
1169 | /* Detect active and valid domains for the given CPU, caller must | 1155 | /* Detect active and valid domains for the given CPU, caller must |
@@ -1180,6 +1166,9 @@ static int rapl_detect_domains(struct rapl_package *rp, int cpu) | |||
1180 | /* use physical package id to read counters */ | 1166 | /* use physical package id to read counters */ |
1181 | if (!rapl_check_domain(cpu, i)) | 1167 | if (!rapl_check_domain(cpu, i)) |
1182 | rp->domain_map |= 1 << i; | 1168 | rp->domain_map |= 1 << i; |
1169 | else | ||
1170 | pr_warn("RAPL domain %s detection failed\n", | ||
1171 | rapl_domain_names[i]); | ||
1183 | } | 1172 | } |
1184 | rp->nr_domains = bitmap_weight(&rp->domain_map, RAPL_DOMAIN_MAX); | 1173 | rp->nr_domains = bitmap_weight(&rp->domain_map, RAPL_DOMAIN_MAX); |
1185 | if (!rp->nr_domains) { | 1174 | if (!rp->nr_domains) { |