[2/2] perf/arm-cmn: Implement shutdown method

Message ID 43fb90e6428d0a667deedd3726f462c3c71a8e94.1669822447.git.robin.murphy@arm.com
State New
Headers
Series [1/2] perf/arm-cmn: Cope with spurious IRQs better |

Commit Message

Robin Murphy Nov. 30, 2022, 3:36 p.m. UTC
  Apparently a kexec-induced shutdown does not manage to close perf events
that processes still had open, and thus can leave the PMU running such
that the next kernel may find an overflow interrupt already asserted.
Although the next kernel should ideally be robust aganst that anyway,
let's be polite and disable the PMU to match what we do on remove.

Suggested-by: Geoff Blake <blakgeof@amazon.com>
Signed-off-by: Robin Murphy <robin.murphy@arm.com>
---
 drivers/perf/arm-cmn.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
  

Patch

diff --git a/drivers/perf/arm-cmn.c b/drivers/perf/arm-cmn.c
index 9e8be5586423..0b2df72cee9f 100644
--- a/drivers/perf/arm-cmn.c
+++ b/drivers/perf/arm-cmn.c
@@ -2309,11 +2309,18 @@  static int arm_cmn_probe(struct platform_device *pdev)
 	return err;
 }
 
-static int arm_cmn_remove(struct platform_device *pdev)
+static void arm_cmn_shutdown(struct platform_device *pdev)
 {
 	struct arm_cmn *cmn = platform_get_drvdata(pdev);
 
 	writel_relaxed(0, cmn->dtc[0].base + CMN_DT_DTC_CTL);
+}
+
+static int arm_cmn_remove(struct platform_device *pdev)
+{
+	struct arm_cmn *cmn = platform_get_drvdata(pdev);
+
+	arm_cmn_shutdown(pdev);
 
 	perf_pmu_unregister(&cmn->pmu);
 	cpuhp_state_remove_instance_nocalls(arm_cmn_hp_state, &cmn->cpuhp_node);
@@ -2350,6 +2357,7 @@  static struct platform_driver arm_cmn_driver = {
 	},
 	.probe = arm_cmn_probe,
 	.remove = arm_cmn_remove,
+	.shutdown = arm_cmn_shutdown,
 };
 
 static int __init arm_cmn_init(void)