Skip to content

Commit 7c404c6

Browse files
committed
Merge tag 'pm-reverts-4.14' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm
Pull power management commit reverts from Rafael Wysocki: "Since Geert reports additional problems with my PM QoS fix from the last week that have not been addressed by the most recent fixup on top of it, they both should better be reverted now and let's fix the original issue properly in 4.15. This reverts two recent PM QoS commits one of which introduced multiple problems and the other one fixed some, but not all of them (Rafael Wysocki)" * tag 'pm-reverts-4.14' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: Revert "PM / QoS: Fix device resume latency PM QoS" Revert "PM / QoS: Fix default runtime_pm device resume latency"
2 parents 287683d + d5919dc commit 7c404c6

8 files changed

Lines changed: 36 additions & 65 deletions

File tree

Documentation/ABI/testing/sysfs-devices-power

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,9 +211,7 @@ Description:
211211
device, after it has been suspended at run time, from a resume
212212
request to the moment the device will be ready to process I/O,
213213
in microseconds. If it is equal to 0, however, this means that
214-
the PM QoS resume latency may be arbitrary and the special value
215-
"n/a" means that user space cannot accept any resume latency at
216-
all for the given device.
214+
the PM QoS resume latency may be arbitrary.
217215

218216
Not all drivers support this attribute. If it isn't supported,
219217
it is not present.

drivers/base/cpu.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -377,8 +377,7 @@ int register_cpu(struct cpu *cpu, int num)
377377

378378
per_cpu(cpu_sys_devices, num) = &cpu->dev;
379379
register_cpu_under_node(num, cpu_to_node(num));
380-
dev_pm_qos_expose_latency_limit(&cpu->dev,
381-
PM_QOS_RESUME_LATENCY_NO_CONSTRAINT);
380+
dev_pm_qos_expose_latency_limit(&cpu->dev, 0);
382381

383382
return 0;
384383
}

drivers/base/power/domain_governor.c

Lines changed: 23 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,23 @@
1414
static int dev_update_qos_constraint(struct device *dev, void *data)
1515
{
1616
s64 *constraint_ns_p = data;
17-
s64 constraint_ns = -1;
17+
s32 constraint_ns = -1;
1818

1919
if (dev->power.subsys_data && dev->power.subsys_data->domain_data)
2020
constraint_ns = dev_gpd_data(dev)->td.effective_constraint_ns;
2121

22-
if (constraint_ns < 0)
22+
if (constraint_ns < 0) {
2323
constraint_ns = dev_pm_qos_read_value(dev);
24-
25-
if (constraint_ns == PM_QOS_RESUME_LATENCY_NO_CONSTRAINT)
24+
constraint_ns *= NSEC_PER_USEC;
25+
}
26+
if (constraint_ns == 0)
2627
return 0;
2728

28-
constraint_ns *= NSEC_PER_USEC;
29-
30-
if (constraint_ns < *constraint_ns_p || *constraint_ns_p < 0)
29+
/*
30+
* constraint_ns cannot be negative here, because the device has been
31+
* suspended.
32+
*/
33+
if (constraint_ns < *constraint_ns_p || *constraint_ns_p == 0)
3134
*constraint_ns_p = constraint_ns;
3235

3336
return 0;
@@ -60,14 +63,10 @@ static bool default_suspend_ok(struct device *dev)
6063

6164
spin_unlock_irqrestore(&dev->power.lock, flags);
6265

63-
if (constraint_ns == 0)
66+
if (constraint_ns < 0)
6467
return false;
6568

66-
if (constraint_ns == PM_QOS_RESUME_LATENCY_NO_CONSTRAINT)
67-
constraint_ns = -1;
68-
else
69-
constraint_ns *= NSEC_PER_USEC;
70-
69+
constraint_ns *= NSEC_PER_USEC;
7170
/*
7271
* We can walk the children without any additional locking, because
7372
* they all have been suspended at this point and their
@@ -77,19 +76,14 @@ static bool default_suspend_ok(struct device *dev)
7776
device_for_each_child(dev, &constraint_ns,
7877
dev_update_qos_constraint);
7978

80-
if (constraint_ns < 0) {
81-
/* The children have no constraints. */
82-
td->effective_constraint_ns = PM_QOS_RESUME_LATENCY_NO_CONSTRAINT;
83-
td->cached_suspend_ok = true;
84-
} else {
85-
constraint_ns -= td->suspend_latency_ns + td->resume_latency_ns;
86-
if (constraint_ns > 0) {
87-
td->effective_constraint_ns = constraint_ns;
88-
td->cached_suspend_ok = true;
89-
} else {
90-
td->effective_constraint_ns = 0;
91-
}
79+
if (constraint_ns > 0) {
80+
constraint_ns -= td->suspend_latency_ns +
81+
td->resume_latency_ns;
82+
if (constraint_ns == 0)
83+
return false;
9284
}
85+
td->effective_constraint_ns = constraint_ns;
86+
td->cached_suspend_ok = constraint_ns >= 0;
9387

9488
/*
9589
* The children have been suspended already, so we don't need to take
@@ -151,14 +145,13 @@ static bool __default_power_down_ok(struct dev_pm_domain *pd,
151145
td = &to_gpd_data(pdd)->td;
152146
constraint_ns = td->effective_constraint_ns;
153147
/* default_suspend_ok() need not be called before us. */
154-
if (constraint_ns < 0)
148+
if (constraint_ns < 0) {
155149
constraint_ns = dev_pm_qos_read_value(pdd->dev);
156-
157-
if (constraint_ns == PM_QOS_RESUME_LATENCY_NO_CONSTRAINT)
150+
constraint_ns *= NSEC_PER_USEC;
151+
}
152+
if (constraint_ns == 0)
158153
continue;
159154

160-
constraint_ns *= NSEC_PER_USEC;
161-
162155
/*
163156
* constraint_ns cannot be negative here, because the device has
164157
* been suspended.

drivers/base/power/qos.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ static int dev_pm_qos_constraints_allocate(struct device *dev)
189189
plist_head_init(&c->list);
190190
c->target_value = PM_QOS_RESUME_LATENCY_DEFAULT_VALUE;
191191
c->default_value = PM_QOS_RESUME_LATENCY_DEFAULT_VALUE;
192-
c->no_constraint_value = PM_QOS_RESUME_LATENCY_NO_CONSTRAINT;
192+
c->no_constraint_value = PM_QOS_RESUME_LATENCY_DEFAULT_VALUE;
193193
c->type = PM_QOS_MIN;
194194
c->notifiers = n;
195195

drivers/base/power/runtime.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ static int rpm_check_suspend_allowed(struct device *dev)
253253
|| (dev->power.request_pending
254254
&& dev->power.request == RPM_REQ_RESUME))
255255
retval = -EAGAIN;
256-
else if (__dev_pm_qos_read_value(dev) == 0)
256+
else if (__dev_pm_qos_read_value(dev) < 0)
257257
retval = -EPERM;
258258
else if (dev->power.runtime_status == RPM_SUSPENDED)
259259
retval = 1;

drivers/base/power/sysfs.c

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -218,14 +218,7 @@ static ssize_t pm_qos_resume_latency_show(struct device *dev,
218218
struct device_attribute *attr,
219219
char *buf)
220220
{
221-
s32 value = dev_pm_qos_requested_resume_latency(dev);
222-
223-
if (value == 0)
224-
return sprintf(buf, "n/a\n");
225-
else if (value == PM_QOS_RESUME_LATENCY_NO_CONSTRAINT)
226-
value = 0;
227-
228-
return sprintf(buf, "%d\n", value);
221+
return sprintf(buf, "%d\n", dev_pm_qos_requested_resume_latency(dev));
229222
}
230223

231224
static ssize_t pm_qos_resume_latency_store(struct device *dev,
@@ -235,21 +228,11 @@ static ssize_t pm_qos_resume_latency_store(struct device *dev,
235228
s32 value;
236229
int ret;
237230

238-
if (!kstrtos32(buf, 0, &value)) {
239-
/*
240-
* Prevent users from writing negative or "no constraint" values
241-
* directly.
242-
*/
243-
if (value < 0 || value == PM_QOS_RESUME_LATENCY_NO_CONSTRAINT)
244-
return -EINVAL;
231+
if (kstrtos32(buf, 0, &value))
232+
return -EINVAL;
245233

246-
if (value == 0)
247-
value = PM_QOS_RESUME_LATENCY_NO_CONSTRAINT;
248-
} else if (!strcmp(buf, "n/a") || !strcmp(buf, "n/a\n")) {
249-
value = 0;
250-
} else {
234+
if (value < 0)
251235
return -EINVAL;
252-
}
253236

254237
ret = dev_pm_qos_update_request(dev->power.qos->resume_latency_req,
255238
value);

drivers/cpuidle/governors/menu.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,8 +298,8 @@ static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device *dev)
298298
data->needs_update = 0;
299299
}
300300

301-
if (resume_latency < latency_req &&
302-
resume_latency != PM_QOS_RESUME_LATENCY_NO_CONSTRAINT)
301+
/* resume_latency is 0 means no restriction */
302+
if (resume_latency && resume_latency < latency_req)
303303
latency_req = resume_latency;
304304

305305
/* Special case when user has set very strict latency requirement */

include/linux/pm_qos.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,16 @@ enum pm_qos_flags_status {
2727
PM_QOS_FLAGS_ALL,
2828
};
2929

30-
#define PM_QOS_DEFAULT_VALUE (-1)
31-
#define PM_QOS_LATENCY_ANY S32_MAX
30+
#define PM_QOS_DEFAULT_VALUE -1
3231

3332
#define PM_QOS_CPU_DMA_LAT_DEFAULT_VALUE (2000 * USEC_PER_SEC)
3433
#define PM_QOS_NETWORK_LAT_DEFAULT_VALUE (2000 * USEC_PER_SEC)
3534
#define PM_QOS_NETWORK_THROUGHPUT_DEFAULT_VALUE 0
3635
#define PM_QOS_MEMORY_BANDWIDTH_DEFAULT_VALUE 0
3736
#define PM_QOS_RESUME_LATENCY_DEFAULT_VALUE 0
38-
#define PM_QOS_RESUME_LATENCY_NO_CONSTRAINT PM_QOS_LATENCY_ANY
3937
#define PM_QOS_LATENCY_TOLERANCE_DEFAULT_VALUE 0
4038
#define PM_QOS_LATENCY_TOLERANCE_NO_CONSTRAINT (-1)
39+
#define PM_QOS_LATENCY_ANY ((s32)(~(__u32)0 >> 1))
4140

4241
#define PM_QOS_FLAG_NO_POWER_OFF (1 << 0)
4342
#define PM_QOS_FLAG_REMOTE_WAKEUP (1 << 1)
@@ -175,8 +174,7 @@ static inline s32 dev_pm_qos_requested_flags(struct device *dev)
175174
static inline s32 dev_pm_qos_raw_read_value(struct device *dev)
176175
{
177176
return IS_ERR_OR_NULL(dev->power.qos) ?
178-
PM_QOS_RESUME_LATENCY_NO_CONSTRAINT :
179-
pm_qos_read_value(&dev->power.qos->resume_latency);
177+
0 : pm_qos_read_value(&dev->power.qos->resume_latency);
180178
}
181179
#else
182180
static inline enum pm_qos_flags_status __dev_pm_qos_flags(struct device *dev,

0 commit comments

Comments
 (0)