ARC: perf: Enable generic software events

Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
ARC: perf: debug msg for cache events

Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
ARC: break off perf header

The mapping conditions don't belong in header, specially in
asm/perf_event.h which causes the whole kernel to recompile

Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
ARC: perf: rename ARC_PMU_MAX_HWEVENTS to ARC_PERF_MAX_COUNTERS

We don't really care about amount of countable conditions, we just map
conditions kernel may use in perf subsystem.

As for counters kernel will use as many of them as available in system.
Still it's good to check if its amount matches our expectations.
For now we rely on current maximim value listed in the spec. This is 32
which fits into one machine word ("int").

If number of counters at some point gets higher not only
ARC_PERF_MAX_COUNTERS constant should be bumped but we'll need another
type for usage flags.

Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
ARC: perf: make @arc_pmu static global

Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
ARC: perf: implement "event_set_period" for future use with interrupts

This generalization prepares for support of overflow interrupts.

Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
[vgupta: Fixed up so @counter need not be in struct arc_pmu
Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
ARCv2: perf: Support sampling events using overflow interrupts

Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
ARCv2: perf: better handling of counter size

 * Adds info on counter length on probe
 * Adds a work-around for STAR 9000789081

Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
ARCv2: perf: implement exclusion of event counting in user or kernel mode

Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
ARCv2: perf: use proper branch mispredict condition on HS

There's a special condition which counts all kinds of mispredicts on ARC HS.
Moreover "bpfail" that was uaed on ARC700 is no longer here for HS.

Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
ARC: perf: SMP support

* split off pmu info into singleton and per-cpu bits
* setup PMU on all cores

Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
ARC: perf: support RAW events

To run perf against raw event user may issue following command:
--->---
Initializing raw event: crun

 Performance counter stats for 'sleep 0':

            583202 r6372756e

       0.020000000 seconds time elapsed
--->---

"-e rXXX" is indication of raw event to count.
XXX is 64-bit ASCII value.
0x6372756e = crun (in ASCII)

Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
ARCv2: introduce HS perf unit

Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
ARC: perf: remove work-arounds for STARs 9000789081 & 9000791975

Now when STARs are fixed in RTL existing work-arounds are not needed any more.

Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
ARC: perf: set usable max period as a half of real max period

Overflow interrupt happens when counter reaches a limit which we set as a
maximum value of the counter.

But for better precision counter continues registration of assigned events even
after reaching pre-defined limit. To not really overlap we leave half of the
counter values free.

Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
ARCv2: add performance counters to relevant device trees

Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
Signed-off-by: Vineet Gupta <vgupta@synopsys.com>