diff options
author | Rafael J. Wysocki <rjw@sisk.pl> | 2012-04-29 16:54:36 -0400 |
---|---|---|
committer | Rafael J. Wysocki <rjw@sisk.pl> | 2012-05-01 15:28:38 -0400 |
commit | 76e267d822f2913893ad210ba431607aa8e2af94 (patch) | |
tree | ce3a821135a398748063f29cb064147d27b40a47 /drivers/base | |
parent | dd8683e97f12609fb3f8c4318628f0d246542f89 (diff) |
PM / Runtime: Remove device fields related to suspend time, v2
After the previous changes in default_stop_ok() and
default_power_down_ok() for PM domains, there are two fields in
struct dev_pm_info that aren't necessary any more, suspend_time
and max_time_suspended_ns.
Remove those fields along with all of the code that accesses them,
which simplifies the runtime PM framework quite a bit.
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Diffstat (limited to 'drivers/base')
-rw-r--r-- | drivers/base/power/domain.c | 13 | ||||
-rw-r--r-- | drivers/base/power/runtime.c | 103 |
2 files changed, 2 insertions, 114 deletions
diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index d03a8c7ad847..45c2b7f0fe3b 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c | |||
@@ -445,16 +445,6 @@ static int pm_genpd_poweroff(struct generic_pm_domain *genpd) | |||
445 | 445 | ||
446 | genpd->status = GPD_STATE_POWER_OFF; | 446 | genpd->status = GPD_STATE_POWER_OFF; |
447 | 447 | ||
448 | /* Update PM QoS information for devices in the domain. */ | ||
449 | list_for_each_entry_reverse(pdd, &genpd->dev_list, list_node) { | ||
450 | struct gpd_timing_data *td = &to_gpd_data(pdd)->td; | ||
451 | |||
452 | pm_runtime_update_max_time_suspended(pdd->dev, | ||
453 | td->start_latency_ns + | ||
454 | td->restore_state_latency_ns + | ||
455 | genpd->power_on_latency_ns); | ||
456 | } | ||
457 | |||
458 | list_for_each_entry(link, &genpd->slave_links, slave_node) { | 448 | list_for_each_entry(link, &genpd->slave_links, slave_node) { |
459 | genpd_sd_counter_dec(link->master); | 449 | genpd_sd_counter_dec(link->master); |
460 | genpd_queue_power_off_work(link->master); | 450 | genpd_queue_power_off_work(link->master); |
@@ -515,9 +505,6 @@ static int pm_genpd_runtime_suspend(struct device *dev) | |||
515 | if (ret) | 505 | if (ret) |
516 | return ret; | 506 | return ret; |
517 | 507 | ||
518 | pm_runtime_update_max_time_suspended(dev, | ||
519 | dev_gpd_data(dev)->td.start_latency_ns); | ||
520 | |||
521 | /* | 508 | /* |
522 | * If power.irq_safe is set, this routine will be run with interrupts | 509 | * If power.irq_safe is set, this routine will be run with interrupts |
523 | * off, so it can't use mutexes. | 510 | * off, so it can't use mutexes. |
diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c index bd0f3949bcf9..59894873a3b3 100644 --- a/drivers/base/power/runtime.c +++ b/drivers/base/power/runtime.c | |||
@@ -282,47 +282,6 @@ static int rpm_callback(int (*cb)(struct device *), struct device *dev) | |||
282 | return retval != -EACCES ? retval : -EIO; | 282 | return retval != -EACCES ? retval : -EIO; |
283 | } | 283 | } |
284 | 284 | ||
285 | struct rpm_qos_data { | ||
286 | ktime_t time_now; | ||
287 | s64 constraint_ns; | ||
288 | }; | ||
289 | |||
290 | /** | ||
291 | * rpm_update_qos_constraint - Update a given PM QoS constraint data. | ||
292 | * @dev: Device whose timing data to use. | ||
293 | * @data: PM QoS constraint data to update. | ||
294 | * | ||
295 | * Use the suspend timing data of @dev to update PM QoS constraint data pointed | ||
296 | * to by @data. | ||
297 | */ | ||
298 | static int rpm_update_qos_constraint(struct device *dev, void *data) | ||
299 | { | ||
300 | struct rpm_qos_data *qos = data; | ||
301 | unsigned long flags; | ||
302 | s64 delta_ns; | ||
303 | int ret = 0; | ||
304 | |||
305 | spin_lock_irqsave(&dev->power.lock, flags); | ||
306 | |||
307 | if (dev->power.max_time_suspended_ns < 0) | ||
308 | goto out; | ||
309 | |||
310 | delta_ns = dev->power.max_time_suspended_ns - | ||
311 | ktime_to_ns(ktime_sub(qos->time_now, dev->power.suspend_time)); | ||
312 | if (delta_ns <= 0) { | ||
313 | ret = -EBUSY; | ||
314 | goto out; | ||
315 | } | ||
316 | |||
317 | if (qos->constraint_ns > delta_ns || qos->constraint_ns == 0) | ||
318 | qos->constraint_ns = delta_ns; | ||
319 | |||
320 | out: | ||
321 | spin_unlock_irqrestore(&dev->power.lock, flags); | ||
322 | |||
323 | return ret; | ||
324 | } | ||
325 | |||
326 | /** | 285 | /** |
327 | * rpm_suspend - Carry out runtime suspend of given device. | 286 | * rpm_suspend - Carry out runtime suspend of given device. |
328 | * @dev: Device to suspend. | 287 | * @dev: Device to suspend. |
@@ -349,7 +308,6 @@ static int rpm_suspend(struct device *dev, int rpmflags) | |||
349 | { | 308 | { |
350 | int (*callback)(struct device *); | 309 | int (*callback)(struct device *); |
351 | struct device *parent = NULL; | 310 | struct device *parent = NULL; |
352 | struct rpm_qos_data qos; | ||
353 | int retval; | 311 | int retval; |
354 | 312 | ||
355 | trace_rpm_suspend(dev, rpmflags); | 313 | trace_rpm_suspend(dev, rpmflags); |
@@ -445,38 +403,14 @@ static int rpm_suspend(struct device *dev, int rpmflags) | |||
445 | goto out; | 403 | goto out; |
446 | } | 404 | } |
447 | 405 | ||
448 | qos.constraint_ns = __dev_pm_qos_read_value(dev); | 406 | if (__dev_pm_qos_read_value(dev) < 0) { |
449 | if (qos.constraint_ns < 0) { | 407 | /* Negative PM QoS constraint means "never suspend". */ |
450 | /* Negative constraint means "never suspend". */ | ||
451 | retval = -EPERM; | 408 | retval = -EPERM; |
452 | goto out; | 409 | goto out; |
453 | } | 410 | } |
454 | qos.constraint_ns *= NSEC_PER_USEC; | ||
455 | qos.time_now = ktime_get(); | ||
456 | 411 | ||
457 | __update_runtime_status(dev, RPM_SUSPENDING); | 412 | __update_runtime_status(dev, RPM_SUSPENDING); |
458 | 413 | ||
459 | if (!dev->power.ignore_children) { | ||
460 | if (dev->power.irq_safe) | ||
461 | spin_unlock(&dev->power.lock); | ||
462 | else | ||
463 | spin_unlock_irq(&dev->power.lock); | ||
464 | |||
465 | retval = device_for_each_child(dev, &qos, | ||
466 | rpm_update_qos_constraint); | ||
467 | |||
468 | if (dev->power.irq_safe) | ||
469 | spin_lock(&dev->power.lock); | ||
470 | else | ||
471 | spin_lock_irq(&dev->power.lock); | ||
472 | |||
473 | if (retval) | ||
474 | goto fail; | ||
475 | } | ||
476 | |||
477 | dev->power.suspend_time = qos.time_now; | ||
478 | dev->power.max_time_suspended_ns = qos.constraint_ns ? : -1; | ||
479 | |||
480 | if (dev->pm_domain) | 414 | if (dev->pm_domain) |
481 | callback = dev->pm_domain->ops.runtime_suspend; | 415 | callback = dev->pm_domain->ops.runtime_suspend; |
482 | else if (dev->type && dev->type->pm) | 416 | else if (dev->type && dev->type->pm) |
@@ -529,8 +463,6 @@ static int rpm_suspend(struct device *dev, int rpmflags) | |||
529 | 463 | ||
530 | fail: | 464 | fail: |
531 | __update_runtime_status(dev, RPM_ACTIVE); | 465 | __update_runtime_status(dev, RPM_ACTIVE); |
532 | dev->power.suspend_time = ktime_set(0, 0); | ||
533 | dev->power.max_time_suspended_ns = -1; | ||
534 | dev->power.deferred_resume = false; | 466 | dev->power.deferred_resume = false; |
535 | wake_up_all(&dev->power.wait_queue); | 467 | wake_up_all(&dev->power.wait_queue); |
536 | 468 | ||
@@ -704,9 +636,6 @@ static int rpm_resume(struct device *dev, int rpmflags) | |||
704 | if (dev->power.no_callbacks) | 636 | if (dev->power.no_callbacks) |
705 | goto no_callback; /* Assume success. */ | 637 | goto no_callback; /* Assume success. */ |
706 | 638 | ||
707 | dev->power.suspend_time = ktime_set(0, 0); | ||
708 | dev->power.max_time_suspended_ns = -1; | ||
709 | |||
710 | __update_runtime_status(dev, RPM_RESUMING); | 639 | __update_runtime_status(dev, RPM_RESUMING); |
711 | 640 | ||
712 | if (dev->pm_domain) | 641 | if (dev->pm_domain) |
@@ -1369,9 +1298,6 @@ void pm_runtime_init(struct device *dev) | |||
1369 | setup_timer(&dev->power.suspend_timer, pm_suspend_timer_fn, | 1298 | setup_timer(&dev->power.suspend_timer, pm_suspend_timer_fn, |
1370 | (unsigned long)dev); | 1299 | (unsigned long)dev); |
1371 | 1300 | ||
1372 | dev->power.suspend_time = ktime_set(0, 0); | ||
1373 | dev->power.max_time_suspended_ns = -1; | ||
1374 | |||
1375 | init_waitqueue_head(&dev->power.wait_queue); | 1301 | init_waitqueue_head(&dev->power.wait_queue); |
1376 | } | 1302 | } |
1377 | 1303 | ||
@@ -1389,28 +1315,3 @@ void pm_runtime_remove(struct device *dev) | |||
1389 | if (dev->power.irq_safe && dev->parent) | 1315 | if (dev->power.irq_safe && dev->parent) |
1390 | pm_runtime_put_sync(dev->parent); | 1316 | pm_runtime_put_sync(dev->parent); |
1391 | } | 1317 | } |
1392 | |||
1393 | /** | ||
1394 | * pm_runtime_update_max_time_suspended - Update device's suspend time data. | ||
1395 | * @dev: Device to handle. | ||
1396 | * @delta_ns: Value to subtract from the device's max_time_suspended_ns field. | ||
1397 | * | ||
1398 | * Update the device's power.max_time_suspended_ns field by subtracting | ||
1399 | * @delta_ns from it. The resulting value of power.max_time_suspended_ns is | ||
1400 | * never negative. | ||
1401 | */ | ||
1402 | void pm_runtime_update_max_time_suspended(struct device *dev, s64 delta_ns) | ||
1403 | { | ||
1404 | unsigned long flags; | ||
1405 | |||
1406 | spin_lock_irqsave(&dev->power.lock, flags); | ||
1407 | |||
1408 | if (delta_ns > 0 && dev->power.max_time_suspended_ns > 0) { | ||
1409 | if (dev->power.max_time_suspended_ns > delta_ns) | ||
1410 | dev->power.max_time_suspended_ns -= delta_ns; | ||
1411 | else | ||
1412 | dev->power.max_time_suspended_ns = 0; | ||
1413 | } | ||
1414 | |||
1415 | spin_unlock_irqrestore(&dev->power.lock, flags); | ||
1416 | } | ||