diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c index 0bfabee0578a..4dd752c4fbf2 100644 --- a/drivers/android/vendor_hooks.c +++ b/drivers/android/vendor_hooks.c @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -104,6 +105,8 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_cgroup_attach); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_iommu_setup_dma_ops); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_iommu_iovad_alloc_iova); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_iommu_iovad_free_iova); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_psci_tos_resident_on); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_psci_cpu_suspend); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_ptype_head); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_allow_domain_state); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_cpuidle_psci_enter); diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c index 2328ca58bba6..e2125e7a5307 100644 --- a/drivers/firmware/psci/psci.c +++ b/drivers/firmware/psci/psci.c @@ -28,6 +28,7 @@ #include #include #include +#include /* * While a 64-bit OS can make calls with SMC32 calling conventions, for some @@ -53,6 +54,12 @@ static enum arm_smccc_conduit psci_conduit = SMCCC_CONDUIT_NONE; bool psci_tos_resident_on(int cpu) { + bool resident = false; + + trace_android_rvh_psci_tos_resident_on(cpu, &resident); + if (resident) + return resident; + return cpu == resident_cpu; } @@ -176,6 +183,11 @@ static __always_inline int __psci_cpu_suspend(u32 fn, u32 state, unsigned long entry_point) { int err; + bool deny = false; + + trace_android_rvh_psci_cpu_suspend(state, &deny); + if (deny) + return -EPERM; err = invoke_psci_fn(fn, state, entry_point, 0); return psci_to_linux_errno(err); diff --git a/include/trace/hooks/psci.h b/include/trace/hooks/psci.h new file mode 100644 index 000000000000..43c169c90ede --- /dev/null +++ b/include/trace/hooks/psci.h @@ -0,0 +1,26 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#undef TRACE_SYSTEM +#define TRACE_SYSTEM psci +#undef TRACE_INCLUDE_PATH + +#define TRACE_INCLUDE_PATH trace/hooks + +#if !defined(_TRACE_HOOK_PSCI_H) || defined(TRACE_HEADER_MULTI_READ) +#define _TRACE_HOOK_PSCI_H + +#include + +DECLARE_HOOK(android_rvh_psci_tos_resident_on, + TP_PROTO(int cpu, bool *resident), + TP_ARGS(cpu, resident)); + +DECLARE_HOOK(android_rvh_psci_cpu_suspend, + TP_PROTO(u32 state, bool *deny), + TP_ARGS(state, deny)); + +/* macro versions of hooks are no longer required */ + +#endif /* _TRACE_HOOK_PSCI_H */ +/* This part must be outside protection */ +#include +