Skip to content

Commit 18320f2

Browse files
committed
Merge tag 'pm+acpi-3.20-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 two reverts related to system suspend breakage by one of a recent commits, a fix for a recently introduced bug in devfreq and a bunch of other things that didn't make it into my previous pull request, but otherwise are ready to go. Specifics: - Revert two ACPI EC driver commits, one that broke system suspend on Acer Aspire S5 and one that depends on it (Rafael J Wysocki). - Fix a typo leading to an incorrect check in the exynos-ppmu devfreq driver (Dan Carpenter). - Add support for one more Broadwell CPU model to intel_idle (Len Brown). - Fix an obscure problem with state transitions related to interrupts in the speedstep-smi cpufreq driver (Mikulas Patocka). - Remove some unnecessary messages related to the "out of memory" condition from the core PM code (Quentin Lambert). - Update turbostat parameters and documentation, add support for one more Broadwell CPU model to it and modify it to skip printing disabled package C-states (Len Brown)" * tag 'pm+acpi-3.20-rc1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: PM / devfreq: event: testing the wrong variable cpufreq: speedstep-smi: enable interrupts when waiting PM / OPP / clk: Remove unnecessary OOM message Revert "ACPI / EC: Add query flushing support" Revert "ACPI / EC: Add GPE reference counting debugging messages" tools/power turbostat: support additional Broadwell model intel_idle: support additional Broadwell model tools/power turbostat: update parameters, documentation tools/power turbostat: Skip printing disabled package C-states
2 parents db3ecde + c7fb90d commit 18320f2

10 files changed

Lines changed: 293 additions & 277 deletions

File tree

‎drivers/acpi/ec.c‎

Lines changed: 18 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131

3232
/* Uncomment next line to get verbose printout */
3333
/* #define DEBUG */
34-
#define DEBUG_REF 0
3534
#define pr_fmt(fmt) "ACPI : EC: " fmt
3635

3736
#include <linux/kernel.h>
@@ -77,9 +76,7 @@ enum ec_command {
7776
* when trying to clear the EC */
7877

7978
enum {
80-
EC_FLAGS_EVENT_ENABLED, /* Event is enabled */
81-
EC_FLAGS_EVENT_PENDING, /* Event is pending */
82-
EC_FLAGS_EVENT_DETECTED, /* Event is detected */
79+
EC_FLAGS_QUERY_PENDING, /* Query is pending */
8380
EC_FLAGS_HANDLERS_INSTALLED, /* Handlers for GPE and
8481
* OpReg are installed */
8582
EC_FLAGS_STARTED, /* Driver is started */
@@ -91,13 +88,6 @@ enum {
9188
#define ACPI_EC_COMMAND_POLL 0x01 /* Available for command byte */
9289
#define ACPI_EC_COMMAND_COMPLETE 0x02 /* Completed last byte */
9390

94-
#define ec_debug_ref(ec, fmt, ...) \
95-
do { \
96-
if (DEBUG_REF) \
97-
pr_debug("%lu: " fmt, ec->reference_count, \
98-
## __VA_ARGS__); \
99-
} while (0)
100-
10191
/* ec.c is compiled in acpi namespace so this shows up as acpi.ec_delay param */
10292
static unsigned int ec_delay __read_mostly = ACPI_EC_DELAY;
10393
module_param(ec_delay, uint, 0644);
@@ -161,12 +151,6 @@ static bool acpi_ec_flushed(struct acpi_ec *ec)
161151
return ec->reference_count == 1;
162152
}
163153

164-
static bool acpi_ec_has_pending_event(struct acpi_ec *ec)
165-
{
166-
return test_bit(EC_FLAGS_EVENT_DETECTED, &ec->flags) ||
167-
test_bit(EC_FLAGS_EVENT_PENDING, &ec->flags);
168-
}
169-
170154
/* --------------------------------------------------------------------------
171155
* EC Registers
172156
* -------------------------------------------------------------------------- */
@@ -334,97 +318,34 @@ static void acpi_ec_clear_storm(struct acpi_ec *ec, u8 flag)
334318
* the flush operation is not in
335319
* progress
336320
* @ec: the EC device
337-
* @allow_event: whether event should be handled
338321
*
339322
* This function must be used before taking a new action that should hold
340323
* the reference count. If this function returns false, then the action
341324
* must be discarded or it will prevent the flush operation from being
342325
* completed.
343-
*
344-
* During flushing, QR_EC command need to pass this check when there is a
345-
* pending event, so that the reference count held for the pending event
346-
* can be decreased by the completion of the QR_EC command.
347326
*/
348-
static bool acpi_ec_submit_flushable_request(struct acpi_ec *ec,
349-
bool allow_event)
327+
static bool acpi_ec_submit_flushable_request(struct acpi_ec *ec)
350328
{
351-
if (!acpi_ec_started(ec)) {
352-
if (!allow_event || !acpi_ec_has_pending_event(ec))
353-
return false;
354-
}
329+
if (!acpi_ec_started(ec))
330+
return false;
355331
acpi_ec_submit_request(ec);
356332
return true;
357333
}
358334

359-
static void acpi_ec_submit_event(struct acpi_ec *ec)
335+
static void acpi_ec_submit_query(struct acpi_ec *ec)
360336
{
361-
if (!test_bit(EC_FLAGS_EVENT_DETECTED, &ec->flags) ||
362-
!test_bit(EC_FLAGS_EVENT_ENABLED, &ec->flags))
363-
return;
364-
/* Hold reference for pending event */
365-
if (!acpi_ec_submit_flushable_request(ec, true))
366-
return;
367-
ec_debug_ref(ec, "Increase event\n");
368-
if (!test_and_set_bit(EC_FLAGS_EVENT_PENDING, &ec->flags)) {
369-
pr_debug("***** Event query started *****\n");
337+
if (!test_and_set_bit(EC_FLAGS_QUERY_PENDING, &ec->flags)) {
338+
pr_debug("***** Event started *****\n");
370339
schedule_work(&ec->work);
371-
return;
372340
}
373-
acpi_ec_complete_request(ec);
374-
ec_debug_ref(ec, "Decrease event\n");
375341
}
376342

377-
static void acpi_ec_complete_event(struct acpi_ec *ec)
343+
static void acpi_ec_complete_query(struct acpi_ec *ec)
378344
{
379345
if (ec->curr->command == ACPI_EC_COMMAND_QUERY) {
380-
clear_bit(EC_FLAGS_EVENT_PENDING, &ec->flags);
381-
pr_debug("***** Event query stopped *****\n");
382-
/* Unhold reference for pending event */
383-
acpi_ec_complete_request(ec);
384-
ec_debug_ref(ec, "Decrease event\n");
385-
/* Check if there is another SCI_EVT detected */
386-
acpi_ec_submit_event(ec);
387-
}
388-
}
389-
390-
static void acpi_ec_submit_detection(struct acpi_ec *ec)
391-
{
392-
/* Hold reference for query submission */
393-
if (!acpi_ec_submit_flushable_request(ec, false))
394-
return;
395-
ec_debug_ref(ec, "Increase query\n");
396-
if (!test_and_set_bit(EC_FLAGS_EVENT_DETECTED, &ec->flags)) {
397-
pr_debug("***** Event detection blocked *****\n");
398-
acpi_ec_submit_event(ec);
399-
return;
346+
clear_bit(EC_FLAGS_QUERY_PENDING, &ec->flags);
347+
pr_debug("***** Event stopped *****\n");
400348
}
401-
acpi_ec_complete_request(ec);
402-
ec_debug_ref(ec, "Decrease query\n");
403-
}
404-
405-
static void acpi_ec_complete_detection(struct acpi_ec *ec)
406-
{
407-
if (ec->curr->command == ACPI_EC_COMMAND_QUERY) {
408-
clear_bit(EC_FLAGS_EVENT_DETECTED, &ec->flags);
409-
pr_debug("***** Event detetion unblocked *****\n");
410-
/* Unhold reference for query submission */
411-
acpi_ec_complete_request(ec);
412-
ec_debug_ref(ec, "Decrease query\n");
413-
}
414-
}
415-
416-
static void acpi_ec_enable_event(struct acpi_ec *ec)
417-
{
418-
unsigned long flags;
419-
420-
spin_lock_irqsave(&ec->lock, flags);
421-
set_bit(EC_FLAGS_EVENT_ENABLED, &ec->flags);
422-
/*
423-
* An event may be pending even with SCI_EVT=0, so QR_EC should
424-
* always be issued right after started.
425-
*/
426-
acpi_ec_submit_detection(ec);
427-
spin_unlock_irqrestore(&ec->lock, flags);
428349
}
429350

430351
static int ec_transaction_completed(struct acpi_ec *ec)
@@ -468,7 +389,6 @@ static void advance_transaction(struct acpi_ec *ec)
468389
t->rdata[t->ri++] = acpi_ec_read_data(ec);
469390
if (t->rlen == t->ri) {
470391
t->flags |= ACPI_EC_COMMAND_COMPLETE;
471-
acpi_ec_complete_event(ec);
472392
if (t->command == ACPI_EC_COMMAND_QUERY)
473393
pr_debug("***** Command(%s) hardware completion *****\n",
474394
acpi_ec_cmd_string(t->command));
@@ -479,7 +399,6 @@ static void advance_transaction(struct acpi_ec *ec)
479399
} else if (t->wlen == t->wi &&
480400
(status & ACPI_EC_FLAG_IBF) == 0) {
481401
t->flags |= ACPI_EC_COMMAND_COMPLETE;
482-
acpi_ec_complete_event(ec);
483402
wakeup = true;
484403
}
485404
goto out;
@@ -488,17 +407,16 @@ static void advance_transaction(struct acpi_ec *ec)
488407
!(status & ACPI_EC_FLAG_SCI) &&
489408
(t->command == ACPI_EC_COMMAND_QUERY)) {
490409
t->flags |= ACPI_EC_COMMAND_POLL;
491-
acpi_ec_complete_detection(ec);
410+
acpi_ec_complete_query(ec);
492411
t->rdata[t->ri++] = 0x00;
493412
t->flags |= ACPI_EC_COMMAND_COMPLETE;
494-
acpi_ec_complete_event(ec);
495413
pr_debug("***** Command(%s) software completion *****\n",
496414
acpi_ec_cmd_string(t->command));
497415
wakeup = true;
498416
} else if ((status & ACPI_EC_FLAG_IBF) == 0) {
499417
acpi_ec_write_cmd(ec, t->command);
500418
t->flags |= ACPI_EC_COMMAND_POLL;
501-
acpi_ec_complete_detection(ec);
419+
acpi_ec_complete_query(ec);
502420
} else
503421
goto err;
504422
goto out;
@@ -519,7 +437,7 @@ static void advance_transaction(struct acpi_ec *ec)
519437
}
520438
out:
521439
if (status & ACPI_EC_FLAG_SCI)
522-
acpi_ec_submit_detection(ec);
440+
acpi_ec_submit_query(ec);
523441
if (wakeup && in_interrupt())
524442
wake_up(&ec->wait);
525443
}
@@ -580,11 +498,10 @@ static int acpi_ec_transaction_unlocked(struct acpi_ec *ec,
580498
/* start transaction */
581499
spin_lock_irqsave(&ec->lock, tmp);
582500
/* Enable GPE for command processing (IBF=0/OBF=1) */
583-
if (!acpi_ec_submit_flushable_request(ec, true)) {
501+
if (!acpi_ec_submit_flushable_request(ec)) {
584502
ret = -EINVAL;
585503
goto unlock;
586504
}
587-
ec_debug_ref(ec, "Increase command\n");
588505
/* following two actions should be kept atomic */
589506
ec->curr = t;
590507
pr_debug("***** Command(%s) started *****\n",
@@ -600,7 +517,6 @@ static int acpi_ec_transaction_unlocked(struct acpi_ec *ec,
600517
ec->curr = NULL;
601518
/* Disable GPE for command processing (IBF=0/OBF=1) */
602519
acpi_ec_complete_request(ec);
603-
ec_debug_ref(ec, "Decrease command\n");
604520
unlock:
605521
spin_unlock_irqrestore(&ec->lock, tmp);
606522
return ret;
@@ -762,10 +678,8 @@ static void acpi_ec_start(struct acpi_ec *ec, bool resuming)
762678
if (!test_and_set_bit(EC_FLAGS_STARTED, &ec->flags)) {
763679
pr_debug("+++++ Starting EC +++++\n");
764680
/* Enable GPE for event processing (SCI_EVT=1) */
765-
if (!resuming) {
681+
if (!resuming)
766682
acpi_ec_submit_request(ec);
767-
ec_debug_ref(ec, "Increase driver\n");
768-
}
769683
pr_info("+++++ EC started +++++\n");
770684
}
771685
spin_unlock_irqrestore(&ec->lock, flags);
@@ -794,10 +708,8 @@ static void acpi_ec_stop(struct acpi_ec *ec, bool suspending)
794708
wait_event(ec->wait, acpi_ec_stopped(ec));
795709
spin_lock_irqsave(&ec->lock, flags);
796710
/* Disable GPE for event processing (SCI_EVT=1) */
797-
if (!suspending) {
711+
if (!suspending)
798712
acpi_ec_complete_request(ec);
799-
ec_debug_ref(ec, "Decrease driver\n");
800-
}
801713
clear_bit(EC_FLAGS_STARTED, &ec->flags);
802714
clear_bit(EC_FLAGS_STOPPED, &ec->flags);
803715
pr_info("+++++ EC stopped +++++\n");
@@ -967,9 +879,7 @@ static void acpi_ec_gpe_poller(struct work_struct *work)
967879
{
968880
struct acpi_ec *ec = container_of(work, struct acpi_ec, work);
969881

970-
pr_debug("***** Event poller started *****\n");
971882
acpi_ec_query(ec, NULL);
972-
pr_debug("***** Event poller stopped *****\n");
973883
}
974884

975885
static u32 acpi_ec_gpe_handler(acpi_handle gpe_device,
@@ -1039,6 +949,7 @@ static struct acpi_ec *make_acpi_ec(void)
1039949

1040950
if (!ec)
1041951
return NULL;
952+
ec->flags = 1 << EC_FLAGS_QUERY_PENDING;
1042953
mutex_init(&ec->mutex);
1043954
init_waitqueue_head(&ec->wait);
1044955
INIT_LIST_HEAD(&ec->list);
@@ -1189,7 +1100,7 @@ static int acpi_ec_add(struct acpi_device *device)
11891100
ret = ec_install_handlers(ec);
11901101

11911102
/* EC is fully operational, allow queries */
1192-
acpi_ec_enable_event(ec);
1103+
clear_bit(EC_FLAGS_QUERY_PENDING, &ec->flags);
11931104

11941105
/* Clear stale _Q events if hardware might require that */
11951106
if (EC_FLAGS_CLEAR_ON_RESUME)

‎drivers/base/firmware_class.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -855,7 +855,6 @@ fw_create_instance(struct firmware *firmware, const char *fw_name,
855855

856856
fw_priv = kzalloc(sizeof(*fw_priv), GFP_KERNEL);
857857
if (!fw_priv) {
858-
dev_err(device, "%s: kmalloc failed\n", __func__);
859858
fw_priv = ERR_PTR(-ENOMEM);
860859
goto exit;
861860
}

‎drivers/base/power/clock_ops.c‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,8 @@ static int __pm_clk_add(struct device *dev, const char *con_id,
8181
return -EINVAL;
8282

8383
ce = kzalloc(sizeof(*ce), GFP_KERNEL);
84-
if (!ce) {
85-
dev_err(dev, "Not enough memory for clock entry.\n");
84+
if (!ce)
8685
return -ENOMEM;
87-
}
8886

8987
if (con_id) {
9088
ce->con_id = kstrdup(con_id, GFP_KERNEL);

‎drivers/base/power/opp.c‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -474,10 +474,8 @@ static int _opp_add_dynamic(struct device *dev, unsigned long freq,
474474

475475
/* allocate new OPP node */
476476
new_opp = kzalloc(sizeof(*new_opp), GFP_KERNEL);
477-
if (!new_opp) {
478-
dev_warn(dev, "%s: Unable to create new OPP node\n", __func__);
477+
if (!new_opp)
479478
return -ENOMEM;
480-
}
481479

482480
/* Hold our list modification lock here */
483481
mutex_lock(&dev_opp_list_lock);
@@ -695,10 +693,8 @@ static int _opp_set_availability(struct device *dev, unsigned long freq,
695693

696694
/* keep the node allocated */
697695
new_opp = kmalloc(sizeof(*new_opp), GFP_KERNEL);
698-
if (!new_opp) {
699-
dev_warn(dev, "%s: Unable to create OPP\n", __func__);
696+
if (!new_opp)
700697
return -ENOMEM;
701-
}
702698

703699
mutex_lock(&dev_opp_list_lock);
704700

‎drivers/cpufreq/speedstep-lib.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,7 @@ unsigned int speedstep_get_freqs(enum speedstep_processor processor,
400400

401401
pr_debug("previous speed is %u\n", prev_speed);
402402

403+
preempt_disable();
403404
local_irq_save(flags);
404405

405406
/* switch to low state */
@@ -464,6 +465,8 @@ unsigned int speedstep_get_freqs(enum speedstep_processor processor,
464465

465466
out:
466467
local_irq_restore(flags);
468+
preempt_enable();
469+
467470
return ret;
468471
}
469472
EXPORT_SYMBOL_GPL(speedstep_get_freqs);

‎drivers/cpufreq/speedstep-smi.c‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ static void speedstep_set_state(unsigned int state)
156156
return;
157157

158158
/* Disable IRQs */
159+
preempt_disable();
159160
local_irq_save(flags);
160161

161162
command = (smi_sig & 0xffffff00) | (smi_cmd & 0xff);
@@ -166,9 +167,19 @@ static void speedstep_set_state(unsigned int state)
166167

167168
do {
168169
if (retry) {
170+
/*
171+
* We need to enable interrupts, otherwise the blockage
172+
* won't resolve.
173+
*
174+
* We disable preemption so that other processes don't
175+
* run. If other processes were running, they could
176+
* submit more DMA requests, making the blockage worse.
177+
*/
169178
pr_debug("retry %u, previous result %u, waiting...\n",
170179
retry, result);
180+
local_irq_enable();
171181
mdelay(retry * 50);
182+
local_irq_disable();
172183
}
173184
retry++;
174185
__asm__ __volatile__(
@@ -185,6 +196,7 @@ static void speedstep_set_state(unsigned int state)
185196

186197
/* enable IRQs */
187198
local_irq_restore(flags);
199+
preempt_enable();
188200

189201
if (new_state == state)
190202
pr_debug("change to %u MHz succeeded after %u tries "

‎drivers/devfreq/event/exynos-ppmu.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,8 +327,8 @@ static int exynos_ppmu_probe(struct platform_device *pdev)
327327

328328
for (i = 0; i < info->num_events; i++) {
329329
edev[i] = devm_devfreq_event_add_edev(&pdev->dev, &desc[i]);
330-
if (IS_ERR(edev)) {
331-
ret = PTR_ERR(edev);
330+
if (IS_ERR(edev[i])) {
331+
ret = PTR_ERR(edev[i]);
332332
dev_err(&pdev->dev,
333333
"failed to add devfreq-event device\n");
334334
goto err;

‎drivers/idle/intel_idle.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -727,6 +727,7 @@ static const struct x86_cpu_id intel_idle_ids[] = {
727727
ICPU(0x46, idle_cpu_hsw),
728728
ICPU(0x4d, idle_cpu_avn),
729729
ICPU(0x3d, idle_cpu_bdw),
730+
ICPU(0x47, idle_cpu_bdw),
730731
ICPU(0x4f, idle_cpu_bdw),
731732
ICPU(0x56, idle_cpu_bdw),
732733
{}

0 commit comments

Comments
 (0)