History

Merge tag 'pm+acpi-3.16-rc1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm

Pull more ACPI and power management updates from Rafael Wysocki: "These are fixups on top of the previous PM+ACPI pull request, regression fixes (ACPI hotplug, cpufreq ppc-corenet), other bug fixes (ACPI reset, cpufreq), new PM trace points for system suspend profiling and a copyright notice update. Specifics: - I didn't remember correctly that the Hans de Goede's ACPI video patches actually didn't flip the video.use_native_backlight default, although we had discussed that and decided to do that. Since I said we would do that in the previous PM+ACPI pull request, make that change for real now. - ACPI bus check notifications for PCI host bridges don't cause the bus below the host bridge to be checked for changes as they should because of a mistake in the ACPI-based PCI hotplug (ACPIPHP) subsystem that forgets to add hotplug contexts to PCI host bridge ACPI device objects. Create hotplug contexts for PCI host bridges too as appropriate. - Revert recent cpufreq commit related to the big.LITTLE cpufreq driver that breaks arm64 builds. - Fix for a regression in the ppc-corenet cpufreq driver introduced during the 3.15 cycle and causing the driver to use the remainder from do_div instead of the quotient. From Ed Swarthout. - Resets triggered by panic activate a BUG_ON() in vmalloc.c on systems where the ACPI reset register is located in memory address space. Fix from Randy Wright. - Fix for a problem with cpufreq governors that decisions made by them may be suboptimal due to the fact that deferrable timers are used by them for CPU load sampling. From Srivatsa S Bhat. - Fix for a problem with the Tegra cpufreq driver where the CPU frequency is temporarily switched to a "stable" level that is different from both the initial and target frequencies during transitions which causes udelay() to expire earlier than it should sometimes. From Viresh Kumar. - New trace points and rework of some existing trace points for system suspend/resume profiling from Todd Brandt. - Assorted cpufreq fixes and cleanups from Stratos Karafotis and Viresh Kumar. - Copyright notice update for suspend-and-cpuhotplug.txt from Srivatsa S Bhat" * tag 'pm+acpi-3.16-rc1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: ACPI / hotplug / PCI: Add hotplug contexts to PCI host bridges PM / sleep: trace events for device PM callbacks cpufreq: cpufreq-cpu0: remove dependency on THERMAL and REGULATOR cpufreq: tegra: update comment for clarity cpufreq: intel_pstate: Remove duplicate CPU ID check cpufreq: Mark CPU0 driver with CPUFREQ_NEED_INITIAL_FREQ_CHECK flag PM / Documentation: Update copyright in suspend-and-cpuhotplug.txt cpufreq: governor: remove copy_prev_load from 'struct cpu_dbs_common_info' cpufreq: governor: Be friendly towards latency-sensitive bursty workloads PM / sleep: trace events for suspend/resume cpufreq: ppc-corenet-cpu-freq: do_div use quotient Revert "cpufreq: Enable big.LITTLE cpufreq driver on arm64" cpufreq: Tegra: implement intermediate frequency callbacks cpufreq: add support for intermediate (stable) frequencies ACPI / video: Change the default for video.use_native_backlight to 1 ACPI: Fix bug when ACPI reset register is implemented in system memory

Linus Torvalds committed 12 years ago

Commit 19c19402 parents 7c574cf d715a2224 files · +437 −113Browse files

Unified · Split

24 files
  1. Documentation/cpu-freq/cpu-drivers.txt +27 −2
  2. Documentation/power/suspend-and-cpuhotplug.txt +1 −1
  3. drivers/acpi/osl.c +12 −0
  4. drivers/acpi/sleep.c +3 −0
  5. drivers/acpi/video.c +1 −1
  6. drivers/base/power/main.c +26 −4
  7. drivers/base/syscore.c +5 −0
  8. drivers/cpufreq/Kconfig +1 −1
  9. drivers/cpufreq/Kconfig.arm +1 −2
  10. drivers/cpufreq/cpufreq-cpu0.c +1 −1
  11. drivers/cpufreq/cpufreq.c +60 −7
  12. drivers/cpufreq/cpufreq_governor.c +64 −3
  13. drivers/cpufreq/cpufreq_governor.h +7 −0
  14. drivers/cpufreq/intel_pstate.c +0 −6
  15. drivers/cpufreq/ppc-corenet-cpufreq.c +5 −4
  16. drivers/cpufreq/tegra-cpufreq.c +65 −35
  17. drivers/pci/hotplug/acpiphp.h +10 −0
  18. drivers/pci/hotplug/acpiphp_glue.c +42 −18
  19. include/linux/cpufreq.h +25 −0
  20. include/trace/events/power.h +58 −26
  21. kernel/cpu.c +5 −0
  22. kernel/power/hibernate.c +3 −0
  23. kernel/power/process.c +3 −0
  24. kernel/power/suspend.c +12 −2
Documentation/cpu-freq/cpu-drivers.txt+27−2
@@ -26,6 +26,7 @@ Contents: · 25 unmodified lines
2626 1.4 target/target_index or setpolicy?
2727 1.5 target/target_index
2828 1.6 setpolicy
29+1.7 get_intermediate and target_intermediate
2930 2. Frequency Table Helpers
3031
3132
@@ -79,6 +80,10 @@ cpufreq_driver.attr - A pointer to a NULL-terminated list of · 47 unmodified lines
7980 "struct freq_attr" which allow to
8081 export values to sysfs.
8182
83+cpufreq_driver.get_intermediate
84+and target_intermediate Used to switch to stable frequency while
85+ changing CPU frequency.
86+
8287
8388 1.2 Per-CPU Initialization
8489 --------------------------
@@ -151,7 +156,7 @@ Some cpufreq-capable processors switch the frequency between certain · 66 unmodified lines
151156 limits on their own. These shall use the ->setpolicy call
152157
153158
154−1.4. target/target_index
159+1.5. target/target_index
155160 -------------
156161
157162 The target_index call has two arguments: struct cpufreq_policy *policy,
@@ -160,6 +165,9 @@ and unsigned int index (into the exposed frequency table). · 2 unmodified lines
160165 The CPUfreq driver must set the new frequency when called here. The
161166 actual frequency must be determined by freq_table[index].frequency.
162167
168+It should always restore to earlier frequency (i.e. policy->restore_freq) in
169+case of errors, even if we switched to intermediate frequency earlier.
170+
163171 Deprecated:
164172 ----------
165173 The target call has three arguments: struct cpufreq_policy *policy,
@@ -179,7 +187,7 @@ Here again the frequency table helper might assist you - see section 2 · 13 unmodified lines
179187 for details.
180188
181189
182−1.5 setpolicy
190+1.6 setpolicy
183191 ---------------
184192
185193 The setpolicy call only takes a struct cpufreq_policy *policy as
@@ -190,6 +198,23 @@ setting when policy->policy is CPUFREQ_POLICY_PERFORMANCE, and a · 4 unmodified lines
190198 powersaving-oriented setting when CPUFREQ_POLICY_POWERSAVE. Also check
191199 the reference implementation in drivers/cpufreq/longrun.c
192200
201+1.7 get_intermediate and target_intermediate
202+--------------------------------------------
203+
204+Only for drivers with target_index() and CPUFREQ_ASYNC_NOTIFICATION unset.
205+
206+get_intermediate should return a stable intermediate frequency platform wants to
207+switch to, and target_intermediate() should set CPU to to that frequency, before
208+jumping to the frequency corresponding to 'index'. Core will take care of
209+sending notifications and driver doesn't have to handle them in
210+target_intermediate() or target_index().
211+
212+Drivers can return '0' from get_intermediate() in case they don't wish to switch
213+to intermediate frequency for some target frequency. In that case core will
214+directly call ->target_index().
215+
216+NOTE: ->target_index() should restore to policy->restore_freq in case of
217+failures as core would send notifications for that.
193218
194219
195220 2. Frequency Table Helpers
Documentation/power/suspend-and-cpuhotplug.txt+1−1
@@ -1,6 +1,6 @@
11 Interaction of Suspend code (S3) with the CPU hotplug infrastructure
22
3− (C) 2011 Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
3+ (C) 2011 - 2014 Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
44
55
66 I. How does the regular CPU hotplug code differ from how the Suspend-to-RAM
drivers/acpi/osl.c+12−0
@@ -1810,6 +1810,16 @@ acpi_status __init acpi_os_initialize(void) · 1809 unmodified lines
18101810 acpi_os_map_generic_address(&acpi_gbl_FADT.xpm1b_event_block);
18111811 acpi_os_map_generic_address(&acpi_gbl_FADT.xgpe0_block);
18121812 acpi_os_map_generic_address(&acpi_gbl_FADT.xgpe1_block);
1813+ if (acpi_gbl_FADT.flags & ACPI_FADT_RESET_REGISTER) {
1814+ /*
1815+ * Use acpi_os_map_generic_address to pre-map the reset
1816+ * register if it's in system memory.
1817+ */
1818+ int rv;
1819+
1820+ rv = acpi_os_map_generic_address(&acpi_gbl_FADT.reset_register);
1821+ pr_debug(PREFIX "%s: map reset_reg status %d\n", __func__, rv);
1822+ }
18131823
18141824 return AE_OK;
18151825 }
@@ -1838,6 +1848,8 @@ acpi_status acpi_os_terminate(void) · 22 unmodified lines
18381848 acpi_os_unmap_generic_address(&acpi_gbl_FADT.xgpe0_block);
18391849 acpi_os_unmap_generic_address(&acpi_gbl_FADT.xpm1b_event_block);
18401850 acpi_os_unmap_generic_address(&acpi_gbl_FADT.xpm1a_event_block);
1851+ if (acpi_gbl_FADT.flags & ACPI_FADT_RESET_REGISTER)
1852+ acpi_os_unmap_generic_address(&acpi_gbl_FADT.reset_register);
18411853
18421854 destroy_workqueue(kacpid_wq);
18431855 destroy_workqueue(kacpi_notify_wq);
drivers/acpi/sleep.c+3−0
@@ -19,6 +19,7 @@ · 18 unmodified lines
1919 #include <linux/acpi.h>
2020 #include <linux/module.h>
2121 #include <asm/io.h>
22+#include <trace/events/power.h>
2223
2324 #include "internal.h"
2425 #include "sleep.h"
@@ -501,6 +502,7 @@ static int acpi_suspend_enter(suspend_state_t pm_state) · 476 unmodified lines
501502
502503 ACPI_FLUSH_CPU_CACHE();
503504
505+ trace_suspend_resume(TPS("acpi_suspend"), acpi_state, true);
504506 switch (acpi_state) {
505507 case ACPI_STATE_S1:
506508 barrier();
@@ -516,6 +518,7 @@ static int acpi_suspend_enter(suspend_state_t pm_state) · 9 unmodified lines
516518 pr_info(PREFIX "Low-level resume complete\n");
517519 break;
518520 }
521+ trace_suspend_resume(TPS("acpi_suspend"), acpi_state, false);
519522
520523 /* This violates the spec but is required for bug compatibility. */
521524 acpi_write_bit_register(ACPI_BITREG_SCI_ENABLE, 1);
drivers/acpi/video.c+1−1
@@ -82,7 +82,7 @@ module_param(allow_duplicates, bool, 0644); · 81 unmodified lines
8282 * For Windows 8 systems: used to decide if video module
8383 * should skip registering backlight interface of its own.
8484 */
85−static int use_native_backlight_param = -1;
85+static int use_native_backlight_param = 1;
8686 module_param_named(use_native_backlight, use_native_backlight_param, int, 0444);
8787 static bool use_native_backlight_dmi = false;
8888
drivers/base/power/main.c+26−4
@@ -214,9 +214,6 @@ static void initcall_debug_report(struct device *dev, ktime_t calltime, · 213 unmodified lines
214214 pr_info("call %s+ returned %d after %Ld usecs\n", dev_name(dev),
215215 error, (unsigned long long)nsecs >> 10);
216216 }
217−
218− trace_device_pm_report_time(dev, info, nsecs, pm_verb(state.event),
219− error);
220217 }
221218
222219 /**
@@ -387,7 +384,9 @@ static int dpm_run_callback(pm_callback_t cb, struct device *dev, · 164 unmodified lines
387384 calltime = initcall_debug_start(dev);
388385
389386 pm_dev_dbg(dev, state, info);
387+ trace_device_pm_callback_start(dev, info, state.event);
390388 error = cb(dev);
389+ trace_device_pm_callback_end(dev, error);
391390 suspend_report_result(cb, error);
392391
393392 initcall_debug_report(dev, calltime, error, state, info);
@@ -545,6 +544,7 @@ static void dpm_resume_noirq(pm_message_t state) · 151 unmodified lines
545544 struct device *dev;
546545 ktime_t starttime = ktime_get();
547546
547+ trace_suspend_resume(TPS("dpm_resume_noirq"), state.event, true);
548548 mutex_lock(&dpm_list_mtx);
549549 pm_transition = state;
550550
@@ -587,6 +587,7 @@ static void dpm_resume_noirq(pm_message_t state) · 36 unmodified lines
587587 dpm_show_time(starttime, state, "noirq");
588588 resume_device_irqs();
589589 cpuidle_resume();
590+ trace_suspend_resume(TPS("dpm_resume_noirq"), state.event, false);
590591 }
591592
592593 /**
@@ -664,6 +665,7 @@ static void dpm_resume_early(pm_message_t state) · 71 unmodified lines
664665 struct device *dev;
665666 ktime_t starttime = ktime_get();
666667
668+ trace_suspend_resume(TPS("dpm_resume_early"), state.event, true);
667669 mutex_lock(&dpm_list_mtx);
668670 pm_transition = state;
669671
@@ -703,6 +705,7 @@ static void dpm_resume_early(pm_message_t state) · 33 unmodified lines
703705 mutex_unlock(&dpm_list_mtx);
704706 async_synchronize_full();
705707 dpm_show_time(starttime, state, "early");
708+ trace_suspend_resume(TPS("dpm_resume_early"), state.event, false);
706709 }
707710
708711 /**
@@ -834,6 +837,7 @@ void dpm_resume(pm_message_t state) · 125 unmodified lines
834837 struct device *dev;
835838 ktime_t starttime = ktime_get();
836839
840+ trace_suspend_resume(TPS("dpm_resume"), state.event, true);
837841 might_sleep();
838842
839843 mutex_lock(&dpm_list_mtx);
@@ -875,6 +879,7 @@ void dpm_resume(pm_message_t state) · 35 unmodified lines
875879 dpm_show_time(starttime, state, NULL);
876880
877881 cpufreq_resume();
882+ trace_suspend_resume(TPS("dpm_resume"), state.event, false);
878883 }
879884
880885 /**
@@ -913,7 +918,9 @@ static void device_complete(struct device *dev, pm_message_t state) · 32 unmodified lines
913918
914919 if (callback) {
915920 pm_dev_dbg(dev, state, info);
921+ trace_device_pm_callback_start(dev, info, state.event);
916922 callback(dev);
923+ trace_device_pm_callback_end(dev, 0);
917924 }
918925
919926 device_unlock(dev);
@@ -932,6 +939,7 @@ void dpm_complete(pm_message_t state) · 12 unmodified lines
932939 {
933940 struct list_head list;
934941
942+ trace_suspend_resume(TPS("dpm_complete"), state.event, true);
935943 might_sleep();
936944
937945 INIT_LIST_HEAD(&list);
@@ -951,6 +959,7 @@ void dpm_complete(pm_message_t state) · 13 unmodified lines
951959 }
952960 list_splice(&list, &dpm_list);
953961 mutex_unlock(&dpm_list_mtx);
962+ trace_suspend_resume(TPS("dpm_complete"), state.event, false);
954963 }
955964
956965 /**
@@ -1086,6 +1095,7 @@ static int dpm_suspend_noirq(pm_message_t state) · 129 unmodified lines
10861095 ktime_t starttime = ktime_get();
10871096 int error = 0;
10881097
1098+ trace_suspend_resume(TPS("dpm_suspend_noirq"), state.event, true);
10891099 cpuidle_pause();
10901100 suspend_device_irqs();
10911101 mutex_lock(&dpm_list_mtx);
@@ -1126,6 +1136,7 @@ static int dpm_suspend_noirq(pm_message_t state) · 34 unmodified lines
11261136 } else {
11271137 dpm_show_time(starttime, state, "noirq");
11281138 }
1139+ trace_suspend_resume(TPS("dpm_suspend_noirq"), state.event, false);
11291140 return error;
11301141 }
11311142
@@ -1222,6 +1233,7 @@ static int dpm_suspend_late(pm_message_t state) · 90 unmodified lines
12221233 ktime_t starttime = ktime_get();
12231234 int error = 0;
12241235
1236+ trace_suspend_resume(TPS("dpm_suspend_late"), state.event, true);
12251237 mutex_lock(&dpm_list_mtx);
12261238 pm_transition = state;
12271239 async_error = 0;
@@ -1257,6 +1269,7 @@ static int dpm_suspend_late(pm_message_t state) · 29 unmodified lines
12571269 } else {
12581270 dpm_show_time(starttime, state, "late");
12591271 }
1272+ trace_suspend_resume(TPS("dpm_suspend_late"), state.event, false);
12601273 return error;
12611274 }
12621275
@@ -1295,7 +1308,9 @@ static int legacy_suspend(struct device *dev, pm_message_t state, · 32 unmodified lines
12951308
12961309 calltime = initcall_debug_start(dev);
12971310
1311+ trace_device_pm_callback_start(dev, info, state.event);
12981312 error = cb(dev, state);
1313+ trace_device_pm_callback_end(dev, error);
12991314 suspend_report_result(cb, error);
13001315
13011316 initcall_debug_report(dev, calltime, error, state, info);
@@ -1461,6 +1476,7 @@ int dpm_suspend(pm_message_t state) · 159 unmodified lines
14611476 ktime_t starttime = ktime_get();
14621477 int error = 0;
14631478
1479+ trace_suspend_resume(TPS("dpm_suspend"), state.event, true);
14641480 might_sleep();
14651481
14661482 cpufreq_suspend();
@@ -1498,6 +1514,7 @@ int dpm_suspend(pm_message_t state) · 31 unmodified lines
14981514 dpm_save_failed_step(SUSPEND_SUSPEND);
14991515 } else
15001516 dpm_show_time(starttime, state, NULL);
1517+ trace_suspend_resume(TPS("dpm_suspend"), state.event, false);
15011518 return error;
15021519 }
15031520
@@ -1549,8 +1566,11 @@ static int device_prepare(struct device *dev, pm_message_t state) · 45 unmodified lines
15491566 callback = dev->driver->pm->prepare;
15501567 }
15511568
1552− if (callback)
1569+ if (callback) {
1570+ trace_device_pm_callback_start(dev, info, state.event);
15531571 ret = callback(dev);
1572+ trace_device_pm_callback_end(dev, ret);
1573+ }
15541574
15551575 device_unlock(dev);
15561576
@@ -1582,6 +1602,7 @@ int dpm_prepare(pm_message_t state) · 25 unmodified lines
15821602 {
15831603 int error = 0;
15841604
1605+ trace_suspend_resume(TPS("dpm_prepare"), state.event, true);
15851606 might_sleep();
15861607
15871608 mutex_lock(&dpm_list_mtx);
@@ -1612,6 +1633,7 @@ int dpm_prepare(pm_message_t state) · 24 unmodified lines
16121633 put_device(dev);
16131634 }
16141635 mutex_unlock(&dpm_list_mtx);
1636+ trace_suspend_resume(TPS("dpm_prepare"), state.event, false);
16151637 return error;
16161638 }
16171639
drivers/base/syscore.c+5−0
@@ -10,6 +10,7 @@ · 9 unmodified lines
1010 #include <linux/mutex.h>
1111 #include <linux/module.h>
1212 #include <linux/interrupt.h>
13+#include <trace/events/power.h>
1314
1415 static LIST_HEAD(syscore_ops_list);
1516 static DEFINE_MUTEX(syscore_ops_lock);
@@ -49,6 +50,7 @@ int syscore_suspend(void) · 33 unmodified lines
4950 struct syscore_ops *ops;
5051 int ret = 0;
5152
53+ trace_suspend_resume(TPS("syscore_suspend"), 0, true);
5254 pr_debug("Checking wakeup interrupts\n");
5355
5456 /* Return error code if there are any wakeup interrupts pending. */
@@ -70,6 +72,7 @@ int syscore_suspend(void) · 15 unmodified lines
7072 "Interrupts enabled after %pF\n", ops->suspend);
7173 }
7274
75+ trace_suspend_resume(TPS("syscore_suspend"), 0, false);
7376 return 0;
7477
7578 err_out:
@@ -92,6 +95,7 @@ void syscore_resume(void) · 16 unmodified lines
9295 {
9396 struct syscore_ops *ops;
9497
98+ trace_suspend_resume(TPS("syscore_resume"), 0, true);
9599 WARN_ONCE(!irqs_disabled(),
96100 "Interrupts enabled before system core resume.\n");
97101
@@ -103,6 +107,7 @@ void syscore_resume(void) · 5 unmodified lines
103107 WARN_ONCE(!irqs_disabled(),
104108 "Interrupts enabled after %pF\n", ops->resume);
105109 }
110+ trace_suspend_resume(TPS("syscore_resume"), 0, false);
106111 }
107112 EXPORT_SYMBOL_GPL(syscore_resume);
108113 #endif /* CONFIG_PM_SLEEP */
drivers/cpufreq/Kconfig+1−1
@@ -185,7 +185,7 @@ config CPU_FREQ_GOV_CONSERVATIVE · 184 unmodified lines
185185
186186 config GENERIC_CPUFREQ_CPU0
187187 tristate "Generic CPU0 cpufreq driver"
188− depends on HAVE_CLK && REGULATOR && OF && THERMAL && CPU_THERMAL
188+ depends on HAVE_CLK && OF
189189 select PM_OPP
190190 help
191191 This adds a generic cpufreq driver for CPU0 frequency management.
drivers/cpufreq/Kconfig.arm+1−2
@@ -5,8 +5,7 @@ · 4 unmodified lines
55 # big LITTLE core layer and glue drivers
66 config ARM_BIG_LITTLE_CPUFREQ
77 tristate "Generic ARM big LITTLE CPUfreq driver"
8− depends on (BIG_LITTLE && ARM_CPU_TOPOLOGY) || (ARM64 && SMP)
9− depends on HAVE_CLK
8+ depends on ARM && BIG_LITTLE && ARM_CPU_TOPOLOGY && HAVE_CLK
109 select PM_OPP
1110 help
1211 This enables the Generic CPUfreq driver for ARM big.LITTLE platforms.
drivers/cpufreq/cpufreq-cpu0.c+1−1
@@ -104,7 +104,7 @@ static int cpu0_cpufreq_init(struct cpufreq_policy *policy) · 103 unmodified lines
104104 }
105105
106106 static struct cpufreq_driver cpu0_cpufreq_driver = {
107− .flags = CPUFREQ_STICKY,
107+ .flags = CPUFREQ_STICKY | CPUFREQ_NEED_INITIAL_FREQ_CHECK,
108108 .verify = cpufreq_generic_frequency_table_verify,
109109 .target_index = cpu0_set_target,
110110 .get = cpufreq_generic_get,
drivers/cpufreq/cpufreq.c+60−7
@@ -1816,20 +1816,55 @@ EXPORT_SYMBOL(cpufreq_unregister_notifier); · 1815 unmodified lines
18161816 * GOVERNORS *
18171817 *********************************************************************/
18181818
1819+/* Must set freqs->new to intermediate frequency */
1820+static int __target_intermediate(struct cpufreq_policy *policy,
1821+ struct cpufreq_freqs *freqs, int index)
1822+{
1823+ int ret;
1824+
1825+ freqs->new = cpufreq_driver->get_intermediate(policy, index);
1826+
1827+ /* We don't need to switch to intermediate freq */
1828+ if (!freqs->new)
1829+ return 0;
1830+
1831+ pr_debug("%s: cpu: %d, switching to intermediate freq: oldfreq: %u, intermediate freq: %u\n",
1832+ __func__, policy->cpu, freqs->old, freqs->new);
1833+
1834+ cpufreq_freq_transition_begin(policy, freqs);
1835+ ret = cpufreq_driver->target_intermediate(policy, index);
1836+ cpufreq_freq_transition_end(policy, freqs, ret);
1837+
1838+ if (ret)
1839+ pr_err("%s: Failed to change to intermediate frequency: %d\n",
1840+ __func__, ret);
1841+
1842+ return ret;
1843+}
1844+
18191845 static int __target_index(struct cpufreq_policy *policy,
18201846 struct cpufreq_frequency_table *freq_table, int index)
18211847 {
1822− struct cpufreq_freqs freqs;
1848+ struct cpufreq_freqs freqs = {.old = policy->cur, .flags = 0};
1849+ unsigned int intermediate_freq = 0;
18231850 int retval = -EINVAL;
18241851 bool notify;
18251852
18261853 notify = !(cpufreq_driver->flags & CPUFREQ_ASYNC_NOTIFICATION);
1827−
18281854 if (notify) {
1829− freqs.old = policy->cur;
1830− freqs.new = freq_table[index].frequency;
1831− freqs.flags = 0;
1855+ /* Handle switching to intermediate frequency */
1856+ if (cpufreq_driver->get_intermediate) {
1857+ retval = __target_intermediate(policy, &freqs, index);
1858+ if (retval)
1859+ return retval;
1860+
1861+ intermediate_freq = freqs.new;
1862+ /* Set old freq to intermediate */
1863+ if (intermediate_freq)
1864+ freqs.old = freqs.new;
1865+ }
18321866
1867+ freqs.new = freq_table[index].frequency;
18331868 pr_debug("%s: cpu: %d, oldfreq: %u, new freq: %u\n",
18341869 __func__, policy->cpu, freqs.old, freqs.new);
18351870
@@ -1841,9 +1876,23 @@ static int __target_index(struct cpufreq_policy *policy, · 5 unmodified lines
18411876 pr_err("%s: Failed to change cpu frequency: %d\n", __func__,
18421877 retval);
18431878
1844− if (notify)
1879+ if (notify) {
18451880 cpufreq_freq_transition_end(policy, &freqs, retval);
18461881
1882+ /*
1883+ * Failed after setting to intermediate freq? Driver should have
1884+ * reverted back to initial frequency and so should we. Check
1885+ * here for intermediate_freq instead of get_intermediate, in
1886+ * case we have't switched to intermediate freq at all.
1887+ */
1888+ if (unlikely(retval && intermediate_freq)) {
1889+ freqs.old = intermediate_freq;
1890+ freqs.new = policy->restore_freq;
1891+ cpufreq_freq_transition_begin(policy, &freqs);
1892+ cpufreq_freq_transition_end(policy, &freqs, 0);
1893+ }
1894+ }
1895+
18471896 return retval;
18481897 }
18491898
@@ -1875,6 +1924,9 @@ int __cpufreq_driver_target(struct cpufreq_policy *policy, · 25 unmodified lines
18751924 if (target_freq == policy->cur)
18761925 return 0;
18771926
1927+ /* Save last value to restore later on errors */
1928+ policy->restore_freq = policy->cur;
1929+
18781930 if (cpufreq_driver->target)
18791931 retval = cpufreq_driver->target(policy, target_freq, relation);
18801932 else if (cpufreq_driver->target_index) {
@@ -2361,7 +2413,8 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data) · 480 unmodified lines
23612413 !(driver_data->setpolicy || driver_data->target_index ||
23622414 driver_data->target) ||
23632415 (driver_data->setpolicy && (driver_data->target_index ||
2364− driver_data->target)))
2416+ driver_data->target)) ||
2417+ (!!driver_data->get_intermediate != !!driver_data->target_intermediate))
23652418 return -EINVAL;
23662419
23672420 pr_debug("trying to register driver %s\n", driver_data->name);
drivers/cpufreq/cpufreq_governor.c+64−3
@@ -36,14 +36,29 @@ void dbs_check_cpu(struct dbs_data *dbs_data, int cpu) · 35 unmodified lines
3636 struct od_dbs_tuners *od_tuners = dbs_data->tuners;
3737 struct cs_dbs_tuners *cs_tuners = dbs_data->tuners;
3838 struct cpufreq_policy *policy;
39+ unsigned int sampling_rate;
3940 unsigned int max_load = 0;
4041 unsigned int ignore_nice;
4142 unsigned int j;
4243
43− if (dbs_data->cdata->governor == GOV_ONDEMAND)
44+ if (dbs_data->cdata->governor == GOV_ONDEMAND) {
45+ struct od_cpu_dbs_info_s *od_dbs_info =
46+ dbs_data->cdata->get_cpu_dbs_info_s(cpu);
47+
48+ /*
49+ * Sometimes, the ondemand governor uses an additional
50+ * multiplier to give long delays. So apply this multiplier to
51+ * the 'sampling_rate', so as to keep the wake-up-from-idle
52+ * detection logic a bit conservative.
53+ */
54+ sampling_rate = od_tuners->sampling_rate;
55+ sampling_rate *= od_dbs_info->rate_mult;
56+
4457 ignore_nice = od_tuners->ignore_nice_load;
45− else
58+ } else {
59+ sampling_rate = cs_tuners->sampling_rate;
4660 ignore_nice = cs_tuners->ignore_nice_load;
61+ }
4762
4863 policy = cdbs->cur_policy;
4964
@@ -96,7 +111,46 @@ void dbs_check_cpu(struct dbs_data *dbs_data, int cpu) · 46 unmodified lines
96111 if (unlikely(!wall_time || wall_time < idle_time))
97112 continue;
98113
99− load = 100 * (wall_time - idle_time) / wall_time;
114+ /*
115+ * If the CPU had gone completely idle, and a task just woke up
116+ * on this CPU now, it would be unfair to calculate 'load' the
117+ * usual way for this elapsed time-window, because it will show
118+ * near-zero load, irrespective of how CPU intensive that task
119+ * actually is. This is undesirable for latency-sensitive bursty
120+ * workloads.
121+ *
122+ * To avoid this, we reuse the 'load' from the previous
123+ * time-window and give this task a chance to start with a
124+ * reasonably high CPU frequency. (However, we shouldn't over-do
125+ * this copy, lest we get stuck at a high load (high frequency)
126+ * for too long, even when the current system load has actually
127+ * dropped down. So we perform the copy only once, upon the
128+ * first wake-up from idle.)
129+ *
130+ * Detecting this situation is easy: the governor's deferrable
131+ * timer would not have fired during CPU-idle periods. Hence
132+ * an unusually large 'wall_time' (as compared to the sampling
133+ * rate) indicates this scenario.
134+ *
135+ * prev_load can be zero in two cases and we must recalculate it
136+ * for both cases:
137+ * - during long idle intervals
138+ * - explicitly set to zero
139+ */
140+ if (unlikely(wall_time > (2 * sampling_rate) &&
141+ j_cdbs->prev_load)) {
142+ load = j_cdbs->prev_load;
143+
144+ /*
145+ * Perform a destructive copy, to ensure that we copy
146+ * the previous load only once, upon the first wake-up
147+ * from idle.
148+ */
149+ j_cdbs->prev_load = 0;
150+ } else {
151+ load = 100 * (wall_time - idle_time) / wall_time;
152+ j_cdbs->prev_load = load;
153+ }
100154
101155 if (load > max_load)
102156 max_load = load;
@@ -318,11 +372,18 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy, · 215 unmodified lines
318372 for_each_cpu(j, policy->cpus) {
319373 struct cpu_dbs_common_info *j_cdbs =
320374 dbs_data->cdata->get_cpu_cdbs(j);
375+ unsigned int prev_load;
321376
322377 j_cdbs->cpu = j;
323378 j_cdbs->cur_policy = policy;
324379 j_cdbs->prev_cpu_idle = get_cpu_idle_time(j,
325380 &j_cdbs->prev_cpu_wall, io_busy);
381+
382+ prev_load = (unsigned int)
383+ (j_cdbs->prev_cpu_wall - j_cdbs->prev_cpu_idle);
384+ j_cdbs->prev_load = 100 * prev_load /
385+ (unsigned int) j_cdbs->prev_cpu_wall;
386+
326387 if (ignore_nice)
327388 j_cdbs->prev_cpu_nice =
328389 kcpustat_cpu(j).cpustat[CPUTIME_NICE];
drivers/cpufreq/cpufreq_governor.h+7−0
@@ -134,6 +134,13 @@ struct cpu_dbs_common_info { · 133 unmodified lines
134134 u64 prev_cpu_idle;
135135 u64 prev_cpu_wall;
136136 u64 prev_cpu_nice;
137+ /*
138+ * Used to keep track of load in the previous interval. However, when
139+ * explicitly set to zero, it is used as a flag to ensure that we copy
140+ * the previous load to the current interval only once, upon the first
141+ * wake-up from idle.
142+ */
143+ unsigned int prev_load;
137144 struct cpufreq_policy *cur_policy;
138145 struct delayed_work work;
139146 /*
drivers/cpufreq/intel_pstate.c+0−6
@@ -691,14 +691,8 @@ MODULE_DEVICE_TABLE(x86cpu, intel_pstate_cpu_ids); · 690 unmodified lines
691691
692692 static int intel_pstate_init_cpu(unsigned int cpunum)
693693 {
694−
695− const struct x86_cpu_id *id;
696694 struct cpudata *cpu;
697695
698− id = x86_match_cpu(intel_pstate_cpu_ids);
699− if (!id)
700− return -ENODEV;
701−
702696 all_cpu_data[cpunum] = kzalloc(sizeof(struct cpudata), GFP_KERNEL);
703697 if (!all_cpu_data[cpunum])
704698 return -ENOMEM;
drivers/cpufreq/ppc-corenet-cpufreq.c+5−4
@@ -138,7 +138,7 @@ static int corenet_cpufreq_cpu_init(struct cpufreq_policy *policy) · 137 unmodified lines
138138 struct cpufreq_frequency_table *table;
139139 struct cpu_data *data;
140140 unsigned int cpu = policy->cpu;
141− u64 transition_latency_hz;
141+ u64 u64temp;
142142
143143 np = of_get_cpu_node(cpu, NULL);
144144 if (!np)
@@ -206,9 +206,10 @@ static int corenet_cpufreq_cpu_init(struct cpufreq_policy *policy) · 61 unmodified lines
206206 for_each_cpu(i, per_cpu(cpu_mask, cpu))
207207 per_cpu(cpu_data, i) = data;
208208
209− transition_latency_hz = 12ULL * NSEC_PER_SEC;
210− policy->cpuinfo.transition_latency =
211− do_div(transition_latency_hz, fsl_get_sys_freq());
209+ /* Minimum transition latency is 12 platform clocks */
210+ u64temp = 12ULL * NSEC_PER_SEC;
211+ do_div(u64temp, fsl_get_sys_freq());
212+ policy->cpuinfo.transition_latency = u64temp + 1;
212213
213214 of_node_put(np);
214215
drivers/cpufreq/tegra-cpufreq.c+65−35
@@ -45,46 +45,54 @@ static struct clk *cpu_clk; · 44 unmodified lines
4545 static struct clk *pll_x_clk;
4646 static struct clk *pll_p_clk;
4747 static struct clk *emc_clk;
48+static bool pll_x_prepared;
4849
49−static int tegra_cpu_clk_set_rate(unsigned long rate)
50+static unsigned int tegra_get_intermediate(struct cpufreq_policy *policy,
51+ unsigned int index)
52+{
53+ unsigned int ifreq = clk_get_rate(pll_p_clk) / 1000;
54+
55+ /*
56+ * Don't switch to intermediate freq if:
57+ * - we are already at it, i.e. policy->cur == ifreq
58+ * - index corresponds to ifreq
59+ */
60+ if ((freq_table[index].frequency == ifreq) || (policy->cur == ifreq))
61+ return 0;
62+
63+ return ifreq;
64+}
65+
66+static int tegra_target_intermediate(struct cpufreq_policy *policy,
67+ unsigned int index)
5068 {
5169 int ret;
5270
5371 /*
5472 * Take an extra reference to the main pll so it doesn't turn
55− * off when we move the cpu off of it
73+ * off when we move the cpu off of it as enabling it again while we
74+ * switch to it from tegra_target() would take additional time.
75+ *
76+ * When target-freq is equal to intermediate freq we don't need to
77+ * switch to an intermediate freq and so this routine isn't called.
78+ * Also, we wouldn't be using pll_x anymore and must not take extra
79+ * reference to it, as it can be disabled now to save some power.
5680 */
5781 clk_prepare_enable(pll_x_clk);
5882
5983 ret = clk_set_parent(cpu_clk, pll_p_clk);
60− if (ret) {
61− pr_err("Failed to switch cpu to clock pll_p\n");
62− goto out;
63− }
64−
65− if (rate == clk_get_rate(pll_p_clk))
66− goto out;
67−
68− ret = clk_set_rate(pll_x_clk, rate);
69− if (ret) {
70− pr_err("Failed to change pll_x to %lu\n", rate);
71− goto out;
72− }
73−
74− ret = clk_set_parent(cpu_clk, pll_x_clk);
75− if (ret) {
76− pr_err("Failed to switch cpu to clock pll_x\n");
77− goto out;
78− }
84+ if (ret)
85+ clk_disable_unprepare(pll_x_clk);
86+ else
87+ pll_x_prepared = true;
7988
80−out:
81− clk_disable_unprepare(pll_x_clk);
8289 return ret;
8390 }
8491
8592 static int tegra_target(struct cpufreq_policy *policy, unsigned int index)
8693 {
8794 unsigned long rate = freq_table[index].frequency;
95+ unsigned int ifreq = clk_get_rate(pll_p_clk) / 1000;
8896 int ret = 0;
8997
9098 /*
@@ -98,10 +106,30 @@ static int tegra_target(struct cpufreq_policy *policy, unsigned int index) · 7 unmodified lines
98106 else
99107 clk_set_rate(emc_clk, 100000000); /* emc 50Mhz */
100108
101− ret = tegra_cpu_clk_set_rate(rate * 1000);
109+ /*
110+ * target freq == pll_p, don't need to take extra reference to pll_x_clk
111+ * as it isn't used anymore.
112+ */
113+ if (rate == ifreq)
114+ return clk_set_parent(cpu_clk, pll_p_clk);
115+
116+ ret = clk_set_rate(pll_x_clk, rate * 1000);
117+ /* Restore to earlier frequency on error, i.e. pll_x */
102118 if (ret)
103− pr_err("cpu-tegra: Failed to set cpu frequency to %lu kHz\n",
104− rate);
119+ pr_err("Failed to change pll_x to %lu\n", rate);
120+
121+ ret = clk_set_parent(cpu_clk, pll_x_clk);
122+ /* This shouldn't fail while changing or restoring */
123+ WARN_ON(ret);
124+
125+ /*
126+ * Drop count to pll_x clock only if we switched to intermediate freq
127+ * earlier while transitioning to a target frequency.
128+ */
129+ if (pll_x_prepared) {
130+ clk_disable_unprepare(pll_x_clk);
131+ pll_x_prepared = false;
132+ }
105133
106134 return ret;
107135 }
@@ -137,16 +165,18 @@ static int tegra_cpu_exit(struct cpufreq_policy *policy) · 29 unmodified lines
137165 }
138166
139167 static struct cpufreq_driver tegra_cpufreq_driver = {
140− .flags = CPUFREQ_NEED_INITIAL_FREQ_CHECK,
141− .verify = cpufreq_generic_frequency_table_verify,
142− .target_index = tegra_target,
143− .get = cpufreq_generic_get,
144− .init = tegra_cpu_init,
145− .exit = tegra_cpu_exit,
146− .name = "tegra",
147− .attr = cpufreq_generic_attr,
168+ .flags = CPUFREQ_NEED_INITIAL_FREQ_CHECK,
169+ .verify = cpufreq_generic_frequency_table_verify,
170+ .get_intermediate = tegra_get_intermediate,
171+ .target_intermediate = tegra_target_intermediate,
172+ .target_index = tegra_target,
173+ .get = cpufreq_generic_get,
174+ .init = tegra_cpu_init,
175+ .exit = tegra_cpu_exit,
176+ .name = "tegra",
177+ .attr = cpufreq_generic_attr,
148178 #ifdef CONFIG_PM
149− .suspend = cpufreq_generic_suspend,
179+ .suspend = cpufreq_generic_suspend,
150180 #endif
151181 };
152182
drivers/pci/hotplug/acpiphp.h+10−0
@@ -142,6 +142,16 @@ static inline acpi_handle func_to_handle(struct acpiphp_func *func) · 141 unmodified lines
142142 return func_to_acpi_device(func)->handle;
143143 }
144144
145+struct acpiphp_root_context {
146+ struct acpi_hotplug_context hp;
147+ struct acpiphp_bridge *root_bridge;
148+};
149+
150+static inline struct acpiphp_root_context *to_acpiphp_root_context(struct acpi_hotplug_context *hp)
151+{
152+ return container_of(hp, struct acpiphp_root_context, hp);
153+}
154+
145155 /*
146156 * struct acpiphp_attention_info - device specific attention registration
147157 *
drivers/pci/hotplug/acpiphp_glue.c+42−18
@@ -373,17 +373,13 @@ static acpi_status acpiphp_add_context(acpi_handle handle, u32 lvl, void *data, · 372 unmodified lines
373373
374374 static struct acpiphp_bridge *acpiphp_dev_to_bridge(struct acpi_device *adev)
375375 {
376− struct acpiphp_context *context;
377376 struct acpiphp_bridge *bridge = NULL;
378377
379378 acpi_lock_hp_context();
380− context = acpiphp_get_context(adev);
381− if (context) {
382− bridge = context->bridge;
379+ if (adev->hp) {
380+ bridge = to_acpiphp_root_context(adev->hp)->root_bridge;
383381 if (bridge)
384382 get_bridge(bridge);
385−
386− acpiphp_put_context(context);
387383 }
388384 acpi_unlock_hp_context();
389385 return bridge;
@@ -881,7 +877,17 @@ void acpiphp_enumerate_slots(struct pci_bus *bus) · 491 unmodified lines
881877 */
882878 get_device(&bus->dev);
883879
884− if (!pci_is_root_bus(bridge->pci_bus)) {
880+ acpi_lock_hp_context();
881+ if (pci_is_root_bus(bridge->pci_bus)) {
882+ struct acpiphp_root_context *root_context;
883+
884+ root_context = kzalloc(sizeof(*root_context), GFP_KERNEL);
885+ if (!root_context)
886+ goto err;
887+
888+ root_context->root_bridge = bridge;
889+ acpi_set_hp_context(adev, &root_context->hp, NULL, NULL, NULL);
890+ } else {
885891 struct acpiphp_context *context;
886892
887893 /*
@@ -890,21 +896,16 @@ void acpiphp_enumerate_slots(struct pci_bus *bus) · 2 unmodified lines
890896 * parent is going to be handled by pciehp, in which case this
891897 * bridge is not interesting to us either.
892898 */
893− acpi_lock_hp_context();
894899 context = acpiphp_get_context(adev);
895− if (!context) {
896− acpi_unlock_hp_context();
897− put_device(&bus->dev);
898− pci_dev_put(bridge->pci_dev);
899− kfree(bridge);
900− return;
901− }
900+ if (!context)
901+ goto err;
902+
902903 bridge->context = context;
903904 context->bridge = bridge;
904905 /* Get a reference to the parent bridge. */
905906 get_bridge(context->func.parent);
906− acpi_unlock_hp_context();
907907 }
908+ acpi_unlock_hp_context();
908909
909910 /* Must be added to the list prior to calling acpiphp_add_context(). */
910911 mutex_lock(&bridge_mutex);
@@ -919,6 +920,30 @@ void acpiphp_enumerate_slots(struct pci_bus *bus) · 8 unmodified lines
919920 cleanup_bridge(bridge);
920921 put_bridge(bridge);
921922 }
923+ return;
924+
925+ err:
926+ acpi_unlock_hp_context();
927+ put_device(&bus->dev);
928+ pci_dev_put(bridge->pci_dev);
929+ kfree(bridge);
930+}
931+
932+void acpiphp_drop_bridge(struct acpiphp_bridge *bridge)
933+{
934+ if (pci_is_root_bus(bridge->pci_bus)) {
935+ struct acpiphp_root_context *root_context;
936+ struct acpi_device *adev;
937+
938+ acpi_lock_hp_context();
939+ adev = ACPI_COMPANION(bridge->pci_bus->bridge);
940+ root_context = to_acpiphp_root_context(adev->hp);
941+ adev->hp = NULL;
942+ acpi_unlock_hp_context();
943+ kfree(root_context);
944+ }
945+ cleanup_bridge(bridge);
946+ put_bridge(bridge);
922947 }
923948
924949 /**
@@ -936,8 +961,7 @@ void acpiphp_remove_slots(struct pci_bus *bus) · 11 unmodified lines
936961 list_for_each_entry(bridge, &bridge_list, list)
937962 if (bridge->pci_bus == bus) {
938963 mutex_unlock(&bridge_mutex);
939− cleanup_bridge(bridge);
940− put_bridge(bridge);
964+ acpiphp_drop_bridge(bridge);
941965 return;
942966 }
943967
include/linux/cpufreq.h+25−0
@@ -75,6 +75,7 @@ struct cpufreq_policy { · 74 unmodified lines
7575 unsigned int max; /* in kHz */
7676 unsigned int cur; /* in kHz, only needed if cpufreq
7777 * governors are used */
78+ unsigned int restore_freq; /* = policy->cur before transition */
7879 unsigned int suspend_freq; /* freq to set during suspend */
7980
8081 unsigned int policy; /* see above */
@@ -221,11 +222,35 @@ struct cpufreq_driver { · 140 unmodified lines
221222
222223 /* define one out of two */
223224 int (*setpolicy) (struct cpufreq_policy *policy);
225+
226+ /*
227+ * On failure, should always restore frequency to policy->restore_freq
228+ * (i.e. old freq).
229+ */
224230 int (*target) (struct cpufreq_policy *policy, /* Deprecated */
225231 unsigned int target_freq,
226232 unsigned int relation);
227233 int (*target_index) (struct cpufreq_policy *policy,
228234 unsigned int index);
235+ /*
236+ * Only for drivers with target_index() and CPUFREQ_ASYNC_NOTIFICATION
237+ * unset.
238+ *
239+ * get_intermediate should return a stable intermediate frequency
240+ * platform wants to switch to and target_intermediate() should set CPU
241+ * to to that frequency, before jumping to the frequency corresponding
242+ * to 'index'. Core will take care of sending notifications and driver
243+ * doesn't have to handle them in target_intermediate() or
244+ * target_index().
245+ *
246+ * Drivers can return '0' from get_intermediate() in case they don't
247+ * wish to switch to intermediate frequency for some target frequency.
248+ * In that case core will directly call ->target_index().
249+ */
250+ unsigned int (*get_intermediate)(struct cpufreq_policy *policy,
251+ unsigned int index);
252+ int (*target_intermediate)(struct cpufreq_policy *policy,
253+ unsigned int index);
229254
230255 /* should be defined, if possible */
231256 unsigned int (*get) (unsigned int cpu);
include/trace/events/power.h+58−26
@@ -7,6 +7,9 @@ · 6 unmodified lines
77 #include <linux/ktime.h>
88 #include <linux/pm_qos.h>
99 #include <linux/tracepoint.h>
10+#include <linux/ftrace_event.h>
11+
12+#define TPS(x) tracepoint_string(x)
1013
1114 DECLARE_EVENT_CLASS(cpu,
1215
@@ -90,6 +93,17 @@ TRACE_EVENT(pstate_sample, · 77 unmodified lines
9093 #define PWR_EVENT_EXIT -1
9194 #endif
9295
96+#define pm_verb_symbolic(event) \
97+ __print_symbolic(event, \
98+ { PM_EVENT_SUSPEND, "suspend" }, \
99+ { PM_EVENT_RESUME, "resume" }, \
100+ { PM_EVENT_FREEZE, "freeze" }, \
101+ { PM_EVENT_QUIESCE, "quiesce" }, \
102+ { PM_EVENT_HIBERNATE, "hibernate" }, \
103+ { PM_EVENT_THAW, "thaw" }, \
104+ { PM_EVENT_RESTORE, "restore" }, \
105+ { PM_EVENT_RECOVER, "recover" })
106+
93107 DEFINE_EVENT(cpu, cpu_frequency,
94108
95109 TP_PROTO(unsigned int frequency, unsigned int cpu_id),
@@ -97,58 +111,76 @@ DEFINE_EVENT(cpu, cpu_frequency, · 1 unmodified line
97111 TP_ARGS(frequency, cpu_id)
98112 );
99113
100−TRACE_EVENT(machine_suspend,
114+TRACE_EVENT(device_pm_callback_start,
101115
102− TP_PROTO(unsigned int state),
116+ TP_PROTO(struct device *dev, const char *pm_ops, int event),
103117
104− TP_ARGS(state),
118+ TP_ARGS(dev, pm_ops, event),
105119
106120 TP_STRUCT__entry(
107− __field( u32, state )
121+ __string(device, dev_name(dev))
122+ __string(driver, dev_driver_string(dev))
123+ __string(parent, dev->parent ? dev_name(dev->parent) : "none")
124+ __string(pm_ops, pm_ops ? pm_ops : "none ")
125+ __field(int, event)
108126 ),
109127
110128 TP_fast_assign(
111− __entry->state = state;
129+ __assign_str(device, dev_name(dev));
130+ __assign_str(driver, dev_driver_string(dev));
131+ __assign_str(parent,
132+ dev->parent ? dev_name(dev->parent) : "none");
133+ __assign_str(pm_ops, pm_ops ? pm_ops : "none ");
134+ __entry->event = event;
112135 ),
113136
114− TP_printk("state=%lu", (unsigned long)__entry->state)
137+ TP_printk("%s %s, parent: %s, %s[%s]", __get_str(driver),
138+ __get_str(device), __get_str(parent), __get_str(pm_ops),
139+ pm_verb_symbolic(__entry->event))
115140 );
116141
117−TRACE_EVENT(device_pm_report_time,
142+TRACE_EVENT(device_pm_callback_end,
118143
119− TP_PROTO(struct device *dev, const char *pm_ops, s64 ops_time,
120− char *pm_event_str, int error),
144+ TP_PROTO(struct device *dev, int error),
121145
122− TP_ARGS(dev, pm_ops, ops_time, pm_event_str, error),
146+ TP_ARGS(dev, error),
123147
124148 TP_STRUCT__entry(
125149 __string(device, dev_name(dev))
126150 __string(driver, dev_driver_string(dev))
127− __string(parent, dev->parent ? dev_name(dev->parent) : "none")
128− __string(pm_ops, pm_ops ? pm_ops : "none ")
129− __string(pm_event_str, pm_event_str)
130− __field(s64, ops_time)
131151 __field(int, error)
132152 ),
133153
134154 TP_fast_assign(
135− const char *tmp = dev->parent ? dev_name(dev->parent) : "none";
136− const char *tmp_i = pm_ops ? pm_ops : "none ";
137−
138155 __assign_str(device, dev_name(dev));
139156 __assign_str(driver, dev_driver_string(dev));
140− __assign_str(parent, tmp);
141− __assign_str(pm_ops, tmp_i);
142− __assign_str(pm_event_str, pm_event_str);
143− __entry->ops_time = ops_time;
144157 __entry->error = error;
145158 ),
146159
147− /* ops_str has an extra space at the end */
148− TP_printk("%s %s parent=%s state=%s ops=%snsecs=%lld err=%d",
149− __get_str(driver), __get_str(device), __get_str(parent),
150− __get_str(pm_event_str), __get_str(pm_ops),
151− __entry->ops_time, __entry->error)
160+ TP_printk("%s %s, err=%d",
161+ __get_str(driver), __get_str(device), __entry->error)
162+);
163+
164+TRACE_EVENT(suspend_resume,
165+
166+ TP_PROTO(const char *action, int val, bool start),
167+
168+ TP_ARGS(action, val, start),
169+
170+ TP_STRUCT__entry(
171+ __field(const char *, action)
172+ __field(int, val)
173+ __field(bool, start)
174+ ),
175+
176+ TP_fast_assign(
177+ __entry->action = action;
178+ __entry->val = val;
179+ __entry->start = start;
180+ ),
181+
182+ TP_printk("%s[%u] %s", __entry->action, (unsigned int)__entry->val,
183+ (__entry->start)?"begin":"end")
152184 );
153185
154186 DECLARE_EVENT_CLASS(wakeup_source,
kernel/cpu.c+5−0
@@ -20,6 +20,7 @@ · 19 unmodified lines
2020 #include <linux/gfp.h>
2121 #include <linux/suspend.h>
2222 #include <linux/lockdep.h>
23+#include <trace/events/power.h>
2324
2425 #include "smpboot.h"
2526
@@ -520,7 +521,9 @@ int disable_nonboot_cpus(void) · 494 unmodified lines
520521 for_each_online_cpu(cpu) {
521522 if (cpu == first_cpu)
522523 continue;
524+ trace_suspend_resume(TPS("CPU_OFF"), cpu, true);
523525 error = _cpu_down(cpu, 1);
526+ trace_suspend_resume(TPS("CPU_OFF"), cpu, false);
524527 if (!error)
525528 cpumask_set_cpu(cpu, frozen_cpus);
526529 else {
@@ -563,7 +566,9 @@ void __ref enable_nonboot_cpus(void) · 36 unmodified lines
563566 arch_enable_nonboot_cpus_begin();
564567
565568 for_each_cpu(cpu, frozen_cpus) {
569+ trace_suspend_resume(TPS("CPU_ON"), cpu, true);
566570 error = _cpu_up(cpu, 1);
571+ trace_suspend_resume(TPS("CPU_ON"), cpu, false);
567572 if (!error) {
568573 pr_info("CPU%d is up\n", cpu);
569574 continue;
kernel/power/hibernate.c+3−0
@@ -28,6 +28,7 @@ · 27 unmodified lines
2828 #include <linux/syscore_ops.h>
2929 #include <linux/ctype.h>
3030 #include <linux/genhd.h>
31+#include <trace/events/power.h>
3132
3233 #include "power.h"
3334
@@ -292,7 +293,9 @@ static int create_image(int platform_mode) · 258 unmodified lines
292293
293294 in_suspend = 1;
294295 save_processor_state();
296+ trace_suspend_resume(TPS("machine_suspend"), PM_EVENT_HIBERNATE, true);
295297 error = swsusp_arch_suspend();
298+ trace_suspend_resume(TPS("machine_suspend"), PM_EVENT_HIBERNATE, false);
296299 if (error)
297300 printk(KERN_ERR "PM: Error %d creating hibernation image\n",
298301 error);
kernel/power/process.c+3−0
@@ -17,6 +17,7 @@ · 16 unmodified lines
1717 #include <linux/delay.h>
1818 #include <linux/workqueue.h>
1919 #include <linux/kmod.h>
20+#include <trace/events/power.h>
2021
2122 /*
2223 * Timeout for stopping processes
@@ -175,6 +176,7 @@ void thaw_processes(void) · 152 unmodified lines
175176 struct task_struct *g, *p;
176177 struct task_struct *curr = current;
177178
179+ trace_suspend_resume(TPS("thaw_processes"), 0, true);
178180 if (pm_freezing)
179181 atomic_dec(&system_freezing_cnt);
180182 pm_freezing = false;
@@ -201,6 +203,7 @@ void thaw_processes(void) · 20 unmodified lines
201203
202204 schedule();
203205 printk("done.\n");
206+ trace_suspend_resume(TPS("thaw_processes"), 0, false);
204207 }
205208
206209 void thaw_kernel_threads(void)
kernel/power/suspend.c+12−2
@@ -177,7 +177,9 @@ static int suspend_prepare(suspend_state_t state) · 176 unmodified lines
177177 if (error)
178178 goto Finish;
179179
180+ trace_suspend_resume(TPS("freeze_processes"), 0, true);
180181 error = suspend_freeze_processes();
182+ trace_suspend_resume(TPS("freeze_processes"), 0, false);
181183 if (!error)
182184 return 0;
183185
@@ -240,7 +242,9 @@ static int suspend_enter(suspend_state_t state, bool *wakeup) · 56 unmodified lines
240242 * all the devices are suspended.
241243 */
242244 if (state == PM_SUSPEND_FREEZE) {
245+ trace_suspend_resume(TPS("machine_suspend"), state, true);
243246 freeze_enter();
247+ trace_suspend_resume(TPS("machine_suspend"), state, false);
244248 goto Platform_wake;
245249 }
246250
@@ -256,7 +260,11 @@ static int suspend_enter(suspend_state_t state, bool *wakeup) · 9 unmodified lines
256260 if (!error) {
257261 *wakeup = pm_wakeup_pending();
258262 if (!(suspend_test(TEST_CORE) || *wakeup)) {
263+ trace_suspend_resume(TPS("machine_suspend"),
264+ state, true);
259265 error = suspend_ops->enter(state);
266+ trace_suspend_resume(TPS("machine_suspend"),
267+ state, false);
260268 events_check_enabled = false;
261269 }
262270 syscore_resume();
@@ -294,7 +302,6 @@ int suspend_devices_and_enter(suspend_state_t state) · 31 unmodified lines
294302 if (need_suspend_ops(state) && !suspend_ops)
295303 return -ENOSYS;
296304
297− trace_machine_suspend(state);
298305 if (need_suspend_ops(state) && suspend_ops->begin) {
299306 error = suspend_ops->begin(state);
300307 if (error)
@@ -331,7 +338,6 @@ int suspend_devices_and_enter(suspend_state_t state) · 30 unmodified lines
331338 else if (state == PM_SUSPEND_FREEZE && freeze_ops->end)
332339 freeze_ops->end();
333340
334− trace_machine_suspend(PWR_EVENT_EXIT);
335341 return error;
336342
337343 Recover_platform:
@@ -365,6 +371,7 @@ static int enter_state(suspend_state_t state) · 27 unmodified lines
365371 {
366372 int error;
367373
374+ trace_suspend_resume(TPS("suspend_enter"), state, true);
368375 if (state == PM_SUSPEND_FREEZE) {
369376 #ifdef CONFIG_PM_DEBUG
370377 if (pm_test_level != TEST_NONE && pm_test_level <= TEST_CPUS) {
@@ -382,9 +389,11 @@ static int enter_state(suspend_state_t state) · 11 unmodified lines
382389 if (state == PM_SUSPEND_FREEZE)
383390 freeze_begin();
384391
392+ trace_suspend_resume(TPS("sync_filesystems"), 0, true);
385393 printk(KERN_INFO "PM: Syncing filesystems ... ");
386394 sys_sync();
387395 printk("done.\n");
396+ trace_suspend_resume(TPS("sync_filesystems"), 0, false);
388397
389398 pr_debug("PM: Preparing system for %s sleep\n", pm_states[state].label);
390399 error = suspend_prepare(state);
@@ -394,6 +403,7 @@ static int enter_state(suspend_state_t state) · 3 unmodified lines
394403 if (suspend_test(TEST_FREEZER))
395404 goto Finish;
396405
406+ trace_suspend_resume(TPS("suspend_enter"), state, false);
397407 pr_debug("PM: Entering %s sleep\n", pm_states[state].label);
398408 pm_restrict_gfp_mask();
399409 error = suspend_devices_and_enter(state);