stm32-ddr-pmu driver creation
Subsystems (5)
cover stm32-ddr-pmu driver creation
The DDRPERFM is the DDR Performance Monitor embedded in STM32MP1 SOC.
This series adds support for the DDRPERFM via a new stm32-ddr-pmu driver, registered into the perf framework.
This driver is inspired from arch/arm/mm/cache-l2x0-pmu.c
This series depends on the "clk: stm32mp1: Add ddrperfm clock" patch, sent separately.
Gerald Baeza (5):
Documentation: perf: stm32: ddrperfm support
dt-bindings: perf: stm32: ddrperfm support
perf: stm32: ddrperfm driver creation
ARM: configs: enable STM32_DDR_PMU
ARM: dts: stm32: add ddrperfm on stm32mp157c
.../devicetree/bindings/perf/stm32-ddr-pmu.txt | 18 + Documentation/perf/stm32-ddr-pmu.txt | 41 ++ arch/arm/boot/dts/stm32mp157c.dtsi | 9 + arch/arm/configs/multi_v7_defconfig | 1 + drivers/perf/Kconfig | 6 + drivers/perf/Makefile | 1 + drivers/perf/stm32_ddr_pmu.c | 502 +++++++++++++++++++++ 7 files changed, 578 insertions(+) create mode 100644 Documentation/devicetree/bindings/perf/stm32-ddr-pmu.txt create mode 100644 Documentation/perf/stm32-ddr-pmu.txt create mode 100644 drivers/perf/stm32_ddr_pmu.c
Signature · 1 line
2.7.4
PATCH 1/5 Documentation: perf: stm32: ddrperfm support
The DDRPERFM is the DDR Performance Monitor embedded in STM32MP1 SOC.
This documentation introduces the DDRPERFM, the stm32-ddr-pmu driver supporting it and how to use it with the perf tool.
--- Documentation/perf/stm32-ddr-pmu.txt | 41 ++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 Documentation/perf/stm32-ddr-pmu.txt
Documentation/perf/stm32-ddr-pmu.txt new file +41 -0
@@ -0,0 +1,41 @@ +STM32 DDR Performance Monitor (DDRPERFM) +======================================== + +The DDRPERFM is the DDR Performance Monitor embedded in STM32MP1 SOC. +See STM32MP157 reference manual RM0436 to get a description of this peripheral. + + +The five following counters are supported by stm32-ddr-pmu driver: + cnt0: read operations counters (read_cnt) + cnt1: write operations counters (write_cnt) + cnt2: active state counters (activate_cnt) + cnt3: idle state counters (idle_cnt) + tcnt: time count, present for all sets (time_cnt) + +The stm32-ddr-pmu driver relies on the perf PMU framework to expose the +counters via sysfs: + $ ls /sys/bus/event_source/devices/ddrperfm/events + activate_cnt idle_cnt read_cnt time_cnt write_cnt + + +The perf PMU framework is usually invoked via the 'perf stat' tool. + +The DDRPERFM is a system monitor that cannot isolate the traffic coming from a +given thread or CPU, that is why stm32-ddr-pmu driver rejects any 'perf stat' +call that does not request a system-wide collection: the '-a, --all-cpus' +option is mandatory! + +Example: + $ perf stat -e ddrperfm/read_cnt/,ddrperfm/time_cnt/ -a sleep 20 + Performance counter stats for 'system wide': + + 342541560 ddrperfm/read_cnt/ + 10660011400 ddrperfm/time_cnt/ + + 20.021068551 seconds time elapsed + + +The driver also exposes a 'bandwidth' attribute that can be used to display +the read/write/total bandwidth achieved during the last 'perf stat' execution. + $ cat /sys/bus/event_source/devices/ddrperfm/bandwidth + Read = 403, Write = 239, Read & Write = 642 (MB/s)
Signature · 1 line
2.7.4
PATCH 2/5 dt-bindings: perf: stm32: ddrperfm support
In reply to Gerald BAEZAThe DDRPERFM is the DDR Performance Monitor embedded in STM32MP1 SOC.
This documentation indicates how to enable stm32-ddr-pmu driver on DDRPERFM peripheral, via the device tree.
--- .../devicetree/bindings/perf/stm32-ddr-pmu.txt | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 Documentation/devicetree/bindings/perf/stm32-ddr-pmu.txt
Documentation/devicetree/bindings/perf/stm32-ddr-pmu.txt new file +18 -0
@@ -0,0 +1,18 @@ +* STM32 DDR Performance Monitor (DDRPERFM) + +Required properties: +- compatible: must be "st,stm32-ddr-pmu". +- reg: physical address and length of the registers set. +- clocks: list of phandles and specifiers to all input clocks listed in + clock-names property. +- clock-names: "bus" corresponds to the DDRPERFM bus clock and "ddr" to + the DDR frequency. + +Example: + ddrperfm: perf@5a007000 { + compatible = "st,stm32-ddr-pmu"; + reg = <0x5a007000 0x400>; + clocks = <&rcc DDRPERFM>, <&rcc PLL2_R>; + clock-names = "bus", "ddr"; + }; +
Signature · 1 line
2.7.4
Rob Herring
maintainerRe: [PATCH 2/5] dt-bindings: perf: stm32: ddrperfm support
Quoted 17 lines · Gerald BAEZA
The DDRPERFM is the DDR Performance Monitor embedded in STM32MP1 SOC.
This documentation indicates how to enable stm32-ddr-pmu driver on DDRPERFM peripheral, via the device tree.
Signed-off-by Gerald Baeza <[email protected]>--- .../devicetree/bindings/perf/stm32-ddr-pmu.txt | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 Documentation/devicetree/bindings/perf/stm32-ddr-pmu.txtDocumentation/devicetree/bindings/perf/stm32-ddr-pmu.txt new file +0
-0
Documentation/devicetree/bindings/perf/stm32-ddr-pmu.txt line 9
Quoted 9 lines
Documentation/devicetree/bindings/perf/stm32-ddr-pmu.txt new file +9
-0@@ -0,0 +1,18 @@ +* STM32 DDR Performance Monitor (DDRPERFM) + +Required properties: +- compatible: must be "st,stm32-ddr-pmu". +- reg: physical address and length of the registers set. +- clocks: list of phandles and specifiers to all input clocks listed in + clock-names property. +- clock-names: "bus" corresponds to the DDRPERFM bus clock and "ddr" to + the DDR frequency.
You have 'resets' in the dts.
Quoted 11 lines
Documentation/devicetree/bindings/perf/stm32-ddr-pmu.txt new file +9
-0+ +Example: + ddrperfm: perf@5a007000 { + compatible = "st,stm32-ddr-pmu"; + reg = <0x5a007000 0x400>; + clocks = <&rcc DDRPERFM>, <&rcc PLL2_R>; + clock-names = "bus", "ddr"; + }; +Signature · 1 line
2.7.4
PATCH 3/5 perf: stm32: ddrperfm driver creation
In reply to Gerald BAEZAThe DDRPERFM is the DDR Performance Monitor embedded in STM32MP1 SOC.
This perf drivers supports the read, write, activate, idle and total time counters, described in the reference manual RM0436.
A 'bandwidth' attribute is added in the 'ddrperfm' event_source in order to directly get the read and write bandwidths (in MB/s), from the last read, write and total time counters reading.
This attribute is aside the 'events' attributes group because it is not a counter, as seen by perf tool.
--- drivers/perf/Kconfig | 6 + drivers/perf/Makefile | 1 + drivers/perf/stm32_ddr_pmu.c | 502 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 509 insertions(+) create mode 100644 drivers/perf/stm32_ddr_pmu.c
drivers/perf/Kconfig +6 -0
@@ -96,6 +96,12 @@ config THUNDERX2_PMU The SoC has PMU support in its L3 cache controller (L3C) and in the DDR4 Memory Controller (DMC). +config STM32_DDR_PMU + tristate "STM32 DDR PMU" + depends on MACH_STM32MP157 + help + Support for STM32 DDR performance monitor (DDRPERFM). + config XGENE_PMU depends on ARCH_XGENE bool "APM X-Gene SoC PMU"
drivers/perf/Makefile +1 -0
@@ -7,6 +7,7 @@ obj-$(CONFIG_ARM_PMU_ACPI) += arm_pmu_acpi.o obj-$(CONFIG_HISI_PMU) += hisilicon/ obj-$(CONFIG_QCOM_L2_PMU) += qcom_l2_pmu.o obj-$(CONFIG_QCOM_L3_PMU) += qcom_l3_pmu.o +obj-$(CONFIG_STM32_DDR_PMU) += stm32_ddr_pmu.o obj-$(CONFIG_THUNDERX2_PMU) += thunderx2_pmu.o obj-$(CONFIG_XGENE_PMU) += xgene_pmu.o obj-$(CONFIG_ARM_SPE_PMU) += arm_spe_pmu.o
drivers/perf/stm32_ddr_pmu.c new file +502 -0
502 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH 4/5 ARM: configs: enable STM32_DDR_PMU
In reply to Gerald BAEZASTM32_DDR_PMU enables the perf driver that
controls the DDR Performance Monitor (DDRPERFM)
--- arch/arm/configs/multi_v7_defconfig | 1 + 1 file changed, 1 insertion(+)
arch/arm/configs/multi_v7_defconfig +1 -0
@@ -979,6 +979,7 @@ CONFIG_PHY_UNIPHIER_USB2=y CONFIG_OMAP_USB2=y CONFIG_TI_PIPE3=y CONFIG_TWL4030_USB=m +CONFIG_STM32_DDR_PMU=m CONFIG_NVMEM_IMX_OCOTP=y CONFIG_NVMEM_SUNXI_SID=y CONFIG_NVMEM_VF610_OCOTP=y
Signature · 1 line
2.7.4
PATCH 5/5 ARM: dts: stm32: add ddrperfm on stm32mp157c
In reply to Gerald BAEZAThe DDRPERFM is the DDR Performance Monitor embedded in STM32MP1 SOC.
--- arch/arm/boot/dts/stm32mp157c.dtsi | 9 +++++++++ 1 file changed, 9 insertions(+)
arch/arm/boot/dts/stm32mp157c.dtsi +9 -0
@@ -1155,6 +1155,15 @@ }; }; + ddrperfm: perf@5a007000 { + compatible = "st,stm32-ddr-pmu"; + reg = <0x5a007000 0x400>; + clocks = <&rcc DDRPERFM>, <&rcc PLL2_R>; + clock-names = "bus", "ddr"; + resets = <&rcc DDRPERFM_R>; + status = "okay"; + }; + usart1: serial@5c000000 { compatible = "st,stm32h7-uart"; reg = <0x5c000000 0x400>;
Signature · 1 line
2.7.4