Skip to content

Commit f9b9e80

Browse files
watologo1rjwysocki
authored andcommitted
PM QoS: Make pm_qos settings readable
I have a machine where entering deep C-states broke. pm_qos was a hot candidate, but I couldn't find any way to double check without the need of recompiling. While in this case it was a driver bug (ath9k): https://bugzilla.kernel.org/show_bug.cgi?id=27532 powertop or others may want to read out cpu_dma_latency restrictions which could be the cause of preventing a machine entering deeper C-states. Output with this patch: # default value of 2000 * USEC_PER_SEC (0x77359400) cat /dev/network_latency |hexdump 0000000 9400 7735 0000004 # value of 55 us which is the reason for not entering C2 cat /dev/cpu_dma_latency |hexdump 0000000 0037 0000 0000004 There is no reason to hide this info -> make pm_qos files readable. Signed-off-by: Thomas Renninger <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent 7ae4961 commit f9b9e80

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

kernel/pm_qos_params.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,14 @@ static struct pm_qos_object *pm_qos_array[] = {
103103

104104
static ssize_t pm_qos_power_write(struct file *filp, const char __user *buf,
105105
size_t count, loff_t *f_pos);
106+
static ssize_t pm_qos_power_read(struct file *filp, char __user *buf,
107+
size_t count, loff_t *f_pos);
106108
static int pm_qos_power_open(struct inode *inode, struct file *filp);
107109
static int pm_qos_power_release(struct inode *inode, struct file *filp);
108110

109111
static const struct file_operations pm_qos_power_fops = {
110112
.write = pm_qos_power_write,
113+
.read = pm_qos_power_read,
111114
.open = pm_qos_power_open,
112115
.release = pm_qos_power_release,
113116
.llseek = noop_llseek,
@@ -376,6 +379,27 @@ static int pm_qos_power_release(struct inode *inode, struct file *filp)
376379
}
377380

378381

382+
static ssize_t pm_qos_power_read(struct file *filp, char __user *buf,
383+
size_t count, loff_t *f_pos)
384+
{
385+
s32 value;
386+
unsigned long flags;
387+
struct pm_qos_object *o;
388+
struct pm_qos_request_list *pm_qos_req = filp->private_data;;
389+
390+
if (!pm_qos_req)
391+
return -EINVAL;
392+
if (!pm_qos_request_active(pm_qos_req))
393+
return -EINVAL;
394+
395+
o = pm_qos_array[pm_qos_req->pm_qos_class];
396+
spin_lock_irqsave(&pm_qos_lock, flags);
397+
value = pm_qos_get_value(o);
398+
spin_unlock_irqrestore(&pm_qos_lock, flags);
399+
400+
return simple_read_from_buffer(buf, count, f_pos, &value, sizeof(s32));
401+
}
402+
379403
static ssize_t pm_qos_power_write(struct file *filp, const char __user *buf,
380404
size_t count, loff_t *f_pos)
381405
{

0 commit comments

Comments
 (0)