mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-30 08:02:30 +00:00
Merge branch 'for-next/perf' into for-next/core
* for-next/perf: (25 commits) perf/marvell: Fix !CONFIG_OF build for CN10K DDR PMU driver drivers/perf: Add Apple icestorm/firestorm CPU PMU driver drivers/perf: arm_pmu: Handle 47 bit counters arm64: perf: Consistently make all event numbers as 16-bits arm64: perf: Expose some Armv9 common events under sysfs perf/marvell: cn10k DDR perf event core ownership perf/marvell: cn10k DDR perfmon event overflow handling perf/marvell: CN10k DDR performance monitor support dt-bindings: perf: marvell: cn10k ddr performance monitor perf/arm-cmn: Update watchpoint format perf/arm-cmn: Hide XP PUB events for CMN-600 perf: replace bitmap_weight with bitmap_empty where appropriate perf: Replace acpi_bus_get_device() perf/marvell_cn10k: Fix unused variable warning when W=1 and CONFIG_OF=n perf/arm-cmn: Make arm_cmn_debugfs static perf: MARVELL_CN10K_TAD_PMU should depend on ARCH_THUNDER perf/arm-ccn: Use platform_get_irq() to get the interrupt irqchip/apple-aic: Move PMU-specific registers to their own include file arm64: dts: apple: Add t8303 PMU nodes arm64: dts: apple: Add t8103 PMU interrupt affinities ...
This commit is contained in:
commit
b5ef94fb56
23 changed files with 1790 additions and 188 deletions
|
@ -20,6 +20,8 @@ properties:
|
|||
items:
|
||||
- enum:
|
||||
- apm,potenza-pmu
|
||||
- apple,firestorm-pmu
|
||||
- apple,icestorm-pmu
|
||||
- arm,armv8-pmuv3 # Only for s/w models
|
||||
- arm,arm1136-pmu
|
||||
- arm,arm1176-pmu
|
||||
|
|
|
@ -56,6 +56,8 @@ properties:
|
|||
- 1: virtual HV timer
|
||||
- 2: physical guest timer
|
||||
- 3: virtual guest timer
|
||||
- 4: 'efficient' CPU PMU
|
||||
- 5: 'performance' CPU PMU
|
||||
|
||||
The 3rd cell contains the interrupt flags. This is normally
|
||||
IRQ_TYPE_LEVEL_HIGH (4).
|
||||
|
@ -68,6 +70,35 @@ properties:
|
|||
power-domains:
|
||||
maxItems: 1
|
||||
|
||||
affinities:
|
||||
type: object
|
||||
additionalProperties: false
|
||||
description:
|
||||
FIQ affinity can be expressed as a single "affinities" node,
|
||||
containing a set of sub-nodes, one per FIQ with a non-default
|
||||
affinity.
|
||||
patternProperties:
|
||||
"^.+-affinity$":
|
||||
type: object
|
||||
additionalProperties: false
|
||||
properties:
|
||||
apple,fiq-index:
|
||||
description:
|
||||
The interrupt number specified as a FIQ, and for which
|
||||
the affinity is not the default.
|
||||
$ref: /schemas/types.yaml#/definitions/uint32
|
||||
maximum: 5
|
||||
|
||||
cpus:
|
||||
$ref: /schemas/types.yaml#/definitions/phandle-array
|
||||
description:
|
||||
Should be a list of phandles to CPU nodes (as described in
|
||||
Documentation/devicetree/bindings/arm/cpus.yaml).
|
||||
|
||||
required:
|
||||
- fiq-index
|
||||
- cpus
|
||||
|
||||
required:
|
||||
- compatible
|
||||
- '#interrupt-cells'
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
|
||||
%YAML 1.2
|
||||
---
|
||||
$id: http://devicetree.org/schemas/perf/marvell-cn10k-ddr.yaml#
|
||||
$schema: http://devicetree.org/meta-schemas/core.yaml#
|
||||
|
||||
title: Marvell CN10K DDR performance monitor
|
||||
|
||||
maintainers:
|
||||
- Bharat Bhushan <bbhushan2@marvell.com>
|
||||
|
||||
properties:
|
||||
compatible:
|
||||
items:
|
||||
- enum:
|
||||
- marvell,cn10k-ddr-pmu
|
||||
|
||||
reg:
|
||||
maxItems: 1
|
||||
|
||||
required:
|
||||
- compatible
|
||||
- reg
|
||||
|
||||
additionalProperties: false
|
||||
|
||||
examples:
|
||||
- |
|
||||
bus {
|
||||
#address-cells = <2>;
|
||||
#size-cells = <2>;
|
||||
|
||||
pmu@87e1c0000000 {
|
||||
compatible = "marvell,cn10k-ddr-pmu";
|
||||
reg = <0x87e1 0xc0000000 0x0 0x10000>;
|
||||
};
|
||||
};
|
|
@ -97,6 +97,18 @@ timer {
|
|||
<AIC_FIQ AIC_TMR_HV_VIRT IRQ_TYPE_LEVEL_HIGH>;
|
||||
};
|
||||
|
||||
pmu-e {
|
||||
compatible = "apple,icestorm-pmu";
|
||||
interrupt-parent = <&aic>;
|
||||
interrupts = <AIC_FIQ AIC_CPU_PMU_E IRQ_TYPE_LEVEL_HIGH>;
|
||||
};
|
||||
|
||||
pmu-p {
|
||||
compatible = "apple,firestorm-pmu";
|
||||
interrupt-parent = <&aic>;
|
||||
interrupts = <AIC_FIQ AIC_CPU_PMU_P IRQ_TYPE_LEVEL_HIGH>;
|
||||
};
|
||||
|
||||
clkref: clock-ref {
|
||||
compatible = "fixed-clock";
|
||||
#clock-cells = <0>;
|
||||
|
@ -213,6 +225,18 @@ aic: interrupt-controller@23b100000 {
|
|||
interrupt-controller;
|
||||
reg = <0x2 0x3b100000 0x0 0x8000>;
|
||||
power-domains = <&ps_aic>;
|
||||
|
||||
affinities {
|
||||
e-core-pmu-affinity {
|
||||
apple,fiq-index = <AIC_CPU_PMU_E>;
|
||||
cpus = <&cpu0 &cpu1 &cpu2 &cpu3>;
|
||||
};
|
||||
|
||||
p-core-pmu-affinity {
|
||||
apple,fiq-index = <AIC_CPU_PMU_P>;
|
||||
cpus = <&cpu4 &cpu5 &cpu6 &cpu7>;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
pmgr: power-management@23b700000 {
|
||||
|
|
64
arch/arm64/include/asm/apple_m1_pmu.h
Normal file
64
arch/arm64/include/asm/apple_m1_pmu.h
Normal file
|
@ -0,0 +1,64 @@
|
|||
// SPDX-License-Identifier: GPL-2.0
|
||||
|
||||
#ifndef __ASM_APPLE_M1_PMU_h
|
||||
#define __ASM_APPLE_M1_PMU_h
|
||||
|
||||
#include <linux/bits.h>
|
||||
#include <asm/sysreg.h>
|
||||
|
||||
/* Counters */
|
||||
#define SYS_IMP_APL_PMC0_EL1 sys_reg(3, 2, 15, 0, 0)
|
||||
#define SYS_IMP_APL_PMC1_EL1 sys_reg(3, 2, 15, 1, 0)
|
||||
#define SYS_IMP_APL_PMC2_EL1 sys_reg(3, 2, 15, 2, 0)
|
||||
#define SYS_IMP_APL_PMC3_EL1 sys_reg(3, 2, 15, 3, 0)
|
||||
#define SYS_IMP_APL_PMC4_EL1 sys_reg(3, 2, 15, 4, 0)
|
||||
#define SYS_IMP_APL_PMC5_EL1 sys_reg(3, 2, 15, 5, 0)
|
||||
#define SYS_IMP_APL_PMC6_EL1 sys_reg(3, 2, 15, 6, 0)
|
||||
#define SYS_IMP_APL_PMC7_EL1 sys_reg(3, 2, 15, 7, 0)
|
||||
#define SYS_IMP_APL_PMC8_EL1 sys_reg(3, 2, 15, 9, 0)
|
||||
#define SYS_IMP_APL_PMC9_EL1 sys_reg(3, 2, 15, 10, 0)
|
||||
|
||||
/* Core PMC control register */
|
||||
#define SYS_IMP_APL_PMCR0_EL1 sys_reg(3, 1, 15, 0, 0)
|
||||
#define PMCR0_CNT_ENABLE_0_7 GENMASK(7, 0)
|
||||
#define PMCR0_IMODE GENMASK(10, 8)
|
||||
#define PMCR0_IMODE_OFF 0
|
||||
#define PMCR0_IMODE_PMI 1
|
||||
#define PMCR0_IMODE_AIC 2
|
||||
#define PMCR0_IMODE_HALT 3
|
||||
#define PMCR0_IMODE_FIQ 4
|
||||
#define PMCR0_IACT BIT(11)
|
||||
#define PMCR0_PMI_ENABLE_0_7 GENMASK(19, 12)
|
||||
#define PMCR0_STOP_CNT_ON_PMI BIT(20)
|
||||
#define PMCR0_CNT_GLOB_L2C_EVT BIT(21)
|
||||
#define PMCR0_DEFER_PMI_TO_ERET BIT(22)
|
||||
#define PMCR0_ALLOW_CNT_EN_EL0 BIT(30)
|
||||
#define PMCR0_CNT_ENABLE_8_9 GENMASK(33, 32)
|
||||
#define PMCR0_PMI_ENABLE_8_9 GENMASK(45, 44)
|
||||
|
||||
#define SYS_IMP_APL_PMCR1_EL1 sys_reg(3, 1, 15, 1, 0)
|
||||
#define PMCR1_COUNT_A64_EL0_0_7 GENMASK(15, 8)
|
||||
#define PMCR1_COUNT_A64_EL1_0_7 GENMASK(23, 16)
|
||||
#define PMCR1_COUNT_A64_EL0_8_9 GENMASK(41, 40)
|
||||
#define PMCR1_COUNT_A64_EL1_8_9 GENMASK(49, 48)
|
||||
|
||||
#define SYS_IMP_APL_PMCR2_EL1 sys_reg(3, 1, 15, 2, 0)
|
||||
#define SYS_IMP_APL_PMCR3_EL1 sys_reg(3, 1, 15, 3, 0)
|
||||
#define SYS_IMP_APL_PMCR4_EL1 sys_reg(3, 1, 15, 4, 0)
|
||||
|
||||
#define SYS_IMP_APL_PMESR0_EL1 sys_reg(3, 1, 15, 5, 0)
|
||||
#define PMESR0_EVT_CNT_2 GENMASK(7, 0)
|
||||
#define PMESR0_EVT_CNT_3 GENMASK(15, 8)
|
||||
#define PMESR0_EVT_CNT_4 GENMASK(23, 16)
|
||||
#define PMESR0_EVT_CNT_5 GENMASK(31, 24)
|
||||
|
||||
#define SYS_IMP_APL_PMESR1_EL1 sys_reg(3, 1, 15, 6, 0)
|
||||
#define PMESR1_EVT_CNT_6 GENMASK(7, 0)
|
||||
#define PMESR1_EVT_CNT_7 GENMASK(15, 8)
|
||||
#define PMESR1_EVT_CNT_8 GENMASK(23, 16)
|
||||
#define PMESR1_EVT_CNT_9 GENMASK(31, 24)
|
||||
|
||||
#define SYS_IMP_APL_PMSR_EL1 sys_reg(3, 1, 15, 13, 0)
|
||||
#define PMSR_OVERFLOW GENMASK(9, 0)
|
||||
|
||||
#endif /* __ASM_APPLE_M1_PMU_h */
|
|
@ -15,70 +15,70 @@
|
|||
/*
|
||||
* Common architectural and microarchitectural event numbers.
|
||||
*/
|
||||
#define ARMV8_PMUV3_PERFCTR_SW_INCR 0x00
|
||||
#define ARMV8_PMUV3_PERFCTR_L1I_CACHE_REFILL 0x01
|
||||
#define ARMV8_PMUV3_PERFCTR_L1I_TLB_REFILL 0x02
|
||||
#define ARMV8_PMUV3_PERFCTR_L1D_CACHE_REFILL 0x03
|
||||
#define ARMV8_PMUV3_PERFCTR_L1D_CACHE 0x04
|
||||
#define ARMV8_PMUV3_PERFCTR_L1D_TLB_REFILL 0x05
|
||||
#define ARMV8_PMUV3_PERFCTR_LD_RETIRED 0x06
|
||||
#define ARMV8_PMUV3_PERFCTR_ST_RETIRED 0x07
|
||||
#define ARMV8_PMUV3_PERFCTR_INST_RETIRED 0x08
|
||||
#define ARMV8_PMUV3_PERFCTR_EXC_TAKEN 0x09
|
||||
#define ARMV8_PMUV3_PERFCTR_EXC_RETURN 0x0A
|
||||
#define ARMV8_PMUV3_PERFCTR_CID_WRITE_RETIRED 0x0B
|
||||
#define ARMV8_PMUV3_PERFCTR_PC_WRITE_RETIRED 0x0C
|
||||
#define ARMV8_PMUV3_PERFCTR_BR_IMMED_RETIRED 0x0D
|
||||
#define ARMV8_PMUV3_PERFCTR_BR_RETURN_RETIRED 0x0E
|
||||
#define ARMV8_PMUV3_PERFCTR_UNALIGNED_LDST_RETIRED 0x0F
|
||||
#define ARMV8_PMUV3_PERFCTR_BR_MIS_PRED 0x10
|
||||
#define ARMV8_PMUV3_PERFCTR_CPU_CYCLES 0x11
|
||||
#define ARMV8_PMUV3_PERFCTR_BR_PRED 0x12
|
||||
#define ARMV8_PMUV3_PERFCTR_MEM_ACCESS 0x13
|
||||
#define ARMV8_PMUV3_PERFCTR_L1I_CACHE 0x14
|
||||
#define ARMV8_PMUV3_PERFCTR_L1D_CACHE_WB 0x15
|
||||
#define ARMV8_PMUV3_PERFCTR_L2D_CACHE 0x16
|
||||
#define ARMV8_PMUV3_PERFCTR_L2D_CACHE_REFILL 0x17
|
||||
#define ARMV8_PMUV3_PERFCTR_L2D_CACHE_WB 0x18
|
||||
#define ARMV8_PMUV3_PERFCTR_BUS_ACCESS 0x19
|
||||
#define ARMV8_PMUV3_PERFCTR_MEMORY_ERROR 0x1A
|
||||
#define ARMV8_PMUV3_PERFCTR_INST_SPEC 0x1B
|
||||
#define ARMV8_PMUV3_PERFCTR_TTBR_WRITE_RETIRED 0x1C
|
||||
#define ARMV8_PMUV3_PERFCTR_BUS_CYCLES 0x1D
|
||||
#define ARMV8_PMUV3_PERFCTR_CHAIN 0x1E
|
||||
#define ARMV8_PMUV3_PERFCTR_L1D_CACHE_ALLOCATE 0x1F
|
||||
#define ARMV8_PMUV3_PERFCTR_L2D_CACHE_ALLOCATE 0x20
|
||||
#define ARMV8_PMUV3_PERFCTR_BR_RETIRED 0x21
|
||||
#define ARMV8_PMUV3_PERFCTR_BR_MIS_PRED_RETIRED 0x22
|
||||
#define ARMV8_PMUV3_PERFCTR_STALL_FRONTEND 0x23
|
||||
#define ARMV8_PMUV3_PERFCTR_STALL_BACKEND 0x24
|
||||
#define ARMV8_PMUV3_PERFCTR_L1D_TLB 0x25
|
||||
#define ARMV8_PMUV3_PERFCTR_L1I_TLB 0x26
|
||||
#define ARMV8_PMUV3_PERFCTR_L2I_CACHE 0x27
|
||||
#define ARMV8_PMUV3_PERFCTR_L2I_CACHE_REFILL 0x28
|
||||
#define ARMV8_PMUV3_PERFCTR_L3D_CACHE_ALLOCATE 0x29
|
||||
#define ARMV8_PMUV3_PERFCTR_L3D_CACHE_REFILL 0x2A
|
||||
#define ARMV8_PMUV3_PERFCTR_L3D_CACHE 0x2B
|
||||
#define ARMV8_PMUV3_PERFCTR_L3D_CACHE_WB 0x2C
|
||||
#define ARMV8_PMUV3_PERFCTR_L2D_TLB_REFILL 0x2D
|
||||
#define ARMV8_PMUV3_PERFCTR_L2I_TLB_REFILL 0x2E
|
||||
#define ARMV8_PMUV3_PERFCTR_L2D_TLB 0x2F
|
||||
#define ARMV8_PMUV3_PERFCTR_L2I_TLB 0x30
|
||||
#define ARMV8_PMUV3_PERFCTR_REMOTE_ACCESS 0x31
|
||||
#define ARMV8_PMUV3_PERFCTR_LL_CACHE 0x32
|
||||
#define ARMV8_PMUV3_PERFCTR_LL_CACHE_MISS 0x33
|
||||
#define ARMV8_PMUV3_PERFCTR_DTLB_WALK 0x34
|
||||
#define ARMV8_PMUV3_PERFCTR_ITLB_WALK 0x35
|
||||
#define ARMV8_PMUV3_PERFCTR_LL_CACHE_RD 0x36
|
||||
#define ARMV8_PMUV3_PERFCTR_LL_CACHE_MISS_RD 0x37
|
||||
#define ARMV8_PMUV3_PERFCTR_REMOTE_ACCESS_RD 0x38
|
||||
#define ARMV8_PMUV3_PERFCTR_L1D_CACHE_LMISS_RD 0x39
|
||||
#define ARMV8_PMUV3_PERFCTR_OP_RETIRED 0x3A
|
||||
#define ARMV8_PMUV3_PERFCTR_OP_SPEC 0x3B
|
||||
#define ARMV8_PMUV3_PERFCTR_STALL 0x3C
|
||||
#define ARMV8_PMUV3_PERFCTR_STALL_SLOT_BACKEND 0x3D
|
||||
#define ARMV8_PMUV3_PERFCTR_STALL_SLOT_FRONTEND 0x3E
|
||||
#define ARMV8_PMUV3_PERFCTR_STALL_SLOT 0x3F
|
||||
#define ARMV8_PMUV3_PERFCTR_SW_INCR 0x0000
|
||||
#define ARMV8_PMUV3_PERFCTR_L1I_CACHE_REFILL 0x0001
|
||||
#define ARMV8_PMUV3_PERFCTR_L1I_TLB_REFILL 0x0002
|
||||
#define ARMV8_PMUV3_PERFCTR_L1D_CACHE_REFILL 0x0003
|
||||
#define ARMV8_PMUV3_PERFCTR_L1D_CACHE 0x0004
|
||||
#define ARMV8_PMUV3_PERFCTR_L1D_TLB_REFILL 0x0005
|
||||
#define ARMV8_PMUV3_PERFCTR_LD_RETIRED 0x0006
|
||||
#define ARMV8_PMUV3_PERFCTR_ST_RETIRED 0x0007
|
||||
#define ARMV8_PMUV3_PERFCTR_INST_RETIRED 0x0008
|
||||
#define ARMV8_PMUV3_PERFCTR_EXC_TAKEN 0x0009
|
||||
#define ARMV8_PMUV3_PERFCTR_EXC_RETURN 0x000A
|
||||
#define ARMV8_PMUV3_PERFCTR_CID_WRITE_RETIRED 0x000B
|
||||
#define ARMV8_PMUV3_PERFCTR_PC_WRITE_RETIRED 0x000C
|
||||
#define ARMV8_PMUV3_PERFCTR_BR_IMMED_RETIRED 0x000D
|
||||
#define ARMV8_PMUV3_PERFCTR_BR_RETURN_RETIRED 0x000E
|
||||
#define ARMV8_PMUV3_PERFCTR_UNALIGNED_LDST_RETIRED 0x000F
|
||||
#define ARMV8_PMUV3_PERFCTR_BR_MIS_PRED 0x0010
|
||||
#define ARMV8_PMUV3_PERFCTR_CPU_CYCLES 0x0011
|
||||
#define ARMV8_PMUV3_PERFCTR_BR_PRED 0x0012
|
||||
#define ARMV8_PMUV3_PERFCTR_MEM_ACCESS 0x0013
|
||||
#define ARMV8_PMUV3_PERFCTR_L1I_CACHE 0x0014
|
||||
#define ARMV8_PMUV3_PERFCTR_L1D_CACHE_WB 0x0015
|
||||
#define ARMV8_PMUV3_PERFCTR_L2D_CACHE 0x0016
|
||||
#define ARMV8_PMUV3_PERFCTR_L2D_CACHE_REFILL 0x0017
|
||||
#define ARMV8_PMUV3_PERFCTR_L2D_CACHE_WB 0x0018
|
||||
#define ARMV8_PMUV3_PERFCTR_BUS_ACCESS 0x0019
|
||||
#define ARMV8_PMUV3_PERFCTR_MEMORY_ERROR 0x001A
|
||||
#define ARMV8_PMUV3_PERFCTR_INST_SPEC 0x001B
|
||||
#define ARMV8_PMUV3_PERFCTR_TTBR_WRITE_RETIRED 0x001C
|
||||
#define ARMV8_PMUV3_PERFCTR_BUS_CYCLES 0x001D
|
||||
#define ARMV8_PMUV3_PERFCTR_CHAIN 0x001E
|
||||
#define ARMV8_PMUV3_PERFCTR_L1D_CACHE_ALLOCATE 0x001F
|
||||
#define ARMV8_PMUV3_PERFCTR_L2D_CACHE_ALLOCATE 0x0020
|
||||
#define ARMV8_PMUV3_PERFCTR_BR_RETIRED 0x0021
|
||||
#define ARMV8_PMUV3_PERFCTR_BR_MIS_PRED_RETIRED 0x0022
|
||||
#define ARMV8_PMUV3_PERFCTR_STALL_FRONTEND 0x0023
|
||||
#define ARMV8_PMUV3_PERFCTR_STALL_BACKEND 0x0024
|
||||
#define ARMV8_PMUV3_PERFCTR_L1D_TLB 0x0025
|
||||
#define ARMV8_PMUV3_PERFCTR_L1I_TLB 0x0026
|
||||
#define ARMV8_PMUV3_PERFCTR_L2I_CACHE 0x0027
|
||||
#define ARMV8_PMUV3_PERFCTR_L2I_CACHE_REFILL 0x0028
|
||||
#define ARMV8_PMUV3_PERFCTR_L3D_CACHE_ALLOCATE 0x0029
|
||||
#define ARMV8_PMUV3_PERFCTR_L3D_CACHE_REFILL 0x002A
|
||||
#define ARMV8_PMUV3_PERFCTR_L3D_CACHE 0x002B
|
||||
#define ARMV8_PMUV3_PERFCTR_L3D_CACHE_WB 0x002C
|
||||
#define ARMV8_PMUV3_PERFCTR_L2D_TLB_REFILL 0x002D
|
||||
#define ARMV8_PMUV3_PERFCTR_L2I_TLB_REFILL 0x002E
|
||||
#define ARMV8_PMUV3_PERFCTR_L2D_TLB 0x002F
|
||||
#define ARMV8_PMUV3_PERFCTR_L2I_TLB 0x0030
|
||||
#define ARMV8_PMUV3_PERFCTR_REMOTE_ACCESS 0x0031
|
||||
#define ARMV8_PMUV3_PERFCTR_LL_CACHE 0x0032
|
||||
#define ARMV8_PMUV3_PERFCTR_LL_CACHE_MISS 0x0033
|
||||
#define ARMV8_PMUV3_PERFCTR_DTLB_WALK 0x0034
|
||||
#define ARMV8_PMUV3_PERFCTR_ITLB_WALK 0x0035
|
||||
#define ARMV8_PMUV3_PERFCTR_LL_CACHE_RD 0x0036
|
||||
#define ARMV8_PMUV3_PERFCTR_LL_CACHE_MISS_RD 0x0037
|
||||
#define ARMV8_PMUV3_PERFCTR_REMOTE_ACCESS_RD 0x0038
|
||||
#define ARMV8_PMUV3_PERFCTR_L1D_CACHE_LMISS_RD 0x0039
|
||||
#define ARMV8_PMUV3_PERFCTR_OP_RETIRED 0x003A
|
||||
#define ARMV8_PMUV3_PERFCTR_OP_SPEC 0x003B
|
||||
#define ARMV8_PMUV3_PERFCTR_STALL 0x003C
|
||||
#define ARMV8_PMUV3_PERFCTR_STALL_SLOT_BACKEND 0x003D
|
||||
#define ARMV8_PMUV3_PERFCTR_STALL_SLOT_FRONTEND 0x003E
|
||||
#define ARMV8_PMUV3_PERFCTR_STALL_SLOT 0x003F
|
||||
|
||||
/* Statistical profiling extension microarchitectural events */
|
||||
#define ARMV8_SPE_PERFCTR_SAMPLE_POP 0x4000
|
||||
|
@ -96,6 +96,20 @@
|
|||
#define ARMV8_PMUV3_PERFCTR_L2I_CACHE_LMISS 0x400A
|
||||
#define ARMV8_PMUV3_PERFCTR_L3D_CACHE_LMISS_RD 0x400B
|
||||
|
||||
/* Trace buffer events */
|
||||
#define ARMV8_PMUV3_PERFCTR_TRB_WRAP 0x400C
|
||||
#define ARMV8_PMUV3_PERFCTR_TRB_TRIG 0x400E
|
||||
|
||||
/* Trace unit events */
|
||||
#define ARMV8_PMUV3_PERFCTR_TRCEXTOUT0 0x4010
|
||||
#define ARMV8_PMUV3_PERFCTR_TRCEXTOUT1 0x4011
|
||||
#define ARMV8_PMUV3_PERFCTR_TRCEXTOUT2 0x4012
|
||||
#define ARMV8_PMUV3_PERFCTR_TRCEXTOUT3 0x4013
|
||||
#define ARMV8_PMUV3_PERFCTR_CTI_TRIGOUT4 0x4018
|
||||
#define ARMV8_PMUV3_PERFCTR_CTI_TRIGOUT5 0x4019
|
||||
#define ARMV8_PMUV3_PERFCTR_CTI_TRIGOUT6 0x401A
|
||||
#define ARMV8_PMUV3_PERFCTR_CTI_TRIGOUT7 0x401B
|
||||
|
||||
/* additional latency from alignment events */
|
||||
#define ARMV8_PMUV3_PERFCTR_LDST_ALIGN_LAT 0x4020
|
||||
#define ARMV8_PMUV3_PERFCTR_LD_ALIGN_LAT 0x4021
|
||||
|
@ -107,91 +121,91 @@
|
|||
#define ARMV8_MTE_PERFCTR_MEM_ACCESS_CHECKED_WR 0x4026
|
||||
|
||||
/* ARMv8 recommended implementation defined event types */
|
||||
#define ARMV8_IMPDEF_PERFCTR_L1D_CACHE_RD 0x40
|
||||
#define ARMV8_IMPDEF_PERFCTR_L1D_CACHE_WR 0x41
|
||||
#define ARMV8_IMPDEF_PERFCTR_L1D_CACHE_REFILL_RD 0x42
|
||||
#define ARMV8_IMPDEF_PERFCTR_L1D_CACHE_REFILL_WR 0x43
|
||||
#define ARMV8_IMPDEF_PERFCTR_L1D_CACHE_REFILL_INNER 0x44
|
||||
#define ARMV8_IMPDEF_PERFCTR_L1D_CACHE_REFILL_OUTER 0x45
|
||||
#define ARMV8_IMPDEF_PERFCTR_L1D_CACHE_WB_VICTIM 0x46
|
||||
#define ARMV8_IMPDEF_PERFCTR_L1D_CACHE_WB_CLEAN 0x47
|
||||
#define ARMV8_IMPDEF_PERFCTR_L1D_CACHE_INVAL 0x48
|
||||
#define ARMV8_IMPDEF_PERFCTR_L1D_CACHE_RD 0x0040
|
||||
#define ARMV8_IMPDEF_PERFCTR_L1D_CACHE_WR 0x0041
|
||||
#define ARMV8_IMPDEF_PERFCTR_L1D_CACHE_REFILL_RD 0x0042
|
||||
#define ARMV8_IMPDEF_PERFCTR_L1D_CACHE_REFILL_WR 0x0043
|
||||
#define ARMV8_IMPDEF_PERFCTR_L1D_CACHE_REFILL_INNER 0x0044
|
||||
#define ARMV8_IMPDEF_PERFCTR_L1D_CACHE_REFILL_OUTER 0x0045
|
||||
#define ARMV8_IMPDEF_PERFCTR_L1D_CACHE_WB_VICTIM 0x0046
|
||||
#define ARMV8_IMPDEF_PERFCTR_L1D_CACHE_WB_CLEAN 0x0047
|
||||
#define ARMV8_IMPDEF_PERFCTR_L1D_CACHE_INVAL 0x0048
|
||||
|
||||
#define ARMV8_IMPDEF_PERFCTR_L1D_TLB_REFILL_RD 0x4C
|
||||
#define ARMV8_IMPDEF_PERFCTR_L1D_TLB_REFILL_WR 0x4D
|
||||
#define ARMV8_IMPDEF_PERFCTR_L1D_TLB_RD 0x4E
|
||||
#define ARMV8_IMPDEF_PERFCTR_L1D_TLB_WR 0x4F
|
||||
#define ARMV8_IMPDEF_PERFCTR_L2D_CACHE_RD 0x50
|
||||
#define ARMV8_IMPDEF_PERFCTR_L2D_CACHE_WR 0x51
|
||||
#define ARMV8_IMPDEF_PERFCTR_L2D_CACHE_REFILL_RD 0x52
|
||||
#define ARMV8_IMPDEF_PERFCTR_L2D_CACHE_REFILL_WR 0x53
|
||||
#define ARMV8_IMPDEF_PERFCTR_L1D_TLB_REFILL_RD 0x004C
|
||||
#define ARMV8_IMPDEF_PERFCTR_L1D_TLB_REFILL_WR 0x004D
|
||||
#define ARMV8_IMPDEF_PERFCTR_L1D_TLB_RD 0x004E
|
||||
#define ARMV8_IMPDEF_PERFCTR_L1D_TLB_WR 0x004F
|
||||
#define ARMV8_IMPDEF_PERFCTR_L2D_CACHE_RD 0x0050
|
||||
#define ARMV8_IMPDEF_PERFCTR_L2D_CACHE_WR 0x0051
|
||||
#define ARMV8_IMPDEF_PERFCTR_L2D_CACHE_REFILL_RD 0x0052
|
||||
#define ARMV8_IMPDEF_PERFCTR_L2D_CACHE_REFILL_WR 0x0053
|
||||
|
||||
#define ARMV8_IMPDEF_PERFCTR_L2D_CACHE_WB_VICTIM 0x56
|
||||
#define ARMV8_IMPDEF_PERFCTR_L2D_CACHE_WB_CLEAN 0x57
|
||||
#define ARMV8_IMPDEF_PERFCTR_L2D_CACHE_INVAL 0x58
|
||||
#define ARMV8_IMPDEF_PERFCTR_L2D_CACHE_WB_VICTIM 0x0056
|
||||
#define ARMV8_IMPDEF_PERFCTR_L2D_CACHE_WB_CLEAN 0x0057
|
||||
#define ARMV8_IMPDEF_PERFCTR_L2D_CACHE_INVAL 0x0058
|
||||
|
||||
#define ARMV8_IMPDEF_PERFCTR_L2D_TLB_REFILL_RD 0x5C
|
||||
#define ARMV8_IMPDEF_PERFCTR_L2D_TLB_REFILL_WR 0x5D
|
||||
#define ARMV8_IMPDEF_PERFCTR_L2D_TLB_RD 0x5E
|
||||
#define ARMV8_IMPDEF_PERFCTR_L2D_TLB_WR 0x5F
|
||||
#define ARMV8_IMPDEF_PERFCTR_BUS_ACCESS_RD 0x60
|
||||
#define ARMV8_IMPDEF_PERFCTR_BUS_ACCESS_WR 0x61
|
||||
#define ARMV8_IMPDEF_PERFCTR_BUS_ACCESS_SHARED 0x62
|
||||
#define ARMV8_IMPDEF_PERFCTR_BUS_ACCESS_NOT_SHARED 0x63
|
||||
#define ARMV8_IMPDEF_PERFCTR_BUS_ACCESS_NORMAL 0x64
|
||||
#define ARMV8_IMPDEF_PERFCTR_BUS_ACCESS_PERIPH 0x65
|
||||
#define ARMV8_IMPDEF_PERFCTR_MEM_ACCESS_RD 0x66
|
||||
#define ARMV8_IMPDEF_PERFCTR_MEM_ACCESS_WR 0x67
|
||||
#define ARMV8_IMPDEF_PERFCTR_UNALIGNED_LD_SPEC 0x68
|
||||
#define ARMV8_IMPDEF_PERFCTR_UNALIGNED_ST_SPEC 0x69
|
||||
#define ARMV8_IMPDEF_PERFCTR_UNALIGNED_LDST_SPEC 0x6A
|
||||
#define ARMV8_IMPDEF_PERFCTR_L2D_TLB_REFILL_RD 0x005C
|
||||
#define ARMV8_IMPDEF_PERFCTR_L2D_TLB_REFILL_WR 0x005D
|
||||
#define ARMV8_IMPDEF_PERFCTR_L2D_TLB_RD 0x005E
|
||||
#define ARMV8_IMPDEF_PERFCTR_L2D_TLB_WR 0x005F
|
||||
#define ARMV8_IMPDEF_PERFCTR_BUS_ACCESS_RD 0x0060
|
||||
#define ARMV8_IMPDEF_PERFCTR_BUS_ACCESS_WR 0x0061
|
||||
#define ARMV8_IMPDEF_PERFCTR_BUS_ACCESS_SHARED 0x0062
|
||||
#define ARMV8_IMPDEF_PERFCTR_BUS_ACCESS_NOT_SHARED 0x0063
|
||||
#define ARMV8_IMPDEF_PERFCTR_BUS_ACCESS_NORMAL 0x0064
|
||||
#define ARMV8_IMPDEF_PERFCTR_BUS_ACCESS_PERIPH 0x0065
|
||||
#define ARMV8_IMPDEF_PERFCTR_MEM_ACCESS_RD 0x0066
|
||||
#define ARMV8_IMPDEF_PERFCTR_MEM_ACCESS_WR 0x0067
|
||||
#define ARMV8_IMPDEF_PERFCTR_UNALIGNED_LD_SPEC 0x0068
|
||||
#define ARMV8_IMPDEF_PERFCTR_UNALIGNED_ST_SPEC 0x0069
|
||||
#define ARMV8_IMPDEF_PERFCTR_UNALIGNED_LDST_SPEC 0x006A
|
||||
|
||||
#define ARMV8_IMPDEF_PERFCTR_LDREX_SPEC 0x6C
|
||||
#define ARMV8_IMPDEF_PERFCTR_STREX_PASS_SPEC 0x6D
|
||||
#define ARMV8_IMPDEF_PERFCTR_STREX_FAIL_SPEC 0x6E
|
||||
#define ARMV8_IMPDEF_PERFCTR_STREX_SPEC 0x6F
|
||||
#define ARMV8_IMPDEF_PERFCTR_LD_SPEC 0x70
|
||||
#define ARMV8_IMPDEF_PERFCTR_ST_SPEC 0x71
|
||||
#define ARMV8_IMPDEF_PERFCTR_LDST_SPEC 0x72
|
||||
#define ARMV8_IMPDEF_PERFCTR_DP_SPEC 0x73
|
||||
#define ARMV8_IMPDEF_PERFCTR_ASE_SPEC 0x74
|
||||
#define ARMV8_IMPDEF_PERFCTR_VFP_SPEC 0x75
|
||||
#define ARMV8_IMPDEF_PERFCTR_PC_WRITE_SPEC 0x76
|
||||
#define ARMV8_IMPDEF_PERFCTR_CRYPTO_SPEC 0x77
|
||||
#define ARMV8_IMPDEF_PERFCTR_BR_IMMED_SPEC 0x78
|
||||
#define ARMV8_IMPDEF_PERFCTR_BR_RETURN_SPEC 0x79
|
||||
#define ARMV8_IMPDEF_PERFCTR_BR_INDIRECT_SPEC 0x7A
|
||||
#define ARMV8_IMPDEF_PERFCTR_LDREX_SPEC 0x006C
|
||||
#define ARMV8_IMPDEF_PERFCTR_STREX_PASS_SPEC 0x006D
|
||||
#define ARMV8_IMPDEF_PERFCTR_STREX_FAIL_SPEC 0x006E
|
||||
#define ARMV8_IMPDEF_PERFCTR_STREX_SPEC 0x006F
|
||||
#define ARMV8_IMPDEF_PERFCTR_LD_SPEC 0x0070
|
||||
#define ARMV8_IMPDEF_PERFCTR_ST_SPEC 0x0071
|
||||
#define ARMV8_IMPDEF_PERFCTR_LDST_SPEC 0x0072
|
||||
#define ARMV8_IMPDEF_PERFCTR_DP_SPEC 0x0073
|
||||
#define ARMV8_IMPDEF_PERFCTR_ASE_SPEC 0x0074
|
||||
#define ARMV8_IMPDEF_PERFCTR_VFP_SPEC 0x0075
|
||||
#define ARMV8_IMPDEF_PERFCTR_PC_WRITE_SPEC 0x0076
|
||||
#define ARMV8_IMPDEF_PERFCTR_CRYPTO_SPEC 0x0077
|
||||
#define ARMV8_IMPDEF_PERFCTR_BR_IMMED_SPEC 0x0078
|
||||
#define ARMV8_IMPDEF_PERFCTR_BR_RETURN_SPEC 0x0079
|
||||
#define ARMV8_IMPDEF_PERFCTR_BR_INDIRECT_SPEC 0x007A
|
||||
|
||||
#define ARMV8_IMPDEF_PERFCTR_ISB_SPEC 0x7C
|
||||
#define ARMV8_IMPDEF_PERFCTR_DSB_SPEC 0x7D
|
||||
#define ARMV8_IMPDEF_PERFCTR_DMB_SPEC 0x7E
|
||||
#define ARMV8_IMPDEF_PERFCTR_ISB_SPEC 0x007C
|
||||
#define ARMV8_IMPDEF_PERFCTR_DSB_SPEC 0x007D
|
||||
#define ARMV8_IMPDEF_PERFCTR_DMB_SPEC 0x007E
|
||||
|
||||
#define ARMV8_IMPDEF_PERFCTR_EXC_UNDEF 0x81
|
||||
#define ARMV8_IMPDEF_PERFCTR_EXC_SVC 0x82
|
||||
#define ARMV8_IMPDEF_PERFCTR_EXC_PABORT 0x83
|
||||
#define ARMV8_IMPDEF_PERFCTR_EXC_DABORT 0x84
|
||||
#define ARMV8_IMPDEF_PERFCTR_EXC_UNDEF 0x0081
|
||||
#define ARMV8_IMPDEF_PERFCTR_EXC_SVC 0x0082
|
||||
#define ARMV8_IMPDEF_PERFCTR_EXC_PABORT 0x0083
|
||||
#define ARMV8_IMPDEF_PERFCTR_EXC_DABORT 0x0084
|
||||
|
||||
#define ARMV8_IMPDEF_PERFCTR_EXC_IRQ 0x86
|
||||
#define ARMV8_IMPDEF_PERFCTR_EXC_FIQ 0x87
|
||||
#define ARMV8_IMPDEF_PERFCTR_EXC_SMC 0x88
|
||||
#define ARMV8_IMPDEF_PERFCTR_EXC_IRQ 0x0086
|
||||
#define ARMV8_IMPDEF_PERFCTR_EXC_FIQ 0x0087
|
||||
#define ARMV8_IMPDEF_PERFCTR_EXC_SMC 0x0088
|
||||
|
||||
#define ARMV8_IMPDEF_PERFCTR_EXC_HVC 0x8A
|
||||
#define ARMV8_IMPDEF_PERFCTR_EXC_TRAP_PABORT 0x8B
|
||||
#define ARMV8_IMPDEF_PERFCTR_EXC_TRAP_DABORT 0x8C
|
||||
#define ARMV8_IMPDEF_PERFCTR_EXC_TRAP_OTHER 0x8D
|
||||
#define ARMV8_IMPDEF_PERFCTR_EXC_TRAP_IRQ 0x8E
|
||||
#define ARMV8_IMPDEF_PERFCTR_EXC_TRAP_FIQ 0x8F
|
||||
#define ARMV8_IMPDEF_PERFCTR_RC_LD_SPEC 0x90
|
||||
#define ARMV8_IMPDEF_PERFCTR_RC_ST_SPEC 0x91
|
||||
#define ARMV8_IMPDEF_PERFCTR_EXC_HVC 0x008A
|
||||
#define ARMV8_IMPDEF_PERFCTR_EXC_TRAP_PABORT 0x008B
|
||||
#define ARMV8_IMPDEF_PERFCTR_EXC_TRAP_DABORT 0x008C
|
||||
#define ARMV8_IMPDEF_PERFCTR_EXC_TRAP_OTHER 0x008D
|
||||
#define ARMV8_IMPDEF_PERFCTR_EXC_TRAP_IRQ 0x008E
|
||||
#define ARMV8_IMPDEF_PERFCTR_EXC_TRAP_FIQ 0x008F
|
||||
#define ARMV8_IMPDEF_PERFCTR_RC_LD_SPEC 0x0090
|
||||
#define ARMV8_IMPDEF_PERFCTR_RC_ST_SPEC 0x0091
|
||||
|
||||
#define ARMV8_IMPDEF_PERFCTR_L3D_CACHE_RD 0xA0
|
||||
#define ARMV8_IMPDEF_PERFCTR_L3D_CACHE_WR 0xA1
|
||||
#define ARMV8_IMPDEF_PERFCTR_L3D_CACHE_REFILL_RD 0xA2
|
||||
#define ARMV8_IMPDEF_PERFCTR_L3D_CACHE_REFILL_WR 0xA3
|
||||
#define ARMV8_IMPDEF_PERFCTR_L3D_CACHE_RD 0x00A0
|
||||
#define ARMV8_IMPDEF_PERFCTR_L3D_CACHE_WR 0x00A1
|
||||
#define ARMV8_IMPDEF_PERFCTR_L3D_CACHE_REFILL_RD 0x00A2
|
||||
#define ARMV8_IMPDEF_PERFCTR_L3D_CACHE_REFILL_WR 0x00A3
|
||||
|
||||
#define ARMV8_IMPDEF_PERFCTR_L3D_CACHE_WB_VICTIM 0xA6
|
||||
#define ARMV8_IMPDEF_PERFCTR_L3D_CACHE_WB_CLEAN 0xA7
|
||||
#define ARMV8_IMPDEF_PERFCTR_L3D_CACHE_INVAL 0xA8
|
||||
#define ARMV8_IMPDEF_PERFCTR_L3D_CACHE_WB_VICTIM 0x00A6
|
||||
#define ARMV8_IMPDEF_PERFCTR_L3D_CACHE_WB_CLEAN 0x00A7
|
||||
#define ARMV8_IMPDEF_PERFCTR_L3D_CACHE_INVAL 0x00A8
|
||||
|
||||
/*
|
||||
* Per-CPU PMCR: config reg
|
||||
|
|
|
@ -242,6 +242,16 @@ static struct attribute *armv8_pmuv3_event_attrs[] = {
|
|||
ARMV8_EVENT_ATTR(l2d_cache_lmiss_rd, ARMV8_PMUV3_PERFCTR_L2D_CACHE_LMISS_RD),
|
||||
ARMV8_EVENT_ATTR(l2i_cache_lmiss, ARMV8_PMUV3_PERFCTR_L2I_CACHE_LMISS),
|
||||
ARMV8_EVENT_ATTR(l3d_cache_lmiss_rd, ARMV8_PMUV3_PERFCTR_L3D_CACHE_LMISS_RD),
|
||||
ARMV8_EVENT_ATTR(trb_wrap, ARMV8_PMUV3_PERFCTR_TRB_WRAP),
|
||||
ARMV8_EVENT_ATTR(trb_trig, ARMV8_PMUV3_PERFCTR_TRB_TRIG),
|
||||
ARMV8_EVENT_ATTR(trcextout0, ARMV8_PMUV3_PERFCTR_TRCEXTOUT0),
|
||||
ARMV8_EVENT_ATTR(trcextout1, ARMV8_PMUV3_PERFCTR_TRCEXTOUT1),
|
||||
ARMV8_EVENT_ATTR(trcextout2, ARMV8_PMUV3_PERFCTR_TRCEXTOUT2),
|
||||
ARMV8_EVENT_ATTR(trcextout3, ARMV8_PMUV3_PERFCTR_TRCEXTOUT3),
|
||||
ARMV8_EVENT_ATTR(cti_trigout4, ARMV8_PMUV3_PERFCTR_CTI_TRIGOUT4),
|
||||
ARMV8_EVENT_ATTR(cti_trigout5, ARMV8_PMUV3_PERFCTR_CTI_TRIGOUT5),
|
||||
ARMV8_EVENT_ATTR(cti_trigout6, ARMV8_PMUV3_PERFCTR_CTI_TRIGOUT6),
|
||||
ARMV8_EVENT_ATTR(cti_trigout7, ARMV8_PMUV3_PERFCTR_CTI_TRIGOUT7),
|
||||
ARMV8_EVENT_ATTR(ldst_align_lat, ARMV8_PMUV3_PERFCTR_LDST_ALIGN_LAT),
|
||||
ARMV8_EVENT_ATTR(ld_align_lat, ARMV8_PMUV3_PERFCTR_LD_ALIGN_LAT),
|
||||
ARMV8_EVENT_ATTR(st_align_lat, ARMV8_PMUV3_PERFCTR_ST_ALIGN_LAT),
|
||||
|
|
|
@ -55,6 +55,7 @@
|
|||
#include <linux/limits.h>
|
||||
#include <linux/of_address.h>
|
||||
#include <linux/slab.h>
|
||||
#include <asm/apple_m1_pmu.h>
|
||||
#include <asm/exception.h>
|
||||
#include <asm/sysreg.h>
|
||||
#include <asm/virt.h>
|
||||
|
@ -109,16 +110,6 @@
|
|||
* Note: sysreg-based IPIs are not supported yet.
|
||||
*/
|
||||
|
||||
/* Core PMC control register */
|
||||
#define SYS_IMP_APL_PMCR0_EL1 sys_reg(3, 1, 15, 0, 0)
|
||||
#define PMCR0_IMODE GENMASK(10, 8)
|
||||
#define PMCR0_IMODE_OFF 0
|
||||
#define PMCR0_IMODE_PMI 1
|
||||
#define PMCR0_IMODE_AIC 2
|
||||
#define PMCR0_IMODE_HALT 3
|
||||
#define PMCR0_IMODE_FIQ 4
|
||||
#define PMCR0_IACT BIT(11)
|
||||
|
||||
/* IPI request registers */
|
||||
#define SYS_IMP_APL_IPI_RR_LOCAL_EL1 sys_reg(3, 5, 15, 0, 0)
|
||||
#define SYS_IMP_APL_IPI_RR_GLOBAL_EL1 sys_reg(3, 5, 15, 0, 1)
|
||||
|
@ -155,7 +146,7 @@
|
|||
#define SYS_IMP_APL_UPMSR_EL1 sys_reg(3, 7, 15, 6, 4)
|
||||
#define UPMSR_IACT BIT(0)
|
||||
|
||||
#define AIC_NR_FIQ 4
|
||||
#define AIC_NR_FIQ 6
|
||||
#define AIC_NR_SWIPI 32
|
||||
|
||||
/*
|
||||
|
@ -177,6 +168,9 @@ struct aic_irq_chip {
|
|||
void __iomem *base;
|
||||
struct irq_domain *hw_domain;
|
||||
struct irq_domain *ipi_domain;
|
||||
struct {
|
||||
cpumask_t aff;
|
||||
} *fiq_aff[AIC_NR_FIQ];
|
||||
int nr_hw;
|
||||
};
|
||||
|
||||
|
@ -412,16 +406,15 @@ static void __exception_irq_entry aic_handle_fiq(struct pt_regs *regs)
|
|||
aic_irqc->nr_hw + AIC_TMR_EL02_VIRT);
|
||||
}
|
||||
|
||||
if ((read_sysreg_s(SYS_IMP_APL_PMCR0_EL1) & (PMCR0_IMODE | PMCR0_IACT)) ==
|
||||
(FIELD_PREP(PMCR0_IMODE, PMCR0_IMODE_FIQ) | PMCR0_IACT)) {
|
||||
/*
|
||||
* Not supported yet, let's figure out how to handle this when
|
||||
* we implement these proprietary performance counters. For now,
|
||||
* just mask it and move on.
|
||||
*/
|
||||
pr_err_ratelimited("PMC FIQ fired. Masking.\n");
|
||||
sysreg_clear_set_s(SYS_IMP_APL_PMCR0_EL1, PMCR0_IMODE | PMCR0_IACT,
|
||||
FIELD_PREP(PMCR0_IMODE, PMCR0_IMODE_OFF));
|
||||
if (read_sysreg_s(SYS_IMP_APL_PMCR0_EL1) & PMCR0_IACT) {
|
||||
int irq;
|
||||
if (cpumask_test_cpu(smp_processor_id(),
|
||||
&aic_irqc->fiq_aff[AIC_CPU_PMU_P]->aff))
|
||||
irq = AIC_CPU_PMU_P;
|
||||
else
|
||||
irq = AIC_CPU_PMU_E;
|
||||
generic_handle_domain_irq(aic_irqc->hw_domain,
|
||||
aic_irqc->nr_hw + irq);
|
||||
}
|
||||
|
||||
if (FIELD_GET(UPMCR0_IMODE, read_sysreg_s(SYS_IMP_APL_UPMCR0_EL1)) == UPMCR0_IMODE_FIQ &&
|
||||
|
@ -461,7 +454,18 @@ static int aic_irq_domain_map(struct irq_domain *id, unsigned int irq,
|
|||
handle_fasteoi_irq, NULL, NULL);
|
||||
irqd_set_single_target(irq_desc_get_irq_data(irq_to_desc(irq)));
|
||||
} else {
|
||||
irq_set_percpu_devid(irq);
|
||||
int fiq = hw - ic->nr_hw;
|
||||
|
||||
switch (fiq) {
|
||||
case AIC_CPU_PMU_P:
|
||||
case AIC_CPU_PMU_E:
|
||||
irq_set_percpu_devid_partition(irq, &ic->fiq_aff[fiq]->aff);
|
||||
break;
|
||||
default:
|
||||
irq_set_percpu_devid(irq);
|
||||
break;
|
||||
}
|
||||
|
||||
irq_domain_set_info(id, irq, hw, &fiq_chip, id->host_data,
|
||||
handle_percpu_devid_irq, NULL, NULL);
|
||||
}
|
||||
|
@ -793,12 +797,50 @@ static struct gic_kvm_info vgic_info __initdata = {
|
|||
.no_hw_deactivation = true,
|
||||
};
|
||||
|
||||
static void build_fiq_affinity(struct aic_irq_chip *ic, struct device_node *aff)
|
||||
{
|
||||
int i, n;
|
||||
u32 fiq;
|
||||
|
||||
if (of_property_read_u32(aff, "apple,fiq-index", &fiq) ||
|
||||
WARN_ON(fiq >= AIC_NR_FIQ) || ic->fiq_aff[fiq])
|
||||
return;
|
||||
|
||||
n = of_property_count_elems_of_size(aff, "cpus", sizeof(u32));
|
||||
if (WARN_ON(n < 0))
|
||||
return;
|
||||
|
||||
ic->fiq_aff[fiq] = kzalloc(sizeof(ic->fiq_aff[fiq]), GFP_KERNEL);
|
||||
if (!ic->fiq_aff[fiq])
|
||||
return;
|
||||
|
||||
for (i = 0; i < n; i++) {
|
||||
struct device_node *cpu_node;
|
||||
u32 cpu_phandle;
|
||||
int cpu;
|
||||
|
||||
if (of_property_read_u32_index(aff, "cpus", i, &cpu_phandle))
|
||||
continue;
|
||||
|
||||
cpu_node = of_find_node_by_phandle(cpu_phandle);
|
||||
if (WARN_ON(!cpu_node))
|
||||
continue;
|
||||
|
||||
cpu = of_cpu_node_to_id(cpu_node);
|
||||
if (WARN_ON(cpu < 0))
|
||||
continue;
|
||||
|
||||
cpumask_set_cpu(cpu, &ic->fiq_aff[fiq]->aff);
|
||||
}
|
||||
}
|
||||
|
||||
static int __init aic_of_ic_init(struct device_node *node, struct device_node *parent)
|
||||
{
|
||||
int i;
|
||||
void __iomem *regs;
|
||||
u32 info;
|
||||
struct aic_irq_chip *irqc;
|
||||
struct device_node *affs;
|
||||
|
||||
regs = of_iomap(node, 0);
|
||||
if (WARN_ON(!regs))
|
||||
|
@ -832,6 +874,14 @@ static int __init aic_of_ic_init(struct device_node *node, struct device_node *p
|
|||
return -ENODEV;
|
||||
}
|
||||
|
||||
affs = of_get_child_by_name(node, "affinities");
|
||||
if (affs) {
|
||||
struct device_node *chld;
|
||||
|
||||
for_each_child_of_node(affs, chld)
|
||||
build_fiq_affinity(irqc, chld);
|
||||
}
|
||||
|
||||
set_handle_irq(aic_handle_irq);
|
||||
set_handle_fiq(aic_handle_fiq);
|
||||
|
||||
|
|
|
@ -141,11 +141,25 @@ config ARM_DMC620_PMU
|
|||
|
||||
config MARVELL_CN10K_TAD_PMU
|
||||
tristate "Marvell CN10K LLC-TAD PMU"
|
||||
depends on ARM64 || (COMPILE_TEST && 64BIT)
|
||||
depends on ARCH_THUNDER || (COMPILE_TEST && 64BIT)
|
||||
help
|
||||
Provides support for Last-Level cache Tag-and-data Units (LLC-TAD)
|
||||
performance monitors on CN10K family silicons.
|
||||
|
||||
config APPLE_M1_CPU_PMU
|
||||
bool "Apple M1 CPU PMU support"
|
||||
depends on ARM_PMU && ARCH_APPLE
|
||||
help
|
||||
Provides support for the non-architectural CPU PMUs present on
|
||||
the Apple M1 SoCs and derivatives.
|
||||
|
||||
source "drivers/perf/hisilicon/Kconfig"
|
||||
|
||||
config MARVELL_CN10K_DDR_PMU
|
||||
tristate "Enable MARVELL CN10K DRAM Subsystem(DSS) PMU Support"
|
||||
depends on ARM64 || (COMPILE_TEST && 64BIT)
|
||||
help
|
||||
Enable perf support for Marvell DDR Performance monitoring
|
||||
event on CN10K platform.
|
||||
|
||||
endmenu
|
||||
|
|
|
@ -15,3 +15,5 @@ obj-$(CONFIG_XGENE_PMU) += xgene_pmu.o
|
|||
obj-$(CONFIG_ARM_SPE_PMU) += arm_spe_pmu.o
|
||||
obj-$(CONFIG_ARM_DMC620_PMU) += arm_dmc620_pmu.o
|
||||
obj-$(CONFIG_MARVELL_CN10K_TAD_PMU) += marvell_cn10k_tad_pmu.o
|
||||
obj-$(CONFIG_MARVELL_CN10K_DDR_PMU) += marvell_cn10k_ddr_pmu.o
|
||||
obj-$(CONFIG_APPLE_M1_CPU_PMU) += apple_m1_cpu_pmu.o
|
||||
|
|
584
drivers/perf/apple_m1_cpu_pmu.c
Normal file
584
drivers/perf/apple_m1_cpu_pmu.c
Normal file
|
@ -0,0 +1,584 @@
|
|||
// SPDX-License-Identifier: GPL-2.0
|
||||
/*
|
||||
* CPU PMU driver for the Apple M1 and derivatives
|
||||
*
|
||||
* Copyright (C) 2021 Google LLC
|
||||
*
|
||||
* Author: Marc Zyngier <maz@kernel.org>
|
||||
*
|
||||
* Most of the information used in this driver was provided by the
|
||||
* Asahi Linux project. The rest was experimentally discovered.
|
||||
*/
|
||||
|
||||
#include <linux/of.h>
|
||||
#include <linux/perf/arm_pmu.h>
|
||||
#include <linux/platform_device.h>
|
||||
|
||||
#include <asm/apple_m1_pmu.h>
|
||||
#include <asm/irq_regs.h>
|
||||
#include <asm/perf_event.h>
|
||||
|
||||
#define M1_PMU_NR_COUNTERS 10
|
||||
|
||||
#define M1_PMU_CFG_EVENT GENMASK(7, 0)
|
||||
|
||||
#define ANY_BUT_0_1 GENMASK(9, 2)
|
||||
#define ONLY_2_TO_7 GENMASK(7, 2)
|
||||
#define ONLY_2_4_6 (BIT(2) | BIT(4) | BIT(6))
|
||||
#define ONLY_5_6_7 (BIT(5) | BIT(6) | BIT(7))
|
||||
|
||||
/*
|
||||
* Description of the events we actually know about, as well as those with
|
||||
* a specific counter affinity. Yes, this is a grand total of two known
|
||||
* counters, and the rest is anybody's guess.
|
||||
*
|
||||
* Not all counters can count all events. Counters #0 and #1 are wired to
|
||||
* count cycles and instructions respectively, and some events have
|
||||
* bizarre mappings (every other counter, or even *one* counter). These
|
||||
* restrictions equally apply to both P and E cores.
|
||||
*
|
||||
* It is worth noting that the PMUs attached to P and E cores are likely
|
||||
* to be different because the underlying uarches are different. At the
|
||||
* moment, we don't really need to distinguish between the two because we
|
||||
* know next to nothing about the events themselves, and we already have
|
||||
* per cpu-type PMU abstractions.
|
||||
*
|
||||
* If we eventually find out that the events are different across
|
||||
* implementations, we'll have to introduce per cpu-type tables.
|
||||
*/
|
||||
enum m1_pmu_events {
|
||||
M1_PMU_PERFCTR_UNKNOWN_01 = 0x01,
|
||||
M1_PMU_PERFCTR_CPU_CYCLES = 0x02,
|
||||
M1_PMU_PERFCTR_INSTRUCTIONS = 0x8c,
|
||||
M1_PMU_PERFCTR_UNKNOWN_8d = 0x8d,
|
||||
M1_PMU_PERFCTR_UNKNOWN_8e = 0x8e,
|
||||
M1_PMU_PERFCTR_UNKNOWN_8f = 0x8f,
|
||||
M1_PMU_PERFCTR_UNKNOWN_90 = 0x90,
|
||||
M1_PMU_PERFCTR_UNKNOWN_93 = 0x93,
|
||||
M1_PMU_PERFCTR_UNKNOWN_94 = 0x94,
|
||||
M1_PMU_PERFCTR_UNKNOWN_95 = 0x95,
|
||||
M1_PMU_PERFCTR_UNKNOWN_96 = 0x96,
|
||||
M1_PMU_PERFCTR_UNKNOWN_97 = 0x97,
|
||||
M1_PMU_PERFCTR_UNKNOWN_98 = 0x98,
|
||||
M1_PMU_PERFCTR_UNKNOWN_99 = 0x99,
|
||||
M1_PMU_PERFCTR_UNKNOWN_9a = 0x9a,
|
||||
M1_PMU_PERFCTR_UNKNOWN_9b = 0x9b,
|
||||
M1_PMU_PERFCTR_UNKNOWN_9c = 0x9c,
|
||||
M1_PMU_PERFCTR_UNKNOWN_9f = 0x9f,
|
||||
M1_PMU_PERFCTR_UNKNOWN_bf = 0xbf,
|
||||
M1_PMU_PERFCTR_UNKNOWN_c0 = 0xc0,
|
||||
M1_PMU_PERFCTR_UNKNOWN_c1 = 0xc1,
|
||||
M1_PMU_PERFCTR_UNKNOWN_c4 = 0xc4,
|
||||
M1_PMU_PERFCTR_UNKNOWN_c5 = 0xc5,
|
||||
M1_PMU_PERFCTR_UNKNOWN_c6 = 0xc6,
|
||||
M1_PMU_PERFCTR_UNKNOWN_c8 = 0xc8,
|
||||
M1_PMU_PERFCTR_UNKNOWN_ca = 0xca,
|
||||
M1_PMU_PERFCTR_UNKNOWN_cb = 0xcb,
|
||||
M1_PMU_PERFCTR_UNKNOWN_f5 = 0xf5,
|
||||
M1_PMU_PERFCTR_UNKNOWN_f6 = 0xf6,
|
||||
M1_PMU_PERFCTR_UNKNOWN_f7 = 0xf7,
|
||||
M1_PMU_PERFCTR_UNKNOWN_f8 = 0xf8,
|
||||
M1_PMU_PERFCTR_UNKNOWN_fd = 0xfd,
|
||||
M1_PMU_PERFCTR_LAST = M1_PMU_CFG_EVENT,
|
||||
|
||||
/*
|
||||
* From this point onwards, these are not actual HW events,
|
||||
* but attributes that get stored in hw->config_base.
|
||||
*/
|
||||
M1_PMU_CFG_COUNT_USER = BIT(8),
|
||||
M1_PMU_CFG_COUNT_KERNEL = BIT(9),
|
||||
};
|
||||
|
||||
/*
|
||||
* Per-event affinity table. Most events can be installed on counter
|
||||
* 2-9, but there are a number of exceptions. Note that this table
|
||||
* has been created experimentally, and I wouldn't be surprised if more
|
||||
* counters had strange affinities.
|
||||
*/
|
||||
static const u16 m1_pmu_event_affinity[M1_PMU_PERFCTR_LAST + 1] = {
|
||||
[0 ... M1_PMU_PERFCTR_LAST] = ANY_BUT_0_1,
|
||||
[M1_PMU_PERFCTR_UNKNOWN_01] = BIT(7),
|
||||
[M1_PMU_PERFCTR_CPU_CYCLES] = ANY_BUT_0_1 | BIT(0),
|
||||
[M1_PMU_PERFCTR_INSTRUCTIONS] = BIT(7) | BIT(1),
|
||||
[M1_PMU_PERFCTR_UNKNOWN_8d] = ONLY_5_6_7,
|
||||
[M1_PMU_PERFCTR_UNKNOWN_8e] = ONLY_5_6_7,
|
||||
[M1_PMU_PERFCTR_UNKNOWN_8f] = ONLY_5_6_7,
|
||||
[M1_PMU_PERFCTR_UNKNOWN_90] = ONLY_5_6_7,
|
||||
[M1_PMU_PERFCTR_UNKNOWN_93] = ONLY_5_6_7,
|
||||
[M1_PMU_PERFCTR_UNKNOWN_94] = ONLY_5_6_7,
|
||||
[M1_PMU_PERFCTR_UNKNOWN_95] = ONLY_5_6_7,
|
||||
[M1_PMU_PERFCTR_UNKNOWN_96] = ONLY_5_6_7,
|
||||
[M1_PMU_PERFCTR_UNKNOWN_97] = BIT(7),
|
||||
[M1_PMU_PERFCTR_UNKNOWN_98] = ONLY_5_6_7,
|
||||
[M1_PMU_PERFCTR_UNKNOWN_99] = ONLY_5_6_7,
|
||||
[M1_PMU_PERFCTR_UNKNOWN_9a] = BIT(7),
|
||||
[M1_PMU_PERFCTR_UNKNOWN_9b] = ONLY_5_6_7,
|
||||
[M1_PMU_PERFCTR_UNKNOWN_9c] = ONLY_5_6_7,
|
||||
[M1_PMU_PERFCTR_UNKNOWN_9f] = BIT(7),
|
||||
[M1_PMU_PERFCTR_UNKNOWN_bf] = ONLY_5_6_7,
|
||||
[M1_PMU_PERFCTR_UNKNOWN_c0] = ONLY_5_6_7,
|
||||
[M1_PMU_PERFCTR_UNKNOWN_c1] = ONLY_5_6_7,
|
||||
[M1_PMU_PERFCTR_UNKNOWN_c4] = ONLY_5_6_7,
|
||||
[M1_PMU_PERFCTR_UNKNOWN_c5] = ONLY_5_6_7,
|
||||
[M1_PMU_PERFCTR_UNKNOWN_c6] = ONLY_5_6_7,
|
||||
[M1_PMU_PERFCTR_UNKNOWN_c8] = ONLY_5_6_7,
|
||||
[M1_PMU_PERFCTR_UNKNOWN_ca] = ONLY_5_6_7,
|
||||
[M1_PMU_PERFCTR_UNKNOWN_cb] = ONLY_5_6_7,
|
||||
[M1_PMU_PERFCTR_UNKNOWN_f5] = ONLY_2_4_6,
|
||||
[M1_PMU_PERFCTR_UNKNOWN_f6] = ONLY_2_4_6,
|
||||
[M1_PMU_PERFCTR_UNKNOWN_f7] = ONLY_2_4_6,
|
||||
[M1_PMU_PERFCTR_UNKNOWN_f8] = ONLY_2_TO_7,
|
||||
[M1_PMU_PERFCTR_UNKNOWN_fd] = ONLY_2_4_6,
|
||||
};
|
||||
|
||||
static const unsigned m1_pmu_perf_map[PERF_COUNT_HW_MAX] = {
|
||||
PERF_MAP_ALL_UNSUPPORTED,
|
||||
[PERF_COUNT_HW_CPU_CYCLES] = M1_PMU_PERFCTR_CPU_CYCLES,
|
||||
[PERF_COUNT_HW_INSTRUCTIONS] = M1_PMU_PERFCTR_INSTRUCTIONS,
|
||||
/* No idea about the rest yet */
|
||||
};
|
||||
|
||||
/* sysfs definitions */
|
||||
static ssize_t m1_pmu_events_sysfs_show(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
char *page)
|
||||
{
|
||||
struct perf_pmu_events_attr *pmu_attr;
|
||||
|
||||
pmu_attr = container_of(attr, struct perf_pmu_events_attr, attr);
|
||||
|
||||
return sprintf(page, "event=0x%04llx\n", pmu_attr->id);
|
||||
}
|
||||
|
||||
#define M1_PMU_EVENT_ATTR(name, config) \
|
||||
PMU_EVENT_ATTR_ID(name, m1_pmu_events_sysfs_show, config)
|
||||
|
||||
static struct attribute *m1_pmu_event_attrs[] = {
|
||||
M1_PMU_EVENT_ATTR(cycles, M1_PMU_PERFCTR_CPU_CYCLES),
|
||||
M1_PMU_EVENT_ATTR(instructions, M1_PMU_PERFCTR_INSTRUCTIONS),
|
||||
NULL,
|
||||
};
|
||||
|
||||
static const struct attribute_group m1_pmu_events_attr_group = {
|
||||
.name = "events",
|
||||
.attrs = m1_pmu_event_attrs,
|
||||
};
|
||||
|
||||
PMU_FORMAT_ATTR(event, "config:0-7");
|
||||
|
||||
static struct attribute *m1_pmu_format_attrs[] = {
|
||||
&format_attr_event.attr,
|
||||
NULL,
|
||||
};
|
||||
|
||||
static const struct attribute_group m1_pmu_format_attr_group = {
|
||||
.name = "format",
|
||||
.attrs = m1_pmu_format_attrs,
|
||||
};
|
||||
|
||||
/* Low level accessors. No synchronisation. */
|
||||
#define PMU_READ_COUNTER(_idx) \
|
||||
case _idx: return read_sysreg_s(SYS_IMP_APL_PMC## _idx ##_EL1)
|
||||
|
||||
#define PMU_WRITE_COUNTER(_val, _idx) \
|
||||
case _idx: \
|
||||
write_sysreg_s(_val, SYS_IMP_APL_PMC## _idx ##_EL1); \
|
||||
return
|
||||
|
||||
static u64 m1_pmu_read_hw_counter(unsigned int index)
|
||||
{
|
||||
switch (index) {
|
||||
PMU_READ_COUNTER(0);
|
||||
PMU_READ_COUNTER(1);
|
||||
PMU_READ_COUNTER(2);
|
||||
PMU_READ_COUNTER(3);
|
||||
PMU_READ_COUNTER(4);
|
||||
PMU_READ_COUNTER(5);
|
||||
PMU_READ_COUNTER(6);
|
||||
PMU_READ_COUNTER(7);
|
||||
PMU_READ_COUNTER(8);
|
||||
PMU_READ_COUNTER(9);
|
||||
}
|
||||
|
||||
BUG();
|
||||
}
|
||||
|
||||
static void m1_pmu_write_hw_counter(u64 val, unsigned int index)
|
||||
{
|
||||
switch (index) {
|
||||
PMU_WRITE_COUNTER(val, 0);
|
||||
PMU_WRITE_COUNTER(val, 1);
|
||||
PMU_WRITE_COUNTER(val, 2);
|
||||
PMU_WRITE_COUNTER(val, 3);
|
||||
PMU_WRITE_COUNTER(val, 4);
|
||||
PMU_WRITE_COUNTER(val, 5);
|
||||
PMU_WRITE_COUNTER(val, 6);
|
||||
PMU_WRITE_COUNTER(val, 7);
|
||||
PMU_WRITE_COUNTER(val, 8);
|
||||
PMU_WRITE_COUNTER(val, 9);
|
||||
}
|
||||
|
||||
BUG();
|
||||
}
|
||||
|
||||
#define get_bit_offset(index, mask) (__ffs(mask) + (index))
|
||||
|
||||
static void __m1_pmu_enable_counter(unsigned int index, bool en)
|
||||
{
|
||||
u64 val, bit;
|
||||
|
||||
switch (index) {
|
||||
case 0 ... 7:
|
||||
bit = BIT(get_bit_offset(index, PMCR0_CNT_ENABLE_0_7));
|
||||
break;
|
||||
case 8 ... 9:
|
||||
bit = BIT(get_bit_offset(index - 8, PMCR0_CNT_ENABLE_8_9));
|
||||
break;
|
||||
default:
|
||||
BUG();
|
||||
}
|
||||
|
||||
val = read_sysreg_s(SYS_IMP_APL_PMCR0_EL1);
|
||||
|
||||
if (en)
|
||||
val |= bit;
|
||||
else
|
||||
val &= ~bit;
|
||||
|
||||
write_sysreg_s(val, SYS_IMP_APL_PMCR0_EL1);
|
||||
}
|
||||
|
||||
static void m1_pmu_enable_counter(unsigned int index)
|
||||
{
|
||||
__m1_pmu_enable_counter(index, true);
|
||||
}
|
||||
|
||||
static void m1_pmu_disable_counter(unsigned int index)
|
||||
{
|
||||
__m1_pmu_enable_counter(index, false);
|
||||
}
|
||||
|
||||
static void __m1_pmu_enable_counter_interrupt(unsigned int index, bool en)
|
||||
{
|
||||
u64 val, bit;
|
||||
|
||||
switch (index) {
|
||||
case 0 ... 7:
|
||||
bit = BIT(get_bit_offset(index, PMCR0_PMI_ENABLE_0_7));
|
||||
break;
|
||||
case 8 ... 9:
|
||||
bit = BIT(get_bit_offset(index - 8, PMCR0_PMI_ENABLE_8_9));
|
||||
break;
|
||||
default:
|
||||
BUG();
|
||||
}
|
||||
|
||||
val = read_sysreg_s(SYS_IMP_APL_PMCR0_EL1);
|
||||
|
||||
if (en)
|
||||
val |= bit;
|
||||
else
|
||||
val &= ~bit;
|
||||
|
||||
write_sysreg_s(val, SYS_IMP_APL_PMCR0_EL1);
|
||||
}
|
||||
|
||||
static void m1_pmu_enable_counter_interrupt(unsigned int index)
|
||||
{
|
||||
__m1_pmu_enable_counter_interrupt(index, true);
|
||||
}
|
||||
|
||||
static void m1_pmu_disable_counter_interrupt(unsigned int index)
|
||||
{
|
||||
__m1_pmu_enable_counter_interrupt(index, false);
|
||||
}
|
||||
|
||||
static void m1_pmu_configure_counter(unsigned int index, u8 event,
|
||||
bool user, bool kernel)
|
||||
{
|
||||
u64 val, user_bit, kernel_bit;
|
||||
int shift;
|
||||
|
||||
switch (index) {
|
||||
case 0 ... 7:
|
||||
user_bit = BIT(get_bit_offset(index, PMCR1_COUNT_A64_EL0_0_7));
|
||||
kernel_bit = BIT(get_bit_offset(index, PMCR1_COUNT_A64_EL1_0_7));
|
||||
break;
|
||||
case 8 ... 9:
|
||||
user_bit = BIT(get_bit_offset(index - 8, PMCR1_COUNT_A64_EL0_8_9));
|
||||
kernel_bit = BIT(get_bit_offset(index - 8, PMCR1_COUNT_A64_EL1_8_9));
|
||||
break;
|
||||
default:
|
||||
BUG();
|
||||
}
|
||||
|
||||
val = read_sysreg_s(SYS_IMP_APL_PMCR1_EL1);
|
||||
|
||||
if (user)
|
||||
val |= user_bit;
|
||||
else
|
||||
val &= ~user_bit;
|
||||
|
||||
if (kernel)
|
||||
val |= kernel_bit;
|
||||
else
|
||||
val &= ~kernel_bit;
|
||||
|
||||
write_sysreg_s(val, SYS_IMP_APL_PMCR1_EL1);
|
||||
|
||||
/*
|
||||
* Counters 0 and 1 have fixed events. For anything else,
|
||||
* place the event at the expected location in the relevant
|
||||
* register (PMESR0 holds the event configuration for counters
|
||||
* 2-5, resp. PMESR1 for counters 6-9).
|
||||
*/
|
||||
switch (index) {
|
||||
case 0 ... 1:
|
||||
break;
|
||||
case 2 ... 5:
|
||||
shift = (index - 2) * 8;
|
||||
val = read_sysreg_s(SYS_IMP_APL_PMESR0_EL1);
|
||||
val &= ~((u64)0xff << shift);
|
||||
val |= (u64)event << shift;
|
||||
write_sysreg_s(val, SYS_IMP_APL_PMESR0_EL1);
|
||||
break;
|
||||
case 6 ... 9:
|
||||
shift = (index - 6) * 8;
|
||||
val = read_sysreg_s(SYS_IMP_APL_PMESR1_EL1);
|
||||
val &= ~((u64)0xff << shift);
|
||||
val |= (u64)event << shift;
|
||||
write_sysreg_s(val, SYS_IMP_APL_PMESR1_EL1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* arm_pmu backend */
|
||||
static void m1_pmu_enable_event(struct perf_event *event)
|
||||
{
|
||||
bool user, kernel;
|
||||
u8 evt;
|
||||
|
||||
evt = event->hw.config_base & M1_PMU_CFG_EVENT;
|
||||
user = event->hw.config_base & M1_PMU_CFG_COUNT_USER;
|
||||
kernel = event->hw.config_base & M1_PMU_CFG_COUNT_KERNEL;
|
||||
|
||||
m1_pmu_disable_counter_interrupt(event->hw.idx);
|
||||
m1_pmu_disable_counter(event->hw.idx);
|
||||
isb();
|
||||
|
||||
m1_pmu_configure_counter(event->hw.idx, evt, user, kernel);
|
||||
m1_pmu_enable_counter(event->hw.idx);
|
||||
m1_pmu_enable_counter_interrupt(event->hw.idx);
|
||||
isb();
|
||||
}
|
||||
|
||||
static void m1_pmu_disable_event(struct perf_event *event)
|
||||
{
|
||||
m1_pmu_disable_counter_interrupt(event->hw.idx);
|
||||
m1_pmu_disable_counter(event->hw.idx);
|
||||
isb();
|
||||
}
|
||||
|
||||
static irqreturn_t m1_pmu_handle_irq(struct arm_pmu *cpu_pmu)
|
||||
{
|
||||
struct pmu_hw_events *cpuc = this_cpu_ptr(cpu_pmu->hw_events);
|
||||
struct pt_regs *regs;
|
||||
u64 overflow, state;
|
||||
int idx;
|
||||
|
||||
overflow = read_sysreg_s(SYS_IMP_APL_PMSR_EL1);
|
||||
if (!overflow) {
|
||||
/* Spurious interrupt? */
|
||||
state = read_sysreg_s(SYS_IMP_APL_PMCR0_EL1);
|
||||
state &= ~PMCR0_IACT;
|
||||
write_sysreg_s(state, SYS_IMP_APL_PMCR0_EL1);
|
||||
isb();
|
||||
return IRQ_NONE;
|
||||
}
|
||||
|
||||
cpu_pmu->stop(cpu_pmu);
|
||||
|
||||
regs = get_irq_regs();
|
||||
|
||||
for (idx = 0; idx < cpu_pmu->num_events; idx++) {
|
||||
struct perf_event *event = cpuc->events[idx];
|
||||
struct perf_sample_data data;
|
||||
|
||||
if (!event)
|
||||
continue;
|
||||
|
||||
armpmu_event_update(event);
|
||||
perf_sample_data_init(&data, 0, event->hw.last_period);
|
||||
if (!armpmu_event_set_period(event))
|
||||
continue;
|
||||
|
||||
if (perf_event_overflow(event, &data, regs))
|
||||
m1_pmu_disable_event(event);
|
||||
}
|
||||
|
||||
cpu_pmu->start(cpu_pmu);
|
||||
|
||||
return IRQ_HANDLED;
|
||||
}
|
||||
|
||||
static u64 m1_pmu_read_counter(struct perf_event *event)
|
||||
{
|
||||
return m1_pmu_read_hw_counter(event->hw.idx);
|
||||
}
|
||||
|
||||
static void m1_pmu_write_counter(struct perf_event *event, u64 value)
|
||||
{
|
||||
m1_pmu_write_hw_counter(value, event->hw.idx);
|
||||
isb();
|
||||
}
|
||||
|
||||
static int m1_pmu_get_event_idx(struct pmu_hw_events *cpuc,
|
||||
struct perf_event *event)
|
||||
{
|
||||
unsigned long evtype = event->hw.config_base & M1_PMU_CFG_EVENT;
|
||||
unsigned long affinity = m1_pmu_event_affinity[evtype];
|
||||
int idx;
|
||||
|
||||
/*
|
||||
* Place the event on the first free counter that can count
|
||||
* this event.
|
||||
*
|
||||
* We could do a better job if we had a view of all the events
|
||||
* counting on the PMU at any given time, and by placing the
|
||||
* most constraining events first.
|
||||
*/
|
||||
for_each_set_bit(idx, &affinity, M1_PMU_NR_COUNTERS) {
|
||||
if (!test_and_set_bit(idx, cpuc->used_mask))
|
||||
return idx;
|
||||
}
|
||||
|
||||
return -EAGAIN;
|
||||
}
|
||||
|
||||
static void m1_pmu_clear_event_idx(struct pmu_hw_events *cpuc,
|
||||
struct perf_event *event)
|
||||
{
|
||||
clear_bit(event->hw.idx, cpuc->used_mask);
|
||||
}
|
||||
|
||||
static void __m1_pmu_set_mode(u8 mode)
|
||||
{
|
||||
u64 val;
|
||||
|
||||
val = read_sysreg_s(SYS_IMP_APL_PMCR0_EL1);
|
||||
val &= ~(PMCR0_IMODE | PMCR0_IACT);
|
||||
val |= FIELD_PREP(PMCR0_IMODE, mode);
|
||||
write_sysreg_s(val, SYS_IMP_APL_PMCR0_EL1);
|
||||
isb();
|
||||
}
|
||||
|
||||
static void m1_pmu_start(struct arm_pmu *cpu_pmu)
|
||||
{
|
||||
__m1_pmu_set_mode(PMCR0_IMODE_FIQ);
|
||||
}
|
||||
|
||||
static void m1_pmu_stop(struct arm_pmu *cpu_pmu)
|
||||
{
|
||||
__m1_pmu_set_mode(PMCR0_IMODE_OFF);
|
||||
}
|
||||
|
||||
static int m1_pmu_map_event(struct perf_event *event)
|
||||
{
|
||||
/*
|
||||
* Although the counters are 48bit wide, bit 47 is what
|
||||
* triggers the overflow interrupt. Advertise the counters
|
||||
* being 47bit wide to mimick the behaviour of the ARM PMU.
|
||||
*/
|
||||
event->hw.flags |= ARMPMU_EVT_47BIT;
|
||||
return armpmu_map_event(event, &m1_pmu_perf_map, NULL, M1_PMU_CFG_EVENT);
|
||||
}
|
||||
|
||||
static void m1_pmu_reset(void *info)
|
||||
{
|
||||
int i;
|
||||
|
||||
__m1_pmu_set_mode(PMCR0_IMODE_OFF);
|
||||
|
||||
for (i = 0; i < M1_PMU_NR_COUNTERS; i++) {
|
||||
m1_pmu_disable_counter(i);
|
||||
m1_pmu_disable_counter_interrupt(i);
|
||||
m1_pmu_write_hw_counter(0, i);
|
||||
}
|
||||
|
||||
isb();
|
||||
}
|
||||
|
||||
static int m1_pmu_set_event_filter(struct hw_perf_event *event,
|
||||
struct perf_event_attr *attr)
|
||||
{
|
||||
unsigned long config_base = 0;
|
||||
|
||||
if (!attr->exclude_guest)
|
||||
return -EINVAL;
|
||||
if (!attr->exclude_kernel)
|
||||
config_base |= M1_PMU_CFG_COUNT_KERNEL;
|
||||
if (!attr->exclude_user)
|
||||
config_base |= M1_PMU_CFG_COUNT_USER;
|
||||
|
||||
event->config_base = config_base;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int m1_pmu_init(struct arm_pmu *cpu_pmu)
|
||||
{
|
||||
cpu_pmu->handle_irq = m1_pmu_handle_irq;
|
||||
cpu_pmu->enable = m1_pmu_enable_event;
|
||||
cpu_pmu->disable = m1_pmu_disable_event;
|
||||
cpu_pmu->read_counter = m1_pmu_read_counter;
|
||||
cpu_pmu->write_counter = m1_pmu_write_counter;
|
||||
cpu_pmu->get_event_idx = m1_pmu_get_event_idx;
|
||||
cpu_pmu->clear_event_idx = m1_pmu_clear_event_idx;
|
||||
cpu_pmu->start = m1_pmu_start;
|
||||
cpu_pmu->stop = m1_pmu_stop;
|
||||
cpu_pmu->map_event = m1_pmu_map_event;
|
||||
cpu_pmu->reset = m1_pmu_reset;
|
||||
cpu_pmu->set_event_filter = m1_pmu_set_event_filter;
|
||||
|
||||
cpu_pmu->num_events = M1_PMU_NR_COUNTERS;
|
||||
cpu_pmu->attr_groups[ARMPMU_ATTR_GROUP_EVENTS] = &m1_pmu_events_attr_group;
|
||||
cpu_pmu->attr_groups[ARMPMU_ATTR_GROUP_FORMATS] = &m1_pmu_format_attr_group;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Device driver gunk */
|
||||
static int m1_pmu_ice_init(struct arm_pmu *cpu_pmu)
|
||||
{
|
||||
cpu_pmu->name = "apple_icestorm_pmu";
|
||||
return m1_pmu_init(cpu_pmu);
|
||||
}
|
||||
|
||||
static int m1_pmu_fire_init(struct arm_pmu *cpu_pmu)
|
||||
{
|
||||
cpu_pmu->name = "apple_firestorm_pmu";
|
||||
return m1_pmu_init(cpu_pmu);
|
||||
}
|
||||
|
||||
static const struct of_device_id m1_pmu_of_device_ids[] = {
|
||||
{ .compatible = "apple,icestorm-pmu", .data = m1_pmu_ice_init, },
|
||||
{ .compatible = "apple,firestorm-pmu", .data = m1_pmu_fire_init, },
|
||||
{ },
|
||||
};
|
||||
MODULE_DEVICE_TABLE(of, m1_pmu_of_device_ids);
|
||||
|
||||
static int m1_pmu_device_probe(struct platform_device *pdev)
|
||||
{
|
||||
return arm_pmu_device_probe(pdev, m1_pmu_of_device_ids, NULL);
|
||||
}
|
||||
|
||||
static struct platform_driver m1_pmu_driver = {
|
||||
.driver = {
|
||||
.name = "apple-m1-cpu-pmu",
|
||||
.of_match_table = m1_pmu_of_device_ids,
|
||||
.suppress_bind_attrs = true,
|
||||
},
|
||||
.probe = m1_pmu_device_probe,
|
||||
};
|
||||
|
||||
module_platform_driver(m1_pmu_driver);
|
||||
MODULE_LICENSE("GPL v2");
|
|
@ -1096,7 +1096,7 @@ static void cci_pmu_enable(struct pmu *pmu)
|
|||
{
|
||||
struct cci_pmu *cci_pmu = to_cci_pmu(pmu);
|
||||
struct cci_pmu_hw_events *hw_events = &cci_pmu->hw_events;
|
||||
int enabled = bitmap_weight(hw_events->used_mask, cci_pmu->num_cntrs);
|
||||
bool enabled = !bitmap_empty(hw_events->used_mask, cci_pmu->num_cntrs);
|
||||
unsigned long flags;
|
||||
|
||||
if (!enabled)
|
||||
|
|
|
@ -1460,8 +1460,7 @@ static irqreturn_t arm_ccn_irq_handler(int irq, void *dev_id)
|
|||
static int arm_ccn_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct arm_ccn *ccn;
|
||||
struct resource *res;
|
||||
unsigned int irq;
|
||||
int irq;
|
||||
int err;
|
||||
|
||||
ccn = devm_kzalloc(&pdev->dev, sizeof(*ccn), GFP_KERNEL);
|
||||
|
@ -1474,10 +1473,9 @@ static int arm_ccn_probe(struct platform_device *pdev)
|
|||
if (IS_ERR(ccn->base))
|
||||
return PTR_ERR(ccn->base);
|
||||
|
||||
res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
|
||||
if (!res)
|
||||
return -EINVAL;
|
||||
irq = res->start;
|
||||
irq = platform_get_irq(pdev, 0);
|
||||
if (irq < 0)
|
||||
return irq;
|
||||
|
||||
/* Check if we can use the interrupt */
|
||||
writel(CCN_MN_ERRINT_STATUS__PMU_EVENTS__DISABLE,
|
||||
|
|
|
@ -71,9 +71,11 @@
|
|||
#define CMN_DTM_WPn(n) (0x1A0 + (n) * 0x18)
|
||||
#define CMN_DTM_WPn_CONFIG(n) (CMN_DTM_WPn(n) + 0x00)
|
||||
#define CMN_DTM_WPn_CONFIG_WP_DEV_SEL2 GENMASK_ULL(18,17)
|
||||
#define CMN_DTM_WPn_CONFIG_WP_COMBINE BIT(6)
|
||||
#define CMN_DTM_WPn_CONFIG_WP_EXCLUSIVE BIT(5)
|
||||
#define CMN_DTM_WPn_CONFIG_WP_GRP BIT(4)
|
||||
#define CMN_DTM_WPn_CONFIG_WP_COMBINE BIT(9)
|
||||
#define CMN_DTM_WPn_CONFIG_WP_EXCLUSIVE BIT(8)
|
||||
#define CMN600_WPn_CONFIG_WP_COMBINE BIT(6)
|
||||
#define CMN600_WPn_CONFIG_WP_EXCLUSIVE BIT(5)
|
||||
#define CMN_DTM_WPn_CONFIG_WP_GRP GENMASK_ULL(5, 4)
|
||||
#define CMN_DTM_WPn_CONFIG_WP_CHN_SEL GENMASK_ULL(3, 1)
|
||||
#define CMN_DTM_WPn_CONFIG_WP_DEV_SEL BIT(0)
|
||||
#define CMN_DTM_WPn_VAL(n) (CMN_DTM_WPn(n) + 0x08)
|
||||
|
@ -155,6 +157,7 @@
|
|||
#define CMN_CONFIG_WP_COMBINE GENMASK_ULL(27, 24)
|
||||
#define CMN_CONFIG_WP_DEV_SEL GENMASK_ULL(50, 48)
|
||||
#define CMN_CONFIG_WP_CHN_SEL GENMASK_ULL(55, 51)
|
||||
/* Note that we don't yet support the tertiary match group on newer IPs */
|
||||
#define CMN_CONFIG_WP_GRP BIT_ULL(56)
|
||||
#define CMN_CONFIG_WP_EXCLUSIVE BIT_ULL(57)
|
||||
#define CMN_CONFIG1_WP_VAL GENMASK_ULL(63, 0)
|
||||
|
@ -353,7 +356,7 @@ static struct arm_cmn_node *arm_cmn_node(const struct arm_cmn *cmn,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
struct dentry *arm_cmn_debugfs;
|
||||
static struct dentry *arm_cmn_debugfs;
|
||||
|
||||
#ifdef CONFIG_DEBUG_FS
|
||||
static const char *arm_cmn_device_type(u8 type)
|
||||
|
@ -595,6 +598,9 @@ static umode_t arm_cmn_event_attr_is_visible(struct kobject *kobj,
|
|||
if ((intf & 4) && !(cmn->ports_used & BIT(intf & 3)))
|
||||
return 0;
|
||||
|
||||
if (chan == 4 && cmn->model == CMN600)
|
||||
return 0;
|
||||
|
||||
if ((chan == 5 && cmn->rsp_vc_num < 2) ||
|
||||
(chan == 6 && cmn->dat_vc_num < 2))
|
||||
return 0;
|
||||
|
@ -905,15 +911,18 @@ static u32 arm_cmn_wp_config(struct perf_event *event)
|
|||
u32 grp = CMN_EVENT_WP_GRP(event);
|
||||
u32 exc = CMN_EVENT_WP_EXCLUSIVE(event);
|
||||
u32 combine = CMN_EVENT_WP_COMBINE(event);
|
||||
bool is_cmn600 = to_cmn(event->pmu)->model == CMN600;
|
||||
|
||||
config = FIELD_PREP(CMN_DTM_WPn_CONFIG_WP_DEV_SEL, dev) |
|
||||
FIELD_PREP(CMN_DTM_WPn_CONFIG_WP_CHN_SEL, chn) |
|
||||
FIELD_PREP(CMN_DTM_WPn_CONFIG_WP_GRP, grp) |
|
||||
FIELD_PREP(CMN_DTM_WPn_CONFIG_WP_EXCLUSIVE, exc) |
|
||||
FIELD_PREP(CMN_DTM_WPn_CONFIG_WP_DEV_SEL2, dev >> 1);
|
||||
if (exc)
|
||||
config |= is_cmn600 ? CMN600_WPn_CONFIG_WP_EXCLUSIVE :
|
||||
CMN_DTM_WPn_CONFIG_WP_EXCLUSIVE;
|
||||
if (combine && !grp)
|
||||
config |= CMN_DTM_WPn_CONFIG_WP_COMBINE;
|
||||
|
||||
config |= is_cmn600 ? CMN600_WPn_CONFIG_WP_COMBINE :
|
||||
CMN_DTM_WPn_CONFIG_WP_COMBINE;
|
||||
return config;
|
||||
}
|
||||
|
||||
|
|
|
@ -109,6 +109,8 @@ static inline u64 arm_pmu_event_max_period(struct perf_event *event)
|
|||
{
|
||||
if (event->hw.flags & ARMPMU_EVT_64BIT)
|
||||
return GENMASK_ULL(63, 0);
|
||||
else if (event->hw.flags & ARMPMU_EVT_47BIT)
|
||||
return GENMASK_ULL(46, 0);
|
||||
else
|
||||
return GENMASK_ULL(31, 0);
|
||||
}
|
||||
|
@ -524,7 +526,7 @@ static void armpmu_enable(struct pmu *pmu)
|
|||
{
|
||||
struct arm_pmu *armpmu = to_arm_pmu(pmu);
|
||||
struct pmu_hw_events *hw_events = this_cpu_ptr(armpmu->hw_events);
|
||||
int enabled = bitmap_weight(hw_events->used_mask, armpmu->num_events);
|
||||
bool enabled = !bitmap_empty(hw_events->used_mask, armpmu->num_events);
|
||||
|
||||
/* For task-bound events we may be called on other CPUs */
|
||||
if (!cpumask_test_cpu(smp_processor_id(), &armpmu->supported_cpus))
|
||||
|
@ -785,7 +787,7 @@ static int cpu_pm_pmu_notify(struct notifier_block *b, unsigned long cmd,
|
|||
{
|
||||
struct arm_pmu *armpmu = container_of(b, struct arm_pmu, cpu_pm_nb);
|
||||
struct pmu_hw_events *hw_events = this_cpu_ptr(armpmu->hw_events);
|
||||
int enabled = bitmap_weight(hw_events->used_mask, armpmu->num_events);
|
||||
bool enabled = !bitmap_empty(hw_events->used_mask, armpmu->num_events);
|
||||
|
||||
if (!cpumask_test_cpu(smp_processor_id(), &armpmu->supported_cpus))
|
||||
return NOTIFY_DONE;
|
||||
|
|
|
@ -393,7 +393,7 @@ EXPORT_SYMBOL_GPL(hisi_uncore_pmu_read);
|
|||
void hisi_uncore_pmu_enable(struct pmu *pmu)
|
||||
{
|
||||
struct hisi_pmu *hisi_pmu = to_hisi_pmu(pmu);
|
||||
int enabled = bitmap_weight(hisi_pmu->pmu_events.used_mask,
|
||||
bool enabled = !bitmap_empty(hisi_pmu->pmu_events.used_mask,
|
||||
hisi_pmu->num_counters);
|
||||
|
||||
if (!enabled)
|
||||
|
|
758
drivers/perf/marvell_cn10k_ddr_pmu.c
Normal file
758
drivers/perf/marvell_cn10k_ddr_pmu.c
Normal file
|
@ -0,0 +1,758 @@
|
|||
// SPDX-License-Identifier: GPL-2.0
|
||||
/* Marvell CN10K DRAM Subsystem (DSS) Performance Monitor Driver
|
||||
*
|
||||
* Copyright (C) 2021 Marvell.
|
||||
*/
|
||||
|
||||
#include <linux/init.h>
|
||||
#include <linux/io.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/of.h>
|
||||
#include <linux/of_address.h>
|
||||
#include <linux/of_device.h>
|
||||
#include <linux/perf_event.h>
|
||||
#include <linux/hrtimer.h>
|
||||
|
||||
/* Performance Counters Operating Mode Control Registers */
|
||||
#define DDRC_PERF_CNT_OP_MODE_CTRL 0x8020
|
||||
#define OP_MODE_CTRL_VAL_MANNUAL 0x1
|
||||
|
||||
/* Performance Counters Start Operation Control Registers */
|
||||
#define DDRC_PERF_CNT_START_OP_CTRL 0x8028
|
||||
#define START_OP_CTRL_VAL_START 0x1ULL
|
||||
#define START_OP_CTRL_VAL_ACTIVE 0x2
|
||||
|
||||
/* Performance Counters End Operation Control Registers */
|
||||
#define DDRC_PERF_CNT_END_OP_CTRL 0x8030
|
||||
#define END_OP_CTRL_VAL_END 0x1ULL
|
||||
|
||||
/* Performance Counters End Status Registers */
|
||||
#define DDRC_PERF_CNT_END_STATUS 0x8038
|
||||
#define END_STATUS_VAL_END_TIMER_MODE_END 0x1
|
||||
|
||||
/* Performance Counters Configuration Registers */
|
||||
#define DDRC_PERF_CFG_BASE 0x8040
|
||||
|
||||
/* 8 Generic event counter + 2 fixed event counters */
|
||||
#define DDRC_PERF_NUM_GEN_COUNTERS 8
|
||||
#define DDRC_PERF_NUM_FIX_COUNTERS 2
|
||||
#define DDRC_PERF_READ_COUNTER_IDX DDRC_PERF_NUM_GEN_COUNTERS
|
||||
#define DDRC_PERF_WRITE_COUNTER_IDX (DDRC_PERF_NUM_GEN_COUNTERS + 1)
|
||||
#define DDRC_PERF_NUM_COUNTERS (DDRC_PERF_NUM_GEN_COUNTERS + \
|
||||
DDRC_PERF_NUM_FIX_COUNTERS)
|
||||
|
||||
/* Generic event counter registers */
|
||||
#define DDRC_PERF_CFG(n) (DDRC_PERF_CFG_BASE + 8 * (n))
|
||||
#define EVENT_ENABLE BIT_ULL(63)
|
||||
|
||||
/* Two dedicated event counters for DDR reads and writes */
|
||||
#define EVENT_DDR_READS 101
|
||||
#define EVENT_DDR_WRITES 100
|
||||
|
||||
/*
|
||||
* programmable events IDs in programmable event counters.
|
||||
* DO NOT change these event-id numbers, they are used to
|
||||
* program event bitmap in h/w.
|
||||
*/
|
||||
#define EVENT_OP_IS_ZQLATCH 55
|
||||
#define EVENT_OP_IS_ZQSTART 54
|
||||
#define EVENT_OP_IS_TCR_MRR 53
|
||||
#define EVENT_OP_IS_DQSOSC_MRR 52
|
||||
#define EVENT_OP_IS_DQSOSC_MPC 51
|
||||
#define EVENT_VISIBLE_WIN_LIMIT_REACHED_WR 50
|
||||
#define EVENT_VISIBLE_WIN_LIMIT_REACHED_RD 49
|
||||
#define EVENT_BSM_STARVATION 48
|
||||
#define EVENT_BSM_ALLOC 47
|
||||
#define EVENT_LPR_REQ_WITH_NOCREDIT 46
|
||||
#define EVENT_HPR_REQ_WITH_NOCREDIT 45
|
||||
#define EVENT_OP_IS_ZQCS 44
|
||||
#define EVENT_OP_IS_ZQCL 43
|
||||
#define EVENT_OP_IS_LOAD_MODE 42
|
||||
#define EVENT_OP_IS_SPEC_REF 41
|
||||
#define EVENT_OP_IS_CRIT_REF 40
|
||||
#define EVENT_OP_IS_REFRESH 39
|
||||
#define EVENT_OP_IS_ENTER_MPSM 35
|
||||
#define EVENT_OP_IS_ENTER_POWERDOWN 31
|
||||
#define EVENT_OP_IS_ENTER_SELFREF 27
|
||||
#define EVENT_WAW_HAZARD 26
|
||||
#define EVENT_RAW_HAZARD 25
|
||||
#define EVENT_WAR_HAZARD 24
|
||||
#define EVENT_WRITE_COMBINE 23
|
||||
#define EVENT_RDWR_TRANSITIONS 22
|
||||
#define EVENT_PRECHARGE_FOR_OTHER 21
|
||||
#define EVENT_PRECHARGE_FOR_RDWR 20
|
||||
#define EVENT_OP_IS_PRECHARGE 19
|
||||
#define EVENT_OP_IS_MWR 18
|
||||
#define EVENT_OP_IS_WR 17
|
||||
#define EVENT_OP_IS_RD 16
|
||||
#define EVENT_OP_IS_RD_ACTIVATE 15
|
||||
#define EVENT_OP_IS_RD_OR_WR 14
|
||||
#define EVENT_OP_IS_ACTIVATE 13
|
||||
#define EVENT_WR_XACT_WHEN_CRITICAL 12
|
||||
#define EVENT_LPR_XACT_WHEN_CRITICAL 11
|
||||
#define EVENT_HPR_XACT_WHEN_CRITICAL 10
|
||||
#define EVENT_DFI_RD_DATA_CYCLES 9
|
||||
#define EVENT_DFI_WR_DATA_CYCLES 8
|
||||
#define EVENT_ACT_BYPASS 7
|
||||
#define EVENT_READ_BYPASS 6
|
||||
#define EVENT_HIF_HI_PRI_RD 5
|
||||
#define EVENT_HIF_RMW 4
|
||||
#define EVENT_HIF_RD 3
|
||||
#define EVENT_HIF_WR 2
|
||||
#define EVENT_HIF_RD_OR_WR 1
|
||||
|
||||
/* Event counter value registers */
|
||||
#define DDRC_PERF_CNT_VALUE_BASE 0x8080
|
||||
#define DDRC_PERF_CNT_VALUE(n) (DDRC_PERF_CNT_VALUE_BASE + 8 * (n))
|
||||
|
||||
/* Fixed event counter enable/disable register */
|
||||
#define DDRC_PERF_CNT_FREERUN_EN 0x80C0
|
||||
#define DDRC_PERF_FREERUN_WRITE_EN 0x1
|
||||
#define DDRC_PERF_FREERUN_READ_EN 0x2
|
||||
|
||||
/* Fixed event counter control register */
|
||||
#define DDRC_PERF_CNT_FREERUN_CTRL 0x80C8
|
||||
#define DDRC_FREERUN_WRITE_CNT_CLR 0x1
|
||||
#define DDRC_FREERUN_READ_CNT_CLR 0x2
|
||||
|
||||
/* Fixed event counter value register */
|
||||
#define DDRC_PERF_CNT_VALUE_WR_OP 0x80D0
|
||||
#define DDRC_PERF_CNT_VALUE_RD_OP 0x80D8
|
||||
#define DDRC_PERF_CNT_VALUE_OVERFLOW BIT_ULL(48)
|
||||
#define DDRC_PERF_CNT_MAX_VALUE GENMASK_ULL(48, 0)
|
||||
|
||||
struct cn10k_ddr_pmu {
|
||||
struct pmu pmu;
|
||||
void __iomem *base;
|
||||
unsigned int cpu;
|
||||
struct device *dev;
|
||||
int active_events;
|
||||
struct perf_event *events[DDRC_PERF_NUM_COUNTERS];
|
||||
struct hrtimer hrtimer;
|
||||
struct hlist_node node;
|
||||
};
|
||||
|
||||
#define to_cn10k_ddr_pmu(p) container_of(p, struct cn10k_ddr_pmu, pmu)
|
||||
|
||||
static ssize_t cn10k_ddr_pmu_event_show(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
char *page)
|
||||
{
|
||||
struct perf_pmu_events_attr *pmu_attr;
|
||||
|
||||
pmu_attr = container_of(attr, struct perf_pmu_events_attr, attr);
|
||||
return sysfs_emit(page, "event=0x%02llx\n", pmu_attr->id);
|
||||
|
||||
}
|
||||
|
||||
#define CN10K_DDR_PMU_EVENT_ATTR(_name, _id) \
|
||||
PMU_EVENT_ATTR_ID(_name, cn10k_ddr_pmu_event_show, _id)
|
||||
|
||||
static struct attribute *cn10k_ddr_perf_events_attrs[] = {
|
||||
CN10K_DDR_PMU_EVENT_ATTR(ddr_hif_rd_or_wr_access, EVENT_HIF_RD_OR_WR),
|
||||
CN10K_DDR_PMU_EVENT_ATTR(ddr_hif_wr_access, EVENT_HIF_WR),
|
||||
CN10K_DDR_PMU_EVENT_ATTR(ddr_hif_rd_access, EVENT_HIF_RD),
|
||||
CN10K_DDR_PMU_EVENT_ATTR(ddr_hif_rmw_access, EVENT_HIF_RMW),
|
||||
CN10K_DDR_PMU_EVENT_ATTR(ddr_hif_pri_rdaccess, EVENT_HIF_HI_PRI_RD),
|
||||
CN10K_DDR_PMU_EVENT_ATTR(ddr_rd_bypass_access, EVENT_READ_BYPASS),
|
||||
CN10K_DDR_PMU_EVENT_ATTR(ddr_act_bypass_access, EVENT_ACT_BYPASS),
|
||||
CN10K_DDR_PMU_EVENT_ATTR(ddr_dif_wr_data_access, EVENT_DFI_WR_DATA_CYCLES),
|
||||
CN10K_DDR_PMU_EVENT_ATTR(ddr_dif_rd_data_access, EVENT_DFI_RD_DATA_CYCLES),
|
||||
CN10K_DDR_PMU_EVENT_ATTR(ddr_hpri_sched_rd_crit_access,
|
||||
EVENT_HPR_XACT_WHEN_CRITICAL),
|
||||
CN10K_DDR_PMU_EVENT_ATTR(ddr_lpri_sched_rd_crit_access,
|
||||
EVENT_LPR_XACT_WHEN_CRITICAL),
|
||||
CN10K_DDR_PMU_EVENT_ATTR(ddr_wr_trxn_crit_access,
|
||||
EVENT_WR_XACT_WHEN_CRITICAL),
|
||||
CN10K_DDR_PMU_EVENT_ATTR(ddr_cam_active_access, EVENT_OP_IS_ACTIVATE),
|
||||
CN10K_DDR_PMU_EVENT_ATTR(ddr_cam_rd_or_wr_access, EVENT_OP_IS_RD_OR_WR),
|
||||
CN10K_DDR_PMU_EVENT_ATTR(ddr_cam_rd_active_access, EVENT_OP_IS_RD_ACTIVATE),
|
||||
CN10K_DDR_PMU_EVENT_ATTR(ddr_cam_read, EVENT_OP_IS_RD),
|
||||
CN10K_DDR_PMU_EVENT_ATTR(ddr_cam_write, EVENT_OP_IS_WR),
|
||||
CN10K_DDR_PMU_EVENT_ATTR(ddr_cam_mwr, EVENT_OP_IS_MWR),
|
||||
CN10K_DDR_PMU_EVENT_ATTR(ddr_precharge, EVENT_OP_IS_PRECHARGE),
|
||||
CN10K_DDR_PMU_EVENT_ATTR(ddr_precharge_for_rdwr, EVENT_PRECHARGE_FOR_RDWR),
|
||||
CN10K_DDR_PMU_EVENT_ATTR(ddr_precharge_for_other,
|
||||
EVENT_PRECHARGE_FOR_OTHER),
|
||||
CN10K_DDR_PMU_EVENT_ATTR(ddr_rdwr_transitions, EVENT_RDWR_TRANSITIONS),
|
||||
CN10K_DDR_PMU_EVENT_ATTR(ddr_write_combine, EVENT_WRITE_COMBINE),
|
||||
CN10K_DDR_PMU_EVENT_ATTR(ddr_war_hazard, EVENT_WAR_HAZARD),
|
||||
CN10K_DDR_PMU_EVENT_ATTR(ddr_raw_hazard, EVENT_RAW_HAZARD),
|
||||
CN10K_DDR_PMU_EVENT_ATTR(ddr_waw_hazard, EVENT_WAW_HAZARD),
|
||||
CN10K_DDR_PMU_EVENT_ATTR(ddr_enter_selfref, EVENT_OP_IS_ENTER_SELFREF),
|
||||
CN10K_DDR_PMU_EVENT_ATTR(ddr_enter_powerdown, EVENT_OP_IS_ENTER_POWERDOWN),
|
||||
CN10K_DDR_PMU_EVENT_ATTR(ddr_enter_mpsm, EVENT_OP_IS_ENTER_MPSM),
|
||||
CN10K_DDR_PMU_EVENT_ATTR(ddr_refresh, EVENT_OP_IS_REFRESH),
|
||||
CN10K_DDR_PMU_EVENT_ATTR(ddr_crit_ref, EVENT_OP_IS_CRIT_REF),
|
||||
CN10K_DDR_PMU_EVENT_ATTR(ddr_spec_ref, EVENT_OP_IS_SPEC_REF),
|
||||
CN10K_DDR_PMU_EVENT_ATTR(ddr_load_mode, EVENT_OP_IS_LOAD_MODE),
|
||||
CN10K_DDR_PMU_EVENT_ATTR(ddr_zqcl, EVENT_OP_IS_ZQCL),
|
||||
CN10K_DDR_PMU_EVENT_ATTR(ddr_cam_wr_access, EVENT_OP_IS_ZQCS),
|
||||
CN10K_DDR_PMU_EVENT_ATTR(ddr_hpr_req_with_nocredit,
|
||||
EVENT_HPR_REQ_WITH_NOCREDIT),
|
||||
CN10K_DDR_PMU_EVENT_ATTR(ddr_lpr_req_with_nocredit,
|
||||
EVENT_LPR_REQ_WITH_NOCREDIT),
|
||||
CN10K_DDR_PMU_EVENT_ATTR(ddr_bsm_alloc, EVENT_BSM_ALLOC),
|
||||
CN10K_DDR_PMU_EVENT_ATTR(ddr_bsm_starvation, EVENT_BSM_STARVATION),
|
||||
CN10K_DDR_PMU_EVENT_ATTR(ddr_win_limit_reached_rd,
|
||||
EVENT_VISIBLE_WIN_LIMIT_REACHED_RD),
|
||||
CN10K_DDR_PMU_EVENT_ATTR(ddr_win_limit_reached_wr,
|
||||
EVENT_VISIBLE_WIN_LIMIT_REACHED_WR),
|
||||
CN10K_DDR_PMU_EVENT_ATTR(ddr_dqsosc_mpc, EVENT_OP_IS_DQSOSC_MPC),
|
||||
CN10K_DDR_PMU_EVENT_ATTR(ddr_dqsosc_mrr, EVENT_OP_IS_DQSOSC_MRR),
|
||||
CN10K_DDR_PMU_EVENT_ATTR(ddr_tcr_mrr, EVENT_OP_IS_TCR_MRR),
|
||||
CN10K_DDR_PMU_EVENT_ATTR(ddr_zqstart, EVENT_OP_IS_ZQSTART),
|
||||
CN10K_DDR_PMU_EVENT_ATTR(ddr_zqlatch, EVENT_OP_IS_ZQLATCH),
|
||||
/* Free run event counters */
|
||||
CN10K_DDR_PMU_EVENT_ATTR(ddr_ddr_reads, EVENT_DDR_READS),
|
||||
CN10K_DDR_PMU_EVENT_ATTR(ddr_ddr_writes, EVENT_DDR_WRITES),
|
||||
NULL
|
||||
};
|
||||
|
||||
static struct attribute_group cn10k_ddr_perf_events_attr_group = {
|
||||
.name = "events",
|
||||
.attrs = cn10k_ddr_perf_events_attrs,
|
||||
};
|
||||
|
||||
PMU_FORMAT_ATTR(event, "config:0-8");
|
||||
|
||||
static struct attribute *cn10k_ddr_perf_format_attrs[] = {
|
||||
&format_attr_event.attr,
|
||||
NULL,
|
||||
};
|
||||
|
||||
static struct attribute_group cn10k_ddr_perf_format_attr_group = {
|
||||
.name = "format",
|
||||
.attrs = cn10k_ddr_perf_format_attrs,
|
||||
};
|
||||
|
||||
static ssize_t cn10k_ddr_perf_cpumask_show(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
char *buf)
|
||||
{
|
||||
struct cn10k_ddr_pmu *pmu = dev_get_drvdata(dev);
|
||||
|
||||
return cpumap_print_to_pagebuf(true, buf, cpumask_of(pmu->cpu));
|
||||
}
|
||||
|
||||
static struct device_attribute cn10k_ddr_perf_cpumask_attr =
|
||||
__ATTR(cpumask, 0444, cn10k_ddr_perf_cpumask_show, NULL);
|
||||
|
||||
static struct attribute *cn10k_ddr_perf_cpumask_attrs[] = {
|
||||
&cn10k_ddr_perf_cpumask_attr.attr,
|
||||
NULL,
|
||||
};
|
||||
|
||||
static struct attribute_group cn10k_ddr_perf_cpumask_attr_group = {
|
||||
.attrs = cn10k_ddr_perf_cpumask_attrs,
|
||||
};
|
||||
|
||||
static const struct attribute_group *cn10k_attr_groups[] = {
|
||||
&cn10k_ddr_perf_events_attr_group,
|
||||
&cn10k_ddr_perf_format_attr_group,
|
||||
&cn10k_ddr_perf_cpumask_attr_group,
|
||||
NULL,
|
||||
};
|
||||
|
||||
/* Default poll timeout is 100 sec, which is very sufficient for
|
||||
* 48 bit counter incremented max at 5.6 GT/s, which may take many
|
||||
* hours to overflow.
|
||||
*/
|
||||
static unsigned long cn10k_ddr_pmu_poll_period_sec = 100;
|
||||
module_param_named(poll_period_sec, cn10k_ddr_pmu_poll_period_sec, ulong, 0644);
|
||||
|
||||
static ktime_t cn10k_ddr_pmu_timer_period(void)
|
||||
{
|
||||
return ms_to_ktime((u64)cn10k_ddr_pmu_poll_period_sec * USEC_PER_SEC);
|
||||
}
|
||||
|
||||
static int ddr_perf_get_event_bitmap(int eventid, u64 *event_bitmap)
|
||||
{
|
||||
switch (eventid) {
|
||||
case EVENT_HIF_RD_OR_WR ... EVENT_WAW_HAZARD:
|
||||
case EVENT_OP_IS_REFRESH ... EVENT_OP_IS_ZQLATCH:
|
||||
*event_bitmap = (1ULL << (eventid - 1));
|
||||
break;
|
||||
case EVENT_OP_IS_ENTER_SELFREF:
|
||||
case EVENT_OP_IS_ENTER_POWERDOWN:
|
||||
case EVENT_OP_IS_ENTER_MPSM:
|
||||
*event_bitmap = (0xFULL << (eventid - 1));
|
||||
break;
|
||||
default:
|
||||
pr_err("%s Invalid eventid %d\n", __func__, eventid);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int cn10k_ddr_perf_alloc_counter(struct cn10k_ddr_pmu *pmu,
|
||||
struct perf_event *event)
|
||||
{
|
||||
u8 config = event->attr.config;
|
||||
int i;
|
||||
|
||||
/* DDR read free-run counter index */
|
||||
if (config == EVENT_DDR_READS) {
|
||||
pmu->events[DDRC_PERF_READ_COUNTER_IDX] = event;
|
||||
return DDRC_PERF_READ_COUNTER_IDX;
|
||||
}
|
||||
|
||||
/* DDR write free-run counter index */
|
||||
if (config == EVENT_DDR_WRITES) {
|
||||
pmu->events[DDRC_PERF_WRITE_COUNTER_IDX] = event;
|
||||
return DDRC_PERF_WRITE_COUNTER_IDX;
|
||||
}
|
||||
|
||||
/* Allocate DDR generic counters */
|
||||
for (i = 0; i < DDRC_PERF_NUM_GEN_COUNTERS; i++) {
|
||||
if (pmu->events[i] == NULL) {
|
||||
pmu->events[i] = event;
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
static void cn10k_ddr_perf_free_counter(struct cn10k_ddr_pmu *pmu, int counter)
|
||||
{
|
||||
pmu->events[counter] = NULL;
|
||||
}
|
||||
|
||||
static int cn10k_ddr_perf_event_init(struct perf_event *event)
|
||||
{
|
||||
struct cn10k_ddr_pmu *pmu = to_cn10k_ddr_pmu(event->pmu);
|
||||
struct hw_perf_event *hwc = &event->hw;
|
||||
|
||||
if (event->attr.type != event->pmu->type)
|
||||
return -ENOENT;
|
||||
|
||||
if (is_sampling_event(event)) {
|
||||
dev_info(pmu->dev, "Sampling not supported!\n");
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
|
||||
if (event->cpu < 0) {
|
||||
dev_warn(pmu->dev, "Can't provide per-task data!\n");
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
|
||||
/* We must NOT create groups containing mixed PMUs */
|
||||
if (event->group_leader->pmu != event->pmu &&
|
||||
!is_software_event(event->group_leader))
|
||||
return -EINVAL;
|
||||
|
||||
/* Set ownership of event to one CPU, same event can not be observed
|
||||
* on multiple cpus at same time.
|
||||
*/
|
||||
event->cpu = pmu->cpu;
|
||||
hwc->idx = -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void cn10k_ddr_perf_counter_enable(struct cn10k_ddr_pmu *pmu,
|
||||
int counter, bool enable)
|
||||
{
|
||||
u32 reg;
|
||||
u64 val;
|
||||
|
||||
if (counter > DDRC_PERF_NUM_COUNTERS) {
|
||||
pr_err("Error: unsupported counter %d\n", counter);
|
||||
return;
|
||||
}
|
||||
|
||||
if (counter < DDRC_PERF_NUM_GEN_COUNTERS) {
|
||||
reg = DDRC_PERF_CFG(counter);
|
||||
val = readq_relaxed(pmu->base + reg);
|
||||
|
||||
if (enable)
|
||||
val |= EVENT_ENABLE;
|
||||
else
|
||||
val &= ~EVENT_ENABLE;
|
||||
|
||||
writeq_relaxed(val, pmu->base + reg);
|
||||
} else {
|
||||
val = readq_relaxed(pmu->base + DDRC_PERF_CNT_FREERUN_EN);
|
||||
if (enable) {
|
||||
if (counter == DDRC_PERF_READ_COUNTER_IDX)
|
||||
val |= DDRC_PERF_FREERUN_READ_EN;
|
||||
else
|
||||
val |= DDRC_PERF_FREERUN_WRITE_EN;
|
||||
} else {
|
||||
if (counter == DDRC_PERF_READ_COUNTER_IDX)
|
||||
val &= ~DDRC_PERF_FREERUN_READ_EN;
|
||||
else
|
||||
val &= ~DDRC_PERF_FREERUN_WRITE_EN;
|
||||
}
|
||||
writeq_relaxed(val, pmu->base + DDRC_PERF_CNT_FREERUN_EN);
|
||||
}
|
||||
}
|
||||
|
||||
static u64 cn10k_ddr_perf_read_counter(struct cn10k_ddr_pmu *pmu, int counter)
|
||||
{
|
||||
u64 val;
|
||||
|
||||
if (counter == DDRC_PERF_READ_COUNTER_IDX)
|
||||
return readq_relaxed(pmu->base + DDRC_PERF_CNT_VALUE_RD_OP);
|
||||
|
||||
if (counter == DDRC_PERF_WRITE_COUNTER_IDX)
|
||||
return readq_relaxed(pmu->base + DDRC_PERF_CNT_VALUE_WR_OP);
|
||||
|
||||
val = readq_relaxed(pmu->base + DDRC_PERF_CNT_VALUE(counter));
|
||||
return val;
|
||||
}
|
||||
|
||||
static void cn10k_ddr_perf_event_update(struct perf_event *event)
|
||||
{
|
||||
struct cn10k_ddr_pmu *pmu = to_cn10k_ddr_pmu(event->pmu);
|
||||
struct hw_perf_event *hwc = &event->hw;
|
||||
u64 prev_count, new_count, mask;
|
||||
|
||||
do {
|
||||
prev_count = local64_read(&hwc->prev_count);
|
||||
new_count = cn10k_ddr_perf_read_counter(pmu, hwc->idx);
|
||||
} while (local64_xchg(&hwc->prev_count, new_count) != prev_count);
|
||||
|
||||
mask = DDRC_PERF_CNT_MAX_VALUE;
|
||||
|
||||
local64_add((new_count - prev_count) & mask, &event->count);
|
||||
}
|
||||
|
||||
static void cn10k_ddr_perf_event_start(struct perf_event *event, int flags)
|
||||
{
|
||||
struct cn10k_ddr_pmu *pmu = to_cn10k_ddr_pmu(event->pmu);
|
||||
struct hw_perf_event *hwc = &event->hw;
|
||||
int counter = hwc->idx;
|
||||
|
||||
local64_set(&hwc->prev_count, 0);
|
||||
|
||||
cn10k_ddr_perf_counter_enable(pmu, counter, true);
|
||||
|
||||
hwc->state = 0;
|
||||
}
|
||||
|
||||
static int cn10k_ddr_perf_event_add(struct perf_event *event, int flags)
|
||||
{
|
||||
struct cn10k_ddr_pmu *pmu = to_cn10k_ddr_pmu(event->pmu);
|
||||
struct hw_perf_event *hwc = &event->hw;
|
||||
u8 config = event->attr.config;
|
||||
int counter, ret;
|
||||
u32 reg_offset;
|
||||
u64 val;
|
||||
|
||||
counter = cn10k_ddr_perf_alloc_counter(pmu, event);
|
||||
if (counter < 0)
|
||||
return -EAGAIN;
|
||||
|
||||
pmu->active_events++;
|
||||
hwc->idx = counter;
|
||||
|
||||
if (pmu->active_events == 1)
|
||||
hrtimer_start(&pmu->hrtimer, cn10k_ddr_pmu_timer_period(),
|
||||
HRTIMER_MODE_REL_PINNED);
|
||||
|
||||
if (counter < DDRC_PERF_NUM_GEN_COUNTERS) {
|
||||
/* Generic counters, configure event id */
|
||||
reg_offset = DDRC_PERF_CFG(counter);
|
||||
ret = ddr_perf_get_event_bitmap(config, &val);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
writeq_relaxed(val, pmu->base + reg_offset);
|
||||
} else {
|
||||
/* fixed event counter, clear counter value */
|
||||
if (counter == DDRC_PERF_READ_COUNTER_IDX)
|
||||
val = DDRC_FREERUN_READ_CNT_CLR;
|
||||
else
|
||||
val = DDRC_FREERUN_WRITE_CNT_CLR;
|
||||
|
||||
writeq_relaxed(val, pmu->base + DDRC_PERF_CNT_FREERUN_CTRL);
|
||||
}
|
||||
|
||||
hwc->state |= PERF_HES_STOPPED;
|
||||
|
||||
if (flags & PERF_EF_START)
|
||||
cn10k_ddr_perf_event_start(event, flags);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void cn10k_ddr_perf_event_stop(struct perf_event *event, int flags)
|
||||
{
|
||||
struct cn10k_ddr_pmu *pmu = to_cn10k_ddr_pmu(event->pmu);
|
||||
struct hw_perf_event *hwc = &event->hw;
|
||||
int counter = hwc->idx;
|
||||
|
||||
cn10k_ddr_perf_counter_enable(pmu, counter, false);
|
||||
|
||||
if (flags & PERF_EF_UPDATE)
|
||||
cn10k_ddr_perf_event_update(event);
|
||||
|
||||
hwc->state |= PERF_HES_STOPPED;
|
||||
}
|
||||
|
||||
static void cn10k_ddr_perf_event_del(struct perf_event *event, int flags)
|
||||
{
|
||||
struct cn10k_ddr_pmu *pmu = to_cn10k_ddr_pmu(event->pmu);
|
||||
struct hw_perf_event *hwc = &event->hw;
|
||||
int counter = hwc->idx;
|
||||
|
||||
cn10k_ddr_perf_event_stop(event, PERF_EF_UPDATE);
|
||||
|
||||
cn10k_ddr_perf_free_counter(pmu, counter);
|
||||
pmu->active_events--;
|
||||
hwc->idx = -1;
|
||||
|
||||
/* Cancel timer when no events to capture */
|
||||
if (pmu->active_events == 0)
|
||||
hrtimer_cancel(&pmu->hrtimer);
|
||||
}
|
||||
|
||||
static void cn10k_ddr_perf_pmu_enable(struct pmu *pmu)
|
||||
{
|
||||
struct cn10k_ddr_pmu *ddr_pmu = to_cn10k_ddr_pmu(pmu);
|
||||
|
||||
writeq_relaxed(START_OP_CTRL_VAL_START, ddr_pmu->base +
|
||||
DDRC_PERF_CNT_START_OP_CTRL);
|
||||
}
|
||||
|
||||
static void cn10k_ddr_perf_pmu_disable(struct pmu *pmu)
|
||||
{
|
||||
struct cn10k_ddr_pmu *ddr_pmu = to_cn10k_ddr_pmu(pmu);
|
||||
|
||||
writeq_relaxed(END_OP_CTRL_VAL_END, ddr_pmu->base +
|
||||
DDRC_PERF_CNT_END_OP_CTRL);
|
||||
}
|
||||
|
||||
static void cn10k_ddr_perf_event_update_all(struct cn10k_ddr_pmu *pmu)
|
||||
{
|
||||
struct hw_perf_event *hwc;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < DDRC_PERF_NUM_GEN_COUNTERS; i++) {
|
||||
if (pmu->events[i] == NULL)
|
||||
continue;
|
||||
|
||||
cn10k_ddr_perf_event_update(pmu->events[i]);
|
||||
}
|
||||
|
||||
/* Reset previous count as h/w counter are reset */
|
||||
for (i = 0; i < DDRC_PERF_NUM_GEN_COUNTERS; i++) {
|
||||
if (pmu->events[i] == NULL)
|
||||
continue;
|
||||
|
||||
hwc = &pmu->events[i]->hw;
|
||||
local64_set(&hwc->prev_count, 0);
|
||||
}
|
||||
}
|
||||
|
||||
static irqreturn_t cn10k_ddr_pmu_overflow_handler(struct cn10k_ddr_pmu *pmu)
|
||||
{
|
||||
struct perf_event *event;
|
||||
struct hw_perf_event *hwc;
|
||||
u64 prev_count, new_count;
|
||||
u64 value;
|
||||
int i;
|
||||
|
||||
event = pmu->events[DDRC_PERF_READ_COUNTER_IDX];
|
||||
if (event) {
|
||||
hwc = &event->hw;
|
||||
prev_count = local64_read(&hwc->prev_count);
|
||||
new_count = cn10k_ddr_perf_read_counter(pmu, hwc->idx);
|
||||
|
||||
/* Overflow condition is when new count less than
|
||||
* previous count
|
||||
*/
|
||||
if (new_count < prev_count)
|
||||
cn10k_ddr_perf_event_update(event);
|
||||
}
|
||||
|
||||
event = pmu->events[DDRC_PERF_WRITE_COUNTER_IDX];
|
||||
if (event) {
|
||||
hwc = &event->hw;
|
||||
prev_count = local64_read(&hwc->prev_count);
|
||||
new_count = cn10k_ddr_perf_read_counter(pmu, hwc->idx);
|
||||
|
||||
/* Overflow condition is when new count less than
|
||||
* previous count
|
||||
*/
|
||||
if (new_count < prev_count)
|
||||
cn10k_ddr_perf_event_update(event);
|
||||
}
|
||||
|
||||
for (i = 0; i < DDRC_PERF_NUM_GEN_COUNTERS; i++) {
|
||||
if (pmu->events[i] == NULL)
|
||||
continue;
|
||||
|
||||
value = cn10k_ddr_perf_read_counter(pmu, i);
|
||||
if (value == DDRC_PERF_CNT_MAX_VALUE) {
|
||||
pr_info("Counter-(%d) reached max value\n", i);
|
||||
cn10k_ddr_perf_event_update_all(pmu);
|
||||
cn10k_ddr_perf_pmu_disable(&pmu->pmu);
|
||||
cn10k_ddr_perf_pmu_enable(&pmu->pmu);
|
||||
}
|
||||
}
|
||||
|
||||
return IRQ_HANDLED;
|
||||
}
|
||||
|
||||
static enum hrtimer_restart cn10k_ddr_pmu_timer_handler(struct hrtimer *hrtimer)
|
||||
{
|
||||
struct cn10k_ddr_pmu *pmu = container_of(hrtimer, struct cn10k_ddr_pmu,
|
||||
hrtimer);
|
||||
unsigned long flags;
|
||||
|
||||
local_irq_save(flags);
|
||||
cn10k_ddr_pmu_overflow_handler(pmu);
|
||||
local_irq_restore(flags);
|
||||
|
||||
hrtimer_forward_now(hrtimer, cn10k_ddr_pmu_timer_period());
|
||||
return HRTIMER_RESTART;
|
||||
}
|
||||
|
||||
static int cn10k_ddr_pmu_offline_cpu(unsigned int cpu, struct hlist_node *node)
|
||||
{
|
||||
struct cn10k_ddr_pmu *pmu = hlist_entry_safe(node, struct cn10k_ddr_pmu,
|
||||
node);
|
||||
unsigned int target;
|
||||
|
||||
if (cpu != pmu->cpu)
|
||||
return 0;
|
||||
|
||||
target = cpumask_any_but(cpu_online_mask, cpu);
|
||||
if (target >= nr_cpu_ids)
|
||||
return 0;
|
||||
|
||||
perf_pmu_migrate_context(&pmu->pmu, cpu, target);
|
||||
pmu->cpu = target;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int cn10k_ddr_perf_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct cn10k_ddr_pmu *ddr_pmu;
|
||||
struct resource *res;
|
||||
void __iomem *base;
|
||||
char *name;
|
||||
int ret;
|
||||
|
||||
ddr_pmu = devm_kzalloc(&pdev->dev, sizeof(*ddr_pmu), GFP_KERNEL);
|
||||
if (!ddr_pmu)
|
||||
return -ENOMEM;
|
||||
|
||||
ddr_pmu->dev = &pdev->dev;
|
||||
platform_set_drvdata(pdev, ddr_pmu);
|
||||
|
||||
base = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
|
||||
if (IS_ERR(base))
|
||||
return PTR_ERR(base);
|
||||
|
||||
ddr_pmu->base = base;
|
||||
|
||||
/* Setup the PMU counter to work in manual mode */
|
||||
writeq_relaxed(OP_MODE_CTRL_VAL_MANNUAL, ddr_pmu->base +
|
||||
DDRC_PERF_CNT_OP_MODE_CTRL);
|
||||
|
||||
ddr_pmu->pmu = (struct pmu) {
|
||||
.module = THIS_MODULE,
|
||||
.capabilities = PERF_PMU_CAP_NO_EXCLUDE,
|
||||
.task_ctx_nr = perf_invalid_context,
|
||||
.attr_groups = cn10k_attr_groups,
|
||||
.event_init = cn10k_ddr_perf_event_init,
|
||||
.add = cn10k_ddr_perf_event_add,
|
||||
.del = cn10k_ddr_perf_event_del,
|
||||
.start = cn10k_ddr_perf_event_start,
|
||||
.stop = cn10k_ddr_perf_event_stop,
|
||||
.read = cn10k_ddr_perf_event_update,
|
||||
.pmu_enable = cn10k_ddr_perf_pmu_enable,
|
||||
.pmu_disable = cn10k_ddr_perf_pmu_disable,
|
||||
};
|
||||
|
||||
/* Choose this cpu to collect perf data */
|
||||
ddr_pmu->cpu = raw_smp_processor_id();
|
||||
|
||||
name = devm_kasprintf(ddr_pmu->dev, GFP_KERNEL, "mrvl_ddr_pmu_%llx",
|
||||
res->start);
|
||||
if (!name)
|
||||
return -ENOMEM;
|
||||
|
||||
hrtimer_init(&ddr_pmu->hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
|
||||
ddr_pmu->hrtimer.function = cn10k_ddr_pmu_timer_handler;
|
||||
|
||||
cpuhp_state_add_instance_nocalls(
|
||||
CPUHP_AP_PERF_ARM_MARVELL_CN10K_DDR_ONLINE,
|
||||
&ddr_pmu->node);
|
||||
|
||||
ret = perf_pmu_register(&ddr_pmu->pmu, name, -1);
|
||||
if (ret)
|
||||
goto error;
|
||||
|
||||
pr_info("CN10K DDR PMU Driver for ddrc@%llx\n", res->start);
|
||||
return 0;
|
||||
error:
|
||||
cpuhp_state_remove_instance_nocalls(
|
||||
CPUHP_AP_PERF_ARM_MARVELL_CN10K_DDR_ONLINE,
|
||||
&ddr_pmu->node);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int cn10k_ddr_perf_remove(struct platform_device *pdev)
|
||||
{
|
||||
struct cn10k_ddr_pmu *ddr_pmu = platform_get_drvdata(pdev);
|
||||
|
||||
cpuhp_state_remove_instance_nocalls(
|
||||
CPUHP_AP_PERF_ARM_MARVELL_CN10K_DDR_ONLINE,
|
||||
&ddr_pmu->node);
|
||||
|
||||
perf_pmu_unregister(&ddr_pmu->pmu);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_OF
|
||||
static const struct of_device_id cn10k_ddr_pmu_of_match[] = {
|
||||
{ .compatible = "marvell,cn10k-ddr-pmu", },
|
||||
{ },
|
||||
};
|
||||
MODULE_DEVICE_TABLE(of, cn10k_ddr_pmu_of_match);
|
||||
#endif
|
||||
|
||||
static struct platform_driver cn10k_ddr_pmu_driver = {
|
||||
.driver = {
|
||||
.name = "cn10k-ddr-pmu",
|
||||
.of_match_table = of_match_ptr(cn10k_ddr_pmu_of_match),
|
||||
.suppress_bind_attrs = true,
|
||||
},
|
||||
.probe = cn10k_ddr_perf_probe,
|
||||
.remove = cn10k_ddr_perf_remove,
|
||||
};
|
||||
|
||||
static int __init cn10k_ddr_pmu_init(void)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = cpuhp_setup_state_multi(
|
||||
CPUHP_AP_PERF_ARM_MARVELL_CN10K_DDR_ONLINE,
|
||||
"perf/marvell/cn10k/ddr:online", NULL,
|
||||
cn10k_ddr_pmu_offline_cpu);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = platform_driver_register(&cn10k_ddr_pmu_driver);
|
||||
if (ret)
|
||||
cpuhp_remove_multi_state(
|
||||
CPUHP_AP_PERF_ARM_MARVELL_CN10K_DDR_ONLINE);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void __exit cn10k_ddr_pmu_exit(void)
|
||||
{
|
||||
platform_driver_unregister(&cn10k_ddr_pmu_driver);
|
||||
cpuhp_remove_multi_state(CPUHP_AP_PERF_ARM_MARVELL_CN10K_DDR_ONLINE);
|
||||
}
|
||||
|
||||
module_init(cn10k_ddr_pmu_init);
|
||||
module_exit(cn10k_ddr_pmu_exit);
|
||||
|
||||
MODULE_AUTHOR("Bharat Bhushan <bbhushan2@marvell.com>");
|
||||
MODULE_LICENSE("GPL v2");
|
|
@ -368,10 +368,12 @@ static int tad_pmu_remove(struct platform_device *pdev)
|
|||
return 0;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_OF
|
||||
static const struct of_device_id tad_pmu_of_match[] = {
|
||||
{ .compatible = "marvell,cn10k-tad-pmu", },
|
||||
{},
|
||||
};
|
||||
#endif
|
||||
|
||||
static struct platform_driver tad_pmu_driver = {
|
||||
.driver = {
|
||||
|
|
|
@ -887,13 +887,11 @@ static struct tx2_uncore_pmu *tx2_uncore_pmu_init_dev(struct device *dev,
|
|||
static acpi_status tx2_uncore_pmu_add(acpi_handle handle, u32 level,
|
||||
void *data, void **return_value)
|
||||
{
|
||||
struct acpi_device *adev = acpi_fetch_acpi_dev(handle);
|
||||
struct tx2_uncore_pmu *tx2_pmu;
|
||||
struct acpi_device *adev;
|
||||
enum tx2_uncore_type type;
|
||||
|
||||
if (acpi_bus_get_device(handle, &adev))
|
||||
return AE_OK;
|
||||
if (acpi_bus_get_status(adev) || !adev->status.present)
|
||||
if (!adev || acpi_bus_get_status(adev) || !adev->status.present)
|
||||
return AE_OK;
|
||||
|
||||
type = get_tx2_pmu_type(adev);
|
||||
|
|
|
@ -867,7 +867,7 @@ static void xgene_perf_pmu_enable(struct pmu *pmu)
|
|||
{
|
||||
struct xgene_pmu_dev *pmu_dev = to_pmu_dev(pmu);
|
||||
struct xgene_pmu *xgene_pmu = pmu_dev->parent;
|
||||
int enabled = bitmap_weight(pmu_dev->cntr_assign_mask,
|
||||
bool enabled = !bitmap_empty(pmu_dev->cntr_assign_mask,
|
||||
pmu_dev->max_counters);
|
||||
|
||||
if (!enabled)
|
||||
|
@ -1549,14 +1549,12 @@ static const struct acpi_device_id *xgene_pmu_acpi_match_type(
|
|||
static acpi_status acpi_pmu_dev_add(acpi_handle handle, u32 level,
|
||||
void *data, void **return_value)
|
||||
{
|
||||
struct acpi_device *adev = acpi_fetch_acpi_dev(handle);
|
||||
const struct acpi_device_id *acpi_id;
|
||||
struct xgene_pmu *xgene_pmu = data;
|
||||
struct xgene_pmu_dev_ctx *ctx;
|
||||
struct acpi_device *adev;
|
||||
|
||||
if (acpi_bus_get_device(handle, &adev))
|
||||
return AE_OK;
|
||||
if (acpi_bus_get_status(adev) || !adev->status.present)
|
||||
if (!adev || acpi_bus_get_status(adev) || !adev->status.present)
|
||||
return AE_OK;
|
||||
|
||||
acpi_id = xgene_pmu_acpi_match_type(xgene_pmu_acpi_type_match, adev);
|
||||
|
|
|
@ -11,5 +11,7 @@
|
|||
#define AIC_TMR_HV_VIRT 1
|
||||
#define AIC_TMR_GUEST_PHYS 2
|
||||
#define AIC_TMR_GUEST_VIRT 3
|
||||
#define AIC_CPU_PMU_E 4
|
||||
#define AIC_CPU_PMU_P 5
|
||||
|
||||
#endif
|
||||
|
|
|
@ -231,6 +231,7 @@ enum cpuhp_state {
|
|||
CPUHP_AP_PERF_ARM_QCOM_L3_ONLINE,
|
||||
CPUHP_AP_PERF_ARM_APM_XGENE_ONLINE,
|
||||
CPUHP_AP_PERF_ARM_CAVIUM_TX2_UNCORE_ONLINE,
|
||||
CPUHP_AP_PERF_ARM_MARVELL_CN10K_DDR_ONLINE,
|
||||
CPUHP_AP_PERF_POWERPC_NEST_IMC_ONLINE,
|
||||
CPUHP_AP_PERF_POWERPC_CORE_IMC_ONLINE,
|
||||
CPUHP_AP_PERF_POWERPC_THREAD_IMC_ONLINE,
|
||||
|
|
|
@ -26,6 +26,8 @@
|
|||
*/
|
||||
/* Event uses a 64bit counter */
|
||||
#define ARMPMU_EVT_64BIT 1
|
||||
/* Event uses a 47bit counter */
|
||||
#define ARMPMU_EVT_47BIT 2
|
||||
|
||||
#define HW_OP_UNSUPPORTED 0xFFFF
|
||||
#define C(_x) PERF_COUNT_HW_CACHE_##_x
|
||||
|
|
Loading…
Reference in a new issue