Skip to content

Commit e9b6fea

Browse files
andip71DhineshCool
authored andcommitted
devfreq: Expose GPU used frequency statistics in a new sysfs (condensed version)
basically it contains the information of trans_stat file, just reduced to frequencies ans time used in ms (cherry picked from commit 8f2c76861fe0e877a56ee763f315e03734a1787f) Signed-off-by: ZyCromerZ <neetroid97@gmail.com> Signed-off-by: Kunmun <kunmun.devroms@gmail.com>
1 parent ad55b42 commit e9b6fea

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

drivers/devfreq/devfreq.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1279,6 +1279,33 @@ static ssize_t trans_stat_show(struct device *dev,
12791279
}
12801280
static DEVICE_ATTR_RO(trans_stat);
12811281

1282+
static ssize_t time_in_state_show(struct device *dev, struct device_attribute *attr,
1283+
char *buf)
1284+
{
1285+
struct devfreq *devfreq = to_devfreq(dev);
1286+
ssize_t len;
1287+
int i, err;
1288+
unsigned int max_state = devfreq->profile->max_state;
1289+
1290+
err = devfreq_update_status(devfreq, devfreq->previous_freq);
1291+
if (err)
1292+
return 0;
1293+
1294+
len = 0;
1295+
1296+
for (i = 0; i < max_state; i++) {
1297+
len += sprintf(buf + len, "%u ",
1298+
devfreq->profile->freq_table[i]);
1299+
len += sprintf(buf + len, "%u ",
1300+
jiffies_to_msecs(devfreq->time_in_state[i]));
1301+
}
1302+
1303+
len += sprintf(buf + len, "\n");
1304+
1305+
return len;
1306+
}
1307+
static DEVICE_ATTR_RO(time_in_state);
1308+
12821309
static struct attribute *devfreq_attrs[] = {
12831310
&dev_attr_name.attr,
12841311
&dev_attr_governor.attr,
@@ -1290,6 +1317,7 @@ static struct attribute *devfreq_attrs[] = {
12901317
&dev_attr_min_freq.attr,
12911318
&dev_attr_max_freq.attr,
12921319
&dev_attr_trans_stat.attr,
1320+
&dev_attr_time_in_state.attr,
12931321
NULL,
12941322
};
12951323
ATTRIBUTE_GROUPS(devfreq);

0 commit comments

Comments
 (0)