Skip to content

Commit 02b9735

Browse files
committed
Merge tag 'pm+acpi-fixes-3.12-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm
Pull ACPI and power management fixes from Rafael Wysocki: "All of these commits are fixes that have emerged recently and some of them fix bugs introduced during this merge window. Specifics: 1) ACPI-based PCI hotplug (ACPIPHP) fixes related to spurious events After the recent ACPIPHP changes we've seen some interesting breakage on a system that triggers device check notifications during boot for non-existing devices. Although those notifications are really spurious, we should be able to deal with them nevertheless and that shouldn't introduce too much overhead. Four commits to make that work properly. 2) Memory hotplug and hibernation mutual exclusion rework This was maent to be a cleanup, but it happens to fix a classical ABBA deadlock between system suspend/hibernation and ACPI memory hotplug which is possible if they are started roughly at the same time. Three commits rework memory hotplug so that it doesn't acquire pm_mutex and make hibernation use device_hotplug_lock which prevents it from racing with memory hotplug. 3) ACPI Intel LPSS (Low-Power Subsystem) driver crash fix The ACPI LPSS driver crashes during boot on Apple Macbook Air with Haswell that has slightly unusual BIOS configuration in which one of the LPSS device's _CRS method doesn't return all of the information expected by the driver. Fix from Mika Westerberg, for stable. 4) ACPICA fix related to Store->ArgX operation AML interpreter fix for obscure breakage that causes AML to be executed incorrectly on some machines (observed in practice). From Bob Moore. 5) ACPI core fix for PCI ACPI device objects lookup There still are cases in which there is more than one ACPI device object matching a given PCI device and we don't choose the one that the BIOS expects us to choose, so this makes the lookup take more criteria into account in those cases. 6) Fix to prevent cpuidle from crashing in some rare cases If the result of cpuidle_get_driver() is NULL, which can happen on some systems, cpuidle_driver_ref() will crash trying to use that pointer and the Daniel Fu's fix prevents that from happening. 7) cpufreq fixes related to CPU hotplug Stephen Boyd reported a number of concurrency problems with cpufreq related to CPU hotplug which are addressed by a series of fixes from Srivatsa S Bhat and Viresh Kumar. 8) cpufreq fix for time conversion in time_in_state attribute Time conversion carried out by cpufreq when user space attempts to read /sys/devices/system/cpu/cpu*/cpufreq/stats/time_in_state won't work correcty if cputime_t doesn't map directly to jiffies. Fix from Andreas Schwab. 9) Revert of a troublesome cpufreq commit Commit 7c30ed5 (cpufreq: make sure frequency transitions are serialized) was intended to address some known concurrency problems in cpufreq related to the ordering of transitions, but unfortunately it introduced several problems of its own, so I decided to revert it now and address the original problems later in a more robust way. 10) Intel Haswell CPU models for intel_pstate from Nell Hardcastle. 11) cpufreq fixes related to system suspend/resume The recent cpufreq changes that made it preserve CPU sysfs attributes over suspend/resume cycles introduced a possible NULL pointer dereference that caused it to crash during the second attempt to suspend. Three commits from Srivatsa S Bhat fix that problem and a couple of related issues. 12) cpufreq locking fix cpufreq_policy_restore() should acquire the lock for reading, but it acquires it for writing. Fix from Lan Tianyu" * tag 'pm+acpi-fixes-3.12-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: (25 commits) cpufreq: Acquire the lock in cpufreq_policy_restore() for reading cpufreq: Prevent problems in update_policy_cpu() if last_cpu == new_cpu cpufreq: Restructure if/else block to avoid unintended behavior cpufreq: Fix crash in cpufreq-stats during suspend/resume intel_pstate: Add Haswell CPU models Revert "cpufreq: make sure frequency transitions are serialized" cpufreq: Use signed type for 'ret' variable, to store negative error values cpufreq: Remove temporary fix for race between CPU hotplug and sysfs-writes cpufreq: Synchronize the cpufreq store_*() routines with CPU hotplug cpufreq: Invoke __cpufreq_remove_dev_finish() after releasing cpu_hotplug.lock cpufreq: Split __cpufreq_remove_dev() into two parts cpufreq: Fix wrong time unit conversion cpufreq: serialize calls to __cpufreq_governor() cpufreq: don't allow governor limits to be changed when it is disabled ACPI / bind: Prefer device objects with _STA to those without it ACPI / hotplug / PCI: Avoid parent bus rescans on spurious device checks ACPI / hotplug / PCI: Use _OST to notify firmware about notify status ACPI / hotplug / PCI: Avoid doing too much for spurious notifies ACPICA: Fix for a Store->ArgX when ArgX contains a reference to a field. ACPI / hotplug / PCI: Don't trim devices before scanning the namespace ...
2 parents 75acebf + f1728fd commit 02b9735

13 files changed

Lines changed: 328 additions & 188 deletions

File tree

‎drivers/acpi/acpi_lpss.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,12 +257,13 @@ static int acpi_lpss_create_device(struct acpi_device *adev,
257257
pdata->mmio_size = resource_size(&rentry->res);
258258
pdata->mmio_base = ioremap(rentry->res.start,
259259
pdata->mmio_size);
260-
pdata->dev_desc = dev_desc;
261260
break;
262261
}
263262

264263
acpi_dev_free_resource_list(&resource_list);
265264

265+
pdata->dev_desc = dev_desc;
266+
266267
if (dev_desc->clk_required) {
267268
ret = register_device_clock(adev, pdata);
268269
if (ret) {

‎drivers/acpi/acpica/exstore.c‎

Lines changed: 102 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@ acpi_ex_store_object_to_index(union acpi_operand_object *val_desc,
5757
union acpi_operand_object *dest_desc,
5858
struct acpi_walk_state *walk_state);
5959

60+
static acpi_status
61+
acpi_ex_store_direct_to_node(union acpi_operand_object *source_desc,
62+
struct acpi_namespace_node *node,
63+
struct acpi_walk_state *walk_state);
64+
6065
/*******************************************************************************
6166
*
6267
* FUNCTION: acpi_ex_store
@@ -375,7 +380,11 @@ acpi_ex_store_object_to_index(union acpi_operand_object *source_desc,
375380
* When storing into an object the data is converted to the
376381
* target object type then stored in the object. This means
377382
* that the target object type (for an initialized target) will
378-
* not be changed by a store operation.
383+
* not be changed by a store operation. A copy_object can change
384+
* the target type, however.
385+
*
386+
* The implicit_conversion flag is set to NO/FALSE only when
387+
* storing to an arg_x -- as per the rules of the ACPI spec.
379388
*
380389
* Assumes parameters are already validated.
381390
*
@@ -399,7 +408,7 @@ acpi_ex_store_object_to_node(union acpi_operand_object *source_desc,
399408
target_type = acpi_ns_get_type(node);
400409
target_desc = acpi_ns_get_attached_object(node);
401410

402-
ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Storing %p(%s) into node %p(%s)\n",
411+
ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Storing %p (%s) to node %p (%s)\n",
403412
source_desc,
404413
acpi_ut_get_object_type_name(source_desc), node,
405414
acpi_ut_get_type_name(target_type)));
@@ -413,45 +422,30 @@ acpi_ex_store_object_to_node(union acpi_operand_object *source_desc,
413422
return_ACPI_STATUS(status);
414423
}
415424

416-
/* If no implicit conversion, drop into the default case below */
417-
418-
if ((!implicit_conversion) ||
419-
((walk_state->opcode == AML_COPY_OP) &&
420-
(target_type != ACPI_TYPE_LOCAL_REGION_FIELD) &&
421-
(target_type != ACPI_TYPE_LOCAL_BANK_FIELD) &&
422-
(target_type != ACPI_TYPE_LOCAL_INDEX_FIELD))) {
423-
/*
424-
* Force execution of default (no implicit conversion). Note:
425-
* copy_object does not perform an implicit conversion, as per the ACPI
426-
* spec -- except in case of region/bank/index fields -- because these
427-
* objects must retain their original type permanently.
428-
*/
429-
target_type = ACPI_TYPE_ANY;
430-
}
431-
432425
/* Do the actual store operation */
433426

434427
switch (target_type) {
435-
case ACPI_TYPE_BUFFER_FIELD:
436-
case ACPI_TYPE_LOCAL_REGION_FIELD:
437-
case ACPI_TYPE_LOCAL_BANK_FIELD:
438-
case ACPI_TYPE_LOCAL_INDEX_FIELD:
439-
440-
/* For fields, copy the source data to the target field. */
441-
442-
status = acpi_ex_write_data_to_field(source_desc, target_desc,
443-
&walk_state->result_obj);
444-
break;
445-
446428
case ACPI_TYPE_INTEGER:
447429
case ACPI_TYPE_STRING:
448430
case ACPI_TYPE_BUFFER:
449431
/*
450-
* These target types are all of type Integer/String/Buffer, and
451-
* therefore support implicit conversion before the store.
452-
*
453-
* Copy and/or convert the source object to a new target object
432+
* The simple data types all support implicit source operand
433+
* conversion before the store.
454434
*/
435+
436+
if ((walk_state->opcode == AML_COPY_OP) || !implicit_conversion) {
437+
/*
438+
* However, copy_object and Stores to arg_x do not perform
439+
* an implicit conversion, as per the ACPI specification.
440+
* A direct store is performed instead.
441+
*/
442+
status = acpi_ex_store_direct_to_node(source_desc, node,
443+
walk_state);
444+
break;
445+
}
446+
447+
/* Store with implicit source operand conversion support */
448+
455449
status =
456450
acpi_ex_store_object_to_object(source_desc, target_desc,
457451
&new_desc, walk_state);
@@ -465,13 +459,12 @@ acpi_ex_store_object_to_node(union acpi_operand_object *source_desc,
465459
* the Name's type to that of the value being stored in it.
466460
* source_desc reference count is incremented by attach_object.
467461
*
468-
* Note: This may change the type of the node if an explicit store
469-
* has been performed such that the node/object type has been
470-
* changed.
462+
* Note: This may change the type of the node if an explicit
463+
* store has been performed such that the node/object type
464+
* has been changed.
471465
*/
472-
status =
473-
acpi_ns_attach_object(node, new_desc,
474-
new_desc->common.type);
466+
status = acpi_ns_attach_object(node, new_desc,
467+
new_desc->common.type);
475468

476469
ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
477470
"Store %s into %s via Convert/Attach\n",
@@ -482,38 +475,83 @@ acpi_ex_store_object_to_node(union acpi_operand_object *source_desc,
482475
}
483476
break;
484477

485-
default:
486-
487-
ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
488-
"Storing [%s] (%p) directly into node [%s] (%p)"
489-
" with no implicit conversion\n",
490-
acpi_ut_get_object_type_name(source_desc),
491-
source_desc,
492-
acpi_ut_get_object_type_name(target_desc),
493-
node));
478+
case ACPI_TYPE_BUFFER_FIELD:
479+
case ACPI_TYPE_LOCAL_REGION_FIELD:
480+
case ACPI_TYPE_LOCAL_BANK_FIELD:
481+
case ACPI_TYPE_LOCAL_INDEX_FIELD:
482+
/*
483+
* For all fields, always write the source data to the target
484+
* field. Any required implicit source operand conversion is
485+
* performed in the function below as necessary. Note, field
486+
* objects must retain their original type permanently.
487+
*/
488+
status = acpi_ex_write_data_to_field(source_desc, target_desc,
489+
&walk_state->result_obj);
490+
break;
494491

492+
default:
495493
/*
496494
* No conversions for all other types. Directly store a copy of
497-
* the source object. NOTE: This is a departure from the ACPI
498-
* spec, which states "If conversion is impossible, abort the
499-
* running control method".
495+
* the source object. This is the ACPI spec-defined behavior for
496+
* the copy_object operator.
500497
*
501-
* This code implements "If conversion is impossible, treat the
502-
* Store operation as a CopyObject".
498+
* NOTE: For the Store operator, this is a departure from the
499+
* ACPI spec, which states "If conversion is impossible, abort
500+
* the running control method". Instead, this code implements
501+
* "If conversion is impossible, treat the Store operation as
502+
* a CopyObject".
503503
*/
504-
status =
505-
acpi_ut_copy_iobject_to_iobject(source_desc, &new_desc,
506-
walk_state);
507-
if (ACPI_FAILURE(status)) {
508-
return_ACPI_STATUS(status);
509-
}
510-
511-
status =
512-
acpi_ns_attach_object(node, new_desc,
513-
new_desc->common.type);
514-
acpi_ut_remove_reference(new_desc);
504+
status = acpi_ex_store_direct_to_node(source_desc, node,
505+
walk_state);
515506
break;
516507
}
517508

518509
return_ACPI_STATUS(status);
519510
}
511+
512+
/*******************************************************************************
513+
*
514+
* FUNCTION: acpi_ex_store_direct_to_node
515+
*
516+
* PARAMETERS: source_desc - Value to be stored
517+
* node - Named object to receive the value
518+
* walk_state - Current walk state
519+
*
520+
* RETURN: Status
521+
*
522+
* DESCRIPTION: "Store" an object directly to a node. This involves a copy
523+
* and an attach.
524+
*
525+
******************************************************************************/
526+
527+
static acpi_status
528+
acpi_ex_store_direct_to_node(union acpi_operand_object *source_desc,
529+
struct acpi_namespace_node *node,
530+
struct acpi_walk_state *walk_state)
531+
{
532+
acpi_status status;
533+
union acpi_operand_object *new_desc;
534+
535+
ACPI_FUNCTION_TRACE(ex_store_direct_to_node);
536+
537+
ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
538+
"Storing [%s] (%p) directly into node [%s] (%p)"
539+
" with no implicit conversion\n",
540+
acpi_ut_get_object_type_name(source_desc),
541+
source_desc, acpi_ut_get_type_name(node->type),
542+
node));
543+
544+
/* Copy the source object to a new object */
545+
546+
status =
547+
acpi_ut_copy_iobject_to_iobject(source_desc, &new_desc, walk_state);
548+
if (ACPI_FAILURE(status)) {
549+
return_ACPI_STATUS(status);
550+
}
551+
552+
/* Attach the new object to the node */
553+
554+
status = acpi_ns_attach_object(node, new_desc, new_desc->common.type);
555+
acpi_ut_remove_reference(new_desc);
556+
return_ACPI_STATUS(status);
557+
}

‎drivers/acpi/glue.c‎

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ static struct acpi_bus_type *acpi_get_bus_type(struct device *dev)
7979
return ret;
8080
}
8181

82+
#define FIND_CHILD_MIN_SCORE 1
83+
#define FIND_CHILD_MAX_SCORE 2
84+
8285
static acpi_status acpi_dev_present(acpi_handle handle, u32 lvl_not_used,
8386
void *not_used, void **ret_p)
8487
{
@@ -92,31 +95,35 @@ static acpi_status acpi_dev_present(acpi_handle handle, u32 lvl_not_used,
9295
return AE_OK;
9396
}
9497

95-
static bool acpi_extra_checks_passed(acpi_handle handle, bool is_bridge)
98+
static int do_find_child_checks(acpi_handle handle, bool is_bridge)
9699
{
100+
bool sta_present = true;
97101
unsigned long long sta;
98102
acpi_status status;
99103

100-
status = acpi_bus_get_status_handle(handle, &sta);
101-
if (ACPI_FAILURE(status) || !(sta & ACPI_STA_DEVICE_ENABLED))
102-
return false;
104+
status = acpi_evaluate_integer(handle, "_STA", NULL, &sta);
105+
if (status == AE_NOT_FOUND)
106+
sta_present = false;
107+
else if (ACPI_FAILURE(status) || !(sta & ACPI_STA_DEVICE_ENABLED))
108+
return -ENODEV;
103109

104110
if (is_bridge) {
105111
void *test = NULL;
106112

107113
/* Check if this object has at least one child device. */
108114
acpi_walk_namespace(ACPI_TYPE_DEVICE, handle, 1,
109115
acpi_dev_present, NULL, NULL, &test);
110-
return !!test;
116+
if (!test)
117+
return -ENODEV;
111118
}
112-
return true;
119+
return sta_present ? FIND_CHILD_MAX_SCORE : FIND_CHILD_MIN_SCORE;
113120
}
114121

115122
struct find_child_context {
116123
u64 addr;
117124
bool is_bridge;
118125
acpi_handle ret;
119-
bool ret_checked;
126+
int ret_score;
120127
};
121128

122129
static acpi_status do_find_child(acpi_handle handle, u32 lvl_not_used,
@@ -125,6 +132,7 @@ static acpi_status do_find_child(acpi_handle handle, u32 lvl_not_used,
125132
struct find_child_context *context = data;
126133
unsigned long long addr;
127134
acpi_status status;
135+
int score;
128136

129137
status = acpi_evaluate_integer(handle, METHOD_NAME__ADR, NULL, &addr);
130138
if (ACPI_FAILURE(status) || addr != context->addr)
@@ -144,15 +152,20 @@ static acpi_status do_find_child(acpi_handle handle, u32 lvl_not_used,
144152
* its handle if so. Second, check the same for the object that we've
145153
* just found.
146154
*/
147-
if (!context->ret_checked) {
148-
if (acpi_extra_checks_passed(context->ret, context->is_bridge))
155+
if (!context->ret_score) {
156+
score = do_find_child_checks(context->ret, context->is_bridge);
157+
if (score == FIND_CHILD_MAX_SCORE)
149158
return AE_CTRL_TERMINATE;
150159
else
151-
context->ret_checked = true;
160+
context->ret_score = score;
152161
}
153-
if (acpi_extra_checks_passed(handle, context->is_bridge)) {
162+
score = do_find_child_checks(handle, context->is_bridge);
163+
if (score == FIND_CHILD_MAX_SCORE) {
154164
context->ret = handle;
155165
return AE_CTRL_TERMINATE;
166+
} else if (score > context->ret_score) {
167+
context->ret = handle;
168+
context->ret_score = score;
156169
}
157170
return AE_OK;
158171
}

0 commit comments

Comments
 (0)