[PATCH v2 5/5] PM / devfreq: passive: Update frequency when start governor

From: Chanwoo Choi
Date: Sat May 07 2022 - 11:02:27 EST


If the parent device changes the their frequency before registering
the passive device, the passive device cannot receive the notification
from parent device and then the passive device cannot be able to
set the proper frequency according to the frequency of parent device.

So, when start the passive governor, update the frequency
according to the frequency of parent device.

Signed-off-by: Chanwoo Choi <cw00.choi@xxxxxxxxxxx>
---
drivers/devfreq/governor_passive.c | 17 +++++++++++++++++
1 file changed, 17 insertions(+)

diff --git a/drivers/devfreq/governor_passive.c b/drivers/devfreq/governor_passive.c
index b34dbe750c0a..74d26c193fdb 100644
--- a/drivers/devfreq/governor_passive.c
+++ b/drivers/devfreq/governor_passive.c
@@ -412,6 +412,23 @@ static int devfreq_passive_event_handler(struct devfreq *devfreq,
if (!p_data->this)
p_data->this = devfreq;

+ /*
+ * If the parent device changes the their frequency before
+ * registering the passive device, the passive device cannot
+ * receive the notification from parent device and then the
+ * passive device cannot be able to set the proper frequency
+ * according to the frequency of parent device.
+ *
+ * When start the passive governor, update the frequency
+ * according to the frequency of parent device.
+ */
+ mutex_lock(&devfreq->lock);
+ ret = devfreq_update_target(devfreq, parent->previous_freq);
+ if (ret < 0)
+ dev_warn(&devfreq->dev,
+ "failed to update devfreq using passive governor\n");
+ mutex_unlock(&devfreq->lock);
+
if (p_data->parent_type == DEVFREQ_PARENT_DEV)
ret = devfreq_passive_register_notifier(devfreq);
else if (p_data->parent_type == CPUFREQ_PARENT_DEV)
--
2.25.1