History

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

Pull additional power management updates from Rafael Wysocki: "These fix an ACPI EC driver bug exposed by the recent rework of the suspend-to-idle code flow, reintroduce frequency constraints into device PM QoS (in preparation for adding QoS support to devfreq), drop a redundant field from struct cpuidle_state and clean up Kconfig in some places. Specifics: - Avoid a race condition in the ACPI EC driver that may cause systems to be unable to leave suspend-to-idle (Rafael Wysocki) - Drop the "disabled" field, which is redundant, from struct cpuidle_state (Rafael Wysocki) - Reintroduce device PM QoS frequency constraints (temporarily introduced and than dropped during the 5.4 cycle) in preparation for adding QoS support to devfreq (Leonard Crestez) - Clean up indentation (in multiple places) and the cpuidle drivers help text in Kconfig (Krzysztof Kozlowski, Randy Dunlap)" * tag 'pm-5.5-rc1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: ACPI: PM: s2idle: Rework ACPI events synchronization ACPI: EC: Rework flushing of pending work PM / devfreq: Add missing locking while setting suspend_freq PM / QoS: Restore DEV_PM_QOS_MIN/MAX_FREQUENCY PM / QoS: Reorder pm_qos/freq_qos/dev_pm_qos structs PM / QoS: Initial kunit test PM / QoS: Redefine FREQ_QOS_MAX_DEFAULT_VALUE to S32_MAX power: avs: Fix Kconfig indentation cpufreq: Fix Kconfig indentation cpuidle: minor Kconfig help text fixes cpuidle: Drop disabled field from struct cpuidle_state cpuidle: Fix Kconfig indentation

Linus Torvalds committed 6 years ago

Commit ef867c12 parents 63de374 1e4230f19 files · +324 −120Browse files

Unified · Split

19 files
  1. arch/sh/kernel/cpu/shmobile/cpuidle.c +4 −4
  2. drivers/acpi/ec.c +13 −23
  3. drivers/acpi/sleep.c +19 −7
  4. drivers/base/Kconfig +4 −0
  5. drivers/base/power/Makefile +1 −0
  6. drivers/base/power/qos-test.c +117 −0
  7. drivers/base/power/qos.c +67 −6
  8. drivers/cpufreq/Kconfig.powerpc +4 −4
  9. drivers/cpufreq/Kconfig.x86 +8 −8
  10. drivers/cpuidle/Kconfig +8 −8
  11. drivers/cpuidle/Kconfig.arm +11 −11
  12. drivers/cpuidle/cpuidle.c +1 −1
  13. drivers/cpuidle/poll_state.c +0 −1
  14. drivers/devfreq/devfreq.c +4 −0
  15. drivers/idle/intel_idle.c +3 −3
  16. drivers/power/avs/Kconfig +6 −6
  17. include/linux/cpuidle.h +1 −1
  18. include/linux/pm_qos.h +50 −36
  19. kernel/power/qos.c +3 −1
arch/sh/kernel/cpu/shmobile/cpuidle.c+4−4
@@ -67,7 +67,7 @@ static struct cpuidle_driver cpuidle_driver = { · 66 unmodified lines
6767 .enter = cpuidle_sleep_enter,
6868 .name = "C2",
6969 .desc = "SuperH Sleep Mode [SF]",
70− .disabled = true,
70+ .flags = CPUIDLE_FLAG_UNUSABLE,
7171 },
7272 {
7373 .exit_latency = 2300,
@@ -76,7 +76,7 @@ static struct cpuidle_driver cpuidle_driver = { · 2 unmodified lines
7676 .enter = cpuidle_sleep_enter,
7777 .name = "C3",
7878 .desc = "SuperH Mobile Standby Mode [SF]",
79− .disabled = true,
79+ .flags = CPUIDLE_FLAG_UNUSABLE,
8080 },
8181 },
8282 .safe_state_index = 0,
@@ -86,10 +86,10 @@ static struct cpuidle_driver cpuidle_driver = { · 3 unmodified lines
8686 int __init sh_mobile_setup_cpuidle(void)
8787 {
8888 if (sh_mobile_sleep_supported & SUSP_SH_SF)
89− cpuidle_driver.states[1].disabled = false;
89+ cpuidle_driver.states[1].flags = CPUIDLE_FLAG_NONE;
9090
9191 if (sh_mobile_sleep_supported & SUSP_SH_STANDBY)
92− cpuidle_driver.states[2].disabled = false;
92+ cpuidle_driver.states[2].flags = CPUIDLE_FLAG_NONE;
9393
9494 return cpuidle_register(&cpuidle_driver, NULL);
9595 }
drivers/acpi/ec.c+13−23
@@ -533,26 +533,10 @@ static void acpi_ec_enable_event(struct acpi_ec *ec) · 532 unmodified lines
533533 }
534534
535535 #ifdef CONFIG_PM_SLEEP
536−static bool acpi_ec_query_flushed(struct acpi_ec *ec)
536+static void __acpi_ec_flush_work(void)
537537 {
538− bool flushed;
539− unsigned long flags;
540−
541− spin_lock_irqsave(&ec->lock, flags);
542− flushed = !ec->nr_pending_queries;
543− spin_unlock_irqrestore(&ec->lock, flags);
544− return flushed;
545−}
546−
547−static void __acpi_ec_flush_event(struct acpi_ec *ec)
548−{
549− /*
550− * When ec_freeze_events is true, we need to flush events in
551− * the proper position before entering the noirq stage.
552− */
553− wait_event(ec->wait, acpi_ec_query_flushed(ec));
554− if (ec_query_wq)
555− flush_workqueue(ec_query_wq);
538+ flush_scheduled_work(); /* flush ec->work */
539+ flush_workqueue(ec_query_wq); /* flush queries */
556540 }
557541
558542 static void acpi_ec_disable_event(struct acpi_ec *ec)
@@ -562,15 +546,21 @@ static void acpi_ec_disable_event(struct acpi_ec *ec) · 3 unmodified lines
562546 spin_lock_irqsave(&ec->lock, flags);
563547 __acpi_ec_disable_event(ec);
564548 spin_unlock_irqrestore(&ec->lock, flags);
565− __acpi_ec_flush_event(ec);
549+
550+ /*
551+ * When ec_freeze_events is true, we need to flush events in
552+ * the proper position before entering the noirq stage.
553+ */
554+ __acpi_ec_flush_work();
566555 }
567556
568557 void acpi_ec_flush_work(void)
569558 {
570− if (first_ec)
571− __acpi_ec_flush_event(first_ec);
559+ /* Without ec_query_wq there is nothing to flush. */
560+ if (!ec_query_wq)
561+ return;
572562
573− flush_scheduled_work();
563+ __acpi_ec_flush_work();
574564 }
575565 #endif /* CONFIG_PM_SLEEP */
576566
drivers/acpi/sleep.c+19−7
@@ -977,6 +977,16 @@ static int acpi_s2idle_prepare_late(void) · 976 unmodified lines
977977 return 0;
978978 }
979979
980+static void acpi_s2idle_sync(void)
981+{
982+ /*
983+ * The EC driver uses the system workqueue and an additional special
984+ * one, so those need to be flushed too.
985+ */
986+ acpi_ec_flush_work();
987+ acpi_os_wait_events_complete(); /* synchronize Notify handling */
988+}
989+
980990 static void acpi_s2idle_wake(void)
981991 {
982992 /*
@@ -1001,13 +1011,8 @@ static void acpi_s2idle_wake(void) · 18 unmodified lines
10011011 * should be missed by canceling the wakeup here.
10021012 */
10031013 pm_system_cancel_wakeup();
1004− /*
1005− * The EC driver uses the system workqueue and an additional
1006− * special one, so those need to be flushed too.
1007− */
1008− acpi_os_wait_events_complete(); /* synchronize EC GPE processing */
1009− acpi_ec_flush_work();
1010− acpi_os_wait_events_complete(); /* synchronize Notify handling */
1014+
1015+ acpi_s2idle_sync();
10111016
10121017 rearm_wake_irq(acpi_sci_irq);
10131018 }
@@ -1024,6 +1029,13 @@ static void acpi_s2idle_restore_early(void) · 10 unmodified lines
10241029
10251030 static void acpi_s2idle_restore(void)
10261031 {
1032+ /*
1033+ * Drain pending events before restoring the working-state configuration
1034+ * of GPEs.
1035+ */
1036+ acpi_os_wait_events_complete(); /* synchronize GPE processing */
1037+ acpi_s2idle_sync();
1038+
10271039 s2idle_wakeup = false;
10281040
10291041 acpi_enable_all_runtime_gpes();
drivers/base/Kconfig+4−0
@@ -148,6 +148,10 @@ config DEBUG_TEST_DRIVER_REMOVE · 147 unmodified lines
148148 unusable. You should say N here unless you are explicitly looking to
149149 test this functionality.
150150
151+config PM_QOS_KUNIT_TEST
152+ bool "KUnit Test for PM QoS features"
153+ depends on KUNIT
154+
151155 config HMEM_REPORTING
152156 bool
153157 default n
drivers/base/power/Makefile+1−0
@@ -4,5 +4,6 @@ obj-$(CONFIG_PM_SLEEP) += main.o wakeup.o wakeup_stats.o · 3 unmodified lines
44 obj-$(CONFIG_PM_TRACE_RTC) += trace.o
55 obj-$(CONFIG_PM_GENERIC_DOMAINS) += domain.o domain_governor.o
66 obj-$(CONFIG_HAVE_CLK) += clock_ops.o
7+obj-$(CONFIG_PM_QOS_KUNIT_TEST) += qos-test.o
78
89 ccflags-$(CONFIG_DEBUG_DRIVER) := -DDEBUG
drivers/base/power/qos-test.c+117−0
@@ -0,0 +1,117 @@
1+// SPDX-License-Identifier: GPL-2.0
2+/*
3+ * Copyright 2019 NXP
4+ */
5+#include <kunit/test.h>
6+#include <linux/pm_qos.h>
7+
8+/* Basic test for aggregating two "min" requests */
9+static void freq_qos_test_min(struct kunit *test)
10+{
11+ struct freq_constraints qos;
12+ struct freq_qos_request req1, req2;
13+ int ret;
14+
15+ freq_constraints_init(&qos);
16+ memset(&req1, 0, sizeof(req1));
17+ memset(&req2, 0, sizeof(req2));
18+
19+ ret = freq_qos_add_request(&qos, &req1, FREQ_QOS_MIN, 1000);
20+ KUNIT_EXPECT_EQ(test, ret, 1);
21+ ret = freq_qos_add_request(&qos, &req2, FREQ_QOS_MIN, 2000);
22+ KUNIT_EXPECT_EQ(test, ret, 1);
23+
24+ KUNIT_EXPECT_EQ(test, freq_qos_read_value(&qos, FREQ_QOS_MIN), 2000);
25+
26+ ret = freq_qos_remove_request(&req2);
27+ KUNIT_EXPECT_EQ(test, ret, 1);
28+ KUNIT_EXPECT_EQ(test, freq_qos_read_value(&qos, FREQ_QOS_MIN), 1000);
29+
30+ ret = freq_qos_remove_request(&req1);
31+ KUNIT_EXPECT_EQ(test, ret, 1);
32+ KUNIT_EXPECT_EQ(test, freq_qos_read_value(&qos, FREQ_QOS_MIN),
33+ FREQ_QOS_MIN_DEFAULT_VALUE);
34+}
35+
36+/* Test that requests for MAX_DEFAULT_VALUE have no effect */
37+static void freq_qos_test_maxdef(struct kunit *test)
38+{
39+ struct freq_constraints qos;
40+ struct freq_qos_request req1, req2;
41+ int ret;
42+
43+ freq_constraints_init(&qos);
44+ memset(&req1, 0, sizeof(req1));
45+ memset(&req2, 0, sizeof(req2));
46+ KUNIT_EXPECT_EQ(test, freq_qos_read_value(&qos, FREQ_QOS_MAX),
47+ FREQ_QOS_MAX_DEFAULT_VALUE);
48+
49+ ret = freq_qos_add_request(&qos, &req1, FREQ_QOS_MAX,
50+ FREQ_QOS_MAX_DEFAULT_VALUE);
51+ KUNIT_EXPECT_EQ(test, ret, 0);
52+ ret = freq_qos_add_request(&qos, &req2, FREQ_QOS_MAX,
53+ FREQ_QOS_MAX_DEFAULT_VALUE);
54+ KUNIT_EXPECT_EQ(test, ret, 0);
55+
56+ /* Add max 1000 */
57+ ret = freq_qos_update_request(&req1, 1000);
58+ KUNIT_EXPECT_EQ(test, ret, 1);
59+ KUNIT_EXPECT_EQ(test, freq_qos_read_value(&qos, FREQ_QOS_MAX), 1000);
60+
61+ /* Add max 2000, no impact */
62+ ret = freq_qos_update_request(&req2, 2000);
63+ KUNIT_EXPECT_EQ(test, ret, 0);
64+ KUNIT_EXPECT_EQ(test, freq_qos_read_value(&qos, FREQ_QOS_MAX), 1000);
65+
66+ /* Remove max 1000, new max 2000 */
67+ ret = freq_qos_remove_request(&req1);
68+ KUNIT_EXPECT_EQ(test, ret, 1);
69+ KUNIT_EXPECT_EQ(test, freq_qos_read_value(&qos, FREQ_QOS_MAX), 2000);
70+}
71+
72+/*
73+ * Test that a freq_qos_request can be added again after removal
74+ *
75+ * This issue was solved by commit 05ff1ba412fd ("PM: QoS: Invalidate frequency
76+ * QoS requests after removal")
77+ */
78+static void freq_qos_test_readd(struct kunit *test)
79+{
80+ struct freq_constraints qos;
81+ struct freq_qos_request req;
82+ int ret;
83+
84+ freq_constraints_init(&qos);
85+ memset(&req, 0, sizeof(req));
86+ KUNIT_EXPECT_EQ(test, freq_qos_read_value(&qos, FREQ_QOS_MIN),
87+ FREQ_QOS_MIN_DEFAULT_VALUE);
88+
89+ /* Add */
90+ ret = freq_qos_add_request(&qos, &req, FREQ_QOS_MIN, 1000);
91+ KUNIT_EXPECT_EQ(test, ret, 1);
92+ KUNIT_EXPECT_EQ(test, freq_qos_read_value(&qos, FREQ_QOS_MIN), 1000);
93+
94+ /* Remove */
95+ ret = freq_qos_remove_request(&req);
96+ KUNIT_EXPECT_EQ(test, ret, 1);
97+ KUNIT_EXPECT_EQ(test, freq_qos_read_value(&qos, FREQ_QOS_MIN),
98+ FREQ_QOS_MIN_DEFAULT_VALUE);
99+
100+ /* Add again */
101+ ret = freq_qos_add_request(&qos, &req, FREQ_QOS_MIN, 2000);
102+ KUNIT_EXPECT_EQ(test, ret, 1);
103+ KUNIT_EXPECT_EQ(test, freq_qos_read_value(&qos, FREQ_QOS_MIN), 2000);
104+}
105+
106+static struct kunit_case pm_qos_test_cases[] = {
107+ KUNIT_CASE(freq_qos_test_min),
108+ KUNIT_CASE(freq_qos_test_maxdef),
109+ KUNIT_CASE(freq_qos_test_readd),
110+ {},
111+};
112+
113+static struct kunit_suite pm_qos_test_module = {
114+ .name = "qos-kunit-test",
115+ .test_cases = pm_qos_test_cases,
116+};
117+kunit_test_suite(pm_qos_test_module);
drivers/base/power/qos.c+67−6
@@ -115,10 +115,20 @@ s32 dev_pm_qos_read_value(struct device *dev, enum dev_pm_qos_req_type type) · 114 unmodified lines
115115
116116 spin_lock_irqsave(&dev->power.lock, flags);
117117
118− if (type == DEV_PM_QOS_RESUME_LATENCY) {
118+ switch (type) {
119+ case DEV_PM_QOS_RESUME_LATENCY:
119120 ret = IS_ERR_OR_NULL(qos) ? PM_QOS_RESUME_LATENCY_NO_CONSTRAINT
120121 : pm_qos_read_value(&qos->resume_latency);
121− } else {
122+ break;
123+ case DEV_PM_QOS_MIN_FREQUENCY:
124+ ret = IS_ERR_OR_NULL(qos) ? PM_QOS_MIN_FREQUENCY_DEFAULT_VALUE
125+ : freq_qos_read_value(&qos->freq, FREQ_QOS_MIN);
126+ break;
127+ case DEV_PM_QOS_MAX_FREQUENCY:
128+ ret = IS_ERR_OR_NULL(qos) ? PM_QOS_MAX_FREQUENCY_DEFAULT_VALUE
129+ : freq_qos_read_value(&qos->freq, FREQ_QOS_MAX);
130+ break;
131+ default:
122132 WARN_ON(1);
123133 ret = 0;
124134 }
@@ -159,6 +169,10 @@ static int apply_constraint(struct dev_pm_qos_request *req, · 34 unmodified lines
159169 req->dev->power.set_latency_tolerance(req->dev, value);
160170 }
161171 break;
172+ case DEV_PM_QOS_MIN_FREQUENCY:
173+ case DEV_PM_QOS_MAX_FREQUENCY:
174+ ret = freq_qos_apply(&req->data.freq, action, value);
175+ break;
162176 case DEV_PM_QOS_FLAGS:
163177 ret = pm_qos_update_flags(&qos->flags, &req->data.flr,
164178 action, value);
@@ -209,6 +223,8 @@ static int dev_pm_qos_constraints_allocate(struct device *dev) · 44 unmodified lines
209223 c->no_constraint_value = PM_QOS_LATENCY_TOLERANCE_NO_CONSTRAINT;
210224 c->type = PM_QOS_MIN;
211225
226+ freq_constraints_init(&qos->freq);
227+
212228 INIT_LIST_HEAD(&qos->flags.list);
213229
214230 spin_lock_irq(&dev->power.lock);
@@ -269,6 +285,20 @@ void dev_pm_qos_constraints_destroy(struct device *dev) · 54 unmodified lines
269285 memset(req, 0, sizeof(*req));
270286 }
271287
288+ c = &qos->freq.min_freq;
289+ plist_for_each_entry_safe(req, tmp, &c->list, data.freq.pnode) {
290+ apply_constraint(req, PM_QOS_REMOVE_REQ,
291+ PM_QOS_MIN_FREQUENCY_DEFAULT_VALUE);
292+ memset(req, 0, sizeof(*req));
293+ }
294+
295+ c = &qos->freq.max_freq;
296+ plist_for_each_entry_safe(req, tmp, &c->list, data.freq.pnode) {
297+ apply_constraint(req, PM_QOS_REMOVE_REQ,
298+ PM_QOS_MAX_FREQUENCY_DEFAULT_VALUE);
299+ memset(req, 0, sizeof(*req));
300+ }
301+
272302 f = &qos->flags;
273303 list_for_each_entry_safe(req, tmp, &f->list, data.flr.node) {
274304 apply_constraint(req, PM_QOS_REMOVE_REQ, PM_QOS_DEFAULT_VALUE);
@@ -314,11 +344,22 @@ static int __dev_pm_qos_add_request(struct device *dev, · 39 unmodified lines
314344 ret = dev_pm_qos_constraints_allocate(dev);
315345
316346 trace_dev_pm_qos_add_request(dev_name(dev), type, value);
317− if (!ret) {
318− req->dev = dev;
319− req->type = type;
347+ if (ret)
348+ return ret;
349+
350+ req->dev = dev;
351+ req->type = type;
352+ if (req->type == DEV_PM_QOS_MIN_FREQUENCY)
353+ ret = freq_qos_add_request(&dev->power.qos->freq,
354+ &req->data.freq,
355+ FREQ_QOS_MIN, value);
356+ else if (req->type == DEV_PM_QOS_MAX_FREQUENCY)
357+ ret = freq_qos_add_request(&dev->power.qos->freq,
358+ &req->data.freq,
359+ FREQ_QOS_MAX, value);
360+ else
320361 ret = apply_constraint(req, PM_QOS_ADD_REQ, value);
321− }
362+
322363 return ret;
323364 }
324365
@@ -382,6 +423,10 @@ static int __dev_pm_qos_update_request(struct dev_pm_qos_request *req, · 57 unmodified lines
382423 case DEV_PM_QOS_LATENCY_TOLERANCE:
383424 curr_value = req->data.pnode.prio;
384425 break;
426+ case DEV_PM_QOS_MIN_FREQUENCY:
427+ case DEV_PM_QOS_MAX_FREQUENCY:
428+ curr_value = req->data.freq.pnode.prio;
429+ break;
385430 case DEV_PM_QOS_FLAGS:
386431 curr_value = req->data.flr.flags;
387432 break;
@@ -507,6 +552,14 @@ int dev_pm_qos_add_notifier(struct device *dev, struct notifier_block *notifier, · 119 unmodified lines
507552 ret = blocking_notifier_chain_register(dev->power.qos->resume_latency.notifiers,
508553 notifier);
509554 break;
555+ case DEV_PM_QOS_MIN_FREQUENCY:
556+ ret = freq_qos_add_notifier(&dev->power.qos->freq,
557+ FREQ_QOS_MIN, notifier);
558+ break;
559+ case DEV_PM_QOS_MAX_FREQUENCY:
560+ ret = freq_qos_add_notifier(&dev->power.qos->freq,
561+ FREQ_QOS_MAX, notifier);
562+ break;
510563 default:
511564 WARN_ON(1);
512565 ret = -EINVAL;
@@ -546,6 +599,14 @@ int dev_pm_qos_remove_notifier(struct device *dev, · 33 unmodified lines
546599 ret = blocking_notifier_chain_unregister(dev->power.qos->resume_latency.notifiers,
547600 notifier);
548601 break;
602+ case DEV_PM_QOS_MIN_FREQUENCY:
603+ ret = freq_qos_remove_notifier(&dev->power.qos->freq,
604+ FREQ_QOS_MIN, notifier);
605+ break;
606+ case DEV_PM_QOS_MAX_FREQUENCY:
607+ ret = freq_qos_remove_notifier(&dev->power.qos->freq,
608+ FREQ_QOS_MAX, notifier);
609+ break;
549610 default:
550611 WARN_ON(1);
551612 ret = -EINVAL;
drivers/cpufreq/Kconfig.powerpc+4−4
@@ -48,9 +48,9 @@ config PPC_PASEMI_CPUFREQ · 47 unmodified lines
4848 PWRficient processors.
4949
5050 config POWERNV_CPUFREQ
51− tristate "CPU frequency scaling for IBM POWERNV platform"
52− depends on PPC_POWERNV
53− default y
54− help
51+ tristate "CPU frequency scaling for IBM POWERNV platform"
52+ depends on PPC_POWERNV
53+ default y
54+ help
5555 This adds support for CPU frequency switching on IBM POWERNV
5656 platform
drivers/cpufreq/Kconfig.x86+8−8
@@ -4,17 +4,17 @@ · 3 unmodified lines
44 #
55
66 config X86_INTEL_PSTATE
7− bool "Intel P state control"
8− depends on X86
9− select ACPI_PROCESSOR if ACPI
10− select ACPI_CPPC_LIB if X86_64 && ACPI && SCHED_MC_PRIO
11− help
12− This driver provides a P state for Intel core processors.
7+ bool "Intel P state control"
8+ depends on X86
9+ select ACPI_PROCESSOR if ACPI
10+ select ACPI_CPPC_LIB if X86_64 && ACPI && SCHED_MC_PRIO
11+ help
12+ This driver provides a P state for Intel core processors.
1313 The driver implements an internal governor and will become
14− the scaling driver and governor for Sandy bridge processors.
14+ the scaling driver and governor for Sandy bridge processors.
1515
1616 When this driver is enabled it will become the preferred
17− scaling driver for Sandy bridge processors.
17+ scaling driver for Sandy bridge processors.
1818
1919 If in doubt, say N.
2020
drivers/cpuidle/Kconfig+8−8
@@ -16,7 +16,7 @@ config CPU_IDLE · 15 unmodified lines
1616 if CPU_IDLE
1717
1818 config CPU_IDLE_MULTIPLE_DRIVERS
19− bool
19+ bool
2020
2121 config CPU_IDLE_GOV_LADDER
2222 bool "Ladder governor (for periodic timer tick)"
@@ -63,13 +63,13 @@ source "drivers/cpuidle/Kconfig.powerpc" · 40 unmodified lines
6363 endmenu
6464
6565 config HALTPOLL_CPUIDLE
66− tristate "Halt poll cpuidle driver"
67− depends on X86 && KVM_GUEST
68− default y
69− help
70− This option enables halt poll cpuidle driver, which allows to poll
71− before halting in the guest (more efficient than polling in the
72− host via halt_poll_ns for some scenarios).
66+ tristate "Halt poll cpuidle driver"
67+ depends on X86 && KVM_GUEST
68+ default y
69+ help
70+ This option enables halt poll cpuidle driver, which allows to poll
71+ before halting in the guest (more efficient than polling in the
72+ host via halt_poll_ns for some scenarios).
7373
7474 endif
7575
drivers/cpuidle/Kconfig.arm+11−11
@@ -3,15 +3,15 @@ · 2 unmodified lines
33 # ARM CPU Idle drivers
44 #
55 config ARM_CPUIDLE
6− bool "Generic ARM/ARM64 CPU idle Driver"
7− select DT_IDLE_STATES
6+ bool "Generic ARM/ARM64 CPU idle Driver"
7+ select DT_IDLE_STATES
88 select CPU_IDLE_MULTIPLE_DRIVERS
9− help
10− Select this to enable generic cpuidle driver for ARM.
11− It provides a generic idle driver whose idle states are configured
12− at run-time through DT nodes. The CPUidle suspend backend is
13− initialized by calling the CPU operations init idle hook
14− provided by architecture code.
9+ help
10+ Select this to enable generic cpuidle driver for ARM.
11+ It provides a generic idle driver whose idle states are configured
12+ at run-time through DT nodes. The CPUidle suspend backend is
13+ initialized by calling the CPU operations init idle hook
14+ provided by architecture code.
1515
1616 config ARM_PSCI_CPUIDLE
1717 bool "PSCI CPU idle Driver"
@@ -65,21 +65,21 @@ config ARM_U8500_CPUIDLE · 47 unmodified lines
6565 bool "Cpu Idle Driver for the ST-E u8500 processors"
6666 depends on ARCH_U8500 && !ARM64
6767 help
68− Select this to enable cpuidle for ST-E u8500 processors
68+ Select this to enable cpuidle for ST-E u8500 processors.
6969
7070 config ARM_AT91_CPUIDLE
7171 bool "Cpu Idle Driver for the AT91 processors"
7272 default y
7373 depends on ARCH_AT91 && !ARM64
7474 help
75− Select this to enable cpuidle for AT91 processors
75+ Select this to enable cpuidle for AT91 processors.
7676
7777 config ARM_EXYNOS_CPUIDLE
7878 bool "Cpu Idle Driver for the Exynos processors"
7979 depends on ARCH_EXYNOS && !ARM64
8080 select ARCH_NEEDS_CPU_IDLE_COUPLED if SMP
8181 help
82− Select this to enable cpuidle for Exynos processors
82+ Select this to enable cpuidle for Exynos processors.
8383
8484 config ARM_MVEBU_V7_CPUIDLE
8585 bool "CPU Idle Driver for mvebu v7 family processors"
drivers/cpuidle/cpuidle.c+1−1
@@ -572,7 +572,7 @@ static int __cpuidle_register_device(struct cpuidle_device *dev) · 571 unmodified lines
572572 return -EINVAL;
573573
574574 for (i = 0; i < drv->state_count; i++)
575− if (drv->states[i].disabled)
575+ if (drv->states[i].flags & CPUIDLE_FLAG_UNUSABLE)
576576 dev->states_usage[i].disable |= CPUIDLE_STATE_DISABLED_BY_DRIVER;
577577
578578 per_cpu(cpuidle_devices, dev->cpu) = dev;
drivers/cpuidle/poll_state.c+0−1
@@ -53,7 +53,6 @@ void cpuidle_poll_state_init(struct cpuidle_driver *drv) · 52 unmodified lines
5353 state->target_residency_ns = 0;
5454 state->power_usage = -1;
5555 state->enter = poll_idle;
56− state->disabled = false;
5756 state->flags = CPUIDLE_FLAG_POLLING;
5857 }
5958 EXPORT_SYMBOL_GPL(cpuidle_poll_state_init);
drivers/devfreq/devfreq.c+4−0
@@ -921,7 +921,9 @@ int devfreq_suspend_device(struct devfreq *devfreq) · 920 unmodified lines
921921 }
922922
923923 if (devfreq->suspend_freq) {
924+ mutex_lock(&devfreq->lock);
924925 ret = devfreq_set_target(devfreq, devfreq->suspend_freq, 0);
926+ mutex_unlock(&devfreq->lock);
925927 if (ret)
926928 return ret;
927929 }
@@ -949,7 +951,9 @@ int devfreq_resume_device(struct devfreq *devfreq) · 21 unmodified lines
949951 return 0;
950952
951953 if (devfreq->resume_freq) {
954+ mutex_lock(&devfreq->lock);
952955 ret = devfreq_set_target(devfreq, devfreq->resume_freq, 0);
956+ mutex_unlock(&devfreq->lock);
953957 if (ret)
954958 return ret;
955959 }
drivers/idle/intel_idle.c+3−3
@@ -1291,8 +1291,8 @@ static void sklh_idle_state_table_update(void) · 1290 unmodified lines
12911291 return;
12921292 }
12931293
1294− skl_cstates[5].disabled = 1; /* C8-SKL */
1295− skl_cstates[6].disabled = 1; /* C9-SKL */
1294+ skl_cstates[5].flags |= CPUIDLE_FLAG_UNUSABLE; /* C8-SKL */
1295+ skl_cstates[6].flags |= CPUIDLE_FLAG_UNUSABLE; /* C9-SKL */
12961296 }
12971297 /*
12981298 * intel_idle_state_table_update()
@@ -1355,7 +1355,7 @@ static void __init intel_idle_cpuidle_driver_init(void) · 56 unmodified lines
13551355 continue;
13561356
13571357 /* if state marked as disabled, skip it */
1358− if (cpuidle_state_table[cstate].disabled != 0) {
1358+ if (cpuidle_state_table[cstate].flags & CPUIDLE_FLAG_UNUSABLE) {
13591359 pr_debug("state %s is disabled\n",
13601360 cpuidle_state_table[cstate].name);
13611361 continue;
drivers/power/avs/Kconfig+6−6
@@ -13,9 +13,9 @@ menuconfig POWER_AVS · 12 unmodified lines
1313 Say Y here to enable Adaptive Voltage Scaling class support.
1414
1515 config ROCKCHIP_IODOMAIN
16− tristate "Rockchip IO domain support"
17− depends on POWER_AVS && ARCH_ROCKCHIP && OF
18− help
19− Say y here to enable support io domains on Rockchip SoCs. It is
20− necessary for the io domain setting of the SoC to match the
21− voltage supplied by the regulators.
16+ tristate "Rockchip IO domain support"
17+ depends on POWER_AVS && ARCH_ROCKCHIP && OF
18+ help
19+ Say y here to enable support io domains on Rockchip SoCs. It is
20+ necessary for the io domain setting of the SoC to match the
21+ voltage supplied by the regulators.
include/linux/cpuidle.h+1−1
@@ -54,7 +54,6 @@ struct cpuidle_state { · 53 unmodified lines
5454 unsigned int exit_latency; /* in US */
5555 int power_usage; /* in mW */
5656 unsigned int target_residency; /* in US */
57− bool disabled; /* disabled on all CPUs */
5857
5958 int (*enter) (struct cpuidle_device *dev,
6059 struct cpuidle_driver *drv,
@@ -77,6 +76,7 @@ struct cpuidle_state { · 16 unmodified lines
7776 #define CPUIDLE_FLAG_POLLING BIT(0) /* polling state */
7877 #define CPUIDLE_FLAG_COUPLED BIT(1) /* state applies to multiple cpus */
7978 #define CPUIDLE_FLAG_TIMER_STOP BIT(2) /* timer is stopped on this state */
79+#define CPUIDLE_FLAG_UNUSABLE BIT(3) /* avoid using this state */
8080
8181 struct cpuidle_device_kobj;
8282 struct cpuidle_state_kobj;
include/linux/pm_qos.h+50−36
@@ -34,6 +34,8 @@ enum pm_qos_flags_status { · 33 unmodified lines
3434 #define PM_QOS_RESUME_LATENCY_NO_CONSTRAINT PM_QOS_LATENCY_ANY
3535 #define PM_QOS_RESUME_LATENCY_NO_CONSTRAINT_NS PM_QOS_LATENCY_ANY_NS
3636 #define PM_QOS_LATENCY_TOLERANCE_DEFAULT_VALUE 0
37+#define PM_QOS_MIN_FREQUENCY_DEFAULT_VALUE 0
38+#define PM_QOS_MAX_FREQUENCY_DEFAULT_VALUE FREQ_QOS_MAX_DEFAULT_VALUE
3739 #define PM_QOS_LATENCY_TOLERANCE_NO_CONSTRAINT (-1)
3840
3941 #define PM_QOS_FLAG_NO_POWER_OFF (1 << 0)
@@ -49,21 +51,6 @@ struct pm_qos_flags_request { · 9 unmodified lines
4951 s32 flags; /* Do not change to 64 bit */
5052 };
5153
52−enum dev_pm_qos_req_type {
53− DEV_PM_QOS_RESUME_LATENCY = 1,
54− DEV_PM_QOS_LATENCY_TOLERANCE,
55− DEV_PM_QOS_FLAGS,
56−};
57−
58−struct dev_pm_qos_request {
59− enum dev_pm_qos_req_type type;
60− union {
61− struct plist_node pnode;
62− struct pm_qos_flags_request flr;
63− } data;
64− struct device *dev;
65−};
66−
6754 enum pm_qos_type {
6855 PM_QOS_UNITIALIZED,
6956 PM_QOS_MAX, /* return the largest value */
@@ -90,9 +77,51 @@ struct pm_qos_flags { · 20 unmodified lines
9077 s32 effective_flags; /* Do not change to 64 bit */
9178 };
9279
80+
81+#define FREQ_QOS_MIN_DEFAULT_VALUE 0
82+#define FREQ_QOS_MAX_DEFAULT_VALUE S32_MAX
83+
84+enum freq_qos_req_type {
85+ FREQ_QOS_MIN = 1,
86+ FREQ_QOS_MAX,
87+};
88+
89+struct freq_constraints {
90+ struct pm_qos_constraints min_freq;
91+ struct blocking_notifier_head min_freq_notifiers;
92+ struct pm_qos_constraints max_freq;
93+ struct blocking_notifier_head max_freq_notifiers;
94+};
95+
96+struct freq_qos_request {
97+ enum freq_qos_req_type type;
98+ struct plist_node pnode;
99+ struct freq_constraints *qos;
100+};
101+
102+
103+enum dev_pm_qos_req_type {
104+ DEV_PM_QOS_RESUME_LATENCY = 1,
105+ DEV_PM_QOS_LATENCY_TOLERANCE,
106+ DEV_PM_QOS_MIN_FREQUENCY,
107+ DEV_PM_QOS_MAX_FREQUENCY,
108+ DEV_PM_QOS_FLAGS,
109+};
110+
111+struct dev_pm_qos_request {
112+ enum dev_pm_qos_req_type type;
113+ union {
114+ struct plist_node pnode;
115+ struct pm_qos_flags_request flr;
116+ struct freq_qos_request freq;
117+ } data;
118+ struct device *dev;
119+};
120+
93121 struct dev_pm_qos {
94122 struct pm_qos_constraints resume_latency;
95123 struct pm_qos_constraints latency_tolerance;
124+ struct freq_constraints freq;
96125 struct pm_qos_flags flags;
97126 struct dev_pm_qos_request *resume_latency_req;
98127 struct dev_pm_qos_request *latency_tolerance_req;
@@ -191,6 +220,10 @@ static inline s32 dev_pm_qos_read_value(struct device *dev, · 92 unmodified lines
191220 switch (type) {
192221 case DEV_PM_QOS_RESUME_LATENCY:
193222 return PM_QOS_RESUME_LATENCY_NO_CONSTRAINT;
223+ case DEV_PM_QOS_MIN_FREQUENCY:
224+ return PM_QOS_MIN_FREQUENCY_DEFAULT_VALUE;
225+ case DEV_PM_QOS_MAX_FREQUENCY:
226+ return PM_QOS_MAX_FREQUENCY_DEFAULT_VALUE;
194227 default:
195228 WARN_ON(1);
196229 return 0;
@@ -255,27 +288,6 @@ static inline s32 dev_pm_qos_raw_resume_latency(struct device *dev) · 58 unmodified lines
255288 }
256289 #endif
257290
258−#define FREQ_QOS_MIN_DEFAULT_VALUE 0
259−#define FREQ_QOS_MAX_DEFAULT_VALUE (-1)
260−
261−enum freq_qos_req_type {
262− FREQ_QOS_MIN = 1,
263− FREQ_QOS_MAX,
264−};
265−
266−struct freq_constraints {
267− struct pm_qos_constraints min_freq;
268− struct blocking_notifier_head min_freq_notifiers;
269− struct pm_qos_constraints max_freq;
270− struct blocking_notifier_head max_freq_notifiers;
271−};
272−
273−struct freq_qos_request {
274− enum freq_qos_req_type type;
275− struct plist_node pnode;
276− struct freq_constraints *qos;
277−};
278−
279291 static inline int freq_qos_request_active(struct freq_qos_request *req)
280292 {
281293 return !IS_ERR_OR_NULL(req->qos);
@@ -291,6 +303,8 @@ int freq_qos_add_request(struct freq_constraints *qos, · 9 unmodified lines
291303 enum freq_qos_req_type type, s32 value);
292304 int freq_qos_update_request(struct freq_qos_request *req, s32 new_value);
293305 int freq_qos_remove_request(struct freq_qos_request *req);
306+int freq_qos_apply(struct freq_qos_request *req,
307+ enum pm_qos_req_action action, s32 value);
294308
295309 int freq_qos_add_notifier(struct freq_constraints *qos,
296310 enum freq_qos_req_type type,
kernel/power/qos.c+3−1
@@ -714,8 +714,10 @@ s32 freq_qos_read_value(struct freq_constraints *qos, · 713 unmodified lines
714714 * @req: Constraint request to apply.
715715 * @action: Action to perform (add/update/remove).
716716 * @value: Value to assign to the QoS request.
717+ *
718+ * This is only meant to be called from inside pm_qos, not drivers.
717719 */
718−static int freq_qos_apply(struct freq_qos_request *req,
720+int freq_qos_apply(struct freq_qos_request *req,
719721 enum pm_qos_req_action action, s32 value)
720722 {
721723 int ret;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t