Blame src/perfctr-2.7.x/linux/Documentation/perfctr/low-level-ppc32.txt

Packit 577717
$Id: low-level-ppc32.txt,v 1.1 2004/07/02 18:57:05 mikpe Exp $
Packit 577717
Packit 577717
PERFCTRS PPC32 LOW-LEVEL API
Packit 577717
============================
Packit 577717
Packit 577717
See low-level-api.txt for the common low-level API.
Packit 577717
This document only describes ppc32-specific behaviour.
Packit 577717
For detailed hardware control register layouts, see
Packit 577717
the manufacturers' documentation.
Packit 577717
Packit 577717
Supported processors
Packit 577717
====================
Packit 577717
- PowerPC 604, 604e, 604ev.
Packit 577717
- PowerPC 750/740, 750CX, 750FX, 750GX.
Packit 577717
- PowerPC 7400, 7410, 7451/7441, 7457/7447.
Packit 577717
- Any generic PowerPC with a timebase register.
Packit 577717
Packit 577717
Contents of <asm-$ARCH/perfctr.h>
Packit 577717
=================================
Packit 577717
Packit 577717
"struct perfctr_sum_ctrs"
Packit 577717
-------------------------
Packit 577717
struct perfctr_sum_ctrs {
Packit 577717
	unsigned long long tsc;
Packit 577717
	unsigned long long pmc[8];
Packit 577717
};
Packit 577717
Packit 577717
The pmc[] array has room for 8 counters.
Packit 577717
Packit 577717
"struct perfctr_cpu_control"
Packit 577717
----------------------------
Packit 577717
struct perfctr_cpu_control {
Packit 577717
	unsigned int tsc_on;
Packit 577717
	unsigned int nractrs;		/* # of a-mode counters */
Packit 577717
	unsigned int nrictrs;		/* # of i-mode counters */
Packit 577717
	unsigned int pmc_map[8];
Packit 577717
	unsigned int evntsel[8];	/* one per counter, even on P5 */
Packit 577717
	int ireset[8];			/* [0,0x7fffffff], for i-mode counters */
Packit 577717
	struct {
Packit 577717
		unsigned int mmcr0;	/* sans PMC{1,2}SEL */
Packit 577717
		unsigned int mmcr2;	/* only THRESHMULT */
Packit 577717
		/* IABR/DABR/BAMR not supported */
Packit 577717
	} ppc;
Packit 577717
	unsigned int _reserved1;
Packit 577717
	unsigned int _reserved2;
Packit 577717
	unsigned int _reserved3;
Packit 577717
	unsigned int _reserved4;
Packit 577717
};
Packit 577717
Packit 577717
The per-counter arrays have room for 8 elements.
Packit 577717
Packit 577717
ireset[] values must be non-negative, since overflow occurs on
Packit 577717
the non-negative-to-negative transition.
Packit 577717
Packit 577717
The ppc sub-struct contains PowerPC-specific control data:
Packit 577717
- mmcr0: global control data for the MMCR0 SPR; the event
Packit 577717
  selectors for PMC1 and PMC2 are in evntsel[], not in mmcr0
Packit 577717
- mmcr2: global control data for the MMCR2 SPR; only the
Packit 577717
  THRESHMULT field can be specified
Packit 577717
Packit 577717
"struct perfctr_cpu_state"
Packit 577717
--------------------------
Packit 577717
struct perfctr_cpu_state {
Packit 577717
	unsigned int cstatus;
Packit 577717
	struct {	/* k1 is opaque in the user ABI */
Packit 577717
		unsigned int id;
Packit 577717
		int isuspend_cpu;
Packit 577717
	} k1;
Packit 577717
	/* The two tsc fields must be inlined. Placing them in a
Packit 577717
	   sub-struct causes unwanted internal padding on x86-64. */
Packit 577717
	unsigned int tsc_start;
Packit 577717
	unsigned long long tsc_sum;
Packit 577717
	struct {
Packit 577717
		unsigned int map;
Packit 577717
		unsigned int start;
Packit 577717
		unsigned long long sum;
Packit 577717
	} pmc[8];	/* the size is not part of the user ABI */
Packit 577717
#ifdef __KERNEL__
Packit 577717
	unsigned int ppc_mmcr[3];
Packit 577717
	struct perfctr_cpu_control control;
Packit 577717
#endif
Packit 577717
};
Packit 577717
Packit 577717
The k1 sub-struct is used by the low-level driver for
Packit 577717
caching purposes. "id" identifies the control data, and
Packit 577717
"isuspend_cpu" identifies the CPU on which the i-mode
Packit 577717
counters were last suspended.
Packit 577717
Packit 577717
The pmc[] array has room for 8 elements.
Packit 577717
Packit 577717
ppc_mmcr[] is computed from control by the low-level driver,
Packit 577717
and provides the data for the MMCR0, MMCR1, and MMCR2 SPRs.
Packit 577717
Packit 577717
User-space overflow signal handler items
Packit 577717
----------------------------------------
Packit 577717
#ifdef __KERNEL__
Packit 577717
#define SI_PMC_OVF	(__SI_FAULT|'P')
Packit 577717
#else
Packit 577717
#define SI_PMC_OVF	('P')
Packit 577717
#endif
Packit 577717
#define si_pmc_ovf_mask	_sifields._pad[0]
Packit 577717
Packit 577717
Kernel-internal API
Packit 577717
-------------------
Packit 577717
Packit 577717
In perfctr_cpu_update_control(), the is_global parameter
Packit 577717
is ignored. (It is only relevant for x86.)
Packit 577717
Packit 577717
CONFIG_PERFCTR_CPUS_FORBIDDEN_MASK is never defined.
Packit 577717
(It is only relevant for x86.)
Packit 577717
Packit 577717
Overflow interrupt handling is not yet implemented.
Packit 577717
Packit 577717
Processor-specific Notes
Packit 577717
========================
Packit 577717
Packit 577717
General
Packit 577717
-------
Packit 577717
pmc_map[] contains a counter number, an integer between 0 and 5.
Packit 577717
It never contains an SPR number.
Packit 577717
Packit 577717
Basic operation (the strategy for a-mode counters, caching
Packit 577717
control register contents, recording "suspend CPU" for i-mode
Packit 577717
counters) is the same as in the x86 driver.
Packit 577717
Packit 577717
PowerPC 604/750/74xx
Packit 577717
--------------------
Packit 577717
These processors use similar hardware layouts, differing
Packit 577717
mainly in the number of counter and control registers.
Packit 577717
The set of available events differ greatly, but that only
Packit 577717
affects users, not the low-level driver itself.
Packit 577717
Packit 577717
The hardware has 2 (604), 4 (604e/750/7400/7410), or 6
Packit 577717
(745x) counters (PMC1 to PMC6), and 1 (604), 2 (604e/750),
Packit 577717
or 3 (74xx) control registers (MMCR0 to MMCR2).
Packit 577717
Packit 577717
MMCR0 contains global control bits, and the event selection
Packit 577717
fields for PMC1 and PMC2. MMCR1 contains event selection fields
Packit 577717
for PMC3-PMC6. MMCR2 contains the THRESHMULT flag, which
Packit 577717
specifies how MMCR0[THRESHOLD] should be scaled.
Packit 577717
Packit 577717
In control.ppc.mmcr0, the PMC1SEL and PMC2SEL fields (0x00001FFF)
Packit 577717
are reserved. The PMXE flag (0x04000000) may only be set when
Packit 577717
the driver supports overflow interrupts.
Packit 577717
Packit 577717
If FCECE or TRIGGER is set in MMCR0 on a 74xx processor, then
Packit 577717
MMCR0 can change asynchronously. The driver handles this, at
Packit 577717
the cost of some additional work in perfctr_cpu_suspend().
Packit 577717
Not setting these flags avoids that overhead.
Packit 577717
Packit 577717
In control.ppc.mmcr2, only the THRESHMULT flag (0x80000000)
Packit 577717
may be set, and only on 74xx processors.
Packit 577717
Packit 577717
The SIA (sampled instruction address) register is not used.
Packit 577717
The SDA (sampled data address) register is 604/604e-only,
Packit 577717
and is not used. The BAMR (breakpoint address mask) register
Packit 577717
is not used, but it is cleared by the driver.
Packit 577717
Packit 577717
Generic PowerPC with timebase
Packit 577717
-----------------------------
Packit 577717
The driver supports any PowerPC as long as it has a timebase
Packit 577717
register, and the TB frequency is available via Open Firmware.
Packit 577717
In this case, the only valid usage mode is with tsc_on == 1
Packit 577717
and nractrs == nrictrs == 0 in the control data.