linux-stable/drivers/bus
Suzuki K Poulose a445fcc997 arm-cci: CCI-500: Work around PMU counter writes
The CCI PMU driver sets the event counter to the half of the maximum
value(2^31) it can count before we start the counters via
pmu_event_set_period(). This is done to give us the best chance to
handle the overflow interrupt, taking care of extreme interrupt latencies.

However, CCI-500 comes with advanced power saving schemes, which
disables the clock to the event counters unless the counters are enabled to
count (PMCR.CEN). This prevents the driver from writing the period to the
counters before starting them.  Also, there is no way we can reset the
individual event counter to 0 (PMCR.RST resets all the counters, losing
their current readings). However the value of the counter is preserved and
could be read back, when the counters are not enabled.

So we cannot reliably use the counters and compute the number of events
generated during the sampling period since we don't have the value of the
counter at start.

This patch works around this issue by changing writes to the counter
with the following steps.

 1) Disable all the counters (remembering any counters which were enabled)
 2) Enable the PMU, now that all the counters are disabled.

 For each counter to be programmed, repeat steps 3-7
 3) Save the current event and program the target counter to count an
    invalid event, which by spec is guaranteed to not-generate any events.
 4) Enable the target counter.
 5) Write to the target counter.
 6) Disable the target counter
 7) Restore the event back on the target counter.

 8) Disable the PMU
 9) Restore the status of the all the counters

Cc: Punit Agrawal <punit.agrawal@arm.com>
Acked-by: Olof Johansson <olof@lixom.net>
Acked-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
2016-02-29 23:23:17 +00:00
..
arm-cci.c arm-cci: CCI-500: Work around PMU counter writes 2016-02-29 23:23:17 +00:00
arm-ccn.c bus: arm-ccn: Fix irq affinity setting on CPU migration 2015-10-15 17:10:15 +02:00
brcmstb_gisb.c bus: brcmstb_gisb: Honor the "big-endian" and "native-endian" DT properties 2015-05-28 21:00:20 -07:00
imx-weim.c bus: imx-weim: improve error handling upon child probe-failure 2015-03-02 21:47:59 +08:00
Kconfig bus: uniphier: allow only built-in driver 2015-12-31 23:46:29 +01:00
Makefile bus: uniphier-system-bus: add UniPhier System Bus driver 2015-12-22 11:22:39 -08:00
mips_cdmm.c MIPS: Remove "weak" from mips_cdmm_phys_base() declaration 2015-09-03 12:07:39 +02:00
mvebu-mbus.c bus: mvebu-mbus: add mv_mbus_dram_info_nooverlap() 2015-05-28 12:21:08 +02:00
omap-ocp2scp.c bus: omap-ocp2scp: Fix module alias 2015-10-12 16:10:04 -07:00
omap_l3_noc.c Merge branches 'pm-sleep' and 'pm-runtime' 2015-06-19 01:18:02 +02:00
omap_l3_noc.h bus: omap_l3_noc: Fix master id address decoding for OMAP5 2015-05-04 10:21:01 -07:00
omap_l3_smx.c genirq: Remove the deprecated 'IRQF_DISABLED' request_irq() flag entirely 2015-03-05 20:53:06 +01:00
omap_l3_smx.h
simple-pm-bus.c drivers: bus: Add Simple Power-Managed Bus Driver 2015-02-24 06:36:18 +09:00
sunxi-rsb.c bus: sunxi-rsb: Fix peripheral IC mapping runtime address 2015-12-22 11:42:30 -08:00
uniphier-system-bus.c bus: uniphier-system-bus: add UniPhier System Bus driver 2015-12-22 11:22:39 -08:00
vexpress-config.c mfd: vexpress: Add parentheses around bridge->ops->regmap_init call 2015-08-07 14:50:59 +01:00