Commit 217d3cfb authored by Robert Richter's avatar Robert Richter

x86/oprofile: replace CTR*_IS_RESERVED macros

The patch replaces all CTR*_IS_RESERVED macros.
Signed-off-by: default avatarRobert Richter <robert.richter@amd.com>
parent dea3766c
...@@ -90,7 +90,7 @@ static void op_amd_setup_ctrs(struct op_x86_model_spec const *model, ...@@ -90,7 +90,7 @@ static void op_amd_setup_ctrs(struct op_x86_model_spec const *model,
/* clear all counters */ /* clear all counters */
for (i = 0 ; i < NUM_CONTROLS; ++i) { for (i = 0 ; i < NUM_CONTROLS; ++i) {
if (unlikely(!CTRL_IS_RESERVED(msrs, i))) if (unlikely(!msrs->controls[i].addr))
continue; continue;
rdmsrl(msrs->controls[i].addr, val); rdmsrl(msrs->controls[i].addr, val);
val &= model->reserved; val &= model->reserved;
...@@ -99,14 +99,14 @@ static void op_amd_setup_ctrs(struct op_x86_model_spec const *model, ...@@ -99,14 +99,14 @@ static void op_amd_setup_ctrs(struct op_x86_model_spec const *model,
/* avoid a false detection of ctr overflows in NMI handler */ /* avoid a false detection of ctr overflows in NMI handler */
for (i = 0; i < NUM_COUNTERS; ++i) { for (i = 0; i < NUM_COUNTERS; ++i) {
if (unlikely(!CTR_IS_RESERVED(msrs, i))) if (unlikely(!msrs->counters[i].addr))
continue; continue;
wrmsr(msrs->counters[i].addr, -1, -1); wrmsr(msrs->counters[i].addr, -1, -1);
} }
/* enable active counters */ /* enable active counters */
for (i = 0; i < NUM_COUNTERS; ++i) { for (i = 0; i < NUM_COUNTERS; ++i) {
if ((counter_config[i].enabled) && (CTR_IS_RESERVED(msrs, i))) { if (counter_config[i].enabled && msrs->counters[i].addr) {
reset_value[i] = counter_config[i].count; reset_value[i] = counter_config[i].count;
wrmsr(msrs->counters[i].addr, -(unsigned int)counter_config[i].count, -1); wrmsr(msrs->counters[i].addr, -(unsigned int)counter_config[i].count, -1);
rdmsrl(msrs->controls[i].addr, val); rdmsrl(msrs->controls[i].addr, val);
...@@ -300,11 +300,11 @@ static void op_amd_shutdown(struct op_msrs const * const msrs) ...@@ -300,11 +300,11 @@ static void op_amd_shutdown(struct op_msrs const * const msrs)
int i; int i;
for (i = 0 ; i < NUM_COUNTERS ; ++i) { for (i = 0 ; i < NUM_COUNTERS ; ++i) {
if (CTR_IS_RESERVED(msrs, i)) if (msrs->counters[i].addr)
release_perfctr_nmi(MSR_K7_PERFCTR0 + i); release_perfctr_nmi(MSR_K7_PERFCTR0 + i);
} }
for (i = 0 ; i < NUM_CONTROLS ; ++i) { for (i = 0 ; i < NUM_CONTROLS ; ++i) {
if (CTRL_IS_RESERVED(msrs, i)) if (msrs->controls[i].addr)
release_evntsel_nmi(MSR_K7_EVNTSEL0 + i); release_evntsel_nmi(MSR_K7_EVNTSEL0 + i);
} }
} }
......
...@@ -559,7 +559,7 @@ static void p4_setup_ctrs(struct op_x86_model_spec const *model, ...@@ -559,7 +559,7 @@ static void p4_setup_ctrs(struct op_x86_model_spec const *model,
/* clear the cccrs we will use */ /* clear the cccrs we will use */
for (i = 0 ; i < num_counters ; i++) { for (i = 0 ; i < num_counters ; i++) {
if (unlikely(!CTRL_IS_RESERVED(msrs, i))) if (unlikely(!msrs->controls[i].addr))
continue; continue;
rdmsr(p4_counters[VIRT_CTR(stag, i)].cccr_address, low, high); rdmsr(p4_counters[VIRT_CTR(stag, i)].cccr_address, low, high);
CCCR_CLEAR(low); CCCR_CLEAR(low);
...@@ -569,14 +569,14 @@ static void p4_setup_ctrs(struct op_x86_model_spec const *model, ...@@ -569,14 +569,14 @@ static void p4_setup_ctrs(struct op_x86_model_spec const *model,
/* clear all escrs (including those outside our concern) */ /* clear all escrs (including those outside our concern) */
for (i = num_counters; i < num_controls; i++) { for (i = num_counters; i < num_controls; i++) {
if (unlikely(!CTRL_IS_RESERVED(msrs, i))) if (unlikely(!msrs->controls[i].addr))
continue; continue;
wrmsr(msrs->controls[i].addr, 0, 0); wrmsr(msrs->controls[i].addr, 0, 0);
} }
/* setup all counters */ /* setup all counters */
for (i = 0 ; i < num_counters ; ++i) { for (i = 0 ; i < num_counters ; ++i) {
if ((counter_config[i].enabled) && (CTRL_IS_RESERVED(msrs, i))) { if (counter_config[i].enabled && msrs->controls[i].addr) {
reset_value[i] = counter_config[i].count; reset_value[i] = counter_config[i].count;
pmc_setup_one_p4_counter(i); pmc_setup_one_p4_counter(i);
wrmsr(p4_counters[VIRT_CTR(stag, i)].counter_address, wrmsr(p4_counters[VIRT_CTR(stag, i)].counter_address,
...@@ -679,7 +679,7 @@ static void p4_shutdown(struct op_msrs const * const msrs) ...@@ -679,7 +679,7 @@ static void p4_shutdown(struct op_msrs const * const msrs)
int i; int i;
for (i = 0 ; i < num_counters ; ++i) { for (i = 0 ; i < num_counters ; ++i) {
if (CTR_IS_RESERVED(msrs, i)) if (msrs->counters[i].addr)
release_perfctr_nmi(msrs->counters[i].addr); release_perfctr_nmi(msrs->counters[i].addr);
} }
/* /*
...@@ -688,7 +688,7 @@ static void p4_shutdown(struct op_msrs const * const msrs) ...@@ -688,7 +688,7 @@ static void p4_shutdown(struct op_msrs const * const msrs)
* This saves a few bits. * This saves a few bits.
*/ */
for (i = num_counters ; i < num_controls ; ++i) { for (i = num_counters ; i < num_controls ; ++i) {
if (CTRL_IS_RESERVED(msrs, i)) if (msrs->controls[i].addr)
release_evntsel_nmi(msrs->controls[i].addr); release_evntsel_nmi(msrs->controls[i].addr);
} }
} }
......
...@@ -82,7 +82,7 @@ static void ppro_setup_ctrs(struct op_x86_model_spec const *model, ...@@ -82,7 +82,7 @@ static void ppro_setup_ctrs(struct op_x86_model_spec const *model,
/* clear all counters */ /* clear all counters */
for (i = 0 ; i < num_counters; ++i) { for (i = 0 ; i < num_counters; ++i) {
if (unlikely(!CTRL_IS_RESERVED(msrs, i))) if (unlikely(!msrs->controls[i].addr))
continue; continue;
rdmsrl(msrs->controls[i].addr, val); rdmsrl(msrs->controls[i].addr, val);
val &= model->reserved; val &= model->reserved;
...@@ -91,14 +91,14 @@ static void ppro_setup_ctrs(struct op_x86_model_spec const *model, ...@@ -91,14 +91,14 @@ static void ppro_setup_ctrs(struct op_x86_model_spec const *model,
/* avoid a false detection of ctr overflows in NMI handler */ /* avoid a false detection of ctr overflows in NMI handler */
for (i = 0; i < num_counters; ++i) { for (i = 0; i < num_counters; ++i) {
if (unlikely(!CTR_IS_RESERVED(msrs, i))) if (unlikely(!msrs->counters[i].addr))
continue; continue;
wrmsrl(msrs->counters[i].addr, -1LL); wrmsrl(msrs->counters[i].addr, -1LL);
} }
/* enable active counters */ /* enable active counters */
for (i = 0; i < num_counters; ++i) { for (i = 0; i < num_counters; ++i) {
if ((counter_config[i].enabled) && (CTR_IS_RESERVED(msrs, i))) { if (counter_config[i].enabled && msrs->counters[i].addr) {
reset_value[i] = counter_config[i].count; reset_value[i] = counter_config[i].count;
wrmsrl(msrs->counters[i].addr, -reset_value[i]); wrmsrl(msrs->counters[i].addr, -reset_value[i]);
rdmsrl(msrs->controls[i].addr, val); rdmsrl(msrs->controls[i].addr, val);
...@@ -181,11 +181,11 @@ static void ppro_shutdown(struct op_msrs const * const msrs) ...@@ -181,11 +181,11 @@ static void ppro_shutdown(struct op_msrs const * const msrs)
int i; int i;
for (i = 0 ; i < num_counters ; ++i) { for (i = 0 ; i < num_counters ; ++i) {
if (CTR_IS_RESERVED(msrs, i)) if (msrs->counters[i].addr)
release_perfctr_nmi(MSR_P6_PERFCTR0 + i); release_perfctr_nmi(MSR_P6_PERFCTR0 + i);
} }
for (i = 0 ; i < num_counters ; ++i) { for (i = 0 ; i < num_counters ; ++i) {
if (CTRL_IS_RESERVED(msrs, i)) if (msrs->controls[i].addr)
release_evntsel_nmi(MSR_P6_EVNTSEL0 + i); release_evntsel_nmi(MSR_P6_EVNTSEL0 + i);
} }
if (reset_value) { if (reset_value) {
......
...@@ -15,9 +15,6 @@ ...@@ -15,9 +15,6 @@
#include <asm/types.h> #include <asm/types.h>
#include <asm/intel_arch_perfmon.h> #include <asm/intel_arch_perfmon.h>
#define CTR_IS_RESERVED(msrs, c) ((msrs)->counters[(c)].addr ? 1 : 0)
#define CTRL_IS_RESERVED(msrs, c) ((msrs)->controls[(c)].addr ? 1 : 0)
struct op_saved_msr { struct op_saved_msr {
unsigned int high; unsigned int high;
unsigned int low; unsigned int low;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment