ANDROID: vendor_hooks: psci: add hook to check if cpu is allowed to power off
While TOS is running alongside with linux, cpu power off operation by linux may need be denied by TOS in some scenarios. This patch added two hooks in psci_tos_resident_on and psci_cpu_suspend to hook cpu off operation. The function psci_tos_resident_on originally is used to check if TOS is resident on a specific cpu and that cpu is dedicated for running TOS exclusively. If so, that cpu can not be power off. Actually if TOS supports SMP, TOS may need deny any other cpu to power down in some cases, i.e. there are no-expired timers in TOS. Thus the first hook for psci_tos_resident_on is used to determine if the specific cpu is allowed to power off in the cpu hotplug path. Besides cpu hotplug, a cpu also can power off by cpu_suspend. The second hook for psci_cpu_suspend determines if cpu suspend should go through or not. When the same conditions described above meets, cpu suspend will break up. The hook cherry-pick from commit 88d88955ae0b8b1f1a555d7810beb6c8ca4ca0f1 and changed vh to rvh according to commit 949edf7539b60058cf2da98f24db2b6d4d89eaa0 Bug: 284797902 Change-Id: Ib329beeff20f0cfef263f6a7813280d33f6a5eaa Signed-off-by: Jian Gong <Jian.Gong@unisoc.com> Signed-off-by: Cixi Geng <cixi.geng1@unisoc.com>
This commit is contained in:
parent
3be7d118e7
commit
b7a7fd15ed
@ -62,6 +62,7 @@
|
||||
#include <trace/hooks/typec.h>
|
||||
#include <trace/hooks/user.h>
|
||||
#include <trace/hooks/signal.h>
|
||||
#include <trace/hooks/psci.h>
|
||||
#include <trace/hooks/psi.h>
|
||||
|
||||
/*
|
||||
@ -258,6 +259,8 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_shrink_slab_bypass);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_do_shrink_slab);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_get_page_wmark);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_page_add_new_anon_rmap);
|
||||
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_psi_event);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_psi_group);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_cpufreq_acct_update_power);
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include <asm/system_misc.h>
|
||||
#include <asm/smp_plat.h>
|
||||
#include <asm/suspend.h>
|
||||
#include <trace/hooks/psci.h>
|
||||
|
||||
/*
|
||||
* 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;
|
||||
}
|
||||
|
||||
@ -175,6 +182,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);
|
||||
|
25
include/trace/hooks/psci.h
Normal file
25
include/trace/hooks/psci.h
Normal file
@ -0,0 +1,25 @@
|
||||
/* 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 <trace/hooks/vendor_hooks.h>
|
||||
|
||||
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 <trace/define_trace.h>
|
Loading…
Reference in New Issue
Block a user