Commit 7c404c62 authored by Linus Torvalds's avatar Linus Torvalds

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"
parents 287683d0 d5919dcc
...@@ -211,9 +211,7 @@ Description: ...@@ -211,9 +211,7 @@ Description:
device, after it has been suspended at run time, from a resume device, after it has been suspended at run time, from a resume
request to the moment the device will be ready to process I/O, request to the moment the device will be ready to process I/O,
in microseconds. If it is equal to 0, however, this means that in microseconds. If it is equal to 0, however, this means that
the PM QoS resume latency may be arbitrary and the special value the PM QoS resume latency may be arbitrary.
"n/a" means that user space cannot accept any resume latency at
all for the given device.
Not all drivers support this attribute. If it isn't supported, Not all drivers support this attribute. If it isn't supported,
it is not present. it is not present.
......
...@@ -377,8 +377,7 @@ int register_cpu(struct cpu *cpu, int num) ...@@ -377,8 +377,7 @@ int register_cpu(struct cpu *cpu, int num)
per_cpu(cpu_sys_devices, num) = &cpu->dev; per_cpu(cpu_sys_devices, num) = &cpu->dev;
register_cpu_under_node(num, cpu_to_node(num)); register_cpu_under_node(num, cpu_to_node(num));
dev_pm_qos_expose_latency_limit(&cpu->dev, dev_pm_qos_expose_latency_limit(&cpu->dev, 0);
PM_QOS_RESUME_LATENCY_NO_CONSTRAINT);
return 0; return 0;
} }
......
...@@ -14,20 +14,23 @@ ...@@ -14,20 +14,23 @@
static int dev_update_qos_constraint(struct device *dev, void *data) static int dev_update_qos_constraint(struct device *dev, void *data)
{ {
s64 *constraint_ns_p = data; s64 *constraint_ns_p = data;
s64 constraint_ns = -1; s32 constraint_ns = -1;
if (dev->power.subsys_data && dev->power.subsys_data->domain_data) if (dev->power.subsys_data && dev->power.subsys_data->domain_data)
constraint_ns = dev_gpd_data(dev)->td.effective_constraint_ns; constraint_ns = dev_gpd_data(dev)->td.effective_constraint_ns;
if (constraint_ns < 0) if (constraint_ns < 0) {
constraint_ns = dev_pm_qos_read_value(dev); constraint_ns = dev_pm_qos_read_value(dev);
if (constraint_ns == PM_QOS_RESUME_LATENCY_NO_CONSTRAINT)
return 0;
constraint_ns *= NSEC_PER_USEC; constraint_ns *= NSEC_PER_USEC;
}
if (constraint_ns == 0)
return 0;
if (constraint_ns < *constraint_ns_p || *constraint_ns_p < 0) /*
* constraint_ns cannot be negative here, because the device has been
* suspended.
*/
if (constraint_ns < *constraint_ns_p || *constraint_ns_p == 0)
*constraint_ns_p = constraint_ns; *constraint_ns_p = constraint_ns;
return 0; return 0;
...@@ -60,14 +63,10 @@ static bool default_suspend_ok(struct device *dev) ...@@ -60,14 +63,10 @@ static bool default_suspend_ok(struct device *dev)
spin_unlock_irqrestore(&dev->power.lock, flags); spin_unlock_irqrestore(&dev->power.lock, flags);
if (constraint_ns == 0) if (constraint_ns < 0)
return false; return false;
if (constraint_ns == PM_QOS_RESUME_LATENCY_NO_CONSTRAINT)
constraint_ns = -1;
else
constraint_ns *= NSEC_PER_USEC; constraint_ns *= NSEC_PER_USEC;
/* /*
* We can walk the children without any additional locking, because * We can walk the children without any additional locking, because
* they all have been suspended at this point and their * they all have been suspended at this point and their
...@@ -77,19 +76,14 @@ static bool default_suspend_ok(struct device *dev) ...@@ -77,19 +76,14 @@ static bool default_suspend_ok(struct device *dev)
device_for_each_child(dev, &constraint_ns, device_for_each_child(dev, &constraint_ns,
dev_update_qos_constraint); dev_update_qos_constraint);
if (constraint_ns < 0) {
/* The children have no constraints. */
td->effective_constraint_ns = PM_QOS_RESUME_LATENCY_NO_CONSTRAINT;
td->cached_suspend_ok = true;
} else {
constraint_ns -= td->suspend_latency_ns + td->resume_latency_ns;
if (constraint_ns > 0) { if (constraint_ns > 0) {
td->effective_constraint_ns = constraint_ns; constraint_ns -= td->suspend_latency_ns +
td->cached_suspend_ok = true; td->resume_latency_ns;
} else { if (constraint_ns == 0)
td->effective_constraint_ns = 0; return false;
}
} }
td->effective_constraint_ns = constraint_ns;
td->cached_suspend_ok = constraint_ns >= 0;
/* /*
* The children have been suspended already, so we don't need to take * The children have been suspended already, so we don't need to take
...@@ -151,13 +145,12 @@ static bool __default_power_down_ok(struct dev_pm_domain *pd, ...@@ -151,13 +145,12 @@ static bool __default_power_down_ok(struct dev_pm_domain *pd,
td = &to_gpd_data(pdd)->td; td = &to_gpd_data(pdd)->td;
constraint_ns = td->effective_constraint_ns; constraint_ns = td->effective_constraint_ns;
/* default_suspend_ok() need not be called before us. */ /* default_suspend_ok() need not be called before us. */
if (constraint_ns < 0) if (constraint_ns < 0) {
constraint_ns = dev_pm_qos_read_value(pdd->dev); constraint_ns = dev_pm_qos_read_value(pdd->dev);
if (constraint_ns == PM_QOS_RESUME_LATENCY_NO_CONSTRAINT)
continue;
constraint_ns *= NSEC_PER_USEC; constraint_ns *= NSEC_PER_USEC;
}
if (constraint_ns == 0)
continue;
/* /*
* constraint_ns cannot be negative here, because the device has * constraint_ns cannot be negative here, because the device has
......
...@@ -189,7 +189,7 @@ static int dev_pm_qos_constraints_allocate(struct device *dev) ...@@ -189,7 +189,7 @@ static int dev_pm_qos_constraints_allocate(struct device *dev)
plist_head_init(&c->list); plist_head_init(&c->list);
c->target_value = PM_QOS_RESUME_LATENCY_DEFAULT_VALUE; c->target_value = PM_QOS_RESUME_LATENCY_DEFAULT_VALUE;
c->default_value = PM_QOS_RESUME_LATENCY_DEFAULT_VALUE; c->default_value = PM_QOS_RESUME_LATENCY_DEFAULT_VALUE;
c->no_constraint_value = PM_QOS_RESUME_LATENCY_NO_CONSTRAINT; c->no_constraint_value = PM_QOS_RESUME_LATENCY_DEFAULT_VALUE;
c->type = PM_QOS_MIN; c->type = PM_QOS_MIN;
c->notifiers = n; c->notifiers = n;
......
...@@ -253,7 +253,7 @@ static int rpm_check_suspend_allowed(struct device *dev) ...@@ -253,7 +253,7 @@ static int rpm_check_suspend_allowed(struct device *dev)
|| (dev->power.request_pending || (dev->power.request_pending
&& dev->power.request == RPM_REQ_RESUME)) && dev->power.request == RPM_REQ_RESUME))
retval = -EAGAIN; retval = -EAGAIN;
else if (__dev_pm_qos_read_value(dev) == 0) else if (__dev_pm_qos_read_value(dev) < 0)
retval = -EPERM; retval = -EPERM;
else if (dev->power.runtime_status == RPM_SUSPENDED) else if (dev->power.runtime_status == RPM_SUSPENDED)
retval = 1; retval = 1;
......
...@@ -218,14 +218,7 @@ static ssize_t pm_qos_resume_latency_show(struct device *dev, ...@@ -218,14 +218,7 @@ static ssize_t pm_qos_resume_latency_show(struct device *dev,
struct device_attribute *attr, struct device_attribute *attr,
char *buf) char *buf)
{ {
s32 value = dev_pm_qos_requested_resume_latency(dev); return sprintf(buf, "%d\n", dev_pm_qos_requested_resume_latency(dev));
if (value == 0)
return sprintf(buf, "n/a\n");
else if (value == PM_QOS_RESUME_LATENCY_NO_CONSTRAINT)
value = 0;
return sprintf(buf, "%d\n", value);
} }
static ssize_t pm_qos_resume_latency_store(struct device *dev, 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, ...@@ -235,21 +228,11 @@ static ssize_t pm_qos_resume_latency_store(struct device *dev,
s32 value; s32 value;
int ret; int ret;
if (!kstrtos32(buf, 0, &value)) { if (kstrtos32(buf, 0, &value))
/*
* Prevent users from writing negative or "no constraint" values
* directly.
*/
if (value < 0 || value == PM_QOS_RESUME_LATENCY_NO_CONSTRAINT)
return -EINVAL; return -EINVAL;
if (value == 0) if (value < 0)
value = PM_QOS_RESUME_LATENCY_NO_CONSTRAINT;
} else if (!strcmp(buf, "n/a") || !strcmp(buf, "n/a\n")) {
value = 0;
} else {
return -EINVAL; return -EINVAL;
}
ret = dev_pm_qos_update_request(dev->power.qos->resume_latency_req, ret = dev_pm_qos_update_request(dev->power.qos->resume_latency_req,
value); value);
......
...@@ -298,8 +298,8 @@ static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device *dev) ...@@ -298,8 +298,8 @@ static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device *dev)
data->needs_update = 0; data->needs_update = 0;
} }
if (resume_latency < latency_req && /* resume_latency is 0 means no restriction */
resume_latency != PM_QOS_RESUME_LATENCY_NO_CONSTRAINT) if (resume_latency && resume_latency < latency_req)
latency_req = resume_latency; latency_req = resume_latency;
/* Special case when user has set very strict latency requirement */ /* Special case when user has set very strict latency requirement */
......
...@@ -27,17 +27,16 @@ enum pm_qos_flags_status { ...@@ -27,17 +27,16 @@ enum pm_qos_flags_status {
PM_QOS_FLAGS_ALL, PM_QOS_FLAGS_ALL,
}; };
#define PM_QOS_DEFAULT_VALUE (-1) #define PM_QOS_DEFAULT_VALUE -1
#define PM_QOS_LATENCY_ANY S32_MAX
#define PM_QOS_CPU_DMA_LAT_DEFAULT_VALUE (2000 * USEC_PER_SEC) #define PM_QOS_CPU_DMA_LAT_DEFAULT_VALUE (2000 * USEC_PER_SEC)
#define PM_QOS_NETWORK_LAT_DEFAULT_VALUE (2000 * USEC_PER_SEC) #define PM_QOS_NETWORK_LAT_DEFAULT_VALUE (2000 * USEC_PER_SEC)
#define PM_QOS_NETWORK_THROUGHPUT_DEFAULT_VALUE 0 #define PM_QOS_NETWORK_THROUGHPUT_DEFAULT_VALUE 0
#define PM_QOS_MEMORY_BANDWIDTH_DEFAULT_VALUE 0 #define PM_QOS_MEMORY_BANDWIDTH_DEFAULT_VALUE 0
#define PM_QOS_RESUME_LATENCY_DEFAULT_VALUE 0 #define PM_QOS_RESUME_LATENCY_DEFAULT_VALUE 0
#define PM_QOS_RESUME_LATENCY_NO_CONSTRAINT PM_QOS_LATENCY_ANY
#define PM_QOS_LATENCY_TOLERANCE_DEFAULT_VALUE 0 #define PM_QOS_LATENCY_TOLERANCE_DEFAULT_VALUE 0
#define PM_QOS_LATENCY_TOLERANCE_NO_CONSTRAINT (-1) #define PM_QOS_LATENCY_TOLERANCE_NO_CONSTRAINT (-1)
#define PM_QOS_LATENCY_ANY ((s32)(~(__u32)0 >> 1))
#define PM_QOS_FLAG_NO_POWER_OFF (1 << 0) #define PM_QOS_FLAG_NO_POWER_OFF (1 << 0)
#define PM_QOS_FLAG_REMOTE_WAKEUP (1 << 1) #define PM_QOS_FLAG_REMOTE_WAKEUP (1 << 1)
...@@ -175,8 +174,7 @@ static inline s32 dev_pm_qos_requested_flags(struct device *dev) ...@@ -175,8 +174,7 @@ static inline s32 dev_pm_qos_requested_flags(struct device *dev)
static inline s32 dev_pm_qos_raw_read_value(struct device *dev) static inline s32 dev_pm_qos_raw_read_value(struct device *dev)
{ {
return IS_ERR_OR_NULL(dev->power.qos) ? return IS_ERR_OR_NULL(dev->power.qos) ?
PM_QOS_RESUME_LATENCY_NO_CONSTRAINT : 0 : pm_qos_read_value(&dev->power.qos->resume_latency);
pm_qos_read_value(&dev->power.qos->resume_latency);
} }
#else #else
static inline enum pm_qos_flags_status __dev_pm_qos_flags(struct device *dev, static inline enum pm_qos_flags_status __dev_pm_qos_flags(struct device *dev,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment