From fc520c69712e998b7868dffab86471cdaa2b79e2 Mon Sep 17 00:00:00 2001 From: Lina Iyer Date: Thu, 5 Mar 2020 13:39:08 -0700 Subject: [PATCH] cpuidle: lpm-levels: convert PSCI return value to boolean correctly LPM driver is concerned with the boolean result of the PSCI call. The PSCI error value is not of consequence for further activity. However, it might be helpful to know what the PSCI driver. So, let's log the return value but use the boolean result elsewhere. Change-Id: Ibbc674803da139aef29121d123625661e26bc75d Signed-off-by: Lina Iyer --- drivers/cpuidle/lpm-levels.c | 32 ++++++++++++++-------- include/trace/events/trace_msm_low_power.h | 6 ++-- 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/drivers/cpuidle/lpm-levels.c b/drivers/cpuidle/lpm-levels.c index 39a8f78fe9d3..7c4b7cb5a5ef 100644 --- a/drivers/cpuidle/lpm-levels.c +++ b/drivers/cpuidle/lpm-levels.c @@ -1097,10 +1097,10 @@ unlock_and_return: return state_id; } -static bool psci_enter_sleep(struct lpm_cpu *cpu, int idx, bool from_idle) +static int psci_enter_sleep(struct lpm_cpu *cpu, int idx, bool from_idle) { int affinity_level = 0, state_id = 0, power_state = 0; - bool success = false; + int ret, success; /* * idx = 0 is the default LPM state */ @@ -1109,12 +1109,13 @@ static bool psci_enter_sleep(struct lpm_cpu *cpu, int idx, bool from_idle) stop_critical_timings(); cpu_do_idle(); start_critical_timings(); - return true; + return 0; } if (from_idle && cpu->levels[idx].use_bc_timer) { - if (tick_broadcast_enter()) - return success; + ret = tick_broadcast_enter(); + if (ret) + return ret; } state_id = get_cluster_id(cpu->parent, &affinity_level, from_idle); @@ -1126,7 +1127,8 @@ static bool psci_enter_sleep(struct lpm_cpu *cpu, int idx, bool from_idle) 0xdeaffeed, 0xdeaffeed, from_idle); stop_critical_timings(); - success = !psci_cpu_suspend_enter(state_id); + ret = psci_cpu_suspend_enter(state_id); + success = (ret == 0); start_critical_timings(); update_debug_pc_event(CPU_EXIT, state_id, @@ -1135,7 +1137,7 @@ static bool psci_enter_sleep(struct lpm_cpu *cpu, int idx, bool from_idle) if (from_idle && cpu->levels[idx].use_bc_timer) tick_broadcast_exit(); - return success; + return ret; } static int lpm_cpuidle_select(struct cpuidle_driver *drv, @@ -1191,6 +1193,7 @@ static int lpm_cpuidle_enter(struct cpuidle_device *dev, const struct cpumask *cpumask = get_cpu_mask(dev->cpu); ktime_t start = ktime_get(); uint64_t start_time = ktime_to_ns(start), end_time; + int ret = -EBUSY; cpu_prepare(cpu, idx, true); cluster_prepare(cpu->parent, cpumask, idx, true, start_time); @@ -1201,7 +1204,8 @@ static int lpm_cpuidle_enter(struct cpuidle_device *dev, if (need_resched()) goto exit; - success = psci_enter_sleep(cpu, idx, true); + ret = psci_enter_sleep(cpu, idx, true); + success = (ret == 0); exit: end_time = ktime_to_ns(ktime_get()); @@ -1211,7 +1215,7 @@ exit: cpu_unprepare(cpu, idx, true); dev->last_residency = ktime_us_delta(ktime_get(), start); update_history(dev, idx); - trace_cpu_idle_exit(idx, success); + trace_cpu_idle_exit(idx, ret); if (lpm_prediction && cpu->lpm_prediction) { histtimer_cancel(); clusttimer_cancel(); @@ -1225,7 +1229,8 @@ static void lpm_cpuidle_s2idle(struct cpuidle_device *dev, { struct lpm_cpu *cpu = per_cpu(cpu_lpm, dev->cpu); const struct cpumask *cpumask = get_cpu_mask(dev->cpu); - bool success = false; + bool success; + int ret; for (; idx >= 0; idx--) { if (lpm_cpu_mode_allow(dev->cpu, idx, false)) @@ -1239,7 +1244,8 @@ static void lpm_cpuidle_s2idle(struct cpuidle_device *dev, cpu_prepare(cpu, idx, true); cluster_prepare(cpu->parent, cpumask, idx, false, 0); - success = psci_enter_sleep(cpu, idx, false); + ret = psci_enter_sleep(cpu, idx, false); + success = (ret == 0); cluster_unprepare(cpu->parent, cpumask, idx, false, 0, success); cpu_unprepare(cpu, idx, true); @@ -1443,6 +1449,7 @@ static int lpm_suspend_enter(suspend_state_t state) const struct cpumask *cpumask = get_cpu_mask(cpu); int idx; bool success; + int ret; for (idx = lpm_cpu->nlevels - 1; idx >= 0; idx--) { if (lpm_cpu_mode_allow(cpu, idx, false)) @@ -1455,7 +1462,8 @@ static int lpm_suspend_enter(suspend_state_t state) cpu_prepare(lpm_cpu, idx, false); cluster_prepare(cluster, cpumask, idx, false, 0); - success = psci_enter_sleep(lpm_cpu, idx, false); + ret = psci_enter_sleep(lpm_cpu, idx, false); + success = (ret == 0); cluster_unprepare(cluster, cpumask, idx, false, 0, success); cpu_unprepare(lpm_cpu, idx, false); diff --git a/include/trace/events/trace_msm_low_power.h b/include/trace/events/trace_msm_low_power.h index bae810cb4231..755d69a2069f 100644 --- a/include/trace/events/trace_msm_low_power.h +++ b/include/trace/events/trace_msm_low_power.h @@ -1,7 +1,7 @@ /* SPDX-License-Identifier: GPL-2.0-only */ /* - * Copyright (c) 2016-2019, The Linux Foundation. All rights reserved. + * Copyright (c) 2016-2020, The Linux Foundation. All rights reserved. */ #undef TRACE_SYSTEM @@ -105,13 +105,13 @@ TRACE_EVENT(cpu_idle_enter, TRACE_EVENT(cpu_idle_exit, - TP_PROTO(int index, bool success), + TP_PROTO(int index, int success), TP_ARGS(index, success), TP_STRUCT__entry( __field(int, index) - __field(bool, success) + __field(int, success) ), TP_fast_assign(