diff options
Diffstat (limited to 'arch/x86/oprofile/op_model_amd.c')
-rw-r--r-- | arch/x86/oprofile/op_model_amd.c | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/arch/x86/oprofile/op_model_amd.c b/arch/x86/oprofile/op_model_amd.c index 7e5886d54bd5..536d0b0b39a5 100644 --- a/arch/x86/oprofile/op_model_amd.c +++ b/arch/x86/oprofile/op_model_amd.c | |||
@@ -138,21 +138,30 @@ static void op_amd_shutdown(struct op_msrs const * const msrs) | |||
138 | } | 138 | } |
139 | } | 139 | } |
140 | 140 | ||
141 | static void op_amd_fill_in_addresses(struct op_msrs * const msrs) | 141 | static int op_amd_fill_in_addresses(struct op_msrs * const msrs) |
142 | { | 142 | { |
143 | int i; | 143 | int i; |
144 | 144 | ||
145 | for (i = 0; i < NUM_COUNTERS; i++) { | 145 | for (i = 0; i < NUM_COUNTERS; i++) { |
146 | if (!reserve_perfctr_nmi(MSR_K7_PERFCTR0 + i)) | 146 | if (!reserve_perfctr_nmi(MSR_K7_PERFCTR0 + i)) |
147 | continue; | 147 | goto fail; |
148 | if (!reserve_evntsel_nmi(MSR_K7_EVNTSEL0 + i)) { | 148 | if (!reserve_evntsel_nmi(MSR_K7_EVNTSEL0 + i)) { |
149 | release_perfctr_nmi(MSR_K7_PERFCTR0 + i); | 149 | release_perfctr_nmi(MSR_K7_PERFCTR0 + i); |
150 | continue; | 150 | goto fail; |
151 | } | 151 | } |
152 | /* both registers must be reserved */ | 152 | /* both registers must be reserved */ |
153 | msrs->counters[i].addr = MSR_K7_PERFCTR0 + i; | 153 | msrs->counters[i].addr = MSR_K7_PERFCTR0 + i; |
154 | msrs->controls[i].addr = MSR_K7_EVNTSEL0 + i; | 154 | msrs->controls[i].addr = MSR_K7_EVNTSEL0 + i; |
155 | continue; | ||
156 | fail: | ||
157 | if (!counter_config[i].enabled) | ||
158 | continue; | ||
159 | op_x86_warn_reserved(i); | ||
160 | op_amd_shutdown(msrs); | ||
161 | return -EBUSY; | ||
155 | } | 162 | } |
163 | |||
164 | return 0; | ||
156 | } | 165 | } |
157 | 166 | ||
158 | static void op_amd_setup_ctrs(struct op_x86_model_spec const *model, | 167 | static void op_amd_setup_ctrs(struct op_x86_model_spec const *model, |
@@ -172,15 +181,8 @@ static void op_amd_setup_ctrs(struct op_x86_model_spec const *model, | |||
172 | 181 | ||
173 | /* clear all counters */ | 182 | /* clear all counters */ |
174 | for (i = 0; i < NUM_COUNTERS; ++i) { | 183 | for (i = 0; i < NUM_COUNTERS; ++i) { |
175 | if (unlikely(!msrs->controls[i].addr)) { | 184 | if (!msrs->controls[i].addr) |
176 | if (counter_config[i].enabled && !smp_processor_id()) | ||
177 | /* | ||
178 | * counter is reserved, this is on all | ||
179 | * cpus, so report only for cpu #0 | ||
180 | */ | ||
181 | op_x86_warn_reserved(i); | ||
182 | continue; | 185 | continue; |
183 | } | ||
184 | rdmsrl(msrs->controls[i].addr, val); | 186 | rdmsrl(msrs->controls[i].addr, val); |
185 | if (val & ARCH_PERFMON_EVENTSEL_ENABLE) | 187 | if (val & ARCH_PERFMON_EVENTSEL_ENABLE) |
186 | op_x86_warn_in_use(i); | 188 | op_x86_warn_in_use(i); |