Skip to contentSkip to conversation

PM / devfreq: Set the min_freq and max_freq of devfreq device

PATCH MyungJoo Ham 2 participants 2 messages Nov 19, 2015

lore
Share & tools
lore
#0 lore raw
Quoted 14 lines

After probing the devfreq device driver, the value of both min_freq and max_freq are zero(0). So, this patch initializes the 'min_freq' and 'max_freq' field of devfreq device by using the freq_table array.

---
 drivers/devfreq/devfreq.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/devfreq/devfreq.c +0 -0
index c292ceb7ff19..0b24ae7b7a48 100644

drivers/devfreq/devfreq.c static void devfreq_set_freq_table(struct devfreq *devfreq) · line 129

Quoted 9 lines
drivers/devfreq/devfreq.c +5 -0
@@ -121,6 +121,11 @@ static void devfreq_set_freq_table(struct devfreq *devfreq)
 		profile->freq_table[i] = freq;
 	}
 	rcu_read_unlock();
+
+	mutex_lock(&devfreq->lock);
+	devfreq->min_freq = profile->freq_table[0];
+	devfreq->max_freq = profile->freq_table[profile->max_state - 1];
+	mutex_unlock(&devfreq->lock);
 }

No, you should not do this.

It is allowed to use devfreq without both OPP and freq_table assuming that the devfreq device may operate with very many frequencies so that practically, we can virtually give it any frequency numbers in a given range.
(cases where profile->max_state is 0 and it is not an error)

The value 0 is used for min/max_freq to declare that min/max_freq is deactivated. Therefore, it is not required to do so; they are not intended to show the hardware configuration as well.

Cheers,
MyungJoo

#1 lore raw
Quoted 32 lines · MyungJoo Ham
Quoted 14 lines

After probing the devfreq device driver, the value of both min_freq and max_freq are zero(0). So, this patch initializes the 'min_freq' and 'max_freq' field of devfreq device by using the freq_table array.

---
 drivers/devfreq/devfreq.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/devfreq/devfreq.c +0 -0
index c292ceb7ff19..0b24ae7b7a48 100644

drivers/devfreq/devfreq.c static void devfreq_set_freq_table(struct devfreq *devfreq) · line 129

Quoted 9 lines
drivers/devfreq/devfreq.c +5 -0
@@ -121,6 +121,11 @@ static void devfreq_set_freq_table(struct devfreq *devfreq)
 		profile->freq_table[i] = freq;
 	}
 	rcu_read_unlock();
+
+	mutex_lock(&devfreq->lock);
+	devfreq->min_freq = profile->freq_table[0];
+	devfreq->max_freq = profile->freq_table[profile->max_state - 1];
+	mutex_unlock(&devfreq->lock);
 }

No, you should not do this.

It is allowed to use devfreq without both OPP and freq_table assuming that the devfreq device may operate with very many frequencies so that practically, we can virtually give it any frequency numbers in a given range.
(cases where profile->max_state is 0 and it is not an error)

Quoted 4 lines

The value 0 is used for min/max_freq to declare that min/max_freq is deactivated. Therefore, it is not required to do so; they are not intended to show the hardware configuration as well.

This case consider the devfreq device using OPP because devfreq_set_freq_table() get the number of OPP entry in OPP list before setting the min_freq/max_freq. If the devfreq device don't use the OPP entry, devfreq_set_freq_table() will return without any operation.

IMHO, when devfreq device uses the OPP table including the frequency, min_freq/max_freq should show the correct value as CPUFREQ framework.

Regards,
Chanwoo CHoi