diff options
Diffstat (limited to 'drivers/acpi/events/evregion.c')
-rw-r--r-- | drivers/acpi/events/evregion.c | 133 |
1 files changed, 64 insertions, 69 deletions
diff --git a/drivers/acpi/events/evregion.c b/drivers/acpi/events/evregion.c index 236fbd1ca438..3ddddbfa8db7 100644 --- a/drivers/acpi/events/evregion.c +++ b/drivers/acpi/events/evregion.c | |||
@@ -48,16 +48,8 @@ | |||
48 | 48 | ||
49 | #define _COMPONENT ACPI_EVENTS | 49 | #define _COMPONENT ACPI_EVENTS |
50 | ACPI_MODULE_NAME("evregion") | 50 | ACPI_MODULE_NAME("evregion") |
51 | #define ACPI_NUM_DEFAULT_SPACES 4 | ||
52 | static u8 acpi_gbl_default_address_spaces[ACPI_NUM_DEFAULT_SPACES] = { | ||
53 | ACPI_ADR_SPACE_SYSTEM_MEMORY, | ||
54 | ACPI_ADR_SPACE_SYSTEM_IO, | ||
55 | ACPI_ADR_SPACE_PCI_CONFIG, | ||
56 | ACPI_ADR_SPACE_DATA_TABLE | ||
57 | }; | ||
58 | 51 | ||
59 | /* Local prototypes */ | 52 | /* Local prototypes */ |
60 | |||
61 | static acpi_status | 53 | static acpi_status |
62 | acpi_ev_reg_run(acpi_handle obj_handle, | 54 | acpi_ev_reg_run(acpi_handle obj_handle, |
63 | u32 level, void *context, void **return_value); | 55 | u32 level, void *context, void **return_value); |
@@ -66,6 +58,17 @@ static acpi_status | |||
66 | acpi_ev_install_handler(acpi_handle obj_handle, | 58 | acpi_ev_install_handler(acpi_handle obj_handle, |
67 | u32 level, void *context, void **return_value); | 59 | u32 level, void *context, void **return_value); |
68 | 60 | ||
61 | /* These are the address spaces that will get default handlers */ | ||
62 | |||
63 | #define ACPI_NUM_DEFAULT_SPACES 4 | ||
64 | |||
65 | static u8 acpi_gbl_default_address_spaces[ACPI_NUM_DEFAULT_SPACES] = { | ||
66 | ACPI_ADR_SPACE_SYSTEM_MEMORY, | ||
67 | ACPI_ADR_SPACE_SYSTEM_IO, | ||
68 | ACPI_ADR_SPACE_PCI_CONFIG, | ||
69 | ACPI_ADR_SPACE_DATA_TABLE | ||
70 | }; | ||
71 | |||
69 | /******************************************************************************* | 72 | /******************************************************************************* |
70 | * | 73 | * |
71 | * FUNCTION: acpi_ev_install_region_handlers | 74 | * FUNCTION: acpi_ev_install_region_handlers |
@@ -91,18 +94,19 @@ acpi_status acpi_ev_install_region_handlers(void) | |||
91 | } | 94 | } |
92 | 95 | ||
93 | /* | 96 | /* |
94 | * All address spaces (PCI Config, EC, SMBus) are scope dependent | 97 | * All address spaces (PCI Config, EC, SMBus) are scope dependent and |
95 | * and registration must occur for a specific device. | 98 | * registration must occur for a specific device. |
96 | * | 99 | * |
97 | * In the case of the system memory and IO address spaces there is currently | 100 | * In the case of the system memory and IO address spaces there is |
98 | * no device associated with the address space. For these we use the root. | 101 | * currently no device associated with the address space. For these we |
102 | * use the root. | ||
99 | * | 103 | * |
100 | * We install the default PCI config space handler at the root so | 104 | * We install the default PCI config space handler at the root so that |
101 | * that this space is immediately available even though the we have | 105 | * this space is immediately available even though the we have not |
102 | * not enumerated all the PCI Root Buses yet. This is to conform | 106 | * enumerated all the PCI Root Buses yet. This is to conform to the ACPI |
103 | * to the ACPI specification which states that the PCI config | 107 | * specification which states that the PCI config space must be always |
104 | * space must be always available -- even though we are nowhere | 108 | * available -- even though we are nowhere near ready to find the PCI root |
105 | * near ready to find the PCI root buses at this point. | 109 | * buses at this point. |
106 | * | 110 | * |
107 | * NOTE: We ignore AE_ALREADY_EXISTS because this means that a handler | 111 | * NOTE: We ignore AE_ALREADY_EXISTS because this means that a handler |
108 | * has already been installed (via acpi_install_address_space_handler). | 112 | * has already been installed (via acpi_install_address_space_handler). |
@@ -160,12 +164,11 @@ acpi_status acpi_ev_initialize_op_regions(void) | |||
160 | return_ACPI_STATUS(status); | 164 | return_ACPI_STATUS(status); |
161 | } | 165 | } |
162 | 166 | ||
163 | /* | 167 | /* Run the _REG methods for op_regions in each default address space */ |
164 | * Run the _REG methods for op_regions in each default address space | ||
165 | */ | ||
166 | for (i = 0; i < ACPI_NUM_DEFAULT_SPACES; i++) { | ||
167 | 168 | ||
168 | /* TBD: Make sure handler is the DEFAULT handler, otherwise | 169 | for (i = 0; i < ACPI_NUM_DEFAULT_SPACES; i++) { |
170 | /* | ||
171 | * TBD: Make sure handler is the DEFAULT handler, otherwise | ||
169 | * _REG will have already been run. | 172 | * _REG will have already been run. |
170 | */ | 173 | */ |
171 | status = acpi_ev_execute_reg_methods(acpi_gbl_root_node, | 174 | status = acpi_ev_execute_reg_methods(acpi_gbl_root_node, |
@@ -318,13 +321,13 @@ acpi_ev_address_space_dispatch(union acpi_operand_object *region_obj, | |||
318 | } | 321 | } |
319 | 322 | ||
320 | /* | 323 | /* |
321 | * It may be the case that the region has never been initialized | 324 | * It may be the case that the region has never been initialized. |
322 | * Some types of regions require special init code | 325 | * Some types of regions require special init code |
323 | */ | 326 | */ |
324 | if (!(region_obj->region.flags & AOPOBJ_SETUP_COMPLETE)) { | 327 | if (!(region_obj->region.flags & AOPOBJ_SETUP_COMPLETE)) { |
325 | /* | 328 | |
326 | * This region has not been initialized yet, do it | 329 | /* This region has not been initialized yet, do it */ |
327 | */ | 330 | |
328 | region_setup = handler_desc->address_space.setup; | 331 | region_setup = handler_desc->address_space.setup; |
329 | if (!region_setup) { | 332 | if (!region_setup) { |
330 | 333 | ||
@@ -339,9 +342,9 @@ acpi_ev_address_space_dispatch(union acpi_operand_object *region_obj, | |||
339 | } | 342 | } |
340 | 343 | ||
341 | /* | 344 | /* |
342 | * We must exit the interpreter because the region | 345 | * We must exit the interpreter because the region setup will |
343 | * setup will potentially execute control methods | 346 | * potentially execute control methods (for example, the _REG method |
344 | * (e.g., _REG method for this region) | 347 | * for this region) |
345 | */ | 348 | */ |
346 | acpi_ex_exit_interpreter(); | 349 | acpi_ex_exit_interpreter(); |
347 | 350 | ||
@@ -364,9 +367,8 @@ acpi_ev_address_space_dispatch(union acpi_operand_object *region_obj, | |||
364 | return_ACPI_STATUS(status); | 367 | return_ACPI_STATUS(status); |
365 | } | 368 | } |
366 | 369 | ||
367 | /* | 370 | /* Region initialization may have been completed by region_setup */ |
368 | * Region initialization may have been completed by region_setup | 371 | |
369 | */ | ||
370 | if (!(region_obj->region.flags & AOPOBJ_SETUP_COMPLETE)) { | 372 | if (!(region_obj->region.flags & AOPOBJ_SETUP_COMPLETE)) { |
371 | region_obj->region.flags |= AOPOBJ_SETUP_COMPLETE; | 373 | region_obj->region.flags |= AOPOBJ_SETUP_COMPLETE; |
372 | 374 | ||
@@ -521,8 +523,8 @@ acpi_ev_detach_region(union acpi_operand_object *region_obj, | |||
521 | } | 523 | } |
522 | 524 | ||
523 | /* | 525 | /* |
524 | * If the region has been activated, call the setup handler | 526 | * If the region has been activated, call the setup handler with |
525 | * with the deactivate notification | 527 | * the deactivate notification |
526 | */ | 528 | */ |
527 | if (region_obj->region.flags & AOPOBJ_SETUP_COMPLETE) { | 529 | if (region_obj->region.flags & AOPOBJ_SETUP_COMPLETE) { |
528 | region_setup = handler_obj->address_space.setup; | 530 | region_setup = handler_obj->address_space.setup; |
@@ -668,8 +670,8 @@ acpi_ev_install_handler(acpi_handle obj_handle, | |||
668 | } | 670 | } |
669 | 671 | ||
670 | /* | 672 | /* |
671 | * We only care about regions.and objects | 673 | * We only care about regions and objects that are allowed to have |
672 | * that are allowed to have address space handlers | 674 | * address space handlers |
673 | */ | 675 | */ |
674 | if ((node->type != ACPI_TYPE_DEVICE) && | 676 | if ((node->type != ACPI_TYPE_DEVICE) && |
675 | (node->type != ACPI_TYPE_REGION) && (node != acpi_gbl_root_node)) { | 677 | (node->type != ACPI_TYPE_REGION) && (node != acpi_gbl_root_node)) { |
@@ -710,9 +712,9 @@ acpi_ev_install_handler(acpi_handle obj_handle, | |||
710 | /* | 712 | /* |
711 | * Since the object we found it on was a device, then it | 713 | * Since the object we found it on was a device, then it |
712 | * means that someone has already installed a handler for | 714 | * means that someone has already installed a handler for |
713 | * the branch of the namespace from this device on. Just | 715 | * the branch of the namespace from this device on. Just |
714 | * bail out telling the walk routine to not traverse this | 716 | * bail out telling the walk routine to not traverse this |
715 | * branch. This preserves the scoping rule for handlers. | 717 | * branch. This preserves the scoping rule for handlers. |
716 | */ | 718 | */ |
717 | return (AE_CTRL_DEPTH); | 719 | return (AE_CTRL_DEPTH); |
718 | } | 720 | } |
@@ -723,9 +725,8 @@ acpi_ev_install_handler(acpi_handle obj_handle, | |||
723 | } | 725 | } |
724 | 726 | ||
725 | /* | 727 | /* |
726 | * As long as the device didn't have a handler for this | 728 | * As long as the device didn't have a handler for this space we |
727 | * space we don't care about it. We just ignore it and | 729 | * don't care about it. We just ignore it and proceed. |
728 | * proceed. | ||
729 | */ | 730 | */ |
730 | return (AE_OK); | 731 | return (AE_OK); |
731 | } | 732 | } |
@@ -733,16 +734,14 @@ acpi_ev_install_handler(acpi_handle obj_handle, | |||
733 | /* Object is a Region */ | 734 | /* Object is a Region */ |
734 | 735 | ||
735 | if (obj_desc->region.space_id != handler_obj->address_space.space_id) { | 736 | if (obj_desc->region.space_id != handler_obj->address_space.space_id) { |
736 | /* | 737 | |
737 | * This region is for a different address space | 738 | /* This region is for a different address space, just ignore it */ |
738 | * -- just ignore it | 739 | |
739 | */ | ||
740 | return (AE_OK); | 740 | return (AE_OK); |
741 | } | 741 | } |
742 | 742 | ||
743 | /* | 743 | /* |
744 | * Now we have a region and it is for the handler's address | 744 | * Now we have a region and it is for the handler's address space type. |
745 | * space type. | ||
746 | * | 745 | * |
747 | * First disconnect region for any previous handler (if any) | 746 | * First disconnect region for any previous handler (if any) |
748 | */ | 747 | */ |
@@ -786,9 +785,8 @@ acpi_ev_install_space_handler(struct acpi_namespace_node * node, | |||
786 | ACPI_FUNCTION_TRACE(ev_install_space_handler); | 785 | ACPI_FUNCTION_TRACE(ev_install_space_handler); |
787 | 786 | ||
788 | /* | 787 | /* |
789 | * This registration is valid for only the types below | 788 | * This registration is valid for only the types below and the root. This |
790 | * and the root. This is where the default handlers | 789 | * is where the default handlers get placed. |
791 | * get placed. | ||
792 | */ | 790 | */ |
793 | if ((node->type != ACPI_TYPE_DEVICE) && | 791 | if ((node->type != ACPI_TYPE_DEVICE) && |
794 | (node->type != ACPI_TYPE_PROCESSOR) && | 792 | (node->type != ACPI_TYPE_PROCESSOR) && |
@@ -848,8 +846,8 @@ acpi_ev_install_space_handler(struct acpi_namespace_node * node, | |||
848 | obj_desc = acpi_ns_get_attached_object(node); | 846 | obj_desc = acpi_ns_get_attached_object(node); |
849 | if (obj_desc) { | 847 | if (obj_desc) { |
850 | /* | 848 | /* |
851 | * The attached device object already exists. | 849 | * The attached device object already exists. Make sure the handler |
852 | * Make sure the handler is not already installed. | 850 | * is not already installed. |
853 | */ | 851 | */ |
854 | handler_obj = obj_desc->device.handler; | 852 | handler_obj = obj_desc->device.handler; |
855 | 853 | ||
@@ -864,8 +862,8 @@ acpi_ev_install_space_handler(struct acpi_namespace_node * node, | |||
864 | handler) { | 862 | handler) { |
865 | /* | 863 | /* |
866 | * It is (relatively) OK to attempt to install the SAME | 864 | * It is (relatively) OK to attempt to install the SAME |
867 | * handler twice. This can easily happen | 865 | * handler twice. This can easily happen with the |
868 | * with PCI_Config space. | 866 | * PCI_Config space. |
869 | */ | 867 | */ |
870 | status = AE_SAME_HANDLER; | 868 | status = AE_SAME_HANDLER; |
871 | goto unlock_and_exit; | 869 | goto unlock_and_exit; |
@@ -925,9 +923,8 @@ acpi_ev_install_space_handler(struct acpi_namespace_node * node, | |||
925 | /* | 923 | /* |
926 | * Install the handler | 924 | * Install the handler |
927 | * | 925 | * |
928 | * At this point there is no existing handler. | 926 | * At this point there is no existing handler. Just allocate the object |
929 | * Just allocate the object for the handler and link it | 927 | * for the handler and link it into the list. |
930 | * into the list. | ||
931 | */ | 928 | */ |
932 | handler_obj = | 929 | handler_obj = |
933 | acpi_ut_create_internal_object(ACPI_TYPE_LOCAL_ADDRESS_HANDLER); | 930 | acpi_ut_create_internal_object(ACPI_TYPE_LOCAL_ADDRESS_HANDLER); |
@@ -1000,11 +997,10 @@ acpi_ev_execute_reg_methods(struct acpi_namespace_node *node, | |||
1000 | ACPI_FUNCTION_TRACE(ev_execute_reg_methods); | 997 | ACPI_FUNCTION_TRACE(ev_execute_reg_methods); |
1001 | 998 | ||
1002 | /* | 999 | /* |
1003 | * Run all _REG methods for all Operation Regions for this | 1000 | * Run all _REG methods for all Operation Regions for this space ID. This |
1004 | * space ID. This is a separate walk in order to handle any | 1001 | * is a separate walk in order to handle any interdependencies between |
1005 | * interdependencies between regions and _REG methods. (i.e. handlers | 1002 | * regions and _REG methods. (i.e. handlers must be installed for all |
1006 | * must be installed for all regions of this Space ID before we | 1003 | * regions of this Space ID before we can run any _REG methods) |
1007 | * can run any _REG methods) | ||
1008 | */ | 1004 | */ |
1009 | status = acpi_ns_walk_namespace(ACPI_TYPE_ANY, node, ACPI_UINT32_MAX, | 1005 | status = acpi_ns_walk_namespace(ACPI_TYPE_ANY, node, ACPI_UINT32_MAX, |
1010 | ACPI_NS_WALK_UNLOCK, acpi_ev_reg_run, | 1006 | ACPI_NS_WALK_UNLOCK, acpi_ev_reg_run, |
@@ -1042,8 +1038,8 @@ acpi_ev_reg_run(acpi_handle obj_handle, | |||
1042 | } | 1038 | } |
1043 | 1039 | ||
1044 | /* | 1040 | /* |
1045 | * We only care about regions.and objects | 1041 | * We only care about regions.and objects that are allowed to have address |
1046 | * that are allowed to have address space handlers | 1042 | * space handlers |
1047 | */ | 1043 | */ |
1048 | if ((node->type != ACPI_TYPE_REGION) && (node != acpi_gbl_root_node)) { | 1044 | if ((node->type != ACPI_TYPE_REGION) && (node != acpi_gbl_root_node)) { |
1049 | return (AE_OK); | 1045 | return (AE_OK); |
@@ -1062,10 +1058,9 @@ acpi_ev_reg_run(acpi_handle obj_handle, | |||
1062 | /* Object is a Region */ | 1058 | /* Object is a Region */ |
1063 | 1059 | ||
1064 | if (obj_desc->region.space_id != space_id) { | 1060 | if (obj_desc->region.space_id != space_id) { |
1065 | /* | 1061 | |
1066 | * This region is for a different address space | 1062 | /* This region is for a different address space, just ignore it */ |
1067 | * -- just ignore it | 1063 | |
1068 | */ | ||
1069 | return (AE_OK); | 1064 | return (AE_OK); |
1070 | } | 1065 | } |
1071 | 1066 | ||