From 35ce1503cf7c9cacd3ea4a409bbe9aa10139ca4e Mon Sep 17 00:00:00 2001 From: Maulik Shah Date: Mon, 21 Nov 2022 15:47:34 +0530 Subject: [PATCH] cpuidle: governors: qcom-lpm: Misc Fixes This change fixes below items 1. Update cluster governors's now time stamp if CPU is of same cluster 2. Remove unnecessary condition from CPU idle state select 3. Skip updating cpu prediction history when sleep is disabled Change-Id: I3f2870adf0b4005ca8cd02f2d355647a9c4ecd1a Signed-off-by: Maulik Shah --- drivers/cpuidle/governors/qcom-cluster-lpm.c | 7 ++++--- drivers/cpuidle/governors/qcom-lpm.c | 5 +++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/cpuidle/governors/qcom-cluster-lpm.c b/drivers/cpuidle/governors/qcom-cluster-lpm.c index d3f6202926f6..54be4cec2cde 100644 --- a/drivers/cpuidle/governors/qcom-cluster-lpm.c +++ b/drivers/cpuidle/governors/qcom-cluster-lpm.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2021, The Linux Foundation. All rights reserved. + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. */ #include @@ -390,14 +391,14 @@ void update_cluster_select(struct lpm_cpu *cpu_gov) if (!cluster_gov->initialized) continue; - spin_lock(&cluster_gov->lock); - cluster_gov->now = cpu_gov->now; genpd = cluster_gov->genpd; if (cpumask_test_cpu(cpu, genpd->cpus)) { + spin_lock(&cluster_gov->lock); + cluster_gov->now = cpu_gov->now; cluster_gov->cpu_next_wakeup[cpu] = cpu_gov->next_wakeup; update_cluster_next_wakeup(cluster_gov); + spin_unlock(&cluster_gov->lock); } - spin_unlock(&cluster_gov->lock); } } diff --git a/drivers/cpuidle/governors/qcom-lpm.c b/drivers/cpuidle/governors/qcom-lpm.c index 3158de1c765b..d969bb58f902 100644 --- a/drivers/cpuidle/governors/qcom-lpm.c +++ b/drivers/cpuidle/governors/qcom-lpm.c @@ -345,7 +345,8 @@ static void update_cpu_history(struct lpm_cpu *cpu_gov) u64 measured_us = ktime_to_us(cpu_gov->dev->last_residency_ns); struct cpuidle_state *target; - if (prediction_disabled || idx < 0 || idx > cpu_gov->drv->state_count - 1) + if (sleep_disabled || prediction_disabled || idx < 0 || + idx > cpu_gov->drv->state_count - 1) return; target = &cpu_gov->drv->states[idx]; @@ -568,7 +569,7 @@ static int lpm_select(struct cpuidle_driver *drv, struct cpuidle_device *dev, for (i = drv->state_count - 1; i > 0; i--) { struct cpuidle_state *s = &drv->states[i]; - if (i && dev->states_usage[i].disable) { + if (dev->states_usage[i].disable) { reason |= UPDATE_REASON(i, LPM_SELECT_STATE_DISABLED); continue; }