Skip to contentSkip to conversation

PM / devfreq: Use freq_table for available_frequencies

PATCH New 함명주 2 participants 4 messages Apr 15, 2014 – Apr 17, 2014

Subsystems (2)
lore
Share & tools
lore

함명주

author maintainer
#0 lore raw
Quoted 23 lines · 함명주
Quoted 10 lines
Quoted 5 lines

MyungJoo/Kyungmin,

Bump. Can we accept this patch please?

-Saravana

Nack.

Please note that freq_table is also an optional value, which may be null.

Ah, I saw that the max_freq would be zero if freq_table was NULL and I assumed that it can't be NULL. But I see that the max_freq limit is not applied if it's zero. Thanks for catching it.

Quoted 1 line

Besides, please be aware that your code is under rcu_read_lock().

Valid point. I was just trying to keep the diff simple. No one's really going to be catting this file often when performance matters.

Quoted 2 lines
Quoted 7 lines
Quoted 5 lines

Cheers,
MyungJoo.

ps. I'll send a related patch (avoid accessing null but not-an-error pointer at other sysfs nodes). Thank you for letting me catch such bugs anyway.

I can go ahead and do this myself if you don't mind.

No, we don't need it. It was a false alarm.
Reading again, I've found that we've already made other sysfs nodes check if either freq_table is null or its size is 0.

So, we only need to look at this available_frequencies node now.

I'll add some notes on the ABI doc for available_frequencies soon.

Cheers,
MyungJoo.

Quoted 13 lines

-Saravana

Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation
#1 lore raw
Quoted 31 lines · ???
Quoted 23 lines · ???
Quoted 10 lines
Quoted 5 lines

MyungJoo/Kyungmin,

Bump. Can we accept this patch please?

-Saravana

Nack.

Please note that freq_table is also an optional value, which may be null.

Ah, I saw that the max_freq would be zero if freq_table was NULL and I assumed that it can't be NULL. But I see that the max_freq limit is not applied if it's zero. Thanks for catching it.

Quoted 1 line

Besides, please be aware that your code is under rcu_read_lock().

Valid point. I was just trying to keep the diff simple. No one's really going to be catting this file often when performance matters.

Quoted 2 lines
Quoted 7 lines
Quoted 5 lines

Cheers,
MyungJoo.

ps. I'll send a related patch (avoid accessing null but not-an-error pointer at other sysfs nodes). Thank you for letting me catch such bugs anyway.

I can go ahead and do this myself if you don't mind.

Quoted 8 lines

No, we don't need it. It was a false alarm.
Reading again, I've found that we've already made other sysfs nodes check if either freq_table is null or its size is 0.

So, we only need to look at this available_frequencies node now.

I'll add some notes on the ABI doc for available_frequencies soon.

Ah, I misunderstood your previous email. I thought you Nack-ed my patch and decided to send your own patch to replace mine. Ok, I'll fix up mine and send it out.

-Saravana

Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation
#2 lore raw
Quoted 3 lines · Saravana Kannan

Ah, I misunderstood your previous email. I thought you Nack-ed my patch and decided to send your own patch to replace mine. Ok, I'll fix up mine and send it out.

MyungJoo/Kyungmin,

I sent out an updated patch. Can you please take a look?

Thanks,
Saravana

Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation
#3 lore raw

PATCH v2 1/1 PM / devfreq: Use freq_table for available_frequencies

In reply to 함명주

Some devices use freq_table instead of OPP. For those devices, the available_frequencies file shows up empty. Fix that by using freq_table to generate the available_frequencies data when it's available.

OPP find frequency APIs also skips frequencies that have been temporarily disabled (say, due to thermal, etc). Since available_frequencies is supposed to show the entire list of available frequencies without taking temporary limits into consideration, preference is given to freq_table when available.

---
 drivers/devfreq/devfreq.c | 29 ++++++++++++++++++-----------
 1 file changed, 18 insertions(+), 11 deletions(-)
drivers/devfreq/devfreq.c +18 -11
index 2042ec3..527cbe2 100644
@@ -912,20 +912,27 @@ static ssize_t available_frequencies_show(struct device *d,
 	struct devfreq *df = to_devfreq(d);
 	struct device *dev = df->dev.parent;
 	struct dev_pm_opp *opp;
+	unsigned int i = 0;
 	ssize_t count = 0;
 	unsigned long freq = 0;
 
-	rcu_read_lock();
-	do {
-		opp = dev_pm_opp_find_freq_ceil(dev, &freq);
-		if (IS_ERR(opp))
-			break;
-
-		count += scnprintf(&buf[count], (PAGE_SIZE - count - 2),
-				   "%lu ", freq);
-		freq++;
-	} while (1);
-	rcu_read_unlock();
+	if (df->profile->freq_table) {
+		for (i = 0; i < df->profile->max_state; i++)
+			count += scnprintf(&buf[count], (PAGE_SIZE - count - 2),
+					   "%u ", df->profile->freq_table[i]);
+	} else {
+		rcu_read_lock();
+		do {
+			opp = dev_pm_opp_find_freq_ceil(dev, &freq);
+			if (IS_ERR(opp))
+				break;
+
+			count += scnprintf(&buf[count], (PAGE_SIZE - count - 2),
+					   "%lu ", freq);
+			freq++;
+		} while (1);
+		rcu_read_unlock();
+	}
 
 	/* Truncate the trailing space */
 	if (count)
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation