diff options
Diffstat (limited to 'drivers/acpi')
74 files changed, 1236 insertions, 1058 deletions
diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig index 5d9248526d78..4770de5707b9 100644 --- a/drivers/acpi/Kconfig +++ b/drivers/acpi/Kconfig | |||
@@ -348,7 +348,6 @@ source "drivers/acpi/apei/Kconfig" | |||
348 | config ACPI_EXTLOG | 348 | config ACPI_EXTLOG |
349 | tristate "Extended Error Log support" | 349 | tristate "Extended Error Log support" |
350 | depends on X86_MCE && X86_LOCAL_APIC | 350 | depends on X86_MCE && X86_LOCAL_APIC |
351 | select EFI | ||
352 | select UEFI_CPER | 351 | select UEFI_CPER |
353 | default n | 352 | default n |
354 | help | 353 | help |
diff --git a/drivers/acpi/ac.c b/drivers/acpi/ac.c index 8711e3797165..e7515aa43d6b 100644 --- a/drivers/acpi/ac.c +++ b/drivers/acpi/ac.c | |||
@@ -32,8 +32,7 @@ | |||
32 | #include <linux/delay.h> | 32 | #include <linux/delay.h> |
33 | #include <linux/platform_device.h> | 33 | #include <linux/platform_device.h> |
34 | #include <linux/power_supply.h> | 34 | #include <linux/power_supply.h> |
35 | #include <acpi/acpi_bus.h> | 35 | #include <linux/acpi.h> |
36 | #include <acpi/acpi_drivers.h> | ||
37 | 36 | ||
38 | #define PREFIX "ACPI: " | 37 | #define PREFIX "ACPI: " |
39 | 38 | ||
@@ -207,7 +206,7 @@ static int acpi_ac_probe(struct platform_device *pdev) | |||
207 | goto end; | 206 | goto end; |
208 | 207 | ||
209 | result = acpi_install_notify_handler(ACPI_HANDLE(&pdev->dev), | 208 | result = acpi_install_notify_handler(ACPI_HANDLE(&pdev->dev), |
210 | ACPI_DEVICE_NOTIFY, acpi_ac_notify_handler, ac); | 209 | ACPI_ALL_NOTIFY, acpi_ac_notify_handler, ac); |
211 | if (result) { | 210 | if (result) { |
212 | power_supply_unregister(&ac->charger); | 211 | power_supply_unregister(&ac->charger); |
213 | goto end; | 212 | goto end; |
@@ -255,7 +254,7 @@ static int acpi_ac_remove(struct platform_device *pdev) | |||
255 | return -EINVAL; | 254 | return -EINVAL; |
256 | 255 | ||
257 | acpi_remove_notify_handler(ACPI_HANDLE(&pdev->dev), | 256 | acpi_remove_notify_handler(ACPI_HANDLE(&pdev->dev), |
258 | ACPI_DEVICE_NOTIFY, acpi_ac_notify_handler); | 257 | ACPI_ALL_NOTIFY, acpi_ac_notify_handler); |
259 | 258 | ||
260 | ac = platform_get_drvdata(pdev); | 259 | ac = platform_get_drvdata(pdev); |
261 | if (ac->charger.dev) | 260 | if (ac->charger.dev) |
diff --git a/drivers/acpi/acpi_extlog.c b/drivers/acpi/acpi_extlog.c index a6869e110ce5..94166680b3a3 100644 --- a/drivers/acpi/acpi_extlog.c +++ b/drivers/acpi/acpi_extlog.c | |||
@@ -9,7 +9,6 @@ | |||
9 | 9 | ||
10 | #include <linux/module.h> | 10 | #include <linux/module.h> |
11 | #include <linux/acpi.h> | 11 | #include <linux/acpi.h> |
12 | #include <acpi/acpi_bus.h> | ||
13 | #include <linux/cper.h> | 12 | #include <linux/cper.h> |
14 | #include <linux/ratelimit.h> | 13 | #include <linux/ratelimit.h> |
15 | #include <asm/cpu.h> | 14 | #include <asm/cpu.h> |
@@ -20,11 +19,9 @@ | |||
20 | #define EXT_ELOG_ENTRY_MASK GENMASK_ULL(51, 0) /* elog entry address mask */ | 19 | #define EXT_ELOG_ENTRY_MASK GENMASK_ULL(51, 0) /* elog entry address mask */ |
21 | 20 | ||
22 | #define EXTLOG_DSM_REV 0x0 | 21 | #define EXTLOG_DSM_REV 0x0 |
23 | #define EXTLOG_FN_QUERY 0x0 | ||
24 | #define EXTLOG_FN_ADDR 0x1 | 22 | #define EXTLOG_FN_ADDR 0x1 |
25 | 23 | ||
26 | #define FLAG_OS_OPTIN BIT(0) | 24 | #define FLAG_OS_OPTIN BIT(0) |
27 | #define EXTLOG_QUERY_L1_EXIST BIT(1) | ||
28 | #define ELOG_ENTRY_VALID (1ULL<<63) | 25 | #define ELOG_ENTRY_VALID (1ULL<<63) |
29 | #define ELOG_ENTRY_LEN 0x1000 | 26 | #define ELOG_ENTRY_LEN 0x1000 |
30 | 27 | ||
@@ -43,7 +40,7 @@ struct extlog_l1_head { | |||
43 | u8 rev1[12]; | 40 | u8 rev1[12]; |
44 | }; | 41 | }; |
45 | 42 | ||
46 | static u8 extlog_dsm_uuid[] = "663E35AF-CC10-41A4-88EA-5470AF055295"; | 43 | static u8 extlog_dsm_uuid[] __initdata = "663E35AF-CC10-41A4-88EA-5470AF055295"; |
47 | 44 | ||
48 | /* L1 table related physical address */ | 45 | /* L1 table related physical address */ |
49 | static u64 elog_base; | 46 | static u64 elog_base; |
@@ -153,62 +150,27 @@ static int extlog_print(struct notifier_block *nb, unsigned long val, | |||
153 | return NOTIFY_DONE; | 150 | return NOTIFY_DONE; |
154 | } | 151 | } |
155 | 152 | ||
156 | static int extlog_get_dsm(acpi_handle handle, int rev, int func, u64 *ret) | 153 | static bool __init extlog_get_l1addr(void) |
157 | { | 154 | { |
158 | struct acpi_buffer buf = {ACPI_ALLOCATE_BUFFER, NULL}; | ||
159 | struct acpi_object_list input; | ||
160 | union acpi_object params[4], *obj; | ||
161 | u8 uuid[16]; | 155 | u8 uuid[16]; |
162 | int i; | 156 | acpi_handle handle; |
157 | union acpi_object *obj; | ||
163 | 158 | ||
164 | acpi_str_to_uuid(extlog_dsm_uuid, uuid); | 159 | acpi_str_to_uuid(extlog_dsm_uuid, uuid); |
165 | input.count = 4; | ||
166 | input.pointer = params; | ||
167 | params[0].type = ACPI_TYPE_BUFFER; | ||
168 | params[0].buffer.length = 16; | ||
169 | params[0].buffer.pointer = uuid; | ||
170 | params[1].type = ACPI_TYPE_INTEGER; | ||
171 | params[1].integer.value = rev; | ||
172 | params[2].type = ACPI_TYPE_INTEGER; | ||
173 | params[2].integer.value = func; | ||
174 | params[3].type = ACPI_TYPE_PACKAGE; | ||
175 | params[3].package.count = 0; | ||
176 | params[3].package.elements = NULL; | ||
177 | |||
178 | if (ACPI_FAILURE(acpi_evaluate_object(handle, "_DSM", &input, &buf))) | ||
179 | return -1; | ||
180 | |||
181 | *ret = 0; | ||
182 | obj = (union acpi_object *)buf.pointer; | ||
183 | if (obj->type == ACPI_TYPE_INTEGER) { | ||
184 | *ret = obj->integer.value; | ||
185 | } else if (obj->type == ACPI_TYPE_BUFFER) { | ||
186 | if (obj->buffer.length <= 8) { | ||
187 | for (i = 0; i < obj->buffer.length; i++) | ||
188 | *ret |= (obj->buffer.pointer[i] << (i * 8)); | ||
189 | } | ||
190 | } | ||
191 | kfree(buf.pointer); | ||
192 | |||
193 | return 0; | ||
194 | } | ||
195 | |||
196 | static bool extlog_get_l1addr(void) | ||
197 | { | ||
198 | acpi_handle handle; | ||
199 | u64 ret; | ||
200 | 160 | ||
201 | if (ACPI_FAILURE(acpi_get_handle(NULL, "\\_SB", &handle))) | 161 | if (ACPI_FAILURE(acpi_get_handle(NULL, "\\_SB", &handle))) |
202 | return false; | 162 | return false; |
203 | 163 | if (!acpi_check_dsm(handle, uuid, EXTLOG_DSM_REV, 1 << EXTLOG_FN_ADDR)) | |
204 | if (extlog_get_dsm(handle, EXTLOG_DSM_REV, EXTLOG_FN_QUERY, &ret) || | ||
205 | !(ret & EXTLOG_QUERY_L1_EXIST)) | ||
206 | return false; | 164 | return false; |
207 | 165 | obj = acpi_evaluate_dsm_typed(handle, uuid, EXTLOG_DSM_REV, | |
208 | if (extlog_get_dsm(handle, EXTLOG_DSM_REV, EXTLOG_FN_ADDR, &ret)) | 166 | EXTLOG_FN_ADDR, NULL, ACPI_TYPE_INTEGER); |
167 | if (!obj) { | ||
209 | return false; | 168 | return false; |
169 | } else { | ||
170 | l1_dirbase = obj->integer.value; | ||
171 | ACPI_FREE(obj); | ||
172 | } | ||
210 | 173 | ||
211 | l1_dirbase = ret; | ||
212 | /* Spec says L1 directory must be 4K aligned, bail out if it isn't */ | 174 | /* Spec says L1 directory must be 4K aligned, bail out if it isn't */ |
213 | if (l1_dirbase & ((1 << 12) - 1)) { | 175 | if (l1_dirbase & ((1 << 12) - 1)) { |
214 | pr_warn(FW_BUG "L1 Directory is invalid at physical %llx\n", | 176 | pr_warn(FW_BUG "L1 Directory is invalid at physical %llx\n", |
diff --git a/drivers/acpi/acpi_lpss.c b/drivers/acpi/acpi_lpss.c index 6745fe137b9e..e60390597372 100644 --- a/drivers/acpi/acpi_lpss.c +++ b/drivers/acpi/acpi_lpss.c | |||
@@ -162,6 +162,7 @@ static const struct acpi_device_id acpi_lpss_device_ids[] = { | |||
162 | { "80860F14", (unsigned long)&byt_sdio_dev_desc }, | 162 | { "80860F14", (unsigned long)&byt_sdio_dev_desc }, |
163 | { "80860F41", (unsigned long)&byt_i2c_dev_desc }, | 163 | { "80860F41", (unsigned long)&byt_i2c_dev_desc }, |
164 | { "INT33B2", }, | 164 | { "INT33B2", }, |
165 | { "INT33FC", }, | ||
165 | 166 | ||
166 | { "INT3430", (unsigned long)&lpt_dev_desc }, | 167 | { "INT3430", (unsigned long)&lpt_dev_desc }, |
167 | { "INT3431", (unsigned long)&lpt_dev_desc }, | 168 | { "INT3431", (unsigned long)&lpt_dev_desc }, |
diff --git a/drivers/acpi/acpi_memhotplug.c b/drivers/acpi/acpi_memhotplug.c index 551dad712ffe..9aeacdfca410 100644 --- a/drivers/acpi/acpi_memhotplug.c +++ b/drivers/acpi/acpi_memhotplug.c | |||
@@ -180,14 +180,14 @@ static unsigned long acpi_meminfo_end_pfn(struct acpi_memory_info *info) | |||
180 | 180 | ||
181 | static int acpi_bind_memblk(struct memory_block *mem, void *arg) | 181 | static int acpi_bind_memblk(struct memory_block *mem, void *arg) |
182 | { | 182 | { |
183 | return acpi_bind_one(&mem->dev, (acpi_handle)arg); | 183 | return acpi_bind_one(&mem->dev, arg); |
184 | } | 184 | } |
185 | 185 | ||
186 | static int acpi_bind_memory_blocks(struct acpi_memory_info *info, | 186 | static int acpi_bind_memory_blocks(struct acpi_memory_info *info, |
187 | acpi_handle handle) | 187 | struct acpi_device *adev) |
188 | { | 188 | { |
189 | return walk_memory_range(acpi_meminfo_start_pfn(info), | 189 | return walk_memory_range(acpi_meminfo_start_pfn(info), |
190 | acpi_meminfo_end_pfn(info), (void *)handle, | 190 | acpi_meminfo_end_pfn(info), adev, |
191 | acpi_bind_memblk); | 191 | acpi_bind_memblk); |
192 | } | 192 | } |
193 | 193 | ||
@@ -197,8 +197,7 @@ static int acpi_unbind_memblk(struct memory_block *mem, void *arg) | |||
197 | return 0; | 197 | return 0; |
198 | } | 198 | } |
199 | 199 | ||
200 | static void acpi_unbind_memory_blocks(struct acpi_memory_info *info, | 200 | static void acpi_unbind_memory_blocks(struct acpi_memory_info *info) |
201 | acpi_handle handle) | ||
202 | { | 201 | { |
203 | walk_memory_range(acpi_meminfo_start_pfn(info), | 202 | walk_memory_range(acpi_meminfo_start_pfn(info), |
204 | acpi_meminfo_end_pfn(info), NULL, acpi_unbind_memblk); | 203 | acpi_meminfo_end_pfn(info), NULL, acpi_unbind_memblk); |
@@ -242,9 +241,9 @@ static int acpi_memory_enable_device(struct acpi_memory_device *mem_device) | |||
242 | if (result && result != -EEXIST) | 241 | if (result && result != -EEXIST) |
243 | continue; | 242 | continue; |
244 | 243 | ||
245 | result = acpi_bind_memory_blocks(info, handle); | 244 | result = acpi_bind_memory_blocks(info, mem_device->device); |
246 | if (result) { | 245 | if (result) { |
247 | acpi_unbind_memory_blocks(info, handle); | 246 | acpi_unbind_memory_blocks(info); |
248 | return -ENODEV; | 247 | return -ENODEV; |
249 | } | 248 | } |
250 | 249 | ||
@@ -285,7 +284,7 @@ static void acpi_memory_remove_memory(struct acpi_memory_device *mem_device) | |||
285 | if (nid == NUMA_NO_NODE) | 284 | if (nid == NUMA_NO_NODE) |
286 | nid = memory_add_physaddr_to_nid(info->start_addr); | 285 | nid = memory_add_physaddr_to_nid(info->start_addr); |
287 | 286 | ||
288 | acpi_unbind_memory_blocks(info, handle); | 287 | acpi_unbind_memory_blocks(info); |
289 | remove_memory(nid, info->start_addr, info->length); | 288 | remove_memory(nid, info->start_addr, info->length); |
290 | list_del(&info->list); | 289 | list_del(&info->list); |
291 | kfree(info); | 290 | kfree(info); |
diff --git a/drivers/acpi/acpi_pad.c b/drivers/acpi/acpi_pad.c index fc6008fbce35..65610c0e7243 100644 --- a/drivers/acpi/acpi_pad.c +++ b/drivers/acpi/acpi_pad.c | |||
@@ -28,8 +28,7 @@ | |||
28 | #include <linux/cpu.h> | 28 | #include <linux/cpu.h> |
29 | #include <linux/clockchips.h> | 29 | #include <linux/clockchips.h> |
30 | #include <linux/slab.h> | 30 | #include <linux/slab.h> |
31 | #include <acpi/acpi_bus.h> | 31 | #include <linux/acpi.h> |
32 | #include <acpi/acpi_drivers.h> | ||
33 | #include <asm/mwait.h> | 32 | #include <asm/mwait.h> |
34 | 33 | ||
35 | #define ACPI_PROCESSOR_AGGREGATOR_CLASS "acpi_pad" | 34 | #define ACPI_PROCESSOR_AGGREGATOR_CLASS "acpi_pad" |
diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processor.c index 3c1d6b0c09a4..c9311be29a64 100644 --- a/drivers/acpi/acpi_processor.c +++ b/drivers/acpi/acpi_processor.c | |||
@@ -212,7 +212,7 @@ static int acpi_processor_get_info(struct acpi_device *device) | |||
212 | union acpi_object object = { 0 }; | 212 | union acpi_object object = { 0 }; |
213 | struct acpi_buffer buffer = { sizeof(union acpi_object), &object }; | 213 | struct acpi_buffer buffer = { sizeof(union acpi_object), &object }; |
214 | struct acpi_processor *pr = acpi_driver_data(device); | 214 | struct acpi_processor *pr = acpi_driver_data(device); |
215 | int cpu_index, device_declaration = 0; | 215 | int apic_id, cpu_index, device_declaration = 0; |
216 | acpi_status status = AE_OK; | 216 | acpi_status status = AE_OK; |
217 | static int cpu0_initialized; | 217 | static int cpu0_initialized; |
218 | unsigned long long value; | 218 | unsigned long long value; |
@@ -258,18 +258,21 @@ static int acpi_processor_get_info(struct acpi_device *device) | |||
258 | device_declaration = 1; | 258 | device_declaration = 1; |
259 | pr->acpi_id = value; | 259 | pr->acpi_id = value; |
260 | } | 260 | } |
261 | pr->apic_id = acpi_get_apicid(pr->handle, device_declaration, | ||
262 | pr->acpi_id); | ||
263 | cpu_index = acpi_map_cpuid(pr->apic_id, pr->acpi_id); | ||
264 | 261 | ||
265 | /* Handle UP system running SMP kernel, with no LAPIC in MADT */ | 262 | apic_id = acpi_get_apicid(pr->handle, device_declaration, pr->acpi_id); |
266 | if (!cpu0_initialized && (cpu_index == -1) && | 263 | if (apic_id < 0) { |
267 | (num_online_cpus() == 1)) { | 264 | acpi_handle_err(pr->handle, "failed to get CPU APIC ID.\n"); |
268 | cpu_index = 0; | 265 | return -ENODEV; |
269 | } | 266 | } |
267 | pr->apic_id = apic_id; | ||
270 | 268 | ||
271 | cpu0_initialized = 1; | 269 | cpu_index = acpi_map_cpuid(pr->apic_id, pr->acpi_id); |
272 | 270 | if (!cpu0_initialized) { | |
271 | cpu0_initialized = 1; | ||
272 | /* Handle UP system running SMP kernel, with no LAPIC in MADT */ | ||
273 | if ((cpu_index == -1) && (num_online_cpus() == 1)) | ||
274 | cpu_index = 0; | ||
275 | } | ||
273 | pr->id = cpu_index; | 276 | pr->id = cpu_index; |
274 | 277 | ||
275 | /* | 278 | /* |
@@ -282,6 +285,7 @@ static int acpi_processor_get_info(struct acpi_device *device) | |||
282 | if (ret) | 285 | if (ret) |
283 | return ret; | 286 | return ret; |
284 | } | 287 | } |
288 | |||
285 | /* | 289 | /* |
286 | * On some boxes several processors use the same processor bus id. | 290 | * On some boxes several processors use the same processor bus id. |
287 | * But they are located in different scope. For example: | 291 | * But they are located in different scope. For example: |
@@ -395,7 +399,7 @@ static int acpi_processor_add(struct acpi_device *device, | |||
395 | goto err; | 399 | goto err; |
396 | } | 400 | } |
397 | 401 | ||
398 | result = acpi_bind_one(dev, pr->handle); | 402 | result = acpi_bind_one(dev, device); |
399 | if (result) | 403 | if (result) |
400 | goto err; | 404 | goto err; |
401 | 405 | ||
diff --git a/drivers/acpi/acpica/acdebug.h b/drivers/acpi/acpica/acdebug.h index a9fd0b872062..2bf3ca2b8a7a 100644 --- a/drivers/acpi/acpica/acdebug.h +++ b/drivers/acpi/acpica/acdebug.h | |||
@@ -113,7 +113,6 @@ void acpi_db_display_handlers(void); | |||
113 | ACPI_HW_DEPENDENT_RETURN_VOID(void | 113 | ACPI_HW_DEPENDENT_RETURN_VOID(void |
114 | acpi_db_generate_gpe(char *gpe_arg, | 114 | acpi_db_generate_gpe(char *gpe_arg, |
115 | char *block_arg)) | 115 | char *block_arg)) |
116 | |||
117 | ACPI_HW_DEPENDENT_RETURN_VOID(void acpi_db_generate_sci(void)) | 116 | ACPI_HW_DEPENDENT_RETURN_VOID(void acpi_db_generate_sci(void)) |
118 | 117 | ||
119 | /* | 118 | /* |
diff --git a/drivers/acpi/acpica/acevents.h b/drivers/acpi/acpica/acevents.h index 41abe552c7a3..0fb0adf435d6 100644 --- a/drivers/acpi/acpica/acevents.h +++ b/drivers/acpi/acpica/acevents.h | |||
@@ -71,9 +71,8 @@ acpi_status acpi_ev_init_global_lock_handler(void); | |||
71 | 71 | ||
72 | ACPI_HW_DEPENDENT_RETURN_OK(acpi_status | 72 | ACPI_HW_DEPENDENT_RETURN_OK(acpi_status |
73 | acpi_ev_acquire_global_lock(u16 timeout)) | 73 | acpi_ev_acquire_global_lock(u16 timeout)) |
74 | |||
75 | ACPI_HW_DEPENDENT_RETURN_OK(acpi_status acpi_ev_release_global_lock(void)) | 74 | ACPI_HW_DEPENDENT_RETURN_OK(acpi_status acpi_ev_release_global_lock(void)) |
76 | acpi_status acpi_ev_remove_global_lock_handler(void); | 75 | acpi_status acpi_ev_remove_global_lock_handler(void); |
77 | 76 | ||
78 | /* | 77 | /* |
79 | * evgpe - Low-level GPE support | 78 | * evgpe - Low-level GPE support |
@@ -133,7 +132,7 @@ acpi_status acpi_ev_gpe_initialize(void); | |||
133 | ACPI_HW_DEPENDENT_RETURN_VOID(void | 132 | ACPI_HW_DEPENDENT_RETURN_VOID(void |
134 | acpi_ev_update_gpes(acpi_owner_id table_owner_id)) | 133 | acpi_ev_update_gpes(acpi_owner_id table_owner_id)) |
135 | 134 | ||
136 | acpi_status | 135 | acpi_status |
137 | acpi_ev_match_gpe_method(acpi_handle obj_handle, | 136 | acpi_ev_match_gpe_method(acpi_handle obj_handle, |
138 | u32 level, void *context, void **return_value); | 137 | u32 level, void *context, void **return_value); |
139 | 138 | ||
@@ -149,7 +148,9 @@ acpi_status | |||
149 | acpi_ev_get_gpe_device(struct acpi_gpe_xrupt_info *gpe_xrupt_info, | 148 | acpi_ev_get_gpe_device(struct acpi_gpe_xrupt_info *gpe_xrupt_info, |
150 | struct acpi_gpe_block_info *gpe_block, void *context); | 149 | struct acpi_gpe_block_info *gpe_block, void *context); |
151 | 150 | ||
152 | struct acpi_gpe_xrupt_info *acpi_ev_get_gpe_xrupt_block(u32 interrupt_number); | 151 | acpi_status |
152 | acpi_ev_get_gpe_xrupt_block(u32 interrupt_number, | ||
153 | struct acpi_gpe_xrupt_info **gpe_xrupt_block); | ||
153 | 154 | ||
154 | acpi_status acpi_ev_delete_gpe_xrupt(struct acpi_gpe_xrupt_info *gpe_xrupt); | 155 | acpi_status acpi_ev_delete_gpe_xrupt(struct acpi_gpe_xrupt_info *gpe_xrupt); |
155 | 156 | ||
diff --git a/drivers/acpi/acpica/acglobal.h b/drivers/acpi/acpica/acglobal.h index e9f1fc7f99c7..24db8e153bf0 100644 --- a/drivers/acpi/acpica/acglobal.h +++ b/drivers/acpi/acpica/acglobal.h | |||
@@ -119,6 +119,24 @@ bool ACPI_INIT_GLOBAL(acpi_gbl_enable_aml_debug_object, FALSE); | |||
119 | u8 ACPI_INIT_GLOBAL(acpi_gbl_copy_dsdt_locally, FALSE); | 119 | u8 ACPI_INIT_GLOBAL(acpi_gbl_copy_dsdt_locally, FALSE); |
120 | 120 | ||
121 | /* | 121 | /* |
122 | * Optionally ignore an XSDT if present and use the RSDT instead. | ||
123 | * Although the ACPI specification requires that an XSDT be used instead | ||
124 | * of the RSDT, the XSDT has been found to be corrupt or ill-formed on | ||
125 | * some machines. Default behavior is to use the XSDT if present. | ||
126 | */ | ||
127 | u8 ACPI_INIT_GLOBAL(acpi_gbl_do_not_use_xsdt, FALSE); | ||
128 | |||
129 | /* | ||
130 | * Optionally use 32-bit FADT addresses if and when there is a conflict | ||
131 | * (address mismatch) between the 32-bit and 64-bit versions of the | ||
132 | * address. Although ACPICA adheres to the ACPI specification which | ||
133 | * requires the use of the corresponding 64-bit address if it is non-zero, | ||
134 | * some machines have been found to have a corrupted non-zero 64-bit | ||
135 | * address. Default is FALSE, do not favor the 32-bit addresses. | ||
136 | */ | ||
137 | u8 ACPI_INIT_GLOBAL(acpi_gbl_use32_bit_fadt_addresses, FALSE); | ||
138 | |||
139 | /* | ||
122 | * Optionally truncate I/O addresses to 16 bits. Provides compatibility | 140 | * Optionally truncate I/O addresses to 16 bits. Provides compatibility |
123 | * with other ACPI implementations. NOTE: During ACPICA initialization, | 141 | * with other ACPI implementations. NOTE: During ACPICA initialization, |
124 | * this value is set to TRUE if any Windows OSI strings have been | 142 | * this value is set to TRUE if any Windows OSI strings have been |
@@ -484,6 +502,18 @@ ACPI_EXTERN u32 acpi_gbl_size_of_acpi_objects; | |||
484 | 502 | ||
485 | /***************************************************************************** | 503 | /***************************************************************************** |
486 | * | 504 | * |
505 | * Application globals | ||
506 | * | ||
507 | ****************************************************************************/ | ||
508 | |||
509 | #ifdef ACPI_APPLICATION | ||
510 | |||
511 | ACPI_FILE ACPI_INIT_GLOBAL(acpi_gbl_debug_file, NULL); | ||
512 | |||
513 | #endif /* ACPI_APPLICATION */ | ||
514 | |||
515 | /***************************************************************************** | ||
516 | * | ||
487 | * Info/help support | 517 | * Info/help support |
488 | * | 518 | * |
489 | ****************************************************************************/ | 519 | ****************************************************************************/ |
diff --git a/drivers/acpi/acpica/aclocal.h b/drivers/acpi/acpica/aclocal.h index 53ed1a8ba4f0..d95ca5449ace 100644 --- a/drivers/acpi/acpica/aclocal.h +++ b/drivers/acpi/acpica/aclocal.h | |||
@@ -1038,15 +1038,16 @@ struct acpi_external_list { | |||
1038 | struct acpi_external_list *next; | 1038 | struct acpi_external_list *next; |
1039 | u32 value; | 1039 | u32 value; |
1040 | u16 length; | 1040 | u16 length; |
1041 | u16 flags; | ||
1041 | u8 type; | 1042 | u8 type; |
1042 | u8 flags; | ||
1043 | u8 resolved; | ||
1044 | u8 emitted; | ||
1045 | }; | 1043 | }; |
1046 | 1044 | ||
1047 | /* Values for Flags field above */ | 1045 | /* Values for Flags field above */ |
1048 | 1046 | ||
1049 | #define ACPI_IPATH_ALLOCATED 0x01 | 1047 | #define ACPI_EXT_RESOLVED_REFERENCE 0x01 /* Object was resolved during cross ref */ |
1048 | #define ACPI_EXT_ORIGIN_FROM_FILE 0x02 /* External came from a file */ | ||
1049 | #define ACPI_EXT_INTERNAL_PATH_ALLOCATED 0x04 /* Deallocate internal path on completion */ | ||
1050 | #define ACPI_EXT_EXTERNAL_EMITTED 0x08 /* External() statement has been emitted */ | ||
1050 | 1051 | ||
1051 | struct acpi_external_file { | 1052 | struct acpi_external_file { |
1052 | char *path; | 1053 | char *path; |
diff --git a/drivers/acpi/acpica/dsfield.c b/drivers/acpi/acpica/dsfield.c index 2d4c07322576..e7a57c554e84 100644 --- a/drivers/acpi/acpica/dsfield.c +++ b/drivers/acpi/acpica/dsfield.c | |||
@@ -105,7 +105,7 @@ acpi_ds_create_external_region(acpi_status lookup_status, | |||
105 | * operation_region not found. Generate an External for it, and | 105 | * operation_region not found. Generate an External for it, and |
106 | * insert the name into the namespace. | 106 | * insert the name into the namespace. |
107 | */ | 107 | */ |
108 | acpi_dm_add_to_external_list(op, path, ACPI_TYPE_REGION, 0); | 108 | acpi_dm_add_op_to_external_list(op, path, ACPI_TYPE_REGION, 0, 0); |
109 | status = acpi_ns_lookup(walk_state->scope_info, path, ACPI_TYPE_REGION, | 109 | status = acpi_ns_lookup(walk_state->scope_info, path, ACPI_TYPE_REGION, |
110 | ACPI_IMODE_LOAD_PASS1, ACPI_NS_SEARCH_PARENT, | 110 | ACPI_IMODE_LOAD_PASS1, ACPI_NS_SEARCH_PARENT, |
111 | walk_state, node); | 111 | walk_state, node); |
diff --git a/drivers/acpi/acpica/dsutils.c b/drivers/acpi/acpica/dsutils.c index ade44e49deb4..d7f53fb2979a 100644 --- a/drivers/acpi/acpica/dsutils.c +++ b/drivers/acpi/acpica/dsutils.c | |||
@@ -727,27 +727,26 @@ acpi_ds_create_operands(struct acpi_walk_state *walk_state, | |||
727 | index++; | 727 | index++; |
728 | } | 728 | } |
729 | 729 | ||
730 | index--; | 730 | ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, |
731 | "NumOperands %d, ArgCount %d, Index %d\n", | ||
732 | walk_state->num_operands, arg_count, index)); | ||
731 | 733 | ||
732 | /* It is the appropriate order to get objects from the Result stack */ | 734 | /* Create the interpreter arguments, in reverse order */ |
733 | 735 | ||
736 | index--; | ||
734 | for (i = 0; i < arg_count; i++) { | 737 | for (i = 0; i < arg_count; i++) { |
735 | arg = arguments[index]; | 738 | arg = arguments[index]; |
736 | 739 | walk_state->operand_index = (u8)index; | |
737 | /* Force the filling of the operand stack in inverse order */ | ||
738 | |||
739 | walk_state->operand_index = (u8) index; | ||
740 | 740 | ||
741 | status = acpi_ds_create_operand(walk_state, arg, index); | 741 | status = acpi_ds_create_operand(walk_state, arg, index); |
742 | if (ACPI_FAILURE(status)) { | 742 | if (ACPI_FAILURE(status)) { |
743 | goto cleanup; | 743 | goto cleanup; |
744 | } | 744 | } |
745 | 745 | ||
746 | index--; | ||
747 | |||
748 | ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, | 746 | ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, |
749 | "Arg #%u (%p) done, Arg1=%p\n", index, arg, | 747 | "Created Arg #%u (%p) %u args total\n", |
750 | first_arg)); | 748 | index, arg, arg_count)); |
749 | index--; | ||
751 | } | 750 | } |
752 | 751 | ||
753 | return_ACPI_STATUS(status); | 752 | return_ACPI_STATUS(status); |
diff --git a/drivers/acpi/acpica/dswload.c b/drivers/acpi/acpica/dswload.c index 95e681a36f9c..2dbe109727c8 100644 --- a/drivers/acpi/acpica/dswload.c +++ b/drivers/acpi/acpica/dswload.c | |||
@@ -181,8 +181,8 @@ acpi_ds_load1_begin_op(struct acpi_walk_state * walk_state, | |||
181 | * Target of Scope() not found. Generate an External for it, and | 181 | * Target of Scope() not found. Generate an External for it, and |
182 | * insert the name into the namespace. | 182 | * insert the name into the namespace. |
183 | */ | 183 | */ |
184 | acpi_dm_add_to_external_list(op, path, ACPI_TYPE_DEVICE, | 184 | acpi_dm_add_op_to_external_list(op, path, |
185 | 0); | 185 | ACPI_TYPE_DEVICE, 0, 0); |
186 | status = | 186 | status = |
187 | acpi_ns_lookup(walk_state->scope_info, path, | 187 | acpi_ns_lookup(walk_state->scope_info, path, |
188 | object_type, ACPI_IMODE_LOAD_PASS1, | 188 | object_type, ACPI_IMODE_LOAD_PASS1, |
diff --git a/drivers/acpi/acpica/evgpeblk.c b/drivers/acpi/acpica/evgpeblk.c index a9e76bc4ad97..a31e549e64cc 100644 --- a/drivers/acpi/acpica/evgpeblk.c +++ b/drivers/acpi/acpica/evgpeblk.c | |||
@@ -87,9 +87,9 @@ acpi_ev_install_gpe_block(struct acpi_gpe_block_info *gpe_block, | |||
87 | return_ACPI_STATUS(status); | 87 | return_ACPI_STATUS(status); |
88 | } | 88 | } |
89 | 89 | ||
90 | gpe_xrupt_block = acpi_ev_get_gpe_xrupt_block(interrupt_number); | 90 | status = |
91 | if (!gpe_xrupt_block) { | 91 | acpi_ev_get_gpe_xrupt_block(interrupt_number, &gpe_xrupt_block); |
92 | status = AE_NO_MEMORY; | 92 | if (ACPI_FAILURE(status)) { |
93 | goto unlock_and_exit; | 93 | goto unlock_and_exit; |
94 | } | 94 | } |
95 | 95 | ||
@@ -112,7 +112,7 @@ acpi_ev_install_gpe_block(struct acpi_gpe_block_info *gpe_block, | |||
112 | acpi_os_release_lock(acpi_gbl_gpe_lock, flags); | 112 | acpi_os_release_lock(acpi_gbl_gpe_lock, flags); |
113 | 113 | ||
114 | unlock_and_exit: | 114 | unlock_and_exit: |
115 | status = acpi_ut_release_mutex(ACPI_MTX_EVENTS); | 115 | (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS); |
116 | return_ACPI_STATUS(status); | 116 | return_ACPI_STATUS(status); |
117 | } | 117 | } |
118 | 118 | ||
diff --git a/drivers/acpi/acpica/evgpeutil.c b/drivers/acpi/acpica/evgpeutil.c index d3f5e1e2a2b1..4d764e847a08 100644 --- a/drivers/acpi/acpica/evgpeutil.c +++ b/drivers/acpi/acpica/evgpeutil.c | |||
@@ -197,8 +197,9 @@ acpi_ev_get_gpe_device(struct acpi_gpe_xrupt_info *gpe_xrupt_info, | |||
197 | * FUNCTION: acpi_ev_get_gpe_xrupt_block | 197 | * FUNCTION: acpi_ev_get_gpe_xrupt_block |
198 | * | 198 | * |
199 | * PARAMETERS: interrupt_number - Interrupt for a GPE block | 199 | * PARAMETERS: interrupt_number - Interrupt for a GPE block |
200 | * gpe_xrupt_block - Where the block is returned | ||
200 | * | 201 | * |
201 | * RETURN: A GPE interrupt block | 202 | * RETURN: Status |
202 | * | 203 | * |
203 | * DESCRIPTION: Get or Create a GPE interrupt block. There is one interrupt | 204 | * DESCRIPTION: Get or Create a GPE interrupt block. There is one interrupt |
204 | * block per unique interrupt level used for GPEs. Should be | 205 | * block per unique interrupt level used for GPEs. Should be |
@@ -207,7 +208,9 @@ acpi_ev_get_gpe_device(struct acpi_gpe_xrupt_info *gpe_xrupt_info, | |||
207 | * | 208 | * |
208 | ******************************************************************************/ | 209 | ******************************************************************************/ |
209 | 210 | ||
210 | struct acpi_gpe_xrupt_info *acpi_ev_get_gpe_xrupt_block(u32 interrupt_number) | 211 | acpi_status |
212 | acpi_ev_get_gpe_xrupt_block(u32 interrupt_number, | ||
213 | struct acpi_gpe_xrupt_info ** gpe_xrupt_block) | ||
211 | { | 214 | { |
212 | struct acpi_gpe_xrupt_info *next_gpe_xrupt; | 215 | struct acpi_gpe_xrupt_info *next_gpe_xrupt; |
213 | struct acpi_gpe_xrupt_info *gpe_xrupt; | 216 | struct acpi_gpe_xrupt_info *gpe_xrupt; |
@@ -221,7 +224,8 @@ struct acpi_gpe_xrupt_info *acpi_ev_get_gpe_xrupt_block(u32 interrupt_number) | |||
221 | next_gpe_xrupt = acpi_gbl_gpe_xrupt_list_head; | 224 | next_gpe_xrupt = acpi_gbl_gpe_xrupt_list_head; |
222 | while (next_gpe_xrupt) { | 225 | while (next_gpe_xrupt) { |
223 | if (next_gpe_xrupt->interrupt_number == interrupt_number) { | 226 | if (next_gpe_xrupt->interrupt_number == interrupt_number) { |
224 | return_PTR(next_gpe_xrupt); | 227 | *gpe_xrupt_block = next_gpe_xrupt; |
228 | return_ACPI_STATUS(AE_OK); | ||
225 | } | 229 | } |
226 | 230 | ||
227 | next_gpe_xrupt = next_gpe_xrupt->next; | 231 | next_gpe_xrupt = next_gpe_xrupt->next; |
@@ -231,7 +235,7 @@ struct acpi_gpe_xrupt_info *acpi_ev_get_gpe_xrupt_block(u32 interrupt_number) | |||
231 | 235 | ||
232 | gpe_xrupt = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_gpe_xrupt_info)); | 236 | gpe_xrupt = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_gpe_xrupt_info)); |
233 | if (!gpe_xrupt) { | 237 | if (!gpe_xrupt) { |
234 | return_PTR(NULL); | 238 | return_ACPI_STATUS(AE_NO_MEMORY); |
235 | } | 239 | } |
236 | 240 | ||
237 | gpe_xrupt->interrupt_number = interrupt_number; | 241 | gpe_xrupt->interrupt_number = interrupt_number; |
@@ -250,6 +254,7 @@ struct acpi_gpe_xrupt_info *acpi_ev_get_gpe_xrupt_block(u32 interrupt_number) | |||
250 | } else { | 254 | } else { |
251 | acpi_gbl_gpe_xrupt_list_head = gpe_xrupt; | 255 | acpi_gbl_gpe_xrupt_list_head = gpe_xrupt; |
252 | } | 256 | } |
257 | |||
253 | acpi_os_release_lock(acpi_gbl_gpe_lock, flags); | 258 | acpi_os_release_lock(acpi_gbl_gpe_lock, flags); |
254 | 259 | ||
255 | /* Install new interrupt handler if not SCI_INT */ | 260 | /* Install new interrupt handler if not SCI_INT */ |
@@ -259,14 +264,15 @@ struct acpi_gpe_xrupt_info *acpi_ev_get_gpe_xrupt_block(u32 interrupt_number) | |||
259 | acpi_ev_gpe_xrupt_handler, | 264 | acpi_ev_gpe_xrupt_handler, |
260 | gpe_xrupt); | 265 | gpe_xrupt); |
261 | if (ACPI_FAILURE(status)) { | 266 | if (ACPI_FAILURE(status)) { |
262 | ACPI_ERROR((AE_INFO, | 267 | ACPI_EXCEPTION((AE_INFO, status, |
263 | "Could not install GPE interrupt handler at level 0x%X", | 268 | "Could not install GPE interrupt handler at level 0x%X", |
264 | interrupt_number)); | 269 | interrupt_number)); |
265 | return_PTR(NULL); | 270 | return_ACPI_STATUS(status); |
266 | } | 271 | } |
267 | } | 272 | } |
268 | 273 | ||
269 | return_PTR(gpe_xrupt); | 274 | *gpe_xrupt_block = gpe_xrupt; |
275 | return_ACPI_STATUS(AE_OK); | ||
270 | } | 276 | } |
271 | 277 | ||
272 | /******************************************************************************* | 278 | /******************************************************************************* |
diff --git a/drivers/acpi/acpica/exresnte.c b/drivers/acpi/acpica/exresnte.c index acd34f599313..7ca6925a87ca 100644 --- a/drivers/acpi/acpica/exresnte.c +++ b/drivers/acpi/acpica/exresnte.c | |||
@@ -124,7 +124,8 @@ acpi_ex_resolve_node_to_value(struct acpi_namespace_node **object_ptr, | |||
124 | } | 124 | } |
125 | 125 | ||
126 | if (!source_desc) { | 126 | if (!source_desc) { |
127 | ACPI_ERROR((AE_INFO, "No object attached to node %p", node)); | 127 | ACPI_ERROR((AE_INFO, "No object attached to node [%4.4s] %p", |
128 | node->name.ascii, node)); | ||
128 | return_ACPI_STATUS(AE_AML_NO_OPERAND); | 129 | return_ACPI_STATUS(AE_AML_NO_OPERAND); |
129 | } | 130 | } |
130 | 131 | ||
diff --git a/drivers/acpi/acpica/nsxfeval.c b/drivers/acpi/acpica/nsxfeval.c index e973e311f856..1f0c28ba50df 100644 --- a/drivers/acpi/acpica/nsxfeval.c +++ b/drivers/acpi/acpica/nsxfeval.c | |||
@@ -84,7 +84,7 @@ acpi_evaluate_object_typed(acpi_handle handle, | |||
84 | acpi_object_type return_type) | 84 | acpi_object_type return_type) |
85 | { | 85 | { |
86 | acpi_status status; | 86 | acpi_status status; |
87 | u8 must_free = FALSE; | 87 | u8 free_buffer_on_error = FALSE; |
88 | 88 | ||
89 | ACPI_FUNCTION_TRACE(acpi_evaluate_object_typed); | 89 | ACPI_FUNCTION_TRACE(acpi_evaluate_object_typed); |
90 | 90 | ||
@@ -95,14 +95,13 @@ acpi_evaluate_object_typed(acpi_handle handle, | |||
95 | } | 95 | } |
96 | 96 | ||
97 | if (return_buffer->length == ACPI_ALLOCATE_BUFFER) { | 97 | if (return_buffer->length == ACPI_ALLOCATE_BUFFER) { |
98 | must_free = TRUE; | 98 | free_buffer_on_error = TRUE; |
99 | } | 99 | } |
100 | 100 | ||
101 | /* Evaluate the object */ | 101 | /* Evaluate the object */ |
102 | 102 | ||
103 | status = | 103 | status = acpi_evaluate_object(handle, pathname, |
104 | acpi_evaluate_object(handle, pathname, external_params, | 104 | external_params, return_buffer); |
105 | return_buffer); | ||
106 | if (ACPI_FAILURE(status)) { | 105 | if (ACPI_FAILURE(status)) { |
107 | return_ACPI_STATUS(status); | 106 | return_ACPI_STATUS(status); |
108 | } | 107 | } |
@@ -135,11 +134,15 @@ acpi_evaluate_object_typed(acpi_handle handle, | |||
135 | pointer)->type), | 134 | pointer)->type), |
136 | acpi_ut_get_type_name(return_type))); | 135 | acpi_ut_get_type_name(return_type))); |
137 | 136 | ||
138 | if (must_free) { | 137 | if (free_buffer_on_error) { |
139 | 138 | /* | |
140 | /* Caller used ACPI_ALLOCATE_BUFFER, free the return buffer */ | 139 | * Free a buffer created via ACPI_ALLOCATE_BUFFER. |
141 | 140 | * Note: We use acpi_os_free here because acpi_os_allocate was used | |
142 | ACPI_FREE_BUFFER(*return_buffer); | 141 | * to allocate the buffer. This purposefully bypasses the |
142 | * (optionally enabled) allocation tracking mechanism since we | ||
143 | * only want to track internal allocations. | ||
144 | */ | ||
145 | acpi_os_free(return_buffer->pointer); | ||
143 | return_buffer->pointer = NULL; | 146 | return_buffer->pointer = NULL; |
144 | } | 147 | } |
145 | 148 | ||
diff --git a/drivers/acpi/acpica/psopinfo.c b/drivers/acpi/acpica/psopinfo.c index 9ba5301e5751..b0c9787dbe61 100644 --- a/drivers/acpi/acpica/psopinfo.c +++ b/drivers/acpi/acpica/psopinfo.c | |||
@@ -71,6 +71,10 @@ static const u8 acpi_gbl_argument_count[] = | |||
71 | 71 | ||
72 | const struct acpi_opcode_info *acpi_ps_get_opcode_info(u16 opcode) | 72 | const struct acpi_opcode_info *acpi_ps_get_opcode_info(u16 opcode) |
73 | { | 73 | { |
74 | #ifdef ACPI_DEBUG_OUTPUT | ||
75 | const char *opcode_name = "Unknown AML opcode"; | ||
76 | #endif | ||
77 | |||
74 | ACPI_FUNCTION_NAME(ps_get_opcode_info); | 78 | ACPI_FUNCTION_NAME(ps_get_opcode_info); |
75 | 79 | ||
76 | /* | 80 | /* |
@@ -92,11 +96,54 @@ const struct acpi_opcode_info *acpi_ps_get_opcode_info(u16 opcode) | |||
92 | return (&acpi_gbl_aml_op_info | 96 | return (&acpi_gbl_aml_op_info |
93 | [acpi_gbl_long_op_index[(u8)opcode]]); | 97 | [acpi_gbl_long_op_index[(u8)opcode]]); |
94 | } | 98 | } |
99 | #if defined ACPI_ASL_COMPILER && defined ACPI_DEBUG_OUTPUT | ||
100 | #include "asldefine.h" | ||
101 | |||
102 | switch (opcode) { | ||
103 | case AML_RAW_DATA_BYTE: | ||
104 | opcode_name = "-Raw Data Byte-"; | ||
105 | break; | ||
106 | |||
107 | case AML_RAW_DATA_WORD: | ||
108 | opcode_name = "-Raw Data Word-"; | ||
109 | break; | ||
110 | |||
111 | case AML_RAW_DATA_DWORD: | ||
112 | opcode_name = "-Raw Data Dword-"; | ||
113 | break; | ||
114 | |||
115 | case AML_RAW_DATA_QWORD: | ||
116 | opcode_name = "-Raw Data Qword-"; | ||
117 | break; | ||
118 | |||
119 | case AML_RAW_DATA_BUFFER: | ||
120 | opcode_name = "-Raw Data Buffer-"; | ||
121 | break; | ||
122 | |||
123 | case AML_RAW_DATA_CHAIN: | ||
124 | opcode_name = "-Raw Data Buffer Chain-"; | ||
125 | break; | ||
126 | |||
127 | case AML_PACKAGE_LENGTH: | ||
128 | opcode_name = "-Package Length-"; | ||
129 | break; | ||
130 | |||
131 | case AML_UNASSIGNED_OPCODE: | ||
132 | opcode_name = "-Unassigned Opcode-"; | ||
133 | break; | ||
134 | |||
135 | case AML_DEFAULT_ARG_OP: | ||
136 | opcode_name = "-Default Arg-"; | ||
137 | break; | ||
138 | |||
139 | default: | ||
140 | break; | ||
141 | } | ||
142 | #endif | ||
95 | 143 | ||
96 | /* Unknown AML opcode */ | 144 | /* Unknown AML opcode */ |
97 | 145 | ||
98 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, | 146 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "%s [%4.4X]\n", opcode_name, opcode)); |
99 | "Unknown AML opcode [%4.4X]\n", opcode)); | ||
100 | 147 | ||
101 | return (&acpi_gbl_aml_op_info[_UNK]); | 148 | return (&acpi_gbl_aml_op_info[_UNK]); |
102 | } | 149 | } |
diff --git a/drivers/acpi/acpica/tbfadt.c b/drivers/acpi/acpica/tbfadt.c index 9d99f2189693..8f89263ac47e 100644 --- a/drivers/acpi/acpica/tbfadt.c +++ b/drivers/acpi/acpica/tbfadt.c | |||
@@ -56,10 +56,11 @@ acpi_tb_init_generic_address(struct acpi_generic_address *generic_address, | |||
56 | 56 | ||
57 | static void acpi_tb_convert_fadt(void); | 57 | static void acpi_tb_convert_fadt(void); |
58 | 58 | ||
59 | static void acpi_tb_validate_fadt(void); | ||
60 | |||
61 | static void acpi_tb_setup_fadt_registers(void); | 59 | static void acpi_tb_setup_fadt_registers(void); |
62 | 60 | ||
61 | static u64 | ||
62 | acpi_tb_select_address(char *register_name, u32 address32, u64 address64); | ||
63 | |||
63 | /* Table for conversion of FADT to common internal format and FADT validation */ | 64 | /* Table for conversion of FADT to common internal format and FADT validation */ |
64 | 65 | ||
65 | typedef struct acpi_fadt_info { | 66 | typedef struct acpi_fadt_info { |
@@ -175,6 +176,7 @@ static struct acpi_fadt_pm_info fadt_pm_info_table[] = { | |||
175 | * space_id - ACPI Space ID for this register | 176 | * space_id - ACPI Space ID for this register |
176 | * byte_width - Width of this register | 177 | * byte_width - Width of this register |
177 | * address - Address of the register | 178 | * address - Address of the register |
179 | * register_name - ASCII name of the ACPI register | ||
178 | * | 180 | * |
179 | * RETURN: None | 181 | * RETURN: None |
180 | * | 182 | * |
@@ -220,6 +222,68 @@ acpi_tb_init_generic_address(struct acpi_generic_address *generic_address, | |||
220 | 222 | ||
221 | /******************************************************************************* | 223 | /******************************************************************************* |
222 | * | 224 | * |
225 | * FUNCTION: acpi_tb_select_address | ||
226 | * | ||
227 | * PARAMETERS: register_name - ASCII name of the ACPI register | ||
228 | * address32 - 32-bit address of the register | ||
229 | * address64 - 64-bit address of the register | ||
230 | * | ||
231 | * RETURN: The resolved 64-bit address | ||
232 | * | ||
233 | * DESCRIPTION: Select between 32-bit and 64-bit versions of addresses within | ||
234 | * the FADT. Used for the FACS and DSDT addresses. | ||
235 | * | ||
236 | * NOTES: | ||
237 | * | ||
238 | * Check for FACS and DSDT address mismatches. An address mismatch between | ||
239 | * the 32-bit and 64-bit address fields (FIRMWARE_CTRL/X_FIRMWARE_CTRL and | ||
240 | * DSDT/X_DSDT) could be a corrupted address field or it might indicate | ||
241 | * the presence of two FACS or two DSDT tables. | ||
242 | * | ||
243 | * November 2013: | ||
244 | * By default, as per the ACPICA specification, a valid 64-bit address is | ||
245 | * used regardless of the value of the 32-bit address. However, this | ||
246 | * behavior can be overridden via the acpi_gbl_use32_bit_fadt_addresses flag. | ||
247 | * | ||
248 | ******************************************************************************/ | ||
249 | |||
250 | static u64 | ||
251 | acpi_tb_select_address(char *register_name, u32 address32, u64 address64) | ||
252 | { | ||
253 | |||
254 | if (!address64) { | ||
255 | |||
256 | /* 64-bit address is zero, use 32-bit address */ | ||
257 | |||
258 | return ((u64)address32); | ||
259 | } | ||
260 | |||
261 | if (address32 && (address64 != (u64)address32)) { | ||
262 | |||
263 | /* Address mismatch between 32-bit and 64-bit versions */ | ||
264 | |||
265 | ACPI_BIOS_WARNING((AE_INFO, | ||
266 | "32/64X %s address mismatch in FADT: " | ||
267 | "0x%8.8X/0x%8.8X%8.8X, using %u-bit address", | ||
268 | register_name, address32, | ||
269 | ACPI_FORMAT_UINT64(address64), | ||
270 | acpi_gbl_use32_bit_fadt_addresses ? 32 : | ||
271 | 64)); | ||
272 | |||
273 | /* 32-bit address override */ | ||
274 | |||
275 | if (acpi_gbl_use32_bit_fadt_addresses) { | ||
276 | return ((u64)address32); | ||
277 | } | ||
278 | } | ||
279 | |||
280 | /* Default is to use the 64-bit address */ | ||
281 | |||
282 | return (address64); | ||
283 | } | ||
284 | |||
285 | /******************************************************************************* | ||
286 | * | ||
223 | * FUNCTION: acpi_tb_parse_fadt | 287 | * FUNCTION: acpi_tb_parse_fadt |
224 | * | 288 | * |
225 | * PARAMETERS: table_index - Index for the FADT | 289 | * PARAMETERS: table_index - Index for the FADT |
@@ -331,10 +395,6 @@ void acpi_tb_create_local_fadt(struct acpi_table_header *table, u32 length) | |||
331 | 395 | ||
332 | acpi_tb_convert_fadt(); | 396 | acpi_tb_convert_fadt(); |
333 | 397 | ||
334 | /* Validate FADT values now, before we make any changes */ | ||
335 | |||
336 | acpi_tb_validate_fadt(); | ||
337 | |||
338 | /* Initialize the global ACPI register structures */ | 398 | /* Initialize the global ACPI register structures */ |
339 | 399 | ||
340 | acpi_tb_setup_fadt_registers(); | 400 | acpi_tb_setup_fadt_registers(); |
@@ -344,66 +404,55 @@ void acpi_tb_create_local_fadt(struct acpi_table_header *table, u32 length) | |||
344 | * | 404 | * |
345 | * FUNCTION: acpi_tb_convert_fadt | 405 | * FUNCTION: acpi_tb_convert_fadt |
346 | * | 406 | * |
347 | * PARAMETERS: None, uses acpi_gbl_FADT | 407 | * PARAMETERS: none - acpi_gbl_FADT is used. |
348 | * | 408 | * |
349 | * RETURN: None | 409 | * RETURN: None |
350 | * | 410 | * |
351 | * DESCRIPTION: Converts all versions of the FADT to a common internal format. | 411 | * DESCRIPTION: Converts all versions of the FADT to a common internal format. |
352 | * Expand 32-bit addresses to 64-bit as necessary. | 412 | * Expand 32-bit addresses to 64-bit as necessary. Also validate |
413 | * important fields within the FADT. | ||
353 | * | 414 | * |
354 | * NOTE: acpi_gbl_FADT must be of size (struct acpi_table_fadt), | 415 | * NOTE: acpi_gbl_FADT must be of size (struct acpi_table_fadt), and must |
355 | * and must contain a copy of the actual FADT. | 416 | * contain a copy of the actual BIOS-provided FADT. |
356 | * | 417 | * |
357 | * Notes on 64-bit register addresses: | 418 | * Notes on 64-bit register addresses: |
358 | * | 419 | * |
359 | * After this FADT conversion, later ACPICA code will only use the 64-bit "X" | 420 | * After this FADT conversion, later ACPICA code will only use the 64-bit "X" |
360 | * fields of the FADT for all ACPI register addresses. | 421 | * fields of the FADT for all ACPI register addresses. |
361 | * | 422 | * |
362 | * The 64-bit "X" fields are optional extensions to the original 32-bit FADT | 423 | * The 64-bit X fields are optional extensions to the original 32-bit FADT |
363 | * V1.0 fields. Even if they are present in the FADT, they are optional and | 424 | * V1.0 fields. Even if they are present in the FADT, they are optional and |
364 | * are unused if the BIOS sets them to zero. Therefore, we must copy/expand | 425 | * are unused if the BIOS sets them to zero. Therefore, we must copy/expand |
365 | * 32-bit V1.0 fields if the corresponding X field is zero. | 426 | * 32-bit V1.0 fields to the 64-bit X fields if the the 64-bit X field is |
427 | * originally zero. | ||
366 | * | 428 | * |
367 | * For ACPI 1.0 FADTs, all 32-bit address fields are expanded to the | 429 | * For ACPI 1.0 FADTs (that contain no 64-bit addresses), all 32-bit address |
368 | * corresponding "X" fields in the internal FADT. | 430 | * fields are expanded to the corresponding 64-bit X fields in the internal |
431 | * common FADT. | ||
369 | * | 432 | * |
370 | * For ACPI 2.0+ FADTs, all valid (non-zero) 32-bit address fields are expanded | 433 | * For ACPI 2.0+ FADTs, all valid (non-zero) 32-bit address fields are expanded |
371 | * to the corresponding 64-bit X fields. For compatibility with other ACPI | 434 | * to the corresponding 64-bit X fields, if the 64-bit field is originally |
372 | * implementations, we ignore the 64-bit field if the 32-bit field is valid, | 435 | * zero. Adhering to the ACPI specification, we completely ignore the 32-bit |
373 | * regardless of whether the host OS is 32-bit or 64-bit. | 436 | * field if the 64-bit field is valid, regardless of whether the host OS is |
437 | * 32-bit or 64-bit. | ||
438 | * | ||
439 | * Possible additional checks: | ||
440 | * (acpi_gbl_FADT.pm1_event_length >= 4) | ||
441 | * (acpi_gbl_FADT.pm1_control_length >= 2) | ||
442 | * (acpi_gbl_FADT.pm_timer_length >= 4) | ||
443 | * Gpe block lengths must be multiple of 2 | ||
374 | * | 444 | * |
375 | ******************************************************************************/ | 445 | ******************************************************************************/ |
376 | 446 | ||
377 | static void acpi_tb_convert_fadt(void) | 447 | static void acpi_tb_convert_fadt(void) |
378 | { | 448 | { |
449 | char *name; | ||
379 | struct acpi_generic_address *address64; | 450 | struct acpi_generic_address *address64; |
380 | u32 address32; | 451 | u32 address32; |
452 | u8 length; | ||
381 | u32 i; | 453 | u32 i; |
382 | 454 | ||
383 | /* | 455 | /* |
384 | * Expand the 32-bit FACS and DSDT addresses to 64-bit as necessary. | ||
385 | * Later code will always use the X 64-bit field. Also, check for an | ||
386 | * address mismatch between the 32-bit and 64-bit address fields | ||
387 | * (FIRMWARE_CTRL/X_FIRMWARE_CTRL, DSDT/X_DSDT) which would indicate | ||
388 | * the presence of two FACS or two DSDT tables. | ||
389 | */ | ||
390 | if (!acpi_gbl_FADT.Xfacs) { | ||
391 | acpi_gbl_FADT.Xfacs = (u64) acpi_gbl_FADT.facs; | ||
392 | } else if (acpi_gbl_FADT.facs && | ||
393 | (acpi_gbl_FADT.Xfacs != (u64) acpi_gbl_FADT.facs)) { | ||
394 | ACPI_WARNING((AE_INFO, | ||
395 | "32/64 FACS address mismatch in FADT - two FACS tables!")); | ||
396 | } | ||
397 | |||
398 | if (!acpi_gbl_FADT.Xdsdt) { | ||
399 | acpi_gbl_FADT.Xdsdt = (u64) acpi_gbl_FADT.dsdt; | ||
400 | } else if (acpi_gbl_FADT.dsdt && | ||
401 | (acpi_gbl_FADT.Xdsdt != (u64) acpi_gbl_FADT.dsdt)) { | ||
402 | ACPI_WARNING((AE_INFO, | ||
403 | "32/64 DSDT address mismatch in FADT - two DSDT tables!")); | ||
404 | } | ||
405 | |||
406 | /* | ||
407 | * For ACPI 1.0 FADTs (revision 1 or 2), ensure that reserved fields which | 456 | * For ACPI 1.0 FADTs (revision 1 or 2), ensure that reserved fields which |
408 | * should be zero are indeed zero. This will workaround BIOSs that | 457 | * should be zero are indeed zero. This will workaround BIOSs that |
409 | * inadvertently place values in these fields. | 458 | * inadvertently place values in these fields. |
@@ -421,119 +470,24 @@ static void acpi_tb_convert_fadt(void) | |||
421 | acpi_gbl_FADT.boot_flags = 0; | 470 | acpi_gbl_FADT.boot_flags = 0; |
422 | } | 471 | } |
423 | 472 | ||
424 | /* Update the local FADT table header length */ | ||
425 | |||
426 | acpi_gbl_FADT.header.length = sizeof(struct acpi_table_fadt); | ||
427 | |||
428 | /* | 473 | /* |
429 | * Expand the ACPI 1.0 32-bit addresses to the ACPI 2.0 64-bit "X" | 474 | * Now we can update the local FADT length to the length of the |
430 | * generic address structures as necessary. Later code will always use | 475 | * current FADT version as defined by the ACPI specification. |
431 | * the 64-bit address structures. | 476 | * Thus, we will have a common FADT internally. |
432 | * | ||
433 | * March 2009: | ||
434 | * We now always use the 32-bit address if it is valid (non-null). This | ||
435 | * is not in accordance with the ACPI specification which states that | ||
436 | * the 64-bit address supersedes the 32-bit version, but we do this for | ||
437 | * compatibility with other ACPI implementations. Most notably, in the | ||
438 | * case where both the 32 and 64 versions are non-null, we use the 32-bit | ||
439 | * version. This is the only address that is guaranteed to have been | ||
440 | * tested by the BIOS manufacturer. | ||
441 | */ | 477 | */ |
442 | for (i = 0; i < ACPI_FADT_INFO_ENTRIES; i++) { | 478 | acpi_gbl_FADT.header.length = sizeof(struct acpi_table_fadt); |
443 | address32 = *ACPI_ADD_PTR(u32, | ||
444 | &acpi_gbl_FADT, | ||
445 | fadt_info_table[i].address32); | ||
446 | |||
447 | address64 = ACPI_ADD_PTR(struct acpi_generic_address, | ||
448 | &acpi_gbl_FADT, | ||
449 | fadt_info_table[i].address64); | ||
450 | |||
451 | /* | ||
452 | * If both 32- and 64-bit addresses are valid (non-zero), | ||
453 | * they must match. | ||
454 | */ | ||
455 | if (address64->address && address32 && | ||
456 | (address64->address != (u64)address32)) { | ||
457 | ACPI_BIOS_ERROR((AE_INFO, | ||
458 | "32/64X address mismatch in FADT/%s: " | ||
459 | "0x%8.8X/0x%8.8X%8.8X, using 32", | ||
460 | fadt_info_table[i].name, address32, | ||
461 | ACPI_FORMAT_UINT64(address64-> | ||
462 | address))); | ||
463 | } | ||
464 | |||
465 | /* Always use 32-bit address if it is valid (non-null) */ | ||
466 | |||
467 | if (address32) { | ||
468 | /* | ||
469 | * Copy the 32-bit address to the 64-bit GAS structure. The | ||
470 | * Space ID is always I/O for 32-bit legacy address fields | ||
471 | */ | ||
472 | acpi_tb_init_generic_address(address64, | ||
473 | ACPI_ADR_SPACE_SYSTEM_IO, | ||
474 | *ACPI_ADD_PTR(u8, | ||
475 | &acpi_gbl_FADT, | ||
476 | fadt_info_table | ||
477 | [i].length), | ||
478 | (u64) address32, | ||
479 | fadt_info_table[i].name); | ||
480 | } | ||
481 | } | ||
482 | } | ||
483 | |||
484 | /******************************************************************************* | ||
485 | * | ||
486 | * FUNCTION: acpi_tb_validate_fadt | ||
487 | * | ||
488 | * PARAMETERS: table - Pointer to the FADT to be validated | ||
489 | * | ||
490 | * RETURN: None | ||
491 | * | ||
492 | * DESCRIPTION: Validate various important fields within the FADT. If a problem | ||
493 | * is found, issue a message, but no status is returned. | ||
494 | * Used by both the table manager and the disassembler. | ||
495 | * | ||
496 | * Possible additional checks: | ||
497 | * (acpi_gbl_FADT.pm1_event_length >= 4) | ||
498 | * (acpi_gbl_FADT.pm1_control_length >= 2) | ||
499 | * (acpi_gbl_FADT.pm_timer_length >= 4) | ||
500 | * Gpe block lengths must be multiple of 2 | ||
501 | * | ||
502 | ******************************************************************************/ | ||
503 | |||
504 | static void acpi_tb_validate_fadt(void) | ||
505 | { | ||
506 | char *name; | ||
507 | struct acpi_generic_address *address64; | ||
508 | u8 length; | ||
509 | u32 i; | ||
510 | 479 | ||
511 | /* | 480 | /* |
512 | * Check for FACS and DSDT address mismatches. An address mismatch between | 481 | * Expand the 32-bit FACS and DSDT addresses to 64-bit as necessary. |
513 | * the 32-bit and 64-bit address fields (FIRMWARE_CTRL/X_FIRMWARE_CTRL and | 482 | * Later ACPICA code will always use the X 64-bit field. |
514 | * DSDT/X_DSDT) would indicate the presence of two FACS or two DSDT tables. | ||
515 | */ | 483 | */ |
516 | if (acpi_gbl_FADT.facs && | 484 | acpi_gbl_FADT.Xfacs = acpi_tb_select_address("FACS", |
517 | (acpi_gbl_FADT.Xfacs != (u64)acpi_gbl_FADT.facs)) { | 485 | acpi_gbl_FADT.facs, |
518 | ACPI_BIOS_WARNING((AE_INFO, | 486 | acpi_gbl_FADT.Xfacs); |
519 | "32/64X FACS address mismatch in FADT - " | ||
520 | "0x%8.8X/0x%8.8X%8.8X, using 32", | ||
521 | acpi_gbl_FADT.facs, | ||
522 | ACPI_FORMAT_UINT64(acpi_gbl_FADT.Xfacs))); | ||
523 | |||
524 | acpi_gbl_FADT.Xfacs = (u64)acpi_gbl_FADT.facs; | ||
525 | } | ||
526 | |||
527 | if (acpi_gbl_FADT.dsdt && | ||
528 | (acpi_gbl_FADT.Xdsdt != (u64)acpi_gbl_FADT.dsdt)) { | ||
529 | ACPI_BIOS_WARNING((AE_INFO, | ||
530 | "32/64X DSDT address mismatch in FADT - " | ||
531 | "0x%8.8X/0x%8.8X%8.8X, using 32", | ||
532 | acpi_gbl_FADT.dsdt, | ||
533 | ACPI_FORMAT_UINT64(acpi_gbl_FADT.Xdsdt))); | ||
534 | 487 | ||
535 | acpi_gbl_FADT.Xdsdt = (u64)acpi_gbl_FADT.dsdt; | 488 | acpi_gbl_FADT.Xdsdt = acpi_tb_select_address("DSDT", |
536 | } | 489 | acpi_gbl_FADT.dsdt, |
490 | acpi_gbl_FADT.Xdsdt); | ||
537 | 491 | ||
538 | /* If Hardware Reduced flag is set, we are all done */ | 492 | /* If Hardware Reduced flag is set, we are all done */ |
539 | 493 | ||
@@ -545,18 +499,95 @@ static void acpi_tb_validate_fadt(void) | |||
545 | 499 | ||
546 | for (i = 0; i < ACPI_FADT_INFO_ENTRIES; i++) { | 500 | for (i = 0; i < ACPI_FADT_INFO_ENTRIES; i++) { |
547 | /* | 501 | /* |
548 | * Generate pointer to the 64-bit address, get the register | 502 | * Get the 32-bit and 64-bit addresses, as well as the register |
549 | * length (width) and the register name | 503 | * length and register name. |
550 | */ | 504 | */ |
505 | address32 = *ACPI_ADD_PTR(u32, | ||
506 | &acpi_gbl_FADT, | ||
507 | fadt_info_table[i].address32); | ||
508 | |||
551 | address64 = ACPI_ADD_PTR(struct acpi_generic_address, | 509 | address64 = ACPI_ADD_PTR(struct acpi_generic_address, |
552 | &acpi_gbl_FADT, | 510 | &acpi_gbl_FADT, |
553 | fadt_info_table[i].address64); | 511 | fadt_info_table[i].address64); |
554 | length = | 512 | |
555 | *ACPI_ADD_PTR(u8, &acpi_gbl_FADT, | 513 | length = *ACPI_ADD_PTR(u8, |
556 | fadt_info_table[i].length); | 514 | &acpi_gbl_FADT, |
515 | fadt_info_table[i].length); | ||
516 | |||
557 | name = fadt_info_table[i].name; | 517 | name = fadt_info_table[i].name; |
558 | 518 | ||
559 | /* | 519 | /* |
520 | * Expand the ACPI 1.0 32-bit addresses to the ACPI 2.0 64-bit "X" | ||
521 | * generic address structures as necessary. Later code will always use | ||
522 | * the 64-bit address structures. | ||
523 | * | ||
524 | * November 2013: | ||
525 | * Now always use the 64-bit address if it is valid (non-zero), in | ||
526 | * accordance with the ACPI specification which states that a 64-bit | ||
527 | * address supersedes the 32-bit version. This behavior can be | ||
528 | * overridden by the acpi_gbl_use32_bit_fadt_addresses flag. | ||
529 | * | ||
530 | * During 64-bit address construction and verification, | ||
531 | * these cases are handled: | ||
532 | * | ||
533 | * Address32 zero, Address64 [don't care] - Use Address64 | ||
534 | * | ||
535 | * Address32 non-zero, Address64 zero - Copy/use Address32 | ||
536 | * Address32 non-zero == Address64 non-zero - Use Address64 | ||
537 | * Address32 non-zero != Address64 non-zero - Warning, use Address64 | ||
538 | * | ||
539 | * Override: if acpi_gbl_use32_bit_fadt_addresses is TRUE, and: | ||
540 | * Address32 non-zero != Address64 non-zero - Warning, copy/use Address32 | ||
541 | * | ||
542 | * Note: space_id is always I/O for 32-bit legacy address fields | ||
543 | */ | ||
544 | if (address32) { | ||
545 | if (!address64->address) { | ||
546 | |||
547 | /* 64-bit address is zero, use 32-bit address */ | ||
548 | |||
549 | acpi_tb_init_generic_address(address64, | ||
550 | ACPI_ADR_SPACE_SYSTEM_IO, | ||
551 | *ACPI_ADD_PTR(u8, | ||
552 | &acpi_gbl_FADT, | ||
553 | fadt_info_table | ||
554 | [i]. | ||
555 | length), | ||
556 | (u64)address32, | ||
557 | name); | ||
558 | } else if (address64->address != (u64)address32) { | ||
559 | |||
560 | /* Address mismatch */ | ||
561 | |||
562 | ACPI_BIOS_WARNING((AE_INFO, | ||
563 | "32/64X address mismatch in FADT/%s: " | ||
564 | "0x%8.8X/0x%8.8X%8.8X, using %u-bit address", | ||
565 | name, address32, | ||
566 | ACPI_FORMAT_UINT64 | ||
567 | (address64->address), | ||
568 | acpi_gbl_use32_bit_fadt_addresses | ||
569 | ? 32 : 64)); | ||
570 | |||
571 | if (acpi_gbl_use32_bit_fadt_addresses) { | ||
572 | |||
573 | /* 32-bit address override */ | ||
574 | |||
575 | acpi_tb_init_generic_address(address64, | ||
576 | ACPI_ADR_SPACE_SYSTEM_IO, | ||
577 | *ACPI_ADD_PTR | ||
578 | (u8, | ||
579 | &acpi_gbl_FADT, | ||
580 | fadt_info_table | ||
581 | [i]. | ||
582 | length), | ||
583 | (u64) | ||
584 | address32, | ||
585 | name); | ||
586 | } | ||
587 | } | ||
588 | } | ||
589 | |||
590 | /* | ||
560 | * For each extended field, check for length mismatch between the | 591 | * For each extended field, check for length mismatch between the |
561 | * legacy length field and the corresponding 64-bit X length field. | 592 | * legacy length field and the corresponding 64-bit X length field. |
562 | * Note: If the legacy length field is > 0xFF bits, ignore this | 593 | * Note: If the legacy length field is > 0xFF bits, ignore this |
diff --git a/drivers/acpi/acpica/tbutils.c b/drivers/acpi/acpica/tbutils.c index 3d6bb83aa7e7..6412d3c301cb 100644 --- a/drivers/acpi/acpica/tbutils.c +++ b/drivers/acpi/acpica/tbutils.c | |||
@@ -49,69 +49,11 @@ | |||
49 | ACPI_MODULE_NAME("tbutils") | 49 | ACPI_MODULE_NAME("tbutils") |
50 | 50 | ||
51 | /* Local prototypes */ | 51 | /* Local prototypes */ |
52 | static acpi_status acpi_tb_validate_xsdt(acpi_physical_address address); | ||
53 | |||
52 | static acpi_physical_address | 54 | static acpi_physical_address |
53 | acpi_tb_get_root_table_entry(u8 *table_entry, u32 table_entry_size); | 55 | acpi_tb_get_root_table_entry(u8 *table_entry, u32 table_entry_size); |
54 | 56 | ||
55 | /******************************************************************************* | ||
56 | * | ||
57 | * FUNCTION: acpi_tb_check_xsdt | ||
58 | * | ||
59 | * PARAMETERS: address - Pointer to the XSDT | ||
60 | * | ||
61 | * RETURN: status | ||
62 | * AE_OK - XSDT is okay | ||
63 | * AE_NO_MEMORY - can't map XSDT | ||
64 | * AE_INVALID_TABLE_LENGTH - invalid table length | ||
65 | * AE_NULL_ENTRY - XSDT has NULL entry | ||
66 | * | ||
67 | * DESCRIPTION: validate XSDT | ||
68 | ******************************************************************************/ | ||
69 | |||
70 | static acpi_status | ||
71 | acpi_tb_check_xsdt(acpi_physical_address address) | ||
72 | { | ||
73 | struct acpi_table_header *table; | ||
74 | u32 length; | ||
75 | u64 xsdt_entry_address; | ||
76 | u8 *table_entry; | ||
77 | u32 table_count; | ||
78 | int i; | ||
79 | |||
80 | table = acpi_os_map_memory(address, sizeof(struct acpi_table_header)); | ||
81 | if (!table) | ||
82 | return AE_NO_MEMORY; | ||
83 | |||
84 | length = table->length; | ||
85 | acpi_os_unmap_memory(table, sizeof(struct acpi_table_header)); | ||
86 | if (length < sizeof(struct acpi_table_header)) | ||
87 | return AE_INVALID_TABLE_LENGTH; | ||
88 | |||
89 | table = acpi_os_map_memory(address, length); | ||
90 | if (!table) | ||
91 | return AE_NO_MEMORY; | ||
92 | |||
93 | /* Calculate the number of tables described in XSDT */ | ||
94 | table_count = | ||
95 | (u32) ((table->length - | ||
96 | sizeof(struct acpi_table_header)) / sizeof(u64)); | ||
97 | table_entry = | ||
98 | ACPI_CAST_PTR(u8, table) + sizeof(struct acpi_table_header); | ||
99 | for (i = 0; i < table_count; i++) { | ||
100 | ACPI_MOVE_64_TO_64(&xsdt_entry_address, table_entry); | ||
101 | if (!xsdt_entry_address) { | ||
102 | /* XSDT has NULL entry */ | ||
103 | break; | ||
104 | } | ||
105 | table_entry += sizeof(u64); | ||
106 | } | ||
107 | acpi_os_unmap_memory(table, length); | ||
108 | |||
109 | if (i < table_count) | ||
110 | return AE_NULL_ENTRY; | ||
111 | else | ||
112 | return AE_OK; | ||
113 | } | ||
114 | |||
115 | #if (!ACPI_REDUCED_HARDWARE) | 57 | #if (!ACPI_REDUCED_HARDWARE) |
116 | /******************************************************************************* | 58 | /******************************************************************************* |
117 | * | 59 | * |
@@ -383,7 +325,7 @@ acpi_tb_get_root_table_entry(u8 *table_entry, u32 table_entry_size) | |||
383 | * Get the table physical address (32-bit for RSDT, 64-bit for XSDT): | 325 | * Get the table physical address (32-bit for RSDT, 64-bit for XSDT): |
384 | * Note: Addresses are 32-bit aligned (not 64) in both RSDT and XSDT | 326 | * Note: Addresses are 32-bit aligned (not 64) in both RSDT and XSDT |
385 | */ | 327 | */ |
386 | if (table_entry_size == sizeof(u32)) { | 328 | if (table_entry_size == ACPI_RSDT_ENTRY_SIZE) { |
387 | /* | 329 | /* |
388 | * 32-bit platform, RSDT: Return 32-bit table entry | 330 | * 32-bit platform, RSDT: Return 32-bit table entry |
389 | * 64-bit platform, RSDT: Expand 32-bit to 64-bit and return | 331 | * 64-bit platform, RSDT: Expand 32-bit to 64-bit and return |
@@ -415,6 +357,87 @@ acpi_tb_get_root_table_entry(u8 *table_entry, u32 table_entry_size) | |||
415 | 357 | ||
416 | /******************************************************************************* | 358 | /******************************************************************************* |
417 | * | 359 | * |
360 | * FUNCTION: acpi_tb_validate_xsdt | ||
361 | * | ||
362 | * PARAMETERS: address - Physical address of the XSDT (from RSDP) | ||
363 | * | ||
364 | * RETURN: Status. AE_OK if the table appears to be valid. | ||
365 | * | ||
366 | * DESCRIPTION: Validate an XSDT to ensure that it is of minimum size and does | ||
367 | * not contain any NULL entries. A problem that is seen in the | ||
368 | * field is that the XSDT exists, but is actually useless because | ||
369 | * of one or more (or all) NULL entries. | ||
370 | * | ||
371 | ******************************************************************************/ | ||
372 | |||
373 | static acpi_status acpi_tb_validate_xsdt(acpi_physical_address xsdt_address) | ||
374 | { | ||
375 | struct acpi_table_header *table; | ||
376 | u8 *next_entry; | ||
377 | acpi_physical_address address; | ||
378 | u32 length; | ||
379 | u32 entry_count; | ||
380 | acpi_status status; | ||
381 | u32 i; | ||
382 | |||
383 | /* Get the XSDT length */ | ||
384 | |||
385 | table = | ||
386 | acpi_os_map_memory(xsdt_address, sizeof(struct acpi_table_header)); | ||
387 | if (!table) { | ||
388 | return (AE_NO_MEMORY); | ||
389 | } | ||
390 | |||
391 | length = table->length; | ||
392 | acpi_os_unmap_memory(table, sizeof(struct acpi_table_header)); | ||
393 | |||
394 | /* | ||
395 | * Minimum XSDT length is the size of the standard ACPI header | ||
396 | * plus one physical address entry | ||
397 | */ | ||
398 | if (length < (sizeof(struct acpi_table_header) + ACPI_XSDT_ENTRY_SIZE)) { | ||
399 | return (AE_INVALID_TABLE_LENGTH); | ||
400 | } | ||
401 | |||
402 | /* Map the entire XSDT */ | ||
403 | |||
404 | table = acpi_os_map_memory(xsdt_address, length); | ||
405 | if (!table) { | ||
406 | return (AE_NO_MEMORY); | ||
407 | } | ||
408 | |||
409 | /* Get the number of entries and pointer to first entry */ | ||
410 | |||
411 | status = AE_OK; | ||
412 | next_entry = ACPI_ADD_PTR(u8, table, sizeof(struct acpi_table_header)); | ||
413 | entry_count = (u32)((table->length - sizeof(struct acpi_table_header)) / | ||
414 | ACPI_XSDT_ENTRY_SIZE); | ||
415 | |||
416 | /* Validate each entry (physical address) within the XSDT */ | ||
417 | |||
418 | for (i = 0; i < entry_count; i++) { | ||
419 | address = | ||
420 | acpi_tb_get_root_table_entry(next_entry, | ||
421 | ACPI_XSDT_ENTRY_SIZE); | ||
422 | if (!address) { | ||
423 | |||
424 | /* Detected a NULL entry, XSDT is invalid */ | ||
425 | |||
426 | status = AE_NULL_ENTRY; | ||
427 | break; | ||
428 | } | ||
429 | |||
430 | next_entry += ACPI_XSDT_ENTRY_SIZE; | ||
431 | } | ||
432 | |||
433 | /* Unmap table */ | ||
434 | |||
435 | acpi_os_unmap_memory(table, length); | ||
436 | return (status); | ||
437 | } | ||
438 | |||
439 | /******************************************************************************* | ||
440 | * | ||
418 | * FUNCTION: acpi_tb_parse_root_table | 441 | * FUNCTION: acpi_tb_parse_root_table |
419 | * | 442 | * |
420 | * PARAMETERS: rsdp - Pointer to the RSDP | 443 | * PARAMETERS: rsdp - Pointer to the RSDP |
@@ -438,16 +461,14 @@ acpi_status __init acpi_tb_parse_root_table(acpi_physical_address rsdp_address) | |||
438 | u32 table_count; | 461 | u32 table_count; |
439 | struct acpi_table_header *table; | 462 | struct acpi_table_header *table; |
440 | acpi_physical_address address; | 463 | acpi_physical_address address; |
441 | acpi_physical_address uninitialized_var(rsdt_address); | ||
442 | u32 length; | 464 | u32 length; |
443 | u8 *table_entry; | 465 | u8 *table_entry; |
444 | acpi_status status; | 466 | acpi_status status; |
445 | 467 | ||
446 | ACPI_FUNCTION_TRACE(tb_parse_root_table); | 468 | ACPI_FUNCTION_TRACE(tb_parse_root_table); |
447 | 469 | ||
448 | /* | 470 | /* Map the entire RSDP and extract the address of the RSDT or XSDT */ |
449 | * Map the entire RSDP and extract the address of the RSDT or XSDT | 471 | |
450 | */ | ||
451 | rsdp = acpi_os_map_memory(rsdp_address, sizeof(struct acpi_table_rsdp)); | 472 | rsdp = acpi_os_map_memory(rsdp_address, sizeof(struct acpi_table_rsdp)); |
452 | if (!rsdp) { | 473 | if (!rsdp) { |
453 | return_ACPI_STATUS(AE_NO_MEMORY); | 474 | return_ACPI_STATUS(AE_NO_MEMORY); |
@@ -457,24 +478,22 @@ acpi_status __init acpi_tb_parse_root_table(acpi_physical_address rsdp_address) | |||
457 | ACPI_CAST_PTR(struct acpi_table_header, | 478 | ACPI_CAST_PTR(struct acpi_table_header, |
458 | rsdp)); | 479 | rsdp)); |
459 | 480 | ||
460 | /* Differentiate between RSDT and XSDT root tables */ | 481 | /* Use XSDT if present and not overridden. Otherwise, use RSDT */ |
461 | 482 | ||
462 | if (rsdp->revision > 1 && rsdp->xsdt_physical_address | 483 | if ((rsdp->revision > 1) && |
463 | && !acpi_rsdt_forced) { | 484 | rsdp->xsdt_physical_address && !acpi_gbl_do_not_use_xsdt) { |
464 | /* | 485 | /* |
465 | * Root table is an XSDT (64-bit physical addresses). We must use the | 486 | * RSDP contains an XSDT (64-bit physical addresses). We must use |
466 | * XSDT if the revision is > 1 and the XSDT pointer is present, as per | 487 | * the XSDT if the revision is > 1 and the XSDT pointer is present, |
467 | * the ACPI specification. | 488 | * as per the ACPI specification. |
468 | */ | 489 | */ |
469 | address = (acpi_physical_address) rsdp->xsdt_physical_address; | 490 | address = (acpi_physical_address) rsdp->xsdt_physical_address; |
470 | table_entry_size = sizeof(u64); | 491 | table_entry_size = ACPI_XSDT_ENTRY_SIZE; |
471 | rsdt_address = (acpi_physical_address) | ||
472 | rsdp->rsdt_physical_address; | ||
473 | } else { | 492 | } else { |
474 | /* Root table is an RSDT (32-bit physical addresses) */ | 493 | /* Root table is an RSDT (32-bit physical addresses) */ |
475 | 494 | ||
476 | address = (acpi_physical_address) rsdp->rsdt_physical_address; | 495 | address = (acpi_physical_address) rsdp->rsdt_physical_address; |
477 | table_entry_size = sizeof(u32); | 496 | table_entry_size = ACPI_RSDT_ENTRY_SIZE; |
478 | } | 497 | } |
479 | 498 | ||
480 | /* | 499 | /* |
@@ -483,15 +502,25 @@ acpi_status __init acpi_tb_parse_root_table(acpi_physical_address rsdp_address) | |||
483 | */ | 502 | */ |
484 | acpi_os_unmap_memory(rsdp, sizeof(struct acpi_table_rsdp)); | 503 | acpi_os_unmap_memory(rsdp, sizeof(struct acpi_table_rsdp)); |
485 | 504 | ||
486 | if (table_entry_size == sizeof(u64)) { | 505 | /* |
487 | if (acpi_tb_check_xsdt(address) == AE_NULL_ENTRY) { | 506 | * If it is present and used, validate the XSDT for access/size |
488 | /* XSDT has NULL entry, RSDT is used */ | 507 | * and ensure that all table entries are at least non-NULL |
489 | address = rsdt_address; | 508 | */ |
490 | table_entry_size = sizeof(u32); | 509 | if (table_entry_size == ACPI_XSDT_ENTRY_SIZE) { |
491 | ACPI_WARNING((AE_INFO, "BIOS XSDT has NULL entry, " | 510 | status = acpi_tb_validate_xsdt(address); |
492 | "using RSDT")); | 511 | if (ACPI_FAILURE(status)) { |
512 | ACPI_BIOS_WARNING((AE_INFO, | ||
513 | "XSDT is invalid (%s), using RSDT", | ||
514 | acpi_format_exception(status))); | ||
515 | |||
516 | /* Fall back to the RSDT */ | ||
517 | |||
518 | address = | ||
519 | (acpi_physical_address) rsdp->rsdt_physical_address; | ||
520 | table_entry_size = ACPI_RSDT_ENTRY_SIZE; | ||
493 | } | 521 | } |
494 | } | 522 | } |
523 | |||
495 | /* Map the RSDT/XSDT table header to get the full table length */ | 524 | /* Map the RSDT/XSDT table header to get the full table length */ |
496 | 525 | ||
497 | table = acpi_os_map_memory(address, sizeof(struct acpi_table_header)); | 526 | table = acpi_os_map_memory(address, sizeof(struct acpi_table_header)); |
@@ -501,12 +530,14 @@ acpi_status __init acpi_tb_parse_root_table(acpi_physical_address rsdp_address) | |||
501 | 530 | ||
502 | acpi_tb_print_table_header(address, table); | 531 | acpi_tb_print_table_header(address, table); |
503 | 532 | ||
504 | /* Get the length of the full table, verify length and map entire table */ | 533 | /* |
505 | 534 | * Validate length of the table, and map entire table. | |
535 | * Minimum length table must contain at least one entry. | ||
536 | */ | ||
506 | length = table->length; | 537 | length = table->length; |
507 | acpi_os_unmap_memory(table, sizeof(struct acpi_table_header)); | 538 | acpi_os_unmap_memory(table, sizeof(struct acpi_table_header)); |
508 | 539 | ||
509 | if (length < sizeof(struct acpi_table_header)) { | 540 | if (length < (sizeof(struct acpi_table_header) + table_entry_size)) { |
510 | ACPI_BIOS_ERROR((AE_INFO, | 541 | ACPI_BIOS_ERROR((AE_INFO, |
511 | "Invalid table length 0x%X in RSDT/XSDT", | 542 | "Invalid table length 0x%X in RSDT/XSDT", |
512 | length)); | 543 | length)); |
@@ -526,22 +557,21 @@ acpi_status __init acpi_tb_parse_root_table(acpi_physical_address rsdp_address) | |||
526 | return_ACPI_STATUS(status); | 557 | return_ACPI_STATUS(status); |
527 | } | 558 | } |
528 | 559 | ||
529 | /* Calculate the number of tables described in the root table */ | 560 | /* Get the number of entries and pointer to first entry */ |
530 | 561 | ||
531 | table_count = (u32)((table->length - sizeof(struct acpi_table_header)) / | 562 | table_count = (u32)((table->length - sizeof(struct acpi_table_header)) / |
532 | table_entry_size); | 563 | table_entry_size); |
564 | table_entry = ACPI_ADD_PTR(u8, table, sizeof(struct acpi_table_header)); | ||
565 | |||
533 | /* | 566 | /* |
534 | * First two entries in the table array are reserved for the DSDT | 567 | * First two entries in the table array are reserved for the DSDT |
535 | * and FACS, which are not actually present in the RSDT/XSDT - they | 568 | * and FACS, which are not actually present in the RSDT/XSDT - they |
536 | * come from the FADT | 569 | * come from the FADT |
537 | */ | 570 | */ |
538 | table_entry = | ||
539 | ACPI_CAST_PTR(u8, table) + sizeof(struct acpi_table_header); | ||
540 | acpi_gbl_root_table_list.current_table_count = 2; | 571 | acpi_gbl_root_table_list.current_table_count = 2; |
541 | 572 | ||
542 | /* | 573 | /* Initialize the root table array from the RSDT/XSDT */ |
543 | * Initialize the root table array from the RSDT/XSDT | 574 | |
544 | */ | ||
545 | for (i = 0; i < table_count; i++) { | 575 | for (i = 0; i < table_count; i++) { |
546 | if (acpi_gbl_root_table_list.current_table_count >= | 576 | if (acpi_gbl_root_table_list.current_table_count >= |
547 | acpi_gbl_root_table_list.max_table_count) { | 577 | acpi_gbl_root_table_list.max_table_count) { |
@@ -584,7 +614,7 @@ acpi_status __init acpi_tb_parse_root_table(acpi_physical_address rsdp_address) | |||
584 | acpi_tb_install_table(acpi_gbl_root_table_list.tables[i]. | 614 | acpi_tb_install_table(acpi_gbl_root_table_list.tables[i]. |
585 | address, NULL, i); | 615 | address, NULL, i); |
586 | 616 | ||
587 | /* Special case for FADT - get the DSDT and FACS */ | 617 | /* Special case for FADT - validate it then get the DSDT and FACS */ |
588 | 618 | ||
589 | if (ACPI_COMPARE_NAME | 619 | if (ACPI_COMPARE_NAME |
590 | (&acpi_gbl_root_table_list.tables[i].signature, | 620 | (&acpi_gbl_root_table_list.tables[i].signature, |
diff --git a/drivers/acpi/acpica/utaddress.c b/drivers/acpi/acpica/utaddress.c index e0a2e2779c2e..2c2b6ae5dfc4 100644 --- a/drivers/acpi/acpica/utaddress.c +++ b/drivers/acpi/acpica/utaddress.c | |||
@@ -224,10 +224,11 @@ acpi_ut_check_address_range(acpi_adr_space_type space_id, | |||
224 | 224 | ||
225 | while (range_info) { | 225 | while (range_info) { |
226 | /* | 226 | /* |
227 | * Check if the requested Address/Length overlaps this address_range. | 227 | * Check if the requested address/length overlaps this |
228 | * Four cases to consider: | 228 | * address range. There are four cases to consider: |
229 | * | 229 | * |
230 | * 1) Input address/length is contained completely in the address range | 230 | * 1) Input address/length is contained completely in the |
231 | * address range | ||
231 | * 2) Input address/length overlaps range at the range start | 232 | * 2) Input address/length overlaps range at the range start |
232 | * 3) Input address/length overlaps range at the range end | 233 | * 3) Input address/length overlaps range at the range end |
233 | * 4) Input address/length completely encompasses the range | 234 | * 4) Input address/length completely encompasses the range |
@@ -244,11 +245,17 @@ acpi_ut_check_address_range(acpi_adr_space_type space_id, | |||
244 | region_node); | 245 | region_node); |
245 | 246 | ||
246 | ACPI_WARNING((AE_INFO, | 247 | ACPI_WARNING((AE_INFO, |
247 | "0x%p-0x%p %s conflicts with Region %s %d", | 248 | "%s range 0x%p-0x%p conflicts with OpRegion 0x%p-0x%p (%s)", |
249 | acpi_ut_get_region_name(space_id), | ||
248 | ACPI_CAST_PTR(void, address), | 250 | ACPI_CAST_PTR(void, address), |
249 | ACPI_CAST_PTR(void, end_address), | 251 | ACPI_CAST_PTR(void, end_address), |
250 | acpi_ut_get_region_name(space_id), | 252 | ACPI_CAST_PTR(void, |
251 | pathname, overlap_count)); | 253 | range_info-> |
254 | start_address), | ||
255 | ACPI_CAST_PTR(void, | ||
256 | range_info-> | ||
257 | end_address), | ||
258 | pathname)); | ||
252 | ACPI_FREE(pathname); | 259 | ACPI_FREE(pathname); |
253 | } | 260 | } |
254 | } | 261 | } |
diff --git a/drivers/acpi/acpica/utalloc.c b/drivers/acpi/acpica/utalloc.c index 814267f52715..1851762fc5b5 100644 --- a/drivers/acpi/acpica/utalloc.c +++ b/drivers/acpi/acpica/utalloc.c | |||
@@ -302,9 +302,13 @@ acpi_ut_initialize_buffer(struct acpi_buffer * buffer, | |||
302 | return (AE_BUFFER_OVERFLOW); | 302 | return (AE_BUFFER_OVERFLOW); |
303 | 303 | ||
304 | case ACPI_ALLOCATE_BUFFER: | 304 | case ACPI_ALLOCATE_BUFFER: |
305 | 305 | /* | |
306 | /* Allocate a new buffer */ | 306 | * Allocate a new buffer. We directectly call acpi_os_allocate here to |
307 | 307 | * purposefully bypass the (optionally enabled) internal allocation | |
308 | * tracking mechanism since we only want to track internal | ||
309 | * allocations. Note: The caller should use acpi_os_free to free this | ||
310 | * buffer created via ACPI_ALLOCATE_BUFFER. | ||
311 | */ | ||
308 | buffer->pointer = acpi_os_allocate(required_length); | 312 | buffer->pointer = acpi_os_allocate(required_length); |
309 | break; | 313 | break; |
310 | 314 | ||
diff --git a/drivers/acpi/acpica/utcache.c b/drivers/acpi/acpica/utcache.c index 366bfec4b770..cacd2fd9e665 100644 --- a/drivers/acpi/acpica/utcache.c +++ b/drivers/acpi/acpica/utcache.c | |||
@@ -248,12 +248,12 @@ void *acpi_os_acquire_object(struct acpi_memory_list *cache) | |||
248 | ACPI_FUNCTION_NAME(os_acquire_object); | 248 | ACPI_FUNCTION_NAME(os_acquire_object); |
249 | 249 | ||
250 | if (!cache) { | 250 | if (!cache) { |
251 | return (NULL); | 251 | return_PTR(NULL); |
252 | } | 252 | } |
253 | 253 | ||
254 | status = acpi_ut_acquire_mutex(ACPI_MTX_CACHES); | 254 | status = acpi_ut_acquire_mutex(ACPI_MTX_CACHES); |
255 | if (ACPI_FAILURE(status)) { | 255 | if (ACPI_FAILURE(status)) { |
256 | return (NULL); | 256 | return_PTR(NULL); |
257 | } | 257 | } |
258 | 258 | ||
259 | ACPI_MEM_TRACKING(cache->requests++); | 259 | ACPI_MEM_TRACKING(cache->requests++); |
@@ -276,7 +276,7 @@ void *acpi_os_acquire_object(struct acpi_memory_list *cache) | |||
276 | 276 | ||
277 | status = acpi_ut_release_mutex(ACPI_MTX_CACHES); | 277 | status = acpi_ut_release_mutex(ACPI_MTX_CACHES); |
278 | if (ACPI_FAILURE(status)) { | 278 | if (ACPI_FAILURE(status)) { |
279 | return (NULL); | 279 | return_PTR(NULL); |
280 | } | 280 | } |
281 | 281 | ||
282 | /* Clear (zero) the previously used Object */ | 282 | /* Clear (zero) the previously used Object */ |
@@ -299,15 +299,15 @@ void *acpi_os_acquire_object(struct acpi_memory_list *cache) | |||
299 | 299 | ||
300 | status = acpi_ut_release_mutex(ACPI_MTX_CACHES); | 300 | status = acpi_ut_release_mutex(ACPI_MTX_CACHES); |
301 | if (ACPI_FAILURE(status)) { | 301 | if (ACPI_FAILURE(status)) { |
302 | return (NULL); | 302 | return_PTR(NULL); |
303 | } | 303 | } |
304 | 304 | ||
305 | object = ACPI_ALLOCATE_ZEROED(cache->object_size); | 305 | object = ACPI_ALLOCATE_ZEROED(cache->object_size); |
306 | if (!object) { | 306 | if (!object) { |
307 | return (NULL); | 307 | return_PTR(NULL); |
308 | } | 308 | } |
309 | } | 309 | } |
310 | 310 | ||
311 | return (object); | 311 | return_PTR(object); |
312 | } | 312 | } |
313 | #endif /* ACPI_USE_LOCAL_CACHE */ | 313 | #endif /* ACPI_USE_LOCAL_CACHE */ |
diff --git a/drivers/acpi/acpica/utdebug.c b/drivers/acpi/acpica/utdebug.c index 03ae8affe48f..d971c8631263 100644 --- a/drivers/acpi/acpica/utdebug.c +++ b/drivers/acpi/acpica/utdebug.c | |||
@@ -194,9 +194,9 @@ acpi_debug_print(u32 requested_debug_level, | |||
194 | */ | 194 | */ |
195 | acpi_os_printf("%9s-%04ld ", module_name, line_number); | 195 | acpi_os_printf("%9s-%04ld ", module_name, line_number); |
196 | 196 | ||
197 | #ifdef ACPI_EXEC_APP | 197 | #ifdef ACPI_APPLICATION |
198 | /* | 198 | /* |
199 | * For acpi_exec only, emit the thread ID and nesting level. | 199 | * For acpi_exec/iASL only, emit the thread ID and nesting level. |
200 | * Note: nesting level is really only useful during a single-thread | 200 | * Note: nesting level is really only useful during a single-thread |
201 | * execution. Otherwise, multiple threads will keep resetting the | 201 | * execution. Otherwise, multiple threads will keep resetting the |
202 | * level. | 202 | * level. |
diff --git a/drivers/acpi/acpica/utglobal.c b/drivers/acpi/acpica/utglobal.c index 81f9a9584451..030cb0dc673c 100644 --- a/drivers/acpi/acpica/utglobal.c +++ b/drivers/acpi/acpica/utglobal.c | |||
@@ -388,11 +388,7 @@ acpi_status acpi_ut_init_globals(void) | |||
388 | /* Public globals */ | 388 | /* Public globals */ |
389 | 389 | ||
390 | ACPI_EXPORT_SYMBOL(acpi_gbl_FADT) | 390 | ACPI_EXPORT_SYMBOL(acpi_gbl_FADT) |
391 | |||
392 | ACPI_EXPORT_SYMBOL(acpi_dbg_level) | 391 | ACPI_EXPORT_SYMBOL(acpi_dbg_level) |
393 | |||
394 | ACPI_EXPORT_SYMBOL(acpi_dbg_layer) | 392 | ACPI_EXPORT_SYMBOL(acpi_dbg_layer) |
395 | |||
396 | ACPI_EXPORT_SYMBOL(acpi_gpe_count) | 393 | ACPI_EXPORT_SYMBOL(acpi_gpe_count) |
397 | |||
398 | ACPI_EXPORT_SYMBOL(acpi_current_gpe_count) | 394 | ACPI_EXPORT_SYMBOL(acpi_current_gpe_count) |
diff --git a/drivers/acpi/acpica/utxfinit.c b/drivers/acpi/acpica/utxfinit.c index 75efea0539c1..246ef68681f4 100644 --- a/drivers/acpi/acpica/utxfinit.c +++ b/drivers/acpi/acpica/utxfinit.c | |||
@@ -122,8 +122,16 @@ acpi_status __init acpi_initialize_subsystem(void) | |||
122 | 122 | ||
123 | /* If configured, initialize the AML debugger */ | 123 | /* If configured, initialize the AML debugger */ |
124 | 124 | ||
125 | ACPI_DEBUGGER_EXEC(status = acpi_db_initialize()); | 125 | #ifdef ACPI_DEBUGGER |
126 | return_ACPI_STATUS(status); | 126 | status = acpi_db_initialize(); |
127 | if (ACPI_FAILURE(status)) { | ||
128 | ACPI_EXCEPTION((AE_INFO, status, | ||
129 | "During Debugger initialization")); | ||
130 | return_ACPI_STATUS(status); | ||
131 | } | ||
132 | #endif | ||
133 | |||
134 | return_ACPI_STATUS(AE_OK); | ||
127 | } | 135 | } |
128 | 136 | ||
129 | ACPI_EXPORT_SYMBOL_INIT(acpi_initialize_subsystem) | 137 | ACPI_EXPORT_SYMBOL_INIT(acpi_initialize_subsystem) |
diff --git a/drivers/acpi/apei/Kconfig b/drivers/acpi/apei/Kconfig index 786294bb682c..3650b2183227 100644 --- a/drivers/acpi/apei/Kconfig +++ b/drivers/acpi/apei/Kconfig | |||
@@ -2,7 +2,6 @@ config ACPI_APEI | |||
2 | bool "ACPI Platform Error Interface (APEI)" | 2 | bool "ACPI Platform Error Interface (APEI)" |
3 | select MISC_FILESYSTEMS | 3 | select MISC_FILESYSTEMS |
4 | select PSTORE | 4 | select PSTORE |
5 | select EFI | ||
6 | select UEFI_CPER | 5 | select UEFI_CPER |
7 | depends on X86 | 6 | depends on X86 |
8 | help | 7 | help |
diff --git a/drivers/acpi/apei/apei-base.c b/drivers/acpi/apei/apei-base.c index 6d2c49b86b7f..0760b75f79cc 100644 --- a/drivers/acpi/apei/apei-base.c +++ b/drivers/acpi/apei/apei-base.c | |||
@@ -34,7 +34,6 @@ | |||
34 | #include <linux/module.h> | 34 | #include <linux/module.h> |
35 | #include <linux/init.h> | 35 | #include <linux/init.h> |
36 | #include <linux/acpi.h> | 36 | #include <linux/acpi.h> |
37 | #include <linux/acpi_io.h> | ||
38 | #include <linux/slab.h> | 37 | #include <linux/slab.h> |
39 | #include <linux/io.h> | 38 | #include <linux/io.h> |
40 | #include <linux/kref.h> | 39 | #include <linux/kref.h> |
diff --git a/drivers/acpi/apei/apei-internal.h b/drivers/acpi/apei/apei-internal.h index 21ba34a73883..e5bcd919d4e6 100644 --- a/drivers/acpi/apei/apei-internal.h +++ b/drivers/acpi/apei/apei-internal.h | |||
@@ -8,7 +8,6 @@ | |||
8 | 8 | ||
9 | #include <linux/cper.h> | 9 | #include <linux/cper.h> |
10 | #include <linux/acpi.h> | 10 | #include <linux/acpi.h> |
11 | #include <linux/acpi_io.h> | ||
12 | 11 | ||
13 | struct apei_exec_context; | 12 | struct apei_exec_context; |
14 | 13 | ||
diff --git a/drivers/acpi/apei/einj.c b/drivers/acpi/apei/einj.c index fb57d03e698b..ca0c6d7ec0d4 100644 --- a/drivers/acpi/apei/einj.c +++ b/drivers/acpi/apei/einj.c | |||
@@ -33,7 +33,6 @@ | |||
33 | #include <linux/nmi.h> | 33 | #include <linux/nmi.h> |
34 | #include <linux/delay.h> | 34 | #include <linux/delay.h> |
35 | #include <linux/mm.h> | 35 | #include <linux/mm.h> |
36 | #include <acpi/acpi.h> | ||
37 | 36 | ||
38 | #include "apei-internal.h" | 37 | #include "apei-internal.h" |
39 | 38 | ||
diff --git a/drivers/acpi/apei/erst.c b/drivers/acpi/apei/erst.c index 26311f23c824..cb1d557fc22c 100644 --- a/drivers/acpi/apei/erst.c +++ b/drivers/acpi/apei/erst.c | |||
@@ -942,6 +942,7 @@ static int erst_clearer(enum pstore_type_id type, u64 id, int count, | |||
942 | static struct pstore_info erst_info = { | 942 | static struct pstore_info erst_info = { |
943 | .owner = THIS_MODULE, | 943 | .owner = THIS_MODULE, |
944 | .name = "erst", | 944 | .name = "erst", |
945 | .flags = PSTORE_FLAGS_FRAGILE, | ||
945 | .open = erst_open_pstore, | 946 | .open = erst_open_pstore, |
946 | .close = erst_close_pstore, | 947 | .close = erst_close_pstore, |
947 | .read = erst_reader, | 948 | .read = erst_reader, |
diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c index a30bc313787b..694c486a12ed 100644 --- a/drivers/acpi/apei/ghes.c +++ b/drivers/acpi/apei/ghes.c | |||
@@ -33,7 +33,6 @@ | |||
33 | #include <linux/module.h> | 33 | #include <linux/module.h> |
34 | #include <linux/init.h> | 34 | #include <linux/init.h> |
35 | #include <linux/acpi.h> | 35 | #include <linux/acpi.h> |
36 | #include <linux/acpi_io.h> | ||
37 | #include <linux/io.h> | 36 | #include <linux/io.h> |
38 | #include <linux/interrupt.h> | 37 | #include <linux/interrupt.h> |
39 | #include <linux/timer.h> | 38 | #include <linux/timer.h> |
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c index fbf1aceda8b8..470e7542bf31 100644 --- a/drivers/acpi/battery.c +++ b/drivers/acpi/battery.c | |||
@@ -36,8 +36,7 @@ | |||
36 | #include <linux/suspend.h> | 36 | #include <linux/suspend.h> |
37 | #include <asm/unaligned.h> | 37 | #include <asm/unaligned.h> |
38 | 38 | ||
39 | #include <acpi/acpi_bus.h> | 39 | #include <linux/acpi.h> |
40 | #include <acpi/acpi_drivers.h> | ||
41 | #include <linux/power_supply.h> | 40 | #include <linux/power_supply.h> |
42 | 41 | ||
43 | #define PREFIX "ACPI: " | 42 | #define PREFIX "ACPI: " |
@@ -62,6 +61,7 @@ MODULE_AUTHOR("Alexey Starikovskiy <astarikovskiy@suse.de>"); | |||
62 | MODULE_DESCRIPTION("ACPI Battery Driver"); | 61 | MODULE_DESCRIPTION("ACPI Battery Driver"); |
63 | MODULE_LICENSE("GPL"); | 62 | MODULE_LICENSE("GPL"); |
64 | 63 | ||
64 | static int battery_bix_broken_package; | ||
65 | static unsigned int cache_time = 1000; | 65 | static unsigned int cache_time = 1000; |
66 | module_param(cache_time, uint, 0644); | 66 | module_param(cache_time, uint, 0644); |
67 | MODULE_PARM_DESC(cache_time, "cache time in milliseconds"); | 67 | MODULE_PARM_DESC(cache_time, "cache time in milliseconds"); |
@@ -416,7 +416,12 @@ static int acpi_battery_get_info(struct acpi_battery *battery) | |||
416 | ACPI_EXCEPTION((AE_INFO, status, "Evaluating %s", name)); | 416 | ACPI_EXCEPTION((AE_INFO, status, "Evaluating %s", name)); |
417 | return -ENODEV; | 417 | return -ENODEV; |
418 | } | 418 | } |
419 | if (test_bit(ACPI_BATTERY_XINFO_PRESENT, &battery->flags)) | 419 | |
420 | if (battery_bix_broken_package) | ||
421 | result = extract_package(battery, buffer.pointer, | ||
422 | extended_info_offsets + 1, | ||
423 | ARRAY_SIZE(extended_info_offsets) - 1); | ||
424 | else if (test_bit(ACPI_BATTERY_XINFO_PRESENT, &battery->flags)) | ||
420 | result = extract_package(battery, buffer.pointer, | 425 | result = extract_package(battery, buffer.pointer, |
421 | extended_info_offsets, | 426 | extended_info_offsets, |
422 | ARRAY_SIZE(extended_info_offsets)); | 427 | ARRAY_SIZE(extended_info_offsets)); |
@@ -754,6 +759,17 @@ static int battery_notify(struct notifier_block *nb, | |||
754 | return 0; | 759 | return 0; |
755 | } | 760 | } |
756 | 761 | ||
762 | static struct dmi_system_id bat_dmi_table[] = { | ||
763 | { | ||
764 | .ident = "NEC LZ750/LS", | ||
765 | .matches = { | ||
766 | DMI_MATCH(DMI_SYS_VENDOR, "NEC"), | ||
767 | DMI_MATCH(DMI_PRODUCT_NAME, "PC-LZ750LS"), | ||
768 | }, | ||
769 | }, | ||
770 | {}, | ||
771 | }; | ||
772 | |||
757 | static int acpi_battery_add(struct acpi_device *device) | 773 | static int acpi_battery_add(struct acpi_device *device) |
758 | { | 774 | { |
759 | int result = 0; | 775 | int result = 0; |
@@ -846,6 +862,9 @@ static void __init acpi_battery_init_async(void *unused, async_cookie_t cookie) | |||
846 | { | 862 | { |
847 | if (acpi_disabled) | 863 | if (acpi_disabled) |
848 | return; | 864 | return; |
865 | |||
866 | if (dmi_check_system(bat_dmi_table)) | ||
867 | battery_bix_broken_package = 1; | ||
849 | acpi_bus_register_driver(&acpi_battery_driver); | 868 | acpi_bus_register_driver(&acpi_battery_driver); |
850 | } | 869 | } |
851 | 870 | ||
diff --git a/drivers/acpi/blacklist.c b/drivers/acpi/blacklist.c index 078c4f7fe2dd..10e4964d051a 100644 --- a/drivers/acpi/blacklist.c +++ b/drivers/acpi/blacklist.c | |||
@@ -30,7 +30,6 @@ | |||
30 | #include <linux/kernel.h> | 30 | #include <linux/kernel.h> |
31 | #include <linux/init.h> | 31 | #include <linux/init.h> |
32 | #include <linux/acpi.h> | 32 | #include <linux/acpi.h> |
33 | #include <acpi/acpi_bus.h> | ||
34 | #include <linux/dmi.h> | 33 | #include <linux/dmi.h> |
35 | 34 | ||
36 | #include "internal.h" | 35 | #include "internal.h" |
@@ -323,6 +322,56 @@ static struct dmi_system_id acpi_osi_dmi_table[] __initdata = { | |||
323 | DMI_MATCH(DMI_PRODUCT_VERSION, "2349D15"), | 322 | DMI_MATCH(DMI_PRODUCT_VERSION, "2349D15"), |
324 | }, | 323 | }, |
325 | }, | 324 | }, |
325 | { | ||
326 | .callback = dmi_disable_osi_win8, | ||
327 | .ident = "HP ProBook 2013 models", | ||
328 | .matches = { | ||
329 | DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"), | ||
330 | DMI_MATCH(DMI_PRODUCT_NAME, "HP ProBook "), | ||
331 | DMI_MATCH(DMI_PRODUCT_NAME, " G1"), | ||
332 | }, | ||
333 | }, | ||
334 | { | ||
335 | .callback = dmi_disable_osi_win8, | ||
336 | .ident = "HP EliteBook 2013 models", | ||
337 | .matches = { | ||
338 | DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"), | ||
339 | DMI_MATCH(DMI_PRODUCT_NAME, "HP EliteBook "), | ||
340 | DMI_MATCH(DMI_PRODUCT_NAME, " G1"), | ||
341 | }, | ||
342 | }, | ||
343 | { | ||
344 | .callback = dmi_disable_osi_win8, | ||
345 | .ident = "HP ZBook 14", | ||
346 | .matches = { | ||
347 | DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"), | ||
348 | DMI_MATCH(DMI_PRODUCT_NAME, "HP ZBook 14"), | ||
349 | }, | ||
350 | }, | ||
351 | { | ||
352 | .callback = dmi_disable_osi_win8, | ||
353 | .ident = "HP ZBook 15", | ||
354 | .matches = { | ||
355 | DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"), | ||
356 | DMI_MATCH(DMI_PRODUCT_NAME, "HP ZBook 15"), | ||
357 | }, | ||
358 | }, | ||
359 | { | ||
360 | .callback = dmi_disable_osi_win8, | ||
361 | .ident = "HP ZBook 17", | ||
362 | .matches = { | ||
363 | DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"), | ||
364 | DMI_MATCH(DMI_PRODUCT_NAME, "HP ZBook 17"), | ||
365 | }, | ||
366 | }, | ||
367 | { | ||
368 | .callback = dmi_disable_osi_win8, | ||
369 | .ident = "HP EliteBook 8780w", | ||
370 | .matches = { | ||
371 | DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"), | ||
372 | DMI_MATCH(DMI_PRODUCT_NAME, "HP EliteBook 8780w"), | ||
373 | }, | ||
374 | }, | ||
326 | 375 | ||
327 | /* | 376 | /* |
328 | * BIOS invocation of _OSI(Linux) is almost always a BIOS bug. | 377 | * BIOS invocation of _OSI(Linux) is almost always a BIOS bug. |
diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c index bba9b72e25f8..384da5ab5955 100644 --- a/drivers/acpi/bus.c +++ b/drivers/acpi/bus.c | |||
@@ -37,8 +37,6 @@ | |||
37 | #include <asm/mpspec.h> | 37 | #include <asm/mpspec.h> |
38 | #endif | 38 | #endif |
39 | #include <linux/pci.h> | 39 | #include <linux/pci.h> |
40 | #include <acpi/acpi_bus.h> | ||
41 | #include <acpi/acpi_drivers.h> | ||
42 | #include <acpi/apei.h> | 40 | #include <acpi/apei.h> |
43 | #include <linux/dmi.h> | 41 | #include <linux/dmi.h> |
44 | #include <linux/suspend.h> | 42 | #include <linux/suspend.h> |
@@ -52,9 +50,6 @@ struct acpi_device *acpi_root; | |||
52 | struct proc_dir_entry *acpi_root_dir; | 50 | struct proc_dir_entry *acpi_root_dir; |
53 | EXPORT_SYMBOL(acpi_root_dir); | 51 | EXPORT_SYMBOL(acpi_root_dir); |
54 | 52 | ||
55 | #define STRUCT_TO_INT(s) (*((int*)&s)) | ||
56 | |||
57 | |||
58 | #ifdef CONFIG_X86 | 53 | #ifdef CONFIG_X86 |
59 | static int set_copy_dsdt(const struct dmi_system_id *id) | 54 | static int set_copy_dsdt(const struct dmi_system_id *id) |
60 | { | 55 | { |
@@ -115,18 +110,16 @@ int acpi_bus_get_status(struct acpi_device *device) | |||
115 | if (ACPI_FAILURE(status)) | 110 | if (ACPI_FAILURE(status)) |
116 | return -ENODEV; | 111 | return -ENODEV; |
117 | 112 | ||
118 | STRUCT_TO_INT(device->status) = (int) sta; | 113 | acpi_set_device_status(device, sta); |
119 | 114 | ||
120 | if (device->status.functional && !device->status.present) { | 115 | if (device->status.functional && !device->status.present) { |
121 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] status [%08x]: " | 116 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] status [%08x]: " |
122 | "functional but not present;\n", | 117 | "functional but not present;\n", |
123 | device->pnp.bus_id, | 118 | device->pnp.bus_id, (u32)sta)); |
124 | (u32) STRUCT_TO_INT(device->status))); | ||
125 | } | 119 | } |
126 | 120 | ||
127 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] status [%08x]\n", | 121 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] status [%08x]\n", |
128 | device->pnp.bus_id, | 122 | device->pnp.bus_id, (u32)sta)); |
129 | (u32) STRUCT_TO_INT(device->status))); | ||
130 | return 0; | 123 | return 0; |
131 | } | 124 | } |
132 | EXPORT_SYMBOL(acpi_bus_get_status); | 125 | EXPORT_SYMBOL(acpi_bus_get_status); |
@@ -156,6 +149,16 @@ int acpi_bus_get_private_data(acpi_handle handle, void **data) | |||
156 | } | 149 | } |
157 | EXPORT_SYMBOL(acpi_bus_get_private_data); | 150 | EXPORT_SYMBOL(acpi_bus_get_private_data); |
158 | 151 | ||
152 | void acpi_bus_no_hotplug(acpi_handle handle) | ||
153 | { | ||
154 | struct acpi_device *adev = NULL; | ||
155 | |||
156 | acpi_bus_get_device(handle, &adev); | ||
157 | if (adev) | ||
158 | adev->flags.no_hotplug = true; | ||
159 | } | ||
160 | EXPORT_SYMBOL_GPL(acpi_bus_no_hotplug); | ||
161 | |||
159 | static void acpi_print_osc_error(acpi_handle handle, | 162 | static void acpi_print_osc_error(acpi_handle handle, |
160 | struct acpi_osc_context *context, char *error) | 163 | struct acpi_osc_context *context, char *error) |
161 | { | 164 | { |
@@ -329,58 +332,6 @@ static void acpi_bus_osc_support(void) | |||
329 | Notification Handling | 332 | Notification Handling |
330 | -------------------------------------------------------------------------- */ | 333 | -------------------------------------------------------------------------- */ |
331 | 334 | ||
332 | static void acpi_bus_check_device(acpi_handle handle) | ||
333 | { | ||
334 | struct acpi_device *device; | ||
335 | acpi_status status; | ||
336 | struct acpi_device_status old_status; | ||
337 | |||
338 | if (acpi_bus_get_device(handle, &device)) | ||
339 | return; | ||
340 | if (!device) | ||
341 | return; | ||
342 | |||
343 | old_status = device->status; | ||
344 | |||
345 | /* | ||
346 | * Make sure this device's parent is present before we go about | ||
347 | * messing with the device. | ||
348 | */ | ||
349 | if (device->parent && !device->parent->status.present) { | ||
350 | device->status = device->parent->status; | ||
351 | return; | ||
352 | } | ||
353 | |||
354 | status = acpi_bus_get_status(device); | ||
355 | if (ACPI_FAILURE(status)) | ||
356 | return; | ||
357 | |||
358 | if (STRUCT_TO_INT(old_status) == STRUCT_TO_INT(device->status)) | ||
359 | return; | ||
360 | |||
361 | /* | ||
362 | * Device Insertion/Removal | ||
363 | */ | ||
364 | if ((device->status.present) && !(old_status.present)) { | ||
365 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device insertion detected\n")); | ||
366 | /* TBD: Handle device insertion */ | ||
367 | } else if (!(device->status.present) && (old_status.present)) { | ||
368 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device removal detected\n")); | ||
369 | /* TBD: Handle device removal */ | ||
370 | } | ||
371 | } | ||
372 | |||
373 | static void acpi_bus_check_scope(acpi_handle handle) | ||
374 | { | ||
375 | /* Status Change? */ | ||
376 | acpi_bus_check_device(handle); | ||
377 | |||
378 | /* | ||
379 | * TBD: Enumerate child devices within this device's scope and | ||
380 | * run acpi_bus_check_device()'s on them. | ||
381 | */ | ||
382 | } | ||
383 | |||
384 | /** | 335 | /** |
385 | * acpi_bus_notify | 336 | * acpi_bus_notify |
386 | * --------------- | 337 | * --------------- |
@@ -397,19 +348,11 @@ static void acpi_bus_notify(acpi_handle handle, u32 type, void *data) | |||
397 | switch (type) { | 348 | switch (type) { |
398 | 349 | ||
399 | case ACPI_NOTIFY_BUS_CHECK: | 350 | case ACPI_NOTIFY_BUS_CHECK: |
400 | acpi_bus_check_scope(handle); | 351 | /* TBD */ |
401 | /* | ||
402 | * TBD: We'll need to outsource certain events to non-ACPI | ||
403 | * drivers via the device manager (device.c). | ||
404 | */ | ||
405 | break; | 352 | break; |
406 | 353 | ||
407 | case ACPI_NOTIFY_DEVICE_CHECK: | 354 | case ACPI_NOTIFY_DEVICE_CHECK: |
408 | acpi_bus_check_device(handle); | 355 | /* TBD */ |
409 | /* | ||
410 | * TBD: We'll need to outsource certain events to non-ACPI | ||
411 | * drivers via the device manager (device.c). | ||
412 | */ | ||
413 | break; | 356 | break; |
414 | 357 | ||
415 | case ACPI_NOTIFY_DEVICE_WAKE: | 358 | case ACPI_NOTIFY_DEVICE_WAKE: |
diff --git a/drivers/acpi/button.c b/drivers/acpi/button.c index 5401e9a98b35..11c11f6b8fa1 100644 --- a/drivers/acpi/button.c +++ b/drivers/acpi/button.c | |||
@@ -31,8 +31,7 @@ | |||
31 | #include <linux/seq_file.h> | 31 | #include <linux/seq_file.h> |
32 | #include <linux/input.h> | 32 | #include <linux/input.h> |
33 | #include <linux/slab.h> | 33 | #include <linux/slab.h> |
34 | #include <acpi/acpi_bus.h> | 34 | #include <linux/acpi.h> |
35 | #include <acpi/acpi_drivers.h> | ||
36 | #include <acpi/button.h> | 35 | #include <acpi/button.h> |
37 | 36 | ||
38 | #define PREFIX "ACPI: " | 37 | #define PREFIX "ACPI: " |
diff --git a/drivers/acpi/container.c b/drivers/acpi/container.c index e23151667655..0b6ae6eb5c4a 100644 --- a/drivers/acpi/container.c +++ b/drivers/acpi/container.c | |||
@@ -27,8 +27,7 @@ | |||
27 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | 27 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
28 | */ | 28 | */ |
29 | #include <linux/acpi.h> | 29 | #include <linux/acpi.h> |
30 | 30 | #include <linux/container.h> | |
31 | #include "internal.h" | ||
32 | 31 | ||
33 | #include "internal.h" | 32 | #include "internal.h" |
34 | 33 | ||
@@ -44,19 +43,65 @@ static const struct acpi_device_id container_device_ids[] = { | |||
44 | {"", 0}, | 43 | {"", 0}, |
45 | }; | 44 | }; |
46 | 45 | ||
47 | static int container_device_attach(struct acpi_device *device, | 46 | static int acpi_container_offline(struct container_dev *cdev) |
47 | { | ||
48 | struct acpi_device *adev = ACPI_COMPANION(&cdev->dev); | ||
49 | struct acpi_device *child; | ||
50 | |||
51 | /* Check all of the dependent devices' physical companions. */ | ||
52 | list_for_each_entry(child, &adev->children, node) | ||
53 | if (!acpi_scan_is_offline(child, false)) | ||
54 | return -EBUSY; | ||
55 | |||
56 | return 0; | ||
57 | } | ||
58 | |||
59 | static void acpi_container_release(struct device *dev) | ||
60 | { | ||
61 | kfree(to_container_dev(dev)); | ||
62 | } | ||
63 | |||
64 | static int container_device_attach(struct acpi_device *adev, | ||
48 | const struct acpi_device_id *not_used) | 65 | const struct acpi_device_id *not_used) |
49 | { | 66 | { |
50 | /* This is necessary for container hotplug to work. */ | 67 | struct container_dev *cdev; |
68 | struct device *dev; | ||
69 | int ret; | ||
70 | |||
71 | cdev = kzalloc(sizeof(*cdev), GFP_KERNEL); | ||
72 | if (!cdev) | ||
73 | return -ENOMEM; | ||
74 | |||
75 | cdev->offline = acpi_container_offline; | ||
76 | dev = &cdev->dev; | ||
77 | dev->bus = &container_subsys; | ||
78 | dev_set_name(dev, "%s", dev_name(&adev->dev)); | ||
79 | ACPI_COMPANION_SET(dev, adev); | ||
80 | dev->release = acpi_container_release; | ||
81 | ret = device_register(dev); | ||
82 | if (ret) | ||
83 | return ret; | ||
84 | |||
85 | adev->driver_data = dev; | ||
51 | return 1; | 86 | return 1; |
52 | } | 87 | } |
53 | 88 | ||
89 | static void container_device_detach(struct acpi_device *adev) | ||
90 | { | ||
91 | struct device *dev = acpi_driver_data(adev); | ||
92 | |||
93 | adev->driver_data = NULL; | ||
94 | if (dev) | ||
95 | device_unregister(dev); | ||
96 | } | ||
97 | |||
54 | static struct acpi_scan_handler container_handler = { | 98 | static struct acpi_scan_handler container_handler = { |
55 | .ids = container_device_ids, | 99 | .ids = container_device_ids, |
56 | .attach = container_device_attach, | 100 | .attach = container_device_attach, |
101 | .detach = container_device_detach, | ||
57 | .hotplug = { | 102 | .hotplug = { |
58 | .enabled = true, | 103 | .enabled = true, |
59 | .mode = AHM_CONTAINER, | 104 | .demand_offline = true, |
60 | }, | 105 | }, |
61 | }; | 106 | }; |
62 | 107 | ||
diff --git a/drivers/acpi/custom_method.c b/drivers/acpi/custom_method.c index 12b62f2cdb3f..c68e72414a67 100644 --- a/drivers/acpi/custom_method.c +++ b/drivers/acpi/custom_method.c | |||
@@ -7,7 +7,7 @@ | |||
7 | #include <linux/kernel.h> | 7 | #include <linux/kernel.h> |
8 | #include <linux/uaccess.h> | 8 | #include <linux/uaccess.h> |
9 | #include <linux/debugfs.h> | 9 | #include <linux/debugfs.h> |
10 | #include <acpi/acpi_drivers.h> | 10 | #include <linux/acpi.h> |
11 | 11 | ||
12 | #include "internal.h" | 12 | #include "internal.h" |
13 | 13 | ||
diff --git a/drivers/acpi/debugfs.c b/drivers/acpi/debugfs.c index b55d6a20dc0e..6b1919f6bd82 100644 --- a/drivers/acpi/debugfs.c +++ b/drivers/acpi/debugfs.c | |||
@@ -5,7 +5,7 @@ | |||
5 | #include <linux/export.h> | 5 | #include <linux/export.h> |
6 | #include <linux/init.h> | 6 | #include <linux/init.h> |
7 | #include <linux/debugfs.h> | 7 | #include <linux/debugfs.h> |
8 | #include <acpi/acpi_drivers.h> | 8 | #include <linux/acpi.h> |
9 | 9 | ||
10 | #define _COMPONENT ACPI_SYSTEM_COMPONENT | 10 | #define _COMPONENT ACPI_SYSTEM_COMPONENT |
11 | ACPI_MODULE_NAME("debugfs"); | 11 | ACPI_MODULE_NAME("debugfs"); |
diff --git a/drivers/acpi/device_pm.c b/drivers/acpi/device_pm.c index b3480cf7db1a..d49f1e464703 100644 --- a/drivers/acpi/device_pm.c +++ b/drivers/acpi/device_pm.c | |||
@@ -256,6 +256,8 @@ int acpi_bus_init_power(struct acpi_device *device) | |||
256 | return -EINVAL; | 256 | return -EINVAL; |
257 | 257 | ||
258 | device->power.state = ACPI_STATE_UNKNOWN; | 258 | device->power.state = ACPI_STATE_UNKNOWN; |
259 | if (!acpi_device_is_present(device)) | ||
260 | return 0; | ||
259 | 261 | ||
260 | result = acpi_device_get_power(device, &state); | 262 | result = acpi_device_get_power(device, &state); |
261 | if (result) | 263 | if (result) |
@@ -302,15 +304,18 @@ int acpi_device_fix_up_power(struct acpi_device *device) | |||
302 | return ret; | 304 | return ret; |
303 | } | 305 | } |
304 | 306 | ||
305 | int acpi_bus_update_power(acpi_handle handle, int *state_p) | 307 | int acpi_device_update_power(struct acpi_device *device, int *state_p) |
306 | { | 308 | { |
307 | struct acpi_device *device; | ||
308 | int state; | 309 | int state; |
309 | int result; | 310 | int result; |
310 | 311 | ||
311 | result = acpi_bus_get_device(handle, &device); | 312 | if (device->power.state == ACPI_STATE_UNKNOWN) { |
312 | if (result) | 313 | result = acpi_bus_init_power(device); |
314 | if (!result && state_p) | ||
315 | *state_p = device->power.state; | ||
316 | |||
313 | return result; | 317 | return result; |
318 | } | ||
314 | 319 | ||
315 | result = acpi_device_get_power(device, &state); | 320 | result = acpi_device_get_power(device, &state); |
316 | if (result) | 321 | if (result) |
@@ -338,6 +343,15 @@ int acpi_bus_update_power(acpi_handle handle, int *state_p) | |||
338 | 343 | ||
339 | return 0; | 344 | return 0; |
340 | } | 345 | } |
346 | |||
347 | int acpi_bus_update_power(acpi_handle handle, int *state_p) | ||
348 | { | ||
349 | struct acpi_device *device; | ||
350 | int result; | ||
351 | |||
352 | result = acpi_bus_get_device(handle, &device); | ||
353 | return result ? result : acpi_device_update_power(device, state_p); | ||
354 | } | ||
341 | EXPORT_SYMBOL_GPL(acpi_bus_update_power); | 355 | EXPORT_SYMBOL_GPL(acpi_bus_update_power); |
342 | 356 | ||
343 | bool acpi_bus_power_manageable(acpi_handle handle) | 357 | bool acpi_bus_power_manageable(acpi_handle handle) |
diff --git a/drivers/acpi/dock.c b/drivers/acpi/dock.c index dcd73ccb514c..c431c88faaff 100644 --- a/drivers/acpi/dock.c +++ b/drivers/acpi/dock.c | |||
@@ -32,8 +32,8 @@ | |||
32 | #include <linux/jiffies.h> | 32 | #include <linux/jiffies.h> |
33 | #include <linux/stddef.h> | 33 | #include <linux/stddef.h> |
34 | #include <linux/acpi.h> | 34 | #include <linux/acpi.h> |
35 | #include <acpi/acpi_bus.h> | 35 | |
36 | #include <acpi/acpi_drivers.h> | 36 | #include "internal.h" |
37 | 37 | ||
38 | #define PREFIX "ACPI: " | 38 | #define PREFIX "ACPI: " |
39 | 39 | ||
@@ -323,14 +323,11 @@ static int dock_present(struct dock_station *ds) | |||
323 | */ | 323 | */ |
324 | static void dock_create_acpi_device(acpi_handle handle) | 324 | static void dock_create_acpi_device(acpi_handle handle) |
325 | { | 325 | { |
326 | struct acpi_device *device; | 326 | struct acpi_device *device = NULL; |
327 | int ret; | 327 | int ret; |
328 | 328 | ||
329 | if (acpi_bus_get_device(handle, &device)) { | 329 | acpi_bus_get_device(handle, &device); |
330 | /* | 330 | if (!acpi_device_enumerated(device)) { |
331 | * no device created for this object, | ||
332 | * so we should create one. | ||
333 | */ | ||
334 | ret = acpi_bus_scan(handle); | 331 | ret = acpi_bus_scan(handle); |
335 | if (ret) | 332 | if (ret) |
336 | pr_debug("error adding bus, %x\n", -ret); | 333 | pr_debug("error adding bus, %x\n", -ret); |
@@ -898,9 +895,6 @@ find_dock_and_bay(acpi_handle handle, u32 lvl, void *context, void **rv) | |||
898 | 895 | ||
899 | void __init acpi_dock_init(void) | 896 | void __init acpi_dock_init(void) |
900 | { | 897 | { |
901 | if (acpi_disabled) | ||
902 | return; | ||
903 | |||
904 | /* look for dock stations and bays */ | 898 | /* look for dock stations and bays */ |
905 | acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, | 899 | acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, |
906 | ACPI_UINT32_MAX, find_dock_and_bay, NULL, NULL, NULL); | 900 | ACPI_UINT32_MAX, find_dock_and_bay, NULL, NULL, NULL); |
diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c index 7dac048e8f07..959d41acc108 100644 --- a/drivers/acpi/ec.c +++ b/drivers/acpi/ec.c | |||
@@ -39,10 +39,9 @@ | |||
39 | #include <linux/list.h> | 39 | #include <linux/list.h> |
40 | #include <linux/spinlock.h> | 40 | #include <linux/spinlock.h> |
41 | #include <linux/slab.h> | 41 | #include <linux/slab.h> |
42 | #include <asm/io.h> | 42 | #include <linux/acpi.h> |
43 | #include <acpi/acpi_bus.h> | ||
44 | #include <acpi/acpi_drivers.h> | ||
45 | #include <linux/dmi.h> | 43 | #include <linux/dmi.h> |
44 | #include <asm/io.h> | ||
46 | 45 | ||
47 | #include "internal.h" | 46 | #include "internal.h" |
48 | 47 | ||
@@ -91,10 +90,6 @@ static unsigned int ec_storm_threshold __read_mostly = 8; | |||
91 | module_param(ec_storm_threshold, uint, 0644); | 90 | module_param(ec_storm_threshold, uint, 0644); |
92 | MODULE_PARM_DESC(ec_storm_threshold, "Maxim false GPE numbers not considered as GPE storm"); | 91 | MODULE_PARM_DESC(ec_storm_threshold, "Maxim false GPE numbers not considered as GPE storm"); |
93 | 92 | ||
94 | /* If we find an EC via the ECDT, we need to keep a ptr to its context */ | ||
95 | /* External interfaces use first EC only, so remember */ | ||
96 | typedef int (*acpi_ec_query_func) (void *data); | ||
97 | |||
98 | struct acpi_ec_query_handler { | 93 | struct acpi_ec_query_handler { |
99 | struct list_head node; | 94 | struct list_head node; |
100 | acpi_ec_query_func func; | 95 | acpi_ec_query_func func; |
@@ -387,27 +382,6 @@ static int acpi_ec_write(struct acpi_ec *ec, u8 address, u8 data) | |||
387 | return acpi_ec_transaction(ec, &t); | 382 | return acpi_ec_transaction(ec, &t); |
388 | } | 383 | } |
389 | 384 | ||
390 | /* | ||
391 | * Externally callable EC access functions. For now, assume 1 EC only | ||
392 | */ | ||
393 | int ec_burst_enable(void) | ||
394 | { | ||
395 | if (!first_ec) | ||
396 | return -ENODEV; | ||
397 | return acpi_ec_burst_enable(first_ec); | ||
398 | } | ||
399 | |||
400 | EXPORT_SYMBOL(ec_burst_enable); | ||
401 | |||
402 | int ec_burst_disable(void) | ||
403 | { | ||
404 | if (!first_ec) | ||
405 | return -ENODEV; | ||
406 | return acpi_ec_burst_disable(first_ec); | ||
407 | } | ||
408 | |||
409 | EXPORT_SYMBOL(ec_burst_disable); | ||
410 | |||
411 | int ec_read(u8 addr, u8 *val) | 385 | int ec_read(u8 addr, u8 *val) |
412 | { | 386 | { |
413 | int err; | 387 | int err; |
diff --git a/drivers/acpi/ec_sys.c b/drivers/acpi/ec_sys.c index 4e7b798900f2..b4c216bab22b 100644 --- a/drivers/acpi/ec_sys.c +++ b/drivers/acpi/ec_sys.c | |||
@@ -105,7 +105,7 @@ static const struct file_operations acpi_ec_io_ops = { | |||
105 | .llseek = default_llseek, | 105 | .llseek = default_llseek, |
106 | }; | 106 | }; |
107 | 107 | ||
108 | int acpi_ec_add_debugfs(struct acpi_ec *ec, unsigned int ec_device_count) | 108 | static int acpi_ec_add_debugfs(struct acpi_ec *ec, unsigned int ec_device_count) |
109 | { | 109 | { |
110 | struct dentry *dev_dir; | 110 | struct dentry *dev_dir; |
111 | char name[64]; | 111 | char name[64]; |
diff --git a/drivers/acpi/event.c b/drivers/acpi/event.c index cae3b387b867..ef2d730734dc 100644 --- a/drivers/acpi/event.c +++ b/drivers/acpi/event.c | |||
@@ -12,7 +12,7 @@ | |||
12 | #include <linux/init.h> | 12 | #include <linux/init.h> |
13 | #include <linux/poll.h> | 13 | #include <linux/poll.h> |
14 | #include <linux/gfp.h> | 14 | #include <linux/gfp.h> |
15 | #include <acpi/acpi_drivers.h> | 15 | #include <linux/acpi.h> |
16 | #include <net/netlink.h> | 16 | #include <net/netlink.h> |
17 | #include <net/genetlink.h> | 17 | #include <net/genetlink.h> |
18 | 18 | ||
diff --git a/drivers/acpi/fan.c b/drivers/acpi/fan.c index ba3da88cee45..1fb62900f32a 100644 --- a/drivers/acpi/fan.c +++ b/drivers/acpi/fan.c | |||
@@ -29,8 +29,7 @@ | |||
29 | #include <linux/types.h> | 29 | #include <linux/types.h> |
30 | #include <asm/uaccess.h> | 30 | #include <asm/uaccess.h> |
31 | #include <linux/thermal.h> | 31 | #include <linux/thermal.h> |
32 | #include <acpi/acpi_bus.h> | 32 | #include <linux/acpi.h> |
33 | #include <acpi/acpi_drivers.h> | ||
34 | 33 | ||
35 | #define PREFIX "ACPI: " | 34 | #define PREFIX "ACPI: " |
36 | 35 | ||
diff --git a/drivers/acpi/glue.c b/drivers/acpi/glue.c index a22a295edb69..0c789224d40d 100644 --- a/drivers/acpi/glue.c +++ b/drivers/acpi/glue.c | |||
@@ -37,7 +37,7 @@ int register_acpi_bus_type(struct acpi_bus_type *type) | |||
37 | { | 37 | { |
38 | if (acpi_disabled) | 38 | if (acpi_disabled) |
39 | return -ENODEV; | 39 | return -ENODEV; |
40 | if (type && type->match && type->find_device) { | 40 | if (type && type->match && type->find_companion) { |
41 | down_write(&bus_type_sem); | 41 | down_write(&bus_type_sem); |
42 | list_add_tail(&type->list, &bus_type_list); | 42 | list_add_tail(&type->list, &bus_type_list); |
43 | up_write(&bus_type_sem); | 43 | up_write(&bus_type_sem); |
@@ -82,109 +82,74 @@ static struct acpi_bus_type *acpi_get_bus_type(struct device *dev) | |||
82 | #define FIND_CHILD_MIN_SCORE 1 | 82 | #define FIND_CHILD_MIN_SCORE 1 |
83 | #define FIND_CHILD_MAX_SCORE 2 | 83 | #define FIND_CHILD_MAX_SCORE 2 |
84 | 84 | ||
85 | static acpi_status acpi_dev_present(acpi_handle handle, u32 lvl_not_used, | 85 | static int find_child_checks(struct acpi_device *adev, bool check_children) |
86 | void *not_used, void **ret_p) | ||
87 | { | ||
88 | struct acpi_device *adev = NULL; | ||
89 | |||
90 | acpi_bus_get_device(handle, &adev); | ||
91 | if (adev) { | ||
92 | *ret_p = handle; | ||
93 | return AE_CTRL_TERMINATE; | ||
94 | } | ||
95 | return AE_OK; | ||
96 | } | ||
97 | |||
98 | static int do_find_child_checks(acpi_handle handle, bool is_bridge) | ||
99 | { | 86 | { |
100 | bool sta_present = true; | 87 | bool sta_present = true; |
101 | unsigned long long sta; | 88 | unsigned long long sta; |
102 | acpi_status status; | 89 | acpi_status status; |
103 | 90 | ||
104 | status = acpi_evaluate_integer(handle, "_STA", NULL, &sta); | 91 | status = acpi_evaluate_integer(adev->handle, "_STA", NULL, &sta); |
105 | if (status == AE_NOT_FOUND) | 92 | if (status == AE_NOT_FOUND) |
106 | sta_present = false; | 93 | sta_present = false; |
107 | else if (ACPI_FAILURE(status) || !(sta & ACPI_STA_DEVICE_ENABLED)) | 94 | else if (ACPI_FAILURE(status) || !(sta & ACPI_STA_DEVICE_ENABLED)) |
108 | return -ENODEV; | 95 | return -ENODEV; |
109 | 96 | ||
110 | if (is_bridge) { | 97 | if (check_children && list_empty(&adev->children)) |
111 | void *test = NULL; | 98 | return -ENODEV; |
112 | 99 | ||
113 | /* Check if this object has at least one child device. */ | ||
114 | acpi_walk_namespace(ACPI_TYPE_DEVICE, handle, 1, | ||
115 | acpi_dev_present, NULL, NULL, &test); | ||
116 | if (!test) | ||
117 | return -ENODEV; | ||
118 | } | ||
119 | return sta_present ? FIND_CHILD_MAX_SCORE : FIND_CHILD_MIN_SCORE; | 100 | return sta_present ? FIND_CHILD_MAX_SCORE : FIND_CHILD_MIN_SCORE; |
120 | } | 101 | } |
121 | 102 | ||
122 | struct find_child_context { | 103 | struct acpi_device *acpi_find_child_device(struct acpi_device *parent, |
123 | u64 addr; | 104 | u64 address, bool check_children) |
124 | bool is_bridge; | ||
125 | acpi_handle ret; | ||
126 | int ret_score; | ||
127 | }; | ||
128 | |||
129 | static acpi_status do_find_child(acpi_handle handle, u32 lvl_not_used, | ||
130 | void *data, void **not_used) | ||
131 | { | ||
132 | struct find_child_context *context = data; | ||
133 | unsigned long long addr; | ||
134 | acpi_status status; | ||
135 | int score; | ||
136 | |||
137 | status = acpi_evaluate_integer(handle, METHOD_NAME__ADR, NULL, &addr); | ||
138 | if (ACPI_FAILURE(status) || addr != context->addr) | ||
139 | return AE_OK; | ||
140 | |||
141 | if (!context->ret) { | ||
142 | /* This is the first matching object. Save its handle. */ | ||
143 | context->ret = handle; | ||
144 | return AE_OK; | ||
145 | } | ||
146 | /* | ||
147 | * There is more than one matching object with the same _ADR value. | ||
148 | * That really is unexpected, so we are kind of beyond the scope of the | ||
149 | * spec here. We have to choose which one to return, though. | ||
150 | * | ||
151 | * First, check if the previously found object is good enough and return | ||
152 | * its handle if so. Second, check the same for the object that we've | ||
153 | * just found. | ||
154 | */ | ||
155 | if (!context->ret_score) { | ||
156 | score = do_find_child_checks(context->ret, context->is_bridge); | ||
157 | if (score == FIND_CHILD_MAX_SCORE) | ||
158 | return AE_CTRL_TERMINATE; | ||
159 | else | ||
160 | context->ret_score = score; | ||
161 | } | ||
162 | score = do_find_child_checks(handle, context->is_bridge); | ||
163 | if (score == FIND_CHILD_MAX_SCORE) { | ||
164 | context->ret = handle; | ||
165 | return AE_CTRL_TERMINATE; | ||
166 | } else if (score > context->ret_score) { | ||
167 | context->ret = handle; | ||
168 | context->ret_score = score; | ||
169 | } | ||
170 | return AE_OK; | ||
171 | } | ||
172 | |||
173 | acpi_handle acpi_find_child(acpi_handle parent, u64 addr, bool is_bridge) | ||
174 | { | 105 | { |
175 | if (parent) { | 106 | struct acpi_device *adev, *ret = NULL; |
176 | struct find_child_context context = { | 107 | int ret_score = 0; |
177 | .addr = addr, | 108 | |
178 | .is_bridge = is_bridge, | 109 | if (!parent) |
179 | }; | 110 | return NULL; |
180 | 111 | ||
181 | acpi_walk_namespace(ACPI_TYPE_DEVICE, parent, 1, do_find_child, | 112 | list_for_each_entry(adev, &parent->children, node) { |
182 | NULL, &context, NULL); | 113 | unsigned long long addr; |
183 | return context.ret; | 114 | acpi_status status; |
115 | int score; | ||
116 | |||
117 | status = acpi_evaluate_integer(adev->handle, METHOD_NAME__ADR, | ||
118 | NULL, &addr); | ||
119 | if (ACPI_FAILURE(status) || addr != address) | ||
120 | continue; | ||
121 | |||
122 | if (!ret) { | ||
123 | /* This is the first matching object. Save it. */ | ||
124 | ret = adev; | ||
125 | continue; | ||
126 | } | ||
127 | /* | ||
128 | * There is more than one matching device object with the same | ||
129 | * _ADR value. That really is unexpected, so we are kind of | ||
130 | * beyond the scope of the spec here. We have to choose which | ||
131 | * one to return, though. | ||
132 | * | ||
133 | * First, check if the previously found object is good enough | ||
134 | * and return it if so. Second, do the same for the object that | ||
135 | * we've just found. | ||
136 | */ | ||
137 | if (!ret_score) { | ||
138 | ret_score = find_child_checks(ret, check_children); | ||
139 | if (ret_score == FIND_CHILD_MAX_SCORE) | ||
140 | return ret; | ||
141 | } | ||
142 | score = find_child_checks(adev, check_children); | ||
143 | if (score == FIND_CHILD_MAX_SCORE) { | ||
144 | return adev; | ||
145 | } else if (score > ret_score) { | ||
146 | ret = adev; | ||
147 | ret_score = score; | ||
148 | } | ||
184 | } | 149 | } |
185 | return NULL; | 150 | return ret; |
186 | } | 151 | } |
187 | EXPORT_SYMBOL_GPL(acpi_find_child); | 152 | EXPORT_SYMBOL_GPL(acpi_find_child_device); |
188 | 153 | ||
189 | static void acpi_physnode_link_name(char *buf, unsigned int node_id) | 154 | static void acpi_physnode_link_name(char *buf, unsigned int node_id) |
190 | { | 155 | { |
@@ -195,9 +160,8 @@ static void acpi_physnode_link_name(char *buf, unsigned int node_id) | |||
195 | strcpy(buf, PHYSICAL_NODE_STRING); | 160 | strcpy(buf, PHYSICAL_NODE_STRING); |
196 | } | 161 | } |
197 | 162 | ||
198 | int acpi_bind_one(struct device *dev, acpi_handle handle) | 163 | int acpi_bind_one(struct device *dev, struct acpi_device *acpi_dev) |
199 | { | 164 | { |
200 | struct acpi_device *acpi_dev = NULL; | ||
201 | struct acpi_device_physical_node *physical_node, *pn; | 165 | struct acpi_device_physical_node *physical_node, *pn; |
202 | char physical_node_name[PHYSICAL_NODE_NAME_SIZE]; | 166 | char physical_node_name[PHYSICAL_NODE_NAME_SIZE]; |
203 | struct list_head *physnode_list; | 167 | struct list_head *physnode_list; |
@@ -205,14 +169,12 @@ int acpi_bind_one(struct device *dev, acpi_handle handle) | |||
205 | int retval = -EINVAL; | 169 | int retval = -EINVAL; |
206 | 170 | ||
207 | if (ACPI_COMPANION(dev)) { | 171 | if (ACPI_COMPANION(dev)) { |
208 | if (handle) { | 172 | if (acpi_dev) { |
209 | dev_warn(dev, "ACPI companion already set\n"); | 173 | dev_warn(dev, "ACPI companion already set\n"); |
210 | return -EINVAL; | 174 | return -EINVAL; |
211 | } else { | 175 | } else { |
212 | acpi_dev = ACPI_COMPANION(dev); | 176 | acpi_dev = ACPI_COMPANION(dev); |
213 | } | 177 | } |
214 | } else { | ||
215 | acpi_bus_get_device(handle, &acpi_dev); | ||
216 | } | 178 | } |
217 | if (!acpi_dev) | 179 | if (!acpi_dev) |
218 | return -EINVAL; | 180 | return -EINVAL; |
@@ -322,29 +284,22 @@ int acpi_unbind_one(struct device *dev) | |||
322 | } | 284 | } |
323 | EXPORT_SYMBOL_GPL(acpi_unbind_one); | 285 | EXPORT_SYMBOL_GPL(acpi_unbind_one); |
324 | 286 | ||
325 | void acpi_preset_companion(struct device *dev, acpi_handle parent, u64 addr) | ||
326 | { | ||
327 | struct acpi_device *adev; | ||
328 | |||
329 | if (!acpi_bus_get_device(acpi_get_child(parent, addr), &adev)) | ||
330 | ACPI_COMPANION_SET(dev, adev); | ||
331 | } | ||
332 | EXPORT_SYMBOL_GPL(acpi_preset_companion); | ||
333 | |||
334 | static int acpi_platform_notify(struct device *dev) | 287 | static int acpi_platform_notify(struct device *dev) |
335 | { | 288 | { |
336 | struct acpi_bus_type *type = acpi_get_bus_type(dev); | 289 | struct acpi_bus_type *type = acpi_get_bus_type(dev); |
337 | acpi_handle handle; | ||
338 | int ret; | 290 | int ret; |
339 | 291 | ||
340 | ret = acpi_bind_one(dev, NULL); | 292 | ret = acpi_bind_one(dev, NULL); |
341 | if (ret && type) { | 293 | if (ret && type) { |
342 | ret = type->find_device(dev, &handle); | 294 | struct acpi_device *adev; |
343 | if (ret) { | 295 | |
296 | adev = type->find_companion(dev); | ||
297 | if (!adev) { | ||
344 | DBG("Unable to get handle for %s\n", dev_name(dev)); | 298 | DBG("Unable to get handle for %s\n", dev_name(dev)); |
299 | ret = -ENODEV; | ||
345 | goto out; | 300 | goto out; |
346 | } | 301 | } |
347 | ret = acpi_bind_one(dev, handle); | 302 | ret = acpi_bind_one(dev, adev); |
348 | if (ret) | 303 | if (ret) |
349 | goto out; | 304 | goto out; |
350 | } | 305 | } |
diff --git a/drivers/acpi/hed.c b/drivers/acpi/hed.c index 13b1d39d7cdf..aafe3ca829c2 100644 --- a/drivers/acpi/hed.c +++ b/drivers/acpi/hed.c | |||
@@ -25,8 +25,6 @@ | |||
25 | #include <linux/module.h> | 25 | #include <linux/module.h> |
26 | #include <linux/init.h> | 26 | #include <linux/init.h> |
27 | #include <linux/acpi.h> | 27 | #include <linux/acpi.h> |
28 | #include <acpi/acpi_bus.h> | ||
29 | #include <acpi/acpi_drivers.h> | ||
30 | #include <acpi/hed.h> | 28 | #include <acpi/hed.h> |
31 | 29 | ||
32 | static struct acpi_device_id acpi_hed_ids[] = { | 30 | static struct acpi_device_id acpi_hed_ids[] = { |
diff --git a/drivers/acpi/internal.h b/drivers/acpi/internal.h index a29739c0ba79..dedbb2d802f1 100644 --- a/drivers/acpi/internal.h +++ b/drivers/acpi/internal.h | |||
@@ -28,7 +28,6 @@ int init_acpi_device_notify(void); | |||
28 | int acpi_scan_init(void); | 28 | int acpi_scan_init(void); |
29 | void acpi_pci_root_init(void); | 29 | void acpi_pci_root_init(void); |
30 | void acpi_pci_link_init(void); | 30 | void acpi_pci_link_init(void); |
31 | void acpi_pci_root_hp_init(void); | ||
32 | void acpi_processor_init(void); | 31 | void acpi_processor_init(void); |
33 | void acpi_platform_init(void); | 32 | void acpi_platform_init(void); |
34 | int acpi_sysfs_init(void); | 33 | int acpi_sysfs_init(void); |
@@ -73,6 +72,9 @@ void acpi_lpss_init(void); | |||
73 | static inline void acpi_lpss_init(void) {} | 72 | static inline void acpi_lpss_init(void) {} |
74 | #endif | 73 | #endif |
75 | 74 | ||
75 | bool acpi_queue_hotplug_work(struct work_struct *work); | ||
76 | bool acpi_scan_is_offline(struct acpi_device *adev, bool uevent); | ||
77 | |||
76 | /* -------------------------------------------------------------------------- | 78 | /* -------------------------------------------------------------------------- |
77 | Device Node Initialization / Removal | 79 | Device Node Initialization / Removal |
78 | -------------------------------------------------------------------------- */ | 80 | -------------------------------------------------------------------------- */ |
@@ -85,9 +87,9 @@ void acpi_init_device_object(struct acpi_device *device, acpi_handle handle, | |||
85 | int type, unsigned long long sta); | 87 | int type, unsigned long long sta); |
86 | void acpi_device_add_finalize(struct acpi_device *device); | 88 | void acpi_device_add_finalize(struct acpi_device *device); |
87 | void acpi_free_pnp_ids(struct acpi_device_pnp *pnp); | 89 | void acpi_free_pnp_ids(struct acpi_device_pnp *pnp); |
88 | int acpi_bind_one(struct device *dev, acpi_handle handle); | 90 | int acpi_bind_one(struct device *dev, struct acpi_device *adev); |
89 | int acpi_unbind_one(struct device *dev); | 91 | int acpi_unbind_one(struct device *dev); |
90 | void acpi_bus_device_eject(void *data, u32 ost_src); | 92 | bool acpi_device_is_present(struct acpi_device *adev); |
91 | 93 | ||
92 | /* -------------------------------------------------------------------------- | 94 | /* -------------------------------------------------------------------------- |
93 | Power Resource | 95 | Power Resource |
@@ -105,6 +107,8 @@ int acpi_power_get_inferred_state(struct acpi_device *device, int *state); | |||
105 | int acpi_power_on_resources(struct acpi_device *device, int state); | 107 | int acpi_power_on_resources(struct acpi_device *device, int state); |
106 | int acpi_power_transition(struct acpi_device *device, int state); | 108 | int acpi_power_transition(struct acpi_device *device, int state); |
107 | 109 | ||
110 | int acpi_device_update_power(struct acpi_device *device, int *state_p); | ||
111 | |||
108 | int acpi_wakeup_device_init(void); | 112 | int acpi_wakeup_device_init(void); |
109 | void acpi_early_processor_set_pdc(void); | 113 | void acpi_early_processor_set_pdc(void); |
110 | 114 | ||
@@ -127,12 +131,21 @@ struct acpi_ec { | |||
127 | 131 | ||
128 | extern struct acpi_ec *first_ec; | 132 | extern struct acpi_ec *first_ec; |
129 | 133 | ||
134 | /* If we find an EC via the ECDT, we need to keep a ptr to its context */ | ||
135 | /* External interfaces use first EC only, so remember */ | ||
136 | typedef int (*acpi_ec_query_func) (void *data); | ||
137 | |||
130 | int acpi_ec_init(void); | 138 | int acpi_ec_init(void); |
131 | int acpi_ec_ecdt_probe(void); | 139 | int acpi_ec_ecdt_probe(void); |
132 | int acpi_boot_ec_enable(void); | 140 | int acpi_boot_ec_enable(void); |
133 | void acpi_ec_block_transactions(void); | 141 | void acpi_ec_block_transactions(void); |
134 | void acpi_ec_unblock_transactions(void); | 142 | void acpi_ec_unblock_transactions(void); |
135 | void acpi_ec_unblock_transactions_early(void); | 143 | void acpi_ec_unblock_transactions_early(void); |
144 | int acpi_ec_add_query_handler(struct acpi_ec *ec, u8 query_bit, | ||
145 | acpi_handle handle, acpi_ec_query_func func, | ||
146 | void *data); | ||
147 | void acpi_ec_remove_query_handler(struct acpi_ec *ec, u8 query_bit); | ||
148 | |||
136 | 149 | ||
137 | /*-------------------------------------------------------------------------- | 150 | /*-------------------------------------------------------------------------- |
138 | Suspend/Resume | 151 | Suspend/Resume |
diff --git a/drivers/acpi/numa.c b/drivers/acpi/numa.c index a2343a1d9e0b..9e6816ef280a 100644 --- a/drivers/acpi/numa.c +++ b/drivers/acpi/numa.c | |||
@@ -29,7 +29,6 @@ | |||
29 | #include <linux/errno.h> | 29 | #include <linux/errno.h> |
30 | #include <linux/acpi.h> | 30 | #include <linux/acpi.h> |
31 | #include <linux/numa.h> | 31 | #include <linux/numa.h> |
32 | #include <acpi/acpi_bus.h> | ||
33 | 32 | ||
34 | #define PREFIX "ACPI: " | 33 | #define PREFIX "ACPI: " |
35 | 34 | ||
diff --git a/drivers/acpi/nvs.c b/drivers/acpi/nvs.c index 386a9fe497b4..de4fe03873c5 100644 --- a/drivers/acpi/nvs.c +++ b/drivers/acpi/nvs.c | |||
@@ -12,7 +12,8 @@ | |||
12 | #include <linux/mm.h> | 12 | #include <linux/mm.h> |
13 | #include <linux/slab.h> | 13 | #include <linux/slab.h> |
14 | #include <linux/acpi.h> | 14 | #include <linux/acpi.h> |
15 | #include <linux/acpi_io.h> | 15 | |
16 | #include "internal.h" | ||
16 | 17 | ||
17 | /* ACPI NVS regions, APEI may use it */ | 18 | /* ACPI NVS regions, APEI may use it */ |
18 | 19 | ||
diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c index 54a20ff4b864..fc1aa7909690 100644 --- a/drivers/acpi/osl.c +++ b/drivers/acpi/osl.c | |||
@@ -39,7 +39,6 @@ | |||
39 | #include <linux/workqueue.h> | 39 | #include <linux/workqueue.h> |
40 | #include <linux/nmi.h> | 40 | #include <linux/nmi.h> |
41 | #include <linux/acpi.h> | 41 | #include <linux/acpi.h> |
42 | #include <linux/acpi_io.h> | ||
43 | #include <linux/efi.h> | 42 | #include <linux/efi.h> |
44 | #include <linux/ioport.h> | 43 | #include <linux/ioport.h> |
45 | #include <linux/list.h> | 44 | #include <linux/list.h> |
@@ -49,9 +48,6 @@ | |||
49 | #include <asm/io.h> | 48 | #include <asm/io.h> |
50 | #include <asm/uaccess.h> | 49 | #include <asm/uaccess.h> |
51 | 50 | ||
52 | #include <acpi/acpi.h> | ||
53 | #include <acpi/acpi_bus.h> | ||
54 | #include <acpi/processor.h> | ||
55 | #include "internal.h" | 51 | #include "internal.h" |
56 | 52 | ||
57 | #define _COMPONENT ACPI_OS_SERVICES | 53 | #define _COMPONENT ACPI_OS_SERVICES |
@@ -544,7 +540,7 @@ static u64 acpi_tables_addr; | |||
544 | static int all_tables_size; | 540 | static int all_tables_size; |
545 | 541 | ||
546 | /* Copied from acpica/tbutils.c:acpi_tb_checksum() */ | 542 | /* Copied from acpica/tbutils.c:acpi_tb_checksum() */ |
547 | u8 __init acpi_table_checksum(u8 *buffer, u32 length) | 543 | static u8 __init acpi_table_checksum(u8 *buffer, u32 length) |
548 | { | 544 | { |
549 | u8 sum = 0; | 545 | u8 sum = 0; |
550 | u8 *end = buffer + length; | 546 | u8 *end = buffer + length; |
@@ -1215,6 +1211,10 @@ acpi_status acpi_hotplug_execute(acpi_hp_callback func, void *data, u32 src) | |||
1215 | return AE_OK; | 1211 | return AE_OK; |
1216 | } | 1212 | } |
1217 | 1213 | ||
1214 | bool acpi_queue_hotplug_work(struct work_struct *work) | ||
1215 | { | ||
1216 | return queue_work(kacpi_hotplug_wq, work); | ||
1217 | } | ||
1218 | 1218 | ||
1219 | acpi_status | 1219 | acpi_status |
1220 | acpi_os_create_semaphore(u32 max_units, u32 initial_units, acpi_handle * handle) | 1220 | acpi_os_create_semaphore(u32 max_units, u32 initial_units, acpi_handle * handle) |
@@ -1282,7 +1282,7 @@ acpi_status acpi_os_wait_semaphore(acpi_handle handle, u32 units, u16 timeout) | |||
1282 | jiffies = MAX_SCHEDULE_TIMEOUT; | 1282 | jiffies = MAX_SCHEDULE_TIMEOUT; |
1283 | else | 1283 | else |
1284 | jiffies = msecs_to_jiffies(timeout); | 1284 | jiffies = msecs_to_jiffies(timeout); |
1285 | 1285 | ||
1286 | ret = down_timeout(sem, jiffies); | 1286 | ret = down_timeout(sem, jiffies); |
1287 | if (ret) | 1287 | if (ret) |
1288 | status = AE_TIME; | 1288 | status = AE_TIME; |
@@ -1794,7 +1794,7 @@ acpi_status __init acpi_os_initialize1(void) | |||
1794 | { | 1794 | { |
1795 | kacpid_wq = alloc_workqueue("kacpid", 0, 1); | 1795 | kacpid_wq = alloc_workqueue("kacpid", 0, 1); |
1796 | kacpi_notify_wq = alloc_workqueue("kacpi_notify", 0, 1); | 1796 | kacpi_notify_wq = alloc_workqueue("kacpi_notify", 0, 1); |
1797 | kacpi_hotplug_wq = alloc_workqueue("kacpi_hotplug", 0, 1); | 1797 | kacpi_hotplug_wq = alloc_ordered_workqueue("kacpi_hotplug", 0); |
1798 | BUG_ON(!kacpid_wq); | 1798 | BUG_ON(!kacpid_wq); |
1799 | BUG_ON(!kacpi_notify_wq); | 1799 | BUG_ON(!kacpi_notify_wq); |
1800 | BUG_ON(!kacpi_hotplug_wq); | 1800 | BUG_ON(!kacpi_hotplug_wq); |
diff --git a/drivers/acpi/pci_irq.c b/drivers/acpi/pci_irq.c index 41c5e1b799ef..52d45ea2bc4f 100644 --- a/drivers/acpi/pci_irq.c +++ b/drivers/acpi/pci_irq.c | |||
@@ -37,8 +37,6 @@ | |||
37 | #include <linux/pci.h> | 37 | #include <linux/pci.h> |
38 | #include <linux/acpi.h> | 38 | #include <linux/acpi.h> |
39 | #include <linux/slab.h> | 39 | #include <linux/slab.h> |
40 | #include <acpi/acpi_bus.h> | ||
41 | #include <acpi/acpi_drivers.h> | ||
42 | 40 | ||
43 | #define PREFIX "ACPI: " | 41 | #define PREFIX "ACPI: " |
44 | 42 | ||
diff --git a/drivers/acpi/pci_link.c b/drivers/acpi/pci_link.c index 2652a614deeb..9418c7a1f786 100644 --- a/drivers/acpi/pci_link.c +++ b/drivers/acpi/pci_link.c | |||
@@ -39,9 +39,9 @@ | |||
39 | #include <linux/pci.h> | 39 | #include <linux/pci.h> |
40 | #include <linux/mutex.h> | 40 | #include <linux/mutex.h> |
41 | #include <linux/slab.h> | 41 | #include <linux/slab.h> |
42 | #include <linux/acpi.h> | ||
42 | 43 | ||
43 | #include <acpi/acpi_bus.h> | 44 | #include "internal.h" |
44 | #include <acpi/acpi_drivers.h> | ||
45 | 45 | ||
46 | #define PREFIX "ACPI: " | 46 | #define PREFIX "ACPI: " |
47 | 47 | ||
diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c index 20360e480bd8..afafee56cf8b 100644 --- a/drivers/acpi/pci_root.c +++ b/drivers/acpi/pci_root.c | |||
@@ -35,9 +35,7 @@ | |||
35 | #include <linux/pci-aspm.h> | 35 | #include <linux/pci-aspm.h> |
36 | #include <linux/acpi.h> | 36 | #include <linux/acpi.h> |
37 | #include <linux/slab.h> | 37 | #include <linux/slab.h> |
38 | #include <acpi/acpi_bus.h> | 38 | #include <acpi/apei.h> /* for acpi_hest_init() */ |
39 | #include <acpi/acpi_drivers.h> | ||
40 | #include <acpi/apei.h> | ||
41 | 39 | ||
42 | #include "internal.h" | 40 | #include "internal.h" |
43 | 41 | ||
@@ -51,6 +49,12 @@ static int acpi_pci_root_add(struct acpi_device *device, | |||
51 | const struct acpi_device_id *not_used); | 49 | const struct acpi_device_id *not_used); |
52 | static void acpi_pci_root_remove(struct acpi_device *device); | 50 | static void acpi_pci_root_remove(struct acpi_device *device); |
53 | 51 | ||
52 | static int acpi_pci_root_scan_dependent(struct acpi_device *adev) | ||
53 | { | ||
54 | acpiphp_check_host_bridge(adev->handle); | ||
55 | return 0; | ||
56 | } | ||
57 | |||
54 | #define ACPI_PCIE_REQ_SUPPORT (OSC_PCI_EXT_CONFIG_SUPPORT \ | 58 | #define ACPI_PCIE_REQ_SUPPORT (OSC_PCI_EXT_CONFIG_SUPPORT \ |
55 | | OSC_PCI_ASPM_SUPPORT \ | 59 | | OSC_PCI_ASPM_SUPPORT \ |
56 | | OSC_PCI_CLOCK_PM_SUPPORT \ | 60 | | OSC_PCI_CLOCK_PM_SUPPORT \ |
@@ -66,7 +70,8 @@ static struct acpi_scan_handler pci_root_handler = { | |||
66 | .attach = acpi_pci_root_add, | 70 | .attach = acpi_pci_root_add, |
67 | .detach = acpi_pci_root_remove, | 71 | .detach = acpi_pci_root_remove, |
68 | .hotplug = { | 72 | .hotplug = { |
69 | .ignore = true, | 73 | .enabled = true, |
74 | .scan_dependent = acpi_pci_root_scan_dependent, | ||
70 | }, | 75 | }, |
71 | }; | 76 | }; |
72 | 77 | ||
@@ -624,116 +629,9 @@ static void acpi_pci_root_remove(struct acpi_device *device) | |||
624 | void __init acpi_pci_root_init(void) | 629 | void __init acpi_pci_root_init(void) |
625 | { | 630 | { |
626 | acpi_hest_init(); | 631 | acpi_hest_init(); |
627 | 632 | if (acpi_pci_disabled) | |
628 | if (!acpi_pci_disabled) { | ||
629 | pci_acpi_crs_quirks(); | ||
630 | acpi_scan_add_handler(&pci_root_handler); | ||
631 | } | ||
632 | } | ||
633 | /* Support root bridge hotplug */ | ||
634 | |||
635 | static void handle_root_bridge_insertion(acpi_handle handle) | ||
636 | { | ||
637 | struct acpi_device *device; | ||
638 | |||
639 | if (!acpi_bus_get_device(handle, &device)) { | ||
640 | dev_printk(KERN_DEBUG, &device->dev, | ||
641 | "acpi device already exists; ignoring notify\n"); | ||
642 | return; | 633 | return; |
643 | } | ||
644 | |||
645 | if (acpi_bus_scan(handle)) | ||
646 | acpi_handle_err(handle, "cannot add bridge to acpi list\n"); | ||
647 | } | ||
648 | |||
649 | static void hotplug_event_root(void *data, u32 type) | ||
650 | { | ||
651 | acpi_handle handle = data; | ||
652 | struct acpi_pci_root *root; | ||
653 | |||
654 | acpi_scan_lock_acquire(); | ||
655 | |||
656 | root = acpi_pci_find_root(handle); | ||
657 | |||
658 | switch (type) { | ||
659 | case ACPI_NOTIFY_BUS_CHECK: | ||
660 | /* bus enumerate */ | ||
661 | acpi_handle_printk(KERN_DEBUG, handle, | ||
662 | "Bus check notify on %s\n", __func__); | ||
663 | if (root) | ||
664 | acpiphp_check_host_bridge(handle); | ||
665 | else | ||
666 | handle_root_bridge_insertion(handle); | ||
667 | |||
668 | break; | ||
669 | |||
670 | case ACPI_NOTIFY_DEVICE_CHECK: | ||
671 | /* device check */ | ||
672 | acpi_handle_printk(KERN_DEBUG, handle, | ||
673 | "Device check notify on %s\n", __func__); | ||
674 | if (!root) | ||
675 | handle_root_bridge_insertion(handle); | ||
676 | break; | ||
677 | |||
678 | case ACPI_NOTIFY_EJECT_REQUEST: | ||
679 | /* request device eject */ | ||
680 | acpi_handle_printk(KERN_DEBUG, handle, | ||
681 | "Device eject notify on %s\n", __func__); | ||
682 | if (!root) | ||
683 | break; | ||
684 | |||
685 | get_device(&root->device->dev); | ||
686 | |||
687 | acpi_scan_lock_release(); | ||
688 | |||
689 | acpi_bus_device_eject(root->device, ACPI_NOTIFY_EJECT_REQUEST); | ||
690 | return; | ||
691 | default: | ||
692 | acpi_handle_warn(handle, | ||
693 | "notify_handler: unknown event type 0x%x\n", | ||
694 | type); | ||
695 | break; | ||
696 | } | ||
697 | |||
698 | acpi_scan_lock_release(); | ||
699 | } | ||
700 | |||
701 | static void handle_hotplug_event_root(acpi_handle handle, u32 type, | ||
702 | void *context) | ||
703 | { | ||
704 | acpi_hotplug_execute(hotplug_event_root, handle, type); | ||
705 | } | ||
706 | |||
707 | static acpi_status __init | ||
708 | find_root_bridges(acpi_handle handle, u32 lvl, void *context, void **rv) | ||
709 | { | ||
710 | acpi_status status; | ||
711 | int *count = (int *)context; | ||
712 | |||
713 | if (!acpi_is_root_bridge(handle)) | ||
714 | return AE_OK; | ||
715 | |||
716 | (*count)++; | ||
717 | |||
718 | status = acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY, | ||
719 | handle_hotplug_event_root, NULL); | ||
720 | if (ACPI_FAILURE(status)) | ||
721 | acpi_handle_printk(KERN_DEBUG, handle, | ||
722 | "notify handler is not installed, exit status: %u\n", | ||
723 | (unsigned int)status); | ||
724 | else | ||
725 | acpi_handle_printk(KERN_DEBUG, handle, | ||
726 | "notify handler is installed\n"); | ||
727 | |||
728 | return AE_OK; | ||
729 | } | ||
730 | |||
731 | void __init acpi_pci_root_hp_init(void) | ||
732 | { | ||
733 | int num = 0; | ||
734 | |||
735 | acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, | ||
736 | ACPI_UINT32_MAX, find_root_bridges, NULL, &num, NULL); | ||
737 | 634 | ||
738 | printk(KERN_DEBUG "Found %d acpi root devices\n", num); | 635 | pci_acpi_crs_quirks(); |
636 | acpi_scan_add_handler_with_hotplug(&pci_root_handler, "pci_root"); | ||
739 | } | 637 | } |
diff --git a/drivers/acpi/pci_slot.c b/drivers/acpi/pci_slot.c index d678a180ca2a..139d9e479370 100644 --- a/drivers/acpi/pci_slot.c +++ b/drivers/acpi/pci_slot.c | |||
@@ -35,6 +35,7 @@ | |||
35 | #include <linux/pci.h> | 35 | #include <linux/pci.h> |
36 | #include <linux/acpi.h> | 36 | #include <linux/acpi.h> |
37 | #include <linux/dmi.h> | 37 | #include <linux/dmi.h> |
38 | #include <linux/pci-acpi.h> | ||
38 | 39 | ||
39 | static bool debug; | 40 | static bool debug; |
40 | static int check_sta_before_sun; | 41 | static int check_sta_before_sun; |
diff --git a/drivers/acpi/power.c b/drivers/acpi/power.c index c2ad391d8041..ad7da686e6e6 100644 --- a/drivers/acpi/power.c +++ b/drivers/acpi/power.c | |||
@@ -42,8 +42,7 @@ | |||
42 | #include <linux/slab.h> | 42 | #include <linux/slab.h> |
43 | #include <linux/pm_runtime.h> | 43 | #include <linux/pm_runtime.h> |
44 | #include <linux/sysfs.h> | 44 | #include <linux/sysfs.h> |
45 | #include <acpi/acpi_bus.h> | 45 | #include <linux/acpi.h> |
46 | #include <acpi/acpi_drivers.h> | ||
47 | #include "sleep.h" | 46 | #include "sleep.h" |
48 | #include "internal.h" | 47 | #include "internal.h" |
49 | 48 | ||
diff --git a/drivers/acpi/proc.c b/drivers/acpi/proc.c index 6a5b152ad4d0..50fe34ffe932 100644 --- a/drivers/acpi/proc.c +++ b/drivers/acpi/proc.c | |||
@@ -3,12 +3,11 @@ | |||
3 | #include <linux/export.h> | 3 | #include <linux/export.h> |
4 | #include <linux/suspend.h> | 4 | #include <linux/suspend.h> |
5 | #include <linux/bcd.h> | 5 | #include <linux/bcd.h> |
6 | #include <linux/acpi.h> | ||
6 | #include <asm/uaccess.h> | 7 | #include <asm/uaccess.h> |
7 | 8 | ||
8 | #include <acpi/acpi_bus.h> | ||
9 | #include <acpi/acpi_drivers.h> | ||
10 | |||
11 | #include "sleep.h" | 9 | #include "sleep.h" |
10 | #include "internal.h" | ||
12 | 11 | ||
13 | #define _COMPONENT ACPI_SYSTEM_COMPONENT | 12 | #define _COMPONENT ACPI_SYSTEM_COMPONENT |
14 | 13 | ||
diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c index b3171f30b319..34e7b3c6a08d 100644 --- a/drivers/acpi/processor_core.c +++ b/drivers/acpi/processor_core.c | |||
@@ -10,8 +10,7 @@ | |||
10 | #include <linux/export.h> | 10 | #include <linux/export.h> |
11 | #include <linux/dmi.h> | 11 | #include <linux/dmi.h> |
12 | #include <linux/slab.h> | 12 | #include <linux/slab.h> |
13 | 13 | #include <linux/acpi.h> | |
14 | #include <acpi/acpi_drivers.h> | ||
15 | #include <acpi/processor.h> | 14 | #include <acpi/processor.h> |
16 | 15 | ||
17 | #include "internal.h" | 16 | #include "internal.h" |
diff --git a/drivers/acpi/processor_driver.c b/drivers/acpi/processor_driver.c index 146ab7e2b81d..c1c35623550f 100644 --- a/drivers/acpi/processor_driver.c +++ b/drivers/acpi/processor_driver.c | |||
@@ -224,9 +224,9 @@ static int __acpi_processor_start(struct acpi_device *device) | |||
224 | 224 | ||
225 | static int acpi_processor_start(struct device *dev) | 225 | static int acpi_processor_start(struct device *dev) |
226 | { | 226 | { |
227 | struct acpi_device *device; | 227 | struct acpi_device *device = ACPI_COMPANION(dev); |
228 | 228 | ||
229 | if (acpi_bus_get_device(ACPI_HANDLE(dev), &device)) | 229 | if (!device) |
230 | return -ENODEV; | 230 | return -ENODEV; |
231 | 231 | ||
232 | return __acpi_processor_start(device); | 232 | return __acpi_processor_start(device); |
@@ -234,10 +234,10 @@ static int acpi_processor_start(struct device *dev) | |||
234 | 234 | ||
235 | static int acpi_processor_stop(struct device *dev) | 235 | static int acpi_processor_stop(struct device *dev) |
236 | { | 236 | { |
237 | struct acpi_device *device; | 237 | struct acpi_device *device = ACPI_COMPANION(dev); |
238 | struct acpi_processor *pr; | 238 | struct acpi_processor *pr; |
239 | 239 | ||
240 | if (acpi_bus_get_device(ACPI_HANDLE(dev), &device)) | 240 | if (!device) |
241 | return 0; | 241 | return 0; |
242 | 242 | ||
243 | acpi_remove_notify_handler(device->handle, ACPI_DEVICE_NOTIFY, | 243 | acpi_remove_notify_handler(device->handle, ACPI_DEVICE_NOTIFY, |
diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c index 644516d9bde6..799644c3888c 100644 --- a/drivers/acpi/processor_idle.c +++ b/drivers/acpi/processor_idle.c | |||
@@ -35,6 +35,7 @@ | |||
35 | #include <linux/clockchips.h> | 35 | #include <linux/clockchips.h> |
36 | #include <linux/cpuidle.h> | 36 | #include <linux/cpuidle.h> |
37 | #include <linux/syscore_ops.h> | 37 | #include <linux/syscore_ops.h> |
38 | #include <acpi/processor.h> | ||
38 | 39 | ||
39 | /* | 40 | /* |
40 | * Include the apic definitions for x86 to have the APIC timer related defines | 41 | * Include the apic definitions for x86 to have the APIC timer related defines |
@@ -46,9 +47,6 @@ | |||
46 | #include <asm/apic.h> | 47 | #include <asm/apic.h> |
47 | #endif | 48 | #endif |
48 | 49 | ||
49 | #include <acpi/acpi_bus.h> | ||
50 | #include <acpi/processor.h> | ||
51 | |||
52 | #define PREFIX "ACPI: " | 50 | #define PREFIX "ACPI: " |
53 | 51 | ||
54 | #define ACPI_PROCESSOR_CLASS "processor" | 52 | #define ACPI_PROCESSOR_CLASS "processor" |
@@ -213,7 +211,7 @@ static int acpi_processor_suspend(void) | |||
213 | 211 | ||
214 | static void acpi_processor_resume(void) | 212 | static void acpi_processor_resume(void) |
215 | { | 213 | { |
216 | u32 resumed_bm_rld; | 214 | u32 resumed_bm_rld = 0; |
217 | 215 | ||
218 | acpi_read_bit_register(ACPI_BITREG_BUS_MASTER_RLD, &resumed_bm_rld); | 216 | acpi_read_bit_register(ACPI_BITREG_BUS_MASTER_RLD, &resumed_bm_rld); |
219 | if (resumed_bm_rld == saved_bm_rld) | 217 | if (resumed_bm_rld == saved_bm_rld) |
@@ -598,7 +596,7 @@ static int acpi_processor_power_verify(struct acpi_processor *pr) | |||
598 | case ACPI_STATE_C2: | 596 | case ACPI_STATE_C2: |
599 | if (!cx->address) | 597 | if (!cx->address) |
600 | break; | 598 | break; |
601 | cx->valid = 1; | 599 | cx->valid = 1; |
602 | break; | 600 | break; |
603 | 601 | ||
604 | case ACPI_STATE_C3: | 602 | case ACPI_STATE_C3: |
diff --git a/drivers/acpi/processor_perflib.c b/drivers/acpi/processor_perflib.c index 60a7c28fc167..ff90054f04fd 100644 --- a/drivers/acpi/processor_perflib.c +++ b/drivers/acpi/processor_perflib.c | |||
@@ -31,15 +31,12 @@ | |||
31 | #include <linux/init.h> | 31 | #include <linux/init.h> |
32 | #include <linux/cpufreq.h> | 32 | #include <linux/cpufreq.h> |
33 | #include <linux/slab.h> | 33 | #include <linux/slab.h> |
34 | 34 | #include <linux/acpi.h> | |
35 | #include <acpi/processor.h> | ||
35 | #ifdef CONFIG_X86 | 36 | #ifdef CONFIG_X86 |
36 | #include <asm/cpufeature.h> | 37 | #include <asm/cpufeature.h> |
37 | #endif | 38 | #endif |
38 | 39 | ||
39 | #include <acpi/acpi_bus.h> | ||
40 | #include <acpi/acpi_drivers.h> | ||
41 | #include <acpi/processor.h> | ||
42 | |||
43 | #define PREFIX "ACPI: " | 40 | #define PREFIX "ACPI: " |
44 | 41 | ||
45 | #define ACPI_PROCESSOR_CLASS "processor" | 42 | #define ACPI_PROCESSOR_CLASS "processor" |
diff --git a/drivers/acpi/processor_thermal.c b/drivers/acpi/processor_thermal.c index d1d2e7fb5b30..e003663b2f8e 100644 --- a/drivers/acpi/processor_thermal.c +++ b/drivers/acpi/processor_thermal.c | |||
@@ -30,12 +30,9 @@ | |||
30 | #include <linux/module.h> | 30 | #include <linux/module.h> |
31 | #include <linux/init.h> | 31 | #include <linux/init.h> |
32 | #include <linux/cpufreq.h> | 32 | #include <linux/cpufreq.h> |
33 | 33 | #include <linux/acpi.h> | |
34 | #include <asm/uaccess.h> | ||
35 | |||
36 | #include <acpi/acpi_bus.h> | ||
37 | #include <acpi/processor.h> | 34 | #include <acpi/processor.h> |
38 | #include <acpi/acpi_drivers.h> | 35 | #include <asm/uaccess.h> |
39 | 36 | ||
40 | #define PREFIX "ACPI: " | 37 | #define PREFIX "ACPI: " |
41 | 38 | ||
@@ -186,14 +183,14 @@ static int cpufreq_set_cur_state(unsigned int cpu, int state) | |||
186 | 183 | ||
187 | #endif | 184 | #endif |
188 | 185 | ||
189 | /* thermal coolign device callbacks */ | 186 | /* thermal cooling device callbacks */ |
190 | static int acpi_processor_max_state(struct acpi_processor *pr) | 187 | static int acpi_processor_max_state(struct acpi_processor *pr) |
191 | { | 188 | { |
192 | int max_state = 0; | 189 | int max_state = 0; |
193 | 190 | ||
194 | /* | 191 | /* |
195 | * There exists four states according to | 192 | * There exists four states according to |
196 | * cpufreq_thermal_reduction_ptg. 0, 1, 2, 3 | 193 | * cpufreq_thermal_reduction_pctg. 0, 1, 2, 3 |
197 | */ | 194 | */ |
198 | max_state += cpufreq_get_max_state(pr->id); | 195 | max_state += cpufreq_get_max_state(pr->id); |
199 | if (pr->flags.throttling) | 196 | if (pr->flags.throttling) |
diff --git a/drivers/acpi/processor_throttling.c b/drivers/acpi/processor_throttling.c index e7dd2c1fee79..28baa05b8018 100644 --- a/drivers/acpi/processor_throttling.c +++ b/drivers/acpi/processor_throttling.c | |||
@@ -32,14 +32,11 @@ | |||
32 | #include <linux/init.h> | 32 | #include <linux/init.h> |
33 | #include <linux/sched.h> | 33 | #include <linux/sched.h> |
34 | #include <linux/cpufreq.h> | 34 | #include <linux/cpufreq.h> |
35 | 35 | #include <linux/acpi.h> | |
36 | #include <acpi/processor.h> | ||
36 | #include <asm/io.h> | 37 | #include <asm/io.h> |
37 | #include <asm/uaccess.h> | 38 | #include <asm/uaccess.h> |
38 | 39 | ||
39 | #include <acpi/acpi_bus.h> | ||
40 | #include <acpi/acpi_drivers.h> | ||
41 | #include <acpi/processor.h> | ||
42 | |||
43 | #define PREFIX "ACPI: " | 40 | #define PREFIX "ACPI: " |
44 | 41 | ||
45 | #define ACPI_PROCESSOR_CLASS "processor" | 42 | #define ACPI_PROCESSOR_CLASS "processor" |
diff --git a/drivers/acpi/sbshc.c b/drivers/acpi/sbshc.c index b78bc605837e..26e5b5060523 100644 --- a/drivers/acpi/sbshc.c +++ b/drivers/acpi/sbshc.c | |||
@@ -8,8 +8,7 @@ | |||
8 | * the Free Software Foundation version 2. | 8 | * the Free Software Foundation version 2. |
9 | */ | 9 | */ |
10 | 10 | ||
11 | #include <acpi/acpi_bus.h> | 11 | #include <linux/acpi.h> |
12 | #include <acpi/acpi_drivers.h> | ||
13 | #include <linux/wait.h> | 12 | #include <linux/wait.h> |
14 | #include <linux/slab.h> | 13 | #include <linux/slab.h> |
15 | #include <linux/delay.h> | 14 | #include <linux/delay.h> |
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index fd39459926b1..c0f57ff15024 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c | |||
@@ -12,13 +12,12 @@ | |||
12 | #include <linux/dmi.h> | 12 | #include <linux/dmi.h> |
13 | #include <linux/nls.h> | 13 | #include <linux/nls.h> |
14 | 14 | ||
15 | #include <acpi/acpi_drivers.h> | 15 | #include <asm/pgtable.h> |
16 | 16 | ||
17 | #include "internal.h" | 17 | #include "internal.h" |
18 | 18 | ||
19 | #define _COMPONENT ACPI_BUS_COMPONENT | 19 | #define _COMPONENT ACPI_BUS_COMPONENT |
20 | ACPI_MODULE_NAME("scan"); | 20 | ACPI_MODULE_NAME("scan"); |
21 | #define STRUCT_TO_INT(s) (*((int*)&s)) | ||
22 | extern struct acpi_device *acpi_root; | 21 | extern struct acpi_device *acpi_root; |
23 | 22 | ||
24 | #define ACPI_BUS_CLASS "system_bus" | 23 | #define ACPI_BUS_CLASS "system_bus" |
@@ -27,6 +26,8 @@ extern struct acpi_device *acpi_root; | |||
27 | 26 | ||
28 | #define ACPI_IS_ROOT_DEVICE(device) (!(device)->parent) | 27 | #define ACPI_IS_ROOT_DEVICE(device) (!(device)->parent) |
29 | 28 | ||
29 | #define INVALID_ACPI_HANDLE ((acpi_handle)empty_zero_page) | ||
30 | |||
30 | /* | 31 | /* |
31 | * If set, devices will be hot-removed even if they cannot be put offline | 32 | * If set, devices will be hot-removed even if they cannot be put offline |
32 | * gracefully (from the kernel's standpoint). | 33 | * gracefully (from the kernel's standpoint). |
@@ -125,6 +126,26 @@ acpi_device_modalias_show(struct device *dev, struct device_attribute *attr, cha | |||
125 | } | 126 | } |
126 | static DEVICE_ATTR(modalias, 0444, acpi_device_modalias_show, NULL); | 127 | static DEVICE_ATTR(modalias, 0444, acpi_device_modalias_show, NULL); |
127 | 128 | ||
129 | bool acpi_scan_is_offline(struct acpi_device *adev, bool uevent) | ||
130 | { | ||
131 | struct acpi_device_physical_node *pn; | ||
132 | bool offline = true; | ||
133 | |||
134 | mutex_lock(&adev->physical_node_lock); | ||
135 | |||
136 | list_for_each_entry(pn, &adev->physical_node_list, node) | ||
137 | if (device_supports_offline(pn->dev) && !pn->dev->offline) { | ||
138 | if (uevent) | ||
139 | kobject_uevent(&pn->dev->kobj, KOBJ_CHANGE); | ||
140 | |||
141 | offline = false; | ||
142 | break; | ||
143 | } | ||
144 | |||
145 | mutex_unlock(&adev->physical_node_lock); | ||
146 | return offline; | ||
147 | } | ||
148 | |||
128 | static acpi_status acpi_bus_offline(acpi_handle handle, u32 lvl, void *data, | 149 | static acpi_status acpi_bus_offline(acpi_handle handle, u32 lvl, void *data, |
129 | void **ret_p) | 150 | void **ret_p) |
130 | { | 151 | { |
@@ -195,19 +216,11 @@ static acpi_status acpi_bus_online(acpi_handle handle, u32 lvl, void *data, | |||
195 | return AE_OK; | 216 | return AE_OK; |
196 | } | 217 | } |
197 | 218 | ||
198 | static int acpi_scan_hot_remove(struct acpi_device *device) | 219 | static int acpi_scan_try_to_offline(struct acpi_device *device) |
199 | { | 220 | { |
200 | acpi_handle handle = device->handle; | 221 | acpi_handle handle = device->handle; |
201 | struct device *errdev; | 222 | struct device *errdev = NULL; |
202 | acpi_status status; | 223 | acpi_status status; |
203 | unsigned long long sta; | ||
204 | |||
205 | /* If there is no handle, the device node has been unregistered. */ | ||
206 | if (!handle) { | ||
207 | dev_dbg(&device->dev, "ACPI handle missing\n"); | ||
208 | put_device(&device->dev); | ||
209 | return -EINVAL; | ||
210 | } | ||
211 | 224 | ||
212 | /* | 225 | /* |
213 | * Carry out two passes here and ignore errors in the first pass, | 226 | * Carry out two passes here and ignore errors in the first pass, |
@@ -218,7 +231,6 @@ static int acpi_scan_hot_remove(struct acpi_device *device) | |||
218 | * | 231 | * |
219 | * If the first pass is successful, the second one isn't needed, though. | 232 | * If the first pass is successful, the second one isn't needed, though. |
220 | */ | 233 | */ |
221 | errdev = NULL; | ||
222 | status = acpi_walk_namespace(ACPI_TYPE_ANY, handle, ACPI_UINT32_MAX, | 234 | status = acpi_walk_namespace(ACPI_TYPE_ANY, handle, ACPI_UINT32_MAX, |
223 | NULL, acpi_bus_offline, (void *)false, | 235 | NULL, acpi_bus_offline, (void *)false, |
224 | (void **)&errdev); | 236 | (void **)&errdev); |
@@ -226,7 +238,6 @@ static int acpi_scan_hot_remove(struct acpi_device *device) | |||
226 | dev_warn(errdev, "Offline disabled.\n"); | 238 | dev_warn(errdev, "Offline disabled.\n"); |
227 | acpi_walk_namespace(ACPI_TYPE_ANY, handle, ACPI_UINT32_MAX, | 239 | acpi_walk_namespace(ACPI_TYPE_ANY, handle, ACPI_UINT32_MAX, |
228 | acpi_bus_online, NULL, NULL, NULL); | 240 | acpi_bus_online, NULL, NULL, NULL); |
229 | put_device(&device->dev); | ||
230 | return -EPERM; | 241 | return -EPERM; |
231 | } | 242 | } |
232 | acpi_bus_offline(handle, 0, (void *)false, (void **)&errdev); | 243 | acpi_bus_offline(handle, 0, (void *)false, (void **)&errdev); |
@@ -245,20 +256,32 @@ static int acpi_scan_hot_remove(struct acpi_device *device) | |||
245 | acpi_walk_namespace(ACPI_TYPE_ANY, handle, | 256 | acpi_walk_namespace(ACPI_TYPE_ANY, handle, |
246 | ACPI_UINT32_MAX, acpi_bus_online, | 257 | ACPI_UINT32_MAX, acpi_bus_online, |
247 | NULL, NULL, NULL); | 258 | NULL, NULL, NULL); |
248 | put_device(&device->dev); | ||
249 | return -EBUSY; | 259 | return -EBUSY; |
250 | } | 260 | } |
251 | } | 261 | } |
262 | return 0; | ||
263 | } | ||
264 | |||
265 | static int acpi_scan_hot_remove(struct acpi_device *device) | ||
266 | { | ||
267 | acpi_handle handle = device->handle; | ||
268 | unsigned long long sta; | ||
269 | acpi_status status; | ||
270 | |||
271 | if (device->handler->hotplug.demand_offline && !acpi_force_hot_remove) { | ||
272 | if (!acpi_scan_is_offline(device, true)) | ||
273 | return -EBUSY; | ||
274 | } else { | ||
275 | int error = acpi_scan_try_to_offline(device); | ||
276 | if (error) | ||
277 | return error; | ||
278 | } | ||
252 | 279 | ||
253 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | 280 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, |
254 | "Hot-removing device %s...\n", dev_name(&device->dev))); | 281 | "Hot-removing device %s...\n", dev_name(&device->dev))); |
255 | 282 | ||
256 | acpi_bus_trim(device); | 283 | acpi_bus_trim(device); |
257 | 284 | ||
258 | /* Device node has been unregistered. */ | ||
259 | put_device(&device->dev); | ||
260 | device = NULL; | ||
261 | |||
262 | acpi_evaluate_lck(handle, 0); | 285 | acpi_evaluate_lck(handle, 0); |
263 | /* | 286 | /* |
264 | * TBD: _EJD support. | 287 | * TBD: _EJD support. |
@@ -285,115 +308,127 @@ static int acpi_scan_hot_remove(struct acpi_device *device) | |||
285 | return 0; | 308 | return 0; |
286 | } | 309 | } |
287 | 310 | ||
288 | void acpi_bus_device_eject(void *data, u32 ost_src) | 311 | static int acpi_scan_device_not_present(struct acpi_device *adev) |
289 | { | 312 | { |
290 | struct acpi_device *device = data; | 313 | if (!acpi_device_enumerated(adev)) { |
291 | acpi_handle handle = device->handle; | 314 | dev_warn(&adev->dev, "Still not present\n"); |
292 | u32 ost_code = ACPI_OST_SC_NON_SPECIFIC_FAILURE; | 315 | return -EALREADY; |
293 | int error; | 316 | } |
317 | acpi_bus_trim(adev); | ||
318 | return 0; | ||
319 | } | ||
294 | 320 | ||
295 | lock_device_hotplug(); | 321 | static int acpi_scan_device_check(struct acpi_device *adev) |
296 | mutex_lock(&acpi_scan_lock); | 322 | { |
323 | int error; | ||
297 | 324 | ||
298 | if (ost_src == ACPI_NOTIFY_EJECT_REQUEST) | 325 | acpi_bus_get_status(adev); |
299 | acpi_evaluate_hotplug_ost(handle, ACPI_NOTIFY_EJECT_REQUEST, | 326 | if (adev->status.present || adev->status.functional) { |
300 | ACPI_OST_SC_EJECT_IN_PROGRESS, NULL); | 327 | /* |
328 | * This function is only called for device objects for which | ||
329 | * matching scan handlers exist. The only situation in which | ||
330 | * the scan handler is not attached to this device object yet | ||
331 | * is when the device has just appeared (either it wasn't | ||
332 | * present at all before or it was removed and then added | ||
333 | * again). | ||
334 | */ | ||
335 | if (adev->handler) { | ||
336 | dev_warn(&adev->dev, "Already enumerated\n"); | ||
337 | return -EALREADY; | ||
338 | } | ||
339 | error = acpi_bus_scan(adev->handle); | ||
340 | if (error) { | ||
341 | dev_warn(&adev->dev, "Namespace scan failure\n"); | ||
342 | return error; | ||
343 | } | ||
344 | if (!adev->handler) { | ||
345 | dev_warn(&adev->dev, "Enumeration failure\n"); | ||
346 | error = -ENODEV; | ||
347 | } | ||
348 | } else { | ||
349 | error = acpi_scan_device_not_present(adev); | ||
350 | } | ||
351 | return error; | ||
352 | } | ||
301 | 353 | ||
302 | if (device->handler && device->handler->hotplug.mode == AHM_CONTAINER) | 354 | static int acpi_scan_bus_check(struct acpi_device *adev) |
303 | kobject_uevent(&device->dev.kobj, KOBJ_OFFLINE); | 355 | { |
356 | struct acpi_scan_handler *handler = adev->handler; | ||
357 | struct acpi_device *child; | ||
358 | int error; | ||
304 | 359 | ||
305 | error = acpi_scan_hot_remove(device); | 360 | acpi_bus_get_status(adev); |
306 | if (error == -EPERM) { | 361 | if (!(adev->status.present || adev->status.functional)) { |
307 | goto err_support; | 362 | acpi_scan_device_not_present(adev); |
308 | } else if (error) { | 363 | return 0; |
309 | goto err_out; | ||
310 | } | 364 | } |
365 | if (handler && handler->hotplug.scan_dependent) | ||
366 | return handler->hotplug.scan_dependent(adev); | ||
311 | 367 | ||
312 | out: | 368 | error = acpi_bus_scan(adev->handle); |
313 | mutex_unlock(&acpi_scan_lock); | 369 | if (error) { |
314 | unlock_device_hotplug(); | 370 | dev_warn(&adev->dev, "Namespace scan failure\n"); |
315 | return; | 371 | return error; |
316 | 372 | } | |
317 | err_support: | 373 | list_for_each_entry(child, &adev->children, node) { |
318 | ost_code = ACPI_OST_SC_EJECT_NOT_SUPPORTED; | 374 | error = acpi_scan_bus_check(child); |
319 | err_out: | 375 | if (error) |
320 | acpi_evaluate_hotplug_ost(handle, ost_src, ost_code, NULL); | 376 | return error; |
321 | goto out; | 377 | } |
378 | return 0; | ||
322 | } | 379 | } |
323 | 380 | ||
324 | static void acpi_scan_bus_device_check(void *data, u32 ost_source) | 381 | static void acpi_device_hotplug(void *data, u32 src) |
325 | { | 382 | { |
326 | acpi_handle handle = data; | ||
327 | struct acpi_device *device = NULL; | ||
328 | u32 ost_code = ACPI_OST_SC_NON_SPECIFIC_FAILURE; | 383 | u32 ost_code = ACPI_OST_SC_NON_SPECIFIC_FAILURE; |
384 | struct acpi_device *adev = data; | ||
329 | int error; | 385 | int error; |
330 | 386 | ||
331 | lock_device_hotplug(); | 387 | lock_device_hotplug(); |
332 | mutex_lock(&acpi_scan_lock); | 388 | mutex_lock(&acpi_scan_lock); |
333 | 389 | ||
334 | if (ost_source != ACPI_NOTIFY_BUS_CHECK) { | 390 | /* |
335 | acpi_bus_get_device(handle, &device); | 391 | * The device object's ACPI handle cannot become invalid as long as we |
336 | if (device) { | 392 | * are holding acpi_scan_lock, but it may have become invalid before |
337 | dev_warn(&device->dev, "Attempt to re-insert\n"); | 393 | * that lock was acquired. |
338 | goto out; | 394 | */ |
339 | } | 395 | if (adev->handle == INVALID_ACPI_HANDLE) |
340 | } | ||
341 | error = acpi_bus_scan(handle); | ||
342 | if (error) { | ||
343 | acpi_handle_warn(handle, "Namespace scan failure\n"); | ||
344 | goto out; | ||
345 | } | ||
346 | error = acpi_bus_get_device(handle, &device); | ||
347 | if (error) { | ||
348 | acpi_handle_warn(handle, "Missing device node object\n"); | ||
349 | goto out; | 396 | goto out; |
350 | } | ||
351 | ost_code = ACPI_OST_SC_SUCCESS; | ||
352 | if (device->handler && device->handler->hotplug.mode == AHM_CONTAINER) | ||
353 | kobject_uevent(&device->dev.kobj, KOBJ_ONLINE); | ||
354 | |||
355 | out: | ||
356 | acpi_evaluate_hotplug_ost(handle, ost_source, ost_code, NULL); | ||
357 | mutex_unlock(&acpi_scan_lock); | ||
358 | unlock_device_hotplug(); | ||
359 | } | ||
360 | |||
361 | static void acpi_hotplug_unsupported(acpi_handle handle, u32 type) | ||
362 | { | ||
363 | u32 ost_status; | ||
364 | 397 | ||
365 | switch (type) { | 398 | switch (src) { |
366 | case ACPI_NOTIFY_BUS_CHECK: | 399 | case ACPI_NOTIFY_BUS_CHECK: |
367 | acpi_handle_debug(handle, | 400 | error = acpi_scan_bus_check(adev); |
368 | "ACPI_NOTIFY_BUS_CHECK event: unsupported\n"); | ||
369 | ost_status = ACPI_OST_SC_INSERT_NOT_SUPPORTED; | ||
370 | break; | 401 | break; |
371 | case ACPI_NOTIFY_DEVICE_CHECK: | 402 | case ACPI_NOTIFY_DEVICE_CHECK: |
372 | acpi_handle_debug(handle, | 403 | error = acpi_scan_device_check(adev); |
373 | "ACPI_NOTIFY_DEVICE_CHECK event: unsupported\n"); | ||
374 | ost_status = ACPI_OST_SC_INSERT_NOT_SUPPORTED; | ||
375 | break; | 404 | break; |
376 | case ACPI_NOTIFY_EJECT_REQUEST: | 405 | case ACPI_NOTIFY_EJECT_REQUEST: |
377 | acpi_handle_debug(handle, | 406 | case ACPI_OST_EC_OSPM_EJECT: |
378 | "ACPI_NOTIFY_EJECT_REQUEST event: unsupported\n"); | 407 | error = acpi_scan_hot_remove(adev); |
379 | ost_status = ACPI_OST_SC_EJECT_NOT_SUPPORTED; | ||
380 | break; | 408 | break; |
381 | default: | 409 | default: |
382 | /* non-hotplug event; possibly handled by other handler */ | 410 | error = -EINVAL; |
383 | return; | 411 | break; |
384 | } | 412 | } |
413 | if (!error) | ||
414 | ost_code = ACPI_OST_SC_SUCCESS; | ||
385 | 415 | ||
386 | acpi_evaluate_hotplug_ost(handle, type, ost_status, NULL); | 416 | out: |
417 | acpi_evaluate_hotplug_ost(adev->handle, src, ost_code, NULL); | ||
418 | put_device(&adev->dev); | ||
419 | mutex_unlock(&acpi_scan_lock); | ||
420 | unlock_device_hotplug(); | ||
387 | } | 421 | } |
388 | 422 | ||
389 | static void acpi_hotplug_notify_cb(acpi_handle handle, u32 type, void *data) | 423 | static void acpi_hotplug_notify_cb(acpi_handle handle, u32 type, void *data) |
390 | { | 424 | { |
425 | u32 ost_code = ACPI_OST_SC_NON_SPECIFIC_FAILURE; | ||
391 | struct acpi_scan_handler *handler = data; | 426 | struct acpi_scan_handler *handler = data; |
392 | struct acpi_device *adev; | 427 | struct acpi_device *adev; |
393 | acpi_status status; | 428 | acpi_status status; |
394 | 429 | ||
395 | if (!handler->hotplug.enabled) | 430 | if (acpi_bus_get_device(handle, &adev)) |
396 | return acpi_hotplug_unsupported(handle, type); | 431 | goto err_out; |
397 | 432 | ||
398 | switch (type) { | 433 | switch (type) { |
399 | case ACPI_NOTIFY_BUS_CHECK: | 434 | case ACPI_NOTIFY_BUS_CHECK: |
@@ -404,27 +439,27 @@ static void acpi_hotplug_notify_cb(acpi_handle handle, u32 type, void *data) | |||
404 | break; | 439 | break; |
405 | case ACPI_NOTIFY_EJECT_REQUEST: | 440 | case ACPI_NOTIFY_EJECT_REQUEST: |
406 | acpi_handle_debug(handle, "ACPI_NOTIFY_EJECT_REQUEST event\n"); | 441 | acpi_handle_debug(handle, "ACPI_NOTIFY_EJECT_REQUEST event\n"); |
407 | if (acpi_bus_get_device(handle, &adev)) | 442 | if (!handler->hotplug.enabled) { |
443 | acpi_handle_err(handle, "Eject disabled\n"); | ||
444 | ost_code = ACPI_OST_SC_EJECT_NOT_SUPPORTED; | ||
408 | goto err_out; | 445 | goto err_out; |
409 | 446 | } | |
410 | get_device(&adev->dev); | 447 | acpi_evaluate_hotplug_ost(handle, ACPI_NOTIFY_EJECT_REQUEST, |
411 | status = acpi_hotplug_execute(acpi_bus_device_eject, adev, type); | 448 | ACPI_OST_SC_EJECT_IN_PROGRESS, NULL); |
412 | if (ACPI_SUCCESS(status)) | 449 | break; |
413 | return; | ||
414 | |||
415 | put_device(&adev->dev); | ||
416 | goto err_out; | ||
417 | default: | 450 | default: |
418 | /* non-hotplug event; possibly handled by other handler */ | 451 | /* non-hotplug event; possibly handled by other handler */ |
419 | return; | 452 | return; |
420 | } | 453 | } |
421 | status = acpi_hotplug_execute(acpi_scan_bus_device_check, handle, type); | 454 | get_device(&adev->dev); |
455 | status = acpi_hotplug_execute(acpi_device_hotplug, adev, type); | ||
422 | if (ACPI_SUCCESS(status)) | 456 | if (ACPI_SUCCESS(status)) |
423 | return; | 457 | return; |
424 | 458 | ||
459 | put_device(&adev->dev); | ||
460 | |||
425 | err_out: | 461 | err_out: |
426 | acpi_evaluate_hotplug_ost(handle, type, | 462 | acpi_evaluate_hotplug_ost(handle, type, ost_code, NULL); |
427 | ACPI_OST_SC_NON_SPECIFIC_FAILURE, NULL); | ||
428 | } | 463 | } |
429 | 464 | ||
430 | static ssize_t real_power_state_show(struct device *dev, | 465 | static ssize_t real_power_state_show(struct device *dev, |
@@ -475,7 +510,7 @@ acpi_eject_store(struct device *d, struct device_attribute *attr, | |||
475 | acpi_evaluate_hotplug_ost(acpi_device->handle, ACPI_OST_EC_OSPM_EJECT, | 510 | acpi_evaluate_hotplug_ost(acpi_device->handle, ACPI_OST_EC_OSPM_EJECT, |
476 | ACPI_OST_SC_EJECT_IN_PROGRESS, NULL); | 511 | ACPI_OST_SC_EJECT_IN_PROGRESS, NULL); |
477 | get_device(&acpi_device->dev); | 512 | get_device(&acpi_device->dev); |
478 | status = acpi_hotplug_execute(acpi_bus_device_eject, acpi_device, | 513 | status = acpi_hotplug_execute(acpi_device_hotplug, acpi_device, |
479 | ACPI_OST_EC_OSPM_EJECT); | 514 | ACPI_OST_EC_OSPM_EJECT); |
480 | if (ACPI_SUCCESS(status)) | 515 | if (ACPI_SUCCESS(status)) |
481 | return count; | 516 | return count; |
@@ -567,6 +602,20 @@ acpi_device_sun_show(struct device *dev, struct device_attribute *attr, | |||
567 | } | 602 | } |
568 | static DEVICE_ATTR(sun, 0444, acpi_device_sun_show, NULL); | 603 | static DEVICE_ATTR(sun, 0444, acpi_device_sun_show, NULL); |
569 | 604 | ||
605 | static ssize_t status_show(struct device *dev, struct device_attribute *attr, | ||
606 | char *buf) { | ||
607 | struct acpi_device *acpi_dev = to_acpi_device(dev); | ||
608 | acpi_status status; | ||
609 | unsigned long long sta; | ||
610 | |||
611 | status = acpi_evaluate_integer(acpi_dev->handle, "_STA", NULL, &sta); | ||
612 | if (ACPI_FAILURE(status)) | ||
613 | return -ENODEV; | ||
614 | |||
615 | return sprintf(buf, "%llu\n", sta); | ||
616 | } | ||
617 | static DEVICE_ATTR_RO(status); | ||
618 | |||
570 | static int acpi_device_setup_files(struct acpi_device *dev) | 619 | static int acpi_device_setup_files(struct acpi_device *dev) |
571 | { | 620 | { |
572 | struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL}; | 621 | struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL}; |
@@ -622,6 +671,12 @@ static int acpi_device_setup_files(struct acpi_device *dev) | |||
622 | dev->pnp.sun = (unsigned long)-1; | 671 | dev->pnp.sun = (unsigned long)-1; |
623 | } | 672 | } |
624 | 673 | ||
674 | if (acpi_has_method(dev->handle, "_STA")) { | ||
675 | result = device_create_file(&dev->dev, &dev_attr_status); | ||
676 | if (result) | ||
677 | goto end; | ||
678 | } | ||
679 | |||
625 | /* | 680 | /* |
626 | * If device has _EJ0, 'eject' file is created that is used to trigger | 681 | * If device has _EJ0, 'eject' file is created that is used to trigger |
627 | * hot-removal function from userland. | 682 | * hot-removal function from userland. |
@@ -677,6 +732,8 @@ static void acpi_device_remove_files(struct acpi_device *dev) | |||
677 | device_remove_file(&dev->dev, &dev_attr_adr); | 732 | device_remove_file(&dev->dev, &dev_attr_adr); |
678 | device_remove_file(&dev->dev, &dev_attr_modalias); | 733 | device_remove_file(&dev->dev, &dev_attr_modalias); |
679 | device_remove_file(&dev->dev, &dev_attr_hid); | 734 | device_remove_file(&dev->dev, &dev_attr_hid); |
735 | if (acpi_has_method(dev->handle, "_STA")) | ||
736 | device_remove_file(&dev->dev, &dev_attr_status); | ||
680 | if (dev->handle) | 737 | if (dev->handle) |
681 | device_remove_file(&dev->dev, &dev_attr_path); | 738 | device_remove_file(&dev->dev, &dev_attr_path); |
682 | } | 739 | } |
@@ -907,9 +964,91 @@ struct bus_type acpi_bus_type = { | |||
907 | .uevent = acpi_device_uevent, | 964 | .uevent = acpi_device_uevent, |
908 | }; | 965 | }; |
909 | 966 | ||
910 | static void acpi_bus_data_handler(acpi_handle handle, void *context) | 967 | static void acpi_device_del(struct acpi_device *device) |
911 | { | 968 | { |
912 | /* Intentionally empty. */ | 969 | mutex_lock(&acpi_device_lock); |
970 | if (device->parent) | ||
971 | list_del(&device->node); | ||
972 | |||
973 | list_del(&device->wakeup_list); | ||
974 | mutex_unlock(&acpi_device_lock); | ||
975 | |||
976 | acpi_power_add_remove_device(device, false); | ||
977 | acpi_device_remove_files(device); | ||
978 | if (device->remove) | ||
979 | device->remove(device); | ||
980 | |||
981 | device_del(&device->dev); | ||
982 | } | ||
983 | |||
984 | static LIST_HEAD(acpi_device_del_list); | ||
985 | static DEFINE_MUTEX(acpi_device_del_lock); | ||
986 | |||
987 | static void acpi_device_del_work_fn(struct work_struct *work_not_used) | ||
988 | { | ||
989 | for (;;) { | ||
990 | struct acpi_device *adev; | ||
991 | |||
992 | mutex_lock(&acpi_device_del_lock); | ||
993 | |||
994 | if (list_empty(&acpi_device_del_list)) { | ||
995 | mutex_unlock(&acpi_device_del_lock); | ||
996 | break; | ||
997 | } | ||
998 | adev = list_first_entry(&acpi_device_del_list, | ||
999 | struct acpi_device, del_list); | ||
1000 | list_del(&adev->del_list); | ||
1001 | |||
1002 | mutex_unlock(&acpi_device_del_lock); | ||
1003 | |||
1004 | acpi_device_del(adev); | ||
1005 | /* | ||
1006 | * Drop references to all power resources that might have been | ||
1007 | * used by the device. | ||
1008 | */ | ||
1009 | acpi_power_transition(adev, ACPI_STATE_D3_COLD); | ||
1010 | put_device(&adev->dev); | ||
1011 | } | ||
1012 | } | ||
1013 | |||
1014 | /** | ||
1015 | * acpi_scan_drop_device - Drop an ACPI device object. | ||
1016 | * @handle: Handle of an ACPI namespace node, not used. | ||
1017 | * @context: Address of the ACPI device object to drop. | ||
1018 | * | ||
1019 | * This is invoked by acpi_ns_delete_node() during the removal of the ACPI | ||
1020 | * namespace node the device object pointed to by @context is attached to. | ||
1021 | * | ||
1022 | * The unregistration is carried out asynchronously to avoid running | ||
1023 | * acpi_device_del() under the ACPICA's namespace mutex and the list is used to | ||
1024 | * ensure the correct ordering (the device objects must be unregistered in the | ||
1025 | * same order in which the corresponding namespace nodes are deleted). | ||
1026 | */ | ||
1027 | static void acpi_scan_drop_device(acpi_handle handle, void *context) | ||
1028 | { | ||
1029 | static DECLARE_WORK(work, acpi_device_del_work_fn); | ||
1030 | struct acpi_device *adev = context; | ||
1031 | |||
1032 | mutex_lock(&acpi_device_del_lock); | ||
1033 | |||
1034 | /* | ||
1035 | * Use the ACPI hotplug workqueue which is ordered, so this work item | ||
1036 | * won't run after any hotplug work items submitted subsequently. That | ||
1037 | * prevents attempts to register device objects identical to those being | ||
1038 | * deleted from happening concurrently (such attempts result from | ||
1039 | * hotplug events handled via the ACPI hotplug workqueue). It also will | ||
1040 | * run after all of the work items submitted previosuly, which helps | ||
1041 | * those work items to ensure that they are not accessing stale device | ||
1042 | * objects. | ||
1043 | */ | ||
1044 | if (list_empty(&acpi_device_del_list)) | ||
1045 | acpi_queue_hotplug_work(&work); | ||
1046 | |||
1047 | list_add_tail(&adev->del_list, &acpi_device_del_list); | ||
1048 | /* Make acpi_ns_validate_handle() return NULL for this handle. */ | ||
1049 | adev->handle = INVALID_ACPI_HANDLE; | ||
1050 | |||
1051 | mutex_unlock(&acpi_device_del_lock); | ||
913 | } | 1052 | } |
914 | 1053 | ||
915 | int acpi_bus_get_device(acpi_handle handle, struct acpi_device **device) | 1054 | int acpi_bus_get_device(acpi_handle handle, struct acpi_device **device) |
@@ -919,7 +1058,7 @@ int acpi_bus_get_device(acpi_handle handle, struct acpi_device **device) | |||
919 | if (!device) | 1058 | if (!device) |
920 | return -EINVAL; | 1059 | return -EINVAL; |
921 | 1060 | ||
922 | status = acpi_get_data(handle, acpi_bus_data_handler, (void **)device); | 1061 | status = acpi_get_data(handle, acpi_scan_drop_device, (void **)device); |
923 | if (ACPI_FAILURE(status) || !*device) { | 1062 | if (ACPI_FAILURE(status) || !*device) { |
924 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No context for object [%p]\n", | 1063 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No context for object [%p]\n", |
925 | handle)); | 1064 | handle)); |
@@ -939,7 +1078,7 @@ int acpi_device_add(struct acpi_device *device, | |||
939 | if (device->handle) { | 1078 | if (device->handle) { |
940 | acpi_status status; | 1079 | acpi_status status; |
941 | 1080 | ||
942 | status = acpi_attach_data(device->handle, acpi_bus_data_handler, | 1081 | status = acpi_attach_data(device->handle, acpi_scan_drop_device, |
943 | device); | 1082 | device); |
944 | if (ACPI_FAILURE(status)) { | 1083 | if (ACPI_FAILURE(status)) { |
945 | acpi_handle_err(device->handle, | 1084 | acpi_handle_err(device->handle, |
@@ -957,6 +1096,7 @@ int acpi_device_add(struct acpi_device *device, | |||
957 | INIT_LIST_HEAD(&device->node); | 1096 | INIT_LIST_HEAD(&device->node); |
958 | INIT_LIST_HEAD(&device->wakeup_list); | 1097 | INIT_LIST_HEAD(&device->wakeup_list); |
959 | INIT_LIST_HEAD(&device->physical_node_list); | 1098 | INIT_LIST_HEAD(&device->physical_node_list); |
1099 | INIT_LIST_HEAD(&device->del_list); | ||
960 | mutex_init(&device->physical_node_lock); | 1100 | mutex_init(&device->physical_node_lock); |
961 | 1101 | ||
962 | new_bus_id = kzalloc(sizeof(struct acpi_device_bus_id), GFP_KERNEL); | 1102 | new_bus_id = kzalloc(sizeof(struct acpi_device_bus_id), GFP_KERNEL); |
@@ -1020,37 +1160,10 @@ int acpi_device_add(struct acpi_device *device, | |||
1020 | mutex_unlock(&acpi_device_lock); | 1160 | mutex_unlock(&acpi_device_lock); |
1021 | 1161 | ||
1022 | err_detach: | 1162 | err_detach: |
1023 | acpi_detach_data(device->handle, acpi_bus_data_handler); | 1163 | acpi_detach_data(device->handle, acpi_scan_drop_device); |
1024 | return result; | 1164 | return result; |
1025 | } | 1165 | } |
1026 | 1166 | ||
1027 | static void acpi_device_unregister(struct acpi_device *device) | ||
1028 | { | ||
1029 | mutex_lock(&acpi_device_lock); | ||
1030 | if (device->parent) | ||
1031 | list_del(&device->node); | ||
1032 | |||
1033 | list_del(&device->wakeup_list); | ||
1034 | mutex_unlock(&acpi_device_lock); | ||
1035 | |||
1036 | acpi_detach_data(device->handle, acpi_bus_data_handler); | ||
1037 | |||
1038 | acpi_power_add_remove_device(device, false); | ||
1039 | acpi_device_remove_files(device); | ||
1040 | if (device->remove) | ||
1041 | device->remove(device); | ||
1042 | |||
1043 | device_del(&device->dev); | ||
1044 | /* | ||
1045 | * Transition the device to D3cold to drop the reference counts of all | ||
1046 | * power resources the device depends on and turn off the ones that have | ||
1047 | * no more references. | ||
1048 | */ | ||
1049 | acpi_device_set_power(device, ACPI_STATE_D3_COLD); | ||
1050 | device->handle = NULL; | ||
1051 | put_device(&device->dev); | ||
1052 | } | ||
1053 | |||
1054 | /* -------------------------------------------------------------------------- | 1167 | /* -------------------------------------------------------------------------- |
1055 | Driver Management | 1168 | Driver Management |
1056 | -------------------------------------------------------------------------- */ | 1169 | -------------------------------------------------------------------------- */ |
@@ -1624,11 +1737,13 @@ void acpi_init_device_object(struct acpi_device *device, acpi_handle handle, | |||
1624 | device->device_type = type; | 1737 | device->device_type = type; |
1625 | device->handle = handle; | 1738 | device->handle = handle; |
1626 | device->parent = acpi_bus_get_parent(handle); | 1739 | device->parent = acpi_bus_get_parent(handle); |
1627 | STRUCT_TO_INT(device->status) = sta; | 1740 | acpi_set_device_status(device, sta); |
1628 | acpi_device_get_busid(device); | 1741 | acpi_device_get_busid(device); |
1629 | acpi_set_pnp_ids(handle, &device->pnp, type); | 1742 | acpi_set_pnp_ids(handle, &device->pnp, type); |
1630 | acpi_bus_get_flags(device); | 1743 | acpi_bus_get_flags(device); |
1631 | device->flags.match_driver = false; | 1744 | device->flags.match_driver = false; |
1745 | device->flags.initialized = true; | ||
1746 | device->flags.visited = false; | ||
1632 | device_initialize(&device->dev); | 1747 | device_initialize(&device->dev); |
1633 | dev_set_uevent_suppress(&device->dev, true); | 1748 | dev_set_uevent_suppress(&device->dev, true); |
1634 | } | 1749 | } |
@@ -1713,6 +1828,15 @@ static int acpi_bus_type_and_status(acpi_handle handle, int *type, | |||
1713 | return 0; | 1828 | return 0; |
1714 | } | 1829 | } |
1715 | 1830 | ||
1831 | bool acpi_device_is_present(struct acpi_device *adev) | ||
1832 | { | ||
1833 | if (adev->status.present || adev->status.functional) | ||
1834 | return true; | ||
1835 | |||
1836 | adev->flags.initialized = false; | ||
1837 | return false; | ||
1838 | } | ||
1839 | |||
1716 | static bool acpi_scan_handler_matching(struct acpi_scan_handler *handler, | 1840 | static bool acpi_scan_handler_matching(struct acpi_scan_handler *handler, |
1717 | char *idstr, | 1841 | char *idstr, |
1718 | const struct acpi_device_id **matchid) | 1842 | const struct acpi_device_id **matchid) |
@@ -1772,7 +1896,7 @@ static void acpi_scan_init_hotplug(acpi_handle handle, int type) | |||
1772 | */ | 1896 | */ |
1773 | list_for_each_entry(hwid, &pnp.ids, list) { | 1897 | list_for_each_entry(hwid, &pnp.ids, list) { |
1774 | handler = acpi_scan_match_handler(hwid->id, NULL); | 1898 | handler = acpi_scan_match_handler(hwid->id, NULL); |
1775 | if (handler && !handler->hotplug.ignore) { | 1899 | if (handler) { |
1776 | acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY, | 1900 | acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY, |
1777 | acpi_hotplug_notify_cb, handler); | 1901 | acpi_hotplug_notify_cb, handler); |
1778 | break; | 1902 | break; |
@@ -1806,18 +1930,6 @@ static acpi_status acpi_bus_check_add(acpi_handle handle, u32 lvl_not_used, | |||
1806 | 1930 | ||
1807 | acpi_scan_init_hotplug(handle, type); | 1931 | acpi_scan_init_hotplug(handle, type); |
1808 | 1932 | ||
1809 | if (!(sta & ACPI_STA_DEVICE_PRESENT) && | ||
1810 | !(sta & ACPI_STA_DEVICE_FUNCTIONING)) { | ||
1811 | struct acpi_device_wakeup wakeup; | ||
1812 | |||
1813 | if (acpi_has_method(handle, "_PRW")) { | ||
1814 | acpi_bus_extract_wakeup_device_power_package(handle, | ||
1815 | &wakeup); | ||
1816 | acpi_power_resources_list_free(&wakeup.resources); | ||
1817 | } | ||
1818 | return AE_CTRL_DEPTH; | ||
1819 | } | ||
1820 | |||
1821 | acpi_add_single_object(&device, handle, type, sta); | 1933 | acpi_add_single_object(&device, handle, type, sta); |
1822 | if (!device) | 1934 | if (!device) |
1823 | return AE_CTRL_DEPTH; | 1935 | return AE_CTRL_DEPTH; |
@@ -1852,36 +1964,40 @@ static int acpi_scan_attach_handler(struct acpi_device *device) | |||
1852 | return ret; | 1964 | return ret; |
1853 | } | 1965 | } |
1854 | 1966 | ||
1855 | static acpi_status acpi_bus_device_attach(acpi_handle handle, u32 lvl_not_used, | 1967 | static void acpi_bus_attach(struct acpi_device *device) |
1856 | void *not_used, void **ret_not_used) | ||
1857 | { | 1968 | { |
1858 | struct acpi_device *device; | 1969 | struct acpi_device *child; |
1859 | unsigned long long sta_not_used; | ||
1860 | int ret; | 1970 | int ret; |
1861 | 1971 | ||
1862 | /* | 1972 | acpi_bus_get_status(device); |
1863 | * Ignore errors ignored by acpi_bus_check_add() to avoid terminating | 1973 | /* Skip devices that are not present. */ |
1864 | * namespace walks prematurely. | 1974 | if (!acpi_device_is_present(device)) { |
1865 | */ | 1975 | device->flags.visited = false; |
1866 | if (acpi_bus_type_and_status(handle, &ret, &sta_not_used)) | 1976 | return; |
1867 | return AE_OK; | 1977 | } |
1868 | |||
1869 | if (acpi_bus_get_device(handle, &device)) | ||
1870 | return AE_CTRL_DEPTH; | ||
1871 | |||
1872 | if (device->handler) | 1978 | if (device->handler) |
1873 | return AE_OK; | 1979 | goto ok; |
1874 | 1980 | ||
1981 | if (!device->flags.initialized) { | ||
1982 | acpi_bus_update_power(device, NULL); | ||
1983 | device->flags.initialized = true; | ||
1984 | } | ||
1985 | device->flags.visited = false; | ||
1875 | ret = acpi_scan_attach_handler(device); | 1986 | ret = acpi_scan_attach_handler(device); |
1876 | if (ret < 0) | 1987 | if (ret < 0) |
1877 | return AE_CTRL_DEPTH; | 1988 | return; |
1878 | 1989 | ||
1879 | device->flags.match_driver = true; | 1990 | device->flags.match_driver = true; |
1880 | if (ret > 0) | 1991 | if (!ret) { |
1881 | return AE_OK; | 1992 | ret = device_attach(&device->dev); |
1993 | if (ret < 0) | ||
1994 | return; | ||
1995 | } | ||
1996 | device->flags.visited = true; | ||
1882 | 1997 | ||
1883 | ret = device_attach(&device->dev); | 1998 | ok: |
1884 | return ret >= 0 ? AE_OK : AE_CTRL_DEPTH; | 1999 | list_for_each_entry(child, &device->children, node) |
2000 | acpi_bus_attach(child); | ||
1885 | } | 2001 | } |
1886 | 2002 | ||
1887 | /** | 2003 | /** |
@@ -1901,75 +2017,48 @@ static acpi_status acpi_bus_device_attach(acpi_handle handle, u32 lvl_not_used, | |||
1901 | int acpi_bus_scan(acpi_handle handle) | 2017 | int acpi_bus_scan(acpi_handle handle) |
1902 | { | 2018 | { |
1903 | void *device = NULL; | 2019 | void *device = NULL; |
1904 | int error = 0; | ||
1905 | 2020 | ||
1906 | if (ACPI_SUCCESS(acpi_bus_check_add(handle, 0, NULL, &device))) | 2021 | if (ACPI_SUCCESS(acpi_bus_check_add(handle, 0, NULL, &device))) |
1907 | acpi_walk_namespace(ACPI_TYPE_ANY, handle, ACPI_UINT32_MAX, | 2022 | acpi_walk_namespace(ACPI_TYPE_ANY, handle, ACPI_UINT32_MAX, |
1908 | acpi_bus_check_add, NULL, NULL, &device); | 2023 | acpi_bus_check_add, NULL, NULL, &device); |
1909 | 2024 | ||
1910 | if (!device) | 2025 | if (device) { |
1911 | error = -ENODEV; | 2026 | acpi_bus_attach(device); |
1912 | else if (ACPI_SUCCESS(acpi_bus_device_attach(handle, 0, NULL, NULL))) | 2027 | return 0; |
1913 | acpi_walk_namespace(ACPI_TYPE_ANY, handle, ACPI_UINT32_MAX, | ||
1914 | acpi_bus_device_attach, NULL, NULL, NULL); | ||
1915 | |||
1916 | return error; | ||
1917 | } | ||
1918 | EXPORT_SYMBOL(acpi_bus_scan); | ||
1919 | |||
1920 | static acpi_status acpi_bus_device_detach(acpi_handle handle, u32 lvl_not_used, | ||
1921 | void *not_used, void **ret_not_used) | ||
1922 | { | ||
1923 | struct acpi_device *device = NULL; | ||
1924 | |||
1925 | if (!acpi_bus_get_device(handle, &device)) { | ||
1926 | struct acpi_scan_handler *dev_handler = device->handler; | ||
1927 | |||
1928 | if (dev_handler) { | ||
1929 | if (dev_handler->detach) | ||
1930 | dev_handler->detach(device); | ||
1931 | |||
1932 | device->handler = NULL; | ||
1933 | } else { | ||
1934 | device_release_driver(&device->dev); | ||
1935 | } | ||
1936 | } | 2028 | } |
1937 | return AE_OK; | 2029 | return -ENODEV; |
1938 | } | ||
1939 | |||
1940 | static acpi_status acpi_bus_remove(acpi_handle handle, u32 lvl_not_used, | ||
1941 | void *not_used, void **ret_not_used) | ||
1942 | { | ||
1943 | struct acpi_device *device = NULL; | ||
1944 | |||
1945 | if (!acpi_bus_get_device(handle, &device)) | ||
1946 | acpi_device_unregister(device); | ||
1947 | |||
1948 | return AE_OK; | ||
1949 | } | 2030 | } |
2031 | EXPORT_SYMBOL(acpi_bus_scan); | ||
1950 | 2032 | ||
1951 | /** | 2033 | /** |
1952 | * acpi_bus_trim - Remove ACPI device node and all of its descendants | 2034 | * acpi_bus_trim - Detach scan handlers and drivers from ACPI device objects. |
1953 | * @start: Root of the ACPI device nodes subtree to remove. | 2035 | * @adev: Root of the ACPI namespace scope to walk. |
1954 | * | 2036 | * |
1955 | * Must be called under acpi_scan_lock. | 2037 | * Must be called under acpi_scan_lock. |
1956 | */ | 2038 | */ |
1957 | void acpi_bus_trim(struct acpi_device *start) | 2039 | void acpi_bus_trim(struct acpi_device *adev) |
1958 | { | 2040 | { |
2041 | struct acpi_scan_handler *handler = adev->handler; | ||
2042 | struct acpi_device *child; | ||
2043 | |||
2044 | list_for_each_entry_reverse(child, &adev->children, node) | ||
2045 | acpi_bus_trim(child); | ||
2046 | |||
2047 | if (handler) { | ||
2048 | if (handler->detach) | ||
2049 | handler->detach(adev); | ||
2050 | |||
2051 | adev->handler = NULL; | ||
2052 | } else { | ||
2053 | device_release_driver(&adev->dev); | ||
2054 | } | ||
1959 | /* | 2055 | /* |
1960 | * Execute acpi_bus_device_detach() as a post-order callback to detach | 2056 | * Most likely, the device is going away, so put it into D3cold before |
1961 | * all ACPI drivers from the device nodes being removed. | 2057 | * that. |
1962 | */ | ||
1963 | acpi_walk_namespace(ACPI_TYPE_ANY, start->handle, ACPI_UINT32_MAX, NULL, | ||
1964 | acpi_bus_device_detach, NULL, NULL); | ||
1965 | acpi_bus_device_detach(start->handle, 0, NULL, NULL); | ||
1966 | /* | ||
1967 | * Execute acpi_bus_remove() as a post-order callback to remove device | ||
1968 | * nodes in the given namespace scope. | ||
1969 | */ | 2058 | */ |
1970 | acpi_walk_namespace(ACPI_TYPE_ANY, start->handle, ACPI_UINT32_MAX, NULL, | 2059 | acpi_device_set_power(adev, ACPI_STATE_D3_COLD); |
1971 | acpi_bus_remove, NULL, NULL); | 2060 | adev->flags.initialized = false; |
1972 | acpi_bus_remove(start->handle, 0, NULL, NULL); | 2061 | adev->flags.visited = false; |
1973 | } | 2062 | } |
1974 | EXPORT_SYMBOL_GPL(acpi_bus_trim); | 2063 | EXPORT_SYMBOL_GPL(acpi_bus_trim); |
1975 | 2064 | ||
@@ -2047,14 +2136,14 @@ int __init acpi_scan_init(void) | |||
2047 | 2136 | ||
2048 | result = acpi_bus_scan_fixed(); | 2137 | result = acpi_bus_scan_fixed(); |
2049 | if (result) { | 2138 | if (result) { |
2050 | acpi_device_unregister(acpi_root); | 2139 | acpi_detach_data(acpi_root->handle, acpi_scan_drop_device); |
2140 | acpi_device_del(acpi_root); | ||
2141 | put_device(&acpi_root->dev); | ||
2051 | goto out; | 2142 | goto out; |
2052 | } | 2143 | } |
2053 | 2144 | ||
2054 | acpi_update_all_gpes(); | 2145 | acpi_update_all_gpes(); |
2055 | 2146 | ||
2056 | acpi_pci_root_hp_init(); | ||
2057 | |||
2058 | out: | 2147 | out: |
2059 | mutex_unlock(&acpi_scan_lock); | 2148 | mutex_unlock(&acpi_scan_lock); |
2060 | return result; | 2149 | return result; |
diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c index 721e949e606e..b718806657cd 100644 --- a/drivers/acpi/sleep.c +++ b/drivers/acpi/sleep.c | |||
@@ -18,12 +18,8 @@ | |||
18 | #include <linux/reboot.h> | 18 | #include <linux/reboot.h> |
19 | #include <linux/acpi.h> | 19 | #include <linux/acpi.h> |
20 | #include <linux/module.h> | 20 | #include <linux/module.h> |
21 | |||
22 | #include <asm/io.h> | 21 | #include <asm/io.h> |
23 | 22 | ||
24 | #include <acpi/acpi_bus.h> | ||
25 | #include <acpi/acpi_drivers.h> | ||
26 | |||
27 | #include "internal.h" | 23 | #include "internal.h" |
28 | #include "sleep.h" | 24 | #include "sleep.h" |
29 | 25 | ||
@@ -670,11 +666,8 @@ static void acpi_hibernation_leave(void) | |||
670 | /* Reprogram control registers */ | 666 | /* Reprogram control registers */ |
671 | acpi_leave_sleep_state_prep(ACPI_STATE_S4); | 667 | acpi_leave_sleep_state_prep(ACPI_STATE_S4); |
672 | /* Check the hardware signature */ | 668 | /* Check the hardware signature */ |
673 | if (facs && s4_hardware_signature != facs->hardware_signature) { | 669 | if (facs && s4_hardware_signature != facs->hardware_signature) |
674 | printk(KERN_EMERG "ACPI: Hardware changed while hibernated, " | 670 | pr_crit("ACPI: Hardware changed while hibernated, success doubtful!\n"); |
675 | "cannot resume!\n"); | ||
676 | panic("ACPI S4 hardware signature mismatch"); | ||
677 | } | ||
678 | /* Restore the NVS memory area */ | 671 | /* Restore the NVS memory area */ |
679 | suspend_nvs_restore(); | 672 | suspend_nvs_restore(); |
680 | /* Allow EC transactions to happen. */ | 673 | /* Allow EC transactions to happen. */ |
@@ -806,9 +799,6 @@ int __init acpi_sleep_init(void) | |||
806 | char *pos = supported; | 799 | char *pos = supported; |
807 | int i; | 800 | int i; |
808 | 801 | ||
809 | if (acpi_disabled) | ||
810 | return 0; | ||
811 | |||
812 | acpi_sleep_dmi_check(); | 802 | acpi_sleep_dmi_check(); |
813 | 803 | ||
814 | sleep_states[ACPI_STATE_S0] = 1; | 804 | sleep_states[ACPI_STATE_S0] = 1; |
diff --git a/drivers/acpi/sysfs.c b/drivers/acpi/sysfs.c index 6dbc3ca45223..443dc9366052 100644 --- a/drivers/acpi/sysfs.c +++ b/drivers/acpi/sysfs.c | |||
@@ -5,7 +5,7 @@ | |||
5 | #include <linux/init.h> | 5 | #include <linux/init.h> |
6 | #include <linux/kernel.h> | 6 | #include <linux/kernel.h> |
7 | #include <linux/moduleparam.h> | 7 | #include <linux/moduleparam.h> |
8 | #include <acpi/acpi_drivers.h> | 8 | #include <linux/acpi.h> |
9 | 9 | ||
10 | #include "internal.h" | 10 | #include "internal.h" |
11 | 11 | ||
diff --git a/drivers/acpi/tables.c b/drivers/acpi/tables.c index d67a1fe07f0e..5837f857ac2e 100644 --- a/drivers/acpi/tables.c +++ b/drivers/acpi/tables.c | |||
@@ -278,12 +278,13 @@ acpi_table_parse_madt(enum acpi_madt_type id, | |||
278 | 278 | ||
279 | /** | 279 | /** |
280 | * acpi_table_parse - find table with @id, run @handler on it | 280 | * acpi_table_parse - find table with @id, run @handler on it |
281 | * | ||
282 | * @id: table id to find | 281 | * @id: table id to find |
283 | * @handler: handler to run | 282 | * @handler: handler to run |
284 | * | 283 | * |
285 | * Scan the ACPI System Descriptor Table (STD) for a table matching @id, | 284 | * Scan the ACPI System Descriptor Table (STD) for a table matching @id, |
286 | * run @handler on it. Return 0 if table found, return on if not. | 285 | * run @handler on it. |
286 | * | ||
287 | * Return 0 if table found, -errno if not. | ||
287 | */ | 288 | */ |
288 | int __init acpi_table_parse(char *id, acpi_tbl_table_handler handler) | 289 | int __init acpi_table_parse(char *id, acpi_tbl_table_handler handler) |
289 | { | 290 | { |
@@ -293,7 +294,7 @@ int __init acpi_table_parse(char *id, acpi_tbl_table_handler handler) | |||
293 | if (acpi_disabled) | 294 | if (acpi_disabled) |
294 | return -ENODEV; | 295 | return -ENODEV; |
295 | 296 | ||
296 | if (!handler) | 297 | if (!id || !handler) |
297 | return -EINVAL; | 298 | return -EINVAL; |
298 | 299 | ||
299 | if (strncmp(id, ACPI_SIG_MADT, 4) == 0) | 300 | if (strncmp(id, ACPI_SIG_MADT, 4) == 0) |
@@ -306,7 +307,7 @@ int __init acpi_table_parse(char *id, acpi_tbl_table_handler handler) | |||
306 | early_acpi_os_unmap_memory(table, tbl_size); | 307 | early_acpi_os_unmap_memory(table, tbl_size); |
307 | return 0; | 308 | return 0; |
308 | } else | 309 | } else |
309 | return 1; | 310 | return -ENODEV; |
310 | } | 311 | } |
311 | 312 | ||
312 | /* | 313 | /* |
@@ -351,7 +352,7 @@ int __init acpi_table_init(void) | |||
351 | 352 | ||
352 | status = acpi_initialize_tables(initial_tables, ACPI_MAX_TABLES, 0); | 353 | status = acpi_initialize_tables(initial_tables, ACPI_MAX_TABLES, 0); |
353 | if (ACPI_FAILURE(status)) | 354 | if (ACPI_FAILURE(status)) |
354 | return 1; | 355 | return -EINVAL; |
355 | 356 | ||
356 | check_multiple_madt(); | 357 | check_multiple_madt(); |
357 | return 0; | 358 | return 0; |
diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c index 0d9f46b5ae6d..8349a555b92b 100644 --- a/drivers/acpi/thermal.c +++ b/drivers/acpi/thermal.c | |||
@@ -41,10 +41,9 @@ | |||
41 | #include <linux/kmod.h> | 41 | #include <linux/kmod.h> |
42 | #include <linux/reboot.h> | 42 | #include <linux/reboot.h> |
43 | #include <linux/device.h> | 43 | #include <linux/device.h> |
44 | #include <asm/uaccess.h> | ||
45 | #include <linux/thermal.h> | 44 | #include <linux/thermal.h> |
46 | #include <acpi/acpi_bus.h> | 45 | #include <linux/acpi.h> |
47 | #include <acpi/acpi_drivers.h> | 46 | #include <asm/uaccess.h> |
48 | 47 | ||
49 | #define PREFIX "ACPI: " | 48 | #define PREFIX "ACPI: " |
50 | 49 | ||
@@ -862,7 +861,7 @@ acpi_thermal_unbind_cooling_device(struct thermal_zone_device *thermal, | |||
862 | return acpi_thermal_cooling_device_cb(thermal, cdev, false); | 861 | return acpi_thermal_cooling_device_cb(thermal, cdev, false); |
863 | } | 862 | } |
864 | 863 | ||
865 | static const struct thermal_zone_device_ops acpi_thermal_zone_ops = { | 864 | static struct thermal_zone_device_ops acpi_thermal_zone_ops = { |
866 | .bind = acpi_thermal_bind_cooling_device, | 865 | .bind = acpi_thermal_bind_cooling_device, |
867 | .unbind = acpi_thermal_unbind_cooling_device, | 866 | .unbind = acpi_thermal_unbind_cooling_device, |
868 | .get_temp = thermal_get_temp, | 867 | .get_temp = thermal_get_temp, |
diff --git a/drivers/acpi/utils.c b/drivers/acpi/utils.c index 6d408bfbbb1d..0347a37eb438 100644 --- a/drivers/acpi/utils.c +++ b/drivers/acpi/utils.c | |||
@@ -30,8 +30,6 @@ | |||
30 | #include <linux/types.h> | 30 | #include <linux/types.h> |
31 | #include <linux/hardirq.h> | 31 | #include <linux/hardirq.h> |
32 | #include <linux/acpi.h> | 32 | #include <linux/acpi.h> |
33 | #include <acpi/acpi_bus.h> | ||
34 | #include <acpi/acpi_drivers.h> | ||
35 | 33 | ||
36 | #include "internal.h" | 34 | #include "internal.h" |
37 | 35 | ||
@@ -574,3 +572,100 @@ acpi_status acpi_evaluate_lck(acpi_handle handle, int lock) | |||
574 | 572 | ||
575 | return status; | 573 | return status; |
576 | } | 574 | } |
575 | |||
576 | /** | ||
577 | * acpi_evaluate_dsm - evaluate device's _DSM method | ||
578 | * @handle: ACPI device handle | ||
579 | * @uuid: UUID of requested functions, should be 16 bytes | ||
580 | * @rev: revision number of requested function | ||
581 | * @func: requested function number | ||
582 | * @argv4: the function specific parameter | ||
583 | * | ||
584 | * Evaluate device's _DSM method with specified UUID, revision id and | ||
585 | * function number. Caller needs to free the returned object. | ||
586 | * | ||
587 | * Though ACPI defines the fourth parameter for _DSM should be a package, | ||
588 | * some old BIOSes do expect a buffer or an integer etc. | ||
589 | */ | ||
590 | union acpi_object * | ||
591 | acpi_evaluate_dsm(acpi_handle handle, const u8 *uuid, int rev, int func, | ||
592 | union acpi_object *argv4) | ||
593 | { | ||
594 | acpi_status ret; | ||
595 | struct acpi_buffer buf = {ACPI_ALLOCATE_BUFFER, NULL}; | ||
596 | union acpi_object params[4]; | ||
597 | struct acpi_object_list input = { | ||
598 | .count = 4, | ||
599 | .pointer = params, | ||
600 | }; | ||
601 | |||
602 | params[0].type = ACPI_TYPE_BUFFER; | ||
603 | params[0].buffer.length = 16; | ||
604 | params[0].buffer.pointer = (char *)uuid; | ||
605 | params[1].type = ACPI_TYPE_INTEGER; | ||
606 | params[1].integer.value = rev; | ||
607 | params[2].type = ACPI_TYPE_INTEGER; | ||
608 | params[2].integer.value = func; | ||
609 | if (argv4) { | ||
610 | params[3] = *argv4; | ||
611 | } else { | ||
612 | params[3].type = ACPI_TYPE_PACKAGE; | ||
613 | params[3].package.count = 0; | ||
614 | params[3].package.elements = NULL; | ||
615 | } | ||
616 | |||
617 | ret = acpi_evaluate_object(handle, "_DSM", &input, &buf); | ||
618 | if (ACPI_SUCCESS(ret)) | ||
619 | return (union acpi_object *)buf.pointer; | ||
620 | |||
621 | if (ret != AE_NOT_FOUND) | ||
622 | acpi_handle_warn(handle, | ||
623 | "failed to evaluate _DSM (0x%x)\n", ret); | ||
624 | |||
625 | return NULL; | ||
626 | } | ||
627 | EXPORT_SYMBOL(acpi_evaluate_dsm); | ||
628 | |||
629 | /** | ||
630 | * acpi_check_dsm - check if _DSM method supports requested functions. | ||
631 | * @handle: ACPI device handle | ||
632 | * @uuid: UUID of requested functions, should be 16 bytes at least | ||
633 | * @rev: revision number of requested functions | ||
634 | * @funcs: bitmap of requested functions | ||
635 | * @exclude: excluding special value, used to support i915 and nouveau | ||
636 | * | ||
637 | * Evaluate device's _DSM method to check whether it supports requested | ||
638 | * functions. Currently only support 64 functions at maximum, should be | ||
639 | * enough for now. | ||
640 | */ | ||
641 | bool acpi_check_dsm(acpi_handle handle, const u8 *uuid, int rev, u64 funcs) | ||
642 | { | ||
643 | int i; | ||
644 | u64 mask = 0; | ||
645 | union acpi_object *obj; | ||
646 | |||
647 | if (funcs == 0) | ||
648 | return false; | ||
649 | |||
650 | obj = acpi_evaluate_dsm(handle, uuid, rev, 0, NULL); | ||
651 | if (!obj) | ||
652 | return false; | ||
653 | |||
654 | /* For compatibility, old BIOSes may return an integer */ | ||
655 | if (obj->type == ACPI_TYPE_INTEGER) | ||
656 | mask = obj->integer.value; | ||
657 | else if (obj->type == ACPI_TYPE_BUFFER) | ||
658 | for (i = 0; i < obj->buffer.length && i < 8; i++) | ||
659 | mask |= (((u8)obj->buffer.pointer[i]) << (i * 8)); | ||
660 | ACPI_FREE(obj); | ||
661 | |||
662 | /* | ||
663 | * Bit 0 indicates whether there's support for any functions other than | ||
664 | * function 0 for the specified UUID and revision. | ||
665 | */ | ||
666 | if ((mask & 0x1) && (mask & funcs) == funcs) | ||
667 | return true; | ||
668 | |||
669 | return false; | ||
670 | } | ||
671 | EXPORT_SYMBOL(acpi_check_dsm); | ||
diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c index 995e91bcb97b..b727d105046d 100644 --- a/drivers/acpi/video.c +++ b/drivers/acpi/video.c | |||
@@ -37,12 +37,11 @@ | |||
37 | #include <linux/pci.h> | 37 | #include <linux/pci.h> |
38 | #include <linux/pci_ids.h> | 38 | #include <linux/pci_ids.h> |
39 | #include <linux/slab.h> | 39 | #include <linux/slab.h> |
40 | #include <asm/uaccess.h> | ||
41 | #include <linux/dmi.h> | 40 | #include <linux/dmi.h> |
42 | #include <acpi/acpi_bus.h> | ||
43 | #include <acpi/acpi_drivers.h> | ||
44 | #include <linux/suspend.h> | 41 | #include <linux/suspend.h> |
42 | #include <linux/acpi.h> | ||
45 | #include <acpi/video.h> | 43 | #include <acpi/video.h> |
44 | #include <asm/uaccess.h> | ||
46 | 45 | ||
47 | #include "internal.h" | 46 | #include "internal.h" |
48 | 47 | ||
diff --git a/drivers/acpi/video_detect.c b/drivers/acpi/video_detect.c index 84875fd4c74f..f0447d3daf2c 100644 --- a/drivers/acpi/video_detect.c +++ b/drivers/acpi/video_detect.c | |||
@@ -50,7 +50,7 @@ static bool acpi_video_caps_checked; | |||
50 | 50 | ||
51 | static acpi_status | 51 | static acpi_status |
52 | acpi_backlight_cap_match(acpi_handle handle, u32 level, void *context, | 52 | acpi_backlight_cap_match(acpi_handle handle, u32 level, void *context, |
53 | void **retyurn_value) | 53 | void **return_value) |
54 | { | 54 | { |
55 | long *cap = context; | 55 | long *cap = context; |
56 | 56 | ||
diff --git a/drivers/acpi/wakeup.c b/drivers/acpi/wakeup.c index 7bfbe40bc43b..1638401ab282 100644 --- a/drivers/acpi/wakeup.c +++ b/drivers/acpi/wakeup.c | |||
@@ -5,7 +5,6 @@ | |||
5 | 5 | ||
6 | #include <linux/init.h> | 6 | #include <linux/init.h> |
7 | #include <linux/acpi.h> | 7 | #include <linux/acpi.h> |
8 | #include <acpi/acpi_drivers.h> | ||
9 | #include <linux/kernel.h> | 8 | #include <linux/kernel.h> |
10 | #include <linux/types.h> | 9 | #include <linux/types.h> |
11 | 10 | ||