2 * drivers/base/power/domain.c - Common code related to device power domains.
4 * Copyright (C) 2011 Rafael J. Wysocki <rjw@sisk.pl>, Renesas Electronics Corp.
6 * This file is released under the GPLv2.
9 #include <linux/delay.h>
10 #include <linux/kernel.h>
12 #include <linux/platform_device.h>
13 #include <linux/pm_runtime.h>
14 #include <linux/pm_domain.h>
15 #include <linux/pm_qos.h>
16 #include <linux/pm_clock.h>
17 #include <linux/slab.h>
18 #include <linux/err.h>
19 #include <linux/sched.h>
20 #include <linux/suspend.h>
21 #include <linux/export.h>
23 #define GENPD_RETRY_MAX_MS 250 /* Approximate */
25 #define GENPD_DEV_CALLBACK(genpd, type, callback, dev) \
27 type (*__routine)(struct device *__d); \
28 type __ret = (type)0; \
30 __routine = genpd->dev_ops.callback; \
32 __ret = __routine(dev); \
37 static LIST_HEAD(gpd_list);
38 static DEFINE_MUTEX(gpd_list_lock);
41 * Get the generic PM domain for a particular struct device.
42 * This validates the struct device pointer, the PM domain pointer,
43 * and checks that the PM domain pointer is a real generic PM domain.
44 * Any failure results in NULL being returned.
46 struct generic_pm_domain *pm_genpd_lookup_dev(struct device *dev)
48 struct generic_pm_domain *genpd = NULL, *gpd;
50 if (IS_ERR_OR_NULL(dev) || IS_ERR_OR_NULL(dev->pm_domain))
53 mutex_lock(&gpd_list_lock);
54 list_for_each_entry(gpd, &gpd_list, gpd_list_node) {
55 if (&gpd->domain == dev->pm_domain) {
60 mutex_unlock(&gpd_list_lock);
66 * This should only be used where we are certain that the pm_domain
67 * attached to the device is a genpd domain.
69 static struct generic_pm_domain *dev_to_genpd(struct device *dev)
71 if (IS_ERR_OR_NULL(dev->pm_domain))
72 return ERR_PTR(-EINVAL);
74 return pd_to_genpd(dev->pm_domain);
77 static int genpd_stop_dev(struct generic_pm_domain *genpd, struct device *dev)
79 return GENPD_DEV_CALLBACK(genpd, int, stop, dev);
82 static int genpd_start_dev(struct generic_pm_domain *genpd, struct device *dev)
84 return GENPD_DEV_CALLBACK(genpd, int, start, dev);
87 static bool genpd_sd_counter_dec(struct generic_pm_domain *genpd)
91 if (!WARN_ON(atomic_read(&genpd->sd_count) == 0))
92 ret = !!atomic_dec_and_test(&genpd->sd_count);
97 static void genpd_sd_counter_inc(struct generic_pm_domain *genpd)
99 atomic_inc(&genpd->sd_count);
100 smp_mb__after_atomic();
103 static int genpd_power_on(struct generic_pm_domain *genpd, bool timed)
109 if (!genpd->power_on)
113 return genpd->power_on(genpd);
115 time_start = ktime_get();
116 ret = genpd->power_on(genpd);
120 elapsed_ns = ktime_to_ns(ktime_sub(ktime_get(), time_start));
121 if (elapsed_ns <= genpd->power_on_latency_ns)
124 genpd->power_on_latency_ns = elapsed_ns;
125 genpd->max_off_time_changed = true;
126 pr_debug("%s: Power-%s latency exceeded, new value %lld ns\n",
127 genpd->name, "on", elapsed_ns);
132 static int genpd_power_off(struct generic_pm_domain *genpd, bool timed)
138 if (!genpd->power_off)
142 return genpd->power_off(genpd);
144 time_start = ktime_get();
145 ret = genpd->power_off(genpd);
149 elapsed_ns = ktime_to_ns(ktime_sub(ktime_get(), time_start));
150 if (elapsed_ns <= genpd->power_off_latency_ns)
153 genpd->power_off_latency_ns = elapsed_ns;
154 genpd->max_off_time_changed = true;
155 pr_debug("%s: Power-%s latency exceeded, new value %lld ns\n",
156 genpd->name, "off", elapsed_ns);
162 * genpd_queue_power_off_work - Queue up the execution of genpd_poweroff().
163 * @genpd: PM domait to power off.
165 * Queue up the execution of genpd_poweroff() unless it's already been done
168 static void genpd_queue_power_off_work(struct generic_pm_domain *genpd)
170 queue_work(pm_wq, &genpd->power_off_work);
174 * __genpd_poweron - Restore power to a given PM domain and its masters.
175 * @genpd: PM domain to power up.
176 * @depth: nesting count for lockdep.
178 * Restore power to @genpd and all of its masters so that it is possible to
179 * resume a device belonging to it.
181 static int __genpd_poweron(struct generic_pm_domain *genpd, unsigned int depth)
183 struct gpd_link *link;
186 if (genpd->status == GPD_STATE_ACTIVE)
190 * The list is guaranteed not to change while the loop below is being
191 * executed, unless one of the masters' .power_on() callbacks fiddles
194 list_for_each_entry(link, &genpd->slave_links, slave_node) {
195 struct generic_pm_domain *master = link->master;
197 genpd_sd_counter_inc(master);
199 mutex_lock_nested(&master->lock, depth + 1);
200 ret = __genpd_poweron(master, depth + 1);
201 mutex_unlock(&master->lock);
204 genpd_sd_counter_dec(master);
209 ret = genpd_power_on(genpd, true);
213 genpd->status = GPD_STATE_ACTIVE;
217 list_for_each_entry_continue_reverse(link,
220 genpd_sd_counter_dec(link->master);
221 genpd_queue_power_off_work(link->master);
228 * genpd_poweron - Restore power to a given PM domain and its masters.
229 * @genpd: PM domain to power up.
231 static int genpd_poweron(struct generic_pm_domain *genpd)
235 mutex_lock(&genpd->lock);
236 ret = __genpd_poweron(genpd, 0);
237 mutex_unlock(&genpd->lock);
242 static int genpd_save_dev(struct generic_pm_domain *genpd, struct device *dev)
244 return GENPD_DEV_CALLBACK(genpd, int, save_state, dev);
247 static int genpd_restore_dev(struct generic_pm_domain *genpd,
250 return GENPD_DEV_CALLBACK(genpd, int, restore_state, dev);
253 static int genpd_dev_pm_qos_notifier(struct notifier_block *nb,
254 unsigned long val, void *ptr)
256 struct generic_pm_domain_data *gpd_data;
259 gpd_data = container_of(nb, struct generic_pm_domain_data, nb);
260 dev = gpd_data->base.dev;
263 struct generic_pm_domain *genpd;
264 struct pm_domain_data *pdd;
266 spin_lock_irq(&dev->power.lock);
268 pdd = dev->power.subsys_data ?
269 dev->power.subsys_data->domain_data : NULL;
270 if (pdd && pdd->dev) {
271 to_gpd_data(pdd)->td.constraint_changed = true;
272 genpd = dev_to_genpd(dev);
274 genpd = ERR_PTR(-ENODATA);
277 spin_unlock_irq(&dev->power.lock);
279 if (!IS_ERR(genpd)) {
280 mutex_lock(&genpd->lock);
281 genpd->max_off_time_changed = true;
282 mutex_unlock(&genpd->lock);
286 if (!dev || dev->power.ignore_children)
294 * genpd_poweroff - Remove power from a given PM domain.
295 * @genpd: PM domain to power down.
296 * @is_async: PM domain is powered down from a scheduled work
298 * If all of the @genpd's devices have been suspended and all of its subdomains
299 * have been powered down, remove power from @genpd.
301 static int genpd_poweroff(struct generic_pm_domain *genpd, bool is_async)
303 struct pm_domain_data *pdd;
304 struct gpd_link *link;
305 unsigned int not_suspended = 0;
308 * Do not try to power off the domain in the following situations:
309 * (1) The domain is already in the "power off" state.
310 * (2) System suspend is in progress.
312 if (genpd->status == GPD_STATE_POWER_OFF
313 || genpd->prepared_count > 0)
316 if (atomic_read(&genpd->sd_count) > 0)
319 list_for_each_entry(pdd, &genpd->dev_list, list_node) {
320 enum pm_qos_flags_status stat;
322 stat = dev_pm_qos_flags(pdd->dev,
323 PM_QOS_FLAG_NO_POWER_OFF
324 | PM_QOS_FLAG_REMOTE_WAKEUP);
325 if (stat > PM_QOS_FLAGS_NONE)
328 if (!pm_runtime_suspended(pdd->dev) || pdd->dev->power.irq_safe)
332 if (not_suspended > 1 || (not_suspended == 1 && is_async))
335 if (genpd->gov && genpd->gov->power_down_ok) {
336 if (!genpd->gov->power_down_ok(&genpd->domain))
340 if (genpd->power_off) {
343 if (atomic_read(&genpd->sd_count) > 0)
347 * If sd_count > 0 at this point, one of the subdomains hasn't
348 * managed to call genpd_poweron() for the master yet after
349 * incrementing it. In that case genpd_poweron() will wait
350 * for us to drop the lock, so we can call .power_off() and let
351 * the genpd_poweron() restore power for us (this shouldn't
352 * happen very often).
354 ret = genpd_power_off(genpd, true);
359 genpd->status = GPD_STATE_POWER_OFF;
361 list_for_each_entry(link, &genpd->slave_links, slave_node) {
362 genpd_sd_counter_dec(link->master);
363 genpd_queue_power_off_work(link->master);
370 * genpd_power_off_work_fn - Power off PM domain whose subdomain count is 0.
371 * @work: Work structure used for scheduling the execution of this function.
373 static void genpd_power_off_work_fn(struct work_struct *work)
375 struct generic_pm_domain *genpd;
377 genpd = container_of(work, struct generic_pm_domain, power_off_work);
379 mutex_lock(&genpd->lock);
380 genpd_poweroff(genpd, true);
381 mutex_unlock(&genpd->lock);
385 * pm_genpd_runtime_suspend - Suspend a device belonging to I/O PM domain.
386 * @dev: Device to suspend.
388 * Carry out a runtime suspend of a device under the assumption that its
389 * pm_domain field points to the domain member of an object of type
390 * struct generic_pm_domain representing a PM domain consisting of I/O devices.
392 static int pm_genpd_runtime_suspend(struct device *dev)
394 struct generic_pm_domain *genpd;
395 bool (*stop_ok)(struct device *__dev);
396 struct gpd_timing_data *td = &dev_gpd_data(dev)->td;
397 bool runtime_pm = pm_runtime_enabled(dev);
402 dev_dbg(dev, "%s()\n", __func__);
404 genpd = dev_to_genpd(dev);
409 * A runtime PM centric subsystem/driver may re-use the runtime PM
410 * callbacks for other purposes than runtime PM. In those scenarios
411 * runtime PM is disabled. Under these circumstances, we shall skip
412 * validating/measuring the PM QoS latency.
414 stop_ok = genpd->gov ? genpd->gov->stop_ok : NULL;
415 if (runtime_pm && stop_ok && !stop_ok(dev))
418 /* Measure suspend latency. */
420 time_start = ktime_get();
422 ret = genpd_save_dev(genpd, dev);
426 ret = genpd_stop_dev(genpd, dev);
428 genpd_restore_dev(genpd, dev);
432 /* Update suspend latency value if the measured time exceeds it. */
434 elapsed_ns = ktime_to_ns(ktime_sub(ktime_get(), time_start));
435 if (elapsed_ns > td->suspend_latency_ns) {
436 td->suspend_latency_ns = elapsed_ns;
437 dev_dbg(dev, "suspend latency exceeded, %lld ns\n",
439 genpd->max_off_time_changed = true;
440 td->constraint_changed = true;
445 * If power.irq_safe is set, this routine will be run with interrupts
446 * off, so it can't use mutexes.
448 if (dev->power.irq_safe)
451 mutex_lock(&genpd->lock);
452 genpd_poweroff(genpd, false);
453 mutex_unlock(&genpd->lock);
459 * pm_genpd_runtime_resume - Resume a device belonging to I/O PM domain.
460 * @dev: Device to resume.
462 * Carry out a runtime resume of a device under the assumption that its
463 * pm_domain field points to the domain member of an object of type
464 * struct generic_pm_domain representing a PM domain consisting of I/O devices.
466 static int pm_genpd_runtime_resume(struct device *dev)
468 struct generic_pm_domain *genpd;
469 struct gpd_timing_data *td = &dev_gpd_data(dev)->td;
470 bool runtime_pm = pm_runtime_enabled(dev);
476 dev_dbg(dev, "%s()\n", __func__);
478 genpd = dev_to_genpd(dev);
482 /* If power.irq_safe, the PM domain is never powered off. */
483 if (dev->power.irq_safe) {
488 mutex_lock(&genpd->lock);
489 ret = __genpd_poweron(genpd, 0);
490 mutex_unlock(&genpd->lock);
496 /* Measure resume latency. */
497 if (timed && runtime_pm)
498 time_start = ktime_get();
500 genpd_start_dev(genpd, dev);
501 genpd_restore_dev(genpd, dev);
503 /* Update resume latency value if the measured time exceeds it. */
504 if (timed && runtime_pm) {
505 elapsed_ns = ktime_to_ns(ktime_sub(ktime_get(), time_start));
506 if (elapsed_ns > td->resume_latency_ns) {
507 td->resume_latency_ns = elapsed_ns;
508 dev_dbg(dev, "resume latency exceeded, %lld ns\n",
510 genpd->max_off_time_changed = true;
511 td->constraint_changed = true;
518 static bool pd_ignore_unused;
519 static int __init pd_ignore_unused_setup(char *__unused)
521 pd_ignore_unused = true;
524 __setup("pd_ignore_unused", pd_ignore_unused_setup);
527 * genpd_poweroff_unused - Power off all PM domains with no devices in use.
529 static int __init genpd_poweroff_unused(void)
531 struct generic_pm_domain *genpd;
533 if (pd_ignore_unused) {
534 pr_warn("genpd: Not disabling unused power domains\n");
538 mutex_lock(&gpd_list_lock);
540 list_for_each_entry(genpd, &gpd_list, gpd_list_node)
541 genpd_queue_power_off_work(genpd);
543 mutex_unlock(&gpd_list_lock);
547 late_initcall(genpd_poweroff_unused);
549 #ifdef CONFIG_PM_SLEEP
552 * pm_genpd_present - Check if the given PM domain has been initialized.
553 * @genpd: PM domain to check.
555 static bool pm_genpd_present(const struct generic_pm_domain *genpd)
557 const struct generic_pm_domain *gpd;
559 if (IS_ERR_OR_NULL(genpd))
562 list_for_each_entry(gpd, &gpd_list, gpd_list_node)
569 static bool genpd_dev_active_wakeup(struct generic_pm_domain *genpd,
572 return GENPD_DEV_CALLBACK(genpd, bool, active_wakeup, dev);
576 * pm_genpd_sync_poweroff - Synchronously power off a PM domain and its masters.
577 * @genpd: PM domain to power off, if possible.
578 * @timed: True if latency measurements are allowed.
580 * Check if the given PM domain can be powered off (during system suspend or
581 * hibernation) and do that if so. Also, in that case propagate to its masters.
583 * This function is only called in "noirq" and "syscore" stages of system power
584 * transitions, so it need not acquire locks (all of the "noirq" callbacks are
585 * executed sequentially, so it is guaranteed that it will never run twice in
588 static void pm_genpd_sync_poweroff(struct generic_pm_domain *genpd,
591 struct gpd_link *link;
593 if (genpd->status == GPD_STATE_POWER_OFF)
596 if (genpd->suspended_count != genpd->device_count
597 || atomic_read(&genpd->sd_count) > 0)
600 genpd_power_off(genpd, timed);
602 genpd->status = GPD_STATE_POWER_OFF;
604 list_for_each_entry(link, &genpd->slave_links, slave_node) {
605 genpd_sd_counter_dec(link->master);
606 pm_genpd_sync_poweroff(link->master, timed);
611 * pm_genpd_sync_poweron - Synchronously power on a PM domain and its masters.
612 * @genpd: PM domain to power on.
613 * @timed: True if latency measurements are allowed.
615 * This function is only called in "noirq" and "syscore" stages of system power
616 * transitions, so it need not acquire locks (all of the "noirq" callbacks are
617 * executed sequentially, so it is guaranteed that it will never run twice in
620 static void pm_genpd_sync_poweron(struct generic_pm_domain *genpd,
623 struct gpd_link *link;
625 if (genpd->status == GPD_STATE_ACTIVE)
628 list_for_each_entry(link, &genpd->slave_links, slave_node) {
629 pm_genpd_sync_poweron(link->master, timed);
630 genpd_sd_counter_inc(link->master);
633 genpd_power_on(genpd, timed);
635 genpd->status = GPD_STATE_ACTIVE;
639 * resume_needed - Check whether to resume a device before system suspend.
640 * @dev: Device to check.
641 * @genpd: PM domain the device belongs to.
643 * There are two cases in which a device that can wake up the system from sleep
644 * states should be resumed by pm_genpd_prepare(): (1) if the device is enabled
645 * to wake up the system and it has to remain active for this purpose while the
646 * system is in the sleep state and (2) if the device is not enabled to wake up
647 * the system from sleep states and it generally doesn't generate wakeup signals
648 * by itself (those signals are generated on its behalf by other parts of the
649 * system). In the latter case it may be necessary to reconfigure the device's
650 * wakeup settings during system suspend, because it may have been set up to
651 * signal remote wakeup from the system's working state as needed by runtime PM.
652 * Return 'true' in either of the above cases.
654 static bool resume_needed(struct device *dev, struct generic_pm_domain *genpd)
658 if (!device_can_wakeup(dev))
661 active_wakeup = genpd_dev_active_wakeup(genpd, dev);
662 return device_may_wakeup(dev) ? active_wakeup : !active_wakeup;
666 * pm_genpd_prepare - Start power transition of a device in a PM domain.
667 * @dev: Device to start the transition of.
669 * Start a power transition of a device (during a system-wide power transition)
670 * under the assumption that its pm_domain field points to the domain member of
671 * an object of type struct generic_pm_domain representing a PM domain
672 * consisting of I/O devices.
674 static int pm_genpd_prepare(struct device *dev)
676 struct generic_pm_domain *genpd;
679 dev_dbg(dev, "%s()\n", __func__);
681 genpd = dev_to_genpd(dev);
686 * If a wakeup request is pending for the device, it should be woken up
687 * at this point and a system wakeup event should be reported if it's
688 * set up to wake up the system from sleep states.
690 if (resume_needed(dev, genpd))
691 pm_runtime_resume(dev);
693 mutex_lock(&genpd->lock);
695 if (genpd->prepared_count++ == 0)
696 genpd->suspended_count = 0;
698 mutex_unlock(&genpd->lock);
701 * Even if the PM domain is powered off at this point, we can't expect
702 * it to remain in that state during the entire system PM suspend
703 * phase. Any subsystem/driver for a device in the PM domain, may still
704 * need to serve a request which may require the device to be runtime
705 * resumed and its PM domain to be powered.
707 * As we are disabling runtime PM at this point, we are preventing the
708 * subsystem/driver to decide themselves. For that reason, we need to
709 * make sure the device is operational as it may be required in some
712 pm_runtime_resume(dev);
713 __pm_runtime_disable(dev, false);
715 ret = pm_generic_prepare(dev);
717 mutex_lock(&genpd->lock);
719 genpd->prepared_count--;
721 mutex_unlock(&genpd->lock);
722 pm_runtime_enable(dev);
729 * pm_genpd_suspend_noirq - Completion of suspend of device in an I/O PM domain.
730 * @dev: Device to suspend.
732 * Stop the device and remove power from the domain if all devices in it have
735 static int pm_genpd_suspend_noirq(struct device *dev)
737 struct generic_pm_domain *genpd;
739 dev_dbg(dev, "%s()\n", __func__);
741 genpd = dev_to_genpd(dev);
745 if (dev->power.wakeup_path && genpd_dev_active_wakeup(genpd, dev))
748 genpd_stop_dev(genpd, dev);
751 * Since all of the "noirq" callbacks are executed sequentially, it is
752 * guaranteed that this function will never run twice in parallel for
753 * the same PM domain, so it is not necessary to use locking here.
755 genpd->suspended_count++;
756 pm_genpd_sync_poweroff(genpd, true);
762 * pm_genpd_resume_noirq - Start of resume of device in an I/O PM domain.
763 * @dev: Device to resume.
765 * Restore power to the device's PM domain, if necessary, and start the device.
767 static int pm_genpd_resume_noirq(struct device *dev)
769 struct generic_pm_domain *genpd;
771 dev_dbg(dev, "%s()\n", __func__);
773 genpd = dev_to_genpd(dev);
777 if (dev->power.wakeup_path && genpd_dev_active_wakeup(genpd, dev))
781 * Since all of the "noirq" callbacks are executed sequentially, it is
782 * guaranteed that this function will never run twice in parallel for
783 * the same PM domain, so it is not necessary to use locking here.
785 pm_genpd_sync_poweron(genpd, true);
786 genpd->suspended_count--;
788 return genpd_start_dev(genpd, dev);
792 * pm_genpd_freeze_noirq - Completion of freezing a device in an I/O PM domain.
793 * @dev: Device to freeze.
795 * Carry out a late freeze of a device under the assumption that its
796 * pm_domain field points to the domain member of an object of type
797 * struct generic_pm_domain representing a power domain consisting of I/O
800 static int pm_genpd_freeze_noirq(struct device *dev)
802 struct generic_pm_domain *genpd;
804 dev_dbg(dev, "%s()\n", __func__);
806 genpd = dev_to_genpd(dev);
810 return genpd_stop_dev(genpd, dev);
814 * pm_genpd_thaw_noirq - Early thaw of device in an I/O PM domain.
815 * @dev: Device to thaw.
817 * Start the device, unless power has been removed from the domain already
818 * before the system transition.
820 static int pm_genpd_thaw_noirq(struct device *dev)
822 struct generic_pm_domain *genpd;
824 dev_dbg(dev, "%s()\n", __func__);
826 genpd = dev_to_genpd(dev);
830 return genpd_start_dev(genpd, dev);
834 * pm_genpd_restore_noirq - Start of restore of device in an I/O PM domain.
835 * @dev: Device to resume.
837 * Make sure the domain will be in the same power state as before the
838 * hibernation the system is resuming from and start the device if necessary.
840 static int pm_genpd_restore_noirq(struct device *dev)
842 struct generic_pm_domain *genpd;
844 dev_dbg(dev, "%s()\n", __func__);
846 genpd = dev_to_genpd(dev);
851 * Since all of the "noirq" callbacks are executed sequentially, it is
852 * guaranteed that this function will never run twice in parallel for
853 * the same PM domain, so it is not necessary to use locking here.
855 * At this point suspended_count == 0 means we are being run for the
856 * first time for the given domain in the present cycle.
858 if (genpd->suspended_count++ == 0)
860 * The boot kernel might put the domain into arbitrary state,
861 * so make it appear as powered off to pm_genpd_sync_poweron(),
862 * so that it tries to power it on in case it was really off.
864 genpd->status = GPD_STATE_POWER_OFF;
866 pm_genpd_sync_poweron(genpd, true);
868 return genpd_start_dev(genpd, dev);
872 * pm_genpd_complete - Complete power transition of a device in a power domain.
873 * @dev: Device to complete the transition of.
875 * Complete a power transition of a device (during a system-wide power
876 * transition) under the assumption that its pm_domain field points to the
877 * domain member of an object of type struct generic_pm_domain representing
878 * a power domain consisting of I/O devices.
880 static void pm_genpd_complete(struct device *dev)
882 struct generic_pm_domain *genpd;
884 dev_dbg(dev, "%s()\n", __func__);
886 genpd = dev_to_genpd(dev);
890 mutex_lock(&genpd->lock);
892 genpd->prepared_count--;
894 mutex_unlock(&genpd->lock);
896 pm_generic_complete(dev);
897 pm_runtime_set_active(dev);
898 pm_runtime_enable(dev);
902 * genpd_syscore_switch - Switch power during system core suspend or resume.
903 * @dev: Device that normally is marked as "always on" to switch power for.
905 * This routine may only be called during the system core (syscore) suspend or
906 * resume phase for devices whose "always on" flags are set.
908 static void genpd_syscore_switch(struct device *dev, bool suspend)
910 struct generic_pm_domain *genpd;
912 genpd = dev_to_genpd(dev);
913 if (!pm_genpd_present(genpd))
917 genpd->suspended_count++;
918 pm_genpd_sync_poweroff(genpd, false);
920 pm_genpd_sync_poweron(genpd, false);
921 genpd->suspended_count--;
925 void pm_genpd_syscore_poweroff(struct device *dev)
927 genpd_syscore_switch(dev, true);
929 EXPORT_SYMBOL_GPL(pm_genpd_syscore_poweroff);
931 void pm_genpd_syscore_poweron(struct device *dev)
933 genpd_syscore_switch(dev, false);
935 EXPORT_SYMBOL_GPL(pm_genpd_syscore_poweron);
937 #else /* !CONFIG_PM_SLEEP */
939 #define pm_genpd_prepare NULL
940 #define pm_genpd_suspend_noirq NULL
941 #define pm_genpd_resume_noirq NULL
942 #define pm_genpd_freeze_noirq NULL
943 #define pm_genpd_thaw_noirq NULL
944 #define pm_genpd_restore_noirq NULL
945 #define pm_genpd_complete NULL
947 #endif /* CONFIG_PM_SLEEP */
949 static struct generic_pm_domain_data *genpd_alloc_dev_data(struct device *dev,
950 struct generic_pm_domain *genpd,
951 struct gpd_timing_data *td)
953 struct generic_pm_domain_data *gpd_data;
956 ret = dev_pm_get_subsys_data(dev);
960 gpd_data = kzalloc(sizeof(*gpd_data), GFP_KERNEL);
969 gpd_data->base.dev = dev;
970 gpd_data->td.constraint_changed = true;
971 gpd_data->td.effective_constraint_ns = -1;
972 gpd_data->nb.notifier_call = genpd_dev_pm_qos_notifier;
974 spin_lock_irq(&dev->power.lock);
976 if (dev->power.subsys_data->domain_data) {
981 dev->power.subsys_data->domain_data = &gpd_data->base;
982 dev->pm_domain = &genpd->domain;
984 spin_unlock_irq(&dev->power.lock);
989 spin_unlock_irq(&dev->power.lock);
992 dev_pm_put_subsys_data(dev);
996 static void genpd_free_dev_data(struct device *dev,
997 struct generic_pm_domain_data *gpd_data)
999 spin_lock_irq(&dev->power.lock);
1001 dev->pm_domain = NULL;
1002 dev->power.subsys_data->domain_data = NULL;
1004 spin_unlock_irq(&dev->power.lock);
1007 dev_pm_put_subsys_data(dev);
1011 * __pm_genpd_add_device - Add a device to an I/O PM domain.
1012 * @genpd: PM domain to add the device to.
1013 * @dev: Device to be added.
1014 * @td: Set of PM QoS timing parameters to attach to the device.
1016 int __pm_genpd_add_device(struct generic_pm_domain *genpd, struct device *dev,
1017 struct gpd_timing_data *td)
1019 struct generic_pm_domain_data *gpd_data;
1022 dev_dbg(dev, "%s()\n", __func__);
1024 if (IS_ERR_OR_NULL(genpd) || IS_ERR_OR_NULL(dev))
1027 gpd_data = genpd_alloc_dev_data(dev, genpd, td);
1028 if (IS_ERR(gpd_data))
1029 return PTR_ERR(gpd_data);
1031 mutex_lock(&genpd->lock);
1033 if (genpd->prepared_count > 0) {
1038 ret = genpd->attach_dev ? genpd->attach_dev(genpd, dev) : 0;
1042 genpd->device_count++;
1043 genpd->max_off_time_changed = true;
1045 list_add_tail(&gpd_data->base.list_node, &genpd->dev_list);
1048 mutex_unlock(&genpd->lock);
1051 genpd_free_dev_data(dev, gpd_data);
1053 dev_pm_qos_add_notifier(dev, &gpd_data->nb);
1059 * pm_genpd_remove_device - Remove a device from an I/O PM domain.
1060 * @genpd: PM domain to remove the device from.
1061 * @dev: Device to be removed.
1063 int pm_genpd_remove_device(struct generic_pm_domain *genpd,
1066 struct generic_pm_domain_data *gpd_data;
1067 struct pm_domain_data *pdd;
1070 dev_dbg(dev, "%s()\n", __func__);
1072 if (!genpd || genpd != pm_genpd_lookup_dev(dev))
1075 /* The above validation also means we have existing domain_data. */
1076 pdd = dev->power.subsys_data->domain_data;
1077 gpd_data = to_gpd_data(pdd);
1078 dev_pm_qos_remove_notifier(dev, &gpd_data->nb);
1080 mutex_lock(&genpd->lock);
1082 if (genpd->prepared_count > 0) {
1087 genpd->device_count--;
1088 genpd->max_off_time_changed = true;
1090 if (genpd->detach_dev)
1091 genpd->detach_dev(genpd, dev);
1093 list_del_init(&pdd->list_node);
1095 mutex_unlock(&genpd->lock);
1097 genpd_free_dev_data(dev, gpd_data);
1102 mutex_unlock(&genpd->lock);
1103 dev_pm_qos_add_notifier(dev, &gpd_data->nb);
1109 * pm_genpd_add_subdomain - Add a subdomain to an I/O PM domain.
1110 * @genpd: Master PM domain to add the subdomain to.
1111 * @subdomain: Subdomain to be added.
1113 int pm_genpd_add_subdomain(struct generic_pm_domain *genpd,
1114 struct generic_pm_domain *subdomain)
1116 struct gpd_link *link, *itr;
1119 if (IS_ERR_OR_NULL(genpd) || IS_ERR_OR_NULL(subdomain)
1120 || genpd == subdomain)
1123 link = kzalloc(sizeof(*link), GFP_KERNEL);
1127 mutex_lock(&subdomain->lock);
1128 mutex_lock_nested(&genpd->lock, SINGLE_DEPTH_NESTING);
1130 if (genpd->status == GPD_STATE_POWER_OFF
1131 && subdomain->status != GPD_STATE_POWER_OFF) {
1136 list_for_each_entry(itr, &genpd->master_links, master_node) {
1137 if (itr->slave == subdomain && itr->master == genpd) {
1143 link->master = genpd;
1144 list_add_tail(&link->master_node, &genpd->master_links);
1145 link->slave = subdomain;
1146 list_add_tail(&link->slave_node, &subdomain->slave_links);
1147 if (subdomain->status != GPD_STATE_POWER_OFF)
1148 genpd_sd_counter_inc(genpd);
1151 mutex_unlock(&genpd->lock);
1152 mutex_unlock(&subdomain->lock);
1157 EXPORT_SYMBOL_GPL(pm_genpd_add_subdomain);
1160 * pm_genpd_remove_subdomain - Remove a subdomain from an I/O PM domain.
1161 * @genpd: Master PM domain to remove the subdomain from.
1162 * @subdomain: Subdomain to be removed.
1164 int pm_genpd_remove_subdomain(struct generic_pm_domain *genpd,
1165 struct generic_pm_domain *subdomain)
1167 struct gpd_link *link;
1170 if (IS_ERR_OR_NULL(genpd) || IS_ERR_OR_NULL(subdomain))
1173 mutex_lock(&subdomain->lock);
1174 mutex_lock_nested(&genpd->lock, SINGLE_DEPTH_NESTING);
1176 if (!list_empty(&subdomain->master_links) || subdomain->device_count) {
1177 pr_warn("%s: unable to remove subdomain %s\n", genpd->name,
1183 list_for_each_entry(link, &genpd->master_links, master_node) {
1184 if (link->slave != subdomain)
1187 list_del(&link->master_node);
1188 list_del(&link->slave_node);
1190 if (subdomain->status != GPD_STATE_POWER_OFF)
1191 genpd_sd_counter_dec(genpd);
1198 mutex_unlock(&genpd->lock);
1199 mutex_unlock(&subdomain->lock);
1203 EXPORT_SYMBOL_GPL(pm_genpd_remove_subdomain);
1205 /* Default device callbacks for generic PM domains. */
1208 * pm_genpd_default_save_state - Default "save device state" for PM domains.
1209 * @dev: Device to handle.
1211 static int pm_genpd_default_save_state(struct device *dev)
1213 int (*cb)(struct device *__dev);
1215 if (dev->type && dev->type->pm)
1216 cb = dev->type->pm->runtime_suspend;
1217 else if (dev->class && dev->class->pm)
1218 cb = dev->class->pm->runtime_suspend;
1219 else if (dev->bus && dev->bus->pm)
1220 cb = dev->bus->pm->runtime_suspend;
1224 if (!cb && dev->driver && dev->driver->pm)
1225 cb = dev->driver->pm->runtime_suspend;
1227 return cb ? cb(dev) : 0;
1231 * pm_genpd_default_restore_state - Default PM domains "restore device state".
1232 * @dev: Device to handle.
1234 static int pm_genpd_default_restore_state(struct device *dev)
1236 int (*cb)(struct device *__dev);
1238 if (dev->type && dev->type->pm)
1239 cb = dev->type->pm->runtime_resume;
1240 else if (dev->class && dev->class->pm)
1241 cb = dev->class->pm->runtime_resume;
1242 else if (dev->bus && dev->bus->pm)
1243 cb = dev->bus->pm->runtime_resume;
1247 if (!cb && dev->driver && dev->driver->pm)
1248 cb = dev->driver->pm->runtime_resume;
1250 return cb ? cb(dev) : 0;
1254 * pm_genpd_init - Initialize a generic I/O PM domain object.
1255 * @genpd: PM domain object to initialize.
1256 * @gov: PM domain governor to associate with the domain (may be NULL).
1257 * @is_off: Initial value of the domain's power_is_off field.
1259 void pm_genpd_init(struct generic_pm_domain *genpd,
1260 struct dev_power_governor *gov, bool is_off)
1262 if (IS_ERR_OR_NULL(genpd))
1265 INIT_LIST_HEAD(&genpd->master_links);
1266 INIT_LIST_HEAD(&genpd->slave_links);
1267 INIT_LIST_HEAD(&genpd->dev_list);
1268 mutex_init(&genpd->lock);
1270 INIT_WORK(&genpd->power_off_work, genpd_power_off_work_fn);
1271 atomic_set(&genpd->sd_count, 0);
1272 genpd->status = is_off ? GPD_STATE_POWER_OFF : GPD_STATE_ACTIVE;
1273 genpd->device_count = 0;
1274 genpd->max_off_time_ns = -1;
1275 genpd->max_off_time_changed = true;
1276 genpd->domain.ops.runtime_suspend = pm_genpd_runtime_suspend;
1277 genpd->domain.ops.runtime_resume = pm_genpd_runtime_resume;
1278 genpd->domain.ops.prepare = pm_genpd_prepare;
1279 genpd->domain.ops.suspend = pm_generic_suspend;
1280 genpd->domain.ops.suspend_late = pm_generic_suspend_late;
1281 genpd->domain.ops.suspend_noirq = pm_genpd_suspend_noirq;
1282 genpd->domain.ops.resume_noirq = pm_genpd_resume_noirq;
1283 genpd->domain.ops.resume_early = pm_generic_resume_early;
1284 genpd->domain.ops.resume = pm_generic_resume;
1285 genpd->domain.ops.freeze = pm_generic_freeze;
1286 genpd->domain.ops.freeze_late = pm_generic_freeze_late;
1287 genpd->domain.ops.freeze_noirq = pm_genpd_freeze_noirq;
1288 genpd->domain.ops.thaw_noirq = pm_genpd_thaw_noirq;
1289 genpd->domain.ops.thaw_early = pm_generic_thaw_early;
1290 genpd->domain.ops.thaw = pm_generic_thaw;
1291 genpd->domain.ops.poweroff = pm_generic_poweroff;
1292 genpd->domain.ops.poweroff_late = pm_generic_poweroff_late;
1293 genpd->domain.ops.poweroff_noirq = pm_genpd_suspend_noirq;
1294 genpd->domain.ops.restore_noirq = pm_genpd_restore_noirq;
1295 genpd->domain.ops.restore_early = pm_generic_restore_early;
1296 genpd->domain.ops.restore = pm_generic_restore;
1297 genpd->domain.ops.complete = pm_genpd_complete;
1298 genpd->dev_ops.save_state = pm_genpd_default_save_state;
1299 genpd->dev_ops.restore_state = pm_genpd_default_restore_state;
1301 if (genpd->flags & GENPD_FLAG_PM_CLK) {
1302 genpd->dev_ops.stop = pm_clk_suspend;
1303 genpd->dev_ops.start = pm_clk_resume;
1306 mutex_lock(&gpd_list_lock);
1307 list_add(&genpd->gpd_list_node, &gpd_list);
1308 mutex_unlock(&gpd_list_lock);
1310 EXPORT_SYMBOL_GPL(pm_genpd_init);
1312 #ifdef CONFIG_PM_GENERIC_DOMAINS_OF
1314 * Device Tree based PM domain providers.
1316 * The code below implements generic device tree based PM domain providers that
1317 * bind device tree nodes with generic PM domains registered in the system.
1319 * Any driver that registers generic PM domains and needs to support binding of
1320 * devices to these domains is supposed to register a PM domain provider, which
1321 * maps a PM domain specifier retrieved from the device tree to a PM domain.
1323 * Two simple mapping functions have been provided for convenience:
1324 * - __of_genpd_xlate_simple() for 1:1 device tree node to PM domain mapping.
1325 * - __of_genpd_xlate_onecell() for mapping of multiple PM domains per node by
1330 * struct of_genpd_provider - PM domain provider registration structure
1331 * @link: Entry in global list of PM domain providers
1332 * @node: Pointer to device tree node of PM domain provider
1333 * @xlate: Provider-specific xlate callback mapping a set of specifier cells
1335 * @data: context pointer to be passed into @xlate callback
1337 struct of_genpd_provider {
1338 struct list_head link;
1339 struct device_node *node;
1340 genpd_xlate_t xlate;
1344 /* List of registered PM domain providers. */
1345 static LIST_HEAD(of_genpd_providers);
1346 /* Mutex to protect the list above. */
1347 static DEFINE_MUTEX(of_genpd_mutex);
1350 * __of_genpd_xlate_simple() - Xlate function for direct node-domain mapping
1351 * @genpdspec: OF phandle args to map into a PM domain
1352 * @data: xlate function private data - pointer to struct generic_pm_domain
1354 * This is a generic xlate function that can be used to model PM domains that
1355 * have their own device tree nodes. The private data of xlate function needs
1356 * to be a valid pointer to struct generic_pm_domain.
1358 struct generic_pm_domain *__of_genpd_xlate_simple(
1359 struct of_phandle_args *genpdspec,
1362 if (genpdspec->args_count != 0)
1363 return ERR_PTR(-EINVAL);
1366 EXPORT_SYMBOL_GPL(__of_genpd_xlate_simple);
1369 * __of_genpd_xlate_onecell() - Xlate function using a single index.
1370 * @genpdspec: OF phandle args to map into a PM domain
1371 * @data: xlate function private data - pointer to struct genpd_onecell_data
1373 * This is a generic xlate function that can be used to model simple PM domain
1374 * controllers that have one device tree node and provide multiple PM domains.
1375 * A single cell is used as an index into an array of PM domains specified in
1376 * the genpd_onecell_data struct when registering the provider.
1378 struct generic_pm_domain *__of_genpd_xlate_onecell(
1379 struct of_phandle_args *genpdspec,
1382 struct genpd_onecell_data *genpd_data = data;
1383 unsigned int idx = genpdspec->args[0];
1385 if (genpdspec->args_count != 1)
1386 return ERR_PTR(-EINVAL);
1388 if (idx >= genpd_data->num_domains) {
1389 pr_err("%s: invalid domain index %u\n", __func__, idx);
1390 return ERR_PTR(-EINVAL);
1393 if (!genpd_data->domains[idx])
1394 return ERR_PTR(-ENOENT);
1396 return genpd_data->domains[idx];
1398 EXPORT_SYMBOL_GPL(__of_genpd_xlate_onecell);
1401 * __of_genpd_add_provider() - Register a PM domain provider for a node
1402 * @np: Device node pointer associated with the PM domain provider.
1403 * @xlate: Callback for decoding PM domain from phandle arguments.
1404 * @data: Context pointer for @xlate callback.
1406 int __of_genpd_add_provider(struct device_node *np, genpd_xlate_t xlate,
1409 struct of_genpd_provider *cp;
1411 cp = kzalloc(sizeof(*cp), GFP_KERNEL);
1415 cp->node = of_node_get(np);
1419 mutex_lock(&of_genpd_mutex);
1420 list_add(&cp->link, &of_genpd_providers);
1421 mutex_unlock(&of_genpd_mutex);
1422 pr_debug("Added domain provider from %s\n", np->full_name);
1426 EXPORT_SYMBOL_GPL(__of_genpd_add_provider);
1429 * of_genpd_del_provider() - Remove a previously registered PM domain provider
1430 * @np: Device node pointer associated with the PM domain provider
1432 void of_genpd_del_provider(struct device_node *np)
1434 struct of_genpd_provider *cp;
1436 mutex_lock(&of_genpd_mutex);
1437 list_for_each_entry(cp, &of_genpd_providers, link) {
1438 if (cp->node == np) {
1439 list_del(&cp->link);
1440 of_node_put(cp->node);
1445 mutex_unlock(&of_genpd_mutex);
1447 EXPORT_SYMBOL_GPL(of_genpd_del_provider);
1450 * of_genpd_get_from_provider() - Look-up PM domain
1451 * @genpdspec: OF phandle args to use for look-up
1453 * Looks for a PM domain provider under the node specified by @genpdspec and if
1454 * found, uses xlate function of the provider to map phandle args to a PM
1457 * Returns a valid pointer to struct generic_pm_domain on success or ERR_PTR()
1460 struct generic_pm_domain *of_genpd_get_from_provider(
1461 struct of_phandle_args *genpdspec)
1463 struct generic_pm_domain *genpd = ERR_PTR(-ENOENT);
1464 struct of_genpd_provider *provider;
1466 mutex_lock(&of_genpd_mutex);
1468 /* Check if we have such a provider in our array */
1469 list_for_each_entry(provider, &of_genpd_providers, link) {
1470 if (provider->node == genpdspec->np)
1471 genpd = provider->xlate(genpdspec, provider->data);
1476 mutex_unlock(&of_genpd_mutex);
1480 EXPORT_SYMBOL_GPL(of_genpd_get_from_provider);
1483 * genpd_dev_pm_detach - Detach a device from its PM domain.
1484 * @dev: Device to detach.
1485 * @power_off: Currently not used
1487 * Try to locate a corresponding generic PM domain, which the device was
1488 * attached to previously. If such is found, the device is detached from it.
1490 static void genpd_dev_pm_detach(struct device *dev, bool power_off)
1492 struct generic_pm_domain *pd;
1496 pd = pm_genpd_lookup_dev(dev);
1500 dev_dbg(dev, "removing from PM domain %s\n", pd->name);
1502 for (i = 1; i < GENPD_RETRY_MAX_MS; i <<= 1) {
1503 ret = pm_genpd_remove_device(pd, dev);
1512 dev_err(dev, "failed to remove from PM domain %s: %d",
1517 /* Check if PM domain can be powered off after removing this device. */
1518 genpd_queue_power_off_work(pd);
1521 static void genpd_dev_pm_sync(struct device *dev)
1523 struct generic_pm_domain *pd;
1525 pd = dev_to_genpd(dev);
1529 genpd_queue_power_off_work(pd);
1533 * genpd_dev_pm_attach - Attach a device to its PM domain using DT.
1534 * @dev: Device to attach.
1536 * Parse device's OF node to find a PM domain specifier. If such is found,
1537 * attaches the device to retrieved pm_domain ops.
1539 * Both generic and legacy Samsung-specific DT bindings are supported to keep
1540 * backwards compatibility with existing DTBs.
1542 * Returns 0 on successfully attached PM domain or negative error code. Note
1543 * that if a power-domain exists for the device, but it cannot be found or
1544 * turned on, then return -EPROBE_DEFER to ensure that the device is not
1545 * probed and to re-try again later.
1547 int genpd_dev_pm_attach(struct device *dev)
1549 struct of_phandle_args pd_args;
1550 struct generic_pm_domain *pd;
1560 ret = of_parse_phandle_with_args(dev->of_node, "power-domains",
1561 "#power-domain-cells", 0, &pd_args);
1567 * Try legacy Samsung-specific bindings
1568 * (for backwards compatibility of DT ABI)
1570 pd_args.args_count = 0;
1571 pd_args.np = of_parse_phandle(dev->of_node,
1572 "samsung,power-domain", 0);
1577 pd = of_genpd_get_from_provider(&pd_args);
1578 of_node_put(pd_args.np);
1580 dev_dbg(dev, "%s() failed to find PM domain: %ld\n",
1581 __func__, PTR_ERR(pd));
1582 return -EPROBE_DEFER;
1585 dev_dbg(dev, "adding to PM domain %s\n", pd->name);
1587 for (i = 1; i < GENPD_RETRY_MAX_MS; i <<= 1) {
1588 ret = pm_genpd_add_device(pd, dev);
1597 dev_err(dev, "failed to add to PM domain %s: %d",
1602 dev->pm_domain->detach = genpd_dev_pm_detach;
1603 dev->pm_domain->sync = genpd_dev_pm_sync;
1604 ret = genpd_poweron(pd);
1607 return ret ? -EPROBE_DEFER : 0;
1609 EXPORT_SYMBOL_GPL(genpd_dev_pm_attach);
1610 #endif /* CONFIG_PM_GENERIC_DOMAINS_OF */
1613 /*** debugfs support ***/
1615 #ifdef CONFIG_PM_ADVANCED_DEBUG
1616 #include <linux/pm.h>
1617 #include <linux/device.h>
1618 #include <linux/debugfs.h>
1619 #include <linux/seq_file.h>
1620 #include <linux/init.h>
1621 #include <linux/kobject.h>
1622 static struct dentry *pm_genpd_debugfs_dir;
1625 * TODO: This function is a slightly modified version of rtpm_status_show
1626 * from sysfs.c, so generalize it.
1628 static void rtpm_status_str(struct seq_file *s, struct device *dev)
1630 static const char * const status_lookup[] = {
1631 [RPM_ACTIVE] = "active",
1632 [RPM_RESUMING] = "resuming",
1633 [RPM_SUSPENDED] = "suspended",
1634 [RPM_SUSPENDING] = "suspending"
1638 if (dev->power.runtime_error)
1640 else if (dev->power.disable_depth)
1642 else if (dev->power.runtime_status < ARRAY_SIZE(status_lookup))
1643 p = status_lookup[dev->power.runtime_status];
1650 static int pm_genpd_summary_one(struct seq_file *s,
1651 struct generic_pm_domain *genpd)
1653 static const char * const status_lookup[] = {
1654 [GPD_STATE_ACTIVE] = "on",
1655 [GPD_STATE_POWER_OFF] = "off"
1657 struct pm_domain_data *pm_data;
1658 const char *kobj_path;
1659 struct gpd_link *link;
1662 ret = mutex_lock_interruptible(&genpd->lock);
1664 return -ERESTARTSYS;
1666 if (WARN_ON(genpd->status >= ARRAY_SIZE(status_lookup)))
1668 seq_printf(s, "%-30s %-15s ", genpd->name, status_lookup[genpd->status]);
1671 * Modifications on the list require holding locks on both
1672 * master and slave, so we are safe.
1673 * Also genpd->name is immutable.
1675 list_for_each_entry(link, &genpd->master_links, master_node) {
1676 seq_printf(s, "%s", link->slave->name);
1677 if (!list_is_last(&link->master_node, &genpd->master_links))
1681 list_for_each_entry(pm_data, &genpd->dev_list, list_node) {
1682 kobj_path = kobject_get_path(&pm_data->dev->kobj, GFP_KERNEL);
1683 if (kobj_path == NULL)
1686 seq_printf(s, "\n %-50s ", kobj_path);
1687 rtpm_status_str(s, pm_data->dev);
1693 mutex_unlock(&genpd->lock);
1698 static int pm_genpd_summary_show(struct seq_file *s, void *data)
1700 struct generic_pm_domain *genpd;
1703 seq_puts(s, "domain status slaves\n");
1704 seq_puts(s, " /device runtime status\n");
1705 seq_puts(s, "----------------------------------------------------------------------\n");
1707 ret = mutex_lock_interruptible(&gpd_list_lock);
1709 return -ERESTARTSYS;
1711 list_for_each_entry(genpd, &gpd_list, gpd_list_node) {
1712 ret = pm_genpd_summary_one(s, genpd);
1716 mutex_unlock(&gpd_list_lock);
1721 static int pm_genpd_summary_open(struct inode *inode, struct file *file)
1723 return single_open(file, pm_genpd_summary_show, NULL);
1726 static const struct file_operations pm_genpd_summary_fops = {
1727 .open = pm_genpd_summary_open,
1729 .llseek = seq_lseek,
1730 .release = single_release,
1733 static int __init pm_genpd_debug_init(void)
1737 pm_genpd_debugfs_dir = debugfs_create_dir("pm_genpd", NULL);
1739 if (!pm_genpd_debugfs_dir)
1742 d = debugfs_create_file("pm_genpd_summary", S_IRUGO,
1743 pm_genpd_debugfs_dir, NULL, &pm_genpd_summary_fops);
1749 late_initcall(pm_genpd_debug_init);
1751 static void __exit pm_genpd_debug_exit(void)
1753 debugfs_remove_recursive(pm_genpd_debugfs_dir);
1755 __exitcall(pm_genpd_debug_exit);
1756 #endif /* CONFIG_PM_ADVANCED_DEBUG */