aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2014-01-24 18:51:02 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2014-01-24 18:51:02 -0500
commit09da8dfa98682d871987145ed11e3232accac860 (patch)
tree152a9bb1e52f70db6efb66fffbdc4871f749d7df /drivers/acpi
parent3aacd625f20129f5a41ea3ff3b5353b0e4dabd01 (diff)
parent7744064731a9543105e207504e0262f883bc14c0 (diff)
Merge tag 'pm+acpi-3.14-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm
Pull ACPI and power management updates from Rafael Wysocki: "As far as the number of commits goes, the top spot belongs to ACPI this time with cpufreq in the second position and a handful of PM core, PNP and cpuidle updates. They are fixes and cleanups mostly, as usual, with a couple of new features in the mix. The most visible change is probably that we will create struct acpi_device objects (visible in sysfs) for all devices represented in the ACPI tables regardless of their status and there will be a new sysfs attribute under those objects allowing user space to check that status via _STA. Consequently, ACPI device eject or generally hot-removal will not delete those objects, unless the table containing the corresponding namespace nodes is unloaded, which is extremely rare. Also ACPI container hotplug will be handled quite a bit differently and cpufreq will support CPU boost ("turbo") generically and not only in the acpi-cpufreq driver. Specifics: - ACPI core changes to make it create a struct acpi_device object for every device represented in the ACPI tables during all namespace scans regardless of the current status of that device. In accordance with this, ACPI hotplug operations will not delete those objects, unless the underlying ACPI tables go away. - On top of the above, new sysfs attribute for ACPI device objects allowing user space to check device status by triggering the execution of _STA for its ACPI object. From Srinivas Pandruvada. - ACPI core hotplug changes reducing code duplication, integrating the PCI root hotplug with the core and reworking container hotplug. - ACPI core simplifications making it use ACPI_COMPANION() in the code "glueing" ACPI device objects to "physical" devices. - ACPICA update to upstream version 20131218. This adds support for the DBG2 and PCCT tables to ACPICA, fixes some bugs and improves debug facilities. From Bob Moore, Lv Zheng and Betty Dall. - Init code change to carry out the early ACPI initialization earlier. That should allow us to use ACPI during the timekeeping initialization and possibly to simplify the EFI initialization too. From Chun-Yi Lee. - Clenups of the inclusions of ACPI headers in many places all over from Lv Zheng and Rashika Kheria (work in progress). - New helper for ACPI _DSM execution and rework of the code in drivers that uses _DSM to execute it via the new helper. From Jiang Liu. - New Win8 OSI blacklist entries from Takashi Iwai. - Assorted ACPI fixes and cleanups from Al Stone, Emil Goode, Hanjun Guo, Lan Tianyu, Masanari Iida, Oliver Neukum, Prarit Bhargava, Rashika Kheria, Tang Chen, Zhang Rui. - intel_pstate driver updates, including proper Baytrail support, from Dirk Brandewie and intel_pstate documentation from Ramkumar Ramachandra. - Generic CPU boost ("turbo") support for cpufreq from Lukasz Majewski. - powernow-k6 cpufreq driver fixes from Mikulas Patocka. - cpufreq core fixes and cleanups from Viresh Kumar, Jane Li, Mark Brown. - Assorted cpufreq drivers fixes and cleanups from Anson Huang, John Tobias, Paul Bolle, Paul Walmsley, Sachin Kamat, Shawn Guo, Viresh Kumar. - cpuidle cleanups from Bartlomiej Zolnierkiewicz. - Support for hibernation APM events from Bin Shi. - Hibernation fix to avoid bringing up nonboot CPUs with ACPI EC disabled during thaw transitions from Bjørn Mork. - PM core fixes and cleanups from Ben Dooks, Leonardo Potenza, Ulf Hansson. - PNP subsystem fixes and cleanups from Dmitry Torokhov, Levente Kurusa, Rashika Kheria. - New tool for profiling system suspend from Todd E Brandt and a cpupower tool cleanup from One Thousand Gnomes" * tag 'pm+acpi-3.14-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: (153 commits) thermal: exynos: boost: Automatic enable/disable of BOOST feature (at Exynos4412) cpufreq: exynos4x12: Change L0 driver data to CPUFREQ_BOOST_FREQ Documentation: cpufreq / boost: Update BOOST documentation cpufreq: exynos: Extend Exynos cpufreq driver to support boost cpufreq / boost: Kconfig: Support for software-managed BOOST acpi-cpufreq: Adjust the code to use the common boost attribute cpufreq: Add boost frequency support in core intel_pstate: Add trace point to report internal state. cpufreq: introduce cpufreq_generic_get() routine ARM: SA1100: Create dummy clk_get_rate() to avoid build failures cpufreq: stats: create sysfs entries when cpufreq_stats is a module cpufreq: stats: free table and remove sysfs entry in a single routine cpufreq: stats: remove hotplug notifiers cpufreq: stats: handle cpufreq_unregister_driver() and suspend/resume properly cpufreq: speedstep: remove unused speedstep_get_state platform: introduce OF style 'modalias' support for platform bus PM / tools: new tool for suspend/resume performance optimization ACPI: fix module autoloading for ACPI enumerated devices ACPI: add module autoloading support for ACPI enumerated devices ACPI: fix create_modalias() return value handling ...
Diffstat (limited to 'drivers/acpi')
-rw-r--r--drivers/acpi/ac.c3
-rw-r--r--drivers/acpi/acpi_extlog.c62
-rw-r--r--drivers/acpi/acpi_memhotplug.c27
-rw-r--r--drivers/acpi/acpi_pad.c3
-rw-r--r--drivers/acpi/acpi_processor.c26
-rw-r--r--drivers/acpi/acpica/acdebug.h1
-rw-r--r--drivers/acpi/acpica/acevents.h9
-rw-r--r--drivers/acpi/acpica/acglobal.h30
-rw-r--r--drivers/acpi/acpica/aclocal.h9
-rw-r--r--drivers/acpi/acpica/dsfield.c2
-rw-r--r--drivers/acpi/acpica/dsutils.c19
-rw-r--r--drivers/acpi/acpica/dswload.c4
-rw-r--r--drivers/acpi/acpica/evgpeblk.c8
-rw-r--r--drivers/acpi/acpica/evgpeutil.c24
-rw-r--r--drivers/acpi/acpica/exresnte.c3
-rw-r--r--drivers/acpi/acpica/nsxfeval.c23
-rw-r--r--drivers/acpi/acpica/psopinfo.c51
-rw-r--r--drivers/acpi/acpica/tbfadt.c335
-rw-r--r--drivers/acpi/acpica/tbutils.c214
-rw-r--r--drivers/acpi/acpica/utaddress.c19
-rw-r--r--drivers/acpi/acpica/utalloc.c10
-rw-r--r--drivers/acpi/acpica/utcache.c12
-rw-r--r--drivers/acpi/acpica/utdebug.c4
-rw-r--r--drivers/acpi/acpica/utglobal.c4
-rw-r--r--drivers/acpi/acpica/utxfinit.c12
-rw-r--r--drivers/acpi/apei/apei-base.c1
-rw-r--r--drivers/acpi/apei/apei-internal.h1
-rw-r--r--drivers/acpi/apei/einj.c1
-rw-r--r--drivers/acpi/apei/ghes.c1
-rw-r--r--drivers/acpi/battery.c3
-rw-r--r--drivers/acpi/blacklist.c51
-rw-r--r--drivers/acpi/bus.c77
-rw-r--r--drivers/acpi/button.c21
-rw-r--r--drivers/acpi/container.c55
-rw-r--r--drivers/acpi/custom_method.c2
-rw-r--r--drivers/acpi/debugfs.c2
-rw-r--r--drivers/acpi/device_pm.c22
-rw-r--r--drivers/acpi/dock.c16
-rw-r--r--drivers/acpi/ec.c32
-rw-r--r--drivers/acpi/ec_sys.c2
-rw-r--r--drivers/acpi/event.c2
-rw-r--r--drivers/acpi/fan.c3
-rw-r--r--drivers/acpi/glue.c165
-rw-r--r--drivers/acpi/hed.c2
-rw-r--r--drivers/acpi/internal.h19
-rw-r--r--drivers/acpi/numa.c1
-rw-r--r--drivers/acpi/nvs.c3
-rw-r--r--drivers/acpi/osl.c14
-rw-r--r--drivers/acpi/pci_irq.c2
-rw-r--r--drivers/acpi/pci_link.c4
-rw-r--r--drivers/acpi/pci_root.c126
-rw-r--r--drivers/acpi/pci_slot.c1
-rw-r--r--drivers/acpi/power.c3
-rw-r--r--drivers/acpi/proc.c5
-rw-r--r--drivers/acpi/processor_core.c3
-rw-r--r--drivers/acpi/processor_driver.c8
-rw-r--r--drivers/acpi/processor_idle.c37
-rw-r--r--drivers/acpi/processor_perflib.c7
-rw-r--r--drivers/acpi/processor_thermal.c11
-rw-r--r--drivers/acpi/processor_throttling.c7
-rw-r--r--drivers/acpi/sbshc.c3
-rw-r--r--drivers/acpi/scan.c620
-rw-r--r--drivers/acpi/sleep.c14
-rw-r--r--drivers/acpi/sysfs.c2
-rw-r--r--drivers/acpi/tables.c11
-rw-r--r--drivers/acpi/thermal.c7
-rw-r--r--drivers/acpi/utils.c99
-rw-r--r--drivers/acpi/video.c5
-rw-r--r--drivers/acpi/video_detect.c2
-rw-r--r--drivers/acpi/wakeup.c1
70 files changed, 1295 insertions, 1093 deletions
diff --git a/drivers/acpi/ac.c b/drivers/acpi/ac.c
index 3c2e4aa529c4..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
diff --git a/drivers/acpi/acpi_extlog.c b/drivers/acpi/acpi_extlog.c
index 5d33c5415405..c4a5d87ede7e 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 <linux/edac.h> 14#include <linux/edac.h>
@@ -21,11 +20,9 @@
21#define EXT_ELOG_ENTRY_MASK GENMASK_ULL(51, 0) /* elog entry address mask */ 20#define EXT_ELOG_ENTRY_MASK GENMASK_ULL(51, 0) /* elog entry address mask */
22 21
23#define EXTLOG_DSM_REV 0x0 22#define EXTLOG_DSM_REV 0x0
24#define EXTLOG_FN_QUERY 0x0
25#define EXTLOG_FN_ADDR 0x1 23#define EXTLOG_FN_ADDR 0x1
26 24
27#define FLAG_OS_OPTIN BIT(0) 25#define FLAG_OS_OPTIN BIT(0)
28#define EXTLOG_QUERY_L1_EXIST BIT(1)
29#define ELOG_ENTRY_VALID (1ULL<<63) 26#define ELOG_ENTRY_VALID (1ULL<<63)
30#define ELOG_ENTRY_LEN 0x1000 27#define ELOG_ENTRY_LEN 0x1000
31 28
@@ -46,7 +43,7 @@ struct extlog_l1_head {
46 43
47static int old_edac_report_status; 44static int old_edac_report_status;
48 45
49static u8 extlog_dsm_uuid[] = "663E35AF-CC10-41A4-88EA-5470AF055295"; 46static u8 extlog_dsm_uuid[] __initdata = "663E35AF-CC10-41A4-88EA-5470AF055295";
50 47
51/* L1 table related physical address */ 48/* L1 table related physical address */
52static u64 elog_base; 49static u64 elog_base;
@@ -156,62 +153,27 @@ static int extlog_print(struct notifier_block *nb, unsigned long val,
156 return NOTIFY_STOP; 153 return NOTIFY_STOP;
157} 154}
158 155
159static int extlog_get_dsm(acpi_handle handle, int rev, int func, u64 *ret) 156static bool __init extlog_get_l1addr(void)
160{ 157{
161 struct acpi_buffer buf = {ACPI_ALLOCATE_BUFFER, NULL};
162 struct acpi_object_list input;
163 union acpi_object params[4], *obj;
164 u8 uuid[16]; 158 u8 uuid[16];
165 int i; 159 acpi_handle handle;
160 union acpi_object *obj;
166 161
167 acpi_str_to_uuid(extlog_dsm_uuid, uuid); 162 acpi_str_to_uuid(extlog_dsm_uuid, uuid);
168 input.count = 4;
169 input.pointer = params;
170 params[0].type = ACPI_TYPE_BUFFER;
171 params[0].buffer.length = 16;
172 params[0].buffer.pointer = uuid;
173 params[1].type = ACPI_TYPE_INTEGER;
174 params[1].integer.value = rev;
175 params[2].type = ACPI_TYPE_INTEGER;
176 params[2].integer.value = func;
177 params[3].type = ACPI_TYPE_PACKAGE;
178 params[3].package.count = 0;
179 params[3].package.elements = NULL;
180
181 if (ACPI_FAILURE(acpi_evaluate_object(handle, "_DSM", &input, &buf)))
182 return -1;
183
184 *ret = 0;
185 obj = (union acpi_object *)buf.pointer;
186 if (obj->type == ACPI_TYPE_INTEGER) {
187 *ret = obj->integer.value;
188 } else if (obj->type == ACPI_TYPE_BUFFER) {
189 if (obj->buffer.length <= 8) {
190 for (i = 0; i < obj->buffer.length; i++)
191 *ret |= (obj->buffer.pointer[i] << (i * 8));
192 }
193 }
194 kfree(buf.pointer);
195
196 return 0;
197}
198
199static bool extlog_get_l1addr(void)
200{
201 acpi_handle handle;
202 u64 ret;
203 163
204 if (ACPI_FAILURE(acpi_get_handle(NULL, "\\_SB", &handle))) 164 if (ACPI_FAILURE(acpi_get_handle(NULL, "\\_SB", &handle)))
205 return false; 165 return false;
206 166 if (!acpi_check_dsm(handle, uuid, EXTLOG_DSM_REV, 1 << EXTLOG_FN_ADDR))
207 if (extlog_get_dsm(handle, EXTLOG_DSM_REV, EXTLOG_FN_QUERY, &ret) ||
208 !(ret & EXTLOG_QUERY_L1_EXIST))
209 return false; 167 return false;
210 168 obj = acpi_evaluate_dsm_typed(handle, uuid, EXTLOG_DSM_REV,
211 if (extlog_get_dsm(handle, EXTLOG_DSM_REV, EXTLOG_FN_ADDR, &ret)) 169 EXTLOG_FN_ADDR, NULL, ACPI_TYPE_INTEGER);
170 if (!obj) {
212 return false; 171 return false;
172 } else {
173 l1_dirbase = obj->integer.value;
174 ACPI_FREE(obj);
175 }
213 176
214 l1_dirbase = ret;
215 /* Spec says L1 directory must be 4K aligned, bail out if it isn't */ 177 /* Spec says L1 directory must be 4K aligned, bail out if it isn't */
216 if (l1_dirbase & ((1 << 12) - 1)) { 178 if (l1_dirbase & ((1 << 12) - 1)) {
217 pr_warn(FW_BUG "L1 Directory is invalid at physical %llx\n", 179 pr_warn(FW_BUG "L1 Directory is invalid at physical %llx\n",
diff --git a/drivers/acpi/acpi_memhotplug.c b/drivers/acpi/acpi_memhotplug.c
index 551dad712ffe..b67be85ff0fc 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
181static int acpi_bind_memblk(struct memory_block *mem, void *arg) 181static 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
186static int acpi_bind_memory_blocks(struct acpi_memory_info *info, 186static 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
200static void acpi_unbind_memory_blocks(struct acpi_memory_info *info, 200static 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);
@@ -361,7 +360,19 @@ static void acpi_memory_device_remove(struct acpi_device *device)
361 acpi_memory_device_free(mem_device); 360 acpi_memory_device_free(mem_device);
362} 361}
363 362
363static bool __initdata acpi_no_memhotplug;
364
364void __init acpi_memory_hotplug_init(void) 365void __init acpi_memory_hotplug_init(void)
365{ 366{
367 if (acpi_no_memhotplug)
368 return;
369
366 acpi_scan_add_handler_with_hotplug(&memory_device_handler, "memory"); 370 acpi_scan_add_handler_with_hotplug(&memory_device_handler, "memory");
367} 371}
372
373static int __init disable_acpi_memory_hotplug(char *str)
374{
375 acpi_no_memhotplug = true;
376 return 1;
377}
378__setup("acpi_no_memhotplug", disable_acpi_memory_hotplug);
diff --git a/drivers/acpi/acpi_pad.c b/drivers/acpi/acpi_pad.c
index 509452a62f96..df96a0fe4890 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);
113ACPI_HW_DEPENDENT_RETURN_VOID(void 113ACPI_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
117ACPI_HW_DEPENDENT_RETURN_VOID(void acpi_db_generate_sci(void)) 116ACPI_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
72ACPI_HW_DEPENDENT_RETURN_OK(acpi_status 72ACPI_HW_DEPENDENT_RETURN_OK(acpi_status
73 acpi_ev_acquire_global_lock(u16 timeout)) 73 acpi_ev_acquire_global_lock(u16 timeout))
74
75ACPI_HW_DEPENDENT_RETURN_OK(acpi_status acpi_ev_release_global_lock(void)) 74ACPI_HW_DEPENDENT_RETURN_OK(acpi_status acpi_ev_release_global_lock(void))
76 acpi_status acpi_ev_remove_global_lock_handler(void); 75acpi_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);
133ACPI_HW_DEPENDENT_RETURN_VOID(void 132ACPI_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 135acpi_status
137acpi_ev_match_gpe_method(acpi_handle obj_handle, 136acpi_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
149acpi_ev_get_gpe_device(struct acpi_gpe_xrupt_info *gpe_xrupt_info, 148acpi_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
152struct acpi_gpe_xrupt_info *acpi_ev_get_gpe_xrupt_block(u32 interrupt_number); 151acpi_status
152acpi_ev_get_gpe_xrupt_block(u32 interrupt_number,
153 struct acpi_gpe_xrupt_info **gpe_xrupt_block);
153 154
154acpi_status acpi_ev_delete_gpe_xrupt(struct acpi_gpe_xrupt_info *gpe_xrupt); 155acpi_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);
119u8 ACPI_INIT_GLOBAL(acpi_gbl_copy_dsdt_locally, FALSE); 119u8 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 */
127u8 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 */
137u8 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
511ACPI_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
1051struct acpi_external_file { 1052struct 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
114unlock_and_exit: 114unlock_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
210struct acpi_gpe_xrupt_info *acpi_ev_get_gpe_xrupt_block(u32 interrupt_number) 211acpi_status
212acpi_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
72const struct acpi_opcode_info *acpi_ps_get_opcode_info(u16 opcode) 72const 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
57static void acpi_tb_convert_fadt(void); 57static void acpi_tb_convert_fadt(void);
58 58
59static void acpi_tb_validate_fadt(void);
60
61static void acpi_tb_setup_fadt_registers(void); 59static void acpi_tb_setup_fadt_registers(void);
62 60
61static u64
62acpi_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
65typedef struct acpi_fadt_info { 66typedef 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
250static u64
251acpi_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
377static void acpi_tb_convert_fadt(void) 447static 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
504static 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 @@
49ACPI_MODULE_NAME("tbutils") 49ACPI_MODULE_NAME("tbutils")
50 50
51/* Local prototypes */ 51/* Local prototypes */
52static acpi_status acpi_tb_validate_xsdt(acpi_physical_address address);
53
52static acpi_physical_address 54static acpi_physical_address
53acpi_tb_get_root_table_entry(u8 *table_entry, u32 table_entry_size); 55acpi_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
70static acpi_status
71acpi_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
373static 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
390ACPI_EXPORT_SYMBOL(acpi_gbl_FADT) 390ACPI_EXPORT_SYMBOL(acpi_gbl_FADT)
391
392ACPI_EXPORT_SYMBOL(acpi_dbg_level) 391ACPI_EXPORT_SYMBOL(acpi_dbg_level)
393
394ACPI_EXPORT_SYMBOL(acpi_dbg_layer) 392ACPI_EXPORT_SYMBOL(acpi_dbg_layer)
395
396ACPI_EXPORT_SYMBOL(acpi_gpe_count) 393ACPI_EXPORT_SYMBOL(acpi_gpe_count)
397
398ACPI_EXPORT_SYMBOL(acpi_current_gpe_count) 394ACPI_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
129ACPI_EXPORT_SYMBOL_INIT(acpi_initialize_subsystem) 137ACPI_EXPORT_SYMBOL_INIT(acpi_initialize_subsystem)
diff --git a/drivers/acpi/apei/apei-base.c b/drivers/acpi/apei/apei-base.c
index e55584a072c6..8678dfe5366b 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
13struct apei_exec_context; 12struct apei_exec_context;
14 13
diff --git a/drivers/acpi/apei/einj.c b/drivers/acpi/apei/einj.c
index 7dcc8a824aae..1be6f5564485 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#include <asm/unaligned.h> 36#include <asm/unaligned.h>
38 37
39#include "apei-internal.h" 38#include "apei-internal.h"
diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c
index 46766ef7ef5d..dab7cb7349df 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 5876a49dfd38..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: "
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 0710004055c8..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;
52struct proc_dir_entry *acpi_root_dir; 50struct proc_dir_entry *acpi_root_dir;
53EXPORT_SYMBOL(acpi_root_dir); 51EXPORT_SYMBOL(acpi_root_dir);
54 52
55#define STRUCT_TO_INT(s) (*((int*)&s))
56
57
58#ifdef CONFIG_X86 53#ifdef CONFIG_X86
59static int set_copy_dsdt(const struct dmi_system_id *id) 54static 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}
132EXPORT_SYMBOL(acpi_bus_get_status); 125EXPORT_SYMBOL(acpi_bus_get_status);
@@ -339,58 +332,6 @@ static void acpi_bus_osc_support(void)
339 Notification Handling 332 Notification Handling
340 -------------------------------------------------------------------------- */ 333 -------------------------------------------------------------------------- */
341 334
342static void acpi_bus_check_device(acpi_handle handle)
343{
344 struct acpi_device *device;
345 acpi_status status;
346 struct acpi_device_status old_status;
347
348 if (acpi_bus_get_device(handle, &device))
349 return;
350 if (!device)
351 return;
352
353 old_status = device->status;
354
355 /*
356 * Make sure this device's parent is present before we go about
357 * messing with the device.
358 */
359 if (device->parent && !device->parent->status.present) {
360 device->status = device->parent->status;
361 return;
362 }
363
364 status = acpi_bus_get_status(device);
365 if (ACPI_FAILURE(status))
366 return;
367
368 if (STRUCT_TO_INT(old_status) == STRUCT_TO_INT(device->status))
369 return;
370
371 /*
372 * Device Insertion/Removal
373 */
374 if ((device->status.present) && !(old_status.present)) {
375 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device insertion detected\n"));
376 /* TBD: Handle device insertion */
377 } else if (!(device->status.present) && (old_status.present)) {
378 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device removal detected\n"));
379 /* TBD: Handle device removal */
380 }
381}
382
383static void acpi_bus_check_scope(acpi_handle handle)
384{
385 /* Status Change? */
386 acpi_bus_check_device(handle);
387
388 /*
389 * TBD: Enumerate child devices within this device's scope and
390 * run acpi_bus_check_device()'s on them.
391 */
392}
393
394/** 335/**
395 * acpi_bus_notify 336 * acpi_bus_notify
396 * --------------- 337 * ---------------
@@ -407,19 +348,11 @@ static void acpi_bus_notify(acpi_handle handle, u32 type, void *data)
407 switch (type) { 348 switch (type) {
408 349
409 case ACPI_NOTIFY_BUS_CHECK: 350 case ACPI_NOTIFY_BUS_CHECK:
410 acpi_bus_check_scope(handle); 351 /* TBD */
411 /*
412 * TBD: We'll need to outsource certain events to non-ACPI
413 * drivers via the device manager (device.c).
414 */
415 break; 352 break;
416 353
417 case ACPI_NOTIFY_DEVICE_CHECK: 354 case ACPI_NOTIFY_DEVICE_CHECK:
418 acpi_bus_check_device(handle); 355 /* TBD */
419 /*
420 * TBD: We'll need to outsource certain events to non-ACPI
421 * drivers via the device manager (device.c).
422 */
423 break; 356 break;
424 357
425 case ACPI_NOTIFY_DEVICE_WAKE: 358 case ACPI_NOTIFY_DEVICE_WAKE:
diff --git a/drivers/acpi/button.c b/drivers/acpi/button.c
index c971929d75c2..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: "
@@ -101,7 +100,6 @@ struct acpi_button {
101 struct input_dev *input; 100 struct input_dev *input;
102 char phys[32]; /* for input device */ 101 char phys[32]; /* for input device */
103 unsigned long pushed; 102 unsigned long pushed;
104 bool wakeup_enabled;
105}; 103};
106 104
107static BLOCKING_NOTIFIER_HEAD(acpi_lid_notifier); 105static BLOCKING_NOTIFIER_HEAD(acpi_lid_notifier);
@@ -407,16 +405,6 @@ static int acpi_button_add(struct acpi_device *device)
407 lid_device = device; 405 lid_device = device;
408 } 406 }
409 407
410 if (device->wakeup.flags.valid) {
411 /* Button's GPE is run-wake GPE */
412 acpi_enable_gpe(device->wakeup.gpe_device,
413 device->wakeup.gpe_number);
414 if (!device_may_wakeup(&device->dev)) {
415 device_set_wakeup_enable(&device->dev, true);
416 button->wakeup_enabled = true;
417 }
418 }
419
420 printk(KERN_INFO PREFIX "%s [%s]\n", name, acpi_device_bid(device)); 408 printk(KERN_INFO PREFIX "%s [%s]\n", name, acpi_device_bid(device));
421 return 0; 409 return 0;
422 410
@@ -433,13 +421,6 @@ static int acpi_button_remove(struct acpi_device *device)
433{ 421{
434 struct acpi_button *button = acpi_driver_data(device); 422 struct acpi_button *button = acpi_driver_data(device);
435 423
436 if (device->wakeup.flags.valid) {
437 acpi_disable_gpe(device->wakeup.gpe_device,
438 device->wakeup.gpe_number);
439 if (button->wakeup_enabled)
440 device_set_wakeup_enable(&device->dev, false);
441 }
442
443 acpi_button_remove_fs(device); 424 acpi_button_remove_fs(device);
444 input_unregister_device(button->input); 425 input_unregister_device(button->input);
445 kfree(button); 426 kfree(button);
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
47static int container_device_attach(struct acpi_device *device, 46static 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
59static void acpi_container_release(struct device *dev)
60{
61 kfree(to_container_dev(dev));
62}
63
64static 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
89static 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
54static struct acpi_scan_handler container_handler = { 98static 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
11ACPI_MODULE_NAME("debugfs"); 11ACPI_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
305int acpi_bus_update_power(acpi_handle handle, int *state_p) 307int 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
347int 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}
341EXPORT_SYMBOL_GPL(acpi_bus_update_power); 355EXPORT_SYMBOL_GPL(acpi_bus_update_power);
342 356
343bool acpi_bus_power_manageable(acpi_handle handle) 357bool 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 */
324static void dock_create_acpi_device(acpi_handle handle) 324static 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
899void __init acpi_dock_init(void) 896void __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 ba5b56db9d27..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;
91module_param(ec_storm_threshold, uint, 0644); 90module_param(ec_storm_threshold, uint, 0644);
92MODULE_PARM_DESC(ec_storm_threshold, "Maxim false GPE numbers not considered as GPE storm"); 91MODULE_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 */
96typedef int (*acpi_ec_query_func) (void *data);
97
98struct acpi_ec_query_handler { 93struct 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 */
393int ec_burst_enable(void)
394{
395 if (!first_ec)
396 return -ENODEV;
397 return acpi_ec_burst_enable(first_ec);
398}
399
400EXPORT_SYMBOL(ec_burst_enable);
401
402int ec_burst_disable(void)
403{
404 if (!first_ec)
405 return -ENODEV;
406 return acpi_ec_burst_disable(first_ec);
407}
408
409EXPORT_SYMBOL(ec_burst_disable);
410
411int ec_read(u8 addr, u8 *val) 385int ec_read(u8 addr, u8 *val)
412{ 386{
413 int err; 387 int err;
@@ -779,9 +753,9 @@ static int ec_install_handlers(struct acpi_ec *ec)
779 pr_err("Fail in evaluating the _REG object" 753 pr_err("Fail in evaluating the _REG object"
780 " of EC device. Broken bios is suspected.\n"); 754 " of EC device. Broken bios is suspected.\n");
781 } else { 755 } else {
756 acpi_disable_gpe(NULL, ec->gpe);
782 acpi_remove_gpe_handler(NULL, ec->gpe, 757 acpi_remove_gpe_handler(NULL, ec->gpe,
783 &acpi_ec_gpe_handler); 758 &acpi_ec_gpe_handler);
784 acpi_disable_gpe(NULL, ec->gpe);
785 return -ENODEV; 759 return -ENODEV;
786 } 760 }
787 } 761 }
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
108int acpi_ec_add_debugfs(struct acpi_ec *ec, unsigned int ec_device_count) 108static 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
85static acpi_status acpi_dev_present(acpi_handle handle, u32 lvl_not_used, 85static 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
98static 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
122struct find_child_context { 103struct 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
129static 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
173acpi_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}
187EXPORT_SYMBOL_GPL(acpi_find_child); 152EXPORT_SYMBOL_GPL(acpi_find_child_device);
188 153
189static void acpi_physnode_link_name(char *buf, unsigned int node_id) 154static 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
198int acpi_bind_one(struct device *dev, acpi_handle handle) 163int 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}
323EXPORT_SYMBOL_GPL(acpi_unbind_one); 285EXPORT_SYMBOL_GPL(acpi_unbind_one);
324 286
325void 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}
332EXPORT_SYMBOL_GPL(acpi_preset_companion);
333
334static int acpi_platform_notify(struct device *dev) 287static 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
32static struct acpi_device_id acpi_hed_ids[] = { 30static 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);
28int acpi_scan_init(void); 28int acpi_scan_init(void);
29void acpi_pci_root_init(void); 29void acpi_pci_root_init(void);
30void acpi_pci_link_init(void); 30void acpi_pci_link_init(void);
31void acpi_pci_root_hp_init(void);
32void acpi_processor_init(void); 31void acpi_processor_init(void);
33void acpi_platform_init(void); 32void acpi_platform_init(void);
34int acpi_sysfs_init(void); 33int acpi_sysfs_init(void);
@@ -73,6 +72,9 @@ void acpi_lpss_init(void);
73static inline void acpi_lpss_init(void) {} 72static inline void acpi_lpss_init(void) {}
74#endif 73#endif
75 74
75bool acpi_queue_hotplug_work(struct work_struct *work);
76bool 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);
86void acpi_device_add_finalize(struct acpi_device *device); 88void acpi_device_add_finalize(struct acpi_device *device);
87void acpi_free_pnp_ids(struct acpi_device_pnp *pnp); 89void acpi_free_pnp_ids(struct acpi_device_pnp *pnp);
88int acpi_bind_one(struct device *dev, acpi_handle handle); 90int acpi_bind_one(struct device *dev, struct acpi_device *adev);
89int acpi_unbind_one(struct device *dev); 91int acpi_unbind_one(struct device *dev);
90void acpi_bus_device_eject(void *data, u32 ost_src); 92bool 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);
105int acpi_power_on_resources(struct acpi_device *device, int state); 107int acpi_power_on_resources(struct acpi_device *device, int state);
106int acpi_power_transition(struct acpi_device *device, int state); 108int acpi_power_transition(struct acpi_device *device, int state);
107 109
110int acpi_device_update_power(struct acpi_device *device, int *state_p);
111
108int acpi_wakeup_device_init(void); 112int acpi_wakeup_device_init(void);
109void acpi_early_processor_set_pdc(void); 113void acpi_early_processor_set_pdc(void);
110 114
@@ -127,12 +131,21 @@ struct acpi_ec {
127 131
128extern struct acpi_ec *first_ec; 132extern 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 */
136typedef int (*acpi_ec_query_func) (void *data);
137
130int acpi_ec_init(void); 138int acpi_ec_init(void);
131int acpi_ec_ecdt_probe(void); 139int acpi_ec_ecdt_probe(void);
132int acpi_boot_ec_enable(void); 140int acpi_boot_ec_enable(void);
133void acpi_ec_block_transactions(void); 141void acpi_ec_block_transactions(void);
134void acpi_ec_unblock_transactions(void); 142void acpi_ec_unblock_transactions(void);
135void acpi_ec_unblock_transactions_early(void); 143void acpi_ec_unblock_transactions_early(void);
144int acpi_ec_add_query_handler(struct acpi_ec *ec, u8 query_bit,
145 acpi_handle handle, acpi_ec_query_func func,
146 void *data);
147void 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;
544static int all_tables_size; 540static int all_tables_size;
545 541
546/* Copied from acpica/tbutils.c:acpi_tb_checksum() */ 542/* Copied from acpica/tbutils.c:acpi_tb_checksum() */
547u8 __init acpi_table_checksum(u8 *buffer, u32 length) 543static 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
1214bool acpi_queue_hotplug_work(struct work_struct *work)
1215{
1216 return queue_work(kacpi_hotplug_wq, work);
1217}
1218 1218
1219acpi_status 1219acpi_status
1220acpi_os_create_semaphore(u32 max_units, u32 initial_units, acpi_handle * handle) 1220acpi_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 5b01bd6d5ea0..c1c4102e6478 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);
52static void acpi_pci_root_remove(struct acpi_device *device); 50static void acpi_pci_root_remove(struct acpi_device *device);
53 51
52static 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
@@ -630,116 +635,9 @@ static void acpi_pci_root_remove(struct acpi_device *device)
630void __init acpi_pci_root_init(void) 635void __init acpi_pci_root_init(void)
631{ 636{
632 acpi_hest_init(); 637 acpi_hest_init();
633 638 if (acpi_pci_disabled)
634 if (!acpi_pci_disabled) {
635 pci_acpi_crs_quirks();
636 acpi_scan_add_handler(&pci_root_handler);
637 }
638}
639/* Support root bridge hotplug */
640
641static void handle_root_bridge_insertion(acpi_handle handle)
642{
643 struct acpi_device *device;
644
645 if (!acpi_bus_get_device(handle, &device)) {
646 dev_printk(KERN_DEBUG, &device->dev,
647 "acpi device already exists; ignoring notify\n");
648 return; 639 return;
649 }
650
651 if (acpi_bus_scan(handle))
652 acpi_handle_err(handle, "cannot add bridge to acpi list\n");
653}
654
655static void hotplug_event_root(void *data, u32 type)
656{
657 acpi_handle handle = data;
658 struct acpi_pci_root *root;
659
660 acpi_scan_lock_acquire();
661
662 root = acpi_pci_find_root(handle);
663
664 switch (type) {
665 case ACPI_NOTIFY_BUS_CHECK:
666 /* bus enumerate */
667 acpi_handle_printk(KERN_DEBUG, handle,
668 "Bus check notify on %s\n", __func__);
669 if (root)
670 acpiphp_check_host_bridge(handle);
671 else
672 handle_root_bridge_insertion(handle);
673
674 break;
675
676 case ACPI_NOTIFY_DEVICE_CHECK:
677 /* device check */
678 acpi_handle_printk(KERN_DEBUG, handle,
679 "Device check notify on %s\n", __func__);
680 if (!root)
681 handle_root_bridge_insertion(handle);
682 break;
683
684 case ACPI_NOTIFY_EJECT_REQUEST:
685 /* request device eject */
686 acpi_handle_printk(KERN_DEBUG, handle,
687 "Device eject notify on %s\n", __func__);
688 if (!root)
689 break;
690
691 get_device(&root->device->dev);
692
693 acpi_scan_lock_release();
694
695 acpi_bus_device_eject(root->device, ACPI_NOTIFY_EJECT_REQUEST);
696 return;
697 default:
698 acpi_handle_warn(handle,
699 "notify_handler: unknown event type 0x%x\n",
700 type);
701 break;
702 }
703
704 acpi_scan_lock_release();
705}
706
707static void handle_hotplug_event_root(acpi_handle handle, u32 type,
708 void *context)
709{
710 acpi_hotplug_execute(hotplug_event_root, handle, type);
711}
712
713static acpi_status __init
714find_root_bridges(acpi_handle handle, u32 lvl, void *context, void **rv)
715{
716 acpi_status status;
717 int *count = (int *)context;
718
719 if (!acpi_is_root_bridge(handle))
720 return AE_OK;
721
722 (*count)++;
723
724 status = acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY,
725 handle_hotplug_event_root, NULL);
726 if (ACPI_FAILURE(status))
727 acpi_handle_printk(KERN_DEBUG, handle,
728 "notify handler is not installed, exit status: %u\n",
729 (unsigned int)status);
730 else
731 acpi_handle_printk(KERN_DEBUG, handle,
732 "notify handler is installed\n");
733
734 return AE_OK;
735}
736
737void __init acpi_pci_root_hp_init(void)
738{
739 int num = 0;
740
741 acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
742 ACPI_UINT32_MAX, find_root_bridges, NULL, &num, NULL);
743 640
744 printk(KERN_DEBUG "Found %d acpi root devices\n", num); 641 pci_acpi_crs_quirks();
642 acpi_scan_add_handler_with_hotplug(&pci_root_handler, "pci_root");
745} 643}
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
39static bool debug; 40static bool debug;
40static int check_sta_before_sun; 41static 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
225static int acpi_processor_start(struct device *dev) 225static 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
235static int acpi_processor_stop(struct device *dev) 235static 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 f90c56c8379e..3dca36d4ad26 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
214static void acpi_processor_resume(void) 212static 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:
@@ -780,6 +778,13 @@ static int acpi_idle_enter_simple(struct cpuidle_device *dev,
780 if (unlikely(!pr)) 778 if (unlikely(!pr))
781 return -EINVAL; 779 return -EINVAL;
782 780
781#ifdef CONFIG_HOTPLUG_CPU
782 if ((cx->type != ACPI_STATE_C1) && (num_online_cpus() > 1) &&
783 !pr->flags.has_cst &&
784 !(acpi_gbl_FADT.flags & ACPI_FADT_C2_MP_SUPPORTED))
785 return acpi_idle_enter_c1(dev, drv, CPUIDLE_DRIVER_STATE_START);
786#endif
787
783 /* 788 /*
784 * Must be done before busmaster disable as we might need to 789 * Must be done before busmaster disable as we might need to
785 * access HPET ! 790 * access HPET !
@@ -821,6 +826,13 @@ static int acpi_idle_enter_bm(struct cpuidle_device *dev,
821 if (unlikely(!pr)) 826 if (unlikely(!pr))
822 return -EINVAL; 827 return -EINVAL;
823 828
829#ifdef CONFIG_HOTPLUG_CPU
830 if ((cx->type != ACPI_STATE_C1) && (num_online_cpus() > 1) &&
831 !pr->flags.has_cst &&
832 !(acpi_gbl_FADT.flags & ACPI_FADT_C2_MP_SUPPORTED))
833 return acpi_idle_enter_c1(dev, drv, CPUIDLE_DRIVER_STATE_START);
834#endif
835
824 if (!cx->bm_sts_skip && acpi_idle_bm_check()) { 836 if (!cx->bm_sts_skip && acpi_idle_bm_check()) {
825 if (drv->safe_state_index >= 0) { 837 if (drv->safe_state_index >= 0) {
826 return drv->states[drv->safe_state_index].enter(dev, 838 return drv->states[drv->safe_state_index].enter(dev,
@@ -917,12 +929,6 @@ static int acpi_processor_setup_cpuidle_cx(struct acpi_processor *pr,
917 if (!cx->valid) 929 if (!cx->valid)
918 continue; 930 continue;
919 931
920#ifdef CONFIG_HOTPLUG_CPU
921 if ((cx->type != ACPI_STATE_C1) && (num_online_cpus() > 1) &&
922 !pr->flags.has_cst &&
923 !(acpi_gbl_FADT.flags & ACPI_FADT_C2_MP_SUPPORTED))
924 continue;
925#endif
926 per_cpu(acpi_cstate[count], dev->cpu) = cx; 932 per_cpu(acpi_cstate[count], dev->cpu) = cx;
927 933
928 count++; 934 count++;
@@ -930,8 +936,6 @@ static int acpi_processor_setup_cpuidle_cx(struct acpi_processor *pr,
930 break; 936 break;
931 } 937 }
932 938
933 dev->state_count = count;
934
935 if (!count) 939 if (!count)
936 return -EINVAL; 940 return -EINVAL;
937 941
@@ -972,13 +976,6 @@ static int acpi_processor_setup_cpuidle_states(struct acpi_processor *pr)
972 if (!cx->valid) 976 if (!cx->valid)
973 continue; 977 continue;
974 978
975#ifdef CONFIG_HOTPLUG_CPU
976 if ((cx->type != ACPI_STATE_C1) && (num_online_cpus() > 1) &&
977 !pr->flags.has_cst &&
978 !(acpi_gbl_FADT.flags & ACPI_FADT_C2_MP_SUPPORTED))
979 continue;
980#endif
981
982 state = &drv->states[count]; 979 state = &drv->states[count];
983 snprintf(state->name, CPUIDLE_NAME_LEN, "C%d", i); 980 snprintf(state->name, CPUIDLE_NAME_LEN, "C%d", i);
984 strncpy(state->desc, cx->desc, CPUIDLE_DESC_LEN); 981 strncpy(state->desc, cx->desc, CPUIDLE_DESC_LEN);
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 */
190static int acpi_processor_max_state(struct acpi_processor *pr) 187static 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..e00365ccb897 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
20ACPI_MODULE_NAME("scan"); 20ACPI_MODULE_NAME("scan");
21#define STRUCT_TO_INT(s) (*((int*)&s))
22extern struct acpi_device *acpi_root; 21extern 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).
@@ -85,6 +86,9 @@ int acpi_scan_add_handler_with_hotplug(struct acpi_scan_handler *handler,
85 * Creates hid/cid(s) string needed for modalias and uevent 86 * Creates hid/cid(s) string needed for modalias and uevent
86 * e.g. on a device with hid:IBM0001 and cid:ACPI0001 you get: 87 * e.g. on a device with hid:IBM0001 and cid:ACPI0001 you get:
87 * char *modalias: "acpi:IBM0001:ACPI0001" 88 * char *modalias: "acpi:IBM0001:ACPI0001"
89 * Return: 0: no _HID and no _CID
90 * -EINVAL: output error
91 * -ENOMEM: output is truncated
88*/ 92*/
89static int create_modalias(struct acpi_device *acpi_dev, char *modalias, 93static int create_modalias(struct acpi_device *acpi_dev, char *modalias,
90 int size) 94 int size)
@@ -101,8 +105,10 @@ static int create_modalias(struct acpi_device *acpi_dev, char *modalias,
101 105
102 list_for_each_entry(id, &acpi_dev->pnp.ids, list) { 106 list_for_each_entry(id, &acpi_dev->pnp.ids, list) {
103 count = snprintf(&modalias[len], size, "%s:", id->id); 107 count = snprintf(&modalias[len], size, "%s:", id->id);
104 if (count < 0 || count >= size) 108 if (count < 0)
105 return -EINVAL; 109 return EINVAL;
110 if (count >= size)
111 return -ENOMEM;
106 len += count; 112 len += count;
107 size -= count; 113 size -= count;
108 } 114 }
@@ -111,20 +117,96 @@ static int create_modalias(struct acpi_device *acpi_dev, char *modalias,
111 return len; 117 return len;
112} 118}
113 119
120/*
121 * Creates uevent modalias field for ACPI enumerated devices.
122 * Because the other buses does not support ACPI HIDs & CIDs.
123 * e.g. for a device with hid:IBM0001 and cid:ACPI0001 you get:
124 * "acpi:IBM0001:ACPI0001"
125 */
126int acpi_device_uevent_modalias(struct device *dev, struct kobj_uevent_env *env)
127{
128 struct acpi_device *acpi_dev;
129 int len;
130
131 acpi_dev = ACPI_COMPANION(dev);
132 if (!acpi_dev)
133 return -ENODEV;
134
135 /* Fall back to bus specific way of modalias exporting */
136 if (list_empty(&acpi_dev->pnp.ids))
137 return -ENODEV;
138
139 if (add_uevent_var(env, "MODALIAS="))
140 return -ENOMEM;
141 len = create_modalias(acpi_dev, &env->buf[env->buflen - 1],
142 sizeof(env->buf) - env->buflen);
143 if (len <= 0)
144 return len;
145 env->buflen += len;
146 return 0;
147}
148EXPORT_SYMBOL_GPL(acpi_device_uevent_modalias);
149
150/*
151 * Creates modalias sysfs attribute for ACPI enumerated devices.
152 * Because the other buses does not support ACPI HIDs & CIDs.
153 * e.g. for a device with hid:IBM0001 and cid:ACPI0001 you get:
154 * "acpi:IBM0001:ACPI0001"
155 */
156int acpi_device_modalias(struct device *dev, char *buf, int size)
157{
158 struct acpi_device *acpi_dev;
159 int len;
160
161 acpi_dev = ACPI_COMPANION(dev);
162 if (!acpi_dev)
163 return -ENODEV;
164
165 /* Fall back to bus specific way of modalias exporting */
166 if (list_empty(&acpi_dev->pnp.ids))
167 return -ENODEV;
168
169 len = create_modalias(acpi_dev, buf, size -1);
170 if (len <= 0)
171 return len;
172 buf[len++] = '\n';
173 return len;
174}
175EXPORT_SYMBOL_GPL(acpi_device_modalias);
176
114static ssize_t 177static ssize_t
115acpi_device_modalias_show(struct device *dev, struct device_attribute *attr, char *buf) { 178acpi_device_modalias_show(struct device *dev, struct device_attribute *attr, char *buf) {
116 struct acpi_device *acpi_dev = to_acpi_device(dev); 179 struct acpi_device *acpi_dev = to_acpi_device(dev);
117 int len; 180 int len;
118 181
119 /* Device has no HID and no CID or string is >1024 */
120 len = create_modalias(acpi_dev, buf, 1024); 182 len = create_modalias(acpi_dev, buf, 1024);
121 if (len <= 0) 183 if (len <= 0)
122 return 0; 184 return len;
123 buf[len++] = '\n'; 185 buf[len++] = '\n';
124 return len; 186 return len;
125} 187}
126static DEVICE_ATTR(modalias, 0444, acpi_device_modalias_show, NULL); 188static DEVICE_ATTR(modalias, 0444, acpi_device_modalias_show, NULL);
127 189
190bool acpi_scan_is_offline(struct acpi_device *adev, bool uevent)
191{
192 struct acpi_device_physical_node *pn;
193 bool offline = true;
194
195 mutex_lock(&adev->physical_node_lock);
196
197 list_for_each_entry(pn, &adev->physical_node_list, node)
198 if (device_supports_offline(pn->dev) && !pn->dev->offline) {
199 if (uevent)
200 kobject_uevent(&pn->dev->kobj, KOBJ_CHANGE);
201
202 offline = false;
203 break;
204 }
205
206 mutex_unlock(&adev->physical_node_lock);
207 return offline;
208}
209
128static acpi_status acpi_bus_offline(acpi_handle handle, u32 lvl, void *data, 210static acpi_status acpi_bus_offline(acpi_handle handle, u32 lvl, void *data,
129 void **ret_p) 211 void **ret_p)
130{ 212{
@@ -195,19 +277,11 @@ static acpi_status acpi_bus_online(acpi_handle handle, u32 lvl, void *data,
195 return AE_OK; 277 return AE_OK;
196} 278}
197 279
198static int acpi_scan_hot_remove(struct acpi_device *device) 280static int acpi_scan_try_to_offline(struct acpi_device *device)
199{ 281{
200 acpi_handle handle = device->handle; 282 acpi_handle handle = device->handle;
201 struct device *errdev; 283 struct device *errdev = NULL;
202 acpi_status status; 284 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 285
212 /* 286 /*
213 * Carry out two passes here and ignore errors in the first pass, 287 * Carry out two passes here and ignore errors in the first pass,
@@ -218,7 +292,6 @@ static int acpi_scan_hot_remove(struct acpi_device *device)
218 * 292 *
219 * If the first pass is successful, the second one isn't needed, though. 293 * If the first pass is successful, the second one isn't needed, though.
220 */ 294 */
221 errdev = NULL;
222 status = acpi_walk_namespace(ACPI_TYPE_ANY, handle, ACPI_UINT32_MAX, 295 status = acpi_walk_namespace(ACPI_TYPE_ANY, handle, ACPI_UINT32_MAX,
223 NULL, acpi_bus_offline, (void *)false, 296 NULL, acpi_bus_offline, (void *)false,
224 (void **)&errdev); 297 (void **)&errdev);
@@ -226,7 +299,6 @@ static int acpi_scan_hot_remove(struct acpi_device *device)
226 dev_warn(errdev, "Offline disabled.\n"); 299 dev_warn(errdev, "Offline disabled.\n");
227 acpi_walk_namespace(ACPI_TYPE_ANY, handle, ACPI_UINT32_MAX, 300 acpi_walk_namespace(ACPI_TYPE_ANY, handle, ACPI_UINT32_MAX,
228 acpi_bus_online, NULL, NULL, NULL); 301 acpi_bus_online, NULL, NULL, NULL);
229 put_device(&device->dev);
230 return -EPERM; 302 return -EPERM;
231 } 303 }
232 acpi_bus_offline(handle, 0, (void *)false, (void **)&errdev); 304 acpi_bus_offline(handle, 0, (void *)false, (void **)&errdev);
@@ -245,20 +317,32 @@ static int acpi_scan_hot_remove(struct acpi_device *device)
245 acpi_walk_namespace(ACPI_TYPE_ANY, handle, 317 acpi_walk_namespace(ACPI_TYPE_ANY, handle,
246 ACPI_UINT32_MAX, acpi_bus_online, 318 ACPI_UINT32_MAX, acpi_bus_online,
247 NULL, NULL, NULL); 319 NULL, NULL, NULL);
248 put_device(&device->dev);
249 return -EBUSY; 320 return -EBUSY;
250 } 321 }
251 } 322 }
323 return 0;
324}
325
326static int acpi_scan_hot_remove(struct acpi_device *device)
327{
328 acpi_handle handle = device->handle;
329 unsigned long long sta;
330 acpi_status status;
331
332 if (device->handler->hotplug.demand_offline && !acpi_force_hot_remove) {
333 if (!acpi_scan_is_offline(device, true))
334 return -EBUSY;
335 } else {
336 int error = acpi_scan_try_to_offline(device);
337 if (error)
338 return error;
339 }
252 340
253 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 341 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
254 "Hot-removing device %s...\n", dev_name(&device->dev))); 342 "Hot-removing device %s...\n", dev_name(&device->dev)));
255 343
256 acpi_bus_trim(device); 344 acpi_bus_trim(device);
257 345
258 /* Device node has been unregistered. */
259 put_device(&device->dev);
260 device = NULL;
261
262 acpi_evaluate_lck(handle, 0); 346 acpi_evaluate_lck(handle, 0);
263 /* 347 /*
264 * TBD: _EJD support. 348 * TBD: _EJD support.
@@ -285,115 +369,127 @@ static int acpi_scan_hot_remove(struct acpi_device *device)
285 return 0; 369 return 0;
286} 370}
287 371
288void acpi_bus_device_eject(void *data, u32 ost_src) 372static int acpi_scan_device_not_present(struct acpi_device *adev)
289{ 373{
290 struct acpi_device *device = data; 374 if (!acpi_device_enumerated(adev)) {
291 acpi_handle handle = device->handle; 375 dev_warn(&adev->dev, "Still not present\n");
292 u32 ost_code = ACPI_OST_SC_NON_SPECIFIC_FAILURE; 376 return -EALREADY;
293 int error; 377 }
378 acpi_bus_trim(adev);
379 return 0;
380}
294 381
295 lock_device_hotplug(); 382static int acpi_scan_device_check(struct acpi_device *adev)
296 mutex_lock(&acpi_scan_lock); 383{
384 int error;
297 385
298 if (ost_src == ACPI_NOTIFY_EJECT_REQUEST) 386 acpi_bus_get_status(adev);
299 acpi_evaluate_hotplug_ost(handle, ACPI_NOTIFY_EJECT_REQUEST, 387 if (adev->status.present || adev->status.functional) {
300 ACPI_OST_SC_EJECT_IN_PROGRESS, NULL); 388 /*
389 * This function is only called for device objects for which
390 * matching scan handlers exist. The only situation in which
391 * the scan handler is not attached to this device object yet
392 * is when the device has just appeared (either it wasn't
393 * present at all before or it was removed and then added
394 * again).
395 */
396 if (adev->handler) {
397 dev_warn(&adev->dev, "Already enumerated\n");
398 return -EALREADY;
399 }
400 error = acpi_bus_scan(adev->handle);
401 if (error) {
402 dev_warn(&adev->dev, "Namespace scan failure\n");
403 return error;
404 }
405 if (!adev->handler) {
406 dev_warn(&adev->dev, "Enumeration failure\n");
407 error = -ENODEV;
408 }
409 } else {
410 error = acpi_scan_device_not_present(adev);
411 }
412 return error;
413}
301 414
302 if (device->handler && device->handler->hotplug.mode == AHM_CONTAINER) 415static int acpi_scan_bus_check(struct acpi_device *adev)
303 kobject_uevent(&device->dev.kobj, KOBJ_OFFLINE); 416{
417 struct acpi_scan_handler *handler = adev->handler;
418 struct acpi_device *child;
419 int error;
304 420
305 error = acpi_scan_hot_remove(device); 421 acpi_bus_get_status(adev);
306 if (error == -EPERM) { 422 if (!(adev->status.present || adev->status.functional)) {
307 goto err_support; 423 acpi_scan_device_not_present(adev);
308 } else if (error) { 424 return 0;
309 goto err_out;
310 } 425 }
426 if (handler && handler->hotplug.scan_dependent)
427 return handler->hotplug.scan_dependent(adev);
311 428
312 out: 429 error = acpi_bus_scan(adev->handle);
313 mutex_unlock(&acpi_scan_lock); 430 if (error) {
314 unlock_device_hotplug(); 431 dev_warn(&adev->dev, "Namespace scan failure\n");
315 return; 432 return error;
316 433 }
317 err_support: 434 list_for_each_entry(child, &adev->children, node) {
318 ost_code = ACPI_OST_SC_EJECT_NOT_SUPPORTED; 435 error = acpi_scan_bus_check(child);
319 err_out: 436 if (error)
320 acpi_evaluate_hotplug_ost(handle, ost_src, ost_code, NULL); 437 return error;
321 goto out; 438 }
439 return 0;
322} 440}
323 441
324static void acpi_scan_bus_device_check(void *data, u32 ost_source) 442static void acpi_device_hotplug(void *data, u32 src)
325{ 443{
326 acpi_handle handle = data;
327 struct acpi_device *device = NULL;
328 u32 ost_code = ACPI_OST_SC_NON_SPECIFIC_FAILURE; 444 u32 ost_code = ACPI_OST_SC_NON_SPECIFIC_FAILURE;
445 struct acpi_device *adev = data;
329 int error; 446 int error;
330 447
331 lock_device_hotplug(); 448 lock_device_hotplug();
332 mutex_lock(&acpi_scan_lock); 449 mutex_lock(&acpi_scan_lock);
333 450
334 if (ost_source != ACPI_NOTIFY_BUS_CHECK) { 451 /*
335 acpi_bus_get_device(handle, &device); 452 * The device object's ACPI handle cannot become invalid as long as we
336 if (device) { 453 * are holding acpi_scan_lock, but it may have become invalid before
337 dev_warn(&device->dev, "Attempt to re-insert\n"); 454 * that lock was acquired.
338 goto out; 455 */
339 } 456 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; 457 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 458
355 out: 459 switch (src) {
356 acpi_evaluate_hotplug_ost(handle, ost_source, ost_code, NULL);
357 mutex_unlock(&acpi_scan_lock);
358 unlock_device_hotplug();
359}
360
361static void acpi_hotplug_unsupported(acpi_handle handle, u32 type)
362{
363 u32 ost_status;
364
365 switch (type) {
366 case ACPI_NOTIFY_BUS_CHECK: 460 case ACPI_NOTIFY_BUS_CHECK:
367 acpi_handle_debug(handle, 461 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; 462 break;
371 case ACPI_NOTIFY_DEVICE_CHECK: 463 case ACPI_NOTIFY_DEVICE_CHECK:
372 acpi_handle_debug(handle, 464 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; 465 break;
376 case ACPI_NOTIFY_EJECT_REQUEST: 466 case ACPI_NOTIFY_EJECT_REQUEST:
377 acpi_handle_debug(handle, 467 case ACPI_OST_EC_OSPM_EJECT:
378 "ACPI_NOTIFY_EJECT_REQUEST event: unsupported\n"); 468 error = acpi_scan_hot_remove(adev);
379 ost_status = ACPI_OST_SC_EJECT_NOT_SUPPORTED;
380 break; 469 break;
381 default: 470 default:
382 /* non-hotplug event; possibly handled by other handler */ 471 error = -EINVAL;
383 return; 472 break;
384 } 473 }
474 if (!error)
475 ost_code = ACPI_OST_SC_SUCCESS;
385 476
386 acpi_evaluate_hotplug_ost(handle, type, ost_status, NULL); 477 out:
478 acpi_evaluate_hotplug_ost(adev->handle, src, ost_code, NULL);
479 put_device(&adev->dev);
480 mutex_unlock(&acpi_scan_lock);
481 unlock_device_hotplug();
387} 482}
388 483
389static void acpi_hotplug_notify_cb(acpi_handle handle, u32 type, void *data) 484static void acpi_hotplug_notify_cb(acpi_handle handle, u32 type, void *data)
390{ 485{
486 u32 ost_code = ACPI_OST_SC_NON_SPECIFIC_FAILURE;
391 struct acpi_scan_handler *handler = data; 487 struct acpi_scan_handler *handler = data;
392 struct acpi_device *adev; 488 struct acpi_device *adev;
393 acpi_status status; 489 acpi_status status;
394 490
395 if (!handler->hotplug.enabled) 491 if (acpi_bus_get_device(handle, &adev))
396 return acpi_hotplug_unsupported(handle, type); 492 goto err_out;
397 493
398 switch (type) { 494 switch (type) {
399 case ACPI_NOTIFY_BUS_CHECK: 495 case ACPI_NOTIFY_BUS_CHECK:
@@ -404,27 +500,27 @@ static void acpi_hotplug_notify_cb(acpi_handle handle, u32 type, void *data)
404 break; 500 break;
405 case ACPI_NOTIFY_EJECT_REQUEST: 501 case ACPI_NOTIFY_EJECT_REQUEST:
406 acpi_handle_debug(handle, "ACPI_NOTIFY_EJECT_REQUEST event\n"); 502 acpi_handle_debug(handle, "ACPI_NOTIFY_EJECT_REQUEST event\n");
407 if (acpi_bus_get_device(handle, &adev)) 503 if (!handler->hotplug.enabled) {
504 acpi_handle_err(handle, "Eject disabled\n");
505 ost_code = ACPI_OST_SC_EJECT_NOT_SUPPORTED;
408 goto err_out; 506 goto err_out;
409 507 }
410 get_device(&adev->dev); 508 acpi_evaluate_hotplug_ost(handle, ACPI_NOTIFY_EJECT_REQUEST,
411 status = acpi_hotplug_execute(acpi_bus_device_eject, adev, type); 509 ACPI_OST_SC_EJECT_IN_PROGRESS, NULL);
412 if (ACPI_SUCCESS(status)) 510 break;
413 return;
414
415 put_device(&adev->dev);
416 goto err_out;
417 default: 511 default:
418 /* non-hotplug event; possibly handled by other handler */ 512 /* non-hotplug event; possibly handled by other handler */
419 return; 513 return;
420 } 514 }
421 status = acpi_hotplug_execute(acpi_scan_bus_device_check, handle, type); 515 get_device(&adev->dev);
516 status = acpi_hotplug_execute(acpi_device_hotplug, adev, type);
422 if (ACPI_SUCCESS(status)) 517 if (ACPI_SUCCESS(status))
423 return; 518 return;
424 519
520 put_device(&adev->dev);
521
425 err_out: 522 err_out:
426 acpi_evaluate_hotplug_ost(handle, type, 523 acpi_evaluate_hotplug_ost(handle, type, ost_code, NULL);
427 ACPI_OST_SC_NON_SPECIFIC_FAILURE, NULL);
428} 524}
429 525
430static ssize_t real_power_state_show(struct device *dev, 526static ssize_t real_power_state_show(struct device *dev,
@@ -475,7 +571,7 @@ acpi_eject_store(struct device *d, struct device_attribute *attr,
475 acpi_evaluate_hotplug_ost(acpi_device->handle, ACPI_OST_EC_OSPM_EJECT, 571 acpi_evaluate_hotplug_ost(acpi_device->handle, ACPI_OST_EC_OSPM_EJECT,
476 ACPI_OST_SC_EJECT_IN_PROGRESS, NULL); 572 ACPI_OST_SC_EJECT_IN_PROGRESS, NULL);
477 get_device(&acpi_device->dev); 573 get_device(&acpi_device->dev);
478 status = acpi_hotplug_execute(acpi_bus_device_eject, acpi_device, 574 status = acpi_hotplug_execute(acpi_device_hotplug, acpi_device,
479 ACPI_OST_EC_OSPM_EJECT); 575 ACPI_OST_EC_OSPM_EJECT);
480 if (ACPI_SUCCESS(status)) 576 if (ACPI_SUCCESS(status))
481 return count; 577 return count;
@@ -567,6 +663,20 @@ acpi_device_sun_show(struct device *dev, struct device_attribute *attr,
567} 663}
568static DEVICE_ATTR(sun, 0444, acpi_device_sun_show, NULL); 664static DEVICE_ATTR(sun, 0444, acpi_device_sun_show, NULL);
569 665
666static ssize_t status_show(struct device *dev, struct device_attribute *attr,
667 char *buf) {
668 struct acpi_device *acpi_dev = to_acpi_device(dev);
669 acpi_status status;
670 unsigned long long sta;
671
672 status = acpi_evaluate_integer(acpi_dev->handle, "_STA", NULL, &sta);
673 if (ACPI_FAILURE(status))
674 return -ENODEV;
675
676 return sprintf(buf, "%llu\n", sta);
677}
678static DEVICE_ATTR_RO(status);
679
570static int acpi_device_setup_files(struct acpi_device *dev) 680static int acpi_device_setup_files(struct acpi_device *dev)
571{ 681{
572 struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL}; 682 struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL};
@@ -622,6 +732,12 @@ static int acpi_device_setup_files(struct acpi_device *dev)
622 dev->pnp.sun = (unsigned long)-1; 732 dev->pnp.sun = (unsigned long)-1;
623 } 733 }
624 734
735 if (acpi_has_method(dev->handle, "_STA")) {
736 result = device_create_file(&dev->dev, &dev_attr_status);
737 if (result)
738 goto end;
739 }
740
625 /* 741 /*
626 * If device has _EJ0, 'eject' file is created that is used to trigger 742 * If device has _EJ0, 'eject' file is created that is used to trigger
627 * hot-removal function from userland. 743 * hot-removal function from userland.
@@ -677,6 +793,8 @@ static void acpi_device_remove_files(struct acpi_device *dev)
677 device_remove_file(&dev->dev, &dev_attr_adr); 793 device_remove_file(&dev->dev, &dev_attr_adr);
678 device_remove_file(&dev->dev, &dev_attr_modalias); 794 device_remove_file(&dev->dev, &dev_attr_modalias);
679 device_remove_file(&dev->dev, &dev_attr_hid); 795 device_remove_file(&dev->dev, &dev_attr_hid);
796 if (acpi_has_method(dev->handle, "_STA"))
797 device_remove_file(&dev->dev, &dev_attr_status);
680 if (dev->handle) 798 if (dev->handle)
681 device_remove_file(&dev->dev, &dev_attr_path); 799 device_remove_file(&dev->dev, &dev_attr_path);
682} 800}
@@ -782,8 +900,8 @@ static int acpi_device_uevent(struct device *dev, struct kobj_uevent_env *env)
782 return -ENOMEM; 900 return -ENOMEM;
783 len = create_modalias(acpi_dev, &env->buf[env->buflen - 1], 901 len = create_modalias(acpi_dev, &env->buf[env->buflen - 1],
784 sizeof(env->buf) - env->buflen); 902 sizeof(env->buf) - env->buflen);
785 if (len >= (sizeof(env->buf) - env->buflen)) 903 if (len <= 0)
786 return -ENOMEM; 904 return len;
787 env->buflen += len; 905 env->buflen += len;
788 return 0; 906 return 0;
789} 907}
@@ -907,9 +1025,91 @@ struct bus_type acpi_bus_type = {
907 .uevent = acpi_device_uevent, 1025 .uevent = acpi_device_uevent,
908}; 1026};
909 1027
910static void acpi_bus_data_handler(acpi_handle handle, void *context) 1028static void acpi_device_del(struct acpi_device *device)
1029{
1030 mutex_lock(&acpi_device_lock);
1031 if (device->parent)
1032 list_del(&device->node);
1033
1034 list_del(&device->wakeup_list);
1035 mutex_unlock(&acpi_device_lock);
1036
1037 acpi_power_add_remove_device(device, false);
1038 acpi_device_remove_files(device);
1039 if (device->remove)
1040 device->remove(device);
1041
1042 device_del(&device->dev);
1043}
1044
1045static LIST_HEAD(acpi_device_del_list);
1046static DEFINE_MUTEX(acpi_device_del_lock);
1047
1048static void acpi_device_del_work_fn(struct work_struct *work_not_used)
1049{
1050 for (;;) {
1051 struct acpi_device *adev;
1052
1053 mutex_lock(&acpi_device_del_lock);
1054
1055 if (list_empty(&acpi_device_del_list)) {
1056 mutex_unlock(&acpi_device_del_lock);
1057 break;
1058 }
1059 adev = list_first_entry(&acpi_device_del_list,
1060 struct acpi_device, del_list);
1061 list_del(&adev->del_list);
1062
1063 mutex_unlock(&acpi_device_del_lock);
1064
1065 acpi_device_del(adev);
1066 /*
1067 * Drop references to all power resources that might have been
1068 * used by the device.
1069 */
1070 acpi_power_transition(adev, ACPI_STATE_D3_COLD);
1071 put_device(&adev->dev);
1072 }
1073}
1074
1075/**
1076 * acpi_scan_drop_device - Drop an ACPI device object.
1077 * @handle: Handle of an ACPI namespace node, not used.
1078 * @context: Address of the ACPI device object to drop.
1079 *
1080 * This is invoked by acpi_ns_delete_node() during the removal of the ACPI
1081 * namespace node the device object pointed to by @context is attached to.
1082 *
1083 * The unregistration is carried out asynchronously to avoid running
1084 * acpi_device_del() under the ACPICA's namespace mutex and the list is used to
1085 * ensure the correct ordering (the device objects must be unregistered in the
1086 * same order in which the corresponding namespace nodes are deleted).
1087 */
1088static void acpi_scan_drop_device(acpi_handle handle, void *context)
911{ 1089{
912 /* Intentionally empty. */ 1090 static DECLARE_WORK(work, acpi_device_del_work_fn);
1091 struct acpi_device *adev = context;
1092
1093 mutex_lock(&acpi_device_del_lock);
1094
1095 /*
1096 * Use the ACPI hotplug workqueue which is ordered, so this work item
1097 * won't run after any hotplug work items submitted subsequently. That
1098 * prevents attempts to register device objects identical to those being
1099 * deleted from happening concurrently (such attempts result from
1100 * hotplug events handled via the ACPI hotplug workqueue). It also will
1101 * run after all of the work items submitted previosuly, which helps
1102 * those work items to ensure that they are not accessing stale device
1103 * objects.
1104 */
1105 if (list_empty(&acpi_device_del_list))
1106 acpi_queue_hotplug_work(&work);
1107
1108 list_add_tail(&adev->del_list, &acpi_device_del_list);
1109 /* Make acpi_ns_validate_handle() return NULL for this handle. */
1110 adev->handle = INVALID_ACPI_HANDLE;
1111
1112 mutex_unlock(&acpi_device_del_lock);
913} 1113}
914 1114
915int acpi_bus_get_device(acpi_handle handle, struct acpi_device **device) 1115int acpi_bus_get_device(acpi_handle handle, struct acpi_device **device)
@@ -919,7 +1119,7 @@ int acpi_bus_get_device(acpi_handle handle, struct acpi_device **device)
919 if (!device) 1119 if (!device)
920 return -EINVAL; 1120 return -EINVAL;
921 1121
922 status = acpi_get_data(handle, acpi_bus_data_handler, (void **)device); 1122 status = acpi_get_data(handle, acpi_scan_drop_device, (void **)device);
923 if (ACPI_FAILURE(status) || !*device) { 1123 if (ACPI_FAILURE(status) || !*device) {
924 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No context for object [%p]\n", 1124 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No context for object [%p]\n",
925 handle)); 1125 handle));
@@ -939,7 +1139,7 @@ int acpi_device_add(struct acpi_device *device,
939 if (device->handle) { 1139 if (device->handle) {
940 acpi_status status; 1140 acpi_status status;
941 1141
942 status = acpi_attach_data(device->handle, acpi_bus_data_handler, 1142 status = acpi_attach_data(device->handle, acpi_scan_drop_device,
943 device); 1143 device);
944 if (ACPI_FAILURE(status)) { 1144 if (ACPI_FAILURE(status)) {
945 acpi_handle_err(device->handle, 1145 acpi_handle_err(device->handle,
@@ -957,6 +1157,7 @@ int acpi_device_add(struct acpi_device *device,
957 INIT_LIST_HEAD(&device->node); 1157 INIT_LIST_HEAD(&device->node);
958 INIT_LIST_HEAD(&device->wakeup_list); 1158 INIT_LIST_HEAD(&device->wakeup_list);
959 INIT_LIST_HEAD(&device->physical_node_list); 1159 INIT_LIST_HEAD(&device->physical_node_list);
1160 INIT_LIST_HEAD(&device->del_list);
960 mutex_init(&device->physical_node_lock); 1161 mutex_init(&device->physical_node_lock);
961 1162
962 new_bus_id = kzalloc(sizeof(struct acpi_device_bus_id), GFP_KERNEL); 1163 new_bus_id = kzalloc(sizeof(struct acpi_device_bus_id), GFP_KERNEL);
@@ -1020,37 +1221,10 @@ int acpi_device_add(struct acpi_device *device,
1020 mutex_unlock(&acpi_device_lock); 1221 mutex_unlock(&acpi_device_lock);
1021 1222
1022 err_detach: 1223 err_detach:
1023 acpi_detach_data(device->handle, acpi_bus_data_handler); 1224 acpi_detach_data(device->handle, acpi_scan_drop_device);
1024 return result; 1225 return result;
1025} 1226}
1026 1227
1027static 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/* -------------------------------------------------------------------------- 1228/* --------------------------------------------------------------------------
1055 Driver Management 1229 Driver Management
1056 -------------------------------------------------------------------------- */ 1230 -------------------------------------------------------------------------- */
@@ -1624,11 +1798,13 @@ void acpi_init_device_object(struct acpi_device *device, acpi_handle handle,
1624 device->device_type = type; 1798 device->device_type = type;
1625 device->handle = handle; 1799 device->handle = handle;
1626 device->parent = acpi_bus_get_parent(handle); 1800 device->parent = acpi_bus_get_parent(handle);
1627 STRUCT_TO_INT(device->status) = sta; 1801 acpi_set_device_status(device, sta);
1628 acpi_device_get_busid(device); 1802 acpi_device_get_busid(device);
1629 acpi_set_pnp_ids(handle, &device->pnp, type); 1803 acpi_set_pnp_ids(handle, &device->pnp, type);
1630 acpi_bus_get_flags(device); 1804 acpi_bus_get_flags(device);
1631 device->flags.match_driver = false; 1805 device->flags.match_driver = false;
1806 device->flags.initialized = true;
1807 device->flags.visited = false;
1632 device_initialize(&device->dev); 1808 device_initialize(&device->dev);
1633 dev_set_uevent_suppress(&device->dev, true); 1809 dev_set_uevent_suppress(&device->dev, true);
1634} 1810}
@@ -1713,6 +1889,15 @@ static int acpi_bus_type_and_status(acpi_handle handle, int *type,
1713 return 0; 1889 return 0;
1714} 1890}
1715 1891
1892bool acpi_device_is_present(struct acpi_device *adev)
1893{
1894 if (adev->status.present || adev->status.functional)
1895 return true;
1896
1897 adev->flags.initialized = false;
1898 return false;
1899}
1900
1716static bool acpi_scan_handler_matching(struct acpi_scan_handler *handler, 1901static bool acpi_scan_handler_matching(struct acpi_scan_handler *handler,
1717 char *idstr, 1902 char *idstr,
1718 const struct acpi_device_id **matchid) 1903 const struct acpi_device_id **matchid)
@@ -1772,7 +1957,7 @@ static void acpi_scan_init_hotplug(acpi_handle handle, int type)
1772 */ 1957 */
1773 list_for_each_entry(hwid, &pnp.ids, list) { 1958 list_for_each_entry(hwid, &pnp.ids, list) {
1774 handler = acpi_scan_match_handler(hwid->id, NULL); 1959 handler = acpi_scan_match_handler(hwid->id, NULL);
1775 if (handler && !handler->hotplug.ignore) { 1960 if (handler) {
1776 acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY, 1961 acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY,
1777 acpi_hotplug_notify_cb, handler); 1962 acpi_hotplug_notify_cb, handler);
1778 break; 1963 break;
@@ -1806,18 +1991,6 @@ static acpi_status acpi_bus_check_add(acpi_handle handle, u32 lvl_not_used,
1806 1991
1807 acpi_scan_init_hotplug(handle, type); 1992 acpi_scan_init_hotplug(handle, type);
1808 1993
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); 1994 acpi_add_single_object(&device, handle, type, sta);
1822 if (!device) 1995 if (!device)
1823 return AE_CTRL_DEPTH; 1996 return AE_CTRL_DEPTH;
@@ -1852,36 +2025,40 @@ static int acpi_scan_attach_handler(struct acpi_device *device)
1852 return ret; 2025 return ret;
1853} 2026}
1854 2027
1855static acpi_status acpi_bus_device_attach(acpi_handle handle, u32 lvl_not_used, 2028static void acpi_bus_attach(struct acpi_device *device)
1856 void *not_used, void **ret_not_used)
1857{ 2029{
1858 struct acpi_device *device; 2030 struct acpi_device *child;
1859 unsigned long long sta_not_used;
1860 int ret; 2031 int ret;
1861 2032
1862 /* 2033 acpi_bus_get_status(device);
1863 * Ignore errors ignored by acpi_bus_check_add() to avoid terminating 2034 /* Skip devices that are not present. */
1864 * namespace walks prematurely. 2035 if (!acpi_device_is_present(device)) {
1865 */ 2036 device->flags.visited = false;
1866 if (acpi_bus_type_and_status(handle, &ret, &sta_not_used)) 2037 return;
1867 return AE_OK; 2038 }
1868
1869 if (acpi_bus_get_device(handle, &device))
1870 return AE_CTRL_DEPTH;
1871
1872 if (device->handler) 2039 if (device->handler)
1873 return AE_OK; 2040 goto ok;
1874 2041
2042 if (!device->flags.initialized) {
2043 acpi_bus_update_power(device, NULL);
2044 device->flags.initialized = true;
2045 }
2046 device->flags.visited = false;
1875 ret = acpi_scan_attach_handler(device); 2047 ret = acpi_scan_attach_handler(device);
1876 if (ret < 0) 2048 if (ret < 0)
1877 return AE_CTRL_DEPTH; 2049 return;
1878 2050
1879 device->flags.match_driver = true; 2051 device->flags.match_driver = true;
1880 if (ret > 0) 2052 if (!ret) {
1881 return AE_OK; 2053 ret = device_attach(&device->dev);
2054 if (ret < 0)
2055 return;
2056 }
2057 device->flags.visited = true;
1882 2058
1883 ret = device_attach(&device->dev); 2059 ok:
1884 return ret >= 0 ? AE_OK : AE_CTRL_DEPTH; 2060 list_for_each_entry(child, &device->children, node)
2061 acpi_bus_attach(child);
1885} 2062}
1886 2063
1887/** 2064/**
@@ -1901,75 +2078,48 @@ static acpi_status acpi_bus_device_attach(acpi_handle handle, u32 lvl_not_used,
1901int acpi_bus_scan(acpi_handle handle) 2078int acpi_bus_scan(acpi_handle handle)
1902{ 2079{
1903 void *device = NULL; 2080 void *device = NULL;
1904 int error = 0;
1905 2081
1906 if (ACPI_SUCCESS(acpi_bus_check_add(handle, 0, NULL, &device))) 2082 if (ACPI_SUCCESS(acpi_bus_check_add(handle, 0, NULL, &device)))
1907 acpi_walk_namespace(ACPI_TYPE_ANY, handle, ACPI_UINT32_MAX, 2083 acpi_walk_namespace(ACPI_TYPE_ANY, handle, ACPI_UINT32_MAX,
1908 acpi_bus_check_add, NULL, NULL, &device); 2084 acpi_bus_check_add, NULL, NULL, &device);
1909 2085
1910 if (!device) 2086 if (device) {
1911 error = -ENODEV; 2087 acpi_bus_attach(device);
1912 else if (ACPI_SUCCESS(acpi_bus_device_attach(handle, 0, NULL, NULL))) 2088 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}
1918EXPORT_SYMBOL(acpi_bus_scan);
1919
1920static 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 } 2089 }
1937 return AE_OK; 2090 return -ENODEV;
1938}
1939
1940static 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} 2091}
2092EXPORT_SYMBOL(acpi_bus_scan);
1950 2093
1951/** 2094/**
1952 * acpi_bus_trim - Remove ACPI device node and all of its descendants 2095 * acpi_bus_trim - Detach scan handlers and drivers from ACPI device objects.
1953 * @start: Root of the ACPI device nodes subtree to remove. 2096 * @adev: Root of the ACPI namespace scope to walk.
1954 * 2097 *
1955 * Must be called under acpi_scan_lock. 2098 * Must be called under acpi_scan_lock.
1956 */ 2099 */
1957void acpi_bus_trim(struct acpi_device *start) 2100void acpi_bus_trim(struct acpi_device *adev)
1958{ 2101{
2102 struct acpi_scan_handler *handler = adev->handler;
2103 struct acpi_device *child;
2104
2105 list_for_each_entry_reverse(child, &adev->children, node)
2106 acpi_bus_trim(child);
2107
2108 if (handler) {
2109 if (handler->detach)
2110 handler->detach(adev);
2111
2112 adev->handler = NULL;
2113 } else {
2114 device_release_driver(&adev->dev);
2115 }
1959 /* 2116 /*
1960 * Execute acpi_bus_device_detach() as a post-order callback to detach 2117 * Most likely, the device is going away, so put it into D3cold before
1961 * all ACPI drivers from the device nodes being removed. 2118 * 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 */ 2119 */
1970 acpi_walk_namespace(ACPI_TYPE_ANY, start->handle, ACPI_UINT32_MAX, NULL, 2120 acpi_device_set_power(adev, ACPI_STATE_D3_COLD);
1971 acpi_bus_remove, NULL, NULL); 2121 adev->flags.initialized = false;
1972 acpi_bus_remove(start->handle, 0, NULL, NULL); 2122 adev->flags.visited = false;
1973} 2123}
1974EXPORT_SYMBOL_GPL(acpi_bus_trim); 2124EXPORT_SYMBOL_GPL(acpi_bus_trim);
1975 2125
@@ -2047,14 +2197,14 @@ int __init acpi_scan_init(void)
2047 2197
2048 result = acpi_bus_scan_fixed(); 2198 result = acpi_bus_scan_fixed();
2049 if (result) { 2199 if (result) {
2050 acpi_device_unregister(acpi_root); 2200 acpi_detach_data(acpi_root->handle, acpi_scan_drop_device);
2201 acpi_device_del(acpi_root);
2202 put_device(&acpi_root->dev);
2051 goto out; 2203 goto out;
2052 } 2204 }
2053 2205
2054 acpi_update_all_gpes(); 2206 acpi_update_all_gpes();
2055 2207
2056 acpi_pci_root_hp_init();
2057
2058 out: 2208 out:
2059 mutex_unlock(&acpi_scan_lock); 2209 mutex_unlock(&acpi_scan_lock);
2060 return result; 2210 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 */
288int __init acpi_table_parse(char *id, acpi_tbl_table_handler handler) 289int __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
865static const struct thermal_zone_device_ops acpi_thermal_zone_ops = { 864static 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 */
590union acpi_object *
591acpi_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}
627EXPORT_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 */
641bool 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}
671EXPORT_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
51static acpi_status 51static acpi_status
52acpi_backlight_cap_match(acpi_handle handle, u32 level, void *context, 52acpi_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