All of lore.kernel.org
 help / color / mirror / Atom feed
From: Di Shen <di.shen@unisoc.com>
To: <lukasz.luba@arm.com>, <amitk@kernel.org>, <rui.zhang@intel.com>
Cc: <amit.kachhap@gmail.com>, <daniel.lezcano@linaro.org>,
	<viresh.kumar@linaro.org>, <rafael@kernel.org>,
	<linux-pm@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<xuewen.yan@unisoc.com>, <xuewen.yan94@gmail.com>
Subject: [PATCH] thermal: cpufreq_cooling: Avoid all cluster using global cooling_ops
Date: Mon, 18 Jul 2022 20:24:19 +0800	[thread overview]
Message-ID: <20220718122419.9409-1-di.shen@unisoc.com> (raw)

Now, all the cooling device use the globle cpufreq_cooling_ops. When the
CONFIG_THERMAL_GOV_POWER_ALLOCATOR is enabled, once one cluster init the
cpufreq_cooling_ops, it would make all cooling device use the power allocator's
ops. If one's em is error because of the "em_is_sane", it would cause the
em NULL, but the cooling device's ops is exist, as a result, it would cause
panic because of the em.

Add cpufreq_power_cooling_ops to avoid this case.

Signed-off-by: Di Shen <di.shen@unisoc.com>
Signed-off-by: Xuewen Yan <xuewen.yan@unisoc.com>
---
 drivers/thermal/cpufreq_cooling.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/drivers/thermal/cpufreq_cooling.c b/drivers/thermal/cpufreq_cooling.c
index b8151d95a806..af5cfb458370 100644
--- a/drivers/thermal/cpufreq_cooling.c
+++ b/drivers/thermal/cpufreq_cooling.c
@@ -493,6 +493,17 @@ static struct thermal_cooling_device_ops cpufreq_cooling_ops = {
 	.set_cur_state		= cpufreq_set_cur_state,
 };
 
+#ifdef CONFIG_THERMAL_GOV_POWER_ALLOCATOR
+static struct thermal_cooling_device_ops cpufreq_power_cooling_ops = {
+	.get_max_state		= cpufreq_get_max_state,
+	.get_cur_state		= cpufreq_get_cur_state,
+	.set_cur_state		= cpufreq_set_cur_state,
+	.get_requested_power	= cpufreq_get_requested_power,
+	.state2power		= cpufreq_state2power,
+	.power2state		= cpufreq_power2state,
+};
+#endif
+
 /**
  * __cpufreq_cooling_register - helper function to create cpufreq cooling device
  * @np: a valid struct device_node to the cooling device device tree node
@@ -559,9 +570,7 @@ __cpufreq_cooling_register(struct device_node *np,
 #ifdef CONFIG_THERMAL_GOV_POWER_ALLOCATOR
 	if (em_is_sane(cpufreq_cdev, em)) {
 		cpufreq_cdev->em = em;
-		cooling_ops->get_requested_power = cpufreq_get_requested_power;
-		cooling_ops->state2power = cpufreq_state2power;
-		cooling_ops->power2state = cpufreq_power2state;
+		cooling_ops = &cpufreq_power_cooling_ops;
 	} else
 #endif
 	if (policy->freq_table_sorted == CPUFREQ_TABLE_UNSORTED) {
-- 
2.17.1


             reply	other threads:[~2022-07-18 12:26 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-18 12:24 Di Shen [this message]
2022-07-19  4:14 ` [PATCH] thermal: cpufreq_cooling: Avoid all cluster using global cooling_ops Viresh Kumar
2022-07-19  9:24   ` Di Shen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220718122419.9409-1-di.shen@unisoc.com \
    --to=di.shen@unisoc.com \
    --cc=amit.kachhap@gmail.com \
    --cc=amitk@kernel.org \
    --cc=daniel.lezcano@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=lukasz.luba@arm.com \
    --cc=rafael@kernel.org \
    --cc=rui.zhang@intel.com \
    --cc=viresh.kumar@linaro.org \
    --cc=xuewen.yan94@gmail.com \
    --cc=xuewen.yan@unisoc.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.