* [PATCHv3 0/2] Improved perf support for imx53/ppd
@ 2018-02-09 17:03 Sebastian Reichel
2018-02-09 17:03 ` [PATCHv3 1/2] ARM: imx53: add secure-reg-access support for PMU Sebastian Reichel
2018-02-09 17:03 ` [PATCHv3 2/2] ARM: dts: imx53: PPD: Enable secure-reg-access Sebastian Reichel
0 siblings, 2 replies; 5+ messages in thread
From: Sebastian Reichel @ 2018-02-09 17:03 UTC (permalink / raw)
To: Shawn Guo, Sascha Hauer, Fabio Estevam, Will Deacon, Mark Rutland
Cc: Russell King, Ian Ray, Nandor Han, linux-arm-kernel,
linux-kernel, kernel
Hi,
This improves perf on imx53 by adding support for enabling the Secure
Debug Enable Register (SDER) SUNIDEN bit. This unlocks new
functionality:
ppd before patchset# perf stat -e cycles,instructions sleep 1 2>&1 | grep instructions
0 instructions # 0.00 insn per cycle
ppd after patchset# perf stat -e cycles,instructions sleep 1 2>&1 | grep instructions
177864 instructions # 0.05 insn per cycle
Changes since PATCHv2:
* Always enable GPC_DBG_EN when kernel configuration allows using perf
to allow cleanup of the arm-pmu driver.
Changes since PATCHv1:
* Update DTS patch to reference imx53.dtsi's pmu node
* Remove a superfluous newline in first patch
-- Sebastian
Sebastian Reichel (2):
ARM: imx53: add secure-reg-access support for PMU
ARM: dts: imx53: PPD: Enable secure-reg-access
arch/arm/boot/dts/imx53-ppd.dts | 4 ++++
arch/arm/boot/dts/imx53.dtsi | 2 +-
arch/arm/mach-imx/mach-imx53.c | 41 ++++++++++++++++++++++++++++++++++++++++-
3 files changed, 45 insertions(+), 2 deletions(-)
--
2.15.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCHv3 1/2] ARM: imx53: add secure-reg-access support for PMU
2018-02-09 17:03 [PATCHv3 0/2] Improved perf support for imx53/ppd Sebastian Reichel
@ 2018-02-09 17:03 ` Sebastian Reichel
2018-02-09 20:08 ` Fabio Estevam
2018-02-09 17:03 ` [PATCHv3 2/2] ARM: dts: imx53: PPD: Enable secure-reg-access Sebastian Reichel
1 sibling, 1 reply; 5+ messages in thread
From: Sebastian Reichel @ 2018-02-09 17:03 UTC (permalink / raw)
To: Shawn Guo, Sascha Hauer, Fabio Estevam, Will Deacon, Mark Rutland
Cc: Russell King, Ian Ray, Nandor Han, linux-arm-kernel,
linux-kernel, kernel, Sebastian Reichel
On i.MX53 it is necessary to set the DBG_EN bit in the
platform GPC register to enable access to PMU counters
other than the cycle counter.
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
---
arch/arm/mach-imx/mach-imx53.c | 41 ++++++++++++++++++++++++++++++++++++++++-
1 file changed, 40 insertions(+), 1 deletion(-)
diff --git a/arch/arm/mach-imx/mach-imx53.c b/arch/arm/mach-imx/mach-imx53.c
index 07c2e8dca494..661777ee1cc4 100644
--- a/arch/arm/mach-imx/mach-imx53.c
+++ b/arch/arm/mach-imx/mach-imx53.c
@@ -28,10 +28,49 @@ static void __init imx53_init_early(void)
mxc_set_cpu_type(MXC_CPU_MX53);
}
+#define MXC_CORTEXA8_PLAT_GPC 0x63fa0004
+#define GPC_DBG_EN BIT(16)
+
+/*
+ * This enables the DBGEN bit in ARM_GPC register, which is
+ * required for accessing some performance counter features.
+ * Technically it is only required while perf is used, but to
+ * keep the source code simple we just enable it all the time
+ * when the kernel configuration allows using the feature.
+ */
+static void imx53_pmu_init(void)
+{
+ void __iomem *gpc_reg;
+ struct device_node *node;
+ u32 gpc;
+
+ if (!IS_ENABLED(CONFIG_ARM_PMU))
+ return;
+
+ node = of_find_compatible_node(NULL, NULL, "arm,cortex-a8-pmu");
+ if (!node)
+ return;
+
+ if (!of_property_read_bool(node, "secure-reg-access"))
+ return;
+
+ gpc_reg = ioremap(MXC_CORTEXA8_PLAT_GPC, 4);
+ if (!gpc_reg) {
+ pr_warning("unable to map GPC to enable perf\n");
+ return;
+ }
+
+ gpc = __raw_readl(gpc_reg);
+ gpc |= GPC_DBG_EN;
+ __raw_writel(gpc, gpc_reg);
+
+ return;
+}
+
static void __init imx53_dt_init(void)
{
imx_src_init();
-
+ imx53_pmu_init();
imx_aips_allow_unprivileged_access("fsl,imx53-aipstz");
}
--
2.15.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCHv3 2/2] ARM: dts: imx53: PPD: Enable secure-reg-access
2018-02-09 17:03 [PATCHv3 0/2] Improved perf support for imx53/ppd Sebastian Reichel
2018-02-09 17:03 ` [PATCHv3 1/2] ARM: imx53: add secure-reg-access support for PMU Sebastian Reichel
@ 2018-02-09 17:03 ` Sebastian Reichel
2018-02-09 20:08 ` Fabio Estevam
1 sibling, 1 reply; 5+ messages in thread
From: Sebastian Reichel @ 2018-02-09 17:03 UTC (permalink / raw)
To: Shawn Guo, Sascha Hauer, Fabio Estevam, Will Deacon, Mark Rutland
Cc: Russell King, Ian Ray, Nandor Han, linux-arm-kernel,
linux-kernel, kernel, Sebastian Reichel
Add secure-reg-access on PPD device tree to enable PMU and
hardware counters for perf.
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
---
arch/arm/boot/dts/imx53-ppd.dts | 4 ++++
arch/arm/boot/dts/imx53.dtsi | 2 +-
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/arch/arm/boot/dts/imx53-ppd.dts b/arch/arm/boot/dts/imx53-ppd.dts
index cce959438a79..4ecbe6e4eecb 100644
--- a/arch/arm/boot/dts/imx53-ppd.dts
+++ b/arch/arm/boot/dts/imx53-ppd.dts
@@ -556,6 +556,10 @@
};
};
+&pmu {
+ secure-reg-access;
+};
+
&pwm1 {
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_pwm1>;
diff --git a/arch/arm/boot/dts/imx53.dtsi b/arch/arm/boot/dts/imx53.dtsi
index 1040251f2951..7df4853dc771 100644
--- a/arch/arm/boot/dts/imx53.dtsi
+++ b/arch/arm/boot/dts/imx53.dtsi
@@ -116,7 +116,7 @@
};
};
- pmu {
+ pmu: pmu {
compatible = "arm,cortex-a8-pmu";
interrupt-parent = <&tzic>;
interrupts = <77>;
--
2.15.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCHv3 1/2] ARM: imx53: add secure-reg-access support for PMU
2018-02-09 17:03 ` [PATCHv3 1/2] ARM: imx53: add secure-reg-access support for PMU Sebastian Reichel
@ 2018-02-09 20:08 ` Fabio Estevam
0 siblings, 0 replies; 5+ messages in thread
From: Fabio Estevam @ 2018-02-09 20:08 UTC (permalink / raw)
To: Sebastian Reichel
Cc: Shawn Guo, Sascha Hauer, Fabio Estevam, Will Deacon,
Mark Rutland, linux-kernel, Russell King, Ian Ray, Nandor Han,
kernel, moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE
On Fri, Feb 9, 2018 at 3:03 PM, Sebastian Reichel
<sebastian.reichel@collabora.co.uk> wrote:
> + gpc_reg = ioremap(MXC_CORTEXA8_PLAT_GPC, 4);
> + if (!gpc_reg) {
> + pr_warning("unable to map GPC to enable perf\n");
> + return;
> + }
> +
> + gpc = __raw_readl(gpc_reg);
You could use readl_relaxed() instead.
> + gpc |= GPC_DBG_EN;
> + __raw_writel(gpc, gpc_reg);
You could use writel_relaxed() instead.
> +
> + return;
This 'return' can be removed.
> +}
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCHv3 2/2] ARM: dts: imx53: PPD: Enable secure-reg-access
2018-02-09 17:03 ` [PATCHv3 2/2] ARM: dts: imx53: PPD: Enable secure-reg-access Sebastian Reichel
@ 2018-02-09 20:08 ` Fabio Estevam
0 siblings, 0 replies; 5+ messages in thread
From: Fabio Estevam @ 2018-02-09 20:08 UTC (permalink / raw)
To: Sebastian Reichel
Cc: Shawn Guo, Sascha Hauer, Fabio Estevam, Will Deacon,
Mark Rutland, linux-kernel, Russell King, Ian Ray, Nandor Han,
kernel, moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE
On Fri, Feb 9, 2018 at 3:03 PM, Sebastian Reichel
<sebastian.reichel@collabora.co.uk> wrote:
> Add secure-reg-access on PPD device tree to enable PMU and
> hardware counters for perf.
>
> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
Reviewed-by: Fabio Estevam <fabio.estevam@nxp.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2018-02-09 20:08 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-09 17:03 [PATCHv3 0/2] Improved perf support for imx53/ppd Sebastian Reichel
2018-02-09 17:03 ` [PATCHv3 1/2] ARM: imx53: add secure-reg-access support for PMU Sebastian Reichel
2018-02-09 20:08 ` Fabio Estevam
2018-02-09 17:03 ` [PATCHv3 2/2] ARM: dts: imx53: PPD: Enable secure-reg-access Sebastian Reichel
2018-02-09 20:08 ` Fabio Estevam
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).