Skip to content

Commit

Permalink
sparc64: Fix bit twiddling in sparc_pmu_enable_event().
Browse files Browse the repository at this point in the history
There was a serious disconnect in the logic happening in
sparc_pmu_disable_event() vs. sparc_pmu_enable_event().

Event disable is implemented by programming a NOP event into the PCR.

However, event enable was not reversing this operation.  Instead, it
was setting the User/Priv/Hypervisor trace enable bits.

That's not sparc_pmu_enable_event()'s job, that's what
sparc_pmu_enable() and sparc_pmu_disable() do .

The intent of sparc_pmu_enable_event() is clear, since it first clear
out the event type encoding field.  So fix this by OR'ing in the event
encoding rather than the trace enable bits.

Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
davem330 committed Oct 16, 2012
1 parent 916ca14 commit e793d8c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions arch/sparc/kernel/perf_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -817,15 +817,17 @@ static u64 nop_for_index(int idx)

static inline void sparc_pmu_enable_event(struct cpu_hw_events *cpuc, struct hw_perf_event *hwc, int idx)
{
u64 val, mask = mask_for_index(idx);
u64 enc, val, mask = mask_for_index(idx);
int pcr_index = 0;

if (sparc_pmu->num_pcrs > 1)
pcr_index = idx;

enc = perf_event_get_enc(cpuc->events[idx]);

val = cpuc->pcr[pcr_index];
val &= ~mask;
val |= hwc->config;
val |= event_encoding(enc, idx);
cpuc->pcr[pcr_index] = val;

pcr_ops->write_pcr(pcr_index, cpuc->pcr[pcr_index]);
Expand Down

0 comments on commit e793d8c

Please sign in to comment.