linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/11] PM / devfreq: a few small fixes and improvements
@ 2021-03-09 12:58 Dong Aisheng
  2021-03-09 12:58 ` [PATCH 01/11] doc: ABI: devfreq: remove invalid central_polling description Dong Aisheng
                   ` (22 more replies)
  0 siblings, 23 replies; 58+ messages in thread
From: Dong Aisheng @ 2021-03-09 12:58 UTC (permalink / raw)
  To: linux-pm, linux-arm-kernel
  Cc: dongas86, kernel, shawnguo, linux-imx, linux-kernel,
	myungjoo.ham, kyungmin.park, cw00.choi, abel.vesa, Dong Aisheng

A few small fixes and improvements

Dong Aisheng (11):
  doc: ABI: devfreq: remove invalid central_polling description
  PM / devfreq: remove the invalid description for get_target_freq
  PM / devfreq: fix the wrong set_freq path for userspace governor
  PM / devfreq: bail out early if no freq changes in devfreq_set_target
  PM / devfreq: use more accurate returned new_freq as resume_freq
  PM / devfreq: drop the unnecessary low variable initialization
  PM / devfreq: check get_dev_status before start monitor
  PM / devfreq: check get_dev_status in devfreq_update_stats
  PM / devfreq: governor: optimize simpleondemand get_target_freq
  PM / devfreq: imx8m-ddrc: remove imx8m_ddrc_get_dev_status
  PM / devfreq: imx8m-ddrc: drop polling_ms

 Documentation/ABI/testing/sysfs-class-devfreq |  5 +-
 drivers/devfreq/Kconfig                       |  2 +-
 drivers/devfreq/devfreq.c                     | 21 +++++---
 drivers/devfreq/governor.h                    |  7 +--
 drivers/devfreq/governor_simpleondemand.c     | 53 ++++++++++++-------
 drivers/devfreq/imx8m-ddrc.c                  | 14 -----
 6 files changed, 55 insertions(+), 47 deletions(-)

-- 
2.25.1


^ permalink raw reply	[flat|nested] 58+ messages in thread

* [PATCH 01/11] doc: ABI: devfreq: remove invalid central_polling description
  2021-03-09 12:58 [PATCH 00/11] PM / devfreq: a few small fixes and improvements Dong Aisheng
@ 2021-03-09 12:58 ` Dong Aisheng
  2021-03-09 15:01   ` Chanwoo Choi
  2021-03-09 12:58 ` [PATCH 02/11] PM / devfreq: remove the invalid description for get_target_freq Dong Aisheng
                   ` (21 subsequent siblings)
  22 siblings, 1 reply; 58+ messages in thread
From: Dong Aisheng @ 2021-03-09 12:58 UTC (permalink / raw)
  To: linux-pm, linux-arm-kernel
  Cc: dongas86, kernel, shawnguo, linux-imx, linux-kernel,
	myungjoo.ham, kyungmin.park, cw00.choi, abel.vesa, Dong Aisheng

no_central_polling has been removed since
commit 7e6fdd4bad03 ("PM / devfreq: Core updates to support devices
which can idle")

Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
---
 Documentation/ABI/testing/sysfs-class-devfreq | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/Documentation/ABI/testing/sysfs-class-devfreq b/Documentation/ABI/testing/sysfs-class-devfreq
index 386bc230a33d..5e6b74f30406 100644
--- a/Documentation/ABI/testing/sysfs-class-devfreq
+++ b/Documentation/ABI/testing/sysfs-class-devfreq
@@ -97,10 +97,7 @@ Description:
 		object. The values are represented in ms. If the value is
 		less than 1 jiffy, it is considered to be 0, which means
 		no polling. This value is meaningless if the governor is
-		not polling; thus. If the governor is not using
-		devfreq-provided central polling
-		(/sys/class/devfreq/.../central_polling is 0), this value
-		may be useless.
+		not polling.
 
 		A list of governors that support the node:
 		- simple_ondmenad
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 02/11] PM / devfreq: remove the invalid description for get_target_freq
  2021-03-09 12:58 [PATCH 00/11] PM / devfreq: a few small fixes and improvements Dong Aisheng
  2021-03-09 12:58 ` [PATCH 01/11] doc: ABI: devfreq: remove invalid central_polling description Dong Aisheng
@ 2021-03-09 12:58 ` Dong Aisheng
  2021-03-09 15:02   ` Chanwoo Choi
  2021-03-09 12:58 ` [PATCH 03/11] PM / devfreq: fix the wrong set_freq path for userspace governor Dong Aisheng
                   ` (20 subsequent siblings)
  22 siblings, 1 reply; 58+ messages in thread
From: Dong Aisheng @ 2021-03-09 12:58 UTC (permalink / raw)
  To: linux-pm, linux-arm-kernel
  Cc: dongas86, kernel, shawnguo, linux-imx, linux-kernel,
	myungjoo.ham, kyungmin.park, cw00.choi, abel.vesa, Dong Aisheng

First of all, no_central_polling was removed since
commit 7e6fdd4bad03 ("PM / devfreq: Core updates to support devices
which can idle")
Secondly, get_target_freq() is not only called only with update_devfreq()
notified by OPP now, but also min/max freq qos notifier.

So remove this invalid description now to avoid confusing.

Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
---
 drivers/devfreq/governor.h | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/devfreq/governor.h b/drivers/devfreq/governor.h
index 70f44b3ca42e..5cee3f64fe2b 100644
--- a/drivers/devfreq/governor.h
+++ b/drivers/devfreq/governor.h
@@ -57,8 +57,6 @@
  *			Basically, get_target_freq will run
  *			devfreq_dev_profile.get_dev_status() to get the
  *			status of the device (load = busy_time / total_time).
- *			If no_central_polling is set, this callback is called
- *			only with update_devfreq() notified by OPP.
  * @event_handler:      Callback for devfreq core framework to notify events
  *                      to governors. Events include per device governor
  *                      init and exit, opp changes out of devfreq, suspend
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 03/11] PM / devfreq: fix the wrong set_freq path for userspace governor
  2021-03-09 12:58 [PATCH 00/11] PM / devfreq: a few small fixes and improvements Dong Aisheng
  2021-03-09 12:58 ` [PATCH 01/11] doc: ABI: devfreq: remove invalid central_polling description Dong Aisheng
  2021-03-09 12:58 ` [PATCH 02/11] PM / devfreq: remove the invalid description for get_target_freq Dong Aisheng
@ 2021-03-09 12:58 ` Dong Aisheng
  2021-03-09 15:13   ` Chanwoo Choi
  2021-03-09 12:58 ` [PATCH 04/11] PM / devfreq: bail out early if no freq changes in devfreq_set_target Dong Aisheng
                   ` (19 subsequent siblings)
  22 siblings, 1 reply; 58+ messages in thread
From: Dong Aisheng @ 2021-03-09 12:58 UTC (permalink / raw)
  To: linux-pm, linux-arm-kernel
  Cc: dongas86, kernel, shawnguo, linux-imx, linux-kernel,
	myungjoo.ham, kyungmin.park, cw00.choi, abel.vesa, Dong Aisheng

Fix the wrong set_freq path for userspace governor.

Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
---
 drivers/devfreq/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/devfreq/Kconfig b/drivers/devfreq/Kconfig
index 00704efe6398..20373a893b44 100644
--- a/drivers/devfreq/Kconfig
+++ b/drivers/devfreq/Kconfig
@@ -62,7 +62,7 @@ config DEVFREQ_GOV_USERSPACE
 	help
 	  Sets the frequency at the user specified one.
 	  This governor returns the user configured frequency if there
-	  has been an input to /sys/devices/.../power/devfreq_set_freq.
+	  has been an input to /sys/devices/.../userspace/set_freq.
 	  Otherwise, the governor does not change the frequency
 	  given at the initialization.
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 04/11] PM / devfreq: bail out early if no freq changes in devfreq_set_target
  2021-03-09 12:58 [PATCH 00/11] PM / devfreq: a few small fixes and improvements Dong Aisheng
                   ` (2 preceding siblings ...)
  2021-03-09 12:58 ` [PATCH 03/11] PM / devfreq: fix the wrong set_freq path for userspace governor Dong Aisheng
@ 2021-03-09 12:58 ` Dong Aisheng
  2021-03-09 15:47   ` Chanwoo Choi
  2021-03-09 12:58 ` [PATCH 05/11] PM / devfreq: use more accurate returned new_freq as resume_freq Dong Aisheng
                   ` (18 subsequent siblings)
  22 siblings, 1 reply; 58+ messages in thread
From: Dong Aisheng @ 2021-03-09 12:58 UTC (permalink / raw)
  To: linux-pm, linux-arm-kernel
  Cc: dongas86, kernel, shawnguo, linux-imx, linux-kernel,
	myungjoo.ham, kyungmin.park, cw00.choi, abel.vesa, Dong Aisheng

It's unnecessary to set the same freq again and run notifier calls.

Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
---
 drivers/devfreq/devfreq.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
index bf3047896e41..6e80bf70e7b3 100644
--- a/drivers/devfreq/devfreq.c
+++ b/drivers/devfreq/devfreq.c
@@ -358,6 +358,9 @@ static int devfreq_set_target(struct devfreq *devfreq, unsigned long new_freq,
 	else
 		cur_freq = devfreq->previous_freq;
 
+	if (new_freq == cur_freq)
+		return 0;
+
 	freqs.old = cur_freq;
 	freqs.new = new_freq;
 	devfreq_notify_transition(devfreq, &freqs, DEVFREQ_PRECHANGE);
@@ -374,7 +377,7 @@ static int devfreq_set_target(struct devfreq *devfreq, unsigned long new_freq,
 	 * and DEVFREQ_POSTCHANGE because for showing the correct frequency
 	 * change order of between devfreq device and passive devfreq device.
 	 */
-	if (trace_devfreq_frequency_enabled() && new_freq != cur_freq)
+	if (trace_devfreq_frequency_enabled())
 		trace_devfreq_frequency(devfreq, new_freq, cur_freq);
 
 	freqs.new = new_freq;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 05/11] PM / devfreq: use more accurate returned new_freq as resume_freq
  2021-03-09 12:58 [PATCH 00/11] PM / devfreq: a few small fixes and improvements Dong Aisheng
                   ` (3 preceding siblings ...)
  2021-03-09 12:58 ` [PATCH 04/11] PM / devfreq: bail out early if no freq changes in devfreq_set_target Dong Aisheng
@ 2021-03-09 12:58 ` Dong Aisheng
  2021-03-09 15:53   ` Chanwoo Choi
  2021-03-09 12:58 ` [PATCH 06/11] PM / devfreq: drop the unnecessary low variable initialization Dong Aisheng
                   ` (17 subsequent siblings)
  22 siblings, 1 reply; 58+ messages in thread
From: Dong Aisheng @ 2021-03-09 12:58 UTC (permalink / raw)
  To: linux-pm, linux-arm-kernel
  Cc: dongas86, kernel, shawnguo, linux-imx, linux-kernel,
	myungjoo.ham, kyungmin.park, cw00.choi, abel.vesa, Dong Aisheng

Use the more accurate returned new_freq as resume_freq.
It's the same as how devfreq->previous_freq was updated.

Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
---
 drivers/devfreq/devfreq.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
index 6e80bf70e7b3..ce569bd9adfa 100644
--- a/drivers/devfreq/devfreq.c
+++ b/drivers/devfreq/devfreq.c
@@ -390,7 +390,7 @@ static int devfreq_set_target(struct devfreq *devfreq, unsigned long new_freq,
 	devfreq->previous_freq = new_freq;
 
 	if (devfreq->suspend_freq)
-		devfreq->resume_freq = cur_freq;
+		devfreq->resume_freq = new_freq;
 
 	return err;
 }
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 06/11] PM / devfreq: drop the unnecessary low variable initialization
  2021-03-09 12:58 [PATCH 00/11] PM / devfreq: a few small fixes and improvements Dong Aisheng
                   ` (4 preceding siblings ...)
  2021-03-09 12:58 ` [PATCH 05/11] PM / devfreq: use more accurate returned new_freq as resume_freq Dong Aisheng
@ 2021-03-09 12:58 ` Dong Aisheng
  2021-03-09 12:58 ` [PATCH 07/11] PM / devfreq: check get_dev_status before start monitor Dong Aisheng
                   ` (16 subsequent siblings)
  22 siblings, 0 replies; 58+ messages in thread
From: Dong Aisheng @ 2021-03-09 12:58 UTC (permalink / raw)
  To: linux-pm, linux-arm-kernel
  Cc: dongas86, kernel, shawnguo, linux-imx, linux-kernel,
	myungjoo.ham, kyungmin.park, cw00.choi, abel.vesa, Dong Aisheng

drop the unnecessary low variable initialization and make the return
more straightforward.

Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
---
 drivers/devfreq/devfreq.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
index ce569bd9adfa..7231fe6862a2 100644
--- a/drivers/devfreq/devfreq.c
+++ b/drivers/devfreq/devfreq.c
@@ -351,7 +351,7 @@ static int devfreq_set_target(struct devfreq *devfreq, unsigned long new_freq,
 {
 	struct devfreq_freqs freqs;
 	unsigned long cur_freq;
-	int err = 0;
+	int err;
 
 	if (devfreq->profile->get_cur_freq)
 		devfreq->profile->get_cur_freq(devfreq->dev.parent, &cur_freq);
@@ -392,7 +392,7 @@ static int devfreq_set_target(struct devfreq *devfreq, unsigned long new_freq,
 	if (devfreq->suspend_freq)
 		devfreq->resume_freq = new_freq;
 
-	return err;
+	return 0;
 }
 
 /**
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 07/11] PM / devfreq: check get_dev_status before start monitor
  2021-03-09 12:58 [PATCH 00/11] PM / devfreq: a few small fixes and improvements Dong Aisheng
                   ` (5 preceding siblings ...)
  2021-03-09 12:58 ` [PATCH 06/11] PM / devfreq: drop the unnecessary low variable initialization Dong Aisheng
@ 2021-03-09 12:58 ` Dong Aisheng
  2021-03-09 15:58   ` Chanwoo Choi
  2021-03-09 12:58 ` [PATCH 08/11] PM / devfreq: check get_dev_status in devfreq_update_stats Dong Aisheng
                   ` (15 subsequent siblings)
  22 siblings, 1 reply; 58+ messages in thread
From: Dong Aisheng @ 2021-03-09 12:58 UTC (permalink / raw)
  To: linux-pm, linux-arm-kernel
  Cc: dongas86, kernel, shawnguo, linux-imx, linux-kernel,
	myungjoo.ham, kyungmin.park, cw00.choi, abel.vesa, Dong Aisheng

The devfreq monitor depends on the device to provide load information
by .get_dev_status() to calculate the next target freq.

And this will cause changing governor to simple ondemand fail
if device can't support.

Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
---
 drivers/devfreq/devfreq.c                 | 10 +++++++---
 drivers/devfreq/governor.h                |  2 +-
 drivers/devfreq/governor_simpleondemand.c |  3 +--
 3 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
index 7231fe6862a2..d1787b6c7d7c 100644
--- a/drivers/devfreq/devfreq.c
+++ b/drivers/devfreq/devfreq.c
@@ -482,10 +482,13 @@ static void devfreq_monitor(struct work_struct *work)
  * to be called from governor in response to DEVFREQ_GOV_START
  * event when device is added to devfreq framework.
  */
-void devfreq_monitor_start(struct devfreq *devfreq)
+int devfreq_monitor_start(struct devfreq *devfreq)
 {
 	if (IS_SUPPORTED_FLAG(devfreq->governor->flags, IRQ_DRIVEN))
-		return;
+		return 0;
+
+	if (!devfreq->profile->get_dev_status)
+		return -EINVAL;
 
 	switch (devfreq->profile->timer) {
 	case DEVFREQ_TIMER_DEFERRABLE:
@@ -495,12 +498,13 @@ void devfreq_monitor_start(struct devfreq *devfreq)
 		INIT_DELAYED_WORK(&devfreq->work, devfreq_monitor);
 		break;
 	default:
-		return;
+		return -EINVAL;
 	}
 
 	if (devfreq->profile->polling_ms)
 		queue_delayed_work(devfreq_wq, &devfreq->work,
 			msecs_to_jiffies(devfreq->profile->polling_ms));
+	return 0;
 }
 EXPORT_SYMBOL(devfreq_monitor_start);
 
diff --git a/drivers/devfreq/governor.h b/drivers/devfreq/governor.h
index 5cee3f64fe2b..31af6d072a10 100644
--- a/drivers/devfreq/governor.h
+++ b/drivers/devfreq/governor.h
@@ -75,7 +75,7 @@ struct devfreq_governor {
 				unsigned int event, void *data);
 };
 
-void devfreq_monitor_start(struct devfreq *devfreq);
+int devfreq_monitor_start(struct devfreq *devfreq);
 void devfreq_monitor_stop(struct devfreq *devfreq);
 void devfreq_monitor_suspend(struct devfreq *devfreq);
 void devfreq_monitor_resume(struct devfreq *devfreq);
diff --git a/drivers/devfreq/governor_simpleondemand.c b/drivers/devfreq/governor_simpleondemand.c
index d57b82a2b570..ea287b57cbf3 100644
--- a/drivers/devfreq/governor_simpleondemand.c
+++ b/drivers/devfreq/governor_simpleondemand.c
@@ -89,8 +89,7 @@ static int devfreq_simple_ondemand_handler(struct devfreq *devfreq,
 {
 	switch (event) {
 	case DEVFREQ_GOV_START:
-		devfreq_monitor_start(devfreq);
-		break;
+		return devfreq_monitor_start(devfreq);
 
 	case DEVFREQ_GOV_STOP:
 		devfreq_monitor_stop(devfreq);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 08/11] PM / devfreq: check get_dev_status in devfreq_update_stats
  2021-03-09 12:58 [PATCH 00/11] PM / devfreq: a few small fixes and improvements Dong Aisheng
                   ` (6 preceding siblings ...)
  2021-03-09 12:58 ` [PATCH 07/11] PM / devfreq: check get_dev_status before start monitor Dong Aisheng
@ 2021-03-09 12:58 ` Dong Aisheng
  2021-03-09 16:02   ` Chanwoo Choi
  2021-03-09 16:20   ` Chanwoo Choi
  2021-03-09 12:58 ` [PATCH 09/11] PM / devfreq: governor: optimize simpleondemand get_target_freq Dong Aisheng
                   ` (14 subsequent siblings)
  22 siblings, 2 replies; 58+ messages in thread
From: Dong Aisheng @ 2021-03-09 12:58 UTC (permalink / raw)
  To: linux-pm, linux-arm-kernel
  Cc: dongas86, kernel, shawnguo, linux-imx, linux-kernel,
	myungjoo.ham, kyungmin.park, cw00.choi, abel.vesa, Dong Aisheng

Check .get_dev_status() in devfreq_update_stats in case it's abused
when a device does not provide it.

Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
---
 drivers/devfreq/governor.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/devfreq/governor.h b/drivers/devfreq/governor.h
index 31af6d072a10..67a6dbdd5d23 100644
--- a/drivers/devfreq/governor.h
+++ b/drivers/devfreq/governor.h
@@ -89,6 +89,9 @@ int devfreq_update_target(struct devfreq *devfreq, unsigned long freq);
 
 static inline int devfreq_update_stats(struct devfreq *df)
 {
+	if (!df->profile->get_dev_status)
+		return -EINVAL;
+
 	return df->profile->get_dev_status(df->dev.parent, &df->last_status);
 }
 #endif /* _GOVERNOR_H */
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 09/11] PM / devfreq: governor: optimize simpleondemand get_target_freq
  2021-03-09 12:58 [PATCH 00/11] PM / devfreq: a few small fixes and improvements Dong Aisheng
                   ` (7 preceding siblings ...)
  2021-03-09 12:58 ` [PATCH 08/11] PM / devfreq: check get_dev_status in devfreq_update_stats Dong Aisheng
@ 2021-03-09 12:58 ` Dong Aisheng
  2021-03-09 16:09   ` Chanwoo Choi
  2021-03-09 12:58 ` [PATCH 10/11] PM / devfreq: imx8m-ddrc: remove imx8m_ddrc_get_dev_status Dong Aisheng
                   ` (13 subsequent siblings)
  22 siblings, 1 reply; 58+ messages in thread
From: Dong Aisheng @ 2021-03-09 12:58 UTC (permalink / raw)
  To: linux-pm, linux-arm-kernel
  Cc: dongas86, kernel, shawnguo, linux-imx, linux-kernel,
	myungjoo.ham, kyungmin.park, cw00.choi, abel.vesa, Dong Aisheng

devfreq_simple_ondemand_data only needs to be initialized once when
calling devm_devfreq_add_device. It's unnecessary to put the data
check logic in the hot path (.get_target_freq()) where it will be
called all the time during polling. Instead, we only check and initialize
it one time during DEVFREQ_GOV_START.

This also helps check data validability in advance during DEVFREQ_GOV_START
rather than checking it later when running .get_target_freq().

Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
---
 drivers/devfreq/governor_simpleondemand.c | 50 +++++++++++++++--------
 1 file changed, 34 insertions(+), 16 deletions(-)

diff --git a/drivers/devfreq/governor_simpleondemand.c b/drivers/devfreq/governor_simpleondemand.c
index ea287b57cbf3..341eb7e9dc04 100644
--- a/drivers/devfreq/governor_simpleondemand.c
+++ b/drivers/devfreq/governor_simpleondemand.c
@@ -15,15 +15,19 @@
 /* Default constants for DevFreq-Simple-Ondemand (DFSO) */
 #define DFSO_UPTHRESHOLD	(90)
 #define DFSO_DOWNDIFFERENCTIAL	(5)
+
+static struct devfreq_simple_ondemand_data od_default = {
+	.upthreshold = DFSO_UPTHRESHOLD,
+	.downdifferential = DFSO_DOWNDIFFERENCTIAL,
+};
+
 static int devfreq_simple_ondemand_func(struct devfreq *df,
 					unsigned long *freq)
 {
 	int err;
 	struct devfreq_dev_status *stat;
 	unsigned long long a, b;
-	unsigned int dfso_upthreshold = DFSO_UPTHRESHOLD;
-	unsigned int dfso_downdifferential = DFSO_DOWNDIFFERENCTIAL;
-	struct devfreq_simple_ondemand_data *data = df->data;
+	struct devfreq_simple_ondemand_data *od = df->data;
 
 	err = devfreq_update_stats(df);
 	if (err)
@@ -31,16 +35,6 @@ static int devfreq_simple_ondemand_func(struct devfreq *df,
 
 	stat = &df->last_status;
 
-	if (data) {
-		if (data->upthreshold)
-			dfso_upthreshold = data->upthreshold;
-		if (data->downdifferential)
-			dfso_downdifferential = data->downdifferential;
-	}
-	if (dfso_upthreshold > 100 ||
-	    dfso_upthreshold < dfso_downdifferential)
-		return -EINVAL;
-
 	/* Assume MAX if it is going to be divided by zero */
 	if (stat->total_time == 0) {
 		*freq = DEVFREQ_MAX_FREQ;
@@ -55,7 +49,7 @@ static int devfreq_simple_ondemand_func(struct devfreq *df,
 
 	/* Set MAX if it's busy enough */
 	if (stat->busy_time * 100 >
-	    stat->total_time * dfso_upthreshold) {
+	    stat->total_time * od->upthreshold) {
 		*freq = DEVFREQ_MAX_FREQ;
 		return 0;
 	}
@@ -68,7 +62,7 @@ static int devfreq_simple_ondemand_func(struct devfreq *df,
 
 	/* Keep the current frequency */
 	if (stat->busy_time * 100 >
-	    stat->total_time * (dfso_upthreshold - dfso_downdifferential)) {
+	    stat->total_time * (od->upthreshold - od->downdifferential)) {
 		*freq = stat->current_frequency;
 		return 0;
 	}
@@ -78,17 +72,41 @@ static int devfreq_simple_ondemand_func(struct devfreq *df,
 	a *= stat->current_frequency;
 	b = div_u64(a, stat->total_time);
 	b *= 100;
-	b = div_u64(b, (dfso_upthreshold - dfso_downdifferential / 2));
+	b = div_u64(b, (od->upthreshold - od->downdifferential / 2));
 	*freq = (unsigned long) b;
 
 	return 0;
 }
 
+static int devfreq_simple_ondemand_check_od(struct devfreq *devfreq)
+{
+	struct devfreq_simple_ondemand_data *od = devfreq->data;
+
+	if (od) {
+		if (!od->upthreshold)
+			od->upthreshold = DFSO_UPTHRESHOLD;
+
+		if (!od->downdifferential)
+			od->downdifferential = DFSO_DOWNDIFFERENCTIAL;
+
+		if (od->upthreshold > 100 ||
+		    od->upthreshold < od->downdifferential)
+			return -EINVAL;
+	} else {
+		od = &od_default;
+	}
+
+	return 0;
+}
+
 static int devfreq_simple_ondemand_handler(struct devfreq *devfreq,
 				unsigned int event, void *data)
 {
 	switch (event) {
 	case DEVFREQ_GOV_START:
+		if (devfreq_simple_ondemand_check_od(devfreq))
+			return -EINVAL;
+
 		return devfreq_monitor_start(devfreq);
 
 	case DEVFREQ_GOV_STOP:
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 10/11] PM / devfreq: imx8m-ddrc: remove imx8m_ddrc_get_dev_status
  2021-03-09 12:58 [PATCH 00/11] PM / devfreq: a few small fixes and improvements Dong Aisheng
                   ` (8 preceding siblings ...)
  2021-03-09 12:58 ` [PATCH 09/11] PM / devfreq: governor: optimize simpleondemand get_target_freq Dong Aisheng
@ 2021-03-09 12:58 ` Dong Aisheng
  2021-03-09 16:22   ` Chanwoo Choi
  2021-03-09 12:58 ` [PATCH 11/11] PM / devfreq: imx8m-ddrc: drop polling_ms Dong Aisheng
                   ` (12 subsequent siblings)
  22 siblings, 1 reply; 58+ messages in thread
From: Dong Aisheng @ 2021-03-09 12:58 UTC (permalink / raw)
  To: linux-pm, linux-arm-kernel
  Cc: dongas86, kernel, shawnguo, linux-imx, linux-kernel,
	myungjoo.ham, kyungmin.park, cw00.choi, abel.vesa, Dong Aisheng

Current driver actually does not support simple ondemand governor
as it's unable to provide device load information. So removing
the unnecessary callback to avoid confusing.
Right now the driver is using userspace governor by default.

Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
---
 drivers/devfreq/imx8m-ddrc.c | 13 -------------
 1 file changed, 13 deletions(-)

diff --git a/drivers/devfreq/imx8m-ddrc.c b/drivers/devfreq/imx8m-ddrc.c
index bc82d3653bff..0a6b7a1c829d 100644
--- a/drivers/devfreq/imx8m-ddrc.c
+++ b/drivers/devfreq/imx8m-ddrc.c
@@ -280,18 +280,6 @@ static int imx8m_ddrc_get_cur_freq(struct device *dev, unsigned long *freq)
 	return 0;
 }
 
-static int imx8m_ddrc_get_dev_status(struct device *dev,
-				     struct devfreq_dev_status *stat)
-{
-	struct imx8m_ddrc *priv = dev_get_drvdata(dev);
-
-	stat->busy_time = 0;
-	stat->total_time = 0;
-	stat->current_frequency = clk_get_rate(priv->dram_core);
-
-	return 0;
-}
-
 static int imx8m_ddrc_init_freq_info(struct device *dev)
 {
 	struct imx8m_ddrc *priv = dev_get_drvdata(dev);
@@ -431,7 +419,6 @@ static int imx8m_ddrc_probe(struct platform_device *pdev)
 
 	priv->profile.polling_ms = 1000;
 	priv->profile.target = imx8m_ddrc_target;
-	priv->profile.get_dev_status = imx8m_ddrc_get_dev_status;
 	priv->profile.exit = imx8m_ddrc_exit;
 	priv->profile.get_cur_freq = imx8m_ddrc_get_cur_freq;
 	priv->profile.initial_freq = clk_get_rate(priv->dram_core);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 11/11] PM / devfreq: imx8m-ddrc: drop polling_ms
  2021-03-09 12:58 [PATCH 00/11] PM / devfreq: a few small fixes and improvements Dong Aisheng
                   ` (9 preceding siblings ...)
  2021-03-09 12:58 ` [PATCH 10/11] PM / devfreq: imx8m-ddrc: remove imx8m_ddrc_get_dev_status Dong Aisheng
@ 2021-03-09 12:58 ` Dong Aisheng
  2021-03-09 16:23   ` Chanwoo Choi
  2021-03-09 12:58 ` [PATCH 00/11] PM / devfreq: a few small fixes and improvements Dong Aisheng
                   ` (11 subsequent siblings)
  22 siblings, 1 reply; 58+ messages in thread
From: Dong Aisheng @ 2021-03-09 12:58 UTC (permalink / raw)
  To: linux-pm, linux-arm-kernel
  Cc: dongas86, kernel, shawnguo, linux-imx, linux-kernel,
	myungjoo.ham, kyungmin.park, cw00.choi, abel.vesa, Dong Aisheng

polling_ms is only used by simple ondemand governor which
this driver can't support. Drop it to avoid confusing.

Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
---
 drivers/devfreq/imx8m-ddrc.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/devfreq/imx8m-ddrc.c b/drivers/devfreq/imx8m-ddrc.c
index 0a6b7a1c829d..ecb9375aa877 100644
--- a/drivers/devfreq/imx8m-ddrc.c
+++ b/drivers/devfreq/imx8m-ddrc.c
@@ -417,7 +417,6 @@ static int imx8m_ddrc_probe(struct platform_device *pdev)
 	if (ret < 0)
 		goto err;
 
-	priv->profile.polling_ms = 1000;
 	priv->profile.target = imx8m_ddrc_target;
 	priv->profile.exit = imx8m_ddrc_exit;
 	priv->profile.get_cur_freq = imx8m_ddrc_get_cur_freq;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 00/11] PM / devfreq: a few small fixes and improvements
  2021-03-09 12:58 [PATCH 00/11] PM / devfreq: a few small fixes and improvements Dong Aisheng
                   ` (10 preceding siblings ...)
  2021-03-09 12:58 ` [PATCH 11/11] PM / devfreq: imx8m-ddrc: drop polling_ms Dong Aisheng
@ 2021-03-09 12:58 ` Dong Aisheng
  2021-03-09 12:58 ` [PATCH 01/11] doc: ABI: devfreq: remove invalid central_polling description Dong Aisheng
                   ` (10 subsequent siblings)
  22 siblings, 0 replies; 58+ messages in thread
From: Dong Aisheng @ 2021-03-09 12:58 UTC (permalink / raw)
  To: linux-pm, linux-arm-kernel
  Cc: dongas86, kernel, shawnguo, linux-imx, linux-kernel,
	myungjoo.ham, kyungmin.park, cw00.choi, abel.vesa, Dong Aisheng

A few small fixes and improvements

Dong Aisheng (11):
  doc: ABI: devfreq: remove invalid central_polling description
  PM / devfreq: remove the invalid description for get_target_freq
  PM / devfreq: fix the wrong set_freq path for userspace governor
  PM / devfreq: bail out early if no freq changes in devfreq_set_target
  PM / devfreq: use more accurate returned new_freq as resume_freq
  PM / devfreq: drop the unnecessary low variable initialization
  PM / devfreq: check get_dev_status before start monitor
  PM / devfreq: check get_dev_status in devfreq_update_stats
  PM / devfreq: governor: optimize simpleondemand get_target_freq
  PM / devfreq: imx8m-ddrc: remove imx8m_ddrc_get_dev_status
  PM / devfreq: imx8m-ddrc: drop polling_ms

 Documentation/ABI/testing/sysfs-class-devfreq |  5 +-
 drivers/devfreq/Kconfig                       |  2 +-
 drivers/devfreq/devfreq.c                     | 21 +++++---
 drivers/devfreq/governor.h                    |  7 +--
 drivers/devfreq/governor_simpleondemand.c     | 53 ++++++++++++-------
 drivers/devfreq/imx8m-ddrc.c                  | 14 -----
 6 files changed, 55 insertions(+), 47 deletions(-)

-- 
2.25.1


^ permalink raw reply	[flat|nested] 58+ messages in thread

* [PATCH 01/11] doc: ABI: devfreq: remove invalid central_polling description
  2021-03-09 12:58 [PATCH 00/11] PM / devfreq: a few small fixes and improvements Dong Aisheng
                   ` (11 preceding siblings ...)
  2021-03-09 12:58 ` [PATCH 00/11] PM / devfreq: a few small fixes and improvements Dong Aisheng
@ 2021-03-09 12:58 ` Dong Aisheng
  2021-03-09 12:58 ` [PATCH 02/11] PM / devfreq: remove the invalid description for get_target_freq Dong Aisheng
                   ` (9 subsequent siblings)
  22 siblings, 0 replies; 58+ messages in thread
From: Dong Aisheng @ 2021-03-09 12:58 UTC (permalink / raw)
  To: linux-pm, linux-arm-kernel
  Cc: dongas86, kernel, shawnguo, linux-imx, linux-kernel,
	myungjoo.ham, kyungmin.park, cw00.choi, abel.vesa, Dong Aisheng

no_central_polling has been removed since
commit 7e6fdd4bad03 ("PM / devfreq: Core updates to support devices
which can idle")

Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
---
 Documentation/ABI/testing/sysfs-class-devfreq | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/Documentation/ABI/testing/sysfs-class-devfreq b/Documentation/ABI/testing/sysfs-class-devfreq
index 386bc230a33d..5e6b74f30406 100644
--- a/Documentation/ABI/testing/sysfs-class-devfreq
+++ b/Documentation/ABI/testing/sysfs-class-devfreq
@@ -97,10 +97,7 @@ Description:
 		object. The values are represented in ms. If the value is
 		less than 1 jiffy, it is considered to be 0, which means
 		no polling. This value is meaningless if the governor is
-		not polling; thus. If the governor is not using
-		devfreq-provided central polling
-		(/sys/class/devfreq/.../central_polling is 0), this value
-		may be useless.
+		not polling.
 
 		A list of governors that support the node:
 		- simple_ondmenad
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 02/11] PM / devfreq: remove the invalid description for get_target_freq
  2021-03-09 12:58 [PATCH 00/11] PM / devfreq: a few small fixes and improvements Dong Aisheng
                   ` (12 preceding siblings ...)
  2021-03-09 12:58 ` [PATCH 01/11] doc: ABI: devfreq: remove invalid central_polling description Dong Aisheng
@ 2021-03-09 12:58 ` Dong Aisheng
  2021-03-09 12:58 ` [PATCH 03/11] PM / devfreq: fix the wrong set_freq path for userspace governor Dong Aisheng
                   ` (8 subsequent siblings)
  22 siblings, 0 replies; 58+ messages in thread
From: Dong Aisheng @ 2021-03-09 12:58 UTC (permalink / raw)
  To: linux-pm, linux-arm-kernel
  Cc: dongas86, kernel, shawnguo, linux-imx, linux-kernel,
	myungjoo.ham, kyungmin.park, cw00.choi, abel.vesa, Dong Aisheng

First of all, no_central_polling was removed since
commit 7e6fdd4bad03 ("PM / devfreq: Core updates to support devices
which can idle")
Secondly, get_target_freq() is not only called only with update_devfreq()
notified by OPP now, but also min/max freq qos notifier.

So remove this invalid description now to avoid confusing.

Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
---
 drivers/devfreq/governor.h | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/devfreq/governor.h b/drivers/devfreq/governor.h
index 70f44b3ca42e..5cee3f64fe2b 100644
--- a/drivers/devfreq/governor.h
+++ b/drivers/devfreq/governor.h
@@ -57,8 +57,6 @@
  *			Basically, get_target_freq will run
  *			devfreq_dev_profile.get_dev_status() to get the
  *			status of the device (load = busy_time / total_time).
- *			If no_central_polling is set, this callback is called
- *			only with update_devfreq() notified by OPP.
  * @event_handler:      Callback for devfreq core framework to notify events
  *                      to governors. Events include per device governor
  *                      init and exit, opp changes out of devfreq, suspend
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 03/11] PM / devfreq: fix the wrong set_freq path for userspace governor
  2021-03-09 12:58 [PATCH 00/11] PM / devfreq: a few small fixes and improvements Dong Aisheng
                   ` (13 preceding siblings ...)
  2021-03-09 12:58 ` [PATCH 02/11] PM / devfreq: remove the invalid description for get_target_freq Dong Aisheng
@ 2021-03-09 12:58 ` Dong Aisheng
  2021-03-09 12:58 ` [PATCH 04/11] PM / devfreq: bail out early if no freq changes in devfreq_set_target Dong Aisheng
                   ` (7 subsequent siblings)
  22 siblings, 0 replies; 58+ messages in thread
From: Dong Aisheng @ 2021-03-09 12:58 UTC (permalink / raw)
  To: linux-pm, linux-arm-kernel
  Cc: dongas86, kernel, shawnguo, linux-imx, linux-kernel,
	myungjoo.ham, kyungmin.park, cw00.choi, abel.vesa, Dong Aisheng

Fix the wrong set_freq path for userspace governor.

Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
---
 drivers/devfreq/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/devfreq/Kconfig b/drivers/devfreq/Kconfig
index 00704efe6398..20373a893b44 100644
--- a/drivers/devfreq/Kconfig
+++ b/drivers/devfreq/Kconfig
@@ -62,7 +62,7 @@ config DEVFREQ_GOV_USERSPACE
 	help
 	  Sets the frequency at the user specified one.
 	  This governor returns the user configured frequency if there
-	  has been an input to /sys/devices/.../power/devfreq_set_freq.
+	  has been an input to /sys/devices/.../userspace/set_freq.
 	  Otherwise, the governor does not change the frequency
 	  given at the initialization.
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 04/11] PM / devfreq: bail out early if no freq changes in devfreq_set_target
  2021-03-09 12:58 [PATCH 00/11] PM / devfreq: a few small fixes and improvements Dong Aisheng
                   ` (14 preceding siblings ...)
  2021-03-09 12:58 ` [PATCH 03/11] PM / devfreq: fix the wrong set_freq path for userspace governor Dong Aisheng
@ 2021-03-09 12:58 ` Dong Aisheng
  2021-03-09 12:58 ` [PATCH 05/11] PM / devfreq: use more accurate returned new_freq as resume_freq Dong Aisheng
                   ` (6 subsequent siblings)
  22 siblings, 0 replies; 58+ messages in thread
From: Dong Aisheng @ 2021-03-09 12:58 UTC (permalink / raw)
  To: linux-pm, linux-arm-kernel
  Cc: dongas86, kernel, shawnguo, linux-imx, linux-kernel,
	myungjoo.ham, kyungmin.park, cw00.choi, abel.vesa, Dong Aisheng

It's unnecessary to set the same freq again and run notifier calls.

Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
---
 drivers/devfreq/devfreq.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
index bf3047896e41..6e80bf70e7b3 100644
--- a/drivers/devfreq/devfreq.c
+++ b/drivers/devfreq/devfreq.c
@@ -358,6 +358,9 @@ static int devfreq_set_target(struct devfreq *devfreq, unsigned long new_freq,
 	else
 		cur_freq = devfreq->previous_freq;
 
+	if (new_freq == cur_freq)
+		return 0;
+
 	freqs.old = cur_freq;
 	freqs.new = new_freq;
 	devfreq_notify_transition(devfreq, &freqs, DEVFREQ_PRECHANGE);
@@ -374,7 +377,7 @@ static int devfreq_set_target(struct devfreq *devfreq, unsigned long new_freq,
 	 * and DEVFREQ_POSTCHANGE because for showing the correct frequency
 	 * change order of between devfreq device and passive devfreq device.
 	 */
-	if (trace_devfreq_frequency_enabled() && new_freq != cur_freq)
+	if (trace_devfreq_frequency_enabled())
 		trace_devfreq_frequency(devfreq, new_freq, cur_freq);
 
 	freqs.new = new_freq;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 05/11] PM / devfreq: use more accurate returned new_freq as resume_freq
  2021-03-09 12:58 [PATCH 00/11] PM / devfreq: a few small fixes and improvements Dong Aisheng
                   ` (15 preceding siblings ...)
  2021-03-09 12:58 ` [PATCH 04/11] PM / devfreq: bail out early if no freq changes in devfreq_set_target Dong Aisheng
@ 2021-03-09 12:58 ` Dong Aisheng
  2021-03-09 12:58 ` [PATCH 06/11] PM / devfreq: drop the unnecessary low variable initialization Dong Aisheng
                   ` (5 subsequent siblings)
  22 siblings, 0 replies; 58+ messages in thread
From: Dong Aisheng @ 2021-03-09 12:58 UTC (permalink / raw)
  To: linux-pm, linux-arm-kernel
  Cc: dongas86, kernel, shawnguo, linux-imx, linux-kernel,
	myungjoo.ham, kyungmin.park, cw00.choi, abel.vesa, Dong Aisheng

Use the more accurate returned new_freq as resume_freq.
It's the same as how devfreq->previous_freq was updated.

Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
---
 drivers/devfreq/devfreq.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
index 6e80bf70e7b3..ce569bd9adfa 100644
--- a/drivers/devfreq/devfreq.c
+++ b/drivers/devfreq/devfreq.c
@@ -390,7 +390,7 @@ static int devfreq_set_target(struct devfreq *devfreq, unsigned long new_freq,
 	devfreq->previous_freq = new_freq;
 
 	if (devfreq->suspend_freq)
-		devfreq->resume_freq = cur_freq;
+		devfreq->resume_freq = new_freq;
 
 	return err;
 }
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 06/11] PM / devfreq: drop the unnecessary low variable initialization
  2021-03-09 12:58 [PATCH 00/11] PM / devfreq: a few small fixes and improvements Dong Aisheng
                   ` (16 preceding siblings ...)
  2021-03-09 12:58 ` [PATCH 05/11] PM / devfreq: use more accurate returned new_freq as resume_freq Dong Aisheng
@ 2021-03-09 12:58 ` Dong Aisheng
  2021-03-09 12:58 ` [PATCH 07/11] PM / devfreq: check get_dev_status before start monitor Dong Aisheng
                   ` (4 subsequent siblings)
  22 siblings, 0 replies; 58+ messages in thread
From: Dong Aisheng @ 2021-03-09 12:58 UTC (permalink / raw)
  To: linux-pm, linux-arm-kernel
  Cc: dongas86, kernel, shawnguo, linux-imx, linux-kernel,
	myungjoo.ham, kyungmin.park, cw00.choi, abel.vesa, Dong Aisheng

drop the unnecessary low variable initialization and make the return
more straightforward.

Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
---
 drivers/devfreq/devfreq.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
index ce569bd9adfa..7231fe6862a2 100644
--- a/drivers/devfreq/devfreq.c
+++ b/drivers/devfreq/devfreq.c
@@ -351,7 +351,7 @@ static int devfreq_set_target(struct devfreq *devfreq, unsigned long new_freq,
 {
 	struct devfreq_freqs freqs;
 	unsigned long cur_freq;
-	int err = 0;
+	int err;
 
 	if (devfreq->profile->get_cur_freq)
 		devfreq->profile->get_cur_freq(devfreq->dev.parent, &cur_freq);
@@ -392,7 +392,7 @@ static int devfreq_set_target(struct devfreq *devfreq, unsigned long new_freq,
 	if (devfreq->suspend_freq)
 		devfreq->resume_freq = new_freq;
 
-	return err;
+	return 0;
 }
 
 /**
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 07/11] PM / devfreq: check get_dev_status before start monitor
  2021-03-09 12:58 [PATCH 00/11] PM / devfreq: a few small fixes and improvements Dong Aisheng
                   ` (17 preceding siblings ...)
  2021-03-09 12:58 ` [PATCH 06/11] PM / devfreq: drop the unnecessary low variable initialization Dong Aisheng
@ 2021-03-09 12:58 ` Dong Aisheng
  2021-03-09 12:58 ` [PATCH 08/11] PM / devfreq: check get_dev_status in devfreq_update_stats Dong Aisheng
                   ` (3 subsequent siblings)
  22 siblings, 0 replies; 58+ messages in thread
From: Dong Aisheng @ 2021-03-09 12:58 UTC (permalink / raw)
  To: linux-pm, linux-arm-kernel
  Cc: dongas86, kernel, shawnguo, linux-imx, linux-kernel,
	myungjoo.ham, kyungmin.park, cw00.choi, abel.vesa, Dong Aisheng

The devfreq monitor depends on the device to provide load information
by .get_dev_status() to calculate the next target freq.

And this will cause changing governor to simple ondemand fail
if device can't support.

Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
---
 drivers/devfreq/devfreq.c                 | 10 +++++++---
 drivers/devfreq/governor.h                |  2 +-
 drivers/devfreq/governor_simpleondemand.c |  3 +--
 3 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
index 7231fe6862a2..d1787b6c7d7c 100644
--- a/drivers/devfreq/devfreq.c
+++ b/drivers/devfreq/devfreq.c
@@ -482,10 +482,13 @@ static void devfreq_monitor(struct work_struct *work)
  * to be called from governor in response to DEVFREQ_GOV_START
  * event when device is added to devfreq framework.
  */
-void devfreq_monitor_start(struct devfreq *devfreq)
+int devfreq_monitor_start(struct devfreq *devfreq)
 {
 	if (IS_SUPPORTED_FLAG(devfreq->governor->flags, IRQ_DRIVEN))
-		return;
+		return 0;
+
+	if (!devfreq->profile->get_dev_status)
+		return -EINVAL;
 
 	switch (devfreq->profile->timer) {
 	case DEVFREQ_TIMER_DEFERRABLE:
@@ -495,12 +498,13 @@ void devfreq_monitor_start(struct devfreq *devfreq)
 		INIT_DELAYED_WORK(&devfreq->work, devfreq_monitor);
 		break;
 	default:
-		return;
+		return -EINVAL;
 	}
 
 	if (devfreq->profile->polling_ms)
 		queue_delayed_work(devfreq_wq, &devfreq->work,
 			msecs_to_jiffies(devfreq->profile->polling_ms));
+	return 0;
 }
 EXPORT_SYMBOL(devfreq_monitor_start);
 
diff --git a/drivers/devfreq/governor.h b/drivers/devfreq/governor.h
index 5cee3f64fe2b..31af6d072a10 100644
--- a/drivers/devfreq/governor.h
+++ b/drivers/devfreq/governor.h
@@ -75,7 +75,7 @@ struct devfreq_governor {
 				unsigned int event, void *data);
 };
 
-void devfreq_monitor_start(struct devfreq *devfreq);
+int devfreq_monitor_start(struct devfreq *devfreq);
 void devfreq_monitor_stop(struct devfreq *devfreq);
 void devfreq_monitor_suspend(struct devfreq *devfreq);
 void devfreq_monitor_resume(struct devfreq *devfreq);
diff --git a/drivers/devfreq/governor_simpleondemand.c b/drivers/devfreq/governor_simpleondemand.c
index d57b82a2b570..ea287b57cbf3 100644
--- a/drivers/devfreq/governor_simpleondemand.c
+++ b/drivers/devfreq/governor_simpleondemand.c
@@ -89,8 +89,7 @@ static int devfreq_simple_ondemand_handler(struct devfreq *devfreq,
 {
 	switch (event) {
 	case DEVFREQ_GOV_START:
-		devfreq_monitor_start(devfreq);
-		break;
+		return devfreq_monitor_start(devfreq);
 
 	case DEVFREQ_GOV_STOP:
 		devfreq_monitor_stop(devfreq);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 08/11] PM / devfreq: check get_dev_status in devfreq_update_stats
  2021-03-09 12:58 [PATCH 00/11] PM / devfreq: a few small fixes and improvements Dong Aisheng
                   ` (18 preceding siblings ...)
  2021-03-09 12:58 ` [PATCH 07/11] PM / devfreq: check get_dev_status before start monitor Dong Aisheng
@ 2021-03-09 12:58 ` Dong Aisheng
  2021-03-09 12:58 ` [PATCH 09/11] PM / devfreq: governor: optimize simpleondemand get_target_freq Dong Aisheng
                   ` (2 subsequent siblings)
  22 siblings, 0 replies; 58+ messages in thread
From: Dong Aisheng @ 2021-03-09 12:58 UTC (permalink / raw)
  To: linux-pm, linux-arm-kernel
  Cc: dongas86, kernel, shawnguo, linux-imx, linux-kernel,
	myungjoo.ham, kyungmin.park, cw00.choi, abel.vesa, Dong Aisheng

Check .get_dev_status() in devfreq_update_stats in case it's abused
when a device does not provide it.

Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
---
 drivers/devfreq/governor.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/devfreq/governor.h b/drivers/devfreq/governor.h
index 31af6d072a10..67a6dbdd5d23 100644
--- a/drivers/devfreq/governor.h
+++ b/drivers/devfreq/governor.h
@@ -89,6 +89,9 @@ int devfreq_update_target(struct devfreq *devfreq, unsigned long freq);
 
 static inline int devfreq_update_stats(struct devfreq *df)
 {
+	if (!df->profile->get_dev_status)
+		return -EINVAL;
+
 	return df->profile->get_dev_status(df->dev.parent, &df->last_status);
 }
 #endif /* _GOVERNOR_H */
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 09/11] PM / devfreq: governor: optimize simpleondemand get_target_freq
  2021-03-09 12:58 [PATCH 00/11] PM / devfreq: a few small fixes and improvements Dong Aisheng
                   ` (19 preceding siblings ...)
  2021-03-09 12:58 ` [PATCH 08/11] PM / devfreq: check get_dev_status in devfreq_update_stats Dong Aisheng
@ 2021-03-09 12:58 ` Dong Aisheng
  2021-03-09 12:58 ` [PATCH 10/11] PM / devfreq: imx8m-ddrc: remove imx8m_ddrc_get_dev_status Dong Aisheng
  2021-03-09 12:58 ` [PATCH 11/11] PM / devfreq: imx8m-ddrc: drop polling_ms Dong Aisheng
  22 siblings, 0 replies; 58+ messages in thread
From: Dong Aisheng @ 2021-03-09 12:58 UTC (permalink / raw)
  To: linux-pm, linux-arm-kernel
  Cc: dongas86, kernel, shawnguo, linux-imx, linux-kernel,
	myungjoo.ham, kyungmin.park, cw00.choi, abel.vesa, Dong Aisheng

devfreq_simple_ondemand_data only needs to be initialized once when
calling devm_devfreq_add_device. It's unnecessary to put the data
check logic in the hot path (.get_target_freq()) where it will be
called all the time during polling. Instead, we only check and initialize
it one time during DEVFREQ_GOV_START.

This also helps check data validability in advance during DEVFREQ_GOV_START
rather than checking it later when running .get_target_freq().

Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
---
 drivers/devfreq/governor_simpleondemand.c | 50 +++++++++++++++--------
 1 file changed, 34 insertions(+), 16 deletions(-)

diff --git a/drivers/devfreq/governor_simpleondemand.c b/drivers/devfreq/governor_simpleondemand.c
index ea287b57cbf3..341eb7e9dc04 100644
--- a/drivers/devfreq/governor_simpleondemand.c
+++ b/drivers/devfreq/governor_simpleondemand.c
@@ -15,15 +15,19 @@
 /* Default constants for DevFreq-Simple-Ondemand (DFSO) */
 #define DFSO_UPTHRESHOLD	(90)
 #define DFSO_DOWNDIFFERENCTIAL	(5)
+
+static struct devfreq_simple_ondemand_data od_default = {
+	.upthreshold = DFSO_UPTHRESHOLD,
+	.downdifferential = DFSO_DOWNDIFFERENCTIAL,
+};
+
 static int devfreq_simple_ondemand_func(struct devfreq *df,
 					unsigned long *freq)
 {
 	int err;
 	struct devfreq_dev_status *stat;
 	unsigned long long a, b;
-	unsigned int dfso_upthreshold = DFSO_UPTHRESHOLD;
-	unsigned int dfso_downdifferential = DFSO_DOWNDIFFERENCTIAL;
-	struct devfreq_simple_ondemand_data *data = df->data;
+	struct devfreq_simple_ondemand_data *od = df->data;
 
 	err = devfreq_update_stats(df);
 	if (err)
@@ -31,16 +35,6 @@ static int devfreq_simple_ondemand_func(struct devfreq *df,
 
 	stat = &df->last_status;
 
-	if (data) {
-		if (data->upthreshold)
-			dfso_upthreshold = data->upthreshold;
-		if (data->downdifferential)
-			dfso_downdifferential = data->downdifferential;
-	}
-	if (dfso_upthreshold > 100 ||
-	    dfso_upthreshold < dfso_downdifferential)
-		return -EINVAL;
-
 	/* Assume MAX if it is going to be divided by zero */
 	if (stat->total_time == 0) {
 		*freq = DEVFREQ_MAX_FREQ;
@@ -55,7 +49,7 @@ static int devfreq_simple_ondemand_func(struct devfreq *df,
 
 	/* Set MAX if it's busy enough */
 	if (stat->busy_time * 100 >
-	    stat->total_time * dfso_upthreshold) {
+	    stat->total_time * od->upthreshold) {
 		*freq = DEVFREQ_MAX_FREQ;
 		return 0;
 	}
@@ -68,7 +62,7 @@ static int devfreq_simple_ondemand_func(struct devfreq *df,
 
 	/* Keep the current frequency */
 	if (stat->busy_time * 100 >
-	    stat->total_time * (dfso_upthreshold - dfso_downdifferential)) {
+	    stat->total_time * (od->upthreshold - od->downdifferential)) {
 		*freq = stat->current_frequency;
 		return 0;
 	}
@@ -78,17 +72,41 @@ static int devfreq_simple_ondemand_func(struct devfreq *df,
 	a *= stat->current_frequency;
 	b = div_u64(a, stat->total_time);
 	b *= 100;
-	b = div_u64(b, (dfso_upthreshold - dfso_downdifferential / 2));
+	b = div_u64(b, (od->upthreshold - od->downdifferential / 2));
 	*freq = (unsigned long) b;
 
 	return 0;
 }
 
+static int devfreq_simple_ondemand_check_od(struct devfreq *devfreq)
+{
+	struct devfreq_simple_ondemand_data *od = devfreq->data;
+
+	if (od) {
+		if (!od->upthreshold)
+			od->upthreshold = DFSO_UPTHRESHOLD;
+
+		if (!od->downdifferential)
+			od->downdifferential = DFSO_DOWNDIFFERENCTIAL;
+
+		if (od->upthreshold > 100 ||
+		    od->upthreshold < od->downdifferential)
+			return -EINVAL;
+	} else {
+		od = &od_default;
+	}
+
+	return 0;
+}
+
 static int devfreq_simple_ondemand_handler(struct devfreq *devfreq,
 				unsigned int event, void *data)
 {
 	switch (event) {
 	case DEVFREQ_GOV_START:
+		if (devfreq_simple_ondemand_check_od(devfreq))
+			return -EINVAL;
+
 		return devfreq_monitor_start(devfreq);
 
 	case DEVFREQ_GOV_STOP:
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 10/11] PM / devfreq: imx8m-ddrc: remove imx8m_ddrc_get_dev_status
  2021-03-09 12:58 [PATCH 00/11] PM / devfreq: a few small fixes and improvements Dong Aisheng
                   ` (20 preceding siblings ...)
  2021-03-09 12:58 ` [PATCH 09/11] PM / devfreq: governor: optimize simpleondemand get_target_freq Dong Aisheng
@ 2021-03-09 12:58 ` Dong Aisheng
  2021-03-09 12:58 ` [PATCH 11/11] PM / devfreq: imx8m-ddrc: drop polling_ms Dong Aisheng
  22 siblings, 0 replies; 58+ messages in thread
From: Dong Aisheng @ 2021-03-09 12:58 UTC (permalink / raw)
  To: linux-pm, linux-arm-kernel
  Cc: dongas86, kernel, shawnguo, linux-imx, linux-kernel,
	myungjoo.ham, kyungmin.park, cw00.choi, abel.vesa, Dong Aisheng

Current driver actually does not support simple ondemand governor
as it's unable to provide device load information. So removing
the unnecessary callback to avoid confusing.
Right now the driver is using userspace governor by default.

Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
---
 drivers/devfreq/imx8m-ddrc.c | 13 -------------
 1 file changed, 13 deletions(-)

diff --git a/drivers/devfreq/imx8m-ddrc.c b/drivers/devfreq/imx8m-ddrc.c
index bc82d3653bff..0a6b7a1c829d 100644
--- a/drivers/devfreq/imx8m-ddrc.c
+++ b/drivers/devfreq/imx8m-ddrc.c
@@ -280,18 +280,6 @@ static int imx8m_ddrc_get_cur_freq(struct device *dev, unsigned long *freq)
 	return 0;
 }
 
-static int imx8m_ddrc_get_dev_status(struct device *dev,
-				     struct devfreq_dev_status *stat)
-{
-	struct imx8m_ddrc *priv = dev_get_drvdata(dev);
-
-	stat->busy_time = 0;
-	stat->total_time = 0;
-	stat->current_frequency = clk_get_rate(priv->dram_core);
-
-	return 0;
-}
-
 static int imx8m_ddrc_init_freq_info(struct device *dev)
 {
 	struct imx8m_ddrc *priv = dev_get_drvdata(dev);
@@ -431,7 +419,6 @@ static int imx8m_ddrc_probe(struct platform_device *pdev)
 
 	priv->profile.polling_ms = 1000;
 	priv->profile.target = imx8m_ddrc_target;
-	priv->profile.get_dev_status = imx8m_ddrc_get_dev_status;
 	priv->profile.exit = imx8m_ddrc_exit;
 	priv->profile.get_cur_freq = imx8m_ddrc_get_cur_freq;
 	priv->profile.initial_freq = clk_get_rate(priv->dram_core);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 11/11] PM / devfreq: imx8m-ddrc: drop polling_ms
  2021-03-09 12:58 [PATCH 00/11] PM / devfreq: a few small fixes and improvements Dong Aisheng
                   ` (21 preceding siblings ...)
  2021-03-09 12:58 ` [PATCH 10/11] PM / devfreq: imx8m-ddrc: remove imx8m_ddrc_get_dev_status Dong Aisheng
@ 2021-03-09 12:58 ` Dong Aisheng
  22 siblings, 0 replies; 58+ messages in thread
From: Dong Aisheng @ 2021-03-09 12:58 UTC (permalink / raw)
  To: linux-pm, linux-arm-kernel
  Cc: dongas86, kernel, shawnguo, linux-imx, linux-kernel,
	myungjoo.ham, kyungmin.park, cw00.choi, abel.vesa, Dong Aisheng

polling_ms is only used by simple ondemand governor which
this driver can't support. Drop it to avoid confusing.

Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
---
 drivers/devfreq/imx8m-ddrc.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/devfreq/imx8m-ddrc.c b/drivers/devfreq/imx8m-ddrc.c
index 0a6b7a1c829d..ecb9375aa877 100644
--- a/drivers/devfreq/imx8m-ddrc.c
+++ b/drivers/devfreq/imx8m-ddrc.c
@@ -417,7 +417,6 @@ static int imx8m_ddrc_probe(struct platform_device *pdev)
 	if (ret < 0)
 		goto err;
 
-	priv->profile.polling_ms = 1000;
 	priv->profile.target = imx8m_ddrc_target;
 	priv->profile.exit = imx8m_ddrc_exit;
 	priv->profile.get_cur_freq = imx8m_ddrc_get_cur_freq;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* Re: [PATCH 01/11] doc: ABI: devfreq: remove invalid central_polling description
  2021-03-09 12:58 ` [PATCH 01/11] doc: ABI: devfreq: remove invalid central_polling description Dong Aisheng
@ 2021-03-09 15:01   ` Chanwoo Choi
  0 siblings, 0 replies; 58+ messages in thread
From: Chanwoo Choi @ 2021-03-09 15:01 UTC (permalink / raw)
  To: Dong Aisheng, linux-pm, linux-arm-kernel
  Cc: dongas86, kernel, shawnguo, linux-imx, linux-kernel,
	myungjoo.ham, kyungmin.park, cw00.choi, abel.vesa

On 21. 3. 9. 오후 9:58, Dong Aisheng wrote:
> no_central_polling has been removed since
> commit 7e6fdd4bad03 ("PM / devfreq: Core updates to support devices
> which can idle")
> 
> Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
> ---
>   Documentation/ABI/testing/sysfs-class-devfreq | 5 +----
>   1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/Documentation/ABI/testing/sysfs-class-devfreq b/Documentation/ABI/testing/sysfs-class-devfreq
> index 386bc230a33d..5e6b74f30406 100644
> --- a/Documentation/ABI/testing/sysfs-class-devfreq
> +++ b/Documentation/ABI/testing/sysfs-class-devfreq
> @@ -97,10 +97,7 @@ Description:
>   		object. The values are represented in ms. If the value is
>   		less than 1 jiffy, it is considered to be 0, which means
>   		no polling. This value is meaningless if the governor is
> -		not polling; thus. If the governor is not using
> -		devfreq-provided central polling
> -		(/sys/class/devfreq/.../central_polling is 0), this value
> -		may be useless.
> +		not polling.
>   
>   		A list of governors that support the node:
>   		- simple_ondmenad
> 

Looks good. But, you better to make one patch with patch1/2 by
squashing.

-- 
Best Regards,
Samsung Electronics
Chanwoo Choi

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 02/11] PM / devfreq: remove the invalid description for get_target_freq
  2021-03-09 12:58 ` [PATCH 02/11] PM / devfreq: remove the invalid description for get_target_freq Dong Aisheng
@ 2021-03-09 15:02   ` Chanwoo Choi
  2021-03-09 15:14     ` Dong Aisheng
  0 siblings, 1 reply; 58+ messages in thread
From: Chanwoo Choi @ 2021-03-09 15:02 UTC (permalink / raw)
  To: Dong Aisheng, linux-pm, linux-arm-kernel
  Cc: dongas86, kernel, shawnguo, linux-imx, linux-kernel,
	myungjoo.ham, kyungmin.park, cw00.choi, abel.vesa

On 21. 3. 9. 오후 9:58, Dong Aisheng wrote:
> First of all, no_central_polling was removed since
> commit 7e6fdd4bad03 ("PM / devfreq: Core updates to support devices
> which can idle")
> Secondly, get_target_freq() is not only called only with update_devfreq()
> notified by OPP now, but also min/max freq qos notifier.
> 
> So remove this invalid description now to avoid confusing.
> 
> Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
> ---
>   drivers/devfreq/governor.h | 2 --
>   1 file changed, 2 deletions(-)
> 
> diff --git a/drivers/devfreq/governor.h b/drivers/devfreq/governor.h
> index 70f44b3ca42e..5cee3f64fe2b 100644
> --- a/drivers/devfreq/governor.h
> +++ b/drivers/devfreq/governor.h
> @@ -57,8 +57,6 @@
>    *			Basically, get_target_freq will run
>    *			devfreq_dev_profile.get_dev_status() to get the
>    *			status of the device (load = busy_time / total_time).
> - *			If no_central_polling is set, this callback is called
> - *			only with update_devfreq() notified by OPP.
>    * @event_handler:      Callback for devfreq core framework to notify events
>    *                      to governors. Events include per device governor
>    *                      init and exit, opp changes out of devfreq, suspend
> 

As I replied from patch1, I recommend that squash it with patch1.

-- 
Best Regards,
Samsung Electronics
Chanwoo Choi

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 03/11] PM / devfreq: fix the wrong set_freq path for userspace governor
  2021-03-09 12:58 ` [PATCH 03/11] PM / devfreq: fix the wrong set_freq path for userspace governor Dong Aisheng
@ 2021-03-09 15:13   ` Chanwoo Choi
  2021-03-09 15:16     ` Dong Aisheng
  0 siblings, 1 reply; 58+ messages in thread
From: Chanwoo Choi @ 2021-03-09 15:13 UTC (permalink / raw)
  To: Dong Aisheng, linux-pm, linux-arm-kernel
  Cc: dongas86, kernel, shawnguo, linux-imx, linux-kernel,
	myungjoo.ham, kyungmin.park, cw00.choi, abel.vesa

On 21. 3. 9. 오후 9:58, Dong Aisheng wrote:
> Fix the wrong set_freq path for userspace governor.
> 
> Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
> ---
>   drivers/devfreq/Kconfig | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/devfreq/Kconfig b/drivers/devfreq/Kconfig
> index 00704efe6398..20373a893b44 100644
> --- a/drivers/devfreq/Kconfig
> +++ b/drivers/devfreq/Kconfig
> @@ -62,7 +62,7 @@ config DEVFREQ_GOV_USERSPACE
>   	help
>   	  Sets the frequency at the user specified one.
>   	  This governor returns the user configured frequency if there
> -	  has been an input to /sys/devices/.../power/devfreq_set_freq.
> +	  has been an input to /sys/devices/.../userspace/set_freq.
>   	  Otherwise, the governor does not change the frequency
>   	  given at the initialization.
>   
> 

Looks good. But this patch just fix the information in Kconfig
instead of fixing the wrong operation. To clarify the commit message,
I'll change the patch title and commit message as following:

     PM / devfreq: Fix the wrong set_freq path for userspace governor in 
Kconfig

     Fix the wrong set_freq path for userspace governor in Kconfig.

     Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>


Applied it. But, if you have any other objection, please let me know.


-- 
Best Regards,
Samsung Electronics
Chanwoo Choi

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 02/11] PM / devfreq: remove the invalid description for get_target_freq
  2021-03-09 15:02   ` Chanwoo Choi
@ 2021-03-09 15:14     ` Dong Aisheng
  0 siblings, 0 replies; 58+ messages in thread
From: Dong Aisheng @ 2021-03-09 15:14 UTC (permalink / raw)
  To: Chanwoo Choi
  Cc: Dong Aisheng, Linux PM,
	moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE,
	Sascha Hauer, Shawn Guo, dl-linux-imx, open list, myungjoo.ham,
	kyungmin.park, Chanwoo Choi, Abel Vesa

On Tue, Mar 9, 2021 at 11:02 PM Chanwoo Choi <cwchoi00@gmail.com> wrote:
>
> On 21. 3. 9. 오후 9:58, Dong Aisheng wrote:
> > First of all, no_central_polling was removed since
> > commit 7e6fdd4bad03 ("PM / devfreq: Core updates to support devices
> > which can idle")
> > Secondly, get_target_freq() is not only called only with update_devfreq()
> > notified by OPP now, but also min/max freq qos notifier.
> >
> > So remove this invalid description now to avoid confusing.
> >
> > Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
> > ---
> >   drivers/devfreq/governor.h | 2 --
> >   1 file changed, 2 deletions(-)
> >
> > diff --git a/drivers/devfreq/governor.h b/drivers/devfreq/governor.h
> > index 70f44b3ca42e..5cee3f64fe2b 100644
> > --- a/drivers/devfreq/governor.h
> > +++ b/drivers/devfreq/governor.h
> > @@ -57,8 +57,6 @@
> >    *                  Basically, get_target_freq will run
> >    *                  devfreq_dev_profile.get_dev_status() to get the
> >    *                  status of the device (load = busy_time / total_time).
> > - *                   If no_central_polling is set, this callback is called
> > - *                   only with update_devfreq() notified by OPP.
> >    * @event_handler:      Callback for devfreq core framework to notify events
> >    *                      to governors. Events include per device governor
> >    *                      init and exit, opp changes out of devfreq, suspend
> >
>
> As I replied from patch1, I recommend that squash it with patch1.

Got it, i will squash when sending the next version.
Thanks

Regards
Aisheng

>
> --
> Best Regards,
> Samsung Electronics
> Chanwoo Choi

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 03/11] PM / devfreq: fix the wrong set_freq path for userspace governor
  2021-03-09 15:13   ` Chanwoo Choi
@ 2021-03-09 15:16     ` Dong Aisheng
  0 siblings, 0 replies; 58+ messages in thread
From: Dong Aisheng @ 2021-03-09 15:16 UTC (permalink / raw)
  To: Chanwoo Choi
  Cc: Dong Aisheng, Linux PM,
	moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE,
	Sascha Hauer, Shawn Guo, dl-linux-imx, open list, myungjoo.ham,
	kyungmin.park, Chanwoo Choi, Abel Vesa

On Tue, Mar 9, 2021 at 11:13 PM Chanwoo Choi <cwchoi00@gmail.com> wrote:
>
> On 21. 3. 9. 오후 9:58, Dong Aisheng wrote:
> > Fix the wrong set_freq path for userspace governor.
> >
> > Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
> > ---
> >   drivers/devfreq/Kconfig | 2 +-
> >   1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/devfreq/Kconfig b/drivers/devfreq/Kconfig
> > index 00704efe6398..20373a893b44 100644
> > --- a/drivers/devfreq/Kconfig
> > +++ b/drivers/devfreq/Kconfig
> > @@ -62,7 +62,7 @@ config DEVFREQ_GOV_USERSPACE
> >       help
> >         Sets the frequency at the user specified one.
> >         This governor returns the user configured frequency if there
> > -       has been an input to /sys/devices/.../power/devfreq_set_freq.
> > +       has been an input to /sys/devices/.../userspace/set_freq.
> >         Otherwise, the governor does not change the frequency
> >         given at the initialization.
> >
> >
>
> Looks good. But this patch just fix the information in Kconfig
> instead of fixing the wrong operation. To clarify the commit message,
> I'll change the patch title and commit message as following:

Looks like more accurate. Thanks.

Regards
Aisheng

>
>      PM / devfreq: Fix the wrong set_freq path for userspace governor in
> Kconfig
>
>      Fix the wrong set_freq path for userspace governor in Kconfig.
>
>      Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
>
>
> Applied it. But, if you have any other objection, please let me know.
>
>
> --
> Best Regards,
> Samsung Electronics
> Chanwoo Choi

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 04/11] PM / devfreq: bail out early if no freq changes in devfreq_set_target
  2021-03-09 12:58 ` [PATCH 04/11] PM / devfreq: bail out early if no freq changes in devfreq_set_target Dong Aisheng
@ 2021-03-09 15:47   ` Chanwoo Choi
  2021-03-10  2:42     ` Dong Aisheng
  0 siblings, 1 reply; 58+ messages in thread
From: Chanwoo Choi @ 2021-03-09 15:47 UTC (permalink / raw)
  To: Dong Aisheng, linux-pm, linux-arm-kernel
  Cc: dongas86, kernel, shawnguo, linux-imx, linux-kernel,
	myungjoo.ham, kyungmin.park, cw00.choi, abel.vesa

On 21. 3. 9. 오후 9:58, Dong Aisheng wrote:
> It's unnecessary to set the same freq again and run notifier calls.
> 
> Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
> ---
>   drivers/devfreq/devfreq.c | 5 ++++-
>   1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
> index bf3047896e41..6e80bf70e7b3 100644
> --- a/drivers/devfreq/devfreq.c
> +++ b/drivers/devfreq/devfreq.c
> @@ -358,6 +358,9 @@ static int devfreq_set_target(struct devfreq *devfreq, unsigned long new_freq,
>   	else
>   		cur_freq = devfreq->previous_freq;
>   
> +	if (new_freq == cur_freq)
> +		return 0;
> +
>   	freqs.old = cur_freq;
>   	freqs.new = new_freq;
>   	devfreq_notify_transition(devfreq, &freqs, DEVFREQ_PRECHANGE);
> @@ -374,7 +377,7 @@ static int devfreq_set_target(struct devfreq *devfreq, unsigned long new_freq,
>   	 * and DEVFREQ_POSTCHANGE because for showing the correct frequency
>   	 * change order of between devfreq device and passive devfreq device.
>   	 */
> -	if (trace_devfreq_frequency_enabled() && new_freq != cur_freq)
> +	if (trace_devfreq_frequency_enabled())
>   		trace_devfreq_frequency(devfreq, new_freq, cur_freq);
>   
>   	freqs.new = new_freq;
> 

I'd like you to squash patch4 with patch6 because actually patch6
is too minor clean-up. I think it is possible.

-- 
Best Regards,
Samsung Electronics
Chanwoo Choi

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 05/11] PM / devfreq: use more accurate returned new_freq as resume_freq
  2021-03-09 12:58 ` [PATCH 05/11] PM / devfreq: use more accurate returned new_freq as resume_freq Dong Aisheng
@ 2021-03-09 15:53   ` Chanwoo Choi
  2021-03-10  2:43     ` Dong Aisheng
  0 siblings, 1 reply; 58+ messages in thread
From: Chanwoo Choi @ 2021-03-09 15:53 UTC (permalink / raw)
  To: Dong Aisheng, linux-pm, linux-arm-kernel
  Cc: dongas86, kernel, shawnguo, linux-imx, linux-kernel,
	myungjoo.ham, kyungmin.park, cw00.choi, abel.vesa

On 21. 3. 9. 오후 9:58, Dong Aisheng wrote:
> Use the more accurate returned new_freq as resume_freq.
> It's the same as how devfreq->previous_freq was updated.
> 
> Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
> ---
>   drivers/devfreq/devfreq.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
> index 6e80bf70e7b3..ce569bd9adfa 100644
> --- a/drivers/devfreq/devfreq.c
> +++ b/drivers/devfreq/devfreq.c
> @@ -390,7 +390,7 @@ static int devfreq_set_target(struct devfreq *devfreq, unsigned long new_freq,
>   	devfreq->previous_freq = new_freq;
>   
>   	if (devfreq->suspend_freq)
> -		devfreq->resume_freq = cur_freq;
> +		devfreq->resume_freq = new_freq;
>   
>   	return err;
>   }
> 

This patch fixes the previous patch[1]. So that you need to
add 'Fixes' tag as following:

Fixes: 83f8ca45afbf0 ("PM / devfreq: add support for suspend/resume of a 
devfreq device")

commit 83f8ca45afbf041e312909f442128b99657d90b7
Refs: v4.20-rc6-2-g83f8ca45afbf
Author:     Lukasz Luba <lukasz.luba@arm.com>
AuthorDate: Wed Dec 5 12:05:53 2018 +0100
Commit:     MyungJoo Ham <myungjoo.ham@samsung.com>
CommitDate: Tue Dec 11 11:09:47 2018 +0900

     PM / devfreq: add support for suspend/resume of a devfreq device


-- 
Best Regards,
Samsung Electronics
Chanwoo Choi

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 07/11] PM / devfreq: check get_dev_status before start monitor
  2021-03-09 12:58 ` [PATCH 07/11] PM / devfreq: check get_dev_status before start monitor Dong Aisheng
@ 2021-03-09 15:58   ` Chanwoo Choi
  2021-03-09 16:12     ` Chanwoo Choi
  2021-03-10  2:51     ` Dong Aisheng
  0 siblings, 2 replies; 58+ messages in thread
From: Chanwoo Choi @ 2021-03-09 15:58 UTC (permalink / raw)
  To: Dong Aisheng, linux-pm, linux-arm-kernel
  Cc: dongas86, kernel, shawnguo, linux-imx, linux-kernel,
	myungjoo.ham, kyungmin.park, cw00.choi, abel.vesa

On 21. 3. 9. 오후 9:58, Dong Aisheng wrote:
> The devfreq monitor depends on the device to provide load information
> by .get_dev_status() to calculate the next target freq.
> 
> And this will cause changing governor to simple ondemand fail
> if device can't support.
> 
> Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
> ---
>   drivers/devfreq/devfreq.c                 | 10 +++++++---
>   drivers/devfreq/governor.h                |  2 +-
>   drivers/devfreq/governor_simpleondemand.c |  3 +--
>   3 files changed, 9 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
> index 7231fe6862a2..d1787b6c7d7c 100644
> --- a/drivers/devfreq/devfreq.c
> +++ b/drivers/devfreq/devfreq.c
> @@ -482,10 +482,13 @@ static void devfreq_monitor(struct work_struct *work)
>    * to be called from governor in response to DEVFREQ_GOV_START
>    * event when device is added to devfreq framework.
>    */
> -void devfreq_monitor_start(struct devfreq *devfreq)
> +int devfreq_monitor_start(struct devfreq *devfreq)
>   {
>   	if (IS_SUPPORTED_FLAG(devfreq->governor->flags, IRQ_DRIVEN))
> -		return;
> +		return 0;
> +
> +	if (!devfreq->profile->get_dev_status)
> +		return -EINVAL;
>   
>   	switch (devfreq->profile->timer) {
>   	case DEVFREQ_TIMER_DEFERRABLE:
> @@ -495,12 +498,13 @@ void devfreq_monitor_start(struct devfreq *devfreq)
>   		INIT_DELAYED_WORK(&devfreq->work, devfreq_monitor);
>   		break;
>   	default:
> -		return;
> +		return -EINVAL;
>   	}
>   
>   	if (devfreq->profile->polling_ms)
>   		queue_delayed_work(devfreq_wq, &devfreq->work,
>   			msecs_to_jiffies(devfreq->profile->polling_ms));
> +	return 0;
>   }
>   EXPORT_SYMBOL(devfreq_monitor_start);
>   
> diff --git a/drivers/devfreq/governor.h b/drivers/devfreq/governor.h
> index 5cee3f64fe2b..31af6d072a10 100644
> --- a/drivers/devfreq/governor.h
> +++ b/drivers/devfreq/governor.h
> @@ -75,7 +75,7 @@ struct devfreq_governor {
>   				unsigned int event, void *data);
>   };
>   
> -void devfreq_monitor_start(struct devfreq *devfreq);
> +int devfreq_monitor_start(struct devfreq *devfreq);
>   void devfreq_monitor_stop(struct devfreq *devfreq);
>   void devfreq_monitor_suspend(struct devfreq *devfreq);
>   void devfreq_monitor_resume(struct devfreq *devfreq);
> diff --git a/drivers/devfreq/governor_simpleondemand.c b/drivers/devfreq/governor_simpleondemand.c
> index d57b82a2b570..ea287b57cbf3 100644
> --- a/drivers/devfreq/governor_simpleondemand.c
> +++ b/drivers/devfreq/governor_simpleondemand.c
> @@ -89,8 +89,7 @@ static int devfreq_simple_ondemand_handler(struct devfreq *devfreq,
>   {
>   	switch (event) {
>   	case DEVFREQ_GOV_START:
> -		devfreq_monitor_start(devfreq);
> -		break;
> +		return devfreq_monitor_start(devfreq);
>   
>   	case DEVFREQ_GOV_STOP:
>   		devfreq_monitor_stop(devfreq);
> 

Need to handle the all points of devfreq_monitor_start() usage.
please check the tegra30-devfreq.c for this update.

$ grep -rn "devfreq_monitor_start" drivers/
drivers/devfreq/governor_simpleondemand.c:92: 
devfreq_monitor_start(devfreq);
drivers/devfreq/tegra30-devfreq.c:744:		devfreq_monitor_start(devfreq);
......

-- 
Best Regards,
Samsung Electronics
Chanwoo Choi

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 08/11] PM / devfreq: check get_dev_status in devfreq_update_stats
  2021-03-09 12:58 ` [PATCH 08/11] PM / devfreq: check get_dev_status in devfreq_update_stats Dong Aisheng
@ 2021-03-09 16:02   ` Chanwoo Choi
  2021-03-09 16:20   ` Chanwoo Choi
  1 sibling, 0 replies; 58+ messages in thread
From: Chanwoo Choi @ 2021-03-09 16:02 UTC (permalink / raw)
  To: Dong Aisheng, linux-pm, linux-arm-kernel
  Cc: dongas86, kernel, shawnguo, linux-imx, linux-kernel,
	myungjoo.ham, kyungmin.park, cw00.choi, abel.vesa

On 21. 3. 9. 오후 9:58, Dong Aisheng wrote:
> Check .get_dev_status() in devfreq_update_stats in case it's abused
> when a device does not provide it.
> 
> Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
> ---
>   drivers/devfreq/governor.h | 3 +++
>   1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/devfreq/governor.h b/drivers/devfreq/governor.h
> index 31af6d072a10..67a6dbdd5d23 100644
> --- a/drivers/devfreq/governor.h
> +++ b/drivers/devfreq/governor.h
> @@ -89,6 +89,9 @@ int devfreq_update_target(struct devfreq *devfreq, unsigned long freq);
>   
>   static inline int devfreq_update_stats(struct devfreq *df)
>   {
> +	if (!df->profile->get_dev_status)
> +		return -EINVAL;
> +
>   	return df->profile->get_dev_status(df->dev.parent, &df->last_status);
>   }
>   #endif /* _GOVERNOR_H */
> 

Applied it. Thanks.

-- 
Best Regards,
Samsung Electronics
Chanwoo Choi

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 09/11] PM / devfreq: governor: optimize simpleondemand get_target_freq
  2021-03-09 12:58 ` [PATCH 09/11] PM / devfreq: governor: optimize simpleondemand get_target_freq Dong Aisheng
@ 2021-03-09 16:09   ` Chanwoo Choi
  2021-03-10  3:02     ` Dong Aisheng
  0 siblings, 1 reply; 58+ messages in thread
From: Chanwoo Choi @ 2021-03-09 16:09 UTC (permalink / raw)
  To: Dong Aisheng, linux-pm, linux-arm-kernel
  Cc: dongas86, kernel, shawnguo, linux-imx, linux-kernel,
	myungjoo.ham, kyungmin.park, cw00.choi, abel.vesa

On 21. 3. 9. 오후 9:58, Dong Aisheng wrote:
> devfreq_simple_ondemand_data only needs to be initialized once when
> calling devm_devfreq_add_device. It's unnecessary to put the data
> check logic in the hot path (.get_target_freq()) where it will be
> called all the time during polling. Instead, we only check and initialize
> it one time during DEVFREQ_GOV_START.
> 
> This also helps check data validability in advance during DEVFREQ_GOV_START
> rather than checking it later when running .get_target_freq().
> 
> Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
> ---
>   drivers/devfreq/governor_simpleondemand.c | 50 +++++++++++++++--------
>   1 file changed, 34 insertions(+), 16 deletions(-)
> 
> diff --git a/drivers/devfreq/governor_simpleondemand.c b/drivers/devfreq/governor_simpleondemand.c
> index ea287b57cbf3..341eb7e9dc04 100644
> --- a/drivers/devfreq/governor_simpleondemand.c
> +++ b/drivers/devfreq/governor_simpleondemand.c
> @@ -15,15 +15,19 @@
>   /* Default constants for DevFreq-Simple-Ondemand (DFSO) */
>   #define DFSO_UPTHRESHOLD	(90)
>   #define DFSO_DOWNDIFFERENCTIAL	(5)
> +
> +static struct devfreq_simple_ondemand_data od_default = {
> +	.upthreshold = DFSO_UPTHRESHOLD,
> +	.downdifferential = DFSO_DOWNDIFFERENCTIAL,
> +};
> +
>   static int devfreq_simple_ondemand_func(struct devfreq *df,
>   					unsigned long *freq)
>   {
>   	int err;
>   	struct devfreq_dev_status *stat;
>   	unsigned long long a, b;
> -	unsigned int dfso_upthreshold = DFSO_UPTHRESHOLD;
> -	unsigned int dfso_downdifferential = DFSO_DOWNDIFFERENCTIAL;
> -	struct devfreq_simple_ondemand_data *data = df->data;
> +	struct devfreq_simple_ondemand_data *od = df->data;
>   
>   	err = devfreq_update_stats(df);
>   	if (err)
> @@ -31,16 +35,6 @@ static int devfreq_simple_ondemand_func(struct devfreq *df,
>   
>   	stat = &df->last_status;
>   
> -	if (data) {
> -		if (data->upthreshold)
> -			dfso_upthreshold = data->upthreshold;
> -		if (data->downdifferential)
> -			dfso_downdifferential = data->downdifferential;
> -	}
> -	if (dfso_upthreshold > 100 ||
> -	    dfso_upthreshold < dfso_downdifferential)
> -		return -EINVAL;
> -
>   	/* Assume MAX if it is going to be divided by zero */
>   	if (stat->total_time == 0) {
>   		*freq = DEVFREQ_MAX_FREQ;
> @@ -55,7 +49,7 @@ static int devfreq_simple_ondemand_func(struct devfreq *df,
>   
>   	/* Set MAX if it's busy enough */
>   	if (stat->busy_time * 100 >
> -	    stat->total_time * dfso_upthreshold) {
> +	    stat->total_time * od->upthreshold) {
>   		*freq = DEVFREQ_MAX_FREQ;
>   		return 0;
>   	}
> @@ -68,7 +62,7 @@ static int devfreq_simple_ondemand_func(struct devfreq *df,
>   
>   	/* Keep the current frequency */
>   	if (stat->busy_time * 100 >
> -	    stat->total_time * (dfso_upthreshold - dfso_downdifferential)) {
> +	    stat->total_time * (od->upthreshold - od->downdifferential)) {
>   		*freq = stat->current_frequency;
>   		return 0;
>   	}
> @@ -78,17 +72,41 @@ static int devfreq_simple_ondemand_func(struct devfreq *df,
>   	a *= stat->current_frequency;
>   	b = div_u64(a, stat->total_time);
>   	b *= 100;
> -	b = div_u64(b, (dfso_upthreshold - dfso_downdifferential / 2));
> +	b = div_u64(b, (od->upthreshold - od->downdifferential / 2));
>   	*freq = (unsigned long) b;
>   
>   	return 0;
>   }
>   
> +static int devfreq_simple_ondemand_check_od(struct devfreq *devfreq)
> +{
> +	struct devfreq_simple_ondemand_data *od = devfreq->data;
> +
> +	if (od) {
> +		if (!od->upthreshold)
> +			od->upthreshold = DFSO_UPTHRESHOLD;
> +
> +		if (!od->downdifferential)
> +			od->downdifferential = DFSO_DOWNDIFFERENCTIAL;
> +
> +		if (od->upthreshold > 100 ||
> +		    od->upthreshold < od->downdifferential)
> +			return -EINVAL;
> +	} else {
> +		od = &od_default;
> +	}
> +
> +	return 0;
> +}
> +
>   static int devfreq_simple_ondemand_handler(struct devfreq *devfreq,
>   				unsigned int event, void *data)
>   {
>   	switch (event) {
>   	case DEVFREQ_GOV_START:
> +		if (devfreq_simple_ondemand_check_od(devfreq))
> +			return -EINVAL;
> +
>   		return devfreq_monitor_start(devfreq);
>   
>   	case DEVFREQ_GOV_STOP:
> 

I'm editing the upthreshold and downdifferential for exposing them
via sysfs. So that after my work to expose them via sysfs,
send the patches if you think that need to do more about them.

[1] 
https://git.kernel.org/pub/scm/linux/kernel/git/chanwoo/linux.git/commit/?h=devfreq-testing&id=dc9e557845c17cee173a6adcc3ae14940da03f44

-- 
Best Regards,
Samsung Electronics
Chanwoo Choi

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 07/11] PM / devfreq: check get_dev_status before start monitor
  2021-03-09 15:58   ` Chanwoo Choi
@ 2021-03-09 16:12     ` Chanwoo Choi
  2021-03-10  2:56       ` Dong Aisheng
  2021-03-10  2:51     ` Dong Aisheng
  1 sibling, 1 reply; 58+ messages in thread
From: Chanwoo Choi @ 2021-03-09 16:12 UTC (permalink / raw)
  To: Dong Aisheng, linux-pm, linux-arm-kernel
  Cc: dongas86, kernel, shawnguo, linux-imx, linux-kernel,
	myungjoo.ham, kyungmin.park, cw00.choi, abel.vesa

On 21. 3. 10. 오전 12:58, Chanwoo Choi wrote:
> On 21. 3. 9. 오후 9:58, Dong Aisheng wrote:
>> The devfreq monitor depends on the device to provide load information
>> by .get_dev_status() to calculate the next target freq.
>>
>> And this will cause changing governor to simple ondemand fail
>> if device can't support.
>>
>> Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
>> ---
>>   drivers/devfreq/devfreq.c                 | 10 +++++++---
>>   drivers/devfreq/governor.h                |  2 +-
>>   drivers/devfreq/governor_simpleondemand.c |  3 +--
>>   3 files changed, 9 insertions(+), 6 deletions(-)
>>
>> diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
>> index 7231fe6862a2..d1787b6c7d7c 100644
>> --- a/drivers/devfreq/devfreq.c
>> +++ b/drivers/devfreq/devfreq.c
>> @@ -482,10 +482,13 @@ static void devfreq_monitor(struct work_struct 
>> *work)
>>    * to be called from governor in response to DEVFREQ_GOV_START
>>    * event when device is added to devfreq framework.
>>    */
>> -void devfreq_monitor_start(struct devfreq *devfreq)
>> +int devfreq_monitor_start(struct devfreq *devfreq)
>>   {
>>       if (IS_SUPPORTED_FLAG(devfreq->governor->flags, IRQ_DRIVEN))
>> -        return;
>> +        return 0;
>> +
>> +    if (!devfreq->profile->get_dev_status)
>> +        return -EINVAL;

Again, I think that get_dev_status is not used for all governors.
So that it cause the governor start fail. Don't check whether
.get_dev_status is NULL or not.

>>       switch (devfreq->profile->timer) {
>>       case DEVFREQ_TIMER_DEFERRABLE:
>> @@ -495,12 +498,13 @@ void devfreq_monitor_start(struct devfreq *devfreq)
>>           INIT_DELAYED_WORK(&devfreq->work, devfreq_monitor);
>>           break;
>>       default:
>> -        return;
>> +        return -EINVAL;
>>       }
>>       if (devfreq->profile->polling_ms)
>>           queue_delayed_work(devfreq_wq, &devfreq->work,
>>               msecs_to_jiffies(devfreq->profile->polling_ms));
>> +    return 0;
>>   }
>>   EXPORT_SYMBOL(devfreq_monitor_start);
>> diff --git a/drivers/devfreq/governor.h b/drivers/devfreq/governor.h
>> index 5cee3f64fe2b..31af6d072a10 100644
>> --- a/drivers/devfreq/governor.h
>> +++ b/drivers/devfreq/governor.h
>> @@ -75,7 +75,7 @@ struct devfreq_governor {
>>                   unsigned int event, void *data);
>>   };
>> -void devfreq_monitor_start(struct devfreq *devfreq);
>> +int devfreq_monitor_start(struct devfreq *devfreq);
>>   void devfreq_monitor_stop(struct devfreq *devfreq);
>>   void devfreq_monitor_suspend(struct devfreq *devfreq);
>>   void devfreq_monitor_resume(struct devfreq *devfreq);
>> diff --git a/drivers/devfreq/governor_simpleondemand.c 
>> b/drivers/devfreq/governor_simpleondemand.c
>> index d57b82a2b570..ea287b57cbf3 100644
>> --- a/drivers/devfreq/governor_simpleondemand.c
>> +++ b/drivers/devfreq/governor_simpleondemand.c
>> @@ -89,8 +89,7 @@ static int devfreq_simple_ondemand_handler(struct 
>> devfreq *devfreq,
>>   {
>>       switch (event) {
>>       case DEVFREQ_GOV_START:
>> -        devfreq_monitor_start(devfreq);
>> -        break;
>> +        return devfreq_monitor_start(devfreq);
>>       case DEVFREQ_GOV_STOP:
>>           devfreq_monitor_stop(devfreq);
>>
> 
> Need to handle the all points of devfreq_monitor_start() usage.
> please check the tegra30-devfreq.c for this update.
> 
> $ grep -rn "devfreq_monitor_start" drivers/
> drivers/devfreq/governor_simpleondemand.c:92: 
> devfreq_monitor_start(devfreq);
> drivers/devfreq/tegra30-devfreq.c:744:        
> devfreq_monitor_start(devfreq);
> ......
> 


-- 
Best Regards,
Samsung Electronics
Chanwoo Choi

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 08/11] PM / devfreq: check get_dev_status in devfreq_update_stats
  2021-03-09 12:58 ` [PATCH 08/11] PM / devfreq: check get_dev_status in devfreq_update_stats Dong Aisheng
  2021-03-09 16:02   ` Chanwoo Choi
@ 2021-03-09 16:20   ` Chanwoo Choi
  2021-03-10  3:00     ` Dong Aisheng
  1 sibling, 1 reply; 58+ messages in thread
From: Chanwoo Choi @ 2021-03-09 16:20 UTC (permalink / raw)
  To: Dong Aisheng, linux-pm, linux-arm-kernel
  Cc: dongas86, kernel, shawnguo, linux-imx, linux-kernel,
	myungjoo.ham, kyungmin.park, cw00.choi, abel.vesa

On 21. 3. 9. 오후 9:58, Dong Aisheng wrote:
> Check .get_dev_status() in devfreq_update_stats in case it's abused
> when a device does not provide it.
> 
> Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
> ---
>   drivers/devfreq/governor.h | 3 +++
>   1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/devfreq/governor.h b/drivers/devfreq/governor.h
> index 31af6d072a10..67a6dbdd5d23 100644
> --- a/drivers/devfreq/governor.h
> +++ b/drivers/devfreq/governor.h
> @@ -89,6 +89,9 @@ int devfreq_update_target(struct devfreq *devfreq, unsigned long freq);
>   
>   static inline int devfreq_update_stats(struct devfreq *df)
>   {
> +	if (!df->profile->get_dev_status)
> +		return -EINVAL;
> +

I'm considering the following method instead of returning the error
when .get_dev_status is NULL.

	if (!df->profile->get_dev_status) {
		df->last_status.total_time = 0;
		df->last_status.busy_time = 0;
		df->last_status.current_frequency = 0;
		return 0;	
	}	

>   	return df->profile->get_dev_status(df->dev.parent, &df->last_status);
>   }
>   #endif /* _GOVERNOR_H */
> 


-- 
Best Regards,
Samsung Electronics
Chanwoo Choi

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 10/11] PM / devfreq: imx8m-ddrc: remove imx8m_ddrc_get_dev_status
  2021-03-09 12:58 ` [PATCH 10/11] PM / devfreq: imx8m-ddrc: remove imx8m_ddrc_get_dev_status Dong Aisheng
@ 2021-03-09 16:22   ` Chanwoo Choi
  0 siblings, 0 replies; 58+ messages in thread
From: Chanwoo Choi @ 2021-03-09 16:22 UTC (permalink / raw)
  To: Dong Aisheng, linux-pm, linux-arm-kernel
  Cc: dongas86, kernel, shawnguo, linux-imx, linux-kernel,
	myungjoo.ham, kyungmin.park, cw00.choi, abel.vesa

On 21. 3. 9. 오후 9:58, Dong Aisheng wrote:
> Current driver actually does not support simple ondemand governor
> as it's unable to provide device load information. So removing
> the unnecessary callback to avoid confusing.
> Right now the driver is using userspace governor by default.
> 
> Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
> ---
>   drivers/devfreq/imx8m-ddrc.c | 13 -------------
>   1 file changed, 13 deletions(-)
> 
> diff --git a/drivers/devfreq/imx8m-ddrc.c b/drivers/devfreq/imx8m-ddrc.c
> index bc82d3653bff..0a6b7a1c829d 100644
> --- a/drivers/devfreq/imx8m-ddrc.c
> +++ b/drivers/devfreq/imx8m-ddrc.c
> @@ -280,18 +280,6 @@ static int imx8m_ddrc_get_cur_freq(struct device *dev, unsigned long *freq)
>   	return 0;
>   }
>   
> -static int imx8m_ddrc_get_dev_status(struct device *dev,
> -				     struct devfreq_dev_status *stat)
> -{
> -	struct imx8m_ddrc *priv = dev_get_drvdata(dev);
> -
> -	stat->busy_time = 0;
> -	stat->total_time = 0;
> -	stat->current_frequency = clk_get_rate(priv->dram_core);
> -
> -	return 0;
> -}
> -
>   static int imx8m_ddrc_init_freq_info(struct device *dev)
>   {
>   	struct imx8m_ddrc *priv = dev_get_drvdata(dev);
> @@ -431,7 +419,6 @@ static int imx8m_ddrc_probe(struct platform_device *pdev)
>   
>   	priv->profile.polling_ms = 1000;
>   	priv->profile.target = imx8m_ddrc_target;
> -	priv->profile.get_dev_status = imx8m_ddrc_get_dev_status;
>   	priv->profile.exit = imx8m_ddrc_exit;
>   	priv->profile.get_cur_freq = imx8m_ddrc_get_cur_freq;
>   	priv->profile.initial_freq = clk_get_rate(priv->dram_core);
> 

Acked-by: Chanwoo Choi <cw00.choi@samsung.com>

Will merge this patch after finishing the discussion of
prev patch related to.get_dev_status.

-- 
Best Regards,
Samsung Electronics
Chanwoo Choi

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 11/11] PM / devfreq: imx8m-ddrc: drop polling_ms
  2021-03-09 12:58 ` [PATCH 11/11] PM / devfreq: imx8m-ddrc: drop polling_ms Dong Aisheng
@ 2021-03-09 16:23   ` Chanwoo Choi
  2021-03-10  3:03     ` Dong Aisheng
  0 siblings, 1 reply; 58+ messages in thread
From: Chanwoo Choi @ 2021-03-09 16:23 UTC (permalink / raw)
  To: Dong Aisheng, linux-pm, linux-arm-kernel
  Cc: dongas86, kernel, shawnguo, linux-imx, linux-kernel,
	myungjoo.ham, kyungmin.park, cw00.choi, abel.vesa

On 21. 3. 9. 오후 9:58, Dong Aisheng wrote:
> polling_ms is only used by simple ondemand governor which
> this driver can't support. Drop it to avoid confusing.
> 
> Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
> ---
>   drivers/devfreq/imx8m-ddrc.c | 1 -
>   1 file changed, 1 deletion(-)
> 
> diff --git a/drivers/devfreq/imx8m-ddrc.c b/drivers/devfreq/imx8m-ddrc.c
> index 0a6b7a1c829d..ecb9375aa877 100644
> --- a/drivers/devfreq/imx8m-ddrc.c
> +++ b/drivers/devfreq/imx8m-ddrc.c
> @@ -417,7 +417,6 @@ static int imx8m_ddrc_probe(struct platform_device *pdev)
>   	if (ret < 0)
>   		goto err;
>   
> -	priv->profile.polling_ms = 1000;
>   	priv->profile.target = imx8m_ddrc_target;
>   	priv->profile.exit = imx8m_ddrc_exit;
>   	priv->profile.get_cur_freq = imx8m_ddrc_get_cur_freq;
> 

You can squash this patch with patch10 because polling_ms
is related to .get_dev_status.

-- 
Best Regards,
Samsung Electronics
Chanwoo Choi

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 04/11] PM / devfreq: bail out early if no freq changes in devfreq_set_target
  2021-03-09 15:47   ` Chanwoo Choi
@ 2021-03-10  2:42     ` Dong Aisheng
  0 siblings, 0 replies; 58+ messages in thread
From: Dong Aisheng @ 2021-03-10  2:42 UTC (permalink / raw)
  To: Chanwoo Choi
  Cc: Dong Aisheng, Linux PM,
	moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE,
	Sascha Hauer, Shawn Guo, dl-linux-imx, open list, myungjoo.ham,
	kyungmin.park, Chanwoo Choi, Abel Vesa

On Tue, Mar 9, 2021 at 11:47 PM Chanwoo Choi <cwchoi00@gmail.com> wrote:
>
> On 21. 3. 9. 오후 9:58, Dong Aisheng wrote:
> > It's unnecessary to set the same freq again and run notifier calls.
> >
> > Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
> > ---
> >   drivers/devfreq/devfreq.c | 5 ++++-
> >   1 file changed, 4 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
> > index bf3047896e41..6e80bf70e7b3 100644
> > --- a/drivers/devfreq/devfreq.c
> > +++ b/drivers/devfreq/devfreq.c
> > @@ -358,6 +358,9 @@ static int devfreq_set_target(struct devfreq *devfreq, unsigned long new_freq,
> >       else
> >               cur_freq = devfreq->previous_freq;
> >
> > +     if (new_freq == cur_freq)
> > +             return 0;
> > +
> >       freqs.old = cur_freq;
> >       freqs.new = new_freq;
> >       devfreq_notify_transition(devfreq, &freqs, DEVFREQ_PRECHANGE);
> > @@ -374,7 +377,7 @@ static int devfreq_set_target(struct devfreq *devfreq, unsigned long new_freq,
> >        * and DEVFREQ_POSTCHANGE because for showing the correct frequency
> >        * change order of between devfreq device and passive devfreq device.
> >        */
> > -     if (trace_devfreq_frequency_enabled() && new_freq != cur_freq)
> > +     if (trace_devfreq_frequency_enabled())
> >               trace_devfreq_frequency(devfreq, new_freq, cur_freq);
> >
> >       freqs.new = new_freq;
> >
>
> I'd like you to squash patch4 with patch6 because actually patch6
> is too minor clean-up. I think it is possible.

Got it, will squash when re-send.

Regards
Aisheng

>
> --
> Best Regards,
> Samsung Electronics
> Chanwoo Choi

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 05/11] PM / devfreq: use more accurate returned new_freq as resume_freq
  2021-03-09 15:53   ` Chanwoo Choi
@ 2021-03-10  2:43     ` Dong Aisheng
  2021-03-10  3:07       ` Chanwoo Choi
  0 siblings, 1 reply; 58+ messages in thread
From: Dong Aisheng @ 2021-03-10  2:43 UTC (permalink / raw)
  To: Chanwoo Choi
  Cc: Dong Aisheng, Linux PM,
	moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE,
	Sascha Hauer, Shawn Guo, dl-linux-imx, open list, myungjoo.ham,
	kyungmin.park, Chanwoo Choi, Abel Vesa

On Tue, Mar 9, 2021 at 11:53 PM Chanwoo Choi <cwchoi00@gmail.com> wrote:
>
> On 21. 3. 9. 오후 9:58, Dong Aisheng wrote:
> > Use the more accurate returned new_freq as resume_freq.
> > It's the same as how devfreq->previous_freq was updated.
> >
> > Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
> > ---
> >   drivers/devfreq/devfreq.c | 2 +-
> >   1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
> > index 6e80bf70e7b3..ce569bd9adfa 100644
> > --- a/drivers/devfreq/devfreq.c
> > +++ b/drivers/devfreq/devfreq.c
> > @@ -390,7 +390,7 @@ static int devfreq_set_target(struct devfreq *devfreq, unsigned long new_freq,
> >       devfreq->previous_freq = new_freq;
> >
> >       if (devfreq->suspend_freq)
> > -             devfreq->resume_freq = cur_freq;
> > +             devfreq->resume_freq = new_freq;
> >
> >       return err;
> >   }
> >
>
> This patch fixes the previous patch[1]. So that you need to
> add 'Fixes' tag as following:
>
> Fixes: 83f8ca45afbf0 ("PM / devfreq: add support for suspend/resume of a
> devfreq device")
>

Will add Fixes tag in next version.

> commit 83f8ca45afbf041e312909f442128b99657d90b7
> Refs: v4.20-rc6-2-g83f8ca45afbf
> Author:     Lukasz Luba <lukasz.luba@arm.com>
> AuthorDate: Wed Dec 5 12:05:53 2018 +0100
> Commit:     MyungJoo Ham <myungjoo.ham@samsung.com>
> CommitDate: Tue Dec 11 11:09:47 2018 +0900
>
>      PM / devfreq: add support for suspend/resume of a devfreq device
>
>
> --
> Best Regards,
> Samsung Electronics
> Chanwoo Choi

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 07/11] PM / devfreq: check get_dev_status before start monitor
  2021-03-09 15:58   ` Chanwoo Choi
  2021-03-09 16:12     ` Chanwoo Choi
@ 2021-03-10  2:51     ` Dong Aisheng
  1 sibling, 0 replies; 58+ messages in thread
From: Dong Aisheng @ 2021-03-10  2:51 UTC (permalink / raw)
  To: Chanwoo Choi
  Cc: Dong Aisheng, Linux PM,
	moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE,
	Sascha Hauer, Shawn Guo, dl-linux-imx, open list, myungjoo.ham,
	kyungmin.park, Chanwoo Choi, Abel Vesa

On Tue, Mar 9, 2021 at 11:58 PM Chanwoo Choi <cwchoi00@gmail.com> wrote:
>
> On 21. 3. 9. 오후 9:58, Dong Aisheng wrote:
> > The devfreq monitor depends on the device to provide load information
> > by .get_dev_status() to calculate the next target freq.
> >
> > And this will cause changing governor to simple ondemand fail
> > if device can't support.
> >
> > Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
> > ---
> >   drivers/devfreq/devfreq.c                 | 10 +++++++---
> >   drivers/devfreq/governor.h                |  2 +-
> >   drivers/devfreq/governor_simpleondemand.c |  3 +--
> >   3 files changed, 9 insertions(+), 6 deletions(-)
> >
> > diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
> > index 7231fe6862a2..d1787b6c7d7c 100644
> > --- a/drivers/devfreq/devfreq.c
> > +++ b/drivers/devfreq/devfreq.c
> > @@ -482,10 +482,13 @@ static void devfreq_monitor(struct work_struct *work)
> >    * to be called from governor in response to DEVFREQ_GOV_START
> >    * event when device is added to devfreq framework.
> >    */
> > -void devfreq_monitor_start(struct devfreq *devfreq)
> > +int devfreq_monitor_start(struct devfreq *devfreq)
> >   {
> >       if (IS_SUPPORTED_FLAG(devfreq->governor->flags, IRQ_DRIVEN))
> > -             return;
> > +             return 0;
> > +
> > +     if (!devfreq->profile->get_dev_status)
> > +             return -EINVAL;
> >
> >       switch (devfreq->profile->timer) {
> >       case DEVFREQ_TIMER_DEFERRABLE:
> > @@ -495,12 +498,13 @@ void devfreq_monitor_start(struct devfreq *devfreq)
> >               INIT_DELAYED_WORK(&devfreq->work, devfreq_monitor);
> >               break;
> >       default:
> > -             return;
> > +             return -EINVAL;
> >       }
> >
> >       if (devfreq->profile->polling_ms)
> >               queue_delayed_work(devfreq_wq, &devfreq->work,
> >                       msecs_to_jiffies(devfreq->profile->polling_ms));
> > +     return 0;
> >   }
> >   EXPORT_SYMBOL(devfreq_monitor_start);
> >
> > diff --git a/drivers/devfreq/governor.h b/drivers/devfreq/governor.h
> > index 5cee3f64fe2b..31af6d072a10 100644
> > --- a/drivers/devfreq/governor.h
> > +++ b/drivers/devfreq/governor.h
> > @@ -75,7 +75,7 @@ struct devfreq_governor {
> >                               unsigned int event, void *data);
> >   };
> >
> > -void devfreq_monitor_start(struct devfreq *devfreq);
> > +int devfreq_monitor_start(struct devfreq *devfreq);
> >   void devfreq_monitor_stop(struct devfreq *devfreq);
> >   void devfreq_monitor_suspend(struct devfreq *devfreq);
> >   void devfreq_monitor_resume(struct devfreq *devfreq);
> > diff --git a/drivers/devfreq/governor_simpleondemand.c b/drivers/devfreq/governor_simpleondemand.c
> > index d57b82a2b570..ea287b57cbf3 100644
> > --- a/drivers/devfreq/governor_simpleondemand.c
> > +++ b/drivers/devfreq/governor_simpleondemand.c
> > @@ -89,8 +89,7 @@ static int devfreq_simple_ondemand_handler(struct devfreq *devfreq,
> >   {
> >       switch (event) {
> >       case DEVFREQ_GOV_START:
> > -             devfreq_monitor_start(devfreq);
> > -             break;
> > +             return devfreq_monitor_start(devfreq);
> >
> >       case DEVFREQ_GOV_STOP:
> >               devfreq_monitor_stop(devfreq);
> >
>
> Need to handle the all points of devfreq_monitor_start() usage.
> please check the tegra30-devfreq.c for this update.
>
> $ grep -rn "devfreq_monitor_start" drivers/
> drivers/devfreq/governor_simpleondemand.c:92:
> devfreq_monitor_start(devfreq);
> drivers/devfreq/tegra30-devfreq.c:744:          devfreq_monitor_start(devfreq);

I can add error check for tegra in the next versions.
Thanks

Regards
Aisheng

> ......
>
> --
> Best Regards,
> Samsung Electronics
> Chanwoo Choi

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 07/11] PM / devfreq: check get_dev_status before start monitor
  2021-03-09 16:12     ` Chanwoo Choi
@ 2021-03-10  2:56       ` Dong Aisheng
  2021-03-10  3:25         ` Chanwoo Choi
  0 siblings, 1 reply; 58+ messages in thread
From: Dong Aisheng @ 2021-03-10  2:56 UTC (permalink / raw)
  To: Chanwoo Choi
  Cc: Dong Aisheng, Linux PM,
	moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE,
	Sascha Hauer, Shawn Guo, dl-linux-imx, open list, myungjoo.ham,
	kyungmin.park, Chanwoo Choi, Abel Vesa

On Wed, Mar 10, 2021 at 12:12 AM Chanwoo Choi <cwchoi00@gmail.com> wrote:
>
> On 21. 3. 10. 오전 12:58, Chanwoo Choi wrote:
> > On 21. 3. 9. 오후 9:58, Dong Aisheng wrote:
> >> The devfreq monitor depends on the device to provide load information
> >> by .get_dev_status() to calculate the next target freq.
> >>
> >> And this will cause changing governor to simple ondemand fail
> >> if device can't support.
> >>
> >> Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
> >> ---
> >>   drivers/devfreq/devfreq.c                 | 10 +++++++---
> >>   drivers/devfreq/governor.h                |  2 +-
> >>   drivers/devfreq/governor_simpleondemand.c |  3 +--
> >>   3 files changed, 9 insertions(+), 6 deletions(-)
> >>
> >> diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
> >> index 7231fe6862a2..d1787b6c7d7c 100644
> >> --- a/drivers/devfreq/devfreq.c
> >> +++ b/drivers/devfreq/devfreq.c
> >> @@ -482,10 +482,13 @@ static void devfreq_monitor(struct work_struct
> >> *work)
> >>    * to be called from governor in response to DEVFREQ_GOV_START
> >>    * event when device is added to devfreq framework.
> >>    */
> >> -void devfreq_monitor_start(struct devfreq *devfreq)
> >> +int devfreq_monitor_start(struct devfreq *devfreq)
> >>   {
> >>       if (IS_SUPPORTED_FLAG(devfreq->governor->flags, IRQ_DRIVEN))
> >> -        return;
> >> +        return 0;
> >> +
> >> +    if (!devfreq->profile->get_dev_status)
> >> +        return -EINVAL;
>
> Again, I think that get_dev_status is not used for all governors.
> So that it cause the governor start fail. Don't check whether
> .get_dev_status is NULL or not.
>

I'm not quite understand your point.
it is used by governor_simpleondemand.c and tegra_devfreq_governor.
get_target_freq -> devfreq_update_stats -> get_dev_status

Without checking, device can switch to ondemand governor if it does not support.

Am i missed something?

Regards
Aisheng

> >>       switch (devfreq->profile->timer) {
> >>       case DEVFREQ_TIMER_DEFERRABLE:
> >> @@ -495,12 +498,13 @@ void devfreq_monitor_start(struct devfreq *devfreq)
> >>           INIT_DELAYED_WORK(&devfreq->work, devfreq_monitor);
> >>           break;
> >>       default:
> >> -        return;
> >> +        return -EINVAL;
> >>       }
> >>       if (devfreq->profile->polling_ms)
> >>           queue_delayed_work(devfreq_wq, &devfreq->work,
> >>               msecs_to_jiffies(devfreq->profile->polling_ms));
> >> +    return 0;
> >>   }
> >>   EXPORT_SYMBOL(devfreq_monitor_start);
> >> diff --git a/drivers/devfreq/governor.h b/drivers/devfreq/governor.h
> >> index 5cee3f64fe2b..31af6d072a10 100644
> >> --- a/drivers/devfreq/governor.h
> >> +++ b/drivers/devfreq/governor.h
> >> @@ -75,7 +75,7 @@ struct devfreq_governor {
> >>                   unsigned int event, void *data);
> >>   };
> >> -void devfreq_monitor_start(struct devfreq *devfreq);
> >> +int devfreq_monitor_start(struct devfreq *devfreq);
> >>   void devfreq_monitor_stop(struct devfreq *devfreq);
> >>   void devfreq_monitor_suspend(struct devfreq *devfreq);
> >>   void devfreq_monitor_resume(struct devfreq *devfreq);
> >> diff --git a/drivers/devfreq/governor_simpleondemand.c
> >> b/drivers/devfreq/governor_simpleondemand.c
> >> index d57b82a2b570..ea287b57cbf3 100644
> >> --- a/drivers/devfreq/governor_simpleondemand.c
> >> +++ b/drivers/devfreq/governor_simpleondemand.c
> >> @@ -89,8 +89,7 @@ static int devfreq_simple_ondemand_handler(struct
> >> devfreq *devfreq,
> >>   {
> >>       switch (event) {
> >>       case DEVFREQ_GOV_START:
> >> -        devfreq_monitor_start(devfreq);
> >> -        break;
> >> +        return devfreq_monitor_start(devfreq);
> >>       case DEVFREQ_GOV_STOP:
> >>           devfreq_monitor_stop(devfreq);
> >>
> >
> > Need to handle the all points of devfreq_monitor_start() usage.
> > please check the tegra30-devfreq.c for this update.
> >
> > $ grep -rn "devfreq_monitor_start" drivers/
> > drivers/devfreq/governor_simpleondemand.c:92:
> > devfreq_monitor_start(devfreq);
> > drivers/devfreq/tegra30-devfreq.c:744:
> > devfreq_monitor_start(devfreq);
> > ......
> >
>
>
> --
> Best Regards,
> Samsung Electronics
> Chanwoo Choi

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 08/11] PM / devfreq: check get_dev_status in devfreq_update_stats
  2021-03-09 16:20   ` Chanwoo Choi
@ 2021-03-10  3:00     ` Dong Aisheng
  2021-03-11  7:01       ` Chanwoo Choi
  0 siblings, 1 reply; 58+ messages in thread
From: Dong Aisheng @ 2021-03-10  3:00 UTC (permalink / raw)
  To: Chanwoo Choi
  Cc: Dong Aisheng, Linux PM,
	moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE,
	Sascha Hauer, Shawn Guo, dl-linux-imx, open list, myungjoo.ham,
	kyungmin.park, Chanwoo Choi, Abel Vesa

On Wed, Mar 10, 2021 at 12:20 AM Chanwoo Choi <cwchoi00@gmail.com> wrote:
>
> On 21. 3. 9. 오후 9:58, Dong Aisheng wrote:
> > Check .get_dev_status() in devfreq_update_stats in case it's abused
> > when a device does not provide it.
> >
> > Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
> > ---
> >   drivers/devfreq/governor.h | 3 +++
> >   1 file changed, 3 insertions(+)
> >
> > diff --git a/drivers/devfreq/governor.h b/drivers/devfreq/governor.h
> > index 31af6d072a10..67a6dbdd5d23 100644
> > --- a/drivers/devfreq/governor.h
> > +++ b/drivers/devfreq/governor.h
> > @@ -89,6 +89,9 @@ int devfreq_update_target(struct devfreq *devfreq, unsigned long freq);
> >
> >   static inline int devfreq_update_stats(struct devfreq *df)
> >   {
> > +     if (!df->profile->get_dev_status)
> > +             return -EINVAL;
> > +
>
> I'm considering the following method instead of returning the error
> when .get_dev_status is NULL.
>
>         if (!df->profile->get_dev_status) {
>                 df->last_status.total_time = 0;
>                 df->last_status.busy_time = 0;
>                 df->last_status.current_frequency = 0;
>                 return 0;
>         }

I might  suggest not cause it's meaningless for ondemand governor but
introducing confusing. Simply return error could make the life a bit easier.
does it make sense to you?

Regards
Aisheng

>
> >       return df->profile->get_dev_status(df->dev.parent, &df->last_status);
> >   }
> >   #endif /* _GOVERNOR_H */
> >
>
>
> --
> Best Regards,
> Samsung Electronics
> Chanwoo Choi

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 09/11] PM / devfreq: governor: optimize simpleondemand get_target_freq
  2021-03-09 16:09   ` Chanwoo Choi
@ 2021-03-10  3:02     ` Dong Aisheng
  0 siblings, 0 replies; 58+ messages in thread
From: Dong Aisheng @ 2021-03-10  3:02 UTC (permalink / raw)
  To: Chanwoo Choi
  Cc: Dong Aisheng, Linux PM,
	moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE,
	Sascha Hauer, Shawn Guo, dl-linux-imx, open list, myungjoo.ham,
	kyungmin.park, Chanwoo Choi, Abel Vesa

On Wed, Mar 10, 2021 at 12:09 AM Chanwoo Choi <cwchoi00@gmail.com> wrote:
>
> On 21. 3. 9. 오후 9:58, Dong Aisheng wrote:
> > devfreq_simple_ondemand_data only needs to be initialized once when
> > calling devm_devfreq_add_device. It's unnecessary to put the data
> > check logic in the hot path (.get_target_freq()) where it will be
> > called all the time during polling. Instead, we only check and initialize
> > it one time during DEVFREQ_GOV_START.
> >
> > This also helps check data validability in advance during DEVFREQ_GOV_START
> > rather than checking it later when running .get_target_freq().
> >
> > Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
> > ---
> >   drivers/devfreq/governor_simpleondemand.c | 50 +++++++++++++++--------
> >   1 file changed, 34 insertions(+), 16 deletions(-)
> >
> > diff --git a/drivers/devfreq/governor_simpleondemand.c b/drivers/devfreq/governor_simpleondemand.c
> > index ea287b57cbf3..341eb7e9dc04 100644
> > --- a/drivers/devfreq/governor_simpleondemand.c
> > +++ b/drivers/devfreq/governor_simpleondemand.c
> > @@ -15,15 +15,19 @@
> >   /* Default constants for DevFreq-Simple-Ondemand (DFSO) */
> >   #define DFSO_UPTHRESHOLD    (90)
> >   #define DFSO_DOWNDIFFERENCTIAL      (5)
> > +
> > +static struct devfreq_simple_ondemand_data od_default = {
> > +     .upthreshold = DFSO_UPTHRESHOLD,
> > +     .downdifferential = DFSO_DOWNDIFFERENCTIAL,
> > +};
> > +
> >   static int devfreq_simple_ondemand_func(struct devfreq *df,
> >                                       unsigned long *freq)
> >   {
> >       int err;
> >       struct devfreq_dev_status *stat;
> >       unsigned long long a, b;
> > -     unsigned int dfso_upthreshold = DFSO_UPTHRESHOLD;
> > -     unsigned int dfso_downdifferential = DFSO_DOWNDIFFERENCTIAL;
> > -     struct devfreq_simple_ondemand_data *data = df->data;
> > +     struct devfreq_simple_ondemand_data *od = df->data;
> >
> >       err = devfreq_update_stats(df);
> >       if (err)
> > @@ -31,16 +35,6 @@ static int devfreq_simple_ondemand_func(struct devfreq *df,
> >
> >       stat = &df->last_status;
> >
> > -     if (data) {
> > -             if (data->upthreshold)
> > -                     dfso_upthreshold = data->upthreshold;
> > -             if (data->downdifferential)
> > -                     dfso_downdifferential = data->downdifferential;
> > -     }
> > -     if (dfso_upthreshold > 100 ||
> > -         dfso_upthreshold < dfso_downdifferential)
> > -             return -EINVAL;
> > -
> >       /* Assume MAX if it is going to be divided by zero */
> >       if (stat->total_time == 0) {
> >               *freq = DEVFREQ_MAX_FREQ;
> > @@ -55,7 +49,7 @@ static int devfreq_simple_ondemand_func(struct devfreq *df,
> >
> >       /* Set MAX if it's busy enough */
> >       if (stat->busy_time * 100 >
> > -         stat->total_time * dfso_upthreshold) {
> > +         stat->total_time * od->upthreshold) {
> >               *freq = DEVFREQ_MAX_FREQ;
> >               return 0;
> >       }
> > @@ -68,7 +62,7 @@ static int devfreq_simple_ondemand_func(struct devfreq *df,
> >
> >       /* Keep the current frequency */
> >       if (stat->busy_time * 100 >
> > -         stat->total_time * (dfso_upthreshold - dfso_downdifferential)) {
> > +         stat->total_time * (od->upthreshold - od->downdifferential)) {
> >               *freq = stat->current_frequency;
> >               return 0;
> >       }
> > @@ -78,17 +72,41 @@ static int devfreq_simple_ondemand_func(struct devfreq *df,
> >       a *= stat->current_frequency;
> >       b = div_u64(a, stat->total_time);
> >       b *= 100;
> > -     b = div_u64(b, (dfso_upthreshold - dfso_downdifferential / 2));
> > +     b = div_u64(b, (od->upthreshold - od->downdifferential / 2));
> >       *freq = (unsigned long) b;
> >
> >       return 0;
> >   }
> >
> > +static int devfreq_simple_ondemand_check_od(struct devfreq *devfreq)
> > +{
> > +     struct devfreq_simple_ondemand_data *od = devfreq->data;
> > +
> > +     if (od) {
> > +             if (!od->upthreshold)
> > +                     od->upthreshold = DFSO_UPTHRESHOLD;
> > +
> > +             if (!od->downdifferential)
> > +                     od->downdifferential = DFSO_DOWNDIFFERENCTIAL;
> > +
> > +             if (od->upthreshold > 100 ||
> > +                 od->upthreshold < od->downdifferential)
> > +                     return -EINVAL;
> > +     } else {
> > +             od = &od_default;
> > +     }
> > +
> > +     return 0;
> > +}
> > +
> >   static int devfreq_simple_ondemand_handler(struct devfreq *devfreq,
> >                               unsigned int event, void *data)
> >   {
> >       switch (event) {
> >       case DEVFREQ_GOV_START:
> > +             if (devfreq_simple_ondemand_check_od(devfreq))
> > +                     return -EINVAL;
> > +
> >               return devfreq_monitor_start(devfreq);
> >
> >       case DEVFREQ_GOV_STOP:
> >
>
> I'm editing the upthreshold and downdifferential for exposing them
> via sysfs. So that after my work to expose them via sysfs,
> send the patches if you think that need to do more about them.

Thanks for letting me know..
I can rework after your patch merged.

Regards
Aisheng

>
> [1]
> https://git.kernel.org/pub/scm/linux/kernel/git/chanwoo/linux.git/commit/?h=devfreq-testing&id=dc9e557845c17cee173a6adcc3ae14940da03f44
>
> --
> Best Regards,
> Samsung Electronics
> Chanwoo Choi

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 11/11] PM / devfreq: imx8m-ddrc: drop polling_ms
  2021-03-09 16:23   ` Chanwoo Choi
@ 2021-03-10  3:03     ` Dong Aisheng
  0 siblings, 0 replies; 58+ messages in thread
From: Dong Aisheng @ 2021-03-10  3:03 UTC (permalink / raw)
  To: Chanwoo Choi
  Cc: Dong Aisheng, Linux PM,
	moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE,
	Sascha Hauer, Shawn Guo, dl-linux-imx, open list, myungjoo.ham,
	kyungmin.park, Chanwoo Choi, Abel Vesa

On Wed, Mar 10, 2021 at 12:23 AM Chanwoo Choi <cwchoi00@gmail.com> wrote:
>
> On 21. 3. 9. 오후 9:58, Dong Aisheng wrote:
> > polling_ms is only used by simple ondemand governor which
> > this driver can't support. Drop it to avoid confusing.
> >
> > Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
> > ---
> >   drivers/devfreq/imx8m-ddrc.c | 1 -
> >   1 file changed, 1 deletion(-)
> >
> > diff --git a/drivers/devfreq/imx8m-ddrc.c b/drivers/devfreq/imx8m-ddrc.c
> > index 0a6b7a1c829d..ecb9375aa877 100644
> > --- a/drivers/devfreq/imx8m-ddrc.c
> > +++ b/drivers/devfreq/imx8m-ddrc.c
> > @@ -417,7 +417,6 @@ static int imx8m_ddrc_probe(struct platform_device *pdev)
> >       if (ret < 0)
> >               goto err;
> >
> > -     priv->profile.polling_ms = 1000;
> >       priv->profile.target = imx8m_ddrc_target;
> >       priv->profile.exit = imx8m_ddrc_exit;
> >       priv->profile.get_cur_freq = imx8m_ddrc_get_cur_freq;
> >
>
> You can squash this patch with patch10 because polling_ms
> is related to .get_dev_status.

Sure i can do it.

Regards
Aisheng

>
> --
> Best Regards,
> Samsung Electronics
> Chanwoo Choi

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 05/11] PM / devfreq: use more accurate returned new_freq as resume_freq
  2021-03-10  3:07       ` Chanwoo Choi
@ 2021-03-10  3:04         ` Dong Aisheng
  0 siblings, 0 replies; 58+ messages in thread
From: Dong Aisheng @ 2021-03-10  3:04 UTC (permalink / raw)
  To: Chanwoo Choi
  Cc: Chanwoo Choi, Dong Aisheng, Linux PM,
	moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE,
	Sascha Hauer, Shawn Guo, dl-linux-imx, open list, myungjoo.ham,
	kyungmin.park, Abel Vesa

On Wed, Mar 10, 2021 at 10:50 AM Chanwoo Choi <cw00.choi@samsung.com> wrote:
>
> On 3/10/21 11:43 AM, Dong Aisheng wrote:
> > On Tue, Mar 9, 2021 at 11:53 PM Chanwoo Choi <cwchoi00@gmail.com> wrote:
> >>
> >> On 21. 3. 9. 오후 9:58, Dong Aisheng wrote:
> >>> Use the more accurate returned new_freq as resume_freq.
> >>> It's the same as how devfreq->previous_freq was updated.
> >>>
> >>> Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
> >>> ---
> >>>   drivers/devfreq/devfreq.c | 2 +-
> >>>   1 file changed, 1 insertion(+), 1 deletion(-)
> >>>
> >>> diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
> >>> index 6e80bf70e7b3..ce569bd9adfa 100644
> >>> --- a/drivers/devfreq/devfreq.c
> >>> +++ b/drivers/devfreq/devfreq.c
> >>> @@ -390,7 +390,7 @@ static int devfreq_set_target(struct devfreq *devfreq, unsigned long new_freq,
> >>>       devfreq->previous_freq = new_freq;
> >>>
> >>>       if (devfreq->suspend_freq)
> >>> -             devfreq->resume_freq = cur_freq;
> >>> +             devfreq->resume_freq = new_freq;
> >>>
> >>>       return err;
> >>>   }
> >>>
> >>
> >> This patch fixes the previous patch[1]. So that you need to
> >> add 'Fixes' tag as following:
> >>
> >> Fixes: 83f8ca45afbf0 ("PM / devfreq: add support for suspend/resume of a
> >> devfreq device")
> >>
> >
> > Will add Fixes tag in next version.
>
>
> On next version, recommend to place this patch at the first.

Yes, good practice as it's a fix.

Regards
Aisheng

>
> >
> >> commit 83f8ca45afbf041e312909f442128b99657d90b7
> >> Refs: v4.20-rc6-2-g83f8ca45afbf
> >> Author:     Lukasz Luba <lukasz.luba@arm.com>
> >> AuthorDate: Wed Dec 5 12:05:53 2018 +0100
> >> Commit:     MyungJoo Ham <myungjoo.ham@samsung.com>
> >> CommitDate: Tue Dec 11 11:09:47 2018 +0900
> >>
> >>      PM / devfreq: add support for suspend/resume of a devfreq device
> >>
> >>
> >> --
> >> Best Regards,
> >> Samsung Electronics
> >> Chanwoo Choi
> >
> >
>
>
> --
> Best Regards,
> Chanwoo Choi
> Samsung Electronics

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 05/11] PM / devfreq: use more accurate returned new_freq as resume_freq
  2021-03-10  2:43     ` Dong Aisheng
@ 2021-03-10  3:07       ` Chanwoo Choi
  2021-03-10  3:04         ` Dong Aisheng
  0 siblings, 1 reply; 58+ messages in thread
From: Chanwoo Choi @ 2021-03-10  3:07 UTC (permalink / raw)
  To: Dong Aisheng, Chanwoo Choi
  Cc: Dong Aisheng, Linux PM,
	moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE,
	Sascha Hauer, Shawn Guo, dl-linux-imx, open list, myungjoo.ham,
	kyungmin.park, Abel Vesa

On 3/10/21 11:43 AM, Dong Aisheng wrote:
> On Tue, Mar 9, 2021 at 11:53 PM Chanwoo Choi <cwchoi00@gmail.com> wrote:
>>
>> On 21. 3. 9. 오후 9:58, Dong Aisheng wrote:
>>> Use the more accurate returned new_freq as resume_freq.
>>> It's the same as how devfreq->previous_freq was updated.
>>>
>>> Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
>>> ---
>>>   drivers/devfreq/devfreq.c | 2 +-
>>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
>>> index 6e80bf70e7b3..ce569bd9adfa 100644
>>> --- a/drivers/devfreq/devfreq.c
>>> +++ b/drivers/devfreq/devfreq.c
>>> @@ -390,7 +390,7 @@ static int devfreq_set_target(struct devfreq *devfreq, unsigned long new_freq,
>>>       devfreq->previous_freq = new_freq;
>>>
>>>       if (devfreq->suspend_freq)
>>> -             devfreq->resume_freq = cur_freq;
>>> +             devfreq->resume_freq = new_freq;
>>>
>>>       return err;
>>>   }
>>>
>>
>> This patch fixes the previous patch[1]. So that you need to
>> add 'Fixes' tag as following:
>>
>> Fixes: 83f8ca45afbf0 ("PM / devfreq: add support for suspend/resume of a
>> devfreq device")
>>
> 
> Will add Fixes tag in next version.


On next version, recommend to place this patch at the first.

> 
>> commit 83f8ca45afbf041e312909f442128b99657d90b7
>> Refs: v4.20-rc6-2-g83f8ca45afbf
>> Author:     Lukasz Luba <lukasz.luba@arm.com>
>> AuthorDate: Wed Dec 5 12:05:53 2018 +0100
>> Commit:     MyungJoo Ham <myungjoo.ham@samsung.com>
>> CommitDate: Tue Dec 11 11:09:47 2018 +0900
>>
>>      PM / devfreq: add support for suspend/resume of a devfreq device
>>
>>
>> --
>> Best Regards,
>> Samsung Electronics
>> Chanwoo Choi
> 
> 


-- 
Best Regards,
Chanwoo Choi
Samsung Electronics

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 07/11] PM / devfreq: check get_dev_status before start monitor
  2021-03-10  2:56       ` Dong Aisheng
@ 2021-03-10  3:25         ` Chanwoo Choi
  2021-03-10  4:56           ` Dong Aisheng
  0 siblings, 1 reply; 58+ messages in thread
From: Chanwoo Choi @ 2021-03-10  3:25 UTC (permalink / raw)
  To: Dong Aisheng, Chanwoo Choi
  Cc: Dong Aisheng, Linux PM,
	moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE,
	Sascha Hauer, Shawn Guo, dl-linux-imx, open list, myungjoo.ham,
	kyungmin.park, Abel Vesa

On 3/10/21 11:56 AM, Dong Aisheng wrote:
> On Wed, Mar 10, 2021 at 12:12 AM Chanwoo Choi <cwchoi00@gmail.com> wrote:
>>
>> On 21. 3. 10. 오전 12:58, Chanwoo Choi wrote:
>>> On 21. 3. 9. 오후 9:58, Dong Aisheng wrote:
>>>> The devfreq monitor depends on the device to provide load information
>>>> by .get_dev_status() to calculate the next target freq.
>>>>
>>>> And this will cause changing governor to simple ondemand fail
>>>> if device can't support.
>>>>
>>>> Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
>>>> ---
>>>>   drivers/devfreq/devfreq.c                 | 10 +++++++---
>>>>   drivers/devfreq/governor.h                |  2 +-
>>>>   drivers/devfreq/governor_simpleondemand.c |  3 +--
>>>>   3 files changed, 9 insertions(+), 6 deletions(-)
>>>>
>>>> diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
>>>> index 7231fe6862a2..d1787b6c7d7c 100644
>>>> --- a/drivers/devfreq/devfreq.c
>>>> +++ b/drivers/devfreq/devfreq.c
>>>> @@ -482,10 +482,13 @@ static void devfreq_monitor(struct work_struct
>>>> *work)
>>>>    * to be called from governor in response to DEVFREQ_GOV_START
>>>>    * event when device is added to devfreq framework.
>>>>    */
>>>> -void devfreq_monitor_start(struct devfreq *devfreq)
>>>> +int devfreq_monitor_start(struct devfreq *devfreq)
>>>>   {
>>>>       if (IS_SUPPORTED_FLAG(devfreq->governor->flags, IRQ_DRIVEN))
>>>> -        return;
>>>> +        return 0;
>>>> +
>>>> +    if (!devfreq->profile->get_dev_status)
>>>> +        return -EINVAL;
>>
>> Again, I think that get_dev_status is not used for all governors.
>> So that it cause the governor start fail. Don't check whether
>> .get_dev_status is NULL or not.
>>
> 
> I'm not quite understand your point.
> it is used by governor_simpleondemand.c and tegra_devfreq_governor.
> get_target_freq -> devfreq_update_stats -> get_dev_status

The devfreq can add the new governor by anyone.
So these functions like devfreq_monitor_* have to support 
the governors and also must support the governor to be added
in the future.

> 
> Without checking, device can switch to ondemand governor if it does not support.
> 
> Am i missed something?
> 
> Regards
> Aisheng
> 
>>>>       switch (devfreq->profile->timer) {
>>>>       case DEVFREQ_TIMER_DEFERRABLE:
>>>> @@ -495,12 +498,13 @@ void devfreq_monitor_start(struct devfreq *devfreq)
>>>>           INIT_DELAYED_WORK(&devfreq->work, devfreq_monitor);
>>>>           break;
>>>>       default:
>>>> -        return;
>>>> +        return -EINVAL;
>>>>       }
>>>>       if (devfreq->profile->polling_ms)
>>>>           queue_delayed_work(devfreq_wq, &devfreq->work,
>>>>               msecs_to_jiffies(devfreq->profile->polling_ms));
>>>> +    return 0;
>>>>   }
>>>>   EXPORT_SYMBOL(devfreq_monitor_start);
>>>> diff --git a/drivers/devfreq/governor.h b/drivers/devfreq/governor.h
>>>> index 5cee3f64fe2b..31af6d072a10 100644
>>>> --- a/drivers/devfreq/governor.h
>>>> +++ b/drivers/devfreq/governor.h
>>>> @@ -75,7 +75,7 @@ struct devfreq_governor {
>>>>                   unsigned int event, void *data);
>>>>   };
>>>> -void devfreq_monitor_start(struct devfreq *devfreq);
>>>> +int devfreq_monitor_start(struct devfreq *devfreq);
>>>>   void devfreq_monitor_stop(struct devfreq *devfreq);
>>>>   void devfreq_monitor_suspend(struct devfreq *devfreq);
>>>>   void devfreq_monitor_resume(struct devfreq *devfreq);
>>>> diff --git a/drivers/devfreq/governor_simpleondemand.c
>>>> b/drivers/devfreq/governor_simpleondemand.c
>>>> index d57b82a2b570..ea287b57cbf3 100644
>>>> --- a/drivers/devfreq/governor_simpleondemand.c
>>>> +++ b/drivers/devfreq/governor_simpleondemand.c
>>>> @@ -89,8 +89,7 @@ static int devfreq_simple_ondemand_handler(struct
>>>> devfreq *devfreq,
>>>>   {
>>>>       switch (event) {
>>>>       case DEVFREQ_GOV_START:
>>>> -        devfreq_monitor_start(devfreq);
>>>> -        break;
>>>> +        return devfreq_monitor_start(devfreq);
>>>>       case DEVFREQ_GOV_STOP:
>>>>           devfreq_monitor_stop(devfreq);
>>>>
>>>
>>> Need to handle the all points of devfreq_monitor_start() usage.
>>> please check the tegra30-devfreq.c for this update.
>>>
>>> $ grep -rn "devfreq_monitor_start" drivers/
>>> drivers/devfreq/governor_simpleondemand.c:92:
>>> devfreq_monitor_start(devfreq);
>>> drivers/devfreq/tegra30-devfreq.c:744:
>>> devfreq_monitor_start(devfreq);
>>> ......
>>>
>>
>>
>> --
>> Best Regards,
>> Samsung Electronics
>> Chanwoo Choi
> 
> 


-- 
Best Regards,
Chanwoo Choi
Samsung Electronics

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 07/11] PM / devfreq: check get_dev_status before start monitor
  2021-03-10  3:25         ` Chanwoo Choi
@ 2021-03-10  4:56           ` Dong Aisheng
  2021-03-11  7:10             ` Chanwoo Choi
  0 siblings, 1 reply; 58+ messages in thread
From: Dong Aisheng @ 2021-03-10  4:56 UTC (permalink / raw)
  To: Chanwoo Choi
  Cc: Chanwoo Choi, Dong Aisheng, Linux PM,
	moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE,
	Sascha Hauer, Shawn Guo, dl-linux-imx, open list, myungjoo.ham,
	kyungmin.park, Abel Vesa

On Wed, Mar 10, 2021 at 11:08 AM Chanwoo Choi <cw00.choi@samsung.com> wrote:
>
> On 3/10/21 11:56 AM, Dong Aisheng wrote:
> > On Wed, Mar 10, 2021 at 12:12 AM Chanwoo Choi <cwchoi00@gmail.com> wrote:
> >>
> >> On 21. 3. 10. 오전 12:58, Chanwoo Choi wrote:
> >>> On 21. 3. 9. 오후 9:58, Dong Aisheng wrote:
> >>>> The devfreq monitor depends on the device to provide load information
> >>>> by .get_dev_status() to calculate the next target freq.
> >>>>
> >>>> And this will cause changing governor to simple ondemand fail
> >>>> if device can't support.
> >>>>
> >>>> Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
> >>>> ---
> >>>>   drivers/devfreq/devfreq.c                 | 10 +++++++---
> >>>>   drivers/devfreq/governor.h                |  2 +-
> >>>>   drivers/devfreq/governor_simpleondemand.c |  3 +--
> >>>>   3 files changed, 9 insertions(+), 6 deletions(-)
> >>>>
> >>>> diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
> >>>> index 7231fe6862a2..d1787b6c7d7c 100644
> >>>> --- a/drivers/devfreq/devfreq.c
> >>>> +++ b/drivers/devfreq/devfreq.c
> >>>> @@ -482,10 +482,13 @@ static void devfreq_monitor(struct work_struct
> >>>> *work)
> >>>>    * to be called from governor in response to DEVFREQ_GOV_START
> >>>>    * event when device is added to devfreq framework.
> >>>>    */
> >>>> -void devfreq_monitor_start(struct devfreq *devfreq)
> >>>> +int devfreq_monitor_start(struct devfreq *devfreq)
> >>>>   {
> >>>>       if (IS_SUPPORTED_FLAG(devfreq->governor->flags, IRQ_DRIVEN))
> >>>> -        return;
> >>>> +        return 0;
> >>>> +
> >>>> +    if (!devfreq->profile->get_dev_status)
> >>>> +        return -EINVAL;
> >>
> >> Again, I think that get_dev_status is not used for all governors.
> >> So that it cause the governor start fail. Don't check whether
> >> .get_dev_status is NULL or not.
> >>
> >
> > I'm not quite understand your point.
> > it is used by governor_simpleondemand.c and tegra_devfreq_governor.
> > get_target_freq -> devfreq_update_stats -> get_dev_status
>
> The devfreq can add the new governor by anyone.
> So these functions like devfreq_monitor_* have to support
> the governors and also must support the governor to be added
> in the future.

Yes, but devfreq_monitor_* is only used by polling mode, right?
The governor using it has to implement get_dev_status unless
there's an exception in the future.

Currently this patch wants to address the issue that user can switch
to ondemand governor (polling mode) by sysfs even devices does
not support it (no get_dev_status implemented).

Regards
Aisheng

>
> >
> > Without checking, device can switch to ondemand governor if it does not support.
> >
> > Am i missed something?
> >
> > Regards
> > Aisheng
> >
> >>>>       switch (devfreq->profile->timer) {
> >>>>       case DEVFREQ_TIMER_DEFERRABLE:
> >>>> @@ -495,12 +498,13 @@ void devfreq_monitor_start(struct devfreq *devfreq)
> >>>>           INIT_DELAYED_WORK(&devfreq->work, devfreq_monitor);
> >>>>           break;
> >>>>       default:
> >>>> -        return;
> >>>> +        return -EINVAL;
> >>>>       }
> >>>>       if (devfreq->profile->polling_ms)
> >>>>           queue_delayed_work(devfreq_wq, &devfreq->work,
> >>>>               msecs_to_jiffies(devfreq->profile->polling_ms));
> >>>> +    return 0;
> >>>>   }
> >>>>   EXPORT_SYMBOL(devfreq_monitor_start);
> >>>> diff --git a/drivers/devfreq/governor.h b/drivers/devfreq/governor.h
> >>>> index 5cee3f64fe2b..31af6d072a10 100644
> >>>> --- a/drivers/devfreq/governor.h
> >>>> +++ b/drivers/devfreq/governor.h
> >>>> @@ -75,7 +75,7 @@ struct devfreq_governor {
> >>>>                   unsigned int event, void *data);
> >>>>   };
> >>>> -void devfreq_monitor_start(struct devfreq *devfreq);
> >>>> +int devfreq_monitor_start(struct devfreq *devfreq);
> >>>>   void devfreq_monitor_stop(struct devfreq *devfreq);
> >>>>   void devfreq_monitor_suspend(struct devfreq *devfreq);
> >>>>   void devfreq_monitor_resume(struct devfreq *devfreq);
> >>>> diff --git a/drivers/devfreq/governor_simpleondemand.c
> >>>> b/drivers/devfreq/governor_simpleondemand.c
> >>>> index d57b82a2b570..ea287b57cbf3 100644
> >>>> --- a/drivers/devfreq/governor_simpleondemand.c
> >>>> +++ b/drivers/devfreq/governor_simpleondemand.c
> >>>> @@ -89,8 +89,7 @@ static int devfreq_simple_ondemand_handler(struct
> >>>> devfreq *devfreq,
> >>>>   {
> >>>>       switch (event) {
> >>>>       case DEVFREQ_GOV_START:
> >>>> -        devfreq_monitor_start(devfreq);
> >>>> -        break;
> >>>> +        return devfreq_monitor_start(devfreq);
> >>>>       case DEVFREQ_GOV_STOP:
> >>>>           devfreq_monitor_stop(devfreq);
> >>>>
> >>>
> >>> Need to handle the all points of devfreq_monitor_start() usage.
> >>> please check the tegra30-devfreq.c for this update.
> >>>
> >>> $ grep -rn "devfreq_monitor_start" drivers/
> >>> drivers/devfreq/governor_simpleondemand.c:92:
> >>> devfreq_monitor_start(devfreq);
> >>> drivers/devfreq/tegra30-devfreq.c:744:
> >>> devfreq_monitor_start(devfreq);
> >>> ......
> >>>
> >>
> >>
> >> --
> >> Best Regards,
> >> Samsung Electronics
> >> Chanwoo Choi
> >
> >
>
>
> --
> Best Regards,
> Chanwoo Choi
> Samsung Electronics

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 08/11] PM / devfreq: check get_dev_status in devfreq_update_stats
  2021-03-10  3:00     ` Dong Aisheng
@ 2021-03-11  7:01       ` Chanwoo Choi
  0 siblings, 0 replies; 58+ messages in thread
From: Chanwoo Choi @ 2021-03-11  7:01 UTC (permalink / raw)
  To: Dong Aisheng, Chanwoo Choi
  Cc: Dong Aisheng, Linux PM,
	moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE,
	Sascha Hauer, Shawn Guo, dl-linux-imx, open list, myungjoo.ham,
	kyungmin.park, Abel Vesa

On 3/10/21 12:00 PM, Dong Aisheng wrote:
> On Wed, Mar 10, 2021 at 12:20 AM Chanwoo Choi <cwchoi00@gmail.com> wrote:
>>
>> On 21. 3. 9. 오후 9:58, Dong Aisheng wrote:
>>> Check .get_dev_status() in devfreq_update_stats in case it's abused
>>> when a device does not provide it.
>>>
>>> Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
>>> ---
>>>   drivers/devfreq/governor.h | 3 +++
>>>   1 file changed, 3 insertions(+)
>>>
>>> diff --git a/drivers/devfreq/governor.h b/drivers/devfreq/governor.h
>>> index 31af6d072a10..67a6dbdd5d23 100644
>>> --- a/drivers/devfreq/governor.h
>>> +++ b/drivers/devfreq/governor.h
>>> @@ -89,6 +89,9 @@ int devfreq_update_target(struct devfreq *devfreq, unsigned long freq);
>>>
>>>   static inline int devfreq_update_stats(struct devfreq *df)
>>>   {
>>> +     if (!df->profile->get_dev_status)
>>> +             return -EINVAL;
>>> +
>>
>> I'm considering the following method instead of returning the error
>> when .get_dev_status is NULL.
>>
>>         if (!df->profile->get_dev_status) {
>>                 df->last_status.total_time = 0;
>>                 df->last_status.busy_time = 0;
>>                 df->last_status.current_frequency = 0;
>>                 return 0;
>>         }
> 
> I might  suggest not cause it's meaningless for ondemand governor but
> introducing confusing. Simply return error could make the life a bit easier.
> does it make sense to you?

Actually, I considered the some corner case as following:
We can see the simple_ondemand governor through available_governors
even if the devfreq driver doesn't implement the .get_dev_status.
In this corner case, My intention tried to prevent the error
on this case. But, actually, it is different issue. I'll fix
this issue when get_dev_status is NULL, don't show the
simple_ondemand governor name through available_governors
on other patch.

And I applied it. Thanks.

> 
> Regards
> Aisheng
> 
>>
>>>       return df->profile->get_dev_status(df->dev.parent, &df->last_status);
>>>   }
>>>   #endif /* _GOVERNOR_H */
>>>
>>
>>
>> --
>> Best Regards,
>> Samsung Electronics
>> Chanwoo Choi
> 
> 


-- 
Best Regards,
Chanwoo Choi
Samsung Electronics

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 07/11] PM / devfreq: check get_dev_status before start monitor
  2021-03-10  4:56           ` Dong Aisheng
@ 2021-03-11  7:10             ` Chanwoo Choi
  2021-03-12 10:57               ` Dong Aisheng
  0 siblings, 1 reply; 58+ messages in thread
From: Chanwoo Choi @ 2021-03-11  7:10 UTC (permalink / raw)
  To: Dong Aisheng
  Cc: Chanwoo Choi, Dong Aisheng, Linux PM,
	moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE,
	Sascha Hauer, Shawn Guo, dl-linux-imx, open list, myungjoo.ham,
	kyungmin.park, Abel Vesa

On 3/10/21 1:56 PM, Dong Aisheng wrote:
> On Wed, Mar 10, 2021 at 11:08 AM Chanwoo Choi <cw00.choi@samsung.com> wrote:
>>
>> On 3/10/21 11:56 AM, Dong Aisheng wrote:
>>> On Wed, Mar 10, 2021 at 12:12 AM Chanwoo Choi <cwchoi00@gmail.com> wrote:
>>>>
>>>> On 21. 3. 10. 오전 12:58, Chanwoo Choi wrote:
>>>>> On 21. 3. 9. 오후 9:58, Dong Aisheng wrote:
>>>>>> The devfreq monitor depends on the device to provide load information
>>>>>> by .get_dev_status() to calculate the next target freq.
>>>>>>
>>>>>> And this will cause changing governor to simple ondemand fail
>>>>>> if device can't support.
>>>>>>
>>>>>> Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
>>>>>> ---
>>>>>>   drivers/devfreq/devfreq.c                 | 10 +++++++---
>>>>>>   drivers/devfreq/governor.h                |  2 +-
>>>>>>   drivers/devfreq/governor_simpleondemand.c |  3 +--
>>>>>>   3 files changed, 9 insertions(+), 6 deletions(-)
>>>>>>
>>>>>> diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
>>>>>> index 7231fe6862a2..d1787b6c7d7c 100644
>>>>>> --- a/drivers/devfreq/devfreq.c
>>>>>> +++ b/drivers/devfreq/devfreq.c
>>>>>> @@ -482,10 +482,13 @@ static void devfreq_monitor(struct work_struct
>>>>>> *work)
>>>>>>    * to be called from governor in response to DEVFREQ_GOV_START
>>>>>>    * event when device is added to devfreq framework.
>>>>>>    */
>>>>>> -void devfreq_monitor_start(struct devfreq *devfreq)
>>>>>> +int devfreq_monitor_start(struct devfreq *devfreq)
>>>>>>   {
>>>>>>       if (IS_SUPPORTED_FLAG(devfreq->governor->flags, IRQ_DRIVEN))
>>>>>> -        return;
>>>>>> +        return 0;
>>>>>> +
>>>>>> +    if (!devfreq->profile->get_dev_status)
>>>>>> +        return -EINVAL;
>>>>
>>>> Again, I think that get_dev_status is not used for all governors.
>>>> So that it cause the governor start fail. Don't check whether
>>>> .get_dev_status is NULL or not.
>>>>
>>>
>>> I'm not quite understand your point.
>>> it is used by governor_simpleondemand.c and tegra_devfreq_governor.
>>> get_target_freq -> devfreq_update_stats -> get_dev_status
>>
>> The devfreq can add the new governor by anyone.
>> So these functions like devfreq_monitor_* have to support
>> the governors and also must support the governor to be added
>> in the future.
> 
> Yes, but devfreq_monitor_* is only used by polling mode, right?
> The governor using it has to implement get_dev_status unless
> there's an exception in the future.
> 
> Currently this patch wants to address the issue that user can switch
> to ondemand governor (polling mode) by sysfs even devices does
> not support it (no get_dev_status implemented).

As I commented, I'll fix this issue. If devfreq driver doesn't implement
the .get_dev_status, don't show it via available_governors. I think that
it is fundamental solution to fix this issue. So on this version,
don't add the this conditional statement on this function

And on next version, please use the capital letter for first character
on patch title as following:

- PM / devfreq: Check get_dev_status before start monitor

> 
> Regards
> Aisheng
> 
>>
>>>
>>> Without checking, device can switch to ondemand governor if it does not support.
>>>
>>> Am i missed something?
>>>
>>> Regards
>>> Aisheng
>>>
>>>>>>       switch (devfreq->profile->timer) {
>>>>>>       case DEVFREQ_TIMER_DEFERRABLE:
>>>>>> @@ -495,12 +498,13 @@ void devfreq_monitor_start(struct devfreq *devfreq)
>>>>>>           INIT_DELAYED_WORK(&devfreq->work, devfreq_monitor);
>>>>>>           break;
>>>>>>       default:
>>>>>> -        return;
>>>>>> +        return -EINVAL;
>>>>>>       }
>>>>>>       if (devfreq->profile->polling_ms)
>>>>>>           queue_delayed_work(devfreq_wq, &devfreq->work,
>>>>>>               msecs_to_jiffies(devfreq->profile->polling_ms));
>>>>>> +    return 0;
>>>>>>   }
>>>>>>   EXPORT_SYMBOL(devfreq_monitor_start);
>>>>>> diff --git a/drivers/devfreq/governor.h b/drivers/devfreq/governor.h
>>>>>> index 5cee3f64fe2b..31af6d072a10 100644
>>>>>> --- a/drivers/devfreq/governor.h
>>>>>> +++ b/drivers/devfreq/governor.h
>>>>>> @@ -75,7 +75,7 @@ struct devfreq_governor {
>>>>>>                   unsigned int event, void *data);
>>>>>>   };
>>>>>> -void devfreq_monitor_start(struct devfreq *devfreq);
>>>>>> +int devfreq_monitor_start(struct devfreq *devfreq);
>>>>>>   void devfreq_monitor_stop(struct devfreq *devfreq);
>>>>>>   void devfreq_monitor_suspend(struct devfreq *devfreq);
>>>>>>   void devfreq_monitor_resume(struct devfreq *devfreq);
>>>>>> diff --git a/drivers/devfreq/governor_simpleondemand.c
>>>>>> b/drivers/devfreq/governor_simpleondemand.c
>>>>>> index d57b82a2b570..ea287b57cbf3 100644
>>>>>> --- a/drivers/devfreq/governor_simpleondemand.c
>>>>>> +++ b/drivers/devfreq/governor_simpleondemand.c
>>>>>> @@ -89,8 +89,7 @@ static int devfreq_simple_ondemand_handler(struct
>>>>>> devfreq *devfreq,
>>>>>>   {
>>>>>>       switch (event) {
>>>>>>       case DEVFREQ_GOV_START:
>>>>>> -        devfreq_monitor_start(devfreq);
>>>>>> -        break;
>>>>>> +        return devfreq_monitor_start(devfreq);
>>>>>>       case DEVFREQ_GOV_STOP:
>>>>>>           devfreq_monitor_stop(devfreq);
>>>>>>
>>>>>
>>>>> Need to handle the all points of devfreq_monitor_start() usage.
>>>>> please check the tegra30-devfreq.c for this update.
>>>>>
>>>>> $ grep -rn "devfreq_monitor_start" drivers/
>>>>> drivers/devfreq/governor_simpleondemand.c:92:
>>>>> devfreq_monitor_start(devfreq);
>>>>> drivers/devfreq/tegra30-devfreq.c:744:
>>>>> devfreq_monitor_start(devfreq);
>>>>> ......
>>>>>
>>>>
>>>>
>>>> --
>>>> Best Regards,
>>>> Samsung Electronics
>>>> Chanwoo Choi
>>>
>>>
>>
>>
>> --
>> Best Regards,
>> Chanwoo Choi
>> Samsung Electronics
> 
> 


-- 
Best Regards,
Chanwoo Choi
Samsung Electronics

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 07/11] PM / devfreq: check get_dev_status before start monitor
  2021-03-11  7:10             ` Chanwoo Choi
@ 2021-03-12 10:57               ` Dong Aisheng
  2021-03-12 16:09                 ` Chanwoo Choi
  0 siblings, 1 reply; 58+ messages in thread
From: Dong Aisheng @ 2021-03-12 10:57 UTC (permalink / raw)
  To: Chanwoo Choi
  Cc: Chanwoo Choi, Dong Aisheng, Linux PM,
	moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE,
	Sascha Hauer, Shawn Guo, dl-linux-imx, open list, myungjoo.ham,
	kyungmin.park, Abel Vesa

On Thu, Mar 11, 2021 at 2:54 PM Chanwoo Choi <cw00.choi@samsung.com> wrote:
>
> On 3/10/21 1:56 PM, Dong Aisheng wrote:
> > On Wed, Mar 10, 2021 at 11:08 AM Chanwoo Choi <cw00.choi@samsung.com> wrote:
> >>
> >> On 3/10/21 11:56 AM, Dong Aisheng wrote:
> >>> On Wed, Mar 10, 2021 at 12:12 AM Chanwoo Choi <cwchoi00@gmail.com> wrote:
> >>>>
> >>>> On 21. 3. 10. 오전 12:58, Chanwoo Choi wrote:
> >>>>> On 21. 3. 9. 오후 9:58, Dong Aisheng wrote:
> >>>>>> The devfreq monitor depends on the device to provide load information
> >>>>>> by .get_dev_status() to calculate the next target freq.
> >>>>>>
> >>>>>> And this will cause changing governor to simple ondemand fail
> >>>>>> if device can't support.
> >>>>>>
> >>>>>> Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
> >>>>>> ---
> >>>>>>   drivers/devfreq/devfreq.c                 | 10 +++++++---
> >>>>>>   drivers/devfreq/governor.h                |  2 +-
> >>>>>>   drivers/devfreq/governor_simpleondemand.c |  3 +--
> >>>>>>   3 files changed, 9 insertions(+), 6 deletions(-)
> >>>>>>
> >>>>>> diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
> >>>>>> index 7231fe6862a2..d1787b6c7d7c 100644
> >>>>>> --- a/drivers/devfreq/devfreq.c
> >>>>>> +++ b/drivers/devfreq/devfreq.c
> >>>>>> @@ -482,10 +482,13 @@ static void devfreq_monitor(struct work_struct
> >>>>>> *work)
> >>>>>>    * to be called from governor in response to DEVFREQ_GOV_START
> >>>>>>    * event when device is added to devfreq framework.
> >>>>>>    */
> >>>>>> -void devfreq_monitor_start(struct devfreq *devfreq)
> >>>>>> +int devfreq_monitor_start(struct devfreq *devfreq)
> >>>>>>   {
> >>>>>>       if (IS_SUPPORTED_FLAG(devfreq->governor->flags, IRQ_DRIVEN))
> >>>>>> -        return;
> >>>>>> +        return 0;
> >>>>>> +
> >>>>>> +    if (!devfreq->profile->get_dev_status)
> >>>>>> +        return -EINVAL;
> >>>>
> >>>> Again, I think that get_dev_status is not used for all governors.
> >>>> So that it cause the governor start fail. Don't check whether
> >>>> .get_dev_status is NULL or not.
> >>>>
> >>>
> >>> I'm not quite understand your point.
> >>> it is used by governor_simpleondemand.c and tegra_devfreq_governor.
> >>> get_target_freq -> devfreq_update_stats -> get_dev_status
> >>
> >> The devfreq can add the new governor by anyone.
> >> So these functions like devfreq_monitor_* have to support
> >> the governors and also must support the governor to be added
> >> in the future.
> >
> > Yes, but devfreq_monitor_* is only used by polling mode, right?
> > The governor using it has to implement get_dev_status unless
> > there's an exception in the future.
> >
> > Currently this patch wants to address the issue that user can switch
> > to ondemand governor (polling mode) by sysfs even devices does
> > not support it (no get_dev_status implemented).
>
> As I commented, I'll fix this issue. If devfreq driver doesn't implement
> the .get_dev_status, don't show it via available_governors. I think that
> it is fundamental solution to fix this issue.

Sounds good

> So on this version,
> don't add the this conditional statement on this function
>

Almost all this patch did is adding a checking for get_dev_status.
So do you mean drop this patch?
I wonder it's still a necessary checking to explicitly tell devfreq monitor
users that get_dev_status is needed during governor startup.

> And on next version, please use the capital letter for first character
> on patch title as following:
>
> - PM / devfreq: Check get_dev_status before start monitor
>

Okay to me.
Thanks for the suggestion.

Regards
Aisheng

> >
> > Regards
> > Aisheng
> >
> >>
> >>>
> >>> Without checking, device can switch to ondemand governor if it does not support.
> >>>
> >>> Am i missed something?
> >>>
> >>> Regards
> >>> Aisheng
> >>>
> >>>>>>       switch (devfreq->profile->timer) {
> >>>>>>       case DEVFREQ_TIMER_DEFERRABLE:
> >>>>>> @@ -495,12 +498,13 @@ void devfreq_monitor_start(struct devfreq *devfreq)
> >>>>>>           INIT_DELAYED_WORK(&devfreq->work, devfreq_monitor);
> >>>>>>           break;
> >>>>>>       default:
> >>>>>> -        return;
> >>>>>> +        return -EINVAL;
> >>>>>>       }
> >>>>>>       if (devfreq->profile->polling_ms)
> >>>>>>           queue_delayed_work(devfreq_wq, &devfreq->work,
> >>>>>>               msecs_to_jiffies(devfreq->profile->polling_ms));
> >>>>>> +    return 0;
> >>>>>>   }
> >>>>>>   EXPORT_SYMBOL(devfreq_monitor_start);
> >>>>>> diff --git a/drivers/devfreq/governor.h b/drivers/devfreq/governor.h
> >>>>>> index 5cee3f64fe2b..31af6d072a10 100644
> >>>>>> --- a/drivers/devfreq/governor.h
> >>>>>> +++ b/drivers/devfreq/governor.h
> >>>>>> @@ -75,7 +75,7 @@ struct devfreq_governor {
> >>>>>>                   unsigned int event, void *data);
> >>>>>>   };
> >>>>>> -void devfreq_monitor_start(struct devfreq *devfreq);
> >>>>>> +int devfreq_monitor_start(struct devfreq *devfreq);
> >>>>>>   void devfreq_monitor_stop(struct devfreq *devfreq);
> >>>>>>   void devfreq_monitor_suspend(struct devfreq *devfreq);
> >>>>>>   void devfreq_monitor_resume(struct devfreq *devfreq);
> >>>>>> diff --git a/drivers/devfreq/governor_simpleondemand.c
> >>>>>> b/drivers/devfreq/governor_simpleondemand.c
> >>>>>> index d57b82a2b570..ea287b57cbf3 100644
> >>>>>> --- a/drivers/devfreq/governor_simpleondemand.c
> >>>>>> +++ b/drivers/devfreq/governor_simpleondemand.c
> >>>>>> @@ -89,8 +89,7 @@ static int devfreq_simple_ondemand_handler(struct
> >>>>>> devfreq *devfreq,
> >>>>>>   {
> >>>>>>       switch (event) {
> >>>>>>       case DEVFREQ_GOV_START:
> >>>>>> -        devfreq_monitor_start(devfreq);
> >>>>>> -        break;
> >>>>>> +        return devfreq_monitor_start(devfreq);
> >>>>>>       case DEVFREQ_GOV_STOP:
> >>>>>>           devfreq_monitor_stop(devfreq);
> >>>>>>
> >>>>>
> >>>>> Need to handle the all points of devfreq_monitor_start() usage.
> >>>>> please check the tegra30-devfreq.c for this update.
> >>>>>
> >>>>> $ grep -rn "devfreq_monitor_start" drivers/
> >>>>> drivers/devfreq/governor_simpleondemand.c:92:
> >>>>> devfreq_monitor_start(devfreq);
> >>>>> drivers/devfreq/tegra30-devfreq.c:744:
> >>>>> devfreq_monitor_start(devfreq);
> >>>>> ......
> >>>>>
> >>>>
> >>>>
> >>>> --
> >>>> Best Regards,
> >>>> Samsung Electronics
> >>>> Chanwoo Choi
> >>>
> >>>
> >>
> >>
> >> --
> >> Best Regards,
> >> Chanwoo Choi
> >> Samsung Electronics
> >
> >
>
>
> --
> Best Regards,
> Chanwoo Choi
> Samsung Electronics

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 07/11] PM / devfreq: check get_dev_status before start monitor
  2021-03-12 10:57               ` Dong Aisheng
@ 2021-03-12 16:09                 ` Chanwoo Choi
  2021-03-13  6:45                   ` Dong Aisheng
  0 siblings, 1 reply; 58+ messages in thread
From: Chanwoo Choi @ 2021-03-12 16:09 UTC (permalink / raw)
  To: Dong Aisheng, Chanwoo Choi
  Cc: Dong Aisheng, Linux PM,
	moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE,
	Sascha Hauer, Shawn Guo, dl-linux-imx, open list, myungjoo.ham,
	kyungmin.park, Abel Vesa

On 21. 3. 12. 오후 7:57, Dong Aisheng wrote:
> On Thu, Mar 11, 2021 at 2:54 PM Chanwoo Choi <cw00.choi@samsung.com> wrote:
>>
>> On 3/10/21 1:56 PM, Dong Aisheng wrote:
>>> On Wed, Mar 10, 2021 at 11:08 AM Chanwoo Choi <cw00.choi@samsung.com> wrote:
>>>>
>>>> On 3/10/21 11:56 AM, Dong Aisheng wrote:
>>>>> On Wed, Mar 10, 2021 at 12:12 AM Chanwoo Choi <cwchoi00@gmail.com> wrote:
>>>>>>
>>>>>> On 21. 3. 10. 오전 12:58, Chanwoo Choi wrote:
>>>>>>> On 21. 3. 9. 오후 9:58, Dong Aisheng wrote:
>>>>>>>> The devfreq monitor depends on the device to provide load information
>>>>>>>> by .get_dev_status() to calculate the next target freq.
>>>>>>>>
>>>>>>>> And this will cause changing governor to simple ondemand fail
>>>>>>>> if device can't support.
>>>>>>>>
>>>>>>>> Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
>>>>>>>> ---
>>>>>>>>    drivers/devfreq/devfreq.c                 | 10 +++++++---
>>>>>>>>    drivers/devfreq/governor.h                |  2 +-
>>>>>>>>    drivers/devfreq/governor_simpleondemand.c |  3 +--
>>>>>>>>    3 files changed, 9 insertions(+), 6 deletions(-)
>>>>>>>>
>>>>>>>> diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
>>>>>>>> index 7231fe6862a2..d1787b6c7d7c 100644
>>>>>>>> --- a/drivers/devfreq/devfreq.c
>>>>>>>> +++ b/drivers/devfreq/devfreq.c
>>>>>>>> @@ -482,10 +482,13 @@ static void devfreq_monitor(struct work_struct
>>>>>>>> *work)
>>>>>>>>     * to be called from governor in response to DEVFREQ_GOV_START
>>>>>>>>     * event when device is added to devfreq framework.
>>>>>>>>     */
>>>>>>>> -void devfreq_monitor_start(struct devfreq *devfreq)
>>>>>>>> +int devfreq_monitor_start(struct devfreq *devfreq)
>>>>>>>>    {
>>>>>>>>        if (IS_SUPPORTED_FLAG(devfreq->governor->flags, IRQ_DRIVEN))
>>>>>>>> -        return;
>>>>>>>> +        return 0;
>>>>>>>> +
>>>>>>>> +    if (!devfreq->profile->get_dev_status)
>>>>>>>> +        return -EINVAL;
>>>>>>
>>>>>> Again, I think that get_dev_status is not used for all governors.
>>>>>> So that it cause the governor start fail. Don't check whether
>>>>>> .get_dev_status is NULL or not.
>>>>>>
>>>>>
>>>>> I'm not quite understand your point.
>>>>> it is used by governor_simpleondemand.c and tegra_devfreq_governor.
>>>>> get_target_freq -> devfreq_update_stats -> get_dev_status
>>>>
>>>> The devfreq can add the new governor by anyone.
>>>> So these functions like devfreq_monitor_* have to support
>>>> the governors and also must support the governor to be added
>>>> in the future.
>>>
>>> Yes, but devfreq_monitor_* is only used by polling mode, right?
>>> The governor using it has to implement get_dev_status unless
>>> there's an exception in the future.
>>>
>>> Currently this patch wants to address the issue that user can switch
>>> to ondemand governor (polling mode) by sysfs even devices does
>>> not support it (no get_dev_status implemented).
>>
>> As I commented, I'll fix this issue. If devfreq driver doesn't implement
>> the .get_dev_status, don't show it via available_governors. I think that
>> it is fundamental solution to fix this issue.
> 
> Sounds good
> 
>> So on this version,
>> don't add the this conditional statement on this function
>>
> 
> Almost all this patch did is adding a checking for get_dev_status.
> So do you mean drop this patch?
> I wonder it's still a necessary checking to explicitly tell devfreq monitor
> users that get_dev_status is needed during governor startup.

I think that the it is enough to check .get_dev_status in
devfreq_update_stats. We have to check it on where it is used.

> 
>> And on next version, please use the capital letter for first character
>> on patch title as following:
>>
>> - PM / devfreq: Check get_dev_status before start monitor
>>
> 
> Okay to me.
> Thanks for the suggestion.
> 
> Regards
> Aisheng
> 
>>>
>>> Regards
>>> Aisheng
>>>
>>>>
>>>>>
>>>>> Without checking, device can switch to ondemand governor if it does not support.
>>>>>
>>>>> Am i missed something?
>>>>>
>>>>> Regards
>>>>> Aisheng
>>>>>
>>>>>>>>        switch (devfreq->profile->timer) {
>>>>>>>>        case DEVFREQ_TIMER_DEFERRABLE:
>>>>>>>> @@ -495,12 +498,13 @@ void devfreq_monitor_start(struct devfreq *devfreq)
>>>>>>>>            INIT_DELAYED_WORK(&devfreq->work, devfreq_monitor);
>>>>>>>>            break;
>>>>>>>>        default:
>>>>>>>> -        return;
>>>>>>>> +        return -EINVAL;
>>>>>>>>        }
>>>>>>>>        if (devfreq->profile->polling_ms)
>>>>>>>>            queue_delayed_work(devfreq_wq, &devfreq->work,
>>>>>>>>                msecs_to_jiffies(devfreq->profile->polling_ms));
>>>>>>>> +    return 0;
>>>>>>>>    }
>>>>>>>>    EXPORT_SYMBOL(devfreq_monitor_start);
>>>>>>>> diff --git a/drivers/devfreq/governor.h b/drivers/devfreq/governor.h
>>>>>>>> index 5cee3f64fe2b..31af6d072a10 100644
>>>>>>>> --- a/drivers/devfreq/governor.h
>>>>>>>> +++ b/drivers/devfreq/governor.h
>>>>>>>> @@ -75,7 +75,7 @@ struct devfreq_governor {
>>>>>>>>                    unsigned int event, void *data);
>>>>>>>>    };
>>>>>>>> -void devfreq_monitor_start(struct devfreq *devfreq);
>>>>>>>> +int devfreq_monitor_start(struct devfreq *devfreq);
>>>>>>>>    void devfreq_monitor_stop(struct devfreq *devfreq);
>>>>>>>>    void devfreq_monitor_suspend(struct devfreq *devfreq);
>>>>>>>>    void devfreq_monitor_resume(struct devfreq *devfreq);
>>>>>>>> diff --git a/drivers/devfreq/governor_simpleondemand.c
>>>>>>>> b/drivers/devfreq/governor_simpleondemand.c
>>>>>>>> index d57b82a2b570..ea287b57cbf3 100644
>>>>>>>> --- a/drivers/devfreq/governor_simpleondemand.c
>>>>>>>> +++ b/drivers/devfreq/governor_simpleondemand.c
>>>>>>>> @@ -89,8 +89,7 @@ static int devfreq_simple_ondemand_handler(struct
>>>>>>>> devfreq *devfreq,
>>>>>>>>    {
>>>>>>>>        switch (event) {
>>>>>>>>        case DEVFREQ_GOV_START:
>>>>>>>> -        devfreq_monitor_start(devfreq);
>>>>>>>> -        break;
>>>>>>>> +        return devfreq_monitor_start(devfreq);
>>>>>>>>        case DEVFREQ_GOV_STOP:
>>>>>>>>            devfreq_monitor_stop(devfreq);
>>>>>>>>
>>>>>>>
>>>>>>> Need to handle the all points of devfreq_monitor_start() usage.
>>>>>>> please check the tegra30-devfreq.c for this update.
>>>>>>>
>>>>>>> $ grep -rn "devfreq_monitor_start" drivers/
>>>>>>> drivers/devfreq/governor_simpleondemand.c:92:
>>>>>>> devfreq_monitor_start(devfreq);
>>>>>>> drivers/devfreq/tegra30-devfreq.c:744:
>>>>>>> devfreq_monitor_start(devfreq);
>>>>>>> ......
>>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> Best Regards,
>>>>>> Samsung Electronics
>>>>>> Chanwoo Choi
>>>>>
>>>>>
>>>>
>>>>
>>>> --
>>>> Best Regards,
>>>> Chanwoo Choi
>>>> Samsung Electronics
>>>
>>>
>>
>>
>> --
>> Best Regards,
>> Chanwoo Choi
>> Samsung Electronics


-- 
Best Regards,
Samsung Electronics
Chanwoo Choi

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 07/11] PM / devfreq: check get_dev_status before start monitor
  2021-03-12 16:09                 ` Chanwoo Choi
@ 2021-03-13  6:45                   ` Dong Aisheng
  2021-03-18  8:03                     ` Dong Aisheng
  0 siblings, 1 reply; 58+ messages in thread
From: Dong Aisheng @ 2021-03-13  6:45 UTC (permalink / raw)
  To: Chanwoo Choi
  Cc: Chanwoo Choi, Dong Aisheng, Linux PM,
	moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE,
	Sascha Hauer, Shawn Guo, dl-linux-imx, open list, myungjoo.ham,
	kyungmin.park, Abel Vesa

On Sat, Mar 13, 2021 at 12:09 AM Chanwoo Choi <cwchoi00@gmail.com> wrote:
>
> On 21. 3. 12. 오후 7:57, Dong Aisheng wrote:
> > On Thu, Mar 11, 2021 at 2:54 PM Chanwoo Choi <cw00.choi@samsung.com> wrote:
> >>
> >> On 3/10/21 1:56 PM, Dong Aisheng wrote:
> >>> On Wed, Mar 10, 2021 at 11:08 AM Chanwoo Choi <cw00.choi@samsung.com> wrote:
> >>>>
> >>>> On 3/10/21 11:56 AM, Dong Aisheng wrote:
> >>>>> On Wed, Mar 10, 2021 at 12:12 AM Chanwoo Choi <cwchoi00@gmail.com> wrote:
> >>>>>>
> >>>>>> On 21. 3. 10. 오전 12:58, Chanwoo Choi wrote:
> >>>>>>> On 21. 3. 9. 오후 9:58, Dong Aisheng wrote:
> >>>>>>>> The devfreq monitor depends on the device to provide load information
> >>>>>>>> by .get_dev_status() to calculate the next target freq.
> >>>>>>>>
> >>>>>>>> And this will cause changing governor to simple ondemand fail
> >>>>>>>> if device can't support.
> >>>>>>>>
> >>>>>>>> Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
> >>>>>>>> ---
> >>>>>>>>    drivers/devfreq/devfreq.c                 | 10 +++++++---
> >>>>>>>>    drivers/devfreq/governor.h                |  2 +-
> >>>>>>>>    drivers/devfreq/governor_simpleondemand.c |  3 +--
> >>>>>>>>    3 files changed, 9 insertions(+), 6 deletions(-)
> >>>>>>>>
> >>>>>>>> diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
> >>>>>>>> index 7231fe6862a2..d1787b6c7d7c 100644
> >>>>>>>> --- a/drivers/devfreq/devfreq.c
> >>>>>>>> +++ b/drivers/devfreq/devfreq.c
> >>>>>>>> @@ -482,10 +482,13 @@ static void devfreq_monitor(struct work_struct
> >>>>>>>> *work)
> >>>>>>>>     * to be called from governor in response to DEVFREQ_GOV_START
> >>>>>>>>     * event when device is added to devfreq framework.
> >>>>>>>>     */
> >>>>>>>> -void devfreq_monitor_start(struct devfreq *devfreq)
> >>>>>>>> +int devfreq_monitor_start(struct devfreq *devfreq)
> >>>>>>>>    {
> >>>>>>>>        if (IS_SUPPORTED_FLAG(devfreq->governor->flags, IRQ_DRIVEN))
> >>>>>>>> -        return;
> >>>>>>>> +        return 0;
> >>>>>>>> +
> >>>>>>>> +    if (!devfreq->profile->get_dev_status)
> >>>>>>>> +        return -EINVAL;
> >>>>>>
> >>>>>> Again, I think that get_dev_status is not used for all governors.
> >>>>>> So that it cause the governor start fail. Don't check whether
> >>>>>> .get_dev_status is NULL or not.
> >>>>>>
> >>>>>
> >>>>> I'm not quite understand your point.
> >>>>> it is used by governor_simpleondemand.c and tegra_devfreq_governor.
> >>>>> get_target_freq -> devfreq_update_stats -> get_dev_status
> >>>>
> >>>> The devfreq can add the new governor by anyone.
> >>>> So these functions like devfreq_monitor_* have to support
> >>>> the governors and also must support the governor to be added
> >>>> in the future.
> >>>
> >>> Yes, but devfreq_monitor_* is only used by polling mode, right?
> >>> The governor using it has to implement get_dev_status unless
> >>> there's an exception in the future.
> >>>
> >>> Currently this patch wants to address the issue that user can switch
> >>> to ondemand governor (polling mode) by sysfs even devices does
> >>> not support it (no get_dev_status implemented).
> >>
> >> As I commented, I'll fix this issue. If devfreq driver doesn't implement
> >> the .get_dev_status, don't show it via available_governors. I think that
> >> it is fundamental solution to fix this issue.
> >
> > Sounds good
> >
> >> So on this version,
> >> don't add the this conditional statement on this function
> >>
> >
> > Almost all this patch did is adding a checking for get_dev_status.
> > So do you mean drop this patch?
> > I wonder it's still a necessary checking to explicitly tell devfreq monitor
> > users that get_dev_status is needed during governor startup.
>
> I think that the it is enough to check .get_dev_status in
> devfreq_update_stats. We have to check it on where it is used.
>

I think the drawback of only checking .get_dev_status in
devfreq_update_stats is:
1. devfreq will still register successfully and ondemand governor starts ok
2. ondemand governor will still be shown in sysfs which is something
you want to fix
3. devfreq will end up printing endless error messages in devfreq_monitor worker
    "dvfs failed with (%d) error" as the possible missing .get_dev_status

So i wonder if you don't like changing the common devfreq_monitor_start in order
to make it look common for all governors, then we probably still need
to fix it in
ondemand governor in order to avoid the possible above issues.

static int devfreq_simple_ondemand_handler(struct devfreq *devfreq,
                                unsigned int event, void *data)
{
        switch (event) {
        case DEVFREQ_GOV_START:
                if (!devfreq->profile->get_dev_status)
                        return -EINVAL;

                return devfreq_monitor_start(devfreq);
...
}

How do you think?

Regards
Aisheng


> >
> >> And on next version, please use the capital letter for first character
> >> on patch title as following:
> >>
> >> - PM / devfreq: Check get_dev_status before start monitor
> >>
> >
> > Okay to me.
> > Thanks for the suggestion.
> >
> > Regards
> > Aisheng
> >
> >>>
> >>> Regards
> >>> Aisheng
> >>>
> >>>>
> >>>>>
> >>>>> Without checking, device can switch to ondemand governor if it does not support.
> >>>>>
> >>>>> Am i missed something?
> >>>>>
> >>>>> Regards
> >>>>> Aisheng
> >>>>>
> >>>>>>>>        switch (devfreq->profile->timer) {
> >>>>>>>>        case DEVFREQ_TIMER_DEFERRABLE:
> >>>>>>>> @@ -495,12 +498,13 @@ void devfreq_monitor_start(struct devfreq *devfreq)
> >>>>>>>>            INIT_DELAYED_WORK(&devfreq->work, devfreq_monitor);
> >>>>>>>>            break;
> >>>>>>>>        default:
> >>>>>>>> -        return;
> >>>>>>>> +        return -EINVAL;
> >>>>>>>>        }
> >>>>>>>>        if (devfreq->profile->polling_ms)
> >>>>>>>>            queue_delayed_work(devfreq_wq, &devfreq->work,
> >>>>>>>>                msecs_to_jiffies(devfreq->profile->polling_ms));
> >>>>>>>> +    return 0;
> >>>>>>>>    }
> >>>>>>>>    EXPORT_SYMBOL(devfreq_monitor_start);
> >>>>>>>> diff --git a/drivers/devfreq/governor.h b/drivers/devfreq/governor.h
> >>>>>>>> index 5cee3f64fe2b..31af6d072a10 100644
> >>>>>>>> --- a/drivers/devfreq/governor.h
> >>>>>>>> +++ b/drivers/devfreq/governor.h
> >>>>>>>> @@ -75,7 +75,7 @@ struct devfreq_governor {
> >>>>>>>>                    unsigned int event, void *data);
> >>>>>>>>    };
> >>>>>>>> -void devfreq_monitor_start(struct devfreq *devfreq);
> >>>>>>>> +int devfreq_monitor_start(struct devfreq *devfreq);
> >>>>>>>>    void devfreq_monitor_stop(struct devfreq *devfreq);
> >>>>>>>>    void devfreq_monitor_suspend(struct devfreq *devfreq);
> >>>>>>>>    void devfreq_monitor_resume(struct devfreq *devfreq);
> >>>>>>>> diff --git a/drivers/devfreq/governor_simpleondemand.c
> >>>>>>>> b/drivers/devfreq/governor_simpleondemand.c
> >>>>>>>> index d57b82a2b570..ea287b57cbf3 100644
> >>>>>>>> --- a/drivers/devfreq/governor_simpleondemand.c
> >>>>>>>> +++ b/drivers/devfreq/governor_simpleondemand.c
> >>>>>>>> @@ -89,8 +89,7 @@ static int devfreq_simple_ondemand_handler(struct
> >>>>>>>> devfreq *devfreq,
> >>>>>>>>    {
> >>>>>>>>        switch (event) {
> >>>>>>>>        case DEVFREQ_GOV_START:
> >>>>>>>> -        devfreq_monitor_start(devfreq);
> >>>>>>>> -        break;
> >>>>>>>> +        return devfreq_monitor_start(devfreq);
> >>>>>>>>        case DEVFREQ_GOV_STOP:
> >>>>>>>>            devfreq_monitor_stop(devfreq);
> >>>>>>>>
> >>>>>>>
> >>>>>>> Need to handle the all points of devfreq_monitor_start() usage.
> >>>>>>> please check the tegra30-devfreq.c for this update.
> >>>>>>>
> >>>>>>> $ grep -rn "devfreq_monitor_start" drivers/
> >>>>>>> drivers/devfreq/governor_simpleondemand.c:92:
> >>>>>>> devfreq_monitor_start(devfreq);
> >>>>>>> drivers/devfreq/tegra30-devfreq.c:744:
> >>>>>>> devfreq_monitor_start(devfreq);
> >>>>>>> ......
> >>>>>>>
> >>>>>>
> >>>>>>
> >>>>>> --
> >>>>>> Best Regards,
> >>>>>> Samsung Electronics
> >>>>>> Chanwoo Choi
> >>>>>
> >>>>>
> >>>>
> >>>>
> >>>> --
> >>>> Best Regards,
> >>>> Chanwoo Choi
> >>>> Samsung Electronics
> >>>
> >>>
> >>
> >>
> >> --
> >> Best Regards,
> >> Chanwoo Choi
> >> Samsung Electronics
>
>
> --
> Best Regards,
> Samsung Electronics
> Chanwoo Choi

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 07/11] PM / devfreq: check get_dev_status before start monitor
  2021-03-13  6:45                   ` Dong Aisheng
@ 2021-03-18  8:03                     ` Dong Aisheng
  2021-03-18  9:54                       ` Chanwoo Choi
  0 siblings, 1 reply; 58+ messages in thread
From: Dong Aisheng @ 2021-03-18  8:03 UTC (permalink / raw)
  To: Chanwoo Choi
  Cc: Chanwoo Choi, Dong Aisheng, Linux PM,
	moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE,
	Sascha Hauer, Shawn Guo, dl-linux-imx, open list, myungjoo.ham,
	kyungmin.park, Abel Vesa

Hi Chanwoo,

On Sat, Mar 13, 2021 at 2:45 PM Dong Aisheng <dongas86@gmail.com> wrote:
>
> On Sat, Mar 13, 2021 at 12:09 AM Chanwoo Choi <cwchoi00@gmail.com> wrote:
> >
> > On 21. 3. 12. 오후 7:57, Dong Aisheng wrote:
> > > On Thu, Mar 11, 2021 at 2:54 PM Chanwoo Choi <cw00.choi@samsung.com> wrote:
> > >>
> > >> On 3/10/21 1:56 PM, Dong Aisheng wrote:
> > >>> On Wed, Mar 10, 2021 at 11:08 AM Chanwoo Choi <cw00.choi@samsung.com> wrote:
> > >>>>
> > >>>> On 3/10/21 11:56 AM, Dong Aisheng wrote:
> > >>>>> On Wed, Mar 10, 2021 at 12:12 AM Chanwoo Choi <cwchoi00@gmail.com> wrote:
> > >>>>>>
> > >>>>>> On 21. 3. 10. 오전 12:58, Chanwoo Choi wrote:
> > >>>>>>> On 21. 3. 9. 오후 9:58, Dong Aisheng wrote:
> > >>>>>>>> The devfreq monitor depends on the device to provide load information
> > >>>>>>>> by .get_dev_status() to calculate the next target freq.
> > >>>>>>>>
> > >>>>>>>> And this will cause changing governor to simple ondemand fail
> > >>>>>>>> if device can't support.
> > >>>>>>>>
> > >>>>>>>> Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
> > >>>>>>>> ---
> > >>>>>>>>    drivers/devfreq/devfreq.c                 | 10 +++++++---
> > >>>>>>>>    drivers/devfreq/governor.h                |  2 +-
> > >>>>>>>>    drivers/devfreq/governor_simpleondemand.c |  3 +--
> > >>>>>>>>    3 files changed, 9 insertions(+), 6 deletions(-)
> > >>>>>>>>
> > >>>>>>>> diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
> > >>>>>>>> index 7231fe6862a2..d1787b6c7d7c 100644
> > >>>>>>>> --- a/drivers/devfreq/devfreq.c
> > >>>>>>>> +++ b/drivers/devfreq/devfreq.c
> > >>>>>>>> @@ -482,10 +482,13 @@ static void devfreq_monitor(struct work_struct
> > >>>>>>>> *work)
> > >>>>>>>>     * to be called from governor in response to DEVFREQ_GOV_START
> > >>>>>>>>     * event when device is added to devfreq framework.
> > >>>>>>>>     */
> > >>>>>>>> -void devfreq_monitor_start(struct devfreq *devfreq)
> > >>>>>>>> +int devfreq_monitor_start(struct devfreq *devfreq)
> > >>>>>>>>    {
> > >>>>>>>>        if (IS_SUPPORTED_FLAG(devfreq->governor->flags, IRQ_DRIVEN))
> > >>>>>>>> -        return;
> > >>>>>>>> +        return 0;
> > >>>>>>>> +
> > >>>>>>>> +    if (!devfreq->profile->get_dev_status)
> > >>>>>>>> +        return -EINVAL;
> > >>>>>>
> > >>>>>> Again, I think that get_dev_status is not used for all governors.
> > >>>>>> So that it cause the governor start fail. Don't check whether
> > >>>>>> .get_dev_status is NULL or not.
> > >>>>>>
> > >>>>>
> > >>>>> I'm not quite understand your point.
> > >>>>> it is used by governor_simpleondemand.c and tegra_devfreq_governor.
> > >>>>> get_target_freq -> devfreq_update_stats -> get_dev_status
> > >>>>
> > >>>> The devfreq can add the new governor by anyone.
> > >>>> So these functions like devfreq_monitor_* have to support
> > >>>> the governors and also must support the governor to be added
> > >>>> in the future.
> > >>>
> > >>> Yes, but devfreq_monitor_* is only used by polling mode, right?
> > >>> The governor using it has to implement get_dev_status unless
> > >>> there's an exception in the future.
> > >>>
> > >>> Currently this patch wants to address the issue that user can switch
> > >>> to ondemand governor (polling mode) by sysfs even devices does
> > >>> not support it (no get_dev_status implemented).
> > >>
> > >> As I commented, I'll fix this issue. If devfreq driver doesn't implement
> > >> the .get_dev_status, don't show it via available_governors. I think that
> > >> it is fundamental solution to fix this issue.
> > >
> > > Sounds good
> > >
> > >> So on this version,
> > >> don't add the this conditional statement on this function
> > >>
> > >
> > > Almost all this patch did is adding a checking for get_dev_status.
> > > So do you mean drop this patch?
> > > I wonder it's still a necessary checking to explicitly tell devfreq monitor
> > > users that get_dev_status is needed during governor startup.
> >
> > I think that the it is enough to check .get_dev_status in
> > devfreq_update_stats. We have to check it on where it is used.
> >
>
> I think the drawback of only checking .get_dev_status in
> devfreq_update_stats is:
> 1. devfreq will still register successfully and ondemand governor starts ok
> 2. ondemand governor will still be shown in sysfs which is something
> you want to fix
> 3. devfreq will end up printing endless error messages in devfreq_monitor worker
>     "dvfs failed with (%d) error" as the possible missing .get_dev_status
>
> So i wonder if you don't like changing the common devfreq_monitor_start in order
> to make it look common for all governors, then we probably still need
> to fix it in
> ondemand governor in order to avoid the possible above issues.
>
> static int devfreq_simple_ondemand_handler(struct devfreq *devfreq,
>                                 unsigned int event, void *data)
> {
>         switch (event) {
>         case DEVFREQ_GOV_START:
>                 if (!devfreq->profile->get_dev_status)
>                         return -EINVAL;
>
>                 return devfreq_monitor_start(devfreq);
> ...
> }
>
> How do you think?

Any feedback?

I'm waiting for your confirmation whether dropping this one,
then I can re-sent the series.

Regards
Aisheng

>
> Regards
> Aisheng
>
>
> > >
> > >> And on next version, please use the capital letter for first character
> > >> on patch title as following:
> > >>
> > >> - PM / devfreq: Check get_dev_status before start monitor
> > >>
> > >
> > > Okay to me.
> > > Thanks for the suggestion.
> > >
> > > Regards
> > > Aisheng
> > >
> > >>>
> > >>> Regards
> > >>> Aisheng
> > >>>
> > >>>>
> > >>>>>
> > >>>>> Without checking, device can switch to ondemand governor if it does not support.
> > >>>>>
> > >>>>> Am i missed something?
> > >>>>>
> > >>>>> Regards
> > >>>>> Aisheng
> > >>>>>
> > >>>>>>>>        switch (devfreq->profile->timer) {
> > >>>>>>>>        case DEVFREQ_TIMER_DEFERRABLE:
> > >>>>>>>> @@ -495,12 +498,13 @@ void devfreq_monitor_start(struct devfreq *devfreq)
> > >>>>>>>>            INIT_DELAYED_WORK(&devfreq->work, devfreq_monitor);
> > >>>>>>>>            break;
> > >>>>>>>>        default:
> > >>>>>>>> -        return;
> > >>>>>>>> +        return -EINVAL;
> > >>>>>>>>        }
> > >>>>>>>>        if (devfreq->profile->polling_ms)
> > >>>>>>>>            queue_delayed_work(devfreq_wq, &devfreq->work,
> > >>>>>>>>                msecs_to_jiffies(devfreq->profile->polling_ms));
> > >>>>>>>> +    return 0;
> > >>>>>>>>    }
> > >>>>>>>>    EXPORT_SYMBOL(devfreq_monitor_start);
> > >>>>>>>> diff --git a/drivers/devfreq/governor.h b/drivers/devfreq/governor.h
> > >>>>>>>> index 5cee3f64fe2b..31af6d072a10 100644
> > >>>>>>>> --- a/drivers/devfreq/governor.h
> > >>>>>>>> +++ b/drivers/devfreq/governor.h
> > >>>>>>>> @@ -75,7 +75,7 @@ struct devfreq_governor {
> > >>>>>>>>                    unsigned int event, void *data);
> > >>>>>>>>    };
> > >>>>>>>> -void devfreq_monitor_start(struct devfreq *devfreq);
> > >>>>>>>> +int devfreq_monitor_start(struct devfreq *devfreq);
> > >>>>>>>>    void devfreq_monitor_stop(struct devfreq *devfreq);
> > >>>>>>>>    void devfreq_monitor_suspend(struct devfreq *devfreq);
> > >>>>>>>>    void devfreq_monitor_resume(struct devfreq *devfreq);
> > >>>>>>>> diff --git a/drivers/devfreq/governor_simpleondemand.c
> > >>>>>>>> b/drivers/devfreq/governor_simpleondemand.c
> > >>>>>>>> index d57b82a2b570..ea287b57cbf3 100644
> > >>>>>>>> --- a/drivers/devfreq/governor_simpleondemand.c
> > >>>>>>>> +++ b/drivers/devfreq/governor_simpleondemand.c
> > >>>>>>>> @@ -89,8 +89,7 @@ static int devfreq_simple_ondemand_handler(struct
> > >>>>>>>> devfreq *devfreq,
> > >>>>>>>>    {
> > >>>>>>>>        switch (event) {
> > >>>>>>>>        case DEVFREQ_GOV_START:
> > >>>>>>>> -        devfreq_monitor_start(devfreq);
> > >>>>>>>> -        break;
> > >>>>>>>> +        return devfreq_monitor_start(devfreq);
> > >>>>>>>>        case DEVFREQ_GOV_STOP:
> > >>>>>>>>            devfreq_monitor_stop(devfreq);
> > >>>>>>>>
> > >>>>>>>
> > >>>>>>> Need to handle the all points of devfreq_monitor_start() usage.
> > >>>>>>> please check the tegra30-devfreq.c for this update.
> > >>>>>>>
> > >>>>>>> $ grep -rn "devfreq_monitor_start" drivers/
> > >>>>>>> drivers/devfreq/governor_simpleondemand.c:92:
> > >>>>>>> devfreq_monitor_start(devfreq);
> > >>>>>>> drivers/devfreq/tegra30-devfreq.c:744:
> > >>>>>>> devfreq_monitor_start(devfreq);
> > >>>>>>> ......
> > >>>>>>>
> > >>>>>>
> > >>>>>>
> > >>>>>> --
> > >>>>>> Best Regards,
> > >>>>>> Samsung Electronics
> > >>>>>> Chanwoo Choi
> > >>>>>
> > >>>>>
> > >>>>
> > >>>>
> > >>>> --
> > >>>> Best Regards,
> > >>>> Chanwoo Choi
> > >>>> Samsung Electronics
> > >>>
> > >>>
> > >>
> > >>
> > >> --
> > >> Best Regards,
> > >> Chanwoo Choi
> > >> Samsung Electronics
> >
> >
> > --
> > Best Regards,
> > Samsung Electronics
> > Chanwoo Choi

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 07/11] PM / devfreq: check get_dev_status before start monitor
  2021-03-18  8:03                     ` Dong Aisheng
@ 2021-03-18  9:54                       ` Chanwoo Choi
  2021-03-18  9:59                         ` Chanwoo Choi
  0 siblings, 1 reply; 58+ messages in thread
From: Chanwoo Choi @ 2021-03-18  9:54 UTC (permalink / raw)
  To: Dong Aisheng, Chanwoo Choi
  Cc: Dong Aisheng, Linux PM,
	moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE,
	Sascha Hauer, Shawn Guo, dl-linux-imx, open list, myungjoo.ham,
	kyungmin.park, Abel Vesa

On 3/18/21 5:03 PM, Dong Aisheng wrote:
> Hi Chanwoo,
> 
> On Sat, Mar 13, 2021 at 2:45 PM Dong Aisheng <dongas86@gmail.com> wrote:
>>
>> On Sat, Mar 13, 2021 at 12:09 AM Chanwoo Choi <cwchoi00@gmail.com> wrote:
>>>
>>> On 21. 3. 12. 오후 7:57, Dong Aisheng wrote:
>>>> On Thu, Mar 11, 2021 at 2:54 PM Chanwoo Choi <cw00.choi@samsung.com> wrote:
>>>>>
>>>>> On 3/10/21 1:56 PM, Dong Aisheng wrote:
>>>>>> On Wed, Mar 10, 2021 at 11:08 AM Chanwoo Choi <cw00.choi@samsung.com> wrote:
>>>>>>>
>>>>>>> On 3/10/21 11:56 AM, Dong Aisheng wrote:
>>>>>>>> On Wed, Mar 10, 2021 at 12:12 AM Chanwoo Choi <cwchoi00@gmail.com> wrote:
>>>>>>>>>
>>>>>>>>> On 21. 3. 10. 오전 12:58, Chanwoo Choi wrote:
>>>>>>>>>> On 21. 3. 9. 오후 9:58, Dong Aisheng wrote:
>>>>>>>>>>> The devfreq monitor depends on the device to provide load information
>>>>>>>>>>> by .get_dev_status() to calculate the next target freq.
>>>>>>>>>>>
>>>>>>>>>>> And this will cause changing governor to simple ondemand fail
>>>>>>>>>>> if device can't support.
>>>>>>>>>>>
>>>>>>>>>>> Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
>>>>>>>>>>> ---
>>>>>>>>>>>    drivers/devfreq/devfreq.c                 | 10 +++++++---
>>>>>>>>>>>    drivers/devfreq/governor.h                |  2 +-
>>>>>>>>>>>    drivers/devfreq/governor_simpleondemand.c |  3 +--
>>>>>>>>>>>    3 files changed, 9 insertions(+), 6 deletions(-)
>>>>>>>>>>>
>>>>>>>>>>> diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
>>>>>>>>>>> index 7231fe6862a2..d1787b6c7d7c 100644
>>>>>>>>>>> --- a/drivers/devfreq/devfreq.c
>>>>>>>>>>> +++ b/drivers/devfreq/devfreq.c
>>>>>>>>>>> @@ -482,10 +482,13 @@ static void devfreq_monitor(struct work_struct
>>>>>>>>>>> *work)
>>>>>>>>>>>     * to be called from governor in response to DEVFREQ_GOV_START
>>>>>>>>>>>     * event when device is added to devfreq framework.
>>>>>>>>>>>     */
>>>>>>>>>>> -void devfreq_monitor_start(struct devfreq *devfreq)
>>>>>>>>>>> +int devfreq_monitor_start(struct devfreq *devfreq)
>>>>>>>>>>>    {
>>>>>>>>>>>        if (IS_SUPPORTED_FLAG(devfreq->governor->flags, IRQ_DRIVEN))
>>>>>>>>>>> -        return;
>>>>>>>>>>> +        return 0;
>>>>>>>>>>> +
>>>>>>>>>>> +    if (!devfreq->profile->get_dev_status)
>>>>>>>>>>> +        return -EINVAL;
>>>>>>>>>
>>>>>>>>> Again, I think that get_dev_status is not used for all governors.
>>>>>>>>> So that it cause the governor start fail. Don't check whether
>>>>>>>>> .get_dev_status is NULL or not.
>>>>>>>>>
>>>>>>>>
>>>>>>>> I'm not quite understand your point.
>>>>>>>> it is used by governor_simpleondemand.c and tegra_devfreq_governor.
>>>>>>>> get_target_freq -> devfreq_update_stats -> get_dev_status
>>>>>>>
>>>>>>> The devfreq can add the new governor by anyone.
>>>>>>> So these functions like devfreq_monitor_* have to support
>>>>>>> the governors and also must support the governor to be added
>>>>>>> in the future.
>>>>>>
>>>>>> Yes, but devfreq_monitor_* is only used by polling mode, right?
>>>>>> The governor using it has to implement get_dev_status unless
>>>>>> there's an exception in the future.
>>>>>>
>>>>>> Currently this patch wants to address the issue that user can switch
>>>>>> to ondemand governor (polling mode) by sysfs even devices does
>>>>>> not support it (no get_dev_status implemented).
>>>>>
>>>>> As I commented, I'll fix this issue. If devfreq driver doesn't implement
>>>>> the .get_dev_status, don't show it via available_governors. I think that
>>>>> it is fundamental solution to fix this issue.
>>>>
>>>> Sounds good
>>>>
>>>>> So on this version,
>>>>> don't add the this conditional statement on this function
>>>>>
>>>>
>>>> Almost all this patch did is adding a checking for get_dev_status.
>>>> So do you mean drop this patch?
>>>> I wonder it's still a necessary checking to explicitly tell devfreq monitor
>>>> users that get_dev_status is needed during governor startup.
>>>
>>> I think that the it is enough to check .get_dev_status in
>>> devfreq_update_stats. We have to check it on where it is used.
>>>
>>
>> I think the drawback of only checking .get_dev_status in
>> devfreq_update_stats is:
>> 1. devfreq will still register successfully and ondemand governor starts ok
>> 2. ondemand governor will still be shown in sysfs which is something
>> you want to fix
>> 3. devfreq will end up printing endless error messages in devfreq_monitor worker
>>     "dvfs failed with (%d) error" as the possible missing .get_dev_status

I think that devfreq_monitor_start have to handle only work instance.
This approach is too considering the deep check list.
I want to resolve this periodical error log with different solution.

Actually, we have to reject the registration of devfreq device
when calling devfreq_add_device instead of checking .get_dev_status
in devfreq_monitor_start().


>>
>> So i wonder if you don't like changing the common devfreq_monitor_start in order
>> to make it look common for all governors, then we probably still need
>> to fix it in
>> ondemand governor in order to avoid the possible above issues.
>>
>> static int devfreq_simple_ondemand_handler(struct devfreq *devfreq,
>>                                 unsigned int event, void *data)
>> {
>>         switch (event) {
>>         case DEVFREQ_GOV_START:
>>                 if (!devfreq->profile->get_dev_status)
>>                         return -EINVAL;
>>
>>                 return devfreq_monitor_start(devfreq);
>> ...
>> }
>>
>> How do you think?
> 
> Any feedback?
> 
> I'm waiting for your confirmation whether dropping this one,
> then I can re-sent the series.
> 
> Regards
> Aisheng
> 
>>
>> Regards
>> Aisheng
>>
>>
>>>>
>>>>> And on next version, please use the capital letter for first character
>>>>> on patch title as following:
>>>>>
>>>>> - PM / devfreq: Check get_dev_status before start monitor
>>>>>
>>>>
>>>> Okay to me.
>>>> Thanks for the suggestion.
>>>>
>>>> Regards
>>>> Aisheng
>>>>
>>>>>>
>>>>>> Regards
>>>>>> Aisheng
>>>>>>
>>>>>>>
>>>>>>>>
>>>>>>>> Without checking, device can switch to ondemand governor if it does not support.
>>>>>>>>
>>>>>>>> Am i missed something?
>>>>>>>>
>>>>>>>> Regards
>>>>>>>> Aisheng
>>>>>>>>
>>>>>>>>>>>        switch (devfreq->profile->timer) {
>>>>>>>>>>>        case DEVFREQ_TIMER_DEFERRABLE:
>>>>>>>>>>> @@ -495,12 +498,13 @@ void devfreq_monitor_start(struct devfreq *devfreq)
>>>>>>>>>>>            INIT_DELAYED_WORK(&devfreq->work, devfreq_monitor);
>>>>>>>>>>>            break;
>>>>>>>>>>>        default:
>>>>>>>>>>> -        return;
>>>>>>>>>>> +        return -EINVAL;
>>>>>>>>>>>        }
>>>>>>>>>>>        if (devfreq->profile->polling_ms)
>>>>>>>>>>>            queue_delayed_work(devfreq_wq, &devfreq->work,
>>>>>>>>>>>                msecs_to_jiffies(devfreq->profile->polling_ms));
>>>>>>>>>>> +    return 0;
>>>>>>>>>>>    }
>>>>>>>>>>>    EXPORT_SYMBOL(devfreq_monitor_start);
>>>>>>>>>>> diff --git a/drivers/devfreq/governor.h b/drivers/devfreq/governor.h
>>>>>>>>>>> index 5cee3f64fe2b..31af6d072a10 100644
>>>>>>>>>>> --- a/drivers/devfreq/governor.h
>>>>>>>>>>> +++ b/drivers/devfreq/governor.h
>>>>>>>>>>> @@ -75,7 +75,7 @@ struct devfreq_governor {
>>>>>>>>>>>                    unsigned int event, void *data);
>>>>>>>>>>>    };
>>>>>>>>>>> -void devfreq_monitor_start(struct devfreq *devfreq);
>>>>>>>>>>> +int devfreq_monitor_start(struct devfreq *devfreq);
>>>>>>>>>>>    void devfreq_monitor_stop(struct devfreq *devfreq);
>>>>>>>>>>>    void devfreq_monitor_suspend(struct devfreq *devfreq);
>>>>>>>>>>>    void devfreq_monitor_resume(struct devfreq *devfreq);
>>>>>>>>>>> diff --git a/drivers/devfreq/governor_simpleondemand.c
>>>>>>>>>>> b/drivers/devfreq/governor_simpleondemand.c
>>>>>>>>>>> index d57b82a2b570..ea287b57cbf3 100644
>>>>>>>>>>> --- a/drivers/devfreq/governor_simpleondemand.c
>>>>>>>>>>> +++ b/drivers/devfreq/governor_simpleondemand.c
>>>>>>>>>>> @@ -89,8 +89,7 @@ static int devfreq_simple_ondemand_handler(struct
>>>>>>>>>>> devfreq *devfreq,
>>>>>>>>>>>    {
>>>>>>>>>>>        switch (event) {
>>>>>>>>>>>        case DEVFREQ_GOV_START:
>>>>>>>>>>> -        devfreq_monitor_start(devfreq);
>>>>>>>>>>> -        break;
>>>>>>>>>>> +        return devfreq_monitor_start(devfreq);
>>>>>>>>>>>        case DEVFREQ_GOV_STOP:
>>>>>>>>>>>            devfreq_monitor_stop(devfreq);
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> Need to handle the all points of devfreq_monitor_start() usage.
>>>>>>>>>> please check the tegra30-devfreq.c for this update.
>>>>>>>>>>
>>>>>>>>>> $ grep -rn "devfreq_monitor_start" drivers/
>>>>>>>>>> drivers/devfreq/governor_simpleondemand.c:92:
>>>>>>>>>> devfreq_monitor_start(devfreq);
>>>>>>>>>> drivers/devfreq/tegra30-devfreq.c:744:
>>>>>>>>>> devfreq_monitor_start(devfreq);
>>>>>>>>>> ......
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> --
>>>>>>>>> Best Regards,
>>>>>>>>> Samsung Electronics
>>>>>>>>> Chanwoo Choi
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> Best Regards,
>>>>>>> Chanwoo Choi
>>>>>>> Samsung Electronics
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Best Regards,
>>>>> Chanwoo Choi
>>>>> Samsung Electronics
>>>
>>>
>>> --
>>> Best Regards,
>>> Samsung Electronics
>>> Chanwoo Choi
> 
> 


-- 
Best Regards,
Chanwoo Choi
Samsung Electronics

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 07/11] PM / devfreq: check get_dev_status before start monitor
  2021-03-18  9:54                       ` Chanwoo Choi
@ 2021-03-18  9:59                         ` Chanwoo Choi
  2021-03-18 10:51                           ` Dong Aisheng
  0 siblings, 1 reply; 58+ messages in thread
From: Chanwoo Choi @ 2021-03-18  9:59 UTC (permalink / raw)
  To: Dong Aisheng, Chanwoo Choi
  Cc: Dong Aisheng, Linux PM,
	moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE,
	Sascha Hauer, Shawn Guo, dl-linux-imx, open list, myungjoo.ham,
	kyungmin.park, Abel Vesa

On 3/18/21 6:54 PM, Chanwoo Choi wrote:
> On 3/18/21 5:03 PM, Dong Aisheng wrote:
>> Hi Chanwoo,
>>
>> On Sat, Mar 13, 2021 at 2:45 PM Dong Aisheng <dongas86@gmail.com> wrote:
>>>
>>> On Sat, Mar 13, 2021 at 12:09 AM Chanwoo Choi <cwchoi00@gmail.com> wrote:
>>>>
>>>> On 21. 3. 12. 오후 7:57, Dong Aisheng wrote:
>>>>> On Thu, Mar 11, 2021 at 2:54 PM Chanwoo Choi <cw00.choi@samsung.com> wrote:
>>>>>>
>>>>>> On 3/10/21 1:56 PM, Dong Aisheng wrote:
>>>>>>> On Wed, Mar 10, 2021 at 11:08 AM Chanwoo Choi <cw00.choi@samsung.com> wrote:
>>>>>>>>
>>>>>>>> On 3/10/21 11:56 AM, Dong Aisheng wrote:
>>>>>>>>> On Wed, Mar 10, 2021 at 12:12 AM Chanwoo Choi <cwchoi00@gmail.com> wrote:
>>>>>>>>>>
>>>>>>>>>> On 21. 3. 10. 오전 12:58, Chanwoo Choi wrote:
>>>>>>>>>>> On 21. 3. 9. 오후 9:58, Dong Aisheng wrote:
>>>>>>>>>>>> The devfreq monitor depends on the device to provide load information
>>>>>>>>>>>> by .get_dev_status() to calculate the next target freq.
>>>>>>>>>>>>
>>>>>>>>>>>> And this will cause changing governor to simple ondemand fail
>>>>>>>>>>>> if device can't support.
>>>>>>>>>>>>
>>>>>>>>>>>> Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
>>>>>>>>>>>> ---
>>>>>>>>>>>>    drivers/devfreq/devfreq.c                 | 10 +++++++---
>>>>>>>>>>>>    drivers/devfreq/governor.h                |  2 +-
>>>>>>>>>>>>    drivers/devfreq/governor_simpleondemand.c |  3 +--
>>>>>>>>>>>>    3 files changed, 9 insertions(+), 6 deletions(-)
>>>>>>>>>>>>
>>>>>>>>>>>> diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
>>>>>>>>>>>> index 7231fe6862a2..d1787b6c7d7c 100644
>>>>>>>>>>>> --- a/drivers/devfreq/devfreq.c
>>>>>>>>>>>> +++ b/drivers/devfreq/devfreq.c
>>>>>>>>>>>> @@ -482,10 +482,13 @@ static void devfreq_monitor(struct work_struct
>>>>>>>>>>>> *work)
>>>>>>>>>>>>     * to be called from governor in response to DEVFREQ_GOV_START
>>>>>>>>>>>>     * event when device is added to devfreq framework.
>>>>>>>>>>>>     */
>>>>>>>>>>>> -void devfreq_monitor_start(struct devfreq *devfreq)
>>>>>>>>>>>> +int devfreq_monitor_start(struct devfreq *devfreq)
>>>>>>>>>>>>    {
>>>>>>>>>>>>        if (IS_SUPPORTED_FLAG(devfreq->governor->flags, IRQ_DRIVEN))
>>>>>>>>>>>> -        return;
>>>>>>>>>>>> +        return 0;
>>>>>>>>>>>> +
>>>>>>>>>>>> +    if (!devfreq->profile->get_dev_status)
>>>>>>>>>>>> +        return -EINVAL;
>>>>>>>>>>
>>>>>>>>>> Again, I think that get_dev_status is not used for all governors.
>>>>>>>>>> So that it cause the governor start fail. Don't check whether
>>>>>>>>>> .get_dev_status is NULL or not.
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>> I'm not quite understand your point.
>>>>>>>>> it is used by governor_simpleondemand.c and tegra_devfreq_governor.
>>>>>>>>> get_target_freq -> devfreq_update_stats -> get_dev_status
>>>>>>>>
>>>>>>>> The devfreq can add the new governor by anyone.
>>>>>>>> So these functions like devfreq_monitor_* have to support
>>>>>>>> the governors and also must support the governor to be added
>>>>>>>> in the future.
>>>>>>>
>>>>>>> Yes, but devfreq_monitor_* is only used by polling mode, right?
>>>>>>> The governor using it has to implement get_dev_status unless
>>>>>>> there's an exception in the future.
>>>>>>>
>>>>>>> Currently this patch wants to address the issue that user can switch
>>>>>>> to ondemand governor (polling mode) by sysfs even devices does
>>>>>>> not support it (no get_dev_status implemented).
>>>>>>
>>>>>> As I commented, I'll fix this issue. If devfreq driver doesn't implement
>>>>>> the .get_dev_status, don't show it via available_governors. I think that
>>>>>> it is fundamental solution to fix this issue.
>>>>>
>>>>> Sounds good
>>>>>
>>>>>> So on this version,
>>>>>> don't add the this conditional statement on this function
>>>>>>
>>>>>
>>>>> Almost all this patch did is adding a checking for get_dev_status.
>>>>> So do you mean drop this patch?
>>>>> I wonder it's still a necessary checking to explicitly tell devfreq monitor
>>>>> users that get_dev_status is needed during governor startup.
>>>>
>>>> I think that the it is enough to check .get_dev_status in
>>>> devfreq_update_stats. We have to check it on where it is used.
>>>>
>>>
>>> I think the drawback of only checking .get_dev_status in
>>> devfreq_update_stats is:
>>> 1. devfreq will still register successfully and ondemand governor starts ok
>>> 2. ondemand governor will still be shown in sysfs which is something
>>> you want to fix
>>> 3. devfreq will end up printing endless error messages in devfreq_monitor worker
>>>     "dvfs failed with (%d) error" as the possible missing .get_dev_status
> 
> I think that devfreq_monitor_start have to handle only work instance.
> This approach is too considering the deep check list.
> I want to resolve this periodical error log with different solution.
> 
> Actually, we have to reject the registration of devfreq device
> when calling devfreq_add_device instead of checking .get_dev_status
> in devfreq_monitor_start().


I'll reject the registration of devfreq device if the mandatory
function pointer of struct devfreq_dev_profile are not initialized.
- .get_dev_status
   If some governors like simple_ondemand, have to initialize it.
   So, I need to add the new flag to specify this feature.
- .target is mandatory for all devfreq devices. I'll check it.

> 
> 
>>>
>>> So i wonder if you don't like changing the common devfreq_monitor_start in order
>>> to make it look common for all governors, then we probably still need
>>> to fix it in
>>> ondemand governor in order to avoid the possible above issues.
>>>
>>> static int devfreq_simple_ondemand_handler(struct devfreq *devfreq,
>>>                                 unsigned int event, void *data)
>>> {
>>>         switch (event) {
>>>         case DEVFREQ_GOV_START:
>>>                 if (!devfreq->profile->get_dev_status)
>>>                         return -EINVAL;
>>>
>>>                 return devfreq_monitor_start(devfreq);
>>> ...
>>> }
>>>
>>> How do you think?
>>
>> Any feedback?
>>
>> I'm waiting for your confirmation whether dropping this one,
>> then I can re-sent the series.
>>
>> Regards
>> Aisheng
>>
>>>
>>> Regards
>>> Aisheng
>>>
>>>
>>>>>
>>>>>> And on next version, please use the capital letter for first character
>>>>>> on patch title as following:
>>>>>>
>>>>>> - PM / devfreq: Check get_dev_status before start monitor
>>>>>>
>>>>>
>>>>> Okay to me.
>>>>> Thanks for the suggestion.
>>>>>
>>>>> Regards
>>>>> Aisheng
>>>>>
>>>>>>>
>>>>>>> Regards
>>>>>>> Aisheng
>>>>>>>
>>>>>>>>
>>>>>>>>>
>>>>>>>>> Without checking, device can switch to ondemand governor if it does not support.
>>>>>>>>>
>>>>>>>>> Am i missed something?
>>>>>>>>>
>>>>>>>>> Regards
>>>>>>>>> Aisheng
>>>>>>>>>
>>>>>>>>>>>>        switch (devfreq->profile->timer) {
>>>>>>>>>>>>        case DEVFREQ_TIMER_DEFERRABLE:
>>>>>>>>>>>> @@ -495,12 +498,13 @@ void devfreq_monitor_start(struct devfreq *devfreq)
>>>>>>>>>>>>            INIT_DELAYED_WORK(&devfreq->work, devfreq_monitor);
>>>>>>>>>>>>            break;
>>>>>>>>>>>>        default:
>>>>>>>>>>>> -        return;
>>>>>>>>>>>> +        return -EINVAL;
>>>>>>>>>>>>        }
>>>>>>>>>>>>        if (devfreq->profile->polling_ms)
>>>>>>>>>>>>            queue_delayed_work(devfreq_wq, &devfreq->work,
>>>>>>>>>>>>                msecs_to_jiffies(devfreq->profile->polling_ms));
>>>>>>>>>>>> +    return 0;
>>>>>>>>>>>>    }
>>>>>>>>>>>>    EXPORT_SYMBOL(devfreq_monitor_start);
>>>>>>>>>>>> diff --git a/drivers/devfreq/governor.h b/drivers/devfreq/governor.h
>>>>>>>>>>>> index 5cee3f64fe2b..31af6d072a10 100644
>>>>>>>>>>>> --- a/drivers/devfreq/governor.h
>>>>>>>>>>>> +++ b/drivers/devfreq/governor.h
>>>>>>>>>>>> @@ -75,7 +75,7 @@ struct devfreq_governor {
>>>>>>>>>>>>                    unsigned int event, void *data);
>>>>>>>>>>>>    };
>>>>>>>>>>>> -void devfreq_monitor_start(struct devfreq *devfreq);
>>>>>>>>>>>> +int devfreq_monitor_start(struct devfreq *devfreq);
>>>>>>>>>>>>    void devfreq_monitor_stop(struct devfreq *devfreq);
>>>>>>>>>>>>    void devfreq_monitor_suspend(struct devfreq *devfreq);
>>>>>>>>>>>>    void devfreq_monitor_resume(struct devfreq *devfreq);
>>>>>>>>>>>> diff --git a/drivers/devfreq/governor_simpleondemand.c
>>>>>>>>>>>> b/drivers/devfreq/governor_simpleondemand.c
>>>>>>>>>>>> index d57b82a2b570..ea287b57cbf3 100644
>>>>>>>>>>>> --- a/drivers/devfreq/governor_simpleondemand.c
>>>>>>>>>>>> +++ b/drivers/devfreq/governor_simpleondemand.c
>>>>>>>>>>>> @@ -89,8 +89,7 @@ static int devfreq_simple_ondemand_handler(struct
>>>>>>>>>>>> devfreq *devfreq,
>>>>>>>>>>>>    {
>>>>>>>>>>>>        switch (event) {
>>>>>>>>>>>>        case DEVFREQ_GOV_START:
>>>>>>>>>>>> -        devfreq_monitor_start(devfreq);
>>>>>>>>>>>> -        break;
>>>>>>>>>>>> +        return devfreq_monitor_start(devfreq);
>>>>>>>>>>>>        case DEVFREQ_GOV_STOP:
>>>>>>>>>>>>            devfreq_monitor_stop(devfreq);
>>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> Need to handle the all points of devfreq_monitor_start() usage.
>>>>>>>>>>> please check the tegra30-devfreq.c for this update.
>>>>>>>>>>>
>>>>>>>>>>> $ grep -rn "devfreq_monitor_start" drivers/
>>>>>>>>>>> drivers/devfreq/governor_simpleondemand.c:92:
>>>>>>>>>>> devfreq_monitor_start(devfreq);
>>>>>>>>>>> drivers/devfreq/tegra30-devfreq.c:744:
>>>>>>>>>>> devfreq_monitor_start(devfreq);
>>>>>>>>>>> ......
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> --
>>>>>>>>>> Best Regards,
>>>>>>>>>> Samsung Electronics
>>>>>>>>>> Chanwoo Choi
>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> --
>>>>>>>> Best Regards,
>>>>>>>> Chanwoo Choi
>>>>>>>> Samsung Electronics
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> Best Regards,
>>>>>> Chanwoo Choi
>>>>>> Samsung Electronics
>>>>
>>>>
>>>> --
>>>> Best Regards,
>>>> Samsung Electronics
>>>> Chanwoo Choi
>>
>>
> 
> 


-- 
Best Regards,
Chanwoo Choi
Samsung Electronics

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 07/11] PM / devfreq: check get_dev_status before start monitor
  2021-03-18  9:59                         ` Chanwoo Choi
@ 2021-03-18 10:51                           ` Dong Aisheng
  0 siblings, 0 replies; 58+ messages in thread
From: Dong Aisheng @ 2021-03-18 10:51 UTC (permalink / raw)
  To: Chanwoo Choi
  Cc: Chanwoo Choi, Dong Aisheng, Linux PM,
	moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE,
	Sascha Hauer, Shawn Guo, dl-linux-imx, open list, myungjoo.ham,
	kyungmin.park, Abel Vesa

On Thu, Mar 18, 2021 at 5:42 PM Chanwoo Choi <cw00.choi@samsung.com> wrote:
>
> On 3/18/21 6:54 PM, Chanwoo Choi wrote:
> > On 3/18/21 5:03 PM, Dong Aisheng wrote:
> >> Hi Chanwoo,
> >>
> >> On Sat, Mar 13, 2021 at 2:45 PM Dong Aisheng <dongas86@gmail.com> wrote:
> >>>
> >>> On Sat, Mar 13, 2021 at 12:09 AM Chanwoo Choi <cwchoi00@gmail.com> wrote:
> >>>>
> >>>> On 21. 3. 12. 오후 7:57, Dong Aisheng wrote:
> >>>>> On Thu, Mar 11, 2021 at 2:54 PM Chanwoo Choi <cw00.choi@samsung.com> wrote:
> >>>>>>
> >>>>>> On 3/10/21 1:56 PM, Dong Aisheng wrote:
> >>>>>>> On Wed, Mar 10, 2021 at 11:08 AM Chanwoo Choi <cw00.choi@samsung.com> wrote:
> >>>>>>>>
> >>>>>>>> On 3/10/21 11:56 AM, Dong Aisheng wrote:
> >>>>>>>>> On Wed, Mar 10, 2021 at 12:12 AM Chanwoo Choi <cwchoi00@gmail.com> wrote:
> >>>>>>>>>>
> >>>>>>>>>> On 21. 3. 10. 오전 12:58, Chanwoo Choi wrote:
> >>>>>>>>>>> On 21. 3. 9. 오후 9:58, Dong Aisheng wrote:
> >>>>>>>>>>>> The devfreq monitor depends on the device to provide load information
> >>>>>>>>>>>> by .get_dev_status() to calculate the next target freq.
> >>>>>>>>>>>>
> >>>>>>>>>>>> And this will cause changing governor to simple ondemand fail
> >>>>>>>>>>>> if device can't support.
> >>>>>>>>>>>>
> >>>>>>>>>>>> Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
> >>>>>>>>>>>> ---
> >>>>>>>>>>>>    drivers/devfreq/devfreq.c                 | 10 +++++++---
> >>>>>>>>>>>>    drivers/devfreq/governor.h                |  2 +-
> >>>>>>>>>>>>    drivers/devfreq/governor_simpleondemand.c |  3 +--
> >>>>>>>>>>>>    3 files changed, 9 insertions(+), 6 deletions(-)
> >>>>>>>>>>>>
> >>>>>>>>>>>> diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
> >>>>>>>>>>>> index 7231fe6862a2..d1787b6c7d7c 100644
> >>>>>>>>>>>> --- a/drivers/devfreq/devfreq.c
> >>>>>>>>>>>> +++ b/drivers/devfreq/devfreq.c
> >>>>>>>>>>>> @@ -482,10 +482,13 @@ static void devfreq_monitor(struct work_struct
> >>>>>>>>>>>> *work)
> >>>>>>>>>>>>     * to be called from governor in response to DEVFREQ_GOV_START
> >>>>>>>>>>>>     * event when device is added to devfreq framework.
> >>>>>>>>>>>>     */
> >>>>>>>>>>>> -void devfreq_monitor_start(struct devfreq *devfreq)
> >>>>>>>>>>>> +int devfreq_monitor_start(struct devfreq *devfreq)
> >>>>>>>>>>>>    {
> >>>>>>>>>>>>        if (IS_SUPPORTED_FLAG(devfreq->governor->flags, IRQ_DRIVEN))
> >>>>>>>>>>>> -        return;
> >>>>>>>>>>>> +        return 0;
> >>>>>>>>>>>> +
> >>>>>>>>>>>> +    if (!devfreq->profile->get_dev_status)
> >>>>>>>>>>>> +        return -EINVAL;
> >>>>>>>>>>
> >>>>>>>>>> Again, I think that get_dev_status is not used for all governors.
> >>>>>>>>>> So that it cause the governor start fail. Don't check whether
> >>>>>>>>>> .get_dev_status is NULL or not.
> >>>>>>>>>>
> >>>>>>>>>
> >>>>>>>>> I'm not quite understand your point.
> >>>>>>>>> it is used by governor_simpleondemand.c and tegra_devfreq_governor.
> >>>>>>>>> get_target_freq -> devfreq_update_stats -> get_dev_status
> >>>>>>>>
> >>>>>>>> The devfreq can add the new governor by anyone.
> >>>>>>>> So these functions like devfreq_monitor_* have to support
> >>>>>>>> the governors and also must support the governor to be added
> >>>>>>>> in the future.
> >>>>>>>
> >>>>>>> Yes, but devfreq_monitor_* is only used by polling mode, right?
> >>>>>>> The governor using it has to implement get_dev_status unless
> >>>>>>> there's an exception in the future.
> >>>>>>>
> >>>>>>> Currently this patch wants to address the issue that user can switch
> >>>>>>> to ondemand governor (polling mode) by sysfs even devices does
> >>>>>>> not support it (no get_dev_status implemented).
> >>>>>>
> >>>>>> As I commented, I'll fix this issue. If devfreq driver doesn't implement
> >>>>>> the .get_dev_status, don't show it via available_governors. I think that
> >>>>>> it is fundamental solution to fix this issue.
> >>>>>
> >>>>> Sounds good
> >>>>>
> >>>>>> So on this version,
> >>>>>> don't add the this conditional statement on this function
> >>>>>>
> >>>>>
> >>>>> Almost all this patch did is adding a checking for get_dev_status.
> >>>>> So do you mean drop this patch?
> >>>>> I wonder it's still a necessary checking to explicitly tell devfreq monitor
> >>>>> users that get_dev_status is needed during governor startup.
> >>>>
> >>>> I think that the it is enough to check .get_dev_status in
> >>>> devfreq_update_stats. We have to check it on where it is used.
> >>>>
> >>>
> >>> I think the drawback of only checking .get_dev_status in
> >>> devfreq_update_stats is:
> >>> 1. devfreq will still register successfully and ondemand governor starts ok
> >>> 2. ondemand governor will still be shown in sysfs which is something
> >>> you want to fix
> >>> 3. devfreq will end up printing endless error messages in devfreq_monitor worker
> >>>     "dvfs failed with (%d) error" as the possible missing .get_dev_status
> >
> > I think that devfreq_monitor_start have to handle only work instance.
> > This approach is too considering the deep check list.
> > I want to resolve this periodical error log with different solution.
> >
> > Actually, we have to reject the registration of devfreq device
> > when calling devfreq_add_device instead of checking .get_dev_status
> > in devfreq_monitor_start().
>
>
> I'll reject the registration of devfreq device if the mandatory
> function pointer of struct devfreq_dev_profile are not initialized.
> - .get_dev_status
>    If some governors like simple_ondemand, have to initialize it.
>    So, I need to add the new flag to specify this feature.
> - .target is mandatory for all devfreq devices. I'll check it.

Okay, thanks
Then i will drop this patch and resend series with your other comments
addressed.

Regards
Aisheng

>
> >
> >
> >>>
> >>> So i wonder if you don't like changing the common devfreq_monitor_start in order
> >>> to make it look common for all governors, then we probably still need
> >>> to fix it in
> >>> ondemand governor in order to avoid the possible above issues.
> >>>
> >>> static int devfreq_simple_ondemand_handler(struct devfreq *devfreq,
> >>>                                 unsigned int event, void *data)
> >>> {
> >>>         switch (event) {
> >>>         case DEVFREQ_GOV_START:
> >>>                 if (!devfreq->profile->get_dev_status)
> >>>                         return -EINVAL;
> >>>
> >>>                 return devfreq_monitor_start(devfreq);
> >>> ...
> >>> }
> >>>
> >>> How do you think?
> >>
> >> Any feedback?
> >>
> >> I'm waiting for your confirmation whether dropping this one,
> >> then I can re-sent the series.
> >>
> >> Regards
> >> Aisheng
> >>
> >>>
> >>> Regards
> >>> Aisheng
> >>>
> >>>
> >>>>>
> >>>>>> And on next version, please use the capital letter for first character
> >>>>>> on patch title as following:
> >>>>>>
> >>>>>> - PM / devfreq: Check get_dev_status before start monitor
> >>>>>>
> >>>>>
> >>>>> Okay to me.
> >>>>> Thanks for the suggestion.
> >>>>>
> >>>>> Regards
> >>>>> Aisheng
> >>>>>
> >>>>>>>
> >>>>>>> Regards
> >>>>>>> Aisheng
> >>>>>>>
> >>>>>>>>
> >>>>>>>>>
> >>>>>>>>> Without checking, device can switch to ondemand governor if it does not support.
> >>>>>>>>>
> >>>>>>>>> Am i missed something?
> >>>>>>>>>
> >>>>>>>>> Regards
> >>>>>>>>> Aisheng
> >>>>>>>>>
> >>>>>>>>>>>>        switch (devfreq->profile->timer) {
> >>>>>>>>>>>>        case DEVFREQ_TIMER_DEFERRABLE:
> >>>>>>>>>>>> @@ -495,12 +498,13 @@ void devfreq_monitor_start(struct devfreq *devfreq)
> >>>>>>>>>>>>            INIT_DELAYED_WORK(&devfreq->work, devfreq_monitor);
> >>>>>>>>>>>>            break;
> >>>>>>>>>>>>        default:
> >>>>>>>>>>>> -        return;
> >>>>>>>>>>>> +        return -EINVAL;
> >>>>>>>>>>>>        }
> >>>>>>>>>>>>        if (devfreq->profile->polling_ms)
> >>>>>>>>>>>>            queue_delayed_work(devfreq_wq, &devfreq->work,
> >>>>>>>>>>>>                msecs_to_jiffies(devfreq->profile->polling_ms));
> >>>>>>>>>>>> +    return 0;
> >>>>>>>>>>>>    }
> >>>>>>>>>>>>    EXPORT_SYMBOL(devfreq_monitor_start);
> >>>>>>>>>>>> diff --git a/drivers/devfreq/governor.h b/drivers/devfreq/governor.h
> >>>>>>>>>>>> index 5cee3f64fe2b..31af6d072a10 100644
> >>>>>>>>>>>> --- a/drivers/devfreq/governor.h
> >>>>>>>>>>>> +++ b/drivers/devfreq/governor.h
> >>>>>>>>>>>> @@ -75,7 +75,7 @@ struct devfreq_governor {
> >>>>>>>>>>>>                    unsigned int event, void *data);
> >>>>>>>>>>>>    };
> >>>>>>>>>>>> -void devfreq_monitor_start(struct devfreq *devfreq);
> >>>>>>>>>>>> +int devfreq_monitor_start(struct devfreq *devfreq);
> >>>>>>>>>>>>    void devfreq_monitor_stop(struct devfreq *devfreq);
> >>>>>>>>>>>>    void devfreq_monitor_suspend(struct devfreq *devfreq);
> >>>>>>>>>>>>    void devfreq_monitor_resume(struct devfreq *devfreq);
> >>>>>>>>>>>> diff --git a/drivers/devfreq/governor_simpleondemand.c
> >>>>>>>>>>>> b/drivers/devfreq/governor_simpleondemand.c
> >>>>>>>>>>>> index d57b82a2b570..ea287b57cbf3 100644
> >>>>>>>>>>>> --- a/drivers/devfreq/governor_simpleondemand.c
> >>>>>>>>>>>> +++ b/drivers/devfreq/governor_simpleondemand.c
> >>>>>>>>>>>> @@ -89,8 +89,7 @@ static int devfreq_simple_ondemand_handler(struct
> >>>>>>>>>>>> devfreq *devfreq,
> >>>>>>>>>>>>    {
> >>>>>>>>>>>>        switch (event) {
> >>>>>>>>>>>>        case DEVFREQ_GOV_START:
> >>>>>>>>>>>> -        devfreq_monitor_start(devfreq);
> >>>>>>>>>>>> -        break;
> >>>>>>>>>>>> +        return devfreq_monitor_start(devfreq);
> >>>>>>>>>>>>        case DEVFREQ_GOV_STOP:
> >>>>>>>>>>>>            devfreq_monitor_stop(devfreq);
> >>>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>>> Need to handle the all points of devfreq_monitor_start() usage.
> >>>>>>>>>>> please check the tegra30-devfreq.c for this update.
> >>>>>>>>>>>
> >>>>>>>>>>> $ grep -rn "devfreq_monitor_start" drivers/
> >>>>>>>>>>> drivers/devfreq/governor_simpleondemand.c:92:
> >>>>>>>>>>> devfreq_monitor_start(devfreq);
> >>>>>>>>>>> drivers/devfreq/tegra30-devfreq.c:744:
> >>>>>>>>>>> devfreq_monitor_start(devfreq);
> >>>>>>>>>>> ......
> >>>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>> --
> >>>>>>>>>> Best Regards,
> >>>>>>>>>> Samsung Electronics
> >>>>>>>>>> Chanwoo Choi
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>> --
> >>>>>>>> Best Regards,
> >>>>>>>> Chanwoo Choi
> >>>>>>>> Samsung Electronics
> >>>>>>>
> >>>>>>>
> >>>>>>
> >>>>>>
> >>>>>> --
> >>>>>> Best Regards,
> >>>>>> Chanwoo Choi
> >>>>>> Samsung Electronics
> >>>>
> >>>>
> >>>> --
> >>>> Best Regards,
> >>>> Samsung Electronics
> >>>> Chanwoo Choi
> >>
> >>
> >
> >
>
>
> --
> Best Regards,
> Chanwoo Choi
> Samsung Electronics

^ permalink raw reply	[flat|nested] 58+ messages in thread

end of thread, other threads:[~2021-03-18 10:52 UTC | newest]

Thread overview: 58+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-09 12:58 [PATCH 00/11] PM / devfreq: a few small fixes and improvements Dong Aisheng
2021-03-09 12:58 ` [PATCH 01/11] doc: ABI: devfreq: remove invalid central_polling description Dong Aisheng
2021-03-09 15:01   ` Chanwoo Choi
2021-03-09 12:58 ` [PATCH 02/11] PM / devfreq: remove the invalid description for get_target_freq Dong Aisheng
2021-03-09 15:02   ` Chanwoo Choi
2021-03-09 15:14     ` Dong Aisheng
2021-03-09 12:58 ` [PATCH 03/11] PM / devfreq: fix the wrong set_freq path for userspace governor Dong Aisheng
2021-03-09 15:13   ` Chanwoo Choi
2021-03-09 15:16     ` Dong Aisheng
2021-03-09 12:58 ` [PATCH 04/11] PM / devfreq: bail out early if no freq changes in devfreq_set_target Dong Aisheng
2021-03-09 15:47   ` Chanwoo Choi
2021-03-10  2:42     ` Dong Aisheng
2021-03-09 12:58 ` [PATCH 05/11] PM / devfreq: use more accurate returned new_freq as resume_freq Dong Aisheng
2021-03-09 15:53   ` Chanwoo Choi
2021-03-10  2:43     ` Dong Aisheng
2021-03-10  3:07       ` Chanwoo Choi
2021-03-10  3:04         ` Dong Aisheng
2021-03-09 12:58 ` [PATCH 06/11] PM / devfreq: drop the unnecessary low variable initialization Dong Aisheng
2021-03-09 12:58 ` [PATCH 07/11] PM / devfreq: check get_dev_status before start monitor Dong Aisheng
2021-03-09 15:58   ` Chanwoo Choi
2021-03-09 16:12     ` Chanwoo Choi
2021-03-10  2:56       ` Dong Aisheng
2021-03-10  3:25         ` Chanwoo Choi
2021-03-10  4:56           ` Dong Aisheng
2021-03-11  7:10             ` Chanwoo Choi
2021-03-12 10:57               ` Dong Aisheng
2021-03-12 16:09                 ` Chanwoo Choi
2021-03-13  6:45                   ` Dong Aisheng
2021-03-18  8:03                     ` Dong Aisheng
2021-03-18  9:54                       ` Chanwoo Choi
2021-03-18  9:59                         ` Chanwoo Choi
2021-03-18 10:51                           ` Dong Aisheng
2021-03-10  2:51     ` Dong Aisheng
2021-03-09 12:58 ` [PATCH 08/11] PM / devfreq: check get_dev_status in devfreq_update_stats Dong Aisheng
2021-03-09 16:02   ` Chanwoo Choi
2021-03-09 16:20   ` Chanwoo Choi
2021-03-10  3:00     ` Dong Aisheng
2021-03-11  7:01       ` Chanwoo Choi
2021-03-09 12:58 ` [PATCH 09/11] PM / devfreq: governor: optimize simpleondemand get_target_freq Dong Aisheng
2021-03-09 16:09   ` Chanwoo Choi
2021-03-10  3:02     ` Dong Aisheng
2021-03-09 12:58 ` [PATCH 10/11] PM / devfreq: imx8m-ddrc: remove imx8m_ddrc_get_dev_status Dong Aisheng
2021-03-09 16:22   ` Chanwoo Choi
2021-03-09 12:58 ` [PATCH 11/11] PM / devfreq: imx8m-ddrc: drop polling_ms Dong Aisheng
2021-03-09 16:23   ` Chanwoo Choi
2021-03-10  3:03     ` Dong Aisheng
2021-03-09 12:58 ` [PATCH 00/11] PM / devfreq: a few small fixes and improvements Dong Aisheng
2021-03-09 12:58 ` [PATCH 01/11] doc: ABI: devfreq: remove invalid central_polling description Dong Aisheng
2021-03-09 12:58 ` [PATCH 02/11] PM / devfreq: remove the invalid description for get_target_freq Dong Aisheng
2021-03-09 12:58 ` [PATCH 03/11] PM / devfreq: fix the wrong set_freq path for userspace governor Dong Aisheng
2021-03-09 12:58 ` [PATCH 04/11] PM / devfreq: bail out early if no freq changes in devfreq_set_target Dong Aisheng
2021-03-09 12:58 ` [PATCH 05/11] PM / devfreq: use more accurate returned new_freq as resume_freq Dong Aisheng
2021-03-09 12:58 ` [PATCH 06/11] PM / devfreq: drop the unnecessary low variable initialization Dong Aisheng
2021-03-09 12:58 ` [PATCH 07/11] PM / devfreq: check get_dev_status before start monitor Dong Aisheng
2021-03-09 12:58 ` [PATCH 08/11] PM / devfreq: check get_dev_status in devfreq_update_stats Dong Aisheng
2021-03-09 12:58 ` [PATCH 09/11] PM / devfreq: governor: optimize simpleondemand get_target_freq Dong Aisheng
2021-03-09 12:58 ` [PATCH 10/11] PM / devfreq: imx8m-ddrc: remove imx8m_ddrc_get_dev_status Dong Aisheng
2021-03-09 12:58 ` [PATCH 11/11] PM / devfreq: imx8m-ddrc: drop polling_ms Dong Aisheng

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).