aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2011-03-24 11:25:15 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2011-03-24 11:25:15 -0400
commit047f61c5d16d617e1df2deea5c5d5fb2a1b41c95 (patch)
tree75d51e1813664ad54fa680a0ecfb2b756d3d4b0f
parent05061bf678de5d69ebaae2c0705bf106e3000b6e (diff)
parent3d26678e8009b03f27674c2f9e5b236c2f627b14 (diff)
Merge branch 'release' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux-acpi-2.6
* 'release' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux-acpi-2.6: (42 commits) ACPI: minor printk format change in acpi_pad ACPI: make acpi_pad /sys output more readable ACPICA: Update version to 20110316 ACPICA: Header support for SLIC table ACPI: Make sure the FADT is at least rev 2 before using the reset register ACPI: Bug compatibility for Windows on the ACPI reboot vector ACPICA: Fix access width for reset vector ACPI battery: fribble sysfs files from a resume notifier ACPI button: remove unused procfs I/F ACPI, APEI, Add PCIe AER error information printing support PCIe, AER, use pre-generated prefix in error information printing ACPI, APEI, Add ERST record ID cache ACPI: Use syscore_ops instead of sysdev class and sysdev ACPI: Remove the unused EC sysdev class ACPI: use __cpuinit for the acpi_processor_set_pdc() call tree ACPI: use __init where possible in processor driver Thermal_Framework-Fix_crash_during_hwmon_unregister ACPICA: Update version to 20110211. ACPICA: Add mechanism to defer _REG methods for some installed handlers ACPICA: Add support for FunctionalFixedHW in acpi_ut_get_region_name ...
-rw-r--r--Documentation/acpi/apei/output_format.txt25
-rw-r--r--Documentation/feature-removal-schedule.txt8
-rw-r--r--arch/ia64/include/asm/acpi.h6
-rw-r--r--arch/ia64/kernel/acpi.c23
-rw-r--r--arch/x86/include/asm/acpi.h5
-rw-r--r--arch/x86/kernel/acpi/sleep.c12
-rw-r--r--arch/x86/kernel/acpi/sleep.h2
-rw-r--r--arch/x86/kernel/cpu/mcheck/mce-apei.c42
-rw-r--r--drivers/acpi/acpi_pad.c13
-rw-r--r--drivers/acpi/acpica/Makefile4
-rw-r--r--drivers/acpi/acpica/acdispat.h38
-rw-r--r--drivers/acpi/acpica/acglobal.h4
-rw-r--r--drivers/acpi/acpica/aclocal.h19
-rw-r--r--drivers/acpi/acpica/dsargs.c391
-rw-r--r--drivers/acpi/acpica/dscontrol.c410
-rw-r--r--drivers/acpi/acpica/dsopcode.c725
-rw-r--r--drivers/acpi/acpica/dswload.c670
-rw-r--r--drivers/acpi/acpica/dswload2.c720
-rw-r--r--drivers/acpi/acpica/evgpe.c9
-rw-r--r--drivers/acpi/acpica/evregion.c2
-rw-r--r--drivers/acpi/acpica/evxfregn.c34
-rw-r--r--drivers/acpi/acpica/exfldio.c4
-rw-r--r--drivers/acpi/acpica/hwxface.c10
-rw-r--r--drivers/acpi/acpica/tbfadt.c5
-rw-r--r--drivers/acpi/acpica/utdecode.c548
-rw-r--r--drivers/acpi/acpica/utglobal.c484
-rw-r--r--drivers/acpi/apei/Kconfig7
-rw-r--r--drivers/acpi/apei/cper.c18
-rw-r--r--drivers/acpi/apei/erst-dbg.c24
-rw-r--r--drivers/acpi/apei/erst.c235
-rw-r--r--drivers/acpi/battery.c22
-rw-r--r--drivers/acpi/button.c174
-rw-r--r--drivers/acpi/ec_sys.c4
-rw-r--r--drivers/acpi/internal.h3
-rw-r--r--drivers/acpi/nvs.c22
-rw-r--r--drivers/acpi/osl.c139
-rw-r--r--drivers/acpi/pci_link.c30
-rw-r--r--drivers/acpi/processor_core.c17
-rw-r--r--drivers/acpi/processor_driver.c4
-rw-r--r--drivers/acpi/reboot.c14
-rw-r--r--drivers/acpi/scan.c1
-rw-r--r--drivers/acpi/sleep.c28
-rw-r--r--drivers/pci/pci-acpi.c16
-rw-r--r--drivers/pci/pcie/aer/aerdrv.h9
-rw-r--r--drivers/pci/pcie/aer/aerdrv_errprint.c182
-rw-r--r--drivers/thermal/thermal_sys.c3
-rw-r--r--include/acpi/acoutput.h12
-rw-r--r--include/acpi/acpi_bus.h1
-rw-r--r--include/acpi/acpixf.h2
-rw-r--r--include/acpi/actbl.h16
-rw-r--r--include/acpi/actbl2.h64
-rw-r--r--include/acpi/apei.h5
-rw-r--r--include/linux/acpi_io.h3
-rw-r--r--include/linux/aer.h24
-rw-r--r--include/linux/cper.h2
55 files changed, 2920 insertions, 2374 deletions
diff --git a/Documentation/acpi/apei/output_format.txt b/Documentation/acpi/apei/output_format.txt
index 9146952c612a..0c49c197c47a 100644
--- a/Documentation/acpi/apei/output_format.txt
+++ b/Documentation/acpi/apei/output_format.txt
@@ -92,6 +92,11 @@ vendor_id: <integer>, device_id: <integer>
92class_code: <integer>] 92class_code: <integer>]
93[serial number: <integer>, <integer>] 93[serial number: <integer>, <integer>]
94[bridge: secondary_status: <integer>, control: <integer>] 94[bridge: secondary_status: <integer>, control: <integer>]
95[aer_status: <integer>, aer_mask: <integer>
96<aer status string>
97[aer_uncor_severity: <integer>]
98aer_layer=<aer layer string>, aer_agent=<aer agent string>
99aer_tlp_header: <integer> <integer> <integer> <integer>]
95 100
96<pcie port type string>* := PCIe end point | legacy PCI end point | \ 101<pcie port type string>* := PCIe end point | legacy PCI end point | \
97unknown | unknown | root port | upstream switch port | \ 102unknown | unknown | root port | upstream switch port | \
@@ -99,6 +104,26 @@ downstream switch port | PCIe to PCI/PCI-X bridge | \
99PCI/PCI-X to PCIe bridge | root complex integrated endpoint device | \ 104PCI/PCI-X to PCIe bridge | root complex integrated endpoint device | \
100root complex event collector 105root complex event collector
101 106
107if section severity is fatal or recoverable
108<aer status string># :=
109unknown | unknown | unknown | unknown | Data Link Protocol | \
110unknown | unknown | unknown | unknown | unknown | unknown | unknown | \
111Poisoned TLP | Flow Control Protocol | Completion Timeout | \
112Completer Abort | Unexpected Completion | Receiver Overflow | \
113Malformed TLP | ECRC | Unsupported Request
114else
115<aer status string># :=
116Receiver Error | unknown | unknown | unknown | unknown | unknown | \
117Bad TLP | Bad DLLP | RELAY_NUM Rollover | unknown | unknown | unknown | \
118Replay Timer Timeout | Advisory Non-Fatal
119fi
120
121<aer layer string> :=
122Physical Layer | Data Link Layer | Transaction Layer
123
124<aer agent string> :=
125Receiver ID | Requester ID | Completer ID | Transmitter ID
126
102Where, [] designate corresponding content is optional 127Where, [] designate corresponding content is optional
103 128
104All <field string> description with * has the following format: 129All <field string> description with * has the following format:
diff --git a/Documentation/feature-removal-schedule.txt b/Documentation/feature-removal-schedule.txt
index 895330940f5d..75c37e4c3d75 100644
--- a/Documentation/feature-removal-schedule.txt
+++ b/Documentation/feature-removal-schedule.txt
@@ -270,14 +270,6 @@ Who: Zhang Rui <rui.zhang@intel.com>
270 270
271--------------------------- 271---------------------------
272 272
273What: /proc/acpi/button
274When: August 2007
275Why: /proc/acpi/button has been replaced by events to the input layer
276 since 2.6.20.
277Who: Len Brown <len.brown@intel.com>
278
279---------------------------
280
281What: /proc/acpi/event 273What: /proc/acpi/event
282When: February 2008 274When: February 2008
283Why: /proc/acpi/event has been replaced by events via the input layer 275Why: /proc/acpi/event has been replaced by events via the input layer
diff --git a/arch/ia64/include/asm/acpi.h b/arch/ia64/include/asm/acpi.h
index 837dc82a013e..a06dfb13d518 100644
--- a/arch/ia64/include/asm/acpi.h
+++ b/arch/ia64/include/asm/acpi.h
@@ -128,9 +128,9 @@ static inline const char *acpi_get_sysname (void)
128int acpi_request_vector (u32 int_type); 128int acpi_request_vector (u32 int_type);
129int acpi_gsi_to_irq (u32 gsi, unsigned int *irq); 129int acpi_gsi_to_irq (u32 gsi, unsigned int *irq);
130 130
131/* routines for saving/restoring kernel state */ 131/* Low-level suspend routine. */
132extern int acpi_save_state_mem(void); 132extern int acpi_suspend_lowlevel(void);
133extern void acpi_restore_state_mem(void); 133
134extern unsigned long acpi_wakeup_address; 134extern unsigned long acpi_wakeup_address;
135 135
136/* 136/*
diff --git a/arch/ia64/kernel/acpi.c b/arch/ia64/kernel/acpi.c
index 90ebceb899a0..3be485a300b1 100644
--- a/arch/ia64/kernel/acpi.c
+++ b/arch/ia64/kernel/acpi.c
@@ -803,7 +803,7 @@ int acpi_isa_irq_to_gsi(unsigned isa_irq, u32 *gsi)
803 * ACPI based hotplug CPU support 803 * ACPI based hotplug CPU support
804 */ 804 */
805#ifdef CONFIG_ACPI_HOTPLUG_CPU 805#ifdef CONFIG_ACPI_HOTPLUG_CPU
806static 806static __cpuinit
807int acpi_map_cpu2node(acpi_handle handle, int cpu, int physid) 807int acpi_map_cpu2node(acpi_handle handle, int cpu, int physid)
808{ 808{
809#ifdef CONFIG_ACPI_NUMA 809#ifdef CONFIG_ACPI_NUMA
@@ -878,7 +878,7 @@ __init void prefill_possible_map(void)
878 set_cpu_possible(i, true); 878 set_cpu_possible(i, true);
879} 879}
880 880
881int acpi_map_lsapic(acpi_handle handle, int *pcpu) 881static int __cpuinit _acpi_map_lsapic(acpi_handle handle, int *pcpu)
882{ 882{
883 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; 883 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
884 union acpi_object *obj; 884 union acpi_object *obj;
@@ -929,6 +929,11 @@ int acpi_map_lsapic(acpi_handle handle, int *pcpu)
929 return (0); 929 return (0);
930} 930}
931 931
932/* wrapper to silence section mismatch warning */
933int __ref acpi_map_lsapic(acpi_handle handle, int *pcpu)
934{
935 return _acpi_map_lsapic(handle, pcpu);
936}
932EXPORT_SYMBOL(acpi_map_lsapic); 937EXPORT_SYMBOL(acpi_map_lsapic);
933 938
934int acpi_unmap_lsapic(int cpu) 939int acpi_unmap_lsapic(int cpu)
@@ -1034,18 +1039,8 @@ int acpi_unregister_ioapic(acpi_handle handle, u32 gsi_base)
1034EXPORT_SYMBOL(acpi_unregister_ioapic); 1039EXPORT_SYMBOL(acpi_unregister_ioapic);
1035 1040
1036/* 1041/*
1037 * acpi_save_state_mem() - save kernel state 1042 * acpi_suspend_lowlevel() - save kernel state and suspend.
1038 * 1043 *
1039 * TBD when when IA64 starts to support suspend... 1044 * TBD when when IA64 starts to support suspend...
1040 */ 1045 */
1041int acpi_save_state_mem(void) { return 0; } 1046int acpi_suspend_lowlevel(void) { return 0; }
1042
1043/*
1044 * acpi_restore_state()
1045 */
1046void acpi_restore_state_mem(void) {}
1047
1048/*
1049 * do_suspend_lowlevel()
1050 */
1051void do_suspend_lowlevel(void) {}
diff --git a/arch/x86/include/asm/acpi.h b/arch/x86/include/asm/acpi.h
index 448d73a371ba..12e0e7dd869c 100644
--- a/arch/x86/include/asm/acpi.h
+++ b/arch/x86/include/asm/acpi.h
@@ -114,9 +114,8 @@ static inline void acpi_disable_pci(void)
114 acpi_noirq_set(); 114 acpi_noirq_set();
115} 115}
116 116
117/* routines for saving/restoring kernel state */ 117/* Low-level suspend routine. */
118extern int acpi_save_state_mem(void); 118extern int acpi_suspend_lowlevel(void);
119extern void acpi_restore_state_mem(void);
120 119
121extern const unsigned char acpi_wakeup_code[]; 120extern const unsigned char acpi_wakeup_code[];
122#define acpi_wakeup_address (__pa(TRAMPOLINE_SYM(acpi_wakeup_code))) 121#define acpi_wakeup_address (__pa(TRAMPOLINE_SYM(acpi_wakeup_code)))
diff --git a/arch/x86/kernel/acpi/sleep.c b/arch/x86/kernel/acpi/sleep.c
index 4572c58e66d5..ff93bc1b09c3 100644
--- a/arch/x86/kernel/acpi/sleep.c
+++ b/arch/x86/kernel/acpi/sleep.c
@@ -25,12 +25,12 @@ static char temp_stack[4096];
25#endif 25#endif
26 26
27/** 27/**
28 * acpi_save_state_mem - save kernel state 28 * acpi_suspend_lowlevel - save kernel state
29 * 29 *
30 * Create an identity mapped page table and copy the wakeup routine to 30 * Create an identity mapped page table and copy the wakeup routine to
31 * low memory. 31 * low memory.
32 */ 32 */
33int acpi_save_state_mem(void) 33int acpi_suspend_lowlevel(void)
34{ 34{
35 struct wakeup_header *header; 35 struct wakeup_header *header;
36 /* address in low memory of the wakeup routine. */ 36 /* address in low memory of the wakeup routine. */
@@ -96,16 +96,10 @@ int acpi_save_state_mem(void)
96 saved_magic = 0x123456789abcdef0L; 96 saved_magic = 0x123456789abcdef0L;
97#endif /* CONFIG_64BIT */ 97#endif /* CONFIG_64BIT */
98 98
99 do_suspend_lowlevel();
99 return 0; 100 return 0;
100} 101}
101 102
102/*
103 * acpi_restore_state - undo effects of acpi_save_state_mem
104 */
105void acpi_restore_state_mem(void)
106{
107}
108
109static int __init acpi_sleep_setup(char *str) 103static int __init acpi_sleep_setup(char *str)
110{ 104{
111 while ((str != NULL) && (*str != '\0')) { 105 while ((str != NULL) && (*str != '\0')) {
diff --git a/arch/x86/kernel/acpi/sleep.h b/arch/x86/kernel/acpi/sleep.h
index 86ba1c87165b..416d4be13fef 100644
--- a/arch/x86/kernel/acpi/sleep.h
+++ b/arch/x86/kernel/acpi/sleep.h
@@ -11,3 +11,5 @@ extern int wakeup_pmode_return;
11 11
12extern unsigned long acpi_copy_wakeup_routine(unsigned long); 12extern unsigned long acpi_copy_wakeup_routine(unsigned long);
13extern void wakeup_long64(void); 13extern void wakeup_long64(void);
14
15extern void do_suspend_lowlevel(void);
diff --git a/arch/x86/kernel/cpu/mcheck/mce-apei.c b/arch/x86/kernel/cpu/mcheck/mce-apei.c
index 8209472b27a5..83930deec3c6 100644
--- a/arch/x86/kernel/cpu/mcheck/mce-apei.c
+++ b/arch/x86/kernel/cpu/mcheck/mce-apei.c
@@ -106,24 +106,34 @@ int apei_write_mce(struct mce *m)
106ssize_t apei_read_mce(struct mce *m, u64 *record_id) 106ssize_t apei_read_mce(struct mce *m, u64 *record_id)
107{ 107{
108 struct cper_mce_record rcd; 108 struct cper_mce_record rcd;
109 ssize_t len; 109 int rc, pos;
110 110
111 len = erst_read_next(&rcd.hdr, sizeof(rcd)); 111 rc = erst_get_record_id_begin(&pos);
112 if (len <= 0) 112 if (rc)
113 return len; 113 return rc;
114 /* Can not skip other records in storage via ERST unless clear them */ 114retry:
115 else if (len != sizeof(rcd) || 115 rc = erst_get_record_id_next(&pos, record_id);
116 uuid_le_cmp(rcd.hdr.creator_id, CPER_CREATOR_MCE)) { 116 if (rc)
117 if (printk_ratelimit()) 117 goto out;
118 pr_warning( 118 /* no more record */
119 "MCE-APEI: Can not skip the unknown record in ERST"); 119 if (*record_id == APEI_ERST_INVALID_RECORD_ID)
120 return -EIO; 120 goto out;
121 } 121 rc = erst_read(*record_id, &rcd.hdr, sizeof(rcd));
122 122 /* someone else has cleared the record, try next one */
123 if (rc == -ENOENT)
124 goto retry;
125 else if (rc < 0)
126 goto out;
127 /* try to skip other type records in storage */
128 else if (rc != sizeof(rcd) ||
129 uuid_le_cmp(rcd.hdr.creator_id, CPER_CREATOR_MCE))
130 goto retry;
123 memcpy(m, &rcd.mce, sizeof(*m)); 131 memcpy(m, &rcd.mce, sizeof(*m));
124 *record_id = rcd.hdr.record_id; 132 rc = sizeof(*m);
133out:
134 erst_get_record_id_end();
125 135
126 return sizeof(*m); 136 return rc;
127} 137}
128 138
129/* Check whether there is record in ERST */ 139/* Check whether there is record in ERST */
diff --git a/drivers/acpi/acpi_pad.c b/drivers/acpi/acpi_pad.c
index 6afceb3d4034..a43fa1a57d57 100644
--- a/drivers/acpi/acpi_pad.c
+++ b/drivers/acpi/acpi_pad.c
@@ -298,7 +298,7 @@ static ssize_t acpi_pad_rrtime_store(struct device *dev,
298static ssize_t acpi_pad_rrtime_show(struct device *dev, 298static ssize_t acpi_pad_rrtime_show(struct device *dev,
299 struct device_attribute *attr, char *buf) 299 struct device_attribute *attr, char *buf)
300{ 300{
301 return scnprintf(buf, PAGE_SIZE, "%d", round_robin_time); 301 return scnprintf(buf, PAGE_SIZE, "%d\n", round_robin_time);
302} 302}
303static DEVICE_ATTR(rrtime, S_IRUGO|S_IWUSR, 303static DEVICE_ATTR(rrtime, S_IRUGO|S_IWUSR,
304 acpi_pad_rrtime_show, 304 acpi_pad_rrtime_show,
@@ -321,7 +321,7 @@ static ssize_t acpi_pad_idlepct_store(struct device *dev,
321static ssize_t acpi_pad_idlepct_show(struct device *dev, 321static ssize_t acpi_pad_idlepct_show(struct device *dev,
322 struct device_attribute *attr, char *buf) 322 struct device_attribute *attr, char *buf)
323{ 323{
324 return scnprintf(buf, PAGE_SIZE, "%d", idle_pct); 324 return scnprintf(buf, PAGE_SIZE, "%d\n", idle_pct);
325} 325}
326static DEVICE_ATTR(idlepct, S_IRUGO|S_IWUSR, 326static DEVICE_ATTR(idlepct, S_IRUGO|S_IWUSR,
327 acpi_pad_idlepct_show, 327 acpi_pad_idlepct_show,
@@ -342,8 +342,11 @@ static ssize_t acpi_pad_idlecpus_store(struct device *dev,
342static ssize_t acpi_pad_idlecpus_show(struct device *dev, 342static ssize_t acpi_pad_idlecpus_show(struct device *dev,
343 struct device_attribute *attr, char *buf) 343 struct device_attribute *attr, char *buf)
344{ 344{
345 return cpumask_scnprintf(buf, PAGE_SIZE, 345 int n = 0;
346 to_cpumask(pad_busy_cpus_bits)); 346 n = cpumask_scnprintf(buf, PAGE_SIZE-2, to_cpumask(pad_busy_cpus_bits));
347 buf[n++] = '\n';
348 buf[n] = '\0';
349 return n;
347} 350}
348static DEVICE_ATTR(idlecpus, S_IRUGO|S_IWUSR, 351static DEVICE_ATTR(idlecpus, S_IRUGO|S_IWUSR,
349 acpi_pad_idlecpus_show, 352 acpi_pad_idlecpus_show,
@@ -453,7 +456,7 @@ static void acpi_pad_notify(acpi_handle handle, u32 event,
453 dev_name(&device->dev), event, 0); 456 dev_name(&device->dev), event, 0);
454 break; 457 break;
455 default: 458 default:
456 printk(KERN_WARNING"Unsupported event [0x%x]\n", event); 459 printk(KERN_WARNING "Unsupported event [0x%x]\n", event);
457 break; 460 break;
458 } 461 }
459} 462}
diff --git a/drivers/acpi/acpica/Makefile b/drivers/acpi/acpica/Makefile
index eec2eadd2431..a1224712fd0c 100644
--- a/drivers/acpi/acpica/Makefile
+++ b/drivers/acpi/acpica/Makefile
@@ -10,7 +10,7 @@ obj-y += acpi.o
10 10
11acpi-y := dsfield.o dsmthdat.o dsopcode.o dswexec.o dswscope.o \ 11acpi-y := dsfield.o dsmthdat.o dsopcode.o dswexec.o dswscope.o \
12 dsmethod.o dsobject.o dsutils.o dswload.o dswstate.o \ 12 dsmethod.o dsobject.o dsutils.o dswload.o dswstate.o \
13 dsinit.o 13 dsinit.o dsargs.o dscontrol.o dswload2.o
14 14
15acpi-y += evevent.o evregion.o evsci.o evxfevnt.o \ 15acpi-y += evevent.o evregion.o evsci.o evxfevnt.o \
16 evmisc.o evrgnini.o evxface.o evxfregn.o \ 16 evmisc.o evrgnini.o evxface.o evxfregn.o \
@@ -45,4 +45,4 @@ acpi-y += tbxface.o tbinstal.o tbutils.o tbfind.o tbfadt.o tbxfroot.o
45acpi-y += utalloc.o utdebug.o uteval.o utinit.o utmisc.o utxface.o \ 45acpi-y += utalloc.o utdebug.o uteval.o utinit.o utmisc.o utxface.o \
46 utcopy.o utdelete.o utglobal.o utmath.o utobject.o \ 46 utcopy.o utdelete.o utglobal.o utmath.o utobject.o \
47 utstate.o utmutex.o utobject.o utresrc.o utlock.o utids.o \ 47 utstate.o utmutex.o utobject.o utresrc.o utlock.o utids.o \
48 utosi.o utxferror.o 48 utosi.o utxferror.o utdecode.o
diff --git a/drivers/acpi/acpica/acdispat.h b/drivers/acpi/acpica/acdispat.h
index 666271b65418..2d1b7ffa377a 100644
--- a/drivers/acpi/acpica/acdispat.h
+++ b/drivers/acpi/acpica/acdispat.h
@@ -48,7 +48,7 @@
48#define NAMEOF_ARG_NTE "__A0" 48#define NAMEOF_ARG_NTE "__A0"
49 49
50/* 50/*
51 * dsopcode - support for late evaluation 51 * dsargs - execution of dynamic arguments for static objects
52 */ 52 */
53acpi_status 53acpi_status
54acpi_ds_get_buffer_field_arguments(union acpi_operand_object *obj_desc); 54acpi_ds_get_buffer_field_arguments(union acpi_operand_object *obj_desc);
@@ -62,6 +62,20 @@ acpi_status acpi_ds_get_buffer_arguments(union acpi_operand_object *obj_desc);
62 62
63acpi_status acpi_ds_get_package_arguments(union acpi_operand_object *obj_desc); 63acpi_status acpi_ds_get_package_arguments(union acpi_operand_object *obj_desc);
64 64
65/*
66 * dscontrol - support for execution control opcodes
67 */
68acpi_status
69acpi_ds_exec_begin_control_op(struct acpi_walk_state *walk_state,
70 union acpi_parse_object *op);
71
72acpi_status
73acpi_ds_exec_end_control_op(struct acpi_walk_state *walk_state,
74 union acpi_parse_object *op);
75
76/*
77 * dsopcode - support for late operand evaluation
78 */
65acpi_status 79acpi_status
66acpi_ds_eval_buffer_field_operands(struct acpi_walk_state *walk_state, 80acpi_ds_eval_buffer_field_operands(struct acpi_walk_state *walk_state,
67 union acpi_parse_object *op); 81 union acpi_parse_object *op);
@@ -86,17 +100,6 @@ acpi_ds_eval_bank_field_operands(struct acpi_walk_state *walk_state,
86acpi_status acpi_ds_initialize_region(acpi_handle obj_handle); 100acpi_status acpi_ds_initialize_region(acpi_handle obj_handle);
87 101
88/* 102/*
89 * dsctrl - Parser/Interpreter interface, control stack routines
90 */
91acpi_status
92acpi_ds_exec_begin_control_op(struct acpi_walk_state *walk_state,
93 union acpi_parse_object *op);
94
95acpi_status
96acpi_ds_exec_end_control_op(struct acpi_walk_state *walk_state,
97 union acpi_parse_object *op);
98
99/*
100 * dsexec - Parser/Interpreter interface, method execution callbacks 103 * dsexec - Parser/Interpreter interface, method execution callbacks
101 */ 104 */
102acpi_status 105acpi_status
@@ -136,23 +139,26 @@ acpi_ds_init_field_objects(union acpi_parse_object *op,
136 struct acpi_walk_state *walk_state); 139 struct acpi_walk_state *walk_state);
137 140
138/* 141/*
139 * dsload - Parser/Interpreter interface, namespace load callbacks 142 * dsload - Parser/Interpreter interface, pass 1 namespace load callbacks
140 */ 143 */
141acpi_status 144acpi_status
145acpi_ds_init_callbacks(struct acpi_walk_state *walk_state, u32 pass_number);
146
147acpi_status
142acpi_ds_load1_begin_op(struct acpi_walk_state *walk_state, 148acpi_ds_load1_begin_op(struct acpi_walk_state *walk_state,
143 union acpi_parse_object **out_op); 149 union acpi_parse_object **out_op);
144 150
145acpi_status acpi_ds_load1_end_op(struct acpi_walk_state *walk_state); 151acpi_status acpi_ds_load1_end_op(struct acpi_walk_state *walk_state);
146 152
153/*
154 * dsload - Parser/Interpreter interface, pass 2 namespace load callbacks
155 */
147acpi_status 156acpi_status
148acpi_ds_load2_begin_op(struct acpi_walk_state *walk_state, 157acpi_ds_load2_begin_op(struct acpi_walk_state *walk_state,
149 union acpi_parse_object **out_op); 158 union acpi_parse_object **out_op);
150 159
151acpi_status acpi_ds_load2_end_op(struct acpi_walk_state *walk_state); 160acpi_status acpi_ds_load2_end_op(struct acpi_walk_state *walk_state);
152 161
153acpi_status
154acpi_ds_init_callbacks(struct acpi_walk_state *walk_state, u32 pass_number);
155
156/* 162/*
157 * dsmthdat - method data (locals/args) 163 * dsmthdat - method data (locals/args)
158 */ 164 */
diff --git a/drivers/acpi/acpica/acglobal.h b/drivers/acpi/acpica/acglobal.h
index 82a1bd283db8..d69750b83b36 100644
--- a/drivers/acpi/acpica/acglobal.h
+++ b/drivers/acpi/acpica/acglobal.h
@@ -273,6 +273,10 @@ ACPI_EXTERN u32 acpi_gbl_owner_id_mask[ACPI_NUM_OWNERID_MASKS];
273ACPI_EXTERN u8 acpi_gbl_last_owner_id_index; 273ACPI_EXTERN u8 acpi_gbl_last_owner_id_index;
274ACPI_EXTERN u8 acpi_gbl_next_owner_id_offset; 274ACPI_EXTERN u8 acpi_gbl_next_owner_id_offset;
275 275
276/* Initialization sequencing */
277
278ACPI_EXTERN u8 acpi_gbl_reg_methods_executed;
279
276/* Misc */ 280/* Misc */
277 281
278ACPI_EXTERN u32 acpi_gbl_original_mode; 282ACPI_EXTERN u32 acpi_gbl_original_mode;
diff --git a/drivers/acpi/acpica/aclocal.h b/drivers/acpi/acpica/aclocal.h
index edc25867ad9d..c7f743ca395b 100644
--- a/drivers/acpi/acpica/aclocal.h
+++ b/drivers/acpi/acpica/aclocal.h
@@ -89,25 +89,6 @@ union acpi_parse_object;
89#define ACPI_MAX_MUTEX 7 89#define ACPI_MAX_MUTEX 7
90#define ACPI_NUM_MUTEX ACPI_MAX_MUTEX+1 90#define ACPI_NUM_MUTEX ACPI_MAX_MUTEX+1
91 91
92#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
93#ifdef DEFINE_ACPI_GLOBALS
94
95/* Debug names for the mutexes above */
96
97static char *acpi_gbl_mutex_names[ACPI_NUM_MUTEX] = {
98 "ACPI_MTX_Interpreter",
99 "ACPI_MTX_Namespace",
100 "ACPI_MTX_Tables",
101 "ACPI_MTX_Events",
102 "ACPI_MTX_Caches",
103 "ACPI_MTX_Memory",
104 "ACPI_MTX_CommandComplete",
105 "ACPI_MTX_CommandReady"
106};
107
108#endif
109#endif
110
111/* Lock structure for reader/writer interfaces */ 92/* Lock structure for reader/writer interfaces */
112 93
113struct acpi_rw_lock { 94struct acpi_rw_lock {
diff --git a/drivers/acpi/acpica/dsargs.c b/drivers/acpi/acpica/dsargs.c
new file mode 100644
index 000000000000..8c7b99728aa2
--- /dev/null
+++ b/drivers/acpi/acpica/dsargs.c
@@ -0,0 +1,391 @@
1/******************************************************************************
2 *
3 * Module Name: dsargs - Support for execution of dynamic arguments for static
4 * objects (regions, fields, buffer fields, etc.)
5 *
6 *****************************************************************************/
7
8/*
9 * Copyright (C) 2000 - 2011, Intel Corp.
10 * All rights reserved.
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions, and the following disclaimer,
17 * without modification.
18 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
19 * substantially similar to the "NO WARRANTY" disclaimer below
20 * ("Disclaimer") and any redistribution must be conditioned upon
21 * including a substantially similar Disclaimer requirement for further
22 * binary redistribution.
23 * 3. Neither the names of the above-listed copyright holders nor the names
24 * of any contributors may be used to endorse or promote products derived
25 * from this software without specific prior written permission.
26 *
27 * Alternatively, this software may be distributed under the terms of the
28 * GNU General Public License ("GPL") version 2 as published by the Free
29 * Software Foundation.
30 *
31 * NO WARRANTY
32 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
33 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
34 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
35 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
36 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
37 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
38 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
39 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
40 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
41 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
42 * POSSIBILITY OF SUCH DAMAGES.
43 */
44
45#include <acpi/acpi.h>
46#include "accommon.h"
47#include "acparser.h"
48#include "amlcode.h"
49#include "acdispat.h"
50#include "acnamesp.h"
51
52#define _COMPONENT ACPI_DISPATCHER
53ACPI_MODULE_NAME("dsargs")
54
55/* Local prototypes */
56static acpi_status
57acpi_ds_execute_arguments(struct acpi_namespace_node *node,
58 struct acpi_namespace_node *scope_node,
59 u32 aml_length, u8 *aml_start);
60
61/*******************************************************************************
62 *
63 * FUNCTION: acpi_ds_execute_arguments
64 *
65 * PARAMETERS: Node - Object NS node
66 * scope_node - Parent NS node
67 * aml_length - Length of executable AML
68 * aml_start - Pointer to the AML
69 *
70 * RETURN: Status.
71 *
72 * DESCRIPTION: Late (deferred) execution of region or field arguments
73 *
74 ******************************************************************************/
75
76static acpi_status
77acpi_ds_execute_arguments(struct acpi_namespace_node *node,
78 struct acpi_namespace_node *scope_node,
79 u32 aml_length, u8 *aml_start)
80{
81 acpi_status status;
82 union acpi_parse_object *op;
83 struct acpi_walk_state *walk_state;
84
85 ACPI_FUNCTION_TRACE(ds_execute_arguments);
86
87 /* Allocate a new parser op to be the root of the parsed tree */
88
89 op = acpi_ps_alloc_op(AML_INT_EVAL_SUBTREE_OP);
90 if (!op) {
91 return_ACPI_STATUS(AE_NO_MEMORY);
92 }
93
94 /* Save the Node for use in acpi_ps_parse_aml */
95
96 op->common.node = scope_node;
97
98 /* Create and initialize a new parser state */
99
100 walk_state = acpi_ds_create_walk_state(0, NULL, NULL, NULL);
101 if (!walk_state) {
102 status = AE_NO_MEMORY;
103 goto cleanup;
104 }
105
106 status = acpi_ds_init_aml_walk(walk_state, op, NULL, aml_start,
107 aml_length, NULL, ACPI_IMODE_LOAD_PASS1);
108 if (ACPI_FAILURE(status)) {
109 acpi_ds_delete_walk_state(walk_state);
110 goto cleanup;
111 }
112
113 /* Mark this parse as a deferred opcode */
114
115 walk_state->parse_flags = ACPI_PARSE_DEFERRED_OP;
116 walk_state->deferred_node = node;
117
118 /* Pass1: Parse the entire declaration */
119
120 status = acpi_ps_parse_aml(walk_state);
121 if (ACPI_FAILURE(status)) {
122 goto cleanup;
123 }
124
125 /* Get and init the Op created above */
126
127 op->common.node = node;
128 acpi_ps_delete_parse_tree(op);
129
130 /* Evaluate the deferred arguments */
131
132 op = acpi_ps_alloc_op(AML_INT_EVAL_SUBTREE_OP);
133 if (!op) {
134 return_ACPI_STATUS(AE_NO_MEMORY);
135 }
136
137 op->common.node = scope_node;
138
139 /* Create and initialize a new parser state */
140
141 walk_state = acpi_ds_create_walk_state(0, NULL, NULL, NULL);
142 if (!walk_state) {
143 status = AE_NO_MEMORY;
144 goto cleanup;
145 }
146
147 /* Execute the opcode and arguments */
148
149 status = acpi_ds_init_aml_walk(walk_state, op, NULL, aml_start,
150 aml_length, NULL, ACPI_IMODE_EXECUTE);
151 if (ACPI_FAILURE(status)) {
152 acpi_ds_delete_walk_state(walk_state);
153 goto cleanup;
154 }
155
156 /* Mark this execution as a deferred opcode */
157
158 walk_state->deferred_node = node;
159 status = acpi_ps_parse_aml(walk_state);
160
161 cleanup:
162 acpi_ps_delete_parse_tree(op);
163 return_ACPI_STATUS(status);
164}
165
166/*******************************************************************************
167 *
168 * FUNCTION: acpi_ds_get_buffer_field_arguments
169 *
170 * PARAMETERS: obj_desc - A valid buffer_field object
171 *
172 * RETURN: Status.
173 *
174 * DESCRIPTION: Get buffer_field Buffer and Index. This implements the late
175 * evaluation of these field attributes.
176 *
177 ******************************************************************************/
178
179acpi_status
180acpi_ds_get_buffer_field_arguments(union acpi_operand_object *obj_desc)
181{
182 union acpi_operand_object *extra_desc;
183 struct acpi_namespace_node *node;
184 acpi_status status;
185
186 ACPI_FUNCTION_TRACE_PTR(ds_get_buffer_field_arguments, obj_desc);
187
188 if (obj_desc->common.flags & AOPOBJ_DATA_VALID) {
189 return_ACPI_STATUS(AE_OK);
190 }
191
192 /* Get the AML pointer (method object) and buffer_field node */
193
194 extra_desc = acpi_ns_get_secondary_object(obj_desc);
195 node = obj_desc->buffer_field.node;
196
197 ACPI_DEBUG_EXEC(acpi_ut_display_init_pathname(ACPI_TYPE_BUFFER_FIELD,
198 node, NULL));
199
200 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "[%4.4s] BufferField Arg Init\n",
201 acpi_ut_get_node_name(node)));
202
203 /* Execute the AML code for the term_arg arguments */
204
205 status = acpi_ds_execute_arguments(node, node->parent,
206 extra_desc->extra.aml_length,
207 extra_desc->extra.aml_start);
208 return_ACPI_STATUS(status);
209}
210
211/*******************************************************************************
212 *
213 * FUNCTION: acpi_ds_get_bank_field_arguments
214 *
215 * PARAMETERS: obj_desc - A valid bank_field object
216 *
217 * RETURN: Status.
218 *
219 * DESCRIPTION: Get bank_field bank_value. This implements the late
220 * evaluation of these field attributes.
221 *
222 ******************************************************************************/
223
224acpi_status
225acpi_ds_get_bank_field_arguments(union acpi_operand_object *obj_desc)
226{
227 union acpi_operand_object *extra_desc;
228 struct acpi_namespace_node *node;
229 acpi_status status;
230
231 ACPI_FUNCTION_TRACE_PTR(ds_get_bank_field_arguments, obj_desc);
232
233 if (obj_desc->common.flags & AOPOBJ_DATA_VALID) {
234 return_ACPI_STATUS(AE_OK);
235 }
236
237 /* Get the AML pointer (method object) and bank_field node */
238
239 extra_desc = acpi_ns_get_secondary_object(obj_desc);
240 node = obj_desc->bank_field.node;
241
242 ACPI_DEBUG_EXEC(acpi_ut_display_init_pathname
243 (ACPI_TYPE_LOCAL_BANK_FIELD, node, NULL));
244
245 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "[%4.4s] BankField Arg Init\n",
246 acpi_ut_get_node_name(node)));
247
248 /* Execute the AML code for the term_arg arguments */
249
250 status = acpi_ds_execute_arguments(node, node->parent,
251 extra_desc->extra.aml_length,
252 extra_desc->extra.aml_start);
253 return_ACPI_STATUS(status);
254}
255
256/*******************************************************************************
257 *
258 * FUNCTION: acpi_ds_get_buffer_arguments
259 *
260 * PARAMETERS: obj_desc - A valid Buffer object
261 *
262 * RETURN: Status.
263 *
264 * DESCRIPTION: Get Buffer length and initializer byte list. This implements
265 * the late evaluation of these attributes.
266 *
267 ******************************************************************************/
268
269acpi_status acpi_ds_get_buffer_arguments(union acpi_operand_object *obj_desc)
270{
271 struct acpi_namespace_node *node;
272 acpi_status status;
273
274 ACPI_FUNCTION_TRACE_PTR(ds_get_buffer_arguments, obj_desc);
275
276 if (obj_desc->common.flags & AOPOBJ_DATA_VALID) {
277 return_ACPI_STATUS(AE_OK);
278 }
279
280 /* Get the Buffer node */
281
282 node = obj_desc->buffer.node;
283 if (!node) {
284 ACPI_ERROR((AE_INFO,
285 "No pointer back to namespace node in buffer object %p",
286 obj_desc));
287 return_ACPI_STATUS(AE_AML_INTERNAL);
288 }
289
290 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Buffer Arg Init\n"));
291
292 /* Execute the AML code for the term_arg arguments */
293
294 status = acpi_ds_execute_arguments(node, node,
295 obj_desc->buffer.aml_length,
296 obj_desc->buffer.aml_start);
297 return_ACPI_STATUS(status);
298}
299
300/*******************************************************************************
301 *
302 * FUNCTION: acpi_ds_get_package_arguments
303 *
304 * PARAMETERS: obj_desc - A valid Package object
305 *
306 * RETURN: Status.
307 *
308 * DESCRIPTION: Get Package length and initializer byte list. This implements
309 * the late evaluation of these attributes.
310 *
311 ******************************************************************************/
312
313acpi_status acpi_ds_get_package_arguments(union acpi_operand_object *obj_desc)
314{
315 struct acpi_namespace_node *node;
316 acpi_status status;
317
318 ACPI_FUNCTION_TRACE_PTR(ds_get_package_arguments, obj_desc);
319
320 if (obj_desc->common.flags & AOPOBJ_DATA_VALID) {
321 return_ACPI_STATUS(AE_OK);
322 }
323
324 /* Get the Package node */
325
326 node = obj_desc->package.node;
327 if (!node) {
328 ACPI_ERROR((AE_INFO,
329 "No pointer back to namespace node in package %p",
330 obj_desc));
331 return_ACPI_STATUS(AE_AML_INTERNAL);
332 }
333
334 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Package Arg Init\n"));
335
336 /* Execute the AML code for the term_arg arguments */
337
338 status = acpi_ds_execute_arguments(node, node,
339 obj_desc->package.aml_length,
340 obj_desc->package.aml_start);
341 return_ACPI_STATUS(status);
342}
343
344/*******************************************************************************
345 *
346 * FUNCTION: acpi_ds_get_region_arguments
347 *
348 * PARAMETERS: obj_desc - A valid region object
349 *
350 * RETURN: Status.
351 *
352 * DESCRIPTION: Get region address and length. This implements the late
353 * evaluation of these region attributes.
354 *
355 ******************************************************************************/
356
357acpi_status acpi_ds_get_region_arguments(union acpi_operand_object *obj_desc)
358{
359 struct acpi_namespace_node *node;
360 acpi_status status;
361 union acpi_operand_object *extra_desc;
362
363 ACPI_FUNCTION_TRACE_PTR(ds_get_region_arguments, obj_desc);
364
365 if (obj_desc->region.flags & AOPOBJ_DATA_VALID) {
366 return_ACPI_STATUS(AE_OK);
367 }
368
369 extra_desc = acpi_ns_get_secondary_object(obj_desc);
370 if (!extra_desc) {
371 return_ACPI_STATUS(AE_NOT_EXIST);
372 }
373
374 /* Get the Region node */
375
376 node = obj_desc->region.node;
377
378 ACPI_DEBUG_EXEC(acpi_ut_display_init_pathname
379 (ACPI_TYPE_REGION, node, NULL));
380
381 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "[%4.4s] OpRegion Arg Init at AML %p\n",
382 acpi_ut_get_node_name(node),
383 extra_desc->extra.aml_start));
384
385 /* Execute the argument AML */
386
387 status = acpi_ds_execute_arguments(node, node->parent,
388 extra_desc->extra.aml_length,
389 extra_desc->extra.aml_start);
390 return_ACPI_STATUS(status);
391}
diff --git a/drivers/acpi/acpica/dscontrol.c b/drivers/acpi/acpica/dscontrol.c
new file mode 100644
index 000000000000..26c49fff58da
--- /dev/null
+++ b/drivers/acpi/acpica/dscontrol.c
@@ -0,0 +1,410 @@
1/******************************************************************************
2 *
3 * Module Name: dscontrol - Support for execution control opcodes -
4 * if/else/while/return
5 *
6 *****************************************************************************/
7
8/*
9 * Copyright (C) 2000 - 2011, Intel Corp.
10 * All rights reserved.
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions, and the following disclaimer,
17 * without modification.
18 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
19 * substantially similar to the "NO WARRANTY" disclaimer below
20 * ("Disclaimer") and any redistribution must be conditioned upon
21 * including a substantially similar Disclaimer requirement for further
22 * binary redistribution.
23 * 3. Neither the names of the above-listed copyright holders nor the names
24 * of any contributors may be used to endorse or promote products derived
25 * from this software without specific prior written permission.
26 *
27 * Alternatively, this software may be distributed under the terms of the
28 * GNU General Public License ("GPL") version 2 as published by the Free
29 * Software Foundation.
30 *
31 * NO WARRANTY
32 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
33 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
34 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
35 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
36 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
37 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
38 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
39 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
40 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
41 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
42 * POSSIBILITY OF SUCH DAMAGES.
43 */
44
45#include <acpi/acpi.h>
46#include "accommon.h"
47#include "amlcode.h"
48#include "acdispat.h"
49#include "acinterp.h"
50
51#define _COMPONENT ACPI_DISPATCHER
52ACPI_MODULE_NAME("dscontrol")
53
54/*******************************************************************************
55 *
56 * FUNCTION: acpi_ds_exec_begin_control_op
57 *
58 * PARAMETERS: walk_list - The list that owns the walk stack
59 * Op - The control Op
60 *
61 * RETURN: Status
62 *
63 * DESCRIPTION: Handles all control ops encountered during control method
64 * execution.
65 *
66 ******************************************************************************/
67acpi_status
68acpi_ds_exec_begin_control_op(struct acpi_walk_state *walk_state,
69 union acpi_parse_object *op)
70{
71 acpi_status status = AE_OK;
72 union acpi_generic_state *control_state;
73
74 ACPI_FUNCTION_NAME(ds_exec_begin_control_op);
75
76 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, "Op=%p Opcode=%2.2X State=%p\n",
77 op, op->common.aml_opcode, walk_state));
78
79 switch (op->common.aml_opcode) {
80 case AML_WHILE_OP:
81
82 /*
83 * If this is an additional iteration of a while loop, continue.
84 * There is no need to allocate a new control state.
85 */
86 if (walk_state->control_state) {
87 if (walk_state->control_state->control.
88 aml_predicate_start ==
89 (walk_state->parser_state.aml - 1)) {
90
91 /* Reset the state to start-of-loop */
92
93 walk_state->control_state->common.state =
94 ACPI_CONTROL_CONDITIONAL_EXECUTING;
95 break;
96 }
97 }
98
99 /*lint -fallthrough */
100
101 case AML_IF_OP:
102
103 /*
104 * IF/WHILE: Create a new control state to manage these
105 * constructs. We need to manage these as a stack, in order
106 * to handle nesting.
107 */
108 control_state = acpi_ut_create_control_state();
109 if (!control_state) {
110 status = AE_NO_MEMORY;
111 break;
112 }
113 /*
114 * Save a pointer to the predicate for multiple executions
115 * of a loop
116 */
117 control_state->control.aml_predicate_start =
118 walk_state->parser_state.aml - 1;
119 control_state->control.package_end =
120 walk_state->parser_state.pkg_end;
121 control_state->control.opcode = op->common.aml_opcode;
122
123 /* Push the control state on this walk's control stack */
124
125 acpi_ut_push_generic_state(&walk_state->control_state,
126 control_state);
127 break;
128
129 case AML_ELSE_OP:
130
131 /* Predicate is in the state object */
132 /* If predicate is true, the IF was executed, ignore ELSE part */
133
134 if (walk_state->last_predicate) {
135 status = AE_CTRL_TRUE;
136 }
137
138 break;
139
140 case AML_RETURN_OP:
141
142 break;
143
144 default:
145 break;
146 }
147
148 return (status);
149}
150
151/*******************************************************************************
152 *
153 * FUNCTION: acpi_ds_exec_end_control_op
154 *
155 * PARAMETERS: walk_list - The list that owns the walk stack
156 * Op - The control Op
157 *
158 * RETURN: Status
159 *
160 * DESCRIPTION: Handles all control ops encountered during control method
161 * execution.
162 *
163 ******************************************************************************/
164
165acpi_status
166acpi_ds_exec_end_control_op(struct acpi_walk_state * walk_state,
167 union acpi_parse_object * op)
168{
169 acpi_status status = AE_OK;
170 union acpi_generic_state *control_state;
171
172 ACPI_FUNCTION_NAME(ds_exec_end_control_op);
173
174 switch (op->common.aml_opcode) {
175 case AML_IF_OP:
176
177 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, "[IF_OP] Op=%p\n", op));
178
179 /*
180 * Save the result of the predicate in case there is an
181 * ELSE to come
182 */
183 walk_state->last_predicate =
184 (u8)walk_state->control_state->common.value;
185
186 /*
187 * Pop the control state that was created at the start
188 * of the IF and free it
189 */
190 control_state =
191 acpi_ut_pop_generic_state(&walk_state->control_state);
192 acpi_ut_delete_generic_state(control_state);
193 break;
194
195 case AML_ELSE_OP:
196
197 break;
198
199 case AML_WHILE_OP:
200
201 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, "[WHILE_OP] Op=%p\n", op));
202
203 control_state = walk_state->control_state;
204 if (control_state->common.value) {
205
206 /* Predicate was true, the body of the loop was just executed */
207
208 /*
209 * This loop counter mechanism allows the interpreter to escape
210 * possibly infinite loops. This can occur in poorly written AML
211 * when the hardware does not respond within a while loop and the
212 * loop does not implement a timeout.
213 */
214 control_state->control.loop_count++;
215 if (control_state->control.loop_count >
216 ACPI_MAX_LOOP_ITERATIONS) {
217 status = AE_AML_INFINITE_LOOP;
218 break;
219 }
220
221 /*
222 * Go back and evaluate the predicate and maybe execute the loop
223 * another time
224 */
225 status = AE_CTRL_PENDING;
226 walk_state->aml_last_while =
227 control_state->control.aml_predicate_start;
228 break;
229 }
230
231 /* Predicate was false, terminate this while loop */
232
233 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
234 "[WHILE_OP] termination! Op=%p\n", op));
235
236 /* Pop this control state and free it */
237
238 control_state =
239 acpi_ut_pop_generic_state(&walk_state->control_state);
240 acpi_ut_delete_generic_state(control_state);
241 break;
242
243 case AML_RETURN_OP:
244
245 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
246 "[RETURN_OP] Op=%p Arg=%p\n", op,
247 op->common.value.arg));
248
249 /*
250 * One optional operand -- the return value
251 * It can be either an immediate operand or a result that
252 * has been bubbled up the tree
253 */
254 if (op->common.value.arg) {
255
256 /* Since we have a real Return(), delete any implicit return */
257
258 acpi_ds_clear_implicit_return(walk_state);
259
260 /* Return statement has an immediate operand */
261
262 status =
263 acpi_ds_create_operands(walk_state,
264 op->common.value.arg);
265 if (ACPI_FAILURE(status)) {
266 return (status);
267 }
268
269 /*
270 * If value being returned is a Reference (such as
271 * an arg or local), resolve it now because it may
272 * cease to exist at the end of the method.
273 */
274 status =
275 acpi_ex_resolve_to_value(&walk_state->operands[0],
276 walk_state);
277 if (ACPI_FAILURE(status)) {
278 return (status);
279 }
280
281 /*
282 * Get the return value and save as the last result
283 * value. This is the only place where walk_state->return_desc
284 * is set to anything other than zero!
285 */
286 walk_state->return_desc = walk_state->operands[0];
287 } else if (walk_state->result_count) {
288
289 /* Since we have a real Return(), delete any implicit return */
290
291 acpi_ds_clear_implicit_return(walk_state);
292
293 /*
294 * The return value has come from a previous calculation.
295 *
296 * If value being returned is a Reference (such as
297 * an arg or local), resolve it now because it may
298 * cease to exist at the end of the method.
299 *
300 * Allow references created by the Index operator to return
301 * unchanged.
302 */
303 if ((ACPI_GET_DESCRIPTOR_TYPE
304 (walk_state->results->results.obj_desc[0]) ==
305 ACPI_DESC_TYPE_OPERAND)
306 && ((walk_state->results->results.obj_desc[0])->
307 common.type == ACPI_TYPE_LOCAL_REFERENCE)
308 && ((walk_state->results->results.obj_desc[0])->
309 reference.class != ACPI_REFCLASS_INDEX)) {
310 status =
311 acpi_ex_resolve_to_value(&walk_state->
312 results->results.
313 obj_desc[0],
314 walk_state);
315 if (ACPI_FAILURE(status)) {
316 return (status);
317 }
318 }
319
320 walk_state->return_desc =
321 walk_state->results->results.obj_desc[0];
322 } else {
323 /* No return operand */
324
325 if (walk_state->num_operands) {
326 acpi_ut_remove_reference(walk_state->
327 operands[0]);
328 }
329
330 walk_state->operands[0] = NULL;
331 walk_state->num_operands = 0;
332 walk_state->return_desc = NULL;
333 }
334
335 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
336 "Completed RETURN_OP State=%p, RetVal=%p\n",
337 walk_state, walk_state->return_desc));
338
339 /* End the control method execution right now */
340
341 status = AE_CTRL_TERMINATE;
342 break;
343
344 case AML_NOOP_OP:
345
346 /* Just do nothing! */
347 break;
348
349 case AML_BREAK_POINT_OP:
350
351 /*
352 * Set the single-step flag. This will cause the debugger (if present)
353 * to break to the console within the AML debugger at the start of the
354 * next AML instruction.
355 */
356 ACPI_DEBUGGER_EXEC(acpi_gbl_cm_single_step = TRUE);
357 ACPI_DEBUGGER_EXEC(acpi_os_printf
358 ("**break** Executed AML BreakPoint opcode\n"));
359
360 /* Call to the OSL in case OS wants a piece of the action */
361
362 status = acpi_os_signal(ACPI_SIGNAL_BREAKPOINT,
363 "Executed AML Breakpoint opcode");
364 break;
365
366 case AML_BREAK_OP:
367 case AML_CONTINUE_OP: /* ACPI 2.0 */
368
369 /* Pop and delete control states until we find a while */
370
371 while (walk_state->control_state &&
372 (walk_state->control_state->control.opcode !=
373 AML_WHILE_OP)) {
374 control_state =
375 acpi_ut_pop_generic_state(&walk_state->
376 control_state);
377 acpi_ut_delete_generic_state(control_state);
378 }
379
380 /* No while found? */
381
382 if (!walk_state->control_state) {
383 return (AE_AML_NO_WHILE);
384 }
385
386 /* Was: walk_state->aml_last_while = walk_state->control_state->Control.aml_predicate_start; */
387
388 walk_state->aml_last_while =
389 walk_state->control_state->control.package_end;
390
391 /* Return status depending on opcode */
392
393 if (op->common.aml_opcode == AML_BREAK_OP) {
394 status = AE_CTRL_BREAK;
395 } else {
396 status = AE_CTRL_CONTINUE;
397 }
398 break;
399
400 default:
401
402 ACPI_ERROR((AE_INFO, "Unknown control opcode=0x%X Op=%p",
403 op->common.aml_opcode, op));
404
405 status = AE_AML_BAD_OPCODE;
406 break;
407 }
408
409 return (status);
410}
diff --git a/drivers/acpi/acpica/dsopcode.c b/drivers/acpi/acpica/dsopcode.c
index bbecf293aeeb..c627a288e027 100644
--- a/drivers/acpi/acpica/dsopcode.c
+++ b/drivers/acpi/acpica/dsopcode.c
@@ -1,7 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Module Name: dsopcode - Dispatcher Op Region support and handling of 3 * Module Name: dsopcode - Dispatcher suport for regions and fields
4 * "control" opcodes
5 * 4 *
6 *****************************************************************************/ 5 *****************************************************************************/
7 6
@@ -57,11 +56,6 @@ ACPI_MODULE_NAME("dsopcode")
57 56
58/* Local prototypes */ 57/* Local prototypes */
59static acpi_status 58static acpi_status
60acpi_ds_execute_arguments(struct acpi_namespace_node *node,
61 struct acpi_namespace_node *scope_node,
62 u32 aml_length, u8 * aml_start);
63
64static acpi_status
65acpi_ds_init_buffer_field(u16 aml_opcode, 59acpi_ds_init_buffer_field(u16 aml_opcode,
66 union acpi_operand_object *obj_desc, 60 union acpi_operand_object *obj_desc,
67 union acpi_operand_object *buffer_desc, 61 union acpi_operand_object *buffer_desc,
@@ -71,361 +65,6 @@ acpi_ds_init_buffer_field(u16 aml_opcode,
71 65
72/******************************************************************************* 66/*******************************************************************************
73 * 67 *
74 * FUNCTION: acpi_ds_execute_arguments
75 *
76 * PARAMETERS: Node - Object NS node
77 * scope_node - Parent NS node
78 * aml_length - Length of executable AML
79 * aml_start - Pointer to the AML
80 *
81 * RETURN: Status.
82 *
83 * DESCRIPTION: Late (deferred) execution of region or field arguments
84 *
85 ******************************************************************************/
86
87static acpi_status
88acpi_ds_execute_arguments(struct acpi_namespace_node *node,
89 struct acpi_namespace_node *scope_node,
90 u32 aml_length, u8 * aml_start)
91{
92 acpi_status status;
93 union acpi_parse_object *op;
94 struct acpi_walk_state *walk_state;
95
96 ACPI_FUNCTION_TRACE(ds_execute_arguments);
97
98 /*
99 * Allocate a new parser op to be the root of the parsed tree
100 */
101 op = acpi_ps_alloc_op(AML_INT_EVAL_SUBTREE_OP);
102 if (!op) {
103 return_ACPI_STATUS(AE_NO_MEMORY);
104 }
105
106 /* Save the Node for use in acpi_ps_parse_aml */
107
108 op->common.node = scope_node;
109
110 /* Create and initialize a new parser state */
111
112 walk_state = acpi_ds_create_walk_state(0, NULL, NULL, NULL);
113 if (!walk_state) {
114 status = AE_NO_MEMORY;
115 goto cleanup;
116 }
117
118 status = acpi_ds_init_aml_walk(walk_state, op, NULL, aml_start,
119 aml_length, NULL, ACPI_IMODE_LOAD_PASS1);
120 if (ACPI_FAILURE(status)) {
121 acpi_ds_delete_walk_state(walk_state);
122 goto cleanup;
123 }
124
125 /* Mark this parse as a deferred opcode */
126
127 walk_state->parse_flags = ACPI_PARSE_DEFERRED_OP;
128 walk_state->deferred_node = node;
129
130 /* Pass1: Parse the entire declaration */
131
132 status = acpi_ps_parse_aml(walk_state);
133 if (ACPI_FAILURE(status)) {
134 goto cleanup;
135 }
136
137 /* Get and init the Op created above */
138
139 op->common.node = node;
140 acpi_ps_delete_parse_tree(op);
141
142 /* Evaluate the deferred arguments */
143
144 op = acpi_ps_alloc_op(AML_INT_EVAL_SUBTREE_OP);
145 if (!op) {
146 return_ACPI_STATUS(AE_NO_MEMORY);
147 }
148
149 op->common.node = scope_node;
150
151 /* Create and initialize a new parser state */
152
153 walk_state = acpi_ds_create_walk_state(0, NULL, NULL, NULL);
154 if (!walk_state) {
155 status = AE_NO_MEMORY;
156 goto cleanup;
157 }
158
159 /* Execute the opcode and arguments */
160
161 status = acpi_ds_init_aml_walk(walk_state, op, NULL, aml_start,
162 aml_length, NULL, ACPI_IMODE_EXECUTE);
163 if (ACPI_FAILURE(status)) {
164 acpi_ds_delete_walk_state(walk_state);
165 goto cleanup;
166 }
167
168 /* Mark this execution as a deferred opcode */
169
170 walk_state->deferred_node = node;
171 status = acpi_ps_parse_aml(walk_state);
172
173 cleanup:
174 acpi_ps_delete_parse_tree(op);
175 return_ACPI_STATUS(status);
176}
177
178/*******************************************************************************
179 *
180 * FUNCTION: acpi_ds_get_buffer_field_arguments
181 *
182 * PARAMETERS: obj_desc - A valid buffer_field object
183 *
184 * RETURN: Status.
185 *
186 * DESCRIPTION: Get buffer_field Buffer and Index. This implements the late
187 * evaluation of these field attributes.
188 *
189 ******************************************************************************/
190
191acpi_status
192acpi_ds_get_buffer_field_arguments(union acpi_operand_object *obj_desc)
193{
194 union acpi_operand_object *extra_desc;
195 struct acpi_namespace_node *node;
196 acpi_status status;
197
198 ACPI_FUNCTION_TRACE_PTR(ds_get_buffer_field_arguments, obj_desc);
199
200 if (obj_desc->common.flags & AOPOBJ_DATA_VALID) {
201 return_ACPI_STATUS(AE_OK);
202 }
203
204 /* Get the AML pointer (method object) and buffer_field node */
205
206 extra_desc = acpi_ns_get_secondary_object(obj_desc);
207 node = obj_desc->buffer_field.node;
208
209 ACPI_DEBUG_EXEC(acpi_ut_display_init_pathname
210 (ACPI_TYPE_BUFFER_FIELD, node, NULL));
211 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "[%4.4s] BufferField Arg Init\n",
212 acpi_ut_get_node_name(node)));
213
214 /* Execute the AML code for the term_arg arguments */
215
216 status = acpi_ds_execute_arguments(node, node->parent,
217 extra_desc->extra.aml_length,
218 extra_desc->extra.aml_start);
219 return_ACPI_STATUS(status);
220}
221
222/*******************************************************************************
223 *
224 * FUNCTION: acpi_ds_get_bank_field_arguments
225 *
226 * PARAMETERS: obj_desc - A valid bank_field object
227 *
228 * RETURN: Status.
229 *
230 * DESCRIPTION: Get bank_field bank_value. This implements the late
231 * evaluation of these field attributes.
232 *
233 ******************************************************************************/
234
235acpi_status
236acpi_ds_get_bank_field_arguments(union acpi_operand_object *obj_desc)
237{
238 union acpi_operand_object *extra_desc;
239 struct acpi_namespace_node *node;
240 acpi_status status;
241
242 ACPI_FUNCTION_TRACE_PTR(ds_get_bank_field_arguments, obj_desc);
243
244 if (obj_desc->common.flags & AOPOBJ_DATA_VALID) {
245 return_ACPI_STATUS(AE_OK);
246 }
247
248 /* Get the AML pointer (method object) and bank_field node */
249
250 extra_desc = acpi_ns_get_secondary_object(obj_desc);
251 node = obj_desc->bank_field.node;
252
253 ACPI_DEBUG_EXEC(acpi_ut_display_init_pathname
254 (ACPI_TYPE_LOCAL_BANK_FIELD, node, NULL));
255 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "[%4.4s] BankField Arg Init\n",
256 acpi_ut_get_node_name(node)));
257
258 /* Execute the AML code for the term_arg arguments */
259
260 status = acpi_ds_execute_arguments(node, node->parent,
261 extra_desc->extra.aml_length,
262 extra_desc->extra.aml_start);
263 return_ACPI_STATUS(status);
264}
265
266/*******************************************************************************
267 *
268 * FUNCTION: acpi_ds_get_buffer_arguments
269 *
270 * PARAMETERS: obj_desc - A valid Buffer object
271 *
272 * RETURN: Status.
273 *
274 * DESCRIPTION: Get Buffer length and initializer byte list. This implements
275 * the late evaluation of these attributes.
276 *
277 ******************************************************************************/
278
279acpi_status acpi_ds_get_buffer_arguments(union acpi_operand_object *obj_desc)
280{
281 struct acpi_namespace_node *node;
282 acpi_status status;
283
284 ACPI_FUNCTION_TRACE_PTR(ds_get_buffer_arguments, obj_desc);
285
286 if (obj_desc->common.flags & AOPOBJ_DATA_VALID) {
287 return_ACPI_STATUS(AE_OK);
288 }
289
290 /* Get the Buffer node */
291
292 node = obj_desc->buffer.node;
293 if (!node) {
294 ACPI_ERROR((AE_INFO,
295 "No pointer back to namespace node in buffer object %p",
296 obj_desc));
297 return_ACPI_STATUS(AE_AML_INTERNAL);
298 }
299
300 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Buffer Arg Init\n"));
301
302 /* Execute the AML code for the term_arg arguments */
303
304 status = acpi_ds_execute_arguments(node, node,
305 obj_desc->buffer.aml_length,
306 obj_desc->buffer.aml_start);
307 return_ACPI_STATUS(status);
308}
309
310/*******************************************************************************
311 *
312 * FUNCTION: acpi_ds_get_package_arguments
313 *
314 * PARAMETERS: obj_desc - A valid Package object
315 *
316 * RETURN: Status.
317 *
318 * DESCRIPTION: Get Package length and initializer byte list. This implements
319 * the late evaluation of these attributes.
320 *
321 ******************************************************************************/
322
323acpi_status acpi_ds_get_package_arguments(union acpi_operand_object *obj_desc)
324{
325 struct acpi_namespace_node *node;
326 acpi_status status;
327
328 ACPI_FUNCTION_TRACE_PTR(ds_get_package_arguments, obj_desc);
329
330 if (obj_desc->common.flags & AOPOBJ_DATA_VALID) {
331 return_ACPI_STATUS(AE_OK);
332 }
333
334 /* Get the Package node */
335
336 node = obj_desc->package.node;
337 if (!node) {
338 ACPI_ERROR((AE_INFO,
339 "No pointer back to namespace node in package %p",
340 obj_desc));
341 return_ACPI_STATUS(AE_AML_INTERNAL);
342 }
343
344 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Package Arg Init\n"));
345
346 /* Execute the AML code for the term_arg arguments */
347
348 status = acpi_ds_execute_arguments(node, node,
349 obj_desc->package.aml_length,
350 obj_desc->package.aml_start);
351 return_ACPI_STATUS(status);
352}
353
354/*****************************************************************************
355 *
356 * FUNCTION: acpi_ds_get_region_arguments
357 *
358 * PARAMETERS: obj_desc - A valid region object
359 *
360 * RETURN: Status.
361 *
362 * DESCRIPTION: Get region address and length. This implements the late
363 * evaluation of these region attributes.
364 *
365 ****************************************************************************/
366
367acpi_status acpi_ds_get_region_arguments(union acpi_operand_object *obj_desc)
368{
369 struct acpi_namespace_node *node;
370 acpi_status status;
371 union acpi_operand_object *extra_desc;
372
373 ACPI_FUNCTION_TRACE_PTR(ds_get_region_arguments, obj_desc);
374
375 if (obj_desc->region.flags & AOPOBJ_DATA_VALID) {
376 return_ACPI_STATUS(AE_OK);
377 }
378
379 extra_desc = acpi_ns_get_secondary_object(obj_desc);
380 if (!extra_desc) {
381 return_ACPI_STATUS(AE_NOT_EXIST);
382 }
383
384 /* Get the Region node */
385
386 node = obj_desc->region.node;
387
388 ACPI_DEBUG_EXEC(acpi_ut_display_init_pathname
389 (ACPI_TYPE_REGION, node, NULL));
390
391 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "[%4.4s] OpRegion Arg Init at AML %p\n",
392 acpi_ut_get_node_name(node),
393 extra_desc->extra.aml_start));
394
395 /* Execute the argument AML */
396
397 status = acpi_ds_execute_arguments(node, node->parent,
398 extra_desc->extra.aml_length,
399 extra_desc->extra.aml_start);
400 if (ACPI_FAILURE(status)) {
401 return_ACPI_STATUS(status);
402 }
403
404 /* Validate the region address/length via the host OS */
405
406 status = acpi_os_validate_address(obj_desc->region.space_id,
407 obj_desc->region.address,
408 (acpi_size) obj_desc->region.length,
409 acpi_ut_get_node_name(node));
410
411 if (ACPI_FAILURE(status)) {
412 /*
413 * Invalid address/length. We will emit an error message and mark
414 * the region as invalid, so that it will cause an additional error if
415 * it is ever used. Then return AE_OK.
416 */
417 ACPI_EXCEPTION((AE_INFO, status,
418 "During address validation of OpRegion [%4.4s]",
419 node->name.ascii));
420 obj_desc->common.flags |= AOPOBJ_INVALID;
421 status = AE_OK;
422 }
423
424 return_ACPI_STATUS(status);
425}
426
427/*******************************************************************************
428 *
429 * FUNCTION: acpi_ds_initialize_region 68 * FUNCTION: acpi_ds_initialize_region
430 * 69 *
431 * PARAMETERS: obj_handle - Region namespace node 70 * PARAMETERS: obj_handle - Region namespace node
@@ -826,8 +465,9 @@ acpi_ds_eval_region_operands(struct acpi_walk_state *walk_state,
826 * 465 *
827 * RETURN: Status 466 * RETURN: Status
828 * 467 *
829 * DESCRIPTION: Get region address and length 468 * DESCRIPTION: Get region address and length.
830 * Called from acpi_ds_exec_end_op during data_table_region parse tree walk 469 * Called from acpi_ds_exec_end_op during data_table_region parse
470 * tree walk.
831 * 471 *
832 ******************************************************************************/ 472 ******************************************************************************/
833 473
@@ -1114,360 +754,3 @@ acpi_ds_eval_bank_field_operands(struct acpi_walk_state *walk_state,
1114 acpi_ut_remove_reference(operand_desc); 754 acpi_ut_remove_reference(operand_desc);
1115 return_ACPI_STATUS(status); 755 return_ACPI_STATUS(status);
1116} 756}
1117
1118/*******************************************************************************
1119 *
1120 * FUNCTION: acpi_ds_exec_begin_control_op
1121 *
1122 * PARAMETERS: walk_list - The list that owns the walk stack
1123 * Op - The control Op
1124 *
1125 * RETURN: Status
1126 *
1127 * DESCRIPTION: Handles all control ops encountered during control method
1128 * execution.
1129 *
1130 ******************************************************************************/
1131
1132acpi_status
1133acpi_ds_exec_begin_control_op(struct acpi_walk_state *walk_state,
1134 union acpi_parse_object *op)
1135{
1136 acpi_status status = AE_OK;
1137 union acpi_generic_state *control_state;
1138
1139 ACPI_FUNCTION_NAME(ds_exec_begin_control_op);
1140
1141 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, "Op=%p Opcode=%2.2X State=%p\n", op,
1142 op->common.aml_opcode, walk_state));
1143
1144 switch (op->common.aml_opcode) {
1145 case AML_WHILE_OP:
1146
1147 /*
1148 * If this is an additional iteration of a while loop, continue.
1149 * There is no need to allocate a new control state.
1150 */
1151 if (walk_state->control_state) {
1152 if (walk_state->control_state->control.aml_predicate_start
1153 == (walk_state->parser_state.aml - 1)) {
1154
1155 /* Reset the state to start-of-loop */
1156
1157 walk_state->control_state->common.state =
1158 ACPI_CONTROL_CONDITIONAL_EXECUTING;
1159 break;
1160 }
1161 }
1162
1163 /*lint -fallthrough */
1164
1165 case AML_IF_OP:
1166
1167 /*
1168 * IF/WHILE: Create a new control state to manage these
1169 * constructs. We need to manage these as a stack, in order
1170 * to handle nesting.
1171 */
1172 control_state = acpi_ut_create_control_state();
1173 if (!control_state) {
1174 status = AE_NO_MEMORY;
1175 break;
1176 }
1177 /*
1178 * Save a pointer to the predicate for multiple executions
1179 * of a loop
1180 */
1181 control_state->control.aml_predicate_start =
1182 walk_state->parser_state.aml - 1;
1183 control_state->control.package_end =
1184 walk_state->parser_state.pkg_end;
1185 control_state->control.opcode = op->common.aml_opcode;
1186
1187 /* Push the control state on this walk's control stack */
1188
1189 acpi_ut_push_generic_state(&walk_state->control_state,
1190 control_state);
1191 break;
1192
1193 case AML_ELSE_OP:
1194
1195 /* Predicate is in the state object */
1196 /* If predicate is true, the IF was executed, ignore ELSE part */
1197
1198 if (walk_state->last_predicate) {
1199 status = AE_CTRL_TRUE;
1200 }
1201
1202 break;
1203
1204 case AML_RETURN_OP:
1205
1206 break;
1207
1208 default:
1209 break;
1210 }
1211
1212 return (status);
1213}
1214
1215/*******************************************************************************
1216 *
1217 * FUNCTION: acpi_ds_exec_end_control_op
1218 *
1219 * PARAMETERS: walk_list - The list that owns the walk stack
1220 * Op - The control Op
1221 *
1222 * RETURN: Status
1223 *
1224 * DESCRIPTION: Handles all control ops encountered during control method
1225 * execution.
1226 *
1227 ******************************************************************************/
1228
1229acpi_status
1230acpi_ds_exec_end_control_op(struct acpi_walk_state * walk_state,
1231 union acpi_parse_object * op)
1232{
1233 acpi_status status = AE_OK;
1234 union acpi_generic_state *control_state;
1235
1236 ACPI_FUNCTION_NAME(ds_exec_end_control_op);
1237
1238 switch (op->common.aml_opcode) {
1239 case AML_IF_OP:
1240
1241 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, "[IF_OP] Op=%p\n", op));
1242
1243 /*
1244 * Save the result of the predicate in case there is an
1245 * ELSE to come
1246 */
1247 walk_state->last_predicate =
1248 (u8) walk_state->control_state->common.value;
1249
1250 /*
1251 * Pop the control state that was created at the start
1252 * of the IF and free it
1253 */
1254 control_state =
1255 acpi_ut_pop_generic_state(&walk_state->control_state);
1256 acpi_ut_delete_generic_state(control_state);
1257 break;
1258
1259 case AML_ELSE_OP:
1260
1261 break;
1262
1263 case AML_WHILE_OP:
1264
1265 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, "[WHILE_OP] Op=%p\n", op));
1266
1267 control_state = walk_state->control_state;
1268 if (control_state->common.value) {
1269
1270 /* Predicate was true, the body of the loop was just executed */
1271
1272 /*
1273 * This loop counter mechanism allows the interpreter to escape
1274 * possibly infinite loops. This can occur in poorly written AML
1275 * when the hardware does not respond within a while loop and the
1276 * loop does not implement a timeout.
1277 */
1278 control_state->control.loop_count++;
1279 if (control_state->control.loop_count >
1280 ACPI_MAX_LOOP_ITERATIONS) {
1281 status = AE_AML_INFINITE_LOOP;
1282 break;
1283 }
1284
1285 /*
1286 * Go back and evaluate the predicate and maybe execute the loop
1287 * another time
1288 */
1289 status = AE_CTRL_PENDING;
1290 walk_state->aml_last_while =
1291 control_state->control.aml_predicate_start;
1292 break;
1293 }
1294
1295 /* Predicate was false, terminate this while loop */
1296
1297 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
1298 "[WHILE_OP] termination! Op=%p\n", op));
1299
1300 /* Pop this control state and free it */
1301
1302 control_state =
1303 acpi_ut_pop_generic_state(&walk_state->control_state);
1304 acpi_ut_delete_generic_state(control_state);
1305 break;
1306
1307 case AML_RETURN_OP:
1308
1309 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
1310 "[RETURN_OP] Op=%p Arg=%p\n", op,
1311 op->common.value.arg));
1312
1313 /*
1314 * One optional operand -- the return value
1315 * It can be either an immediate operand or a result that
1316 * has been bubbled up the tree
1317 */
1318 if (op->common.value.arg) {
1319
1320 /* Since we have a real Return(), delete any implicit return */
1321
1322 acpi_ds_clear_implicit_return(walk_state);
1323
1324 /* Return statement has an immediate operand */
1325
1326 status =
1327 acpi_ds_create_operands(walk_state,
1328 op->common.value.arg);
1329 if (ACPI_FAILURE(status)) {
1330 return (status);
1331 }
1332
1333 /*
1334 * If value being returned is a Reference (such as
1335 * an arg or local), resolve it now because it may
1336 * cease to exist at the end of the method.
1337 */
1338 status =
1339 acpi_ex_resolve_to_value(&walk_state->operands[0],
1340 walk_state);
1341 if (ACPI_FAILURE(status)) {
1342 return (status);
1343 }
1344
1345 /*
1346 * Get the return value and save as the last result
1347 * value. This is the only place where walk_state->return_desc
1348 * is set to anything other than zero!
1349 */
1350 walk_state->return_desc = walk_state->operands[0];
1351 } else if (walk_state->result_count) {
1352
1353 /* Since we have a real Return(), delete any implicit return */
1354
1355 acpi_ds_clear_implicit_return(walk_state);
1356
1357 /*
1358 * The return value has come from a previous calculation.
1359 *
1360 * If value being returned is a Reference (such as
1361 * an arg or local), resolve it now because it may
1362 * cease to exist at the end of the method.
1363 *
1364 * Allow references created by the Index operator to return unchanged.
1365 */
1366 if ((ACPI_GET_DESCRIPTOR_TYPE
1367 (walk_state->results->results.obj_desc[0]) ==
1368 ACPI_DESC_TYPE_OPERAND)
1369 && ((walk_state->results->results.obj_desc[0])->
1370 common.type == ACPI_TYPE_LOCAL_REFERENCE)
1371 && ((walk_state->results->results.obj_desc[0])->
1372 reference.class != ACPI_REFCLASS_INDEX)) {
1373 status =
1374 acpi_ex_resolve_to_value(&walk_state->
1375 results->results.
1376 obj_desc[0],
1377 walk_state);
1378 if (ACPI_FAILURE(status)) {
1379 return (status);
1380 }
1381 }
1382
1383 walk_state->return_desc =
1384 walk_state->results->results.obj_desc[0];
1385 } else {
1386 /* No return operand */
1387
1388 if (walk_state->num_operands) {
1389 acpi_ut_remove_reference(walk_state->
1390 operands[0]);
1391 }
1392
1393 walk_state->operands[0] = NULL;
1394 walk_state->num_operands = 0;
1395 walk_state->return_desc = NULL;
1396 }
1397
1398 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
1399 "Completed RETURN_OP State=%p, RetVal=%p\n",
1400 walk_state, walk_state->return_desc));
1401
1402 /* End the control method execution right now */
1403
1404 status = AE_CTRL_TERMINATE;
1405 break;
1406
1407 case AML_NOOP_OP:
1408
1409 /* Just do nothing! */
1410 break;
1411
1412 case AML_BREAK_POINT_OP:
1413
1414 /*
1415 * Set the single-step flag. This will cause the debugger (if present)
1416 * to break to the console within the AML debugger at the start of the
1417 * next AML instruction.
1418 */
1419 ACPI_DEBUGGER_EXEC(acpi_gbl_cm_single_step = TRUE);
1420 ACPI_DEBUGGER_EXEC(acpi_os_printf
1421 ("**break** Executed AML BreakPoint opcode\n"));
1422
1423 /* Call to the OSL in case OS wants a piece of the action */
1424
1425 status = acpi_os_signal(ACPI_SIGNAL_BREAKPOINT,
1426 "Executed AML Breakpoint opcode");
1427 break;
1428
1429 case AML_BREAK_OP:
1430 case AML_CONTINUE_OP: /* ACPI 2.0 */
1431
1432 /* Pop and delete control states until we find a while */
1433
1434 while (walk_state->control_state &&
1435 (walk_state->control_state->control.opcode !=
1436 AML_WHILE_OP)) {
1437 control_state =
1438 acpi_ut_pop_generic_state(&walk_state->
1439 control_state);
1440 acpi_ut_delete_generic_state(control_state);
1441 }
1442
1443 /* No while found? */
1444
1445 if (!walk_state->control_state) {
1446 return (AE_AML_NO_WHILE);
1447 }
1448
1449 /* Was: walk_state->aml_last_while = walk_state->control_state->Control.aml_predicate_start; */
1450
1451 walk_state->aml_last_while =
1452 walk_state->control_state->control.package_end;
1453
1454 /* Return status depending on opcode */
1455
1456 if (op->common.aml_opcode == AML_BREAK_OP) {
1457 status = AE_CTRL_BREAK;
1458 } else {
1459 status = AE_CTRL_CONTINUE;
1460 }
1461 break;
1462
1463 default:
1464
1465 ACPI_ERROR((AE_INFO, "Unknown control opcode=0x%X Op=%p",
1466 op->common.aml_opcode, op));
1467
1468 status = AE_AML_BAD_OPCODE;
1469 break;
1470 }
1471
1472 return (status);
1473}
diff --git a/drivers/acpi/acpica/dswload.c b/drivers/acpi/acpica/dswload.c
index 52566ff5e903..23a3b1ab20c1 100644
--- a/drivers/acpi/acpica/dswload.c
+++ b/drivers/acpi/acpica/dswload.c
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Module Name: dswload - Dispatcher namespace load callbacks 3 * Module Name: dswload - Dispatcher first pass namespace load callbacks
4 * 4 *
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
@@ -48,7 +48,6 @@
48#include "acdispat.h" 48#include "acdispat.h"
49#include "acinterp.h" 49#include "acinterp.h"
50#include "acnamesp.h" 50#include "acnamesp.h"
51#include "acevents.h"
52 51
53#ifdef ACPI_ASL_COMPILER 52#ifdef ACPI_ASL_COMPILER
54#include <acpi/acdisasm.h> 53#include <acpi/acdisasm.h>
@@ -537,670 +536,3 @@ acpi_status acpi_ds_load1_end_op(struct acpi_walk_state *walk_state)
537 536
538 return_ACPI_STATUS(status); 537 return_ACPI_STATUS(status);
539} 538}
540
541/*******************************************************************************
542 *
543 * FUNCTION: acpi_ds_load2_begin_op
544 *
545 * PARAMETERS: walk_state - Current state of the parse tree walk
546 * out_op - Wher to return op if a new one is created
547 *
548 * RETURN: Status
549 *
550 * DESCRIPTION: Descending callback used during the loading of ACPI tables.
551 *
552 ******************************************************************************/
553
554acpi_status
555acpi_ds_load2_begin_op(struct acpi_walk_state *walk_state,
556 union acpi_parse_object **out_op)
557{
558 union acpi_parse_object *op;
559 struct acpi_namespace_node *node;
560 acpi_status status;
561 acpi_object_type object_type;
562 char *buffer_ptr;
563 u32 flags;
564
565 ACPI_FUNCTION_TRACE(ds_load2_begin_op);
566
567 op = walk_state->op;
568 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, "Op=%p State=%p\n", op,
569 walk_state));
570
571 if (op) {
572 if ((walk_state->control_state) &&
573 (walk_state->control_state->common.state ==
574 ACPI_CONTROL_CONDITIONAL_EXECUTING)) {
575
576 /* We are executing a while loop outside of a method */
577
578 status = acpi_ds_exec_begin_op(walk_state, out_op);
579 return_ACPI_STATUS(status);
580 }
581
582 /* We only care about Namespace opcodes here */
583
584 if ((!(walk_state->op_info->flags & AML_NSOPCODE) &&
585 (walk_state->opcode != AML_INT_NAMEPATH_OP)) ||
586 (!(walk_state->op_info->flags & AML_NAMED))) {
587 return_ACPI_STATUS(AE_OK);
588 }
589
590 /* Get the name we are going to enter or lookup in the namespace */
591
592 if (walk_state->opcode == AML_INT_NAMEPATH_OP) {
593
594 /* For Namepath op, get the path string */
595
596 buffer_ptr = op->common.value.string;
597 if (!buffer_ptr) {
598
599 /* No name, just exit */
600
601 return_ACPI_STATUS(AE_OK);
602 }
603 } else {
604 /* Get name from the op */
605
606 buffer_ptr = ACPI_CAST_PTR(char, &op->named.name);
607 }
608 } else {
609 /* Get the namestring from the raw AML */
610
611 buffer_ptr =
612 acpi_ps_get_next_namestring(&walk_state->parser_state);
613 }
614
615 /* Map the opcode into an internal object type */
616
617 object_type = walk_state->op_info->object_type;
618
619 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
620 "State=%p Op=%p Type=%X\n", walk_state, op,
621 object_type));
622
623 switch (walk_state->opcode) {
624 case AML_FIELD_OP:
625 case AML_BANK_FIELD_OP:
626 case AML_INDEX_FIELD_OP:
627
628 node = NULL;
629 status = AE_OK;
630 break;
631
632 case AML_INT_NAMEPATH_OP:
633 /*
634 * The name_path is an object reference to an existing object.
635 * Don't enter the name into the namespace, but look it up
636 * for use later.
637 */
638 status =
639 acpi_ns_lookup(walk_state->scope_info, buffer_ptr,
640 object_type, ACPI_IMODE_EXECUTE,
641 ACPI_NS_SEARCH_PARENT, walk_state, &(node));
642 break;
643
644 case AML_SCOPE_OP:
645
646 /* Special case for Scope(\) -> refers to the Root node */
647
648 if (op && (op->named.node == acpi_gbl_root_node)) {
649 node = op->named.node;
650
651 status =
652 acpi_ds_scope_stack_push(node, object_type,
653 walk_state);
654 if (ACPI_FAILURE(status)) {
655 return_ACPI_STATUS(status);
656 }
657 } else {
658 /*
659 * The Path is an object reference to an existing object.
660 * Don't enter the name into the namespace, but look it up
661 * for use later.
662 */
663 status =
664 acpi_ns_lookup(walk_state->scope_info, buffer_ptr,
665 object_type, ACPI_IMODE_EXECUTE,
666 ACPI_NS_SEARCH_PARENT, walk_state,
667 &(node));
668 if (ACPI_FAILURE(status)) {
669#ifdef ACPI_ASL_COMPILER
670 if (status == AE_NOT_FOUND) {
671 status = AE_OK;
672 } else {
673 ACPI_ERROR_NAMESPACE(buffer_ptr,
674 status);
675 }
676#else
677 ACPI_ERROR_NAMESPACE(buffer_ptr, status);
678#endif
679 return_ACPI_STATUS(status);
680 }
681 }
682
683 /*
684 * We must check to make sure that the target is
685 * one of the opcodes that actually opens a scope
686 */
687 switch (node->type) {
688 case ACPI_TYPE_ANY:
689 case ACPI_TYPE_LOCAL_SCOPE: /* Scope */
690 case ACPI_TYPE_DEVICE:
691 case ACPI_TYPE_POWER:
692 case ACPI_TYPE_PROCESSOR:
693 case ACPI_TYPE_THERMAL:
694
695 /* These are acceptable types */
696 break;
697
698 case ACPI_TYPE_INTEGER:
699 case ACPI_TYPE_STRING:
700 case ACPI_TYPE_BUFFER:
701
702 /*
703 * These types we will allow, but we will change the type.
704 * This enables some existing code of the form:
705 *
706 * Name (DEB, 0)
707 * Scope (DEB) { ... }
708 */
709 ACPI_WARNING((AE_INFO,
710 "Type override - [%4.4s] had invalid type (%s) "
711 "for Scope operator, changed to type ANY\n",
712 acpi_ut_get_node_name(node),
713 acpi_ut_get_type_name(node->type)));
714
715 node->type = ACPI_TYPE_ANY;
716 walk_state->scope_info->common.value = ACPI_TYPE_ANY;
717 break;
718
719 default:
720
721 /* All other types are an error */
722
723 ACPI_ERROR((AE_INFO,
724 "Invalid type (%s) for target of "
725 "Scope operator [%4.4s] (Cannot override)",
726 acpi_ut_get_type_name(node->type),
727 acpi_ut_get_node_name(node)));
728
729 return (AE_AML_OPERAND_TYPE);
730 }
731 break;
732
733 default:
734
735 /* All other opcodes */
736
737 if (op && op->common.node) {
738
739 /* This op/node was previously entered into the namespace */
740
741 node = op->common.node;
742
743 if (acpi_ns_opens_scope(object_type)) {
744 status =
745 acpi_ds_scope_stack_push(node, object_type,
746 walk_state);
747 if (ACPI_FAILURE(status)) {
748 return_ACPI_STATUS(status);
749 }
750 }
751
752 return_ACPI_STATUS(AE_OK);
753 }
754
755 /*
756 * Enter the named type into the internal namespace. We enter the name
757 * as we go downward in the parse tree. Any necessary subobjects that
758 * involve arguments to the opcode must be created as we go back up the
759 * parse tree later.
760 *
761 * Note: Name may already exist if we are executing a deferred opcode.
762 */
763 if (walk_state->deferred_node) {
764
765 /* This name is already in the namespace, get the node */
766
767 node = walk_state->deferred_node;
768 status = AE_OK;
769 break;
770 }
771
772 flags = ACPI_NS_NO_UPSEARCH;
773 if (walk_state->pass_number == ACPI_IMODE_EXECUTE) {
774
775 /* Execution mode, node cannot already exist, node is temporary */
776
777 flags |= ACPI_NS_ERROR_IF_FOUND;
778
779 if (!
780 (walk_state->
781 parse_flags & ACPI_PARSE_MODULE_LEVEL)) {
782 flags |= ACPI_NS_TEMPORARY;
783 }
784 }
785
786 /* Add new entry or lookup existing entry */
787
788 status =
789 acpi_ns_lookup(walk_state->scope_info, buffer_ptr,
790 object_type, ACPI_IMODE_LOAD_PASS2, flags,
791 walk_state, &node);
792
793 if (ACPI_SUCCESS(status) && (flags & ACPI_NS_TEMPORARY)) {
794 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
795 "***New Node [%4.4s] %p is temporary\n",
796 acpi_ut_get_node_name(node), node));
797 }
798 break;
799 }
800
801 if (ACPI_FAILURE(status)) {
802 ACPI_ERROR_NAMESPACE(buffer_ptr, status);
803 return_ACPI_STATUS(status);
804 }
805
806 if (!op) {
807
808 /* Create a new op */
809
810 op = acpi_ps_alloc_op(walk_state->opcode);
811 if (!op) {
812 return_ACPI_STATUS(AE_NO_MEMORY);
813 }
814
815 /* Initialize the new op */
816
817 if (node) {
818 op->named.name = node->name.integer;
819 }
820 *out_op = op;
821 }
822
823 /*
824 * Put the Node in the "op" object that the parser uses, so we
825 * can get it again quickly when this scope is closed
826 */
827 op->common.node = node;
828 return_ACPI_STATUS(status);
829}
830
831/*******************************************************************************
832 *
833 * FUNCTION: acpi_ds_load2_end_op
834 *
835 * PARAMETERS: walk_state - Current state of the parse tree walk
836 *
837 * RETURN: Status
838 *
839 * DESCRIPTION: Ascending callback used during the loading of the namespace,
840 * both control methods and everything else.
841 *
842 ******************************************************************************/
843
844acpi_status acpi_ds_load2_end_op(struct acpi_walk_state *walk_state)
845{
846 union acpi_parse_object *op;
847 acpi_status status = AE_OK;
848 acpi_object_type object_type;
849 struct acpi_namespace_node *node;
850 union acpi_parse_object *arg;
851 struct acpi_namespace_node *new_node;
852#ifndef ACPI_NO_METHOD_EXECUTION
853 u32 i;
854 u8 region_space;
855#endif
856
857 ACPI_FUNCTION_TRACE(ds_load2_end_op);
858
859 op = walk_state->op;
860 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, "Opcode [%s] Op %p State %p\n",
861 walk_state->op_info->name, op, walk_state));
862
863 /* Check if opcode had an associated namespace object */
864
865 if (!(walk_state->op_info->flags & AML_NSOBJECT)) {
866 return_ACPI_STATUS(AE_OK);
867 }
868
869 if (op->common.aml_opcode == AML_SCOPE_OP) {
870 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
871 "Ending scope Op=%p State=%p\n", op,
872 walk_state));
873 }
874
875 object_type = walk_state->op_info->object_type;
876
877 /*
878 * Get the Node/name from the earlier lookup
879 * (It was saved in the *op structure)
880 */
881 node = op->common.node;
882
883 /*
884 * Put the Node on the object stack (Contains the ACPI Name of
885 * this object)
886 */
887 walk_state->operands[0] = (void *)node;
888 walk_state->num_operands = 1;
889
890 /* Pop the scope stack */
891
892 if (acpi_ns_opens_scope(object_type) &&
893 (op->common.aml_opcode != AML_INT_METHODCALL_OP)) {
894 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
895 "(%s) Popping scope for Op %p\n",
896 acpi_ut_get_type_name(object_type), op));
897
898 status = acpi_ds_scope_stack_pop(walk_state);
899 if (ACPI_FAILURE(status)) {
900 goto cleanup;
901 }
902 }
903
904 /*
905 * Named operations are as follows:
906 *
907 * AML_ALIAS
908 * AML_BANKFIELD
909 * AML_CREATEBITFIELD
910 * AML_CREATEBYTEFIELD
911 * AML_CREATEDWORDFIELD
912 * AML_CREATEFIELD
913 * AML_CREATEQWORDFIELD
914 * AML_CREATEWORDFIELD
915 * AML_DATA_REGION
916 * AML_DEVICE
917 * AML_EVENT
918 * AML_FIELD
919 * AML_INDEXFIELD
920 * AML_METHOD
921 * AML_METHODCALL
922 * AML_MUTEX
923 * AML_NAME
924 * AML_NAMEDFIELD
925 * AML_OPREGION
926 * AML_POWERRES
927 * AML_PROCESSOR
928 * AML_SCOPE
929 * AML_THERMALZONE
930 */
931
932 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
933 "Create-Load [%s] State=%p Op=%p NamedObj=%p\n",
934 acpi_ps_get_opcode_name(op->common.aml_opcode),
935 walk_state, op, node));
936
937 /* Decode the opcode */
938
939 arg = op->common.value.arg;
940
941 switch (walk_state->op_info->type) {
942#ifndef ACPI_NO_METHOD_EXECUTION
943
944 case AML_TYPE_CREATE_FIELD:
945 /*
946 * Create the field object, but the field buffer and index must
947 * be evaluated later during the execution phase
948 */
949 status = acpi_ds_create_buffer_field(op, walk_state);
950 break;
951
952 case AML_TYPE_NAMED_FIELD:
953 /*
954 * If we are executing a method, initialize the field
955 */
956 if (walk_state->method_node) {
957 status = acpi_ds_init_field_objects(op, walk_state);
958 }
959
960 switch (op->common.aml_opcode) {
961 case AML_INDEX_FIELD_OP:
962
963 status =
964 acpi_ds_create_index_field(op,
965 (acpi_handle) arg->
966 common.node, walk_state);
967 break;
968
969 case AML_BANK_FIELD_OP:
970
971 status =
972 acpi_ds_create_bank_field(op, arg->common.node,
973 walk_state);
974 break;
975
976 case AML_FIELD_OP:
977
978 status =
979 acpi_ds_create_field(op, arg->common.node,
980 walk_state);
981 break;
982
983 default:
984 /* All NAMED_FIELD opcodes must be handled above */
985 break;
986 }
987 break;
988
989 case AML_TYPE_NAMED_SIMPLE:
990
991 status = acpi_ds_create_operands(walk_state, arg);
992 if (ACPI_FAILURE(status)) {
993 goto cleanup;
994 }
995
996 switch (op->common.aml_opcode) {
997 case AML_PROCESSOR_OP:
998
999 status = acpi_ex_create_processor(walk_state);
1000 break;
1001
1002 case AML_POWER_RES_OP:
1003
1004 status = acpi_ex_create_power_resource(walk_state);
1005 break;
1006
1007 case AML_MUTEX_OP:
1008
1009 status = acpi_ex_create_mutex(walk_state);
1010 break;
1011
1012 case AML_EVENT_OP:
1013
1014 status = acpi_ex_create_event(walk_state);
1015 break;
1016
1017 case AML_ALIAS_OP:
1018
1019 status = acpi_ex_create_alias(walk_state);
1020 break;
1021
1022 default:
1023 /* Unknown opcode */
1024
1025 status = AE_OK;
1026 goto cleanup;
1027 }
1028
1029 /* Delete operands */
1030
1031 for (i = 1; i < walk_state->num_operands; i++) {
1032 acpi_ut_remove_reference(walk_state->operands[i]);
1033 walk_state->operands[i] = NULL;
1034 }
1035
1036 break;
1037#endif /* ACPI_NO_METHOD_EXECUTION */
1038
1039 case AML_TYPE_NAMED_COMPLEX:
1040
1041 switch (op->common.aml_opcode) {
1042#ifndef ACPI_NO_METHOD_EXECUTION
1043 case AML_REGION_OP:
1044 case AML_DATA_REGION_OP:
1045
1046 if (op->common.aml_opcode == AML_REGION_OP) {
1047 region_space = (acpi_adr_space_type)
1048 ((op->common.value.arg)->common.value.
1049 integer);
1050 } else {
1051 region_space = REGION_DATA_TABLE;
1052 }
1053
1054 /*
1055 * The op_region is not fully parsed at this time. The only valid
1056 * argument is the space_id. (We must save the address of the
1057 * AML of the address and length operands)
1058 *
1059 * If we have a valid region, initialize it. The namespace is
1060 * unlocked at this point.
1061 *
1062 * Need to unlock interpreter if it is locked (if we are running
1063 * a control method), in order to allow _REG methods to be run
1064 * during acpi_ev_initialize_region.
1065 */
1066 if (walk_state->method_node) {
1067 /*
1068 * Executing a method: initialize the region and unlock
1069 * the interpreter
1070 */
1071 status =
1072 acpi_ex_create_region(op->named.data,
1073 op->named.length,
1074 region_space,
1075 walk_state);
1076 if (ACPI_FAILURE(status)) {
1077 return (status);
1078 }
1079
1080 acpi_ex_exit_interpreter();
1081 }
1082
1083 status =
1084 acpi_ev_initialize_region
1085 (acpi_ns_get_attached_object(node), FALSE);
1086 if (walk_state->method_node) {
1087 acpi_ex_enter_interpreter();
1088 }
1089
1090 if (ACPI_FAILURE(status)) {
1091 /*
1092 * If AE_NOT_EXIST is returned, it is not fatal
1093 * because many regions get created before a handler
1094 * is installed for said region.
1095 */
1096 if (AE_NOT_EXIST == status) {
1097 status = AE_OK;
1098 }
1099 }
1100 break;
1101
1102 case AML_NAME_OP:
1103
1104 status = acpi_ds_create_node(walk_state, node, op);
1105 break;
1106
1107 case AML_METHOD_OP:
1108 /*
1109 * method_op pkg_length name_string method_flags term_list
1110 *
1111 * Note: We must create the method node/object pair as soon as we
1112 * see the method declaration. This allows later pass1 parsing
1113 * of invocations of the method (need to know the number of
1114 * arguments.)
1115 */
1116 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
1117 "LOADING-Method: State=%p Op=%p NamedObj=%p\n",
1118 walk_state, op, op->named.node));
1119
1120 if (!acpi_ns_get_attached_object(op->named.node)) {
1121 walk_state->operands[0] =
1122 ACPI_CAST_PTR(void, op->named.node);
1123 walk_state->num_operands = 1;
1124
1125 status =
1126 acpi_ds_create_operands(walk_state,
1127 op->common.value.
1128 arg);
1129 if (ACPI_SUCCESS(status)) {
1130 status =
1131 acpi_ex_create_method(op->named.
1132 data,
1133 op->named.
1134 length,
1135 walk_state);
1136 }
1137 walk_state->operands[0] = NULL;
1138 walk_state->num_operands = 0;
1139
1140 if (ACPI_FAILURE(status)) {
1141 return_ACPI_STATUS(status);
1142 }
1143 }
1144 break;
1145
1146#endif /* ACPI_NO_METHOD_EXECUTION */
1147
1148 default:
1149 /* All NAMED_COMPLEX opcodes must be handled above */
1150 break;
1151 }
1152 break;
1153
1154 case AML_CLASS_INTERNAL:
1155
1156 /* case AML_INT_NAMEPATH_OP: */
1157 break;
1158
1159 case AML_CLASS_METHOD_CALL:
1160
1161 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
1162 "RESOLVING-MethodCall: State=%p Op=%p NamedObj=%p\n",
1163 walk_state, op, node));
1164
1165 /*
1166 * Lookup the method name and save the Node
1167 */
1168 status =
1169 acpi_ns_lookup(walk_state->scope_info,
1170 arg->common.value.string, ACPI_TYPE_ANY,
1171 ACPI_IMODE_LOAD_PASS2,
1172 ACPI_NS_SEARCH_PARENT |
1173 ACPI_NS_DONT_OPEN_SCOPE, walk_state,
1174 &(new_node));
1175 if (ACPI_SUCCESS(status)) {
1176 /*
1177 * Make sure that what we found is indeed a method
1178 * We didn't search for a method on purpose, to see if the name
1179 * would resolve
1180 */
1181 if (new_node->type != ACPI_TYPE_METHOD) {
1182 status = AE_AML_OPERAND_TYPE;
1183 }
1184
1185 /* We could put the returned object (Node) on the object stack for
1186 * later, but for now, we will put it in the "op" object that the
1187 * parser uses, so we can get it again at the end of this scope
1188 */
1189 op->common.node = new_node;
1190 } else {
1191 ACPI_ERROR_NAMESPACE(arg->common.value.string, status);
1192 }
1193 break;
1194
1195 default:
1196 break;
1197 }
1198
1199 cleanup:
1200
1201 /* Remove the Node pushed at the very beginning */
1202
1203 walk_state->operands[0] = NULL;
1204 walk_state->num_operands = 0;
1205 return_ACPI_STATUS(status);
1206}
diff --git a/drivers/acpi/acpica/dswload2.c b/drivers/acpi/acpica/dswload2.c
new file mode 100644
index 000000000000..4be4e921dfe1
--- /dev/null
+++ b/drivers/acpi/acpica/dswload2.c
@@ -0,0 +1,720 @@
1/******************************************************************************
2 *
3 * Module Name: dswload2 - Dispatcher second pass namespace load callbacks
4 *
5 *****************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44#include <acpi/acpi.h>
45#include "accommon.h"
46#include "acparser.h"
47#include "amlcode.h"
48#include "acdispat.h"
49#include "acinterp.h"
50#include "acnamesp.h"
51#include "acevents.h"
52
53#define _COMPONENT ACPI_DISPATCHER
54ACPI_MODULE_NAME("dswload2")
55
56/*******************************************************************************
57 *
58 * FUNCTION: acpi_ds_load2_begin_op
59 *
60 * PARAMETERS: walk_state - Current state of the parse tree walk
61 * out_op - Wher to return op if a new one is created
62 *
63 * RETURN: Status
64 *
65 * DESCRIPTION: Descending callback used during the loading of ACPI tables.
66 *
67 ******************************************************************************/
68acpi_status
69acpi_ds_load2_begin_op(struct acpi_walk_state *walk_state,
70 union acpi_parse_object **out_op)
71{
72 union acpi_parse_object *op;
73 struct acpi_namespace_node *node;
74 acpi_status status;
75 acpi_object_type object_type;
76 char *buffer_ptr;
77 u32 flags;
78
79 ACPI_FUNCTION_TRACE(ds_load2_begin_op);
80
81 op = walk_state->op;
82 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, "Op=%p State=%p\n", op,
83 walk_state));
84
85 if (op) {
86 if ((walk_state->control_state) &&
87 (walk_state->control_state->common.state ==
88 ACPI_CONTROL_CONDITIONAL_EXECUTING)) {
89
90 /* We are executing a while loop outside of a method */
91
92 status = acpi_ds_exec_begin_op(walk_state, out_op);
93 return_ACPI_STATUS(status);
94 }
95
96 /* We only care about Namespace opcodes here */
97
98 if ((!(walk_state->op_info->flags & AML_NSOPCODE) &&
99 (walk_state->opcode != AML_INT_NAMEPATH_OP)) ||
100 (!(walk_state->op_info->flags & AML_NAMED))) {
101 return_ACPI_STATUS(AE_OK);
102 }
103
104 /* Get the name we are going to enter or lookup in the namespace */
105
106 if (walk_state->opcode == AML_INT_NAMEPATH_OP) {
107
108 /* For Namepath op, get the path string */
109
110 buffer_ptr = op->common.value.string;
111 if (!buffer_ptr) {
112
113 /* No name, just exit */
114
115 return_ACPI_STATUS(AE_OK);
116 }
117 } else {
118 /* Get name from the op */
119
120 buffer_ptr = ACPI_CAST_PTR(char, &op->named.name);
121 }
122 } else {
123 /* Get the namestring from the raw AML */
124
125 buffer_ptr =
126 acpi_ps_get_next_namestring(&walk_state->parser_state);
127 }
128
129 /* Map the opcode into an internal object type */
130
131 object_type = walk_state->op_info->object_type;
132
133 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
134 "State=%p Op=%p Type=%X\n", walk_state, op,
135 object_type));
136
137 switch (walk_state->opcode) {
138 case AML_FIELD_OP:
139 case AML_BANK_FIELD_OP:
140 case AML_INDEX_FIELD_OP:
141
142 node = NULL;
143 status = AE_OK;
144 break;
145
146 case AML_INT_NAMEPATH_OP:
147 /*
148 * The name_path is an object reference to an existing object.
149 * Don't enter the name into the namespace, but look it up
150 * for use later.
151 */
152 status =
153 acpi_ns_lookup(walk_state->scope_info, buffer_ptr,
154 object_type, ACPI_IMODE_EXECUTE,
155 ACPI_NS_SEARCH_PARENT, walk_state, &(node));
156 break;
157
158 case AML_SCOPE_OP:
159
160 /* Special case for Scope(\) -> refers to the Root node */
161
162 if (op && (op->named.node == acpi_gbl_root_node)) {
163 node = op->named.node;
164
165 status =
166 acpi_ds_scope_stack_push(node, object_type,
167 walk_state);
168 if (ACPI_FAILURE(status)) {
169 return_ACPI_STATUS(status);
170 }
171 } else {
172 /*
173 * The Path is an object reference to an existing object.
174 * Don't enter the name into the namespace, but look it up
175 * for use later.
176 */
177 status =
178 acpi_ns_lookup(walk_state->scope_info, buffer_ptr,
179 object_type, ACPI_IMODE_EXECUTE,
180 ACPI_NS_SEARCH_PARENT, walk_state,
181 &(node));
182 if (ACPI_FAILURE(status)) {
183#ifdef ACPI_ASL_COMPILER
184 if (status == AE_NOT_FOUND) {
185 status = AE_OK;
186 } else {
187 ACPI_ERROR_NAMESPACE(buffer_ptr,
188 status);
189 }
190#else
191 ACPI_ERROR_NAMESPACE(buffer_ptr, status);
192#endif
193 return_ACPI_STATUS(status);
194 }
195 }
196
197 /*
198 * We must check to make sure that the target is
199 * one of the opcodes that actually opens a scope
200 */
201 switch (node->type) {
202 case ACPI_TYPE_ANY:
203 case ACPI_TYPE_LOCAL_SCOPE: /* Scope */
204 case ACPI_TYPE_DEVICE:
205 case ACPI_TYPE_POWER:
206 case ACPI_TYPE_PROCESSOR:
207 case ACPI_TYPE_THERMAL:
208
209 /* These are acceptable types */
210 break;
211
212 case ACPI_TYPE_INTEGER:
213 case ACPI_TYPE_STRING:
214 case ACPI_TYPE_BUFFER:
215
216 /*
217 * These types we will allow, but we will change the type.
218 * This enables some existing code of the form:
219 *
220 * Name (DEB, 0)
221 * Scope (DEB) { ... }
222 */
223 ACPI_WARNING((AE_INFO,
224 "Type override - [%4.4s] had invalid type (%s) "
225 "for Scope operator, changed to type ANY\n",
226 acpi_ut_get_node_name(node),
227 acpi_ut_get_type_name(node->type)));
228
229 node->type = ACPI_TYPE_ANY;
230 walk_state->scope_info->common.value = ACPI_TYPE_ANY;
231 break;
232
233 default:
234
235 /* All other types are an error */
236
237 ACPI_ERROR((AE_INFO,
238 "Invalid type (%s) for target of "
239 "Scope operator [%4.4s] (Cannot override)",
240 acpi_ut_get_type_name(node->type),
241 acpi_ut_get_node_name(node)));
242
243 return (AE_AML_OPERAND_TYPE);
244 }
245 break;
246
247 default:
248
249 /* All other opcodes */
250
251 if (op && op->common.node) {
252
253 /* This op/node was previously entered into the namespace */
254
255 node = op->common.node;
256
257 if (acpi_ns_opens_scope(object_type)) {
258 status =
259 acpi_ds_scope_stack_push(node, object_type,
260 walk_state);
261 if (ACPI_FAILURE(status)) {
262 return_ACPI_STATUS(status);
263 }
264 }
265
266 return_ACPI_STATUS(AE_OK);
267 }
268
269 /*
270 * Enter the named type into the internal namespace. We enter the name
271 * as we go downward in the parse tree. Any necessary subobjects that
272 * involve arguments to the opcode must be created as we go back up the
273 * parse tree later.
274 *
275 * Note: Name may already exist if we are executing a deferred opcode.
276 */
277 if (walk_state->deferred_node) {
278
279 /* This name is already in the namespace, get the node */
280
281 node = walk_state->deferred_node;
282 status = AE_OK;
283 break;
284 }
285
286 flags = ACPI_NS_NO_UPSEARCH;
287 if (walk_state->pass_number == ACPI_IMODE_EXECUTE) {
288
289 /* Execution mode, node cannot already exist, node is temporary */
290
291 flags |= ACPI_NS_ERROR_IF_FOUND;
292
293 if (!
294 (walk_state->
295 parse_flags & ACPI_PARSE_MODULE_LEVEL)) {
296 flags |= ACPI_NS_TEMPORARY;
297 }
298 }
299
300 /* Add new entry or lookup existing entry */
301
302 status =
303 acpi_ns_lookup(walk_state->scope_info, buffer_ptr,
304 object_type, ACPI_IMODE_LOAD_PASS2, flags,
305 walk_state, &node);
306
307 if (ACPI_SUCCESS(status) && (flags & ACPI_NS_TEMPORARY)) {
308 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
309 "***New Node [%4.4s] %p is temporary\n",
310 acpi_ut_get_node_name(node), node));
311 }
312 break;
313 }
314
315 if (ACPI_FAILURE(status)) {
316 ACPI_ERROR_NAMESPACE(buffer_ptr, status);
317 return_ACPI_STATUS(status);
318 }
319
320 if (!op) {
321
322 /* Create a new op */
323
324 op = acpi_ps_alloc_op(walk_state->opcode);
325 if (!op) {
326 return_ACPI_STATUS(AE_NO_MEMORY);
327 }
328
329 /* Initialize the new op */
330
331 if (node) {
332 op->named.name = node->name.integer;
333 }
334 *out_op = op;
335 }
336
337 /*
338 * Put the Node in the "op" object that the parser uses, so we
339 * can get it again quickly when this scope is closed
340 */
341 op->common.node = node;
342 return_ACPI_STATUS(status);
343}
344
345/*******************************************************************************
346 *
347 * FUNCTION: acpi_ds_load2_end_op
348 *
349 * PARAMETERS: walk_state - Current state of the parse tree walk
350 *
351 * RETURN: Status
352 *
353 * DESCRIPTION: Ascending callback used during the loading of the namespace,
354 * both control methods and everything else.
355 *
356 ******************************************************************************/
357
358acpi_status acpi_ds_load2_end_op(struct acpi_walk_state *walk_state)
359{
360 union acpi_parse_object *op;
361 acpi_status status = AE_OK;
362 acpi_object_type object_type;
363 struct acpi_namespace_node *node;
364 union acpi_parse_object *arg;
365 struct acpi_namespace_node *new_node;
366#ifndef ACPI_NO_METHOD_EXECUTION
367 u32 i;
368 u8 region_space;
369#endif
370
371 ACPI_FUNCTION_TRACE(ds_load2_end_op);
372
373 op = walk_state->op;
374 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, "Opcode [%s] Op %p State %p\n",
375 walk_state->op_info->name, op, walk_state));
376
377 /* Check if opcode had an associated namespace object */
378
379 if (!(walk_state->op_info->flags & AML_NSOBJECT)) {
380 return_ACPI_STATUS(AE_OK);
381 }
382
383 if (op->common.aml_opcode == AML_SCOPE_OP) {
384 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
385 "Ending scope Op=%p State=%p\n", op,
386 walk_state));
387 }
388
389 object_type = walk_state->op_info->object_type;
390
391 /*
392 * Get the Node/name from the earlier lookup
393 * (It was saved in the *op structure)
394 */
395 node = op->common.node;
396
397 /*
398 * Put the Node on the object stack (Contains the ACPI Name of
399 * this object)
400 */
401 walk_state->operands[0] = (void *)node;
402 walk_state->num_operands = 1;
403
404 /* Pop the scope stack */
405
406 if (acpi_ns_opens_scope(object_type) &&
407 (op->common.aml_opcode != AML_INT_METHODCALL_OP)) {
408 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
409 "(%s) Popping scope for Op %p\n",
410 acpi_ut_get_type_name(object_type), op));
411
412 status = acpi_ds_scope_stack_pop(walk_state);
413 if (ACPI_FAILURE(status)) {
414 goto cleanup;
415 }
416 }
417
418 /*
419 * Named operations are as follows:
420 *
421 * AML_ALIAS
422 * AML_BANKFIELD
423 * AML_CREATEBITFIELD
424 * AML_CREATEBYTEFIELD
425 * AML_CREATEDWORDFIELD
426 * AML_CREATEFIELD
427 * AML_CREATEQWORDFIELD
428 * AML_CREATEWORDFIELD
429 * AML_DATA_REGION
430 * AML_DEVICE
431 * AML_EVENT
432 * AML_FIELD
433 * AML_INDEXFIELD
434 * AML_METHOD
435 * AML_METHODCALL
436 * AML_MUTEX
437 * AML_NAME
438 * AML_NAMEDFIELD
439 * AML_OPREGION
440 * AML_POWERRES
441 * AML_PROCESSOR
442 * AML_SCOPE
443 * AML_THERMALZONE
444 */
445
446 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
447 "Create-Load [%s] State=%p Op=%p NamedObj=%p\n",
448 acpi_ps_get_opcode_name(op->common.aml_opcode),
449 walk_state, op, node));
450
451 /* Decode the opcode */
452
453 arg = op->common.value.arg;
454
455 switch (walk_state->op_info->type) {
456#ifndef ACPI_NO_METHOD_EXECUTION
457
458 case AML_TYPE_CREATE_FIELD:
459 /*
460 * Create the field object, but the field buffer and index must
461 * be evaluated later during the execution phase
462 */
463 status = acpi_ds_create_buffer_field(op, walk_state);
464 break;
465
466 case AML_TYPE_NAMED_FIELD:
467 /*
468 * If we are executing a method, initialize the field
469 */
470 if (walk_state->method_node) {
471 status = acpi_ds_init_field_objects(op, walk_state);
472 }
473
474 switch (op->common.aml_opcode) {
475 case AML_INDEX_FIELD_OP:
476
477 status =
478 acpi_ds_create_index_field(op,
479 (acpi_handle) arg->
480 common.node, walk_state);
481 break;
482
483 case AML_BANK_FIELD_OP:
484
485 status =
486 acpi_ds_create_bank_field(op, arg->common.node,
487 walk_state);
488 break;
489
490 case AML_FIELD_OP:
491
492 status =
493 acpi_ds_create_field(op, arg->common.node,
494 walk_state);
495 break;
496
497 default:
498 /* All NAMED_FIELD opcodes must be handled above */
499 break;
500 }
501 break;
502
503 case AML_TYPE_NAMED_SIMPLE:
504
505 status = acpi_ds_create_operands(walk_state, arg);
506 if (ACPI_FAILURE(status)) {
507 goto cleanup;
508 }
509
510 switch (op->common.aml_opcode) {
511 case AML_PROCESSOR_OP:
512
513 status = acpi_ex_create_processor(walk_state);
514 break;
515
516 case AML_POWER_RES_OP:
517
518 status = acpi_ex_create_power_resource(walk_state);
519 break;
520
521 case AML_MUTEX_OP:
522
523 status = acpi_ex_create_mutex(walk_state);
524 break;
525
526 case AML_EVENT_OP:
527
528 status = acpi_ex_create_event(walk_state);
529 break;
530
531 case AML_ALIAS_OP:
532
533 status = acpi_ex_create_alias(walk_state);
534 break;
535
536 default:
537 /* Unknown opcode */
538
539 status = AE_OK;
540 goto cleanup;
541 }
542
543 /* Delete operands */
544
545 for (i = 1; i < walk_state->num_operands; i++) {
546 acpi_ut_remove_reference(walk_state->operands[i]);
547 walk_state->operands[i] = NULL;
548 }
549
550 break;
551#endif /* ACPI_NO_METHOD_EXECUTION */
552
553 case AML_TYPE_NAMED_COMPLEX:
554
555 switch (op->common.aml_opcode) {
556#ifndef ACPI_NO_METHOD_EXECUTION
557 case AML_REGION_OP:
558 case AML_DATA_REGION_OP:
559
560 if (op->common.aml_opcode == AML_REGION_OP) {
561 region_space = (acpi_adr_space_type)
562 ((op->common.value.arg)->common.value.
563 integer);
564 } else {
565 region_space = REGION_DATA_TABLE;
566 }
567
568 /*
569 * The op_region is not fully parsed at this time. The only valid
570 * argument is the space_id. (We must save the address of the
571 * AML of the address and length operands)
572 *
573 * If we have a valid region, initialize it. The namespace is
574 * unlocked at this point.
575 *
576 * Need to unlock interpreter if it is locked (if we are running
577 * a control method), in order to allow _REG methods to be run
578 * during acpi_ev_initialize_region.
579 */
580 if (walk_state->method_node) {
581 /*
582 * Executing a method: initialize the region and unlock
583 * the interpreter
584 */
585 status =
586 acpi_ex_create_region(op->named.data,
587 op->named.length,
588 region_space,
589 walk_state);
590 if (ACPI_FAILURE(status)) {
591 return (status);
592 }
593
594 acpi_ex_exit_interpreter();
595 }
596
597 status =
598 acpi_ev_initialize_region
599 (acpi_ns_get_attached_object(node), FALSE);
600 if (walk_state->method_node) {
601 acpi_ex_enter_interpreter();
602 }
603
604 if (ACPI_FAILURE(status)) {
605 /*
606 * If AE_NOT_EXIST is returned, it is not fatal
607 * because many regions get created before a handler
608 * is installed for said region.
609 */
610 if (AE_NOT_EXIST == status) {
611 status = AE_OK;
612 }
613 }
614 break;
615
616 case AML_NAME_OP:
617
618 status = acpi_ds_create_node(walk_state, node, op);
619 break;
620
621 case AML_METHOD_OP:
622 /*
623 * method_op pkg_length name_string method_flags term_list
624 *
625 * Note: We must create the method node/object pair as soon as we
626 * see the method declaration. This allows later pass1 parsing
627 * of invocations of the method (need to know the number of
628 * arguments.)
629 */
630 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
631 "LOADING-Method: State=%p Op=%p NamedObj=%p\n",
632 walk_state, op, op->named.node));
633
634 if (!acpi_ns_get_attached_object(op->named.node)) {
635 walk_state->operands[0] =
636 ACPI_CAST_PTR(void, op->named.node);
637 walk_state->num_operands = 1;
638
639 status =
640 acpi_ds_create_operands(walk_state,
641 op->common.value.
642 arg);
643 if (ACPI_SUCCESS(status)) {
644 status =
645 acpi_ex_create_method(op->named.
646 data,
647 op->named.
648 length,
649 walk_state);
650 }
651 walk_state->operands[0] = NULL;
652 walk_state->num_operands = 0;
653
654 if (ACPI_FAILURE(status)) {
655 return_ACPI_STATUS(status);
656 }
657 }
658 break;
659
660#endif /* ACPI_NO_METHOD_EXECUTION */
661
662 default:
663 /* All NAMED_COMPLEX opcodes must be handled above */
664 break;
665 }
666 break;
667
668 case AML_CLASS_INTERNAL:
669
670 /* case AML_INT_NAMEPATH_OP: */
671 break;
672
673 case AML_CLASS_METHOD_CALL:
674
675 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
676 "RESOLVING-MethodCall: State=%p Op=%p NamedObj=%p\n",
677 walk_state, op, node));
678
679 /*
680 * Lookup the method name and save the Node
681 */
682 status =
683 acpi_ns_lookup(walk_state->scope_info,
684 arg->common.value.string, ACPI_TYPE_ANY,
685 ACPI_IMODE_LOAD_PASS2,
686 ACPI_NS_SEARCH_PARENT |
687 ACPI_NS_DONT_OPEN_SCOPE, walk_state,
688 &(new_node));
689 if (ACPI_SUCCESS(status)) {
690 /*
691 * Make sure that what we found is indeed a method
692 * We didn't search for a method on purpose, to see if the name
693 * would resolve
694 */
695 if (new_node->type != ACPI_TYPE_METHOD) {
696 status = AE_AML_OPERAND_TYPE;
697 }
698
699 /* We could put the returned object (Node) on the object stack for
700 * later, but for now, we will put it in the "op" object that the
701 * parser uses, so we can get it again at the end of this scope
702 */
703 op->common.node = new_node;
704 } else {
705 ACPI_ERROR_NAMESPACE(arg->common.value.string, status);
706 }
707 break;
708
709 default:
710 break;
711 }
712
713 cleanup:
714
715 /* Remove the Node pushed at the very beginning */
716
717 walk_state->operands[0] = NULL;
718 walk_state->num_operands = 0;
719 return_ACPI_STATUS(status);
720}
diff --git a/drivers/acpi/acpica/evgpe.c b/drivers/acpi/acpica/evgpe.c
index f4725212eb48..65c79add3b19 100644
--- a/drivers/acpi/acpica/evgpe.c
+++ b/drivers/acpi/acpica/evgpe.c
@@ -373,6 +373,15 @@ u32 acpi_ev_gpe_detect(struct acpi_gpe_xrupt_info * gpe_xrupt_list)
373 373
374 gpe_register_info = &gpe_block->register_info[i]; 374 gpe_register_info = &gpe_block->register_info[i];
375 375
376 /*
377 * Optimization: If there are no GPEs enabled within this
378 * register, we can safely ignore the entire register.
379 */
380 if (!(gpe_register_info->enable_for_run |
381 gpe_register_info->enable_for_wake)) {
382 continue;
383 }
384
376 /* Read the Status Register */ 385 /* Read the Status Register */
377 386
378 status = 387 status =
diff --git a/drivers/acpi/acpica/evregion.c b/drivers/acpi/acpica/evregion.c
index 785a5ee64585..bea7223d7a71 100644
--- a/drivers/acpi/acpica/evregion.c
+++ b/drivers/acpi/acpica/evregion.c
@@ -231,6 +231,8 @@ acpi_status acpi_ev_initialize_op_regions(void)
231 } 231 }
232 } 232 }
233 233
234 acpi_gbl_reg_methods_executed = TRUE;
235
234 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); 236 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
235 return_ACPI_STATUS(status); 237 return_ACPI_STATUS(status);
236} 238}
diff --git a/drivers/acpi/acpica/evxfregn.c b/drivers/acpi/acpica/evxfregn.c
index eb7386763712..c85c8c45599d 100644
--- a/drivers/acpi/acpica/evxfregn.c
+++ b/drivers/acpi/acpica/evxfregn.c
@@ -110,9 +110,39 @@ acpi_install_address_space_handler(acpi_handle device,
110 goto unlock_and_exit; 110 goto unlock_and_exit;
111 } 111 }
112 112
113 /* Run all _REG methods for this address space */ 113 /*
114 * For the default space_iDs, (the IDs for which there are default region handlers
115 * installed) Only execute the _REG methods if the global initialization _REG
116 * methods have already been run (via acpi_initialize_objects). In other words,
117 * we will defer the execution of the _REG methods for these space_iDs until
118 * execution of acpi_initialize_objects. This is done because we need the handlers
119 * for the default spaces (mem/io/pci/table) to be installed before we can run
120 * any control methods (or _REG methods). There is known BIOS code that depends
121 * on this.
122 *
123 * For all other space_iDs, we can safely execute the _REG methods immediately.
124 * This means that for IDs like embedded_controller, this function should be called
125 * only after acpi_enable_subsystem has been called.
126 */
127 switch (space_id) {
128 case ACPI_ADR_SPACE_SYSTEM_MEMORY:
129 case ACPI_ADR_SPACE_SYSTEM_IO:
130 case ACPI_ADR_SPACE_PCI_CONFIG:
131 case ACPI_ADR_SPACE_DATA_TABLE:
132
133 if (acpi_gbl_reg_methods_executed) {
134
135 /* Run all _REG methods for this address space */
136
137 status = acpi_ev_execute_reg_methods(node, space_id);
138 }
139 break;
140
141 default:
114 142
115 status = acpi_ev_execute_reg_methods(node, space_id); 143 status = acpi_ev_execute_reg_methods(node, space_id);
144 break;
145 }
116 146
117 unlock_and_exit: 147 unlock_and_exit:
118 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); 148 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
diff --git a/drivers/acpi/acpica/exfldio.c b/drivers/acpi/acpica/exfldio.c
index 6c79c29f082d..f915a7f3f921 100644
--- a/drivers/acpi/acpica/exfldio.c
+++ b/drivers/acpi/acpica/exfldio.c
@@ -280,13 +280,13 @@ acpi_ex_access_region(union acpi_operand_object *obj_desc,
280 if (ACPI_FAILURE(status)) { 280 if (ACPI_FAILURE(status)) {
281 if (status == AE_NOT_IMPLEMENTED) { 281 if (status == AE_NOT_IMPLEMENTED) {
282 ACPI_ERROR((AE_INFO, 282 ACPI_ERROR((AE_INFO,
283 "Region %s(0x%X) not implemented", 283 "Region %s (ID=%u) not implemented",
284 acpi_ut_get_region_name(rgn_desc->region. 284 acpi_ut_get_region_name(rgn_desc->region.
285 space_id), 285 space_id),
286 rgn_desc->region.space_id)); 286 rgn_desc->region.space_id));
287 } else if (status == AE_NOT_EXIST) { 287 } else if (status == AE_NOT_EXIST) {
288 ACPI_ERROR((AE_INFO, 288 ACPI_ERROR((AE_INFO,
289 "Region %s(0x%X) has no handler", 289 "Region %s (ID=%u) has no handler",
290 acpi_ut_get_region_name(rgn_desc->region. 290 acpi_ut_get_region_name(rgn_desc->region.
291 space_id), 291 space_id),
292 rgn_desc->region.space_id)); 292 rgn_desc->region.space_id));
diff --git a/drivers/acpi/acpica/hwxface.c b/drivers/acpi/acpica/hwxface.c
index 6f98d210e71c..f75f81ad15c9 100644
--- a/drivers/acpi/acpica/hwxface.c
+++ b/drivers/acpi/acpica/hwxface.c
@@ -80,14 +80,14 @@ acpi_status acpi_reset(void)
80 80
81 if (reset_reg->space_id == ACPI_ADR_SPACE_SYSTEM_IO) { 81 if (reset_reg->space_id == ACPI_ADR_SPACE_SYSTEM_IO) {
82 /* 82 /*
83 * For I/O space, write directly to the OSL. This bypasses the port 83 * For I/O space, write directly to the OSL. This
84 * validation mechanism, which may block a valid write to the reset 84 * bypasses the port validation mechanism, which may
85 * register. 85 * block a valid write to the reset register. Spec
86 * section 4.7.3.6 requires register width to be 8.
86 */ 87 */
87 status = 88 status =
88 acpi_os_write_port((acpi_io_address) reset_reg->address, 89 acpi_os_write_port((acpi_io_address) reset_reg->address,
89 acpi_gbl_FADT.reset_value, 90 acpi_gbl_FADT.reset_value, 8);
90 reset_reg->bit_width);
91 } else { 91 } else {
92 /* Write the reset value to the reset register */ 92 /* Write the reset value to the reset register */
93 93
diff --git a/drivers/acpi/acpica/tbfadt.c b/drivers/acpi/acpica/tbfadt.c
index 428d44e2d162..6f5588e62c0a 100644
--- a/drivers/acpi/acpica/tbfadt.c
+++ b/drivers/acpi/acpica/tbfadt.c
@@ -384,8 +384,11 @@ static void acpi_tb_convert_fadt(void)
384 * 384 *
385 * The ACPI 1.0 reserved fields that will be zeroed are the bytes located at 385 * The ACPI 1.0 reserved fields that will be zeroed are the bytes located at
386 * offset 45, 55, 95, and the word located at offset 109, 110. 386 * offset 45, 55, 95, and the word located at offset 109, 110.
387 *
388 * Note: The FADT revision value is unreliable. Only the length can be
389 * trusted.
387 */ 390 */
388 if (acpi_gbl_FADT.header.revision < FADT2_REVISION_ID) { 391 if (acpi_gbl_FADT.header.length <= ACPI_FADT_V2_SIZE) {
389 acpi_gbl_FADT.preferred_profile = 0; 392 acpi_gbl_FADT.preferred_profile = 0;
390 acpi_gbl_FADT.pstate_control = 0; 393 acpi_gbl_FADT.pstate_control = 0;
391 acpi_gbl_FADT.cst_control = 0; 394 acpi_gbl_FADT.cst_control = 0;
diff --git a/drivers/acpi/acpica/utdecode.c b/drivers/acpi/acpica/utdecode.c
new file mode 100644
index 000000000000..136a814cec69
--- /dev/null
+++ b/drivers/acpi/acpica/utdecode.c
@@ -0,0 +1,548 @@
1/******************************************************************************
2 *
3 * Module Name: utdecode - Utility decoding routines (value-to-string)
4 *
5 *****************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44#include <acpi/acpi.h>
45#include "accommon.h"
46#include "acnamesp.h"
47
48#define _COMPONENT ACPI_UTILITIES
49ACPI_MODULE_NAME("utdecode")
50
51/*******************************************************************************
52 *
53 * FUNCTION: acpi_format_exception
54 *
55 * PARAMETERS: Status - The acpi_status code to be formatted
56 *
57 * RETURN: A string containing the exception text. A valid pointer is
58 * always returned.
59 *
60 * DESCRIPTION: This function translates an ACPI exception into an ASCII string
61 * It is here instead of utxface.c so it is always present.
62 *
63 ******************************************************************************/
64const char *acpi_format_exception(acpi_status status)
65{
66 const char *exception = NULL;
67
68 ACPI_FUNCTION_ENTRY();
69
70 exception = acpi_ut_validate_exception(status);
71 if (!exception) {
72
73 /* Exception code was not recognized */
74
75 ACPI_ERROR((AE_INFO,
76 "Unknown exception code: 0x%8.8X", status));
77
78 exception = "UNKNOWN_STATUS_CODE";
79 }
80
81 return (ACPI_CAST_PTR(const char, exception));
82}
83
84ACPI_EXPORT_SYMBOL(acpi_format_exception)
85
86/*
87 * Properties of the ACPI Object Types, both internal and external.
88 * The table is indexed by values of acpi_object_type
89 */
90const u8 acpi_gbl_ns_properties[ACPI_NUM_NS_TYPES] = {
91 ACPI_NS_NORMAL, /* 00 Any */
92 ACPI_NS_NORMAL, /* 01 Number */
93 ACPI_NS_NORMAL, /* 02 String */
94 ACPI_NS_NORMAL, /* 03 Buffer */
95 ACPI_NS_NORMAL, /* 04 Package */
96 ACPI_NS_NORMAL, /* 05 field_unit */
97 ACPI_NS_NEWSCOPE, /* 06 Device */
98 ACPI_NS_NORMAL, /* 07 Event */
99 ACPI_NS_NEWSCOPE, /* 08 Method */
100 ACPI_NS_NORMAL, /* 09 Mutex */
101 ACPI_NS_NORMAL, /* 10 Region */
102 ACPI_NS_NEWSCOPE, /* 11 Power */
103 ACPI_NS_NEWSCOPE, /* 12 Processor */
104 ACPI_NS_NEWSCOPE, /* 13 Thermal */
105 ACPI_NS_NORMAL, /* 14 buffer_field */
106 ACPI_NS_NORMAL, /* 15 ddb_handle */
107 ACPI_NS_NORMAL, /* 16 Debug Object */
108 ACPI_NS_NORMAL, /* 17 def_field */
109 ACPI_NS_NORMAL, /* 18 bank_field */
110 ACPI_NS_NORMAL, /* 19 index_field */
111 ACPI_NS_NORMAL, /* 20 Reference */
112 ACPI_NS_NORMAL, /* 21 Alias */
113 ACPI_NS_NORMAL, /* 22 method_alias */
114 ACPI_NS_NORMAL, /* 23 Notify */
115 ACPI_NS_NORMAL, /* 24 Address Handler */
116 ACPI_NS_NEWSCOPE | ACPI_NS_LOCAL, /* 25 Resource Desc */
117 ACPI_NS_NEWSCOPE | ACPI_NS_LOCAL, /* 26 Resource Field */
118 ACPI_NS_NEWSCOPE, /* 27 Scope */
119 ACPI_NS_NORMAL, /* 28 Extra */
120 ACPI_NS_NORMAL, /* 29 Data */
121 ACPI_NS_NORMAL /* 30 Invalid */
122};
123
124/*******************************************************************************
125 *
126 * FUNCTION: acpi_ut_hex_to_ascii_char
127 *
128 * PARAMETERS: Integer - Contains the hex digit
129 * Position - bit position of the digit within the
130 * integer (multiple of 4)
131 *
132 * RETURN: The converted Ascii character
133 *
134 * DESCRIPTION: Convert a hex digit to an Ascii character
135 *
136 ******************************************************************************/
137
138/* Hex to ASCII conversion table */
139
140static const char acpi_gbl_hex_to_ascii[] = {
141 '0', '1', '2', '3', '4', '5', '6', '7',
142 '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'
143};
144
145char acpi_ut_hex_to_ascii_char(u64 integer, u32 position)
146{
147
148 return (acpi_gbl_hex_to_ascii[(integer >> position) & 0xF]);
149}
150
151/*******************************************************************************
152 *
153 * FUNCTION: acpi_ut_get_region_name
154 *
155 * PARAMETERS: Space ID - ID for the region
156 *
157 * RETURN: Decoded region space_id name
158 *
159 * DESCRIPTION: Translate a Space ID into a name string (Debug only)
160 *
161 ******************************************************************************/
162
163/* Region type decoding */
164
165const char *acpi_gbl_region_types[ACPI_NUM_PREDEFINED_REGIONS] = {
166 "SystemMemory",
167 "SystemIO",
168 "PCI_Config",
169 "EmbeddedControl",
170 "SMBus",
171 "SystemCMOS",
172 "PCIBARTarget",
173 "IPMI",
174 "DataTable"
175};
176
177char *acpi_ut_get_region_name(u8 space_id)
178{
179
180 if (space_id >= ACPI_USER_REGION_BEGIN) {
181 return ("UserDefinedRegion");
182 } else if (space_id == ACPI_ADR_SPACE_FIXED_HARDWARE) {
183 return ("FunctionalFixedHW");
184 } else if (space_id >= ACPI_NUM_PREDEFINED_REGIONS) {
185 return ("InvalidSpaceId");
186 }
187
188 return (ACPI_CAST_PTR(char, acpi_gbl_region_types[space_id]));
189}
190
191/*******************************************************************************
192 *
193 * FUNCTION: acpi_ut_get_event_name
194 *
195 * PARAMETERS: event_id - Fixed event ID
196 *
197 * RETURN: Decoded event ID name
198 *
199 * DESCRIPTION: Translate a Event ID into a name string (Debug only)
200 *
201 ******************************************************************************/
202
203/* Event type decoding */
204
205static const char *acpi_gbl_event_types[ACPI_NUM_FIXED_EVENTS] = {
206 "PM_Timer",
207 "GlobalLock",
208 "PowerButton",
209 "SleepButton",
210 "RealTimeClock",
211};
212
213char *acpi_ut_get_event_name(u32 event_id)
214{
215
216 if (event_id > ACPI_EVENT_MAX) {
217 return ("InvalidEventID");
218 }
219
220 return (ACPI_CAST_PTR(char, acpi_gbl_event_types[event_id]));
221}
222
223/*******************************************************************************
224 *
225 * FUNCTION: acpi_ut_get_type_name
226 *
227 * PARAMETERS: Type - An ACPI object type
228 *
229 * RETURN: Decoded ACPI object type name
230 *
231 * DESCRIPTION: Translate a Type ID into a name string (Debug only)
232 *
233 ******************************************************************************/
234
235/*
236 * Elements of acpi_gbl_ns_type_names below must match
237 * one-to-one with values of acpi_object_type
238 *
239 * The type ACPI_TYPE_ANY (Untyped) is used as a "don't care" when searching;
240 * when stored in a table it really means that we have thus far seen no
241 * evidence to indicate what type is actually going to be stored for this entry.
242 */
243static const char acpi_gbl_bad_type[] = "UNDEFINED";
244
245/* Printable names of the ACPI object types */
246
247static const char *acpi_gbl_ns_type_names[] = {
248 /* 00 */ "Untyped",
249 /* 01 */ "Integer",
250 /* 02 */ "String",
251 /* 03 */ "Buffer",
252 /* 04 */ "Package",
253 /* 05 */ "FieldUnit",
254 /* 06 */ "Device",
255 /* 07 */ "Event",
256 /* 08 */ "Method",
257 /* 09 */ "Mutex",
258 /* 10 */ "Region",
259 /* 11 */ "Power",
260 /* 12 */ "Processor",
261 /* 13 */ "Thermal",
262 /* 14 */ "BufferField",
263 /* 15 */ "DdbHandle",
264 /* 16 */ "DebugObject",
265 /* 17 */ "RegionField",
266 /* 18 */ "BankField",
267 /* 19 */ "IndexField",
268 /* 20 */ "Reference",
269 /* 21 */ "Alias",
270 /* 22 */ "MethodAlias",
271 /* 23 */ "Notify",
272 /* 24 */ "AddrHandler",
273 /* 25 */ "ResourceDesc",
274 /* 26 */ "ResourceFld",
275 /* 27 */ "Scope",
276 /* 28 */ "Extra",
277 /* 29 */ "Data",
278 /* 30 */ "Invalid"
279};
280
281char *acpi_ut_get_type_name(acpi_object_type type)
282{
283
284 if (type > ACPI_TYPE_INVALID) {
285 return (ACPI_CAST_PTR(char, acpi_gbl_bad_type));
286 }
287
288 return (ACPI_CAST_PTR(char, acpi_gbl_ns_type_names[type]));
289}
290
291char *acpi_ut_get_object_type_name(union acpi_operand_object *obj_desc)
292{
293
294 if (!obj_desc) {
295 return ("[NULL Object Descriptor]");
296 }
297
298 return (acpi_ut_get_type_name(obj_desc->common.type));
299}
300
301/*******************************************************************************
302 *
303 * FUNCTION: acpi_ut_get_node_name
304 *
305 * PARAMETERS: Object - A namespace node
306 *
307 * RETURN: ASCII name of the node
308 *
309 * DESCRIPTION: Validate the node and return the node's ACPI name.
310 *
311 ******************************************************************************/
312
313char *acpi_ut_get_node_name(void *object)
314{
315 struct acpi_namespace_node *node = (struct acpi_namespace_node *)object;
316
317 /* Must return a string of exactly 4 characters == ACPI_NAME_SIZE */
318
319 if (!object) {
320 return ("NULL");
321 }
322
323 /* Check for Root node */
324
325 if ((object == ACPI_ROOT_OBJECT) || (object == acpi_gbl_root_node)) {
326 return ("\"\\\" ");
327 }
328
329 /* Descriptor must be a namespace node */
330
331 if (ACPI_GET_DESCRIPTOR_TYPE(node) != ACPI_DESC_TYPE_NAMED) {
332 return ("####");
333 }
334
335 /*
336 * Ensure name is valid. The name was validated/repaired when the node
337 * was created, but make sure it has not been corrupted.
338 */
339 acpi_ut_repair_name(node->name.ascii);
340
341 /* Return the name */
342
343 return (node->name.ascii);
344}
345
346/*******************************************************************************
347 *
348 * FUNCTION: acpi_ut_get_descriptor_name
349 *
350 * PARAMETERS: Object - An ACPI object
351 *
352 * RETURN: Decoded name of the descriptor type
353 *
354 * DESCRIPTION: Validate object and return the descriptor type
355 *
356 ******************************************************************************/
357
358/* Printable names of object descriptor types */
359
360static const char *acpi_gbl_desc_type_names[] = {
361 /* 00 */ "Not a Descriptor",
362 /* 01 */ "Cached",
363 /* 02 */ "State-Generic",
364 /* 03 */ "State-Update",
365 /* 04 */ "State-Package",
366 /* 05 */ "State-Control",
367 /* 06 */ "State-RootParseScope",
368 /* 07 */ "State-ParseScope",
369 /* 08 */ "State-WalkScope",
370 /* 09 */ "State-Result",
371 /* 10 */ "State-Notify",
372 /* 11 */ "State-Thread",
373 /* 12 */ "Walk",
374 /* 13 */ "Parser",
375 /* 14 */ "Operand",
376 /* 15 */ "Node"
377};
378
379char *acpi_ut_get_descriptor_name(void *object)
380{
381
382 if (!object) {
383 return ("NULL OBJECT");
384 }
385
386 if (ACPI_GET_DESCRIPTOR_TYPE(object) > ACPI_DESC_TYPE_MAX) {
387 return ("Not a Descriptor");
388 }
389
390 return (ACPI_CAST_PTR(char,
391 acpi_gbl_desc_type_names[ACPI_GET_DESCRIPTOR_TYPE
392 (object)]));
393
394}
395
396/*******************************************************************************
397 *
398 * FUNCTION: acpi_ut_get_reference_name
399 *
400 * PARAMETERS: Object - An ACPI reference object
401 *
402 * RETURN: Decoded name of the type of reference
403 *
404 * DESCRIPTION: Decode a reference object sub-type to a string.
405 *
406 ******************************************************************************/
407
408/* Printable names of reference object sub-types */
409
410static const char *acpi_gbl_ref_class_names[] = {
411 /* 00 */ "Local",
412 /* 01 */ "Argument",
413 /* 02 */ "RefOf",
414 /* 03 */ "Index",
415 /* 04 */ "DdbHandle",
416 /* 05 */ "Named Object",
417 /* 06 */ "Debug"
418};
419
420const char *acpi_ut_get_reference_name(union acpi_operand_object *object)
421{
422
423 if (!object) {
424 return ("NULL Object");
425 }
426
427 if (ACPI_GET_DESCRIPTOR_TYPE(object) != ACPI_DESC_TYPE_OPERAND) {
428 return ("Not an Operand object");
429 }
430
431 if (object->common.type != ACPI_TYPE_LOCAL_REFERENCE) {
432 return ("Not a Reference object");
433 }
434
435 if (object->reference.class > ACPI_REFCLASS_MAX) {
436 return ("Unknown Reference class");
437 }
438
439 return (acpi_gbl_ref_class_names[object->reference.class]);
440}
441
442#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
443/*
444 * Strings and procedures used for debug only
445 */
446
447/*******************************************************************************
448 *
449 * FUNCTION: acpi_ut_get_mutex_name
450 *
451 * PARAMETERS: mutex_id - The predefined ID for this mutex.
452 *
453 * RETURN: Decoded name of the internal mutex
454 *
455 * DESCRIPTION: Translate a mutex ID into a name string (Debug only)
456 *
457 ******************************************************************************/
458
459/* Names for internal mutex objects, used for debug output */
460
461static char *acpi_gbl_mutex_names[ACPI_NUM_MUTEX] = {
462 "ACPI_MTX_Interpreter",
463 "ACPI_MTX_Namespace",
464 "ACPI_MTX_Tables",
465 "ACPI_MTX_Events",
466 "ACPI_MTX_Caches",
467 "ACPI_MTX_Memory",
468 "ACPI_MTX_CommandComplete",
469 "ACPI_MTX_CommandReady"
470};
471
472char *acpi_ut_get_mutex_name(u32 mutex_id)
473{
474
475 if (mutex_id > ACPI_MAX_MUTEX) {
476 return ("Invalid Mutex ID");
477 }
478
479 return (acpi_gbl_mutex_names[mutex_id]);
480}
481
482/*******************************************************************************
483 *
484 * FUNCTION: acpi_ut_get_notify_name
485 *
486 * PARAMETERS: notify_value - Value from the Notify() request
487 *
488 * RETURN: Decoded name for the notify value
489 *
490 * DESCRIPTION: Translate a Notify Value to a notify namestring.
491 *
492 ******************************************************************************/
493
494/* Names for Notify() values, used for debug output */
495
496static const char *acpi_gbl_notify_value_names[] = {
497 "Bus Check",
498 "Device Check",
499 "Device Wake",
500 "Eject Request",
501 "Device Check Light",
502 "Frequency Mismatch",
503 "Bus Mode Mismatch",
504 "Power Fault",
505 "Capabilities Check",
506 "Device PLD Check",
507 "Reserved",
508 "System Locality Update"
509};
510
511const char *acpi_ut_get_notify_name(u32 notify_value)
512{
513
514 if (notify_value <= ACPI_NOTIFY_MAX) {
515 return (acpi_gbl_notify_value_names[notify_value]);
516 } else if (notify_value <= ACPI_MAX_SYS_NOTIFY) {
517 return ("Reserved");
518 } else { /* Greater or equal to 0x80 */
519
520 return ("**Device Specific**");
521 }
522}
523#endif
524
525/*******************************************************************************
526 *
527 * FUNCTION: acpi_ut_valid_object_type
528 *
529 * PARAMETERS: Type - Object type to be validated
530 *
531 * RETURN: TRUE if valid object type, FALSE otherwise
532 *
533 * DESCRIPTION: Validate an object type
534 *
535 ******************************************************************************/
536
537u8 acpi_ut_valid_object_type(acpi_object_type type)
538{
539
540 if (type > ACPI_TYPE_LOCAL_MAX) {
541
542 /* Note: Assumes all TYPEs are contiguous (external/local) */
543
544 return (FALSE);
545 }
546
547 return (TRUE);
548}
diff --git a/drivers/acpi/acpica/utglobal.c b/drivers/acpi/acpica/utglobal.c
index 97dd9bbf055a..833a38a9c905 100644
--- a/drivers/acpi/acpica/utglobal.c
+++ b/drivers/acpi/acpica/utglobal.c
@@ -45,7 +45,6 @@
45 45
46#include <acpi/acpi.h> 46#include <acpi/acpi.h>
47#include "accommon.h" 47#include "accommon.h"
48#include "acnamesp.h"
49 48
50#define _COMPONENT ACPI_UTILITIES 49#define _COMPONENT ACPI_UTILITIES
51ACPI_MODULE_NAME("utglobal") 50ACPI_MODULE_NAME("utglobal")
@@ -107,43 +106,6 @@ const char *acpi_gbl_highest_dstate_names[ACPI_NUM_sx_d_METHODS] = {
107 106
108/******************************************************************************* 107/*******************************************************************************
109 * 108 *
110 * FUNCTION: acpi_format_exception
111 *
112 * PARAMETERS: Status - The acpi_status code to be formatted
113 *
114 * RETURN: A string containing the exception text. A valid pointer is
115 * always returned.
116 *
117 * DESCRIPTION: This function translates an ACPI exception into an ASCII string
118 * It is here instead of utxface.c so it is always present.
119 *
120 ******************************************************************************/
121
122const char *acpi_format_exception(acpi_status status)
123{
124 const char *exception = NULL;
125
126 ACPI_FUNCTION_ENTRY();
127
128 exception = acpi_ut_validate_exception(status);
129 if (!exception) {
130
131 /* Exception code was not recognized */
132
133 ACPI_ERROR((AE_INFO,
134 "Unknown exception code: 0x%8.8X", status));
135
136 exception = "UNKNOWN_STATUS_CODE";
137 dump_stack();
138 }
139
140 return (ACPI_CAST_PTR(const char, exception));
141}
142
143ACPI_EXPORT_SYMBOL(acpi_format_exception)
144
145/*******************************************************************************
146 *
147 * Namespace globals 109 * Namespace globals
148 * 110 *
149 ******************************************************************************/ 111 ******************************************************************************/
@@ -177,71 +139,6 @@ const struct acpi_predefined_names acpi_gbl_pre_defined_names[] = {
177 {NULL, ACPI_TYPE_ANY, NULL} 139 {NULL, ACPI_TYPE_ANY, NULL}
178}; 140};
179 141
180/*
181 * Properties of the ACPI Object Types, both internal and external.
182 * The table is indexed by values of acpi_object_type
183 */
184const u8 acpi_gbl_ns_properties[] = {
185 ACPI_NS_NORMAL, /* 00 Any */
186 ACPI_NS_NORMAL, /* 01 Number */
187 ACPI_NS_NORMAL, /* 02 String */
188 ACPI_NS_NORMAL, /* 03 Buffer */
189 ACPI_NS_NORMAL, /* 04 Package */
190 ACPI_NS_NORMAL, /* 05 field_unit */
191 ACPI_NS_NEWSCOPE, /* 06 Device */
192 ACPI_NS_NORMAL, /* 07 Event */
193 ACPI_NS_NEWSCOPE, /* 08 Method */
194 ACPI_NS_NORMAL, /* 09 Mutex */
195 ACPI_NS_NORMAL, /* 10 Region */
196 ACPI_NS_NEWSCOPE, /* 11 Power */
197 ACPI_NS_NEWSCOPE, /* 12 Processor */
198 ACPI_NS_NEWSCOPE, /* 13 Thermal */
199 ACPI_NS_NORMAL, /* 14 buffer_field */
200 ACPI_NS_NORMAL, /* 15 ddb_handle */
201 ACPI_NS_NORMAL, /* 16 Debug Object */
202 ACPI_NS_NORMAL, /* 17 def_field */
203 ACPI_NS_NORMAL, /* 18 bank_field */
204 ACPI_NS_NORMAL, /* 19 index_field */
205 ACPI_NS_NORMAL, /* 20 Reference */
206 ACPI_NS_NORMAL, /* 21 Alias */
207 ACPI_NS_NORMAL, /* 22 method_alias */
208 ACPI_NS_NORMAL, /* 23 Notify */
209 ACPI_NS_NORMAL, /* 24 Address Handler */
210 ACPI_NS_NEWSCOPE | ACPI_NS_LOCAL, /* 25 Resource Desc */
211 ACPI_NS_NEWSCOPE | ACPI_NS_LOCAL, /* 26 Resource Field */
212 ACPI_NS_NEWSCOPE, /* 27 Scope */
213 ACPI_NS_NORMAL, /* 28 Extra */
214 ACPI_NS_NORMAL, /* 29 Data */
215 ACPI_NS_NORMAL /* 30 Invalid */
216};
217
218/* Hex to ASCII conversion table */
219
220static const char acpi_gbl_hex_to_ascii[] = {
221 '0', '1', '2', '3', '4', '5', '6', '7',
222 '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'
223};
224
225/*******************************************************************************
226 *
227 * FUNCTION: acpi_ut_hex_to_ascii_char
228 *
229 * PARAMETERS: Integer - Contains the hex digit
230 * Position - bit position of the digit within the
231 * integer (multiple of 4)
232 *
233 * RETURN: The converted Ascii character
234 *
235 * DESCRIPTION: Convert a hex digit to an Ascii character
236 *
237 ******************************************************************************/
238
239char acpi_ut_hex_to_ascii_char(u64 integer, u32 position)
240{
241
242 return (acpi_gbl_hex_to_ascii[(integer >> position) & 0xF]);
243}
244
245/****************************************************************************** 142/******************************************************************************
246 * 143 *
247 * Event and Hardware globals 144 * Event and Hardware globals
@@ -341,386 +238,6 @@ struct acpi_fixed_event_info acpi_gbl_fixed_event_info[ACPI_NUM_FIXED_EVENTS] =
341 238
342/******************************************************************************* 239/*******************************************************************************
343 * 240 *
344 * FUNCTION: acpi_ut_get_region_name
345 *
346 * PARAMETERS: None.
347 *
348 * RETURN: Status
349 *
350 * DESCRIPTION: Translate a Space ID into a name string (Debug only)
351 *
352 ******************************************************************************/
353
354/* Region type decoding */
355
356const char *acpi_gbl_region_types[ACPI_NUM_PREDEFINED_REGIONS] = {
357 "SystemMemory",
358 "SystemIO",
359 "PCI_Config",
360 "EmbeddedControl",
361 "SMBus",
362 "SystemCMOS",
363 "PCIBARTarget",
364 "IPMI",
365 "DataTable"
366};
367
368char *acpi_ut_get_region_name(u8 space_id)
369{
370
371 if (space_id >= ACPI_USER_REGION_BEGIN) {
372 return ("UserDefinedRegion");
373 } else if (space_id >= ACPI_NUM_PREDEFINED_REGIONS) {
374 return ("InvalidSpaceId");
375 }
376
377 return (ACPI_CAST_PTR(char, acpi_gbl_region_types[space_id]));
378}
379
380/*******************************************************************************
381 *
382 * FUNCTION: acpi_ut_get_event_name
383 *
384 * PARAMETERS: None.
385 *
386 * RETURN: Status
387 *
388 * DESCRIPTION: Translate a Event ID into a name string (Debug only)
389 *
390 ******************************************************************************/
391
392/* Event type decoding */
393
394static const char *acpi_gbl_event_types[ACPI_NUM_FIXED_EVENTS] = {
395 "PM_Timer",
396 "GlobalLock",
397 "PowerButton",
398 "SleepButton",
399 "RealTimeClock",
400};
401
402char *acpi_ut_get_event_name(u32 event_id)
403{
404
405 if (event_id > ACPI_EVENT_MAX) {
406 return ("InvalidEventID");
407 }
408
409 return (ACPI_CAST_PTR(char, acpi_gbl_event_types[event_id]));
410}
411
412/*******************************************************************************
413 *
414 * FUNCTION: acpi_ut_get_type_name
415 *
416 * PARAMETERS: None.
417 *
418 * RETURN: Status
419 *
420 * DESCRIPTION: Translate a Type ID into a name string (Debug only)
421 *
422 ******************************************************************************/
423
424/*
425 * Elements of acpi_gbl_ns_type_names below must match
426 * one-to-one with values of acpi_object_type
427 *
428 * The type ACPI_TYPE_ANY (Untyped) is used as a "don't care" when searching;
429 * when stored in a table it really means that we have thus far seen no
430 * evidence to indicate what type is actually going to be stored for this entry.
431 */
432static const char acpi_gbl_bad_type[] = "UNDEFINED";
433
434/* Printable names of the ACPI object types */
435
436static const char *acpi_gbl_ns_type_names[] = {
437 /* 00 */ "Untyped",
438 /* 01 */ "Integer",
439 /* 02 */ "String",
440 /* 03 */ "Buffer",
441 /* 04 */ "Package",
442 /* 05 */ "FieldUnit",
443 /* 06 */ "Device",
444 /* 07 */ "Event",
445 /* 08 */ "Method",
446 /* 09 */ "Mutex",
447 /* 10 */ "Region",
448 /* 11 */ "Power",
449 /* 12 */ "Processor",
450 /* 13 */ "Thermal",
451 /* 14 */ "BufferField",
452 /* 15 */ "DdbHandle",
453 /* 16 */ "DebugObject",
454 /* 17 */ "RegionField",
455 /* 18 */ "BankField",
456 /* 19 */ "IndexField",
457 /* 20 */ "Reference",
458 /* 21 */ "Alias",
459 /* 22 */ "MethodAlias",
460 /* 23 */ "Notify",
461 /* 24 */ "AddrHandler",
462 /* 25 */ "ResourceDesc",
463 /* 26 */ "ResourceFld",
464 /* 27 */ "Scope",
465 /* 28 */ "Extra",
466 /* 29 */ "Data",
467 /* 30 */ "Invalid"
468};
469
470char *acpi_ut_get_type_name(acpi_object_type type)
471{
472
473 if (type > ACPI_TYPE_INVALID) {
474 return (ACPI_CAST_PTR(char, acpi_gbl_bad_type));
475 }
476
477 return (ACPI_CAST_PTR(char, acpi_gbl_ns_type_names[type]));
478}
479
480char *acpi_ut_get_object_type_name(union acpi_operand_object *obj_desc)
481{
482
483 if (!obj_desc) {
484 return ("[NULL Object Descriptor]");
485 }
486
487 return (acpi_ut_get_type_name(obj_desc->common.type));
488}
489
490/*******************************************************************************
491 *
492 * FUNCTION: acpi_ut_get_node_name
493 *
494 * PARAMETERS: Object - A namespace node
495 *
496 * RETURN: Pointer to a string
497 *
498 * DESCRIPTION: Validate the node and return the node's ACPI name.
499 *
500 ******************************************************************************/
501
502char *acpi_ut_get_node_name(void *object)
503{
504 struct acpi_namespace_node *node = (struct acpi_namespace_node *)object;
505
506 /* Must return a string of exactly 4 characters == ACPI_NAME_SIZE */
507
508 if (!object) {
509 return ("NULL");
510 }
511
512 /* Check for Root node */
513
514 if ((object == ACPI_ROOT_OBJECT) || (object == acpi_gbl_root_node)) {
515 return ("\"\\\" ");
516 }
517
518 /* Descriptor must be a namespace node */
519
520 if (ACPI_GET_DESCRIPTOR_TYPE(node) != ACPI_DESC_TYPE_NAMED) {
521 return ("####");
522 }
523
524 /* Name must be a valid ACPI name */
525
526 if (!acpi_ut_valid_acpi_name(node->name.integer)) {
527 node->name.integer = acpi_ut_repair_name(node->name.ascii);
528 }
529
530 /* Return the name */
531
532 return (node->name.ascii);
533}
534
535/*******************************************************************************
536 *
537 * FUNCTION: acpi_ut_get_descriptor_name
538 *
539 * PARAMETERS: Object - An ACPI object
540 *
541 * RETURN: Pointer to a string
542 *
543 * DESCRIPTION: Validate object and return the descriptor type
544 *
545 ******************************************************************************/
546
547/* Printable names of object descriptor types */
548
549static const char *acpi_gbl_desc_type_names[] = {
550 /* 00 */ "Invalid",
551 /* 01 */ "Cached",
552 /* 02 */ "State-Generic",
553 /* 03 */ "State-Update",
554 /* 04 */ "State-Package",
555 /* 05 */ "State-Control",
556 /* 06 */ "State-RootParseScope",
557 /* 07 */ "State-ParseScope",
558 /* 08 */ "State-WalkScope",
559 /* 09 */ "State-Result",
560 /* 10 */ "State-Notify",
561 /* 11 */ "State-Thread",
562 /* 12 */ "Walk",
563 /* 13 */ "Parser",
564 /* 14 */ "Operand",
565 /* 15 */ "Node"
566};
567
568char *acpi_ut_get_descriptor_name(void *object)
569{
570
571 if (!object) {
572 return ("NULL OBJECT");
573 }
574
575 if (ACPI_GET_DESCRIPTOR_TYPE(object) > ACPI_DESC_TYPE_MAX) {
576 return (ACPI_CAST_PTR(char, acpi_gbl_bad_type));
577 }
578
579 return (ACPI_CAST_PTR(char,
580 acpi_gbl_desc_type_names[ACPI_GET_DESCRIPTOR_TYPE
581 (object)]));
582
583}
584
585/*******************************************************************************
586 *
587 * FUNCTION: acpi_ut_get_reference_name
588 *
589 * PARAMETERS: Object - An ACPI reference object
590 *
591 * RETURN: Pointer to a string
592 *
593 * DESCRIPTION: Decode a reference object sub-type to a string.
594 *
595 ******************************************************************************/
596
597/* Printable names of reference object sub-types */
598
599static const char *acpi_gbl_ref_class_names[] = {
600 /* 00 */ "Local",
601 /* 01 */ "Argument",
602 /* 02 */ "RefOf",
603 /* 03 */ "Index",
604 /* 04 */ "DdbHandle",
605 /* 05 */ "Named Object",
606 /* 06 */ "Debug"
607};
608
609const char *acpi_ut_get_reference_name(union acpi_operand_object *object)
610{
611 if (!object)
612 return "NULL Object";
613
614 if (ACPI_GET_DESCRIPTOR_TYPE(object) != ACPI_DESC_TYPE_OPERAND)
615 return "Not an Operand object";
616
617 if (object->common.type != ACPI_TYPE_LOCAL_REFERENCE)
618 return "Not a Reference object";
619
620 if (object->reference.class > ACPI_REFCLASS_MAX)
621 return "Unknown Reference class";
622
623 return acpi_gbl_ref_class_names[object->reference.class];
624}
625
626#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
627/*
628 * Strings and procedures used for debug only
629 */
630
631/*******************************************************************************
632 *
633 * FUNCTION: acpi_ut_get_mutex_name
634 *
635 * PARAMETERS: mutex_id - The predefined ID for this mutex.
636 *
637 * RETURN: String containing the name of the mutex. Always returns a valid
638 * pointer.
639 *
640 * DESCRIPTION: Translate a mutex ID into a name string (Debug only)
641 *
642 ******************************************************************************/
643
644char *acpi_ut_get_mutex_name(u32 mutex_id)
645{
646
647 if (mutex_id > ACPI_MAX_MUTEX) {
648 return ("Invalid Mutex ID");
649 }
650
651 return (acpi_gbl_mutex_names[mutex_id]);
652}
653
654/*******************************************************************************
655 *
656 * FUNCTION: acpi_ut_get_notify_name
657 *
658 * PARAMETERS: notify_value - Value from the Notify() request
659 *
660 * RETURN: String corresponding to the Notify Value.
661 *
662 * DESCRIPTION: Translate a Notify Value to a notify namestring.
663 *
664 ******************************************************************************/
665
666/* Names for Notify() values, used for debug output */
667
668static const char *acpi_gbl_notify_value_names[] = {
669 "Bus Check",
670 "Device Check",
671 "Device Wake",
672 "Eject Request",
673 "Device Check Light",
674 "Frequency Mismatch",
675 "Bus Mode Mismatch",
676 "Power Fault",
677 "Capabilities Check",
678 "Device PLD Check",
679 "Reserved",
680 "System Locality Update"
681};
682
683const char *acpi_ut_get_notify_name(u32 notify_value)
684{
685
686 if (notify_value <= ACPI_NOTIFY_MAX) {
687 return (acpi_gbl_notify_value_names[notify_value]);
688 } else if (notify_value <= ACPI_MAX_SYS_NOTIFY) {
689 return ("Reserved");
690 } else { /* Greater or equal to 0x80 */
691
692 return ("**Device Specific**");
693 }
694}
695#endif
696
697/*******************************************************************************
698 *
699 * FUNCTION: acpi_ut_valid_object_type
700 *
701 * PARAMETERS: Type - Object type to be validated
702 *
703 * RETURN: TRUE if valid object type, FALSE otherwise
704 *
705 * DESCRIPTION: Validate an object type
706 *
707 ******************************************************************************/
708
709u8 acpi_ut_valid_object_type(acpi_object_type type)
710{
711
712 if (type > ACPI_TYPE_LOCAL_MAX) {
713
714 /* Note: Assumes all TYPEs are contiguous (external/local) */
715
716 return (FALSE);
717 }
718
719 return (TRUE);
720}
721
722/*******************************************************************************
723 *
724 * FUNCTION: acpi_ut_init_globals 241 * FUNCTION: acpi_ut_init_globals
725 * 242 *
726 * PARAMETERS: None 243 * PARAMETERS: None
@@ -806,6 +323,7 @@ acpi_status acpi_ut_init_globals(void)
806 acpi_gbl_db_output_flags = ACPI_DB_CONSOLE_OUTPUT; 323 acpi_gbl_db_output_flags = ACPI_DB_CONSOLE_OUTPUT;
807 acpi_gbl_osi_data = 0; 324 acpi_gbl_osi_data = 0;
808 acpi_gbl_osi_mutex = NULL; 325 acpi_gbl_osi_mutex = NULL;
326 acpi_gbl_reg_methods_executed = FALSE;
809 327
810 /* Hardware oriented */ 328 /* Hardware oriented */
811 329
diff --git a/drivers/acpi/apei/Kconfig b/drivers/acpi/apei/Kconfig
index e91680c7e047..66a03caa2ad9 100644
--- a/drivers/acpi/apei/Kconfig
+++ b/drivers/acpi/apei/Kconfig
@@ -22,6 +22,13 @@ config ACPI_APEI_GHES
22 by firmware to produce more valuable hardware error 22 by firmware to produce more valuable hardware error
23 information for Linux. 23 information for Linux.
24 24
25config ACPI_APEI_PCIEAER
26 bool "APEI PCIe AER logging/recovering support"
27 depends on ACPI_APEI && PCIEAER
28 help
29 PCIe AER errors may be reported via APEI firmware first mode.
30 Turn on this option to enable the corresponding support.
31
25config ACPI_APEI_EINJ 32config ACPI_APEI_EINJ
26 tristate "APEI Error INJection (EINJ)" 33 tristate "APEI Error INJection (EINJ)"
27 depends on ACPI_APEI && DEBUG_FS 34 depends on ACPI_APEI && DEBUG_FS
diff --git a/drivers/acpi/apei/cper.c b/drivers/acpi/apei/cper.c
index 31464a006d76..5d4189464d63 100644
--- a/drivers/acpi/apei/cper.c
+++ b/drivers/acpi/apei/cper.c
@@ -29,6 +29,7 @@
29#include <linux/time.h> 29#include <linux/time.h>
30#include <linux/cper.h> 30#include <linux/cper.h>
31#include <linux/acpi.h> 31#include <linux/acpi.h>
32#include <linux/aer.h>
32 33
33/* 34/*
34 * CPER record ID need to be unique even after reboot, because record 35 * CPER record ID need to be unique even after reboot, because record
@@ -70,8 +71,8 @@ static const char *cper_severity_str(unsigned int severity)
70 * If the output length is longer than 80, multiple line will be 71 * If the output length is longer than 80, multiple line will be
71 * printed, with @pfx is printed at the beginning of each line. 72 * printed, with @pfx is printed at the beginning of each line.
72 */ 73 */
73static void cper_print_bits(const char *pfx, unsigned int bits, 74void cper_print_bits(const char *pfx, unsigned int bits,
74 const char *strs[], unsigned int strs_size) 75 const char *strs[], unsigned int strs_size)
75{ 76{
76 int i, len = 0; 77 int i, len = 0;
77 const char *str; 78 const char *str;
@@ -81,6 +82,8 @@ static void cper_print_bits(const char *pfx, unsigned int bits,
81 if (!(bits & (1U << i))) 82 if (!(bits & (1U << i)))
82 continue; 83 continue;
83 str = strs[i]; 84 str = strs[i];
85 if (!str)
86 continue;
84 if (len && len + strlen(str) + 2 > 80) { 87 if (len && len + strlen(str) + 2 > 80) {
85 printk("%s\n", buf); 88 printk("%s\n", buf);
86 len = 0; 89 len = 0;
@@ -243,7 +246,8 @@ static const char *cper_pcie_port_type_strs[] = {
243 "root complex event collector", 246 "root complex event collector",
244}; 247};
245 248
246static void cper_print_pcie(const char *pfx, const struct cper_sec_pcie *pcie) 249static void cper_print_pcie(const char *pfx, const struct cper_sec_pcie *pcie,
250 const struct acpi_hest_generic_data *gdata)
247{ 251{
248 if (pcie->validation_bits & CPER_PCIE_VALID_PORT_TYPE) 252 if (pcie->validation_bits & CPER_PCIE_VALID_PORT_TYPE)
249 printk("%s""port_type: %d, %s\n", pfx, pcie->port_type, 253 printk("%s""port_type: %d, %s\n", pfx, pcie->port_type,
@@ -276,6 +280,12 @@ static void cper_print_pcie(const char *pfx, const struct cper_sec_pcie *pcie)
276 printk( 280 printk(
277 "%s""bridge: secondary_status: 0x%04x, control: 0x%04x\n", 281 "%s""bridge: secondary_status: 0x%04x, control: 0x%04x\n",
278 pfx, pcie->bridge.secondary_status, pcie->bridge.control); 282 pfx, pcie->bridge.secondary_status, pcie->bridge.control);
283#ifdef CONFIG_ACPI_APEI_PCIEAER
284 if (pcie->validation_bits & CPER_PCIE_VALID_AER_INFO) {
285 struct aer_capability_regs *aer_regs = (void *)pcie->aer_info;
286 cper_print_aer(pfx, gdata->error_severity, aer_regs);
287 }
288#endif
279} 289}
280 290
281static const char *apei_estatus_section_flag_strs[] = { 291static const char *apei_estatus_section_flag_strs[] = {
@@ -322,7 +332,7 @@ static void apei_estatus_print_section(
322 struct cper_sec_pcie *pcie = (void *)(gdata + 1); 332 struct cper_sec_pcie *pcie = (void *)(gdata + 1);
323 printk("%s""section_type: PCIe error\n", pfx); 333 printk("%s""section_type: PCIe error\n", pfx);
324 if (gdata->error_data_length >= sizeof(*pcie)) 334 if (gdata->error_data_length >= sizeof(*pcie))
325 cper_print_pcie(pfx, pcie); 335 cper_print_pcie(pfx, pcie, gdata);
326 else 336 else
327 goto err_section_too_small; 337 goto err_section_too_small;
328 } else 338 } else
diff --git a/drivers/acpi/apei/erst-dbg.c b/drivers/acpi/apei/erst-dbg.c
index de73caf3cebc..a4cfb64c86a1 100644
--- a/drivers/acpi/apei/erst-dbg.c
+++ b/drivers/acpi/apei/erst-dbg.c
@@ -43,12 +43,27 @@ static DEFINE_MUTEX(erst_dbg_mutex);
43 43
44static int erst_dbg_open(struct inode *inode, struct file *file) 44static int erst_dbg_open(struct inode *inode, struct file *file)
45{ 45{
46 int rc, *pos;
47
46 if (erst_disable) 48 if (erst_disable)
47 return -ENODEV; 49 return -ENODEV;
48 50
51 pos = (int *)&file->private_data;
52
53 rc = erst_get_record_id_begin(pos);
54 if (rc)
55 return rc;
56
49 return nonseekable_open(inode, file); 57 return nonseekable_open(inode, file);
50} 58}
51 59
60static int erst_dbg_release(struct inode *inode, struct file *file)
61{
62 erst_get_record_id_end();
63
64 return 0;
65}
66
52static long erst_dbg_ioctl(struct file *f, unsigned int cmd, unsigned long arg) 67static long erst_dbg_ioctl(struct file *f, unsigned int cmd, unsigned long arg)
53{ 68{
54 int rc; 69 int rc;
@@ -79,18 +94,20 @@ static long erst_dbg_ioctl(struct file *f, unsigned int cmd, unsigned long arg)
79static ssize_t erst_dbg_read(struct file *filp, char __user *ubuf, 94static ssize_t erst_dbg_read(struct file *filp, char __user *ubuf,
80 size_t usize, loff_t *off) 95 size_t usize, loff_t *off)
81{ 96{
82 int rc; 97 int rc, *pos;
83 ssize_t len = 0; 98 ssize_t len = 0;
84 u64 id; 99 u64 id;
85 100
86 if (*off != 0) 101 if (*off)
87 return -EINVAL; 102 return -EINVAL;
88 103
89 if (mutex_lock_interruptible(&erst_dbg_mutex) != 0) 104 if (mutex_lock_interruptible(&erst_dbg_mutex) != 0)
90 return -EINTR; 105 return -EINTR;
91 106
107 pos = (int *)&filp->private_data;
108
92retry_next: 109retry_next:
93 rc = erst_get_next_record_id(&id); 110 rc = erst_get_record_id_next(pos, &id);
94 if (rc) 111 if (rc)
95 goto out; 112 goto out;
96 /* no more record */ 113 /* no more record */
@@ -181,6 +198,7 @@ out:
181static const struct file_operations erst_dbg_ops = { 198static const struct file_operations erst_dbg_ops = {
182 .owner = THIS_MODULE, 199 .owner = THIS_MODULE,
183 .open = erst_dbg_open, 200 .open = erst_dbg_open,
201 .release = erst_dbg_release,
184 .read = erst_dbg_read, 202 .read = erst_dbg_read,
185 .write = erst_dbg_write, 203 .write = erst_dbg_write,
186 .unlocked_ioctl = erst_dbg_ioctl, 204 .unlocked_ioctl = erst_dbg_ioctl,
diff --git a/drivers/acpi/apei/erst.c b/drivers/acpi/apei/erst.c
index c02005abce43..d6cb0ff6988e 100644
--- a/drivers/acpi/apei/erst.c
+++ b/drivers/acpi/apei/erst.c
@@ -430,6 +430,22 @@ ssize_t erst_get_record_count(void)
430} 430}
431EXPORT_SYMBOL_GPL(erst_get_record_count); 431EXPORT_SYMBOL_GPL(erst_get_record_count);
432 432
433#define ERST_RECORD_ID_CACHE_SIZE_MIN 16
434#define ERST_RECORD_ID_CACHE_SIZE_MAX 1024
435
436struct erst_record_id_cache {
437 struct mutex lock;
438 u64 *entries;
439 int len;
440 int size;
441 int refcount;
442};
443
444static struct erst_record_id_cache erst_record_id_cache = {
445 .lock = __MUTEX_INITIALIZER(erst_record_id_cache.lock),
446 .refcount = 0,
447};
448
433static int __erst_get_next_record_id(u64 *record_id) 449static int __erst_get_next_record_id(u64 *record_id)
434{ 450{
435 struct apei_exec_context ctx; 451 struct apei_exec_context ctx;
@@ -444,26 +460,179 @@ static int __erst_get_next_record_id(u64 *record_id)
444 return 0; 460 return 0;
445} 461}
446 462
463int erst_get_record_id_begin(int *pos)
464{
465 int rc;
466
467 if (erst_disable)
468 return -ENODEV;
469
470 rc = mutex_lock_interruptible(&erst_record_id_cache.lock);
471 if (rc)
472 return rc;
473 erst_record_id_cache.refcount++;
474 mutex_unlock(&erst_record_id_cache.lock);
475
476 *pos = 0;
477
478 return 0;
479}
480EXPORT_SYMBOL_GPL(erst_get_record_id_begin);
481
482/* erst_record_id_cache.lock must be held by caller */
483static int __erst_record_id_cache_add_one(void)
484{
485 u64 id, prev_id, first_id;
486 int i, rc;
487 u64 *entries;
488 unsigned long flags;
489
490 id = prev_id = first_id = APEI_ERST_INVALID_RECORD_ID;
491retry:
492 raw_spin_lock_irqsave(&erst_lock, flags);
493 rc = __erst_get_next_record_id(&id);
494 raw_spin_unlock_irqrestore(&erst_lock, flags);
495 if (rc == -ENOENT)
496 return 0;
497 if (rc)
498 return rc;
499 if (id == APEI_ERST_INVALID_RECORD_ID)
500 return 0;
501 /* can not skip current ID, or loop back to first ID */
502 if (id == prev_id || id == first_id)
503 return 0;
504 if (first_id == APEI_ERST_INVALID_RECORD_ID)
505 first_id = id;
506 prev_id = id;
507
508 entries = erst_record_id_cache.entries;
509 for (i = 0; i < erst_record_id_cache.len; i++) {
510 if (entries[i] == id)
511 break;
512 }
513 /* record id already in cache, try next */
514 if (i < erst_record_id_cache.len)
515 goto retry;
516 if (erst_record_id_cache.len >= erst_record_id_cache.size) {
517 int new_size, alloc_size;
518 u64 *new_entries;
519
520 new_size = erst_record_id_cache.size * 2;
521 new_size = clamp_val(new_size, ERST_RECORD_ID_CACHE_SIZE_MIN,
522 ERST_RECORD_ID_CACHE_SIZE_MAX);
523 if (new_size <= erst_record_id_cache.size) {
524 if (printk_ratelimit())
525 pr_warning(FW_WARN ERST_PFX
526 "too many record ID!\n");
527 return 0;
528 }
529 alloc_size = new_size * sizeof(entries[0]);
530 if (alloc_size < PAGE_SIZE)
531 new_entries = kmalloc(alloc_size, GFP_KERNEL);
532 else
533 new_entries = vmalloc(alloc_size);
534 if (!new_entries)
535 return -ENOMEM;
536 memcpy(new_entries, entries,
537 erst_record_id_cache.len * sizeof(entries[0]));
538 if (erst_record_id_cache.size < PAGE_SIZE)
539 kfree(entries);
540 else
541 vfree(entries);
542 erst_record_id_cache.entries = entries = new_entries;
543 erst_record_id_cache.size = new_size;
544 }
545 entries[i] = id;
546 erst_record_id_cache.len++;
547
548 return 1;
549}
550
447/* 551/*
448 * Get the record ID of an existing error record on the persistent 552 * Get the record ID of an existing error record on the persistent
449 * storage. If there is no error record on the persistent storage, the 553 * storage. If there is no error record on the persistent storage, the
450 * returned record_id is APEI_ERST_INVALID_RECORD_ID. 554 * returned record_id is APEI_ERST_INVALID_RECORD_ID.
451 */ 555 */
452int erst_get_next_record_id(u64 *record_id) 556int erst_get_record_id_next(int *pos, u64 *record_id)
453{ 557{
454 int rc; 558 int rc = 0;
455 unsigned long flags; 559 u64 *entries;
456 560
457 if (erst_disable) 561 if (erst_disable)
458 return -ENODEV; 562 return -ENODEV;
459 563
460 raw_spin_lock_irqsave(&erst_lock, flags); 564 /* must be enclosed by erst_get_record_id_begin/end */
461 rc = __erst_get_next_record_id(record_id); 565 BUG_ON(!erst_record_id_cache.refcount);
462 raw_spin_unlock_irqrestore(&erst_lock, flags); 566 BUG_ON(*pos < 0 || *pos > erst_record_id_cache.len);
567
568 mutex_lock(&erst_record_id_cache.lock);
569 entries = erst_record_id_cache.entries;
570 for (; *pos < erst_record_id_cache.len; (*pos)++)
571 if (entries[*pos] != APEI_ERST_INVALID_RECORD_ID)
572 break;
573 /* found next record id in cache */
574 if (*pos < erst_record_id_cache.len) {
575 *record_id = entries[*pos];
576 (*pos)++;
577 goto out_unlock;
578 }
579
580 /* Try to add one more record ID to cache */
581 rc = __erst_record_id_cache_add_one();
582 if (rc < 0)
583 goto out_unlock;
584 /* successfully add one new ID */
585 if (rc == 1) {
586 *record_id = erst_record_id_cache.entries[*pos];
587 (*pos)++;
588 rc = 0;
589 } else {
590 *pos = -1;
591 *record_id = APEI_ERST_INVALID_RECORD_ID;
592 }
593out_unlock:
594 mutex_unlock(&erst_record_id_cache.lock);
463 595
464 return rc; 596 return rc;
465} 597}
466EXPORT_SYMBOL_GPL(erst_get_next_record_id); 598EXPORT_SYMBOL_GPL(erst_get_record_id_next);
599
600/* erst_record_id_cache.lock must be held by caller */
601static void __erst_record_id_cache_compact(void)
602{
603 int i, wpos = 0;
604 u64 *entries;
605
606 if (erst_record_id_cache.refcount)
607 return;
608
609 entries = erst_record_id_cache.entries;
610 for (i = 0; i < erst_record_id_cache.len; i++) {
611 if (entries[i] == APEI_ERST_INVALID_RECORD_ID)
612 continue;
613 if (wpos != i)
614 memcpy(&entries[wpos], &entries[i], sizeof(entries[i]));
615 wpos++;
616 }
617 erst_record_id_cache.len = wpos;
618}
619
620void erst_get_record_id_end(void)
621{
622 /*
623 * erst_disable != 0 should be detected by invoker via the
624 * return value of erst_get_record_id_begin/next, so this
625 * function should not be called for erst_disable != 0.
626 */
627 BUG_ON(erst_disable);
628
629 mutex_lock(&erst_record_id_cache.lock);
630 erst_record_id_cache.refcount--;
631 BUG_ON(erst_record_id_cache.refcount < 0);
632 __erst_record_id_cache_compact();
633 mutex_unlock(&erst_record_id_cache.lock);
634}
635EXPORT_SYMBOL_GPL(erst_get_record_id_end);
467 636
468static int __erst_write_to_storage(u64 offset) 637static int __erst_write_to_storage(u64 offset)
469{ 638{
@@ -704,56 +873,34 @@ ssize_t erst_read(u64 record_id, struct cper_record_header *record,
704} 873}
705EXPORT_SYMBOL_GPL(erst_read); 874EXPORT_SYMBOL_GPL(erst_read);
706 875
707/*
708 * If return value > buflen, the buffer size is not big enough,
709 * else if return value = 0, there is no more record to read,
710 * else if return value < 0, something goes wrong,
711 * else everything is OK, and return value is record length
712 */
713ssize_t erst_read_next(struct cper_record_header *record, size_t buflen)
714{
715 int rc;
716 ssize_t len;
717 unsigned long flags;
718 u64 record_id;
719
720 if (erst_disable)
721 return -ENODEV;
722
723 raw_spin_lock_irqsave(&erst_lock, flags);
724 rc = __erst_get_next_record_id(&record_id);
725 if (rc) {
726 raw_spin_unlock_irqrestore(&erst_lock, flags);
727 return rc;
728 }
729 /* no more record */
730 if (record_id == APEI_ERST_INVALID_RECORD_ID) {
731 raw_spin_unlock_irqrestore(&erst_lock, flags);
732 return 0;
733 }
734
735 len = __erst_read(record_id, record, buflen);
736 raw_spin_unlock_irqrestore(&erst_lock, flags);
737
738 return len;
739}
740EXPORT_SYMBOL_GPL(erst_read_next);
741
742int erst_clear(u64 record_id) 876int erst_clear(u64 record_id)
743{ 877{
744 int rc; 878 int rc, i;
745 unsigned long flags; 879 unsigned long flags;
880 u64 *entries;
746 881
747 if (erst_disable) 882 if (erst_disable)
748 return -ENODEV; 883 return -ENODEV;
749 884
885 rc = mutex_lock_interruptible(&erst_record_id_cache.lock);
886 if (rc)
887 return rc;
750 raw_spin_lock_irqsave(&erst_lock, flags); 888 raw_spin_lock_irqsave(&erst_lock, flags);
751 if (erst_erange.attr & ERST_RANGE_NVRAM) 889 if (erst_erange.attr & ERST_RANGE_NVRAM)
752 rc = __erst_clear_from_nvram(record_id); 890 rc = __erst_clear_from_nvram(record_id);
753 else 891 else
754 rc = __erst_clear_from_storage(record_id); 892 rc = __erst_clear_from_storage(record_id);
755 raw_spin_unlock_irqrestore(&erst_lock, flags); 893 raw_spin_unlock_irqrestore(&erst_lock, flags);
756 894 if (rc)
895 goto out;
896 entries = erst_record_id_cache.entries;
897 for (i = 0; i < erst_record_id_cache.len; i++) {
898 if (entries[i] == record_id)
899 entries[i] = APEI_ERST_INVALID_RECORD_ID;
900 }
901 __erst_record_id_cache_compact();
902out:
903 mutex_unlock(&erst_record_id_cache.lock);
757 return rc; 904 return rc;
758} 905}
759EXPORT_SYMBOL_GPL(erst_clear); 906EXPORT_SYMBOL_GPL(erst_clear);
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index ac1a599f5147..fcc13ac0aa18 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -33,6 +33,7 @@
33#include <linux/async.h> 33#include <linux/async.h>
34#include <linux/dmi.h> 34#include <linux/dmi.h>
35#include <linux/slab.h> 35#include <linux/slab.h>
36#include <linux/suspend.h>
36 37
37#ifdef CONFIG_ACPI_PROCFS_POWER 38#ifdef CONFIG_ACPI_PROCFS_POWER
38#include <linux/proc_fs.h> 39#include <linux/proc_fs.h>
@@ -102,6 +103,7 @@ struct acpi_battery {
102 struct mutex lock; 103 struct mutex lock;
103 struct power_supply bat; 104 struct power_supply bat;
104 struct acpi_device *device; 105 struct acpi_device *device;
106 struct notifier_block pm_nb;
105 unsigned long update_time; 107 unsigned long update_time;
106 int rate_now; 108 int rate_now;
107 int capacity_now; 109 int capacity_now;
@@ -940,6 +942,21 @@ static void acpi_battery_notify(struct acpi_device *device, u32 event)
940 power_supply_changed(&battery->bat); 942 power_supply_changed(&battery->bat);
941} 943}
942 944
945static int battery_notify(struct notifier_block *nb,
946 unsigned long mode, void *_unused)
947{
948 struct acpi_battery *battery = container_of(nb, struct acpi_battery,
949 pm_nb);
950 switch (mode) {
951 case PM_POST_SUSPEND:
952 sysfs_remove_battery(battery);
953 sysfs_add_battery(battery);
954 break;
955 }
956
957 return 0;
958}
959
943static int acpi_battery_add(struct acpi_device *device) 960static int acpi_battery_add(struct acpi_device *device)
944{ 961{
945 int result = 0; 962 int result = 0;
@@ -972,6 +989,10 @@ static int acpi_battery_add(struct acpi_device *device)
972#endif 989#endif
973 kfree(battery); 990 kfree(battery);
974 } 991 }
992
993 battery->pm_nb.notifier_call = battery_notify;
994 register_pm_notifier(&battery->pm_nb);
995
975 return result; 996 return result;
976} 997}
977 998
@@ -982,6 +1003,7 @@ static int acpi_battery_remove(struct acpi_device *device, int type)
982 if (!device || !acpi_driver_data(device)) 1003 if (!device || !acpi_driver_data(device))
983 return -EINVAL; 1004 return -EINVAL;
984 battery = acpi_driver_data(device); 1005 battery = acpi_driver_data(device);
1006 unregister_pm_notifier(&battery->pm_nb);
985#ifdef CONFIG_ACPI_PROCFS_POWER 1007#ifdef CONFIG_ACPI_PROCFS_POWER
986 acpi_battery_remove_fs(device); 1008 acpi_battery_remove_fs(device);
987#endif 1009#endif
diff --git a/drivers/acpi/button.c b/drivers/acpi/button.c
index 76bbb78a5ad9..d27d072472f9 100644
--- a/drivers/acpi/button.c
+++ b/drivers/acpi/button.c
@@ -78,8 +78,6 @@ static int acpi_button_add(struct acpi_device *device);
78static int acpi_button_remove(struct acpi_device *device, int type); 78static int acpi_button_remove(struct acpi_device *device, int type);
79static int acpi_button_resume(struct acpi_device *device); 79static int acpi_button_resume(struct acpi_device *device);
80static void acpi_button_notify(struct acpi_device *device, u32 event); 80static void acpi_button_notify(struct acpi_device *device, u32 event);
81static int acpi_button_info_open_fs(struct inode *inode, struct file *file);
82static int acpi_button_state_open_fs(struct inode *inode, struct file *file);
83 81
84static struct acpi_driver acpi_button_driver = { 82static struct acpi_driver acpi_button_driver = {
85 .name = "button", 83 .name = "button",
@@ -98,22 +96,7 @@ struct acpi_button {
98 struct input_dev *input; 96 struct input_dev *input;
99 char phys[32]; /* for input device */ 97 char phys[32]; /* for input device */
100 unsigned long pushed; 98 unsigned long pushed;
101}; 99 bool wakeup_enabled;
102
103static const struct file_operations acpi_button_info_fops = {
104 .owner = THIS_MODULE,
105 .open = acpi_button_info_open_fs,
106 .read = seq_read,
107 .llseek = seq_lseek,
108 .release = single_release,
109};
110
111static const struct file_operations acpi_button_state_fops = {
112 .owner = THIS_MODULE,
113 .open = acpi_button_state_open_fs,
114 .read = seq_read,
115 .llseek = seq_lseek,
116 .release = single_release,
117}; 100};
118 101
119static BLOCKING_NOTIFIER_HEAD(acpi_lid_notifier); 102static BLOCKING_NOTIFIER_HEAD(acpi_lid_notifier);
@@ -124,20 +107,7 @@ static struct acpi_device *lid_device;
124 -------------------------------------------------------------------------- */ 107 -------------------------------------------------------------------------- */
125 108
126static struct proc_dir_entry *acpi_button_dir; 109static struct proc_dir_entry *acpi_button_dir;
127 110static struct proc_dir_entry *acpi_lid_dir;
128static int acpi_button_info_seq_show(struct seq_file *seq, void *offset)
129{
130 struct acpi_device *device = seq->private;
131
132 seq_printf(seq, "type: %s\n",
133 acpi_device_name(device));
134 return 0;
135}
136
137static int acpi_button_info_open_fs(struct inode *inode, struct file *file)
138{
139 return single_open(file, acpi_button_info_seq_show, PDE(inode)->data);
140}
141 111
142static int acpi_button_state_seq_show(struct seq_file *seq, void *offset) 112static int acpi_button_state_seq_show(struct seq_file *seq, void *offset)
143{ 113{
@@ -157,77 +127,85 @@ static int acpi_button_state_open_fs(struct inode *inode, struct file *file)
157 return single_open(file, acpi_button_state_seq_show, PDE(inode)->data); 127 return single_open(file, acpi_button_state_seq_show, PDE(inode)->data);
158} 128}
159 129
160static struct proc_dir_entry *acpi_power_dir; 130static const struct file_operations acpi_button_state_fops = {
161static struct proc_dir_entry *acpi_sleep_dir; 131 .owner = THIS_MODULE,
162static struct proc_dir_entry *acpi_lid_dir; 132 .open = acpi_button_state_open_fs,
133 .read = seq_read,
134 .llseek = seq_lseek,
135 .release = single_release,
136};
163 137
164static int acpi_button_add_fs(struct acpi_device *device) 138static int acpi_button_add_fs(struct acpi_device *device)
165{ 139{
166 struct acpi_button *button = acpi_driver_data(device); 140 struct acpi_button *button = acpi_driver_data(device);
167 struct proc_dir_entry *entry = NULL; 141 struct proc_dir_entry *entry = NULL;
142 int ret = 0;
168 143
169 switch (button->type) { 144 /* procfs I/F for ACPI lid device only */
170 case ACPI_BUTTON_TYPE_POWER: 145 if (button->type != ACPI_BUTTON_TYPE_LID)
171 if (!acpi_power_dir) 146 return 0;
172 acpi_power_dir = proc_mkdir(ACPI_BUTTON_SUBCLASS_POWER, 147
173 acpi_button_dir); 148 if (acpi_button_dir || acpi_lid_dir) {
174 entry = acpi_power_dir; 149 printk(KERN_ERR PREFIX "More than one Lid device found!\n");
175 break; 150 return -EEXIST;
176 case ACPI_BUTTON_TYPE_SLEEP:
177 if (!acpi_sleep_dir)
178 acpi_sleep_dir = proc_mkdir(ACPI_BUTTON_SUBCLASS_SLEEP,
179 acpi_button_dir);
180 entry = acpi_sleep_dir;
181 break;
182 case ACPI_BUTTON_TYPE_LID:
183 if (!acpi_lid_dir)
184 acpi_lid_dir = proc_mkdir(ACPI_BUTTON_SUBCLASS_LID,
185 acpi_button_dir);
186 entry = acpi_lid_dir;
187 break;
188 } 151 }
189 152
190 if (!entry) 153 /* create /proc/acpi/button */
154 acpi_button_dir = proc_mkdir(ACPI_BUTTON_CLASS, acpi_root_dir);
155 if (!acpi_button_dir)
191 return -ENODEV; 156 return -ENODEV;
192 157
193 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), entry); 158 /* create /proc/acpi/button/lid */
194 if (!acpi_device_dir(device)) 159 acpi_lid_dir = proc_mkdir(ACPI_BUTTON_SUBCLASS_LID, acpi_button_dir);
195 return -ENODEV; 160 if (!acpi_lid_dir) {
161 ret = -ENODEV;
162 goto remove_button_dir;
163 }
196 164
197 /* 'info' [R] */ 165 /* create /proc/acpi/button/lid/LID/ */
198 entry = proc_create_data(ACPI_BUTTON_FILE_INFO, 166 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), acpi_lid_dir);
199 S_IRUGO, acpi_device_dir(device), 167 if (!acpi_device_dir(device)) {
200 &acpi_button_info_fops, device); 168 ret = -ENODEV;
201 if (!entry) 169 goto remove_lid_dir;
202 return -ENODEV; 170 }
203 171
204 /* show lid state [R] */ 172 /* create /proc/acpi/button/lid/LID/state */
205 if (button->type == ACPI_BUTTON_TYPE_LID) { 173 entry = proc_create_data(ACPI_BUTTON_FILE_STATE,
206 entry = proc_create_data(ACPI_BUTTON_FILE_STATE, 174 S_IRUGO, acpi_device_dir(device),
207 S_IRUGO, acpi_device_dir(device), 175 &acpi_button_state_fops, device);
208 &acpi_button_state_fops, device); 176 if (!entry) {
209 if (!entry) 177 ret = -ENODEV;
210 return -ENODEV; 178 goto remove_dev_dir;
211 } 179 }
212 180
213 return 0; 181done:
182 return ret;
183
184remove_dev_dir:
185 remove_proc_entry(acpi_device_bid(device),
186 acpi_lid_dir);
187 acpi_device_dir(device) = NULL;
188remove_lid_dir:
189 remove_proc_entry(ACPI_BUTTON_SUBCLASS_LID, acpi_button_dir);
190remove_button_dir:
191 remove_proc_entry(ACPI_BUTTON_CLASS, acpi_root_dir);
192 goto done;
214} 193}
215 194
216static int acpi_button_remove_fs(struct acpi_device *device) 195static int acpi_button_remove_fs(struct acpi_device *device)
217{ 196{
218 struct acpi_button *button = acpi_driver_data(device); 197 struct acpi_button *button = acpi_driver_data(device);
219 198
220 if (acpi_device_dir(device)) { 199 if (button->type != ACPI_BUTTON_TYPE_LID)
221 if (button->type == ACPI_BUTTON_TYPE_LID) 200 return 0;
222 remove_proc_entry(ACPI_BUTTON_FILE_STATE,
223 acpi_device_dir(device));
224 remove_proc_entry(ACPI_BUTTON_FILE_INFO,
225 acpi_device_dir(device));
226 201
227 remove_proc_entry(acpi_device_bid(device), 202 remove_proc_entry(ACPI_BUTTON_FILE_STATE,
228 acpi_device_dir(device)->parent); 203 acpi_device_dir(device));
229 acpi_device_dir(device) = NULL; 204 remove_proc_entry(acpi_device_bid(device),
230 } 205 acpi_lid_dir);
206 acpi_device_dir(device) = NULL;
207 remove_proc_entry(ACPI_BUTTON_SUBCLASS_LID, acpi_button_dir);
208 remove_proc_entry(ACPI_BUTTON_CLASS, acpi_root_dir);
231 209
232 return 0; 210 return 0;
233} 211}
@@ -430,8 +408,10 @@ static int acpi_button_add(struct acpi_device *device)
430 /* Button's GPE is run-wake GPE */ 408 /* Button's GPE is run-wake GPE */
431 acpi_enable_gpe(device->wakeup.gpe_device, 409 acpi_enable_gpe(device->wakeup.gpe_device,
432 device->wakeup.gpe_number); 410 device->wakeup.gpe_number);
433 device->wakeup.run_wake_count++; 411 if (!device_may_wakeup(&device->dev)) {
434 device_set_wakeup_enable(&device->dev, true); 412 device_set_wakeup_enable(&device->dev, true);
413 button->wakeup_enabled = true;
414 }
435 } 415 }
436 416
437 printk(KERN_INFO PREFIX "%s [%s]\n", name, acpi_device_bid(device)); 417 printk(KERN_INFO PREFIX "%s [%s]\n", name, acpi_device_bid(device));
@@ -453,8 +433,8 @@ static int acpi_button_remove(struct acpi_device *device, int type)
453 if (device->wakeup.flags.valid) { 433 if (device->wakeup.flags.valid) {
454 acpi_disable_gpe(device->wakeup.gpe_device, 434 acpi_disable_gpe(device->wakeup.gpe_device,
455 device->wakeup.gpe_number); 435 device->wakeup.gpe_number);
456 device->wakeup.run_wake_count--; 436 if (button->wakeup_enabled)
457 device_set_wakeup_enable(&device->dev, false); 437 device_set_wakeup_enable(&device->dev, false);
458 } 438 }
459 439
460 acpi_button_remove_fs(device); 440 acpi_button_remove_fs(device);
@@ -465,32 +445,12 @@ static int acpi_button_remove(struct acpi_device *device, int type)
465 445
466static int __init acpi_button_init(void) 446static int __init acpi_button_init(void)
467{ 447{
468 int result; 448 return acpi_bus_register_driver(&acpi_button_driver);
469
470 acpi_button_dir = proc_mkdir(ACPI_BUTTON_CLASS, acpi_root_dir);
471 if (!acpi_button_dir)
472 return -ENODEV;
473
474 result = acpi_bus_register_driver(&acpi_button_driver);
475 if (result < 0) {
476 remove_proc_entry(ACPI_BUTTON_CLASS, acpi_root_dir);
477 return -ENODEV;
478 }
479
480 return 0;
481} 449}
482 450
483static void __exit acpi_button_exit(void) 451static void __exit acpi_button_exit(void)
484{ 452{
485 acpi_bus_unregister_driver(&acpi_button_driver); 453 acpi_bus_unregister_driver(&acpi_button_driver);
486
487 if (acpi_power_dir)
488 remove_proc_entry(ACPI_BUTTON_SUBCLASS_POWER, acpi_button_dir);
489 if (acpi_sleep_dir)
490 remove_proc_entry(ACPI_BUTTON_SUBCLASS_SLEEP, acpi_button_dir);
491 if (acpi_lid_dir)
492 remove_proc_entry(ACPI_BUTTON_SUBCLASS_LID, acpi_button_dir);
493 remove_proc_entry(ACPI_BUTTON_CLASS, acpi_root_dir);
494} 454}
495 455
496module_init(acpi_button_init); 456module_init(acpi_button_init);
diff --git a/drivers/acpi/ec_sys.c b/drivers/acpi/ec_sys.c
index 411620ef84c2..05b44201a614 100644
--- a/drivers/acpi/ec_sys.c
+++ b/drivers/acpi/ec_sys.c
@@ -24,10 +24,6 @@ MODULE_PARM_DESC(write_support, "Dangerous, reboot and removal of battery may "
24 24
25#define EC_SPACE_SIZE 256 25#define EC_SPACE_SIZE 256
26 26
27struct sysdev_class acpi_ec_sysdev_class = {
28 .name = "ec",
29};
30
31static struct dentry *acpi_ec_debugfs_dir; 27static struct dentry *acpi_ec_debugfs_dir;
32 28
33static int acpi_ec_open_io(struct inode *i, struct file *f) 29static int acpi_ec_open_io(struct inode *i, struct file *f)
diff --git a/drivers/acpi/internal.h b/drivers/acpi/internal.h
index b1cc81a0431b..4bfb759deb10 100644
--- a/drivers/acpi/internal.h
+++ b/drivers/acpi/internal.h
@@ -21,8 +21,6 @@
21#ifndef _ACPI_INTERNAL_H_ 21#ifndef _ACPI_INTERNAL_H_
22#define _ACPI_INTERNAL_H_ 22#define _ACPI_INTERNAL_H_
23 23
24#include <linux/sysdev.h>
25
26#define PREFIX "ACPI: " 24#define PREFIX "ACPI: "
27 25
28int init_acpi_device_notify(void); 26int init_acpi_device_notify(void);
@@ -64,7 +62,6 @@ struct acpi_ec {
64 struct list_head list; 62 struct list_head list;
65 struct transaction *curr; 63 struct transaction *curr;
66 spinlock_t curr_lock; 64 spinlock_t curr_lock;
67 struct sys_device sysdev;
68}; 65};
69 66
70extern struct acpi_ec *first_ec; 67extern struct acpi_ec *first_ec;
diff --git a/drivers/acpi/nvs.c b/drivers/acpi/nvs.c
index fa5a1df42b79..096787b43c96 100644
--- a/drivers/acpi/nvs.c
+++ b/drivers/acpi/nvs.c
@@ -26,6 +26,7 @@ struct nvs_page {
26 unsigned int size; 26 unsigned int size;
27 void *kaddr; 27 void *kaddr;
28 void *data; 28 void *data;
29 bool unmap;
29 struct list_head node; 30 struct list_head node;
30}; 31};
31 32
@@ -44,6 +45,9 @@ int suspend_nvs_register(unsigned long start, unsigned long size)
44{ 45{
45 struct nvs_page *entry, *next; 46 struct nvs_page *entry, *next;
46 47
48 pr_info("PM: Registering ACPI NVS region at %lx (%ld bytes)\n",
49 start, size);
50
47 while (size > 0) { 51 while (size > 0) {
48 unsigned int nr_bytes; 52 unsigned int nr_bytes;
49 53
@@ -81,7 +85,13 @@ void suspend_nvs_free(void)
81 free_page((unsigned long)entry->data); 85 free_page((unsigned long)entry->data);
82 entry->data = NULL; 86 entry->data = NULL;
83 if (entry->kaddr) { 87 if (entry->kaddr) {
84 iounmap(entry->kaddr); 88 if (entry->unmap) {
89 iounmap(entry->kaddr);
90 entry->unmap = false;
91 } else {
92 acpi_os_unmap_memory(entry->kaddr,
93 entry->size);
94 }
85 entry->kaddr = NULL; 95 entry->kaddr = NULL;
86 } 96 }
87 } 97 }
@@ -115,8 +125,14 @@ int suspend_nvs_save(void)
115 125
116 list_for_each_entry(entry, &nvs_list, node) 126 list_for_each_entry(entry, &nvs_list, node)
117 if (entry->data) { 127 if (entry->data) {
118 entry->kaddr = acpi_os_ioremap(entry->phys_start, 128 unsigned long phys = entry->phys_start;
119 entry->size); 129 unsigned int size = entry->size;
130
131 entry->kaddr = acpi_os_get_iomem(phys, size);
132 if (!entry->kaddr) {
133 entry->kaddr = acpi_os_ioremap(phys, size);
134 entry->unmap = !!entry->kaddr;
135 }
120 if (!entry->kaddr) { 136 if (!entry->kaddr) {
121 suspend_nvs_free(); 137 suspend_nvs_free();
122 return -ENOMEM; 138 return -ENOMEM;
diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c
index 4a6753009d79..45ad4ffef533 100644
--- a/drivers/acpi/osl.c
+++ b/drivers/acpi/osl.c
@@ -76,7 +76,6 @@ EXPORT_SYMBOL(acpi_in_debugger);
76extern char line_buf[80]; 76extern char line_buf[80];
77#endif /*ENABLE_DEBUGGER */ 77#endif /*ENABLE_DEBUGGER */
78 78
79static unsigned int acpi_irq_irq;
80static acpi_osd_handler acpi_irq_handler; 79static acpi_osd_handler acpi_irq_handler;
81static void *acpi_irq_context; 80static void *acpi_irq_context;
82static struct workqueue_struct *kacpid_wq; 81static struct workqueue_struct *kacpid_wq;
@@ -105,11 +104,11 @@ struct acpi_ioremap {
105 void __iomem *virt; 104 void __iomem *virt;
106 acpi_physical_address phys; 105 acpi_physical_address phys;
107 acpi_size size; 106 acpi_size size;
108 struct kref ref; 107 unsigned long refcount;
109}; 108};
110 109
111static LIST_HEAD(acpi_ioremaps); 110static LIST_HEAD(acpi_ioremaps);
112static DEFINE_SPINLOCK(acpi_ioremap_lock); 111static DEFINE_MUTEX(acpi_ioremap_lock);
113 112
114static void __init acpi_osi_setup_late(void); 113static void __init acpi_osi_setup_late(void);
115 114
@@ -285,6 +284,22 @@ acpi_map_vaddr_lookup(acpi_physical_address phys, unsigned int size)
285 return NULL; 284 return NULL;
286} 285}
287 286
287void __iomem *acpi_os_get_iomem(acpi_physical_address phys, unsigned int size)
288{
289 struct acpi_ioremap *map;
290 void __iomem *virt = NULL;
291
292 mutex_lock(&acpi_ioremap_lock);
293 map = acpi_map_lookup(phys, size);
294 if (map) {
295 virt = map->virt + (phys - map->phys);
296 map->refcount++;
297 }
298 mutex_unlock(&acpi_ioremap_lock);
299 return virt;
300}
301EXPORT_SYMBOL_GPL(acpi_os_get_iomem);
302
288/* Must be called with 'acpi_ioremap_lock' or RCU read lock held. */ 303/* Must be called with 'acpi_ioremap_lock' or RCU read lock held. */
289static struct acpi_ioremap * 304static struct acpi_ioremap *
290acpi_map_lookup_virt(void __iomem *virt, acpi_size size) 305acpi_map_lookup_virt(void __iomem *virt, acpi_size size)
@@ -302,8 +317,7 @@ acpi_map_lookup_virt(void __iomem *virt, acpi_size size)
302void __iomem *__init_refok 317void __iomem *__init_refok
303acpi_os_map_memory(acpi_physical_address phys, acpi_size size) 318acpi_os_map_memory(acpi_physical_address phys, acpi_size size)
304{ 319{
305 struct acpi_ioremap *map, *tmp_map; 320 struct acpi_ioremap *map;
306 unsigned long flags;
307 void __iomem *virt; 321 void __iomem *virt;
308 acpi_physical_address pg_off; 322 acpi_physical_address pg_off;
309 acpi_size pg_sz; 323 acpi_size pg_sz;
@@ -316,14 +330,25 @@ acpi_os_map_memory(acpi_physical_address phys, acpi_size size)
316 if (!acpi_gbl_permanent_mmap) 330 if (!acpi_gbl_permanent_mmap)
317 return __acpi_map_table((unsigned long)phys, size); 331 return __acpi_map_table((unsigned long)phys, size);
318 332
333 mutex_lock(&acpi_ioremap_lock);
334 /* Check if there's a suitable mapping already. */
335 map = acpi_map_lookup(phys, size);
336 if (map) {
337 map->refcount++;
338 goto out;
339 }
340
319 map = kzalloc(sizeof(*map), GFP_KERNEL); 341 map = kzalloc(sizeof(*map), GFP_KERNEL);
320 if (!map) 342 if (!map) {
343 mutex_unlock(&acpi_ioremap_lock);
321 return NULL; 344 return NULL;
345 }
322 346
323 pg_off = round_down(phys, PAGE_SIZE); 347 pg_off = round_down(phys, PAGE_SIZE);
324 pg_sz = round_up(phys + size, PAGE_SIZE) - pg_off; 348 pg_sz = round_up(phys + size, PAGE_SIZE) - pg_off;
325 virt = acpi_os_ioremap(pg_off, pg_sz); 349 virt = acpi_os_ioremap(pg_off, pg_sz);
326 if (!virt) { 350 if (!virt) {
351 mutex_unlock(&acpi_ioremap_lock);
327 kfree(map); 352 kfree(map);
328 return NULL; 353 return NULL;
329 } 354 }
@@ -332,62 +357,51 @@ acpi_os_map_memory(acpi_physical_address phys, acpi_size size)
332 map->virt = virt; 357 map->virt = virt;
333 map->phys = pg_off; 358 map->phys = pg_off;
334 map->size = pg_sz; 359 map->size = pg_sz;
335 kref_init(&map->ref); 360 map->refcount = 1;
336 361
337 spin_lock_irqsave(&acpi_ioremap_lock, flags);
338 /* Check if page has already been mapped. */
339 tmp_map = acpi_map_lookup(phys, size);
340 if (tmp_map) {
341 kref_get(&tmp_map->ref);
342 spin_unlock_irqrestore(&acpi_ioremap_lock, flags);
343 iounmap(map->virt);
344 kfree(map);
345 return tmp_map->virt + (phys - tmp_map->phys);
346 }
347 list_add_tail_rcu(&map->list, &acpi_ioremaps); 362 list_add_tail_rcu(&map->list, &acpi_ioremaps);
348 spin_unlock_irqrestore(&acpi_ioremap_lock, flags);
349 363
364 out:
365 mutex_unlock(&acpi_ioremap_lock);
350 return map->virt + (phys - map->phys); 366 return map->virt + (phys - map->phys);
351} 367}
352EXPORT_SYMBOL_GPL(acpi_os_map_memory); 368EXPORT_SYMBOL_GPL(acpi_os_map_memory);
353 369
354static void acpi_kref_del_iomap(struct kref *ref) 370static void acpi_os_drop_map_ref(struct acpi_ioremap *map)
355{ 371{
356 struct acpi_ioremap *map; 372 if (!--map->refcount)
373 list_del_rcu(&map->list);
374}
357 375
358 map = container_of(ref, struct acpi_ioremap, ref); 376static void acpi_os_map_cleanup(struct acpi_ioremap *map)
359 list_del_rcu(&map->list); 377{
378 if (!map->refcount) {
379 synchronize_rcu();
380 iounmap(map->virt);
381 kfree(map);
382 }
360} 383}
361 384
362void __ref acpi_os_unmap_memory(void __iomem *virt, acpi_size size) 385void __ref acpi_os_unmap_memory(void __iomem *virt, acpi_size size)
363{ 386{
364 struct acpi_ioremap *map; 387 struct acpi_ioremap *map;
365 unsigned long flags;
366 int del;
367 388
368 if (!acpi_gbl_permanent_mmap) { 389 if (!acpi_gbl_permanent_mmap) {
369 __acpi_unmap_table(virt, size); 390 __acpi_unmap_table(virt, size);
370 return; 391 return;
371 } 392 }
372 393
373 spin_lock_irqsave(&acpi_ioremap_lock, flags); 394 mutex_lock(&acpi_ioremap_lock);
374 map = acpi_map_lookup_virt(virt, size); 395 map = acpi_map_lookup_virt(virt, size);
375 if (!map) { 396 if (!map) {
376 spin_unlock_irqrestore(&acpi_ioremap_lock, flags); 397 mutex_unlock(&acpi_ioremap_lock);
377 printk(KERN_ERR PREFIX "%s: bad address %p\n", __func__, virt); 398 WARN(true, PREFIX "%s: bad address %p\n", __func__, virt);
378 dump_stack();
379 return; 399 return;
380 } 400 }
401 acpi_os_drop_map_ref(map);
402 mutex_unlock(&acpi_ioremap_lock);
381 403
382 del = kref_put(&map->ref, acpi_kref_del_iomap); 404 acpi_os_map_cleanup(map);
383 spin_unlock_irqrestore(&acpi_ioremap_lock, flags);
384
385 if (!del)
386 return;
387
388 synchronize_rcu();
389 iounmap(map->virt);
390 kfree(map);
391} 405}
392EXPORT_SYMBOL_GPL(acpi_os_unmap_memory); 406EXPORT_SYMBOL_GPL(acpi_os_unmap_memory);
393 407
@@ -397,7 +411,7 @@ void __init early_acpi_os_unmap_memory(void __iomem *virt, acpi_size size)
397 __acpi_unmap_table(virt, size); 411 __acpi_unmap_table(virt, size);
398} 412}
399 413
400int acpi_os_map_generic_address(struct acpi_generic_address *addr) 414static int acpi_os_map_generic_address(struct acpi_generic_address *addr)
401{ 415{
402 void __iomem *virt; 416 void __iomem *virt;
403 417
@@ -413,13 +427,10 @@ int acpi_os_map_generic_address(struct acpi_generic_address *addr)
413 427
414 return 0; 428 return 0;
415} 429}
416EXPORT_SYMBOL_GPL(acpi_os_map_generic_address);
417 430
418void acpi_os_unmap_generic_address(struct acpi_generic_address *addr) 431static void acpi_os_unmap_generic_address(struct acpi_generic_address *addr)
419{ 432{
420 void __iomem *virt; 433 struct acpi_ioremap *map;
421 unsigned long flags;
422 acpi_size size = addr->bit_width / 8;
423 434
424 if (addr->space_id != ACPI_ADR_SPACE_SYSTEM_MEMORY) 435 if (addr->space_id != ACPI_ADR_SPACE_SYSTEM_MEMORY)
425 return; 436 return;
@@ -427,13 +438,17 @@ void acpi_os_unmap_generic_address(struct acpi_generic_address *addr)
427 if (!addr->address || !addr->bit_width) 438 if (!addr->address || !addr->bit_width)
428 return; 439 return;
429 440
430 spin_lock_irqsave(&acpi_ioremap_lock, flags); 441 mutex_lock(&acpi_ioremap_lock);
431 virt = acpi_map_vaddr_lookup(addr->address, size); 442 map = acpi_map_lookup(addr->address, addr->bit_width / 8);
432 spin_unlock_irqrestore(&acpi_ioremap_lock, flags); 443 if (!map) {
444 mutex_unlock(&acpi_ioremap_lock);
445 return;
446 }
447 acpi_os_drop_map_ref(map);
448 mutex_unlock(&acpi_ioremap_lock);
433 449
434 acpi_os_unmap_memory(virt, size); 450 acpi_os_map_cleanup(map);
435} 451}
436EXPORT_SYMBOL_GPL(acpi_os_unmap_generic_address);
437 452
438#ifdef ACPI_FUTURE_USAGE 453#ifdef ACPI_FUTURE_USAGE
439acpi_status 454acpi_status
@@ -516,11 +531,15 @@ acpi_os_install_interrupt_handler(u32 gsi, acpi_osd_handler handler,
516 acpi_irq_stats_init(); 531 acpi_irq_stats_init();
517 532
518 /* 533 /*
519 * Ignore the GSI from the core, and use the value in our copy of the 534 * ACPI interrupts different from the SCI in our copy of the FADT are
520 * FADT. It may not be the same if an interrupt source override exists 535 * not supported.
521 * for the SCI.
522 */ 536 */
523 gsi = acpi_gbl_FADT.sci_interrupt; 537 if (gsi != acpi_gbl_FADT.sci_interrupt)
538 return AE_BAD_PARAMETER;
539
540 if (acpi_irq_handler)
541 return AE_ALREADY_ACQUIRED;
542
524 if (acpi_gsi_to_irq(gsi, &irq) < 0) { 543 if (acpi_gsi_to_irq(gsi, &irq) < 0) {
525 printk(KERN_ERR PREFIX "SCI (ACPI GSI %d) not registered\n", 544 printk(KERN_ERR PREFIX "SCI (ACPI GSI %d) not registered\n",
526 gsi); 545 gsi);
@@ -531,20 +550,20 @@ acpi_os_install_interrupt_handler(u32 gsi, acpi_osd_handler handler,
531 acpi_irq_context = context; 550 acpi_irq_context = context;
532 if (request_irq(irq, acpi_irq, IRQF_SHARED, "acpi", acpi_irq)) { 551 if (request_irq(irq, acpi_irq, IRQF_SHARED, "acpi", acpi_irq)) {
533 printk(KERN_ERR PREFIX "SCI (IRQ%d) allocation failed\n", irq); 552 printk(KERN_ERR PREFIX "SCI (IRQ%d) allocation failed\n", irq);
553 acpi_irq_handler = NULL;
534 return AE_NOT_ACQUIRED; 554 return AE_NOT_ACQUIRED;
535 } 555 }
536 acpi_irq_irq = irq;
537 556
538 return AE_OK; 557 return AE_OK;
539} 558}
540 559
541acpi_status acpi_os_remove_interrupt_handler(u32 irq, acpi_osd_handler handler) 560acpi_status acpi_os_remove_interrupt_handler(u32 irq, acpi_osd_handler handler)
542{ 561{
543 if (irq) { 562 if (irq != acpi_gbl_FADT.sci_interrupt)
544 free_irq(irq, acpi_irq); 563 return AE_BAD_PARAMETER;
545 acpi_irq_handler = NULL; 564
546 acpi_irq_irq = 0; 565 free_irq(irq, acpi_irq);
547 } 566 acpi_irq_handler = NULL;
548 567
549 return AE_OK; 568 return AE_OK;
550} 569}
@@ -1603,7 +1622,7 @@ acpi_status __init acpi_os_initialize1(void)
1603acpi_status acpi_os_terminate(void) 1622acpi_status acpi_os_terminate(void)
1604{ 1623{
1605 if (acpi_irq_handler) { 1624 if (acpi_irq_handler) {
1606 acpi_os_remove_interrupt_handler(acpi_irq_irq, 1625 acpi_os_remove_interrupt_handler(acpi_gbl_FADT.sci_interrupt,
1607 acpi_irq_handler); 1626 acpi_irq_handler);
1608 } 1627 }
1609 1628
diff --git a/drivers/acpi/pci_link.c b/drivers/acpi/pci_link.c
index 9ff80a7e9f6a..4a29763b8eb4 100644
--- a/drivers/acpi/pci_link.c
+++ b/drivers/acpi/pci_link.c
@@ -29,7 +29,7 @@
29 * for IRQ management (e.g. start()->_SRS). 29 * for IRQ management (e.g. start()->_SRS).
30 */ 30 */
31 31
32#include <linux/sysdev.h> 32#include <linux/syscore_ops.h>
33#include <linux/kernel.h> 33#include <linux/kernel.h>
34#include <linux/module.h> 34#include <linux/module.h>
35#include <linux/init.h> 35#include <linux/init.h>
@@ -757,14 +757,13 @@ static int acpi_pci_link_resume(struct acpi_pci_link *link)
757 return 0; 757 return 0;
758} 758}
759 759
760static int irqrouter_resume(struct sys_device *dev) 760static void irqrouter_resume(void)
761{ 761{
762 struct acpi_pci_link *link; 762 struct acpi_pci_link *link;
763 763
764 list_for_each_entry(link, &acpi_link_list, list) { 764 list_for_each_entry(link, &acpi_link_list, list) {
765 acpi_pci_link_resume(link); 765 acpi_pci_link_resume(link);
766 } 766 }
767 return 0;
768} 767}
769 768
770static int acpi_pci_link_remove(struct acpi_device *device, int type) 769static int acpi_pci_link_remove(struct acpi_device *device, int type)
@@ -871,32 +870,19 @@ static int __init acpi_irq_balance_set(char *str)
871 870
872__setup("acpi_irq_balance", acpi_irq_balance_set); 871__setup("acpi_irq_balance", acpi_irq_balance_set);
873 872
874/* FIXME: we will remove this interface after all drivers call pci_disable_device */ 873static struct syscore_ops irqrouter_syscore_ops = {
875static struct sysdev_class irqrouter_sysdev_class = {
876 .name = "irqrouter",
877 .resume = irqrouter_resume, 874 .resume = irqrouter_resume,
878}; 875};
879 876
880static struct sys_device device_irqrouter = { 877static int __init irqrouter_init_ops(void)
881 .id = 0,
882 .cls = &irqrouter_sysdev_class,
883};
884
885static int __init irqrouter_init_sysfs(void)
886{ 878{
887 int error; 879 if (!acpi_disabled && !acpi_noirq)
880 register_syscore_ops(&irqrouter_syscore_ops);
888 881
889 if (acpi_disabled || acpi_noirq) 882 return 0;
890 return 0;
891
892 error = sysdev_class_register(&irqrouter_sysdev_class);
893 if (!error)
894 error = sysdev_register(&device_irqrouter);
895
896 return error;
897} 883}
898 884
899device_initcall(irqrouter_init_sysfs); 885device_initcall(irqrouter_init_ops);
900 886
901static int __init acpi_pci_link_init(void) 887static int __init acpi_pci_link_init(void)
902{ 888{
diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c
index 3c1a2fec8cda..25bf17da69fd 100644
--- a/drivers/acpi/processor_core.c
+++ b/drivers/acpi/processor_core.c
@@ -19,7 +19,7 @@
19#define _COMPONENT ACPI_PROCESSOR_COMPONENT 19#define _COMPONENT ACPI_PROCESSOR_COMPONENT
20ACPI_MODULE_NAME("processor_core"); 20ACPI_MODULE_NAME("processor_core");
21 21
22static int set_no_mwait(const struct dmi_system_id *id) 22static int __init set_no_mwait(const struct dmi_system_id *id)
23{ 23{
24 printk(KERN_NOTICE PREFIX "%s detected - " 24 printk(KERN_NOTICE PREFIX "%s detected - "
25 "disabling mwait for CPU C-states\n", id->ident); 25 "disabling mwait for CPU C-states\n", id->ident);
@@ -27,7 +27,7 @@ static int set_no_mwait(const struct dmi_system_id *id)
27 return 0; 27 return 0;
28} 28}
29 29
30static struct dmi_system_id __cpuinitdata processor_idle_dmi_table[] = { 30static struct dmi_system_id __initdata processor_idle_dmi_table[] = {
31 { 31 {
32 set_no_mwait, "Extensa 5220", { 32 set_no_mwait, "Extensa 5220", {
33 DMI_MATCH(DMI_BIOS_VENDOR, "Phoenix Technologies LTD"), 33 DMI_MATCH(DMI_BIOS_VENDOR, "Phoenix Technologies LTD"),
@@ -183,7 +183,7 @@ int acpi_get_cpuid(acpi_handle handle, int type, u32 acpi_id)
183EXPORT_SYMBOL_GPL(acpi_get_cpuid); 183EXPORT_SYMBOL_GPL(acpi_get_cpuid);
184#endif 184#endif
185 185
186static bool processor_physically_present(acpi_handle handle) 186static bool __init processor_physically_present(acpi_handle handle)
187{ 187{
188 int cpuid, type; 188 int cpuid, type;
189 u32 acpi_id; 189 u32 acpi_id;
@@ -223,7 +223,7 @@ static bool processor_physically_present(acpi_handle handle)
223 return true; 223 return true;
224} 224}
225 225
226static void acpi_set_pdc_bits(u32 *buf) 226static void __cpuinit acpi_set_pdc_bits(u32 *buf)
227{ 227{
228 buf[0] = ACPI_PDC_REVISION_ID; 228 buf[0] = ACPI_PDC_REVISION_ID;
229 buf[1] = 1; 229 buf[1] = 1;
@@ -235,7 +235,7 @@ static void acpi_set_pdc_bits(u32 *buf)
235 arch_acpi_set_pdc_bits(buf); 235 arch_acpi_set_pdc_bits(buf);
236} 236}
237 237
238static struct acpi_object_list *acpi_processor_alloc_pdc(void) 238static struct acpi_object_list *__cpuinit acpi_processor_alloc_pdc(void)
239{ 239{
240 struct acpi_object_list *obj_list; 240 struct acpi_object_list *obj_list;
241 union acpi_object *obj; 241 union acpi_object *obj;
@@ -278,7 +278,7 @@ static struct acpi_object_list *acpi_processor_alloc_pdc(void)
278 * _PDC is required for a BIOS-OS handshake for most of the newer 278 * _PDC is required for a BIOS-OS handshake for most of the newer
279 * ACPI processor features. 279 * ACPI processor features.
280 */ 280 */
281static int 281static int __cpuinit
282acpi_processor_eval_pdc(acpi_handle handle, struct acpi_object_list *pdc_in) 282acpi_processor_eval_pdc(acpi_handle handle, struct acpi_object_list *pdc_in)
283{ 283{
284 acpi_status status = AE_OK; 284 acpi_status status = AE_OK;
@@ -306,7 +306,7 @@ acpi_processor_eval_pdc(acpi_handle handle, struct acpi_object_list *pdc_in)
306 return status; 306 return status;
307} 307}
308 308
309void acpi_processor_set_pdc(acpi_handle handle) 309void __cpuinit acpi_processor_set_pdc(acpi_handle handle)
310{ 310{
311 struct acpi_object_list *obj_list; 311 struct acpi_object_list *obj_list;
312 312
@@ -323,9 +323,8 @@ void acpi_processor_set_pdc(acpi_handle handle)
323 kfree(obj_list->pointer); 323 kfree(obj_list->pointer);
324 kfree(obj_list); 324 kfree(obj_list);
325} 325}
326EXPORT_SYMBOL_GPL(acpi_processor_set_pdc);
327 326
328static acpi_status 327static acpi_status __init
329early_init_pdc(acpi_handle handle, u32 lvl, void *context, void **rv) 328early_init_pdc(acpi_handle handle, u32 lvl, void *context, void **rv)
330{ 329{
331 if (processor_physically_present(handle) == false) 330 if (processor_physically_present(handle) == false)
diff --git a/drivers/acpi/processor_driver.c b/drivers/acpi/processor_driver.c
index 360a74e6add0..a4e0f1ba6040 100644
--- a/drivers/acpi/processor_driver.c
+++ b/drivers/acpi/processor_driver.c
@@ -635,8 +635,8 @@ int acpi_processor_device_add(acpi_handle handle, struct acpi_device **device)
635 return 0; 635 return 0;
636} 636}
637 637
638static void __ref acpi_processor_hotplug_notify(acpi_handle handle, 638static void acpi_processor_hotplug_notify(acpi_handle handle,
639 u32 event, void *data) 639 u32 event, void *data)
640{ 640{
641 struct acpi_processor *pr; 641 struct acpi_processor *pr;
642 struct acpi_device *device = NULL; 642 struct acpi_device *device = NULL;
diff --git a/drivers/acpi/reboot.c b/drivers/acpi/reboot.c
index 93f91142d7ad..a6c77e8b37bd 100644
--- a/drivers/acpi/reboot.c
+++ b/drivers/acpi/reboot.c
@@ -15,9 +15,15 @@ void acpi_reboot(void)
15 15
16 rr = &acpi_gbl_FADT.reset_register; 16 rr = &acpi_gbl_FADT.reset_register;
17 17
18 /* Is the reset register supported? */ 18 /* ACPI reset register was only introduced with v2 of the FADT */
19 if (!(acpi_gbl_FADT.flags & ACPI_FADT_RESET_REGISTER) || 19
20 rr->bit_width != 8 || rr->bit_offset != 0) 20 if (acpi_gbl_FADT.header.revision < 2)
21 return;
22
23 /* Is the reset register supported? The spec says we should be
24 * checking the bit width and bit offset, but Windows ignores
25 * these fields */
26 if (!(acpi_gbl_FADT.flags & ACPI_FADT_RESET_REGISTER))
21 return; 27 return;
22 28
23 reset_value = acpi_gbl_FADT.reset_value; 29 reset_value = acpi_gbl_FADT.reset_value;
@@ -45,6 +51,4 @@ void acpi_reboot(void)
45 acpi_reset(); 51 acpi_reset();
46 break; 52 break;
47 } 53 }
48 /* Wait ten seconds */
49 acpi_os_stall(10000000);
50} 54}
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index b99e62494607..b136c9c1e531 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -797,7 +797,6 @@ static void acpi_bus_set_run_wake_flags(struct acpi_device *device)
797 acpi_status status; 797 acpi_status status;
798 acpi_event_status event_status; 798 acpi_event_status event_status;
799 799
800 device->wakeup.run_wake_count = 0;
801 device->wakeup.flags.notifier_present = 0; 800 device->wakeup.flags.notifier_present = 0;
802 801
803 /* Power button, Lid switch always enable wakeup */ 802 /* Power button, Lid switch always enable wakeup */
diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c
index 1850dac8f45c..6c949602cbd1 100644
--- a/drivers/acpi/sleep.c
+++ b/drivers/acpi/sleep.c
@@ -200,8 +200,6 @@ static void acpi_pm_end(void)
200#endif /* CONFIG_ACPI_SLEEP */ 200#endif /* CONFIG_ACPI_SLEEP */
201 201
202#ifdef CONFIG_SUSPEND 202#ifdef CONFIG_SUSPEND
203extern void do_suspend_lowlevel(void);
204
205static u32 acpi_suspend_states[] = { 203static u32 acpi_suspend_states[] = {
206 [PM_SUSPEND_ON] = ACPI_STATE_S0, 204 [PM_SUSPEND_ON] = ACPI_STATE_S0,
207 [PM_SUSPEND_STANDBY] = ACPI_STATE_S1, 205 [PM_SUSPEND_STANDBY] = ACPI_STATE_S1,
@@ -244,20 +242,11 @@ static int acpi_suspend_begin(suspend_state_t pm_state)
244static int acpi_suspend_enter(suspend_state_t pm_state) 242static int acpi_suspend_enter(suspend_state_t pm_state)
245{ 243{
246 acpi_status status = AE_OK; 244 acpi_status status = AE_OK;
247 unsigned long flags = 0;
248 u32 acpi_state = acpi_target_sleep_state; 245 u32 acpi_state = acpi_target_sleep_state;
246 int error;
249 247
250 ACPI_FLUSH_CPU_CACHE(); 248 ACPI_FLUSH_CPU_CACHE();
251 249
252 /* Do arch specific saving of state. */
253 if (acpi_state == ACPI_STATE_S3) {
254 int error = acpi_save_state_mem();
255
256 if (error)
257 return error;
258 }
259
260 local_irq_save(flags);
261 switch (acpi_state) { 250 switch (acpi_state) {
262 case ACPI_STATE_S1: 251 case ACPI_STATE_S1:
263 barrier(); 252 barrier();
@@ -265,7 +254,10 @@ static int acpi_suspend_enter(suspend_state_t pm_state)
265 break; 254 break;
266 255
267 case ACPI_STATE_S3: 256 case ACPI_STATE_S3:
268 do_suspend_lowlevel(); 257 error = acpi_suspend_lowlevel();
258 if (error)
259 return error;
260 pr_info(PREFIX "Low-level resume complete\n");
269 break; 261 break;
270 } 262 }
271 263
@@ -291,13 +283,6 @@ static int acpi_suspend_enter(suspend_state_t pm_state)
291 /* Allow EC transactions to happen. */ 283 /* Allow EC transactions to happen. */
292 acpi_ec_unblock_transactions_early(); 284 acpi_ec_unblock_transactions_early();
293 285
294 local_irq_restore(flags);
295 printk(KERN_DEBUG "Back to C!\n");
296
297 /* restore processor state */
298 if (acpi_state == ACPI_STATE_S3)
299 acpi_restore_state_mem();
300
301 suspend_nvs_restore(); 286 suspend_nvs_restore();
302 287
303 return ACPI_SUCCESS(status) ? 0 : -EFAULT; 288 return ACPI_SUCCESS(status) ? 0 : -EFAULT;
@@ -473,16 +458,13 @@ static int acpi_hibernation_begin(void)
473static int acpi_hibernation_enter(void) 458static int acpi_hibernation_enter(void)
474{ 459{
475 acpi_status status = AE_OK; 460 acpi_status status = AE_OK;
476 unsigned long flags = 0;
477 461
478 ACPI_FLUSH_CPU_CACHE(); 462 ACPI_FLUSH_CPU_CACHE();
479 463
480 local_irq_save(flags);
481 /* This shouldn't return. If it returns, we have a problem */ 464 /* This shouldn't return. If it returns, we have a problem */
482 status = acpi_enter_sleep_state(ACPI_STATE_S4); 465 status = acpi_enter_sleep_state(ACPI_STATE_S4);
483 /* Reprogram control registers and execute _BFS */ 466 /* Reprogram control registers and execute _BFS */
484 acpi_leave_sleep_state_prep(ACPI_STATE_S4); 467 acpi_leave_sleep_state_prep(ACPI_STATE_S4);
485 local_irq_restore(flags);
486 468
487 return ACPI_SUCCESS(status) ? 0 : -EFAULT; 469 return ACPI_SUCCESS(status) ? 0 : -EFAULT;
488} 470}
diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c
index 6fe0772e0e7d..7c3b18e78cee 100644
--- a/drivers/pci/pci-acpi.c
+++ b/drivers/pci/pci-acpi.c
@@ -293,19 +293,11 @@ static int acpi_dev_run_wake(struct device *phys_dev, bool enable)
293 } 293 }
294 294
295 if (enable) { 295 if (enable) {
296 if (!dev->wakeup.run_wake_count++) { 296 acpi_enable_wakeup_device_power(dev, ACPI_STATE_S0);
297 acpi_enable_wakeup_device_power(dev, ACPI_STATE_S0); 297 acpi_enable_gpe(dev->wakeup.gpe_device, dev->wakeup.gpe_number);
298 acpi_enable_gpe(dev->wakeup.gpe_device,
299 dev->wakeup.gpe_number);
300 }
301 } else if (dev->wakeup.run_wake_count > 0) {
302 if (!--dev->wakeup.run_wake_count) {
303 acpi_disable_gpe(dev->wakeup.gpe_device,
304 dev->wakeup.gpe_number);
305 acpi_disable_wakeup_device_power(dev);
306 }
307 } else { 298 } else {
308 error = -EALREADY; 299 acpi_disable_gpe(dev->wakeup.gpe_device, dev->wakeup.gpe_number);
300 acpi_disable_wakeup_device_power(dev);
309 } 301 }
310 302
311 return error; 303 return error;
diff --git a/drivers/pci/pcie/aer/aerdrv.h b/drivers/pci/pcie/aer/aerdrv.h
index 80c11d131499..3eb77080366a 100644
--- a/drivers/pci/pcie/aer/aerdrv.h
+++ b/drivers/pci/pcie/aer/aerdrv.h
@@ -35,13 +35,6 @@
35 PCI_ERR_UNC_UNX_COMP| \ 35 PCI_ERR_UNC_UNX_COMP| \
36 PCI_ERR_UNC_MALF_TLP) 36 PCI_ERR_UNC_MALF_TLP)
37 37
38struct header_log_regs {
39 unsigned int dw0;
40 unsigned int dw1;
41 unsigned int dw2;
42 unsigned int dw3;
43};
44
45#define AER_MAX_MULTI_ERR_DEVICES 5 /* Not likely to have more */ 38#define AER_MAX_MULTI_ERR_DEVICES 5 /* Not likely to have more */
46struct aer_err_info { 39struct aer_err_info {
47 struct pci_dev *dev[AER_MAX_MULTI_ERR_DEVICES]; 40 struct pci_dev *dev[AER_MAX_MULTI_ERR_DEVICES];
@@ -59,7 +52,7 @@ struct aer_err_info {
59 52
60 unsigned int status; /* COR/UNCOR Error Status */ 53 unsigned int status; /* COR/UNCOR Error Status */
61 unsigned int mask; /* COR/UNCOR Error Mask */ 54 unsigned int mask; /* COR/UNCOR Error Mask */
62 struct header_log_regs tlp; /* TLP Header */ 55 struct aer_header_log_regs tlp; /* TLP Header */
63}; 56};
64 57
65struct aer_err_source { 58struct aer_err_source {
diff --git a/drivers/pci/pcie/aer/aerdrv_errprint.c b/drivers/pci/pcie/aer/aerdrv_errprint.c
index 9d3e4c8d0184..b07a42e0b350 100644
--- a/drivers/pci/pcie/aer/aerdrv_errprint.c
+++ b/drivers/pci/pcie/aer/aerdrv_errprint.c
@@ -19,6 +19,7 @@
19#include <linux/errno.h> 19#include <linux/errno.h>
20#include <linux/pm.h> 20#include <linux/pm.h>
21#include <linux/suspend.h> 21#include <linux/suspend.h>
22#include <linux/cper.h>
22 23
23#include "aerdrv.h" 24#include "aerdrv.h"
24 25
@@ -57,86 +58,44 @@
57 (e & AER_DATA_LINK_LAYER_ERROR_MASK(t)) ? AER_DATA_LINK_LAYER_ERROR : \ 58 (e & AER_DATA_LINK_LAYER_ERROR_MASK(t)) ? AER_DATA_LINK_LAYER_ERROR : \
58 AER_TRANSACTION_LAYER_ERROR) 59 AER_TRANSACTION_LAYER_ERROR)
59 60
60#define AER_PR(info, pdev, fmt, args...) \
61 printk("%s%s %s: " fmt, (info->severity == AER_CORRECTABLE) ? \
62 KERN_WARNING : KERN_ERR, dev_driver_string(&pdev->dev), \
63 dev_name(&pdev->dev), ## args)
64
65/* 61/*
66 * AER error strings 62 * AER error strings
67 */ 63 */
68static char *aer_error_severity_string[] = { 64static const char *aer_error_severity_string[] = {
69 "Uncorrected (Non-Fatal)", 65 "Uncorrected (Non-Fatal)",
70 "Uncorrected (Fatal)", 66 "Uncorrected (Fatal)",
71 "Corrected" 67 "Corrected"
72}; 68};
73 69
74static char *aer_error_layer[] = { 70static const char *aer_error_layer[] = {
75 "Physical Layer", 71 "Physical Layer",
76 "Data Link Layer", 72 "Data Link Layer",
77 "Transaction Layer" 73 "Transaction Layer"
78}; 74};
79static char *aer_correctable_error_string[] = { 75
80 "Receiver Error ", /* Bit Position 0 */ 76static const char *aer_correctable_error_string[] = {
81 NULL, 77 "Receiver Error", /* Bit Position 0 */
82 NULL,
83 NULL,
84 NULL,
85 NULL,
86 "Bad TLP ", /* Bit Position 6 */
87 "Bad DLLP ", /* Bit Position 7 */
88 "RELAY_NUM Rollover ", /* Bit Position 8 */
89 NULL,
90 NULL,
91 NULL,
92 "Replay Timer Timeout ", /* Bit Position 12 */
93 "Advisory Non-Fatal ", /* Bit Position 13 */
94 NULL,
95 NULL,
96 NULL,
97 NULL,
98 NULL,
99 NULL,
100 NULL,
101 NULL,
102 NULL,
103 NULL,
104 NULL, 78 NULL,
105 NULL, 79 NULL,
106 NULL, 80 NULL,
107 NULL, 81 NULL,
108 NULL, 82 NULL,
83 "Bad TLP", /* Bit Position 6 */
84 "Bad DLLP", /* Bit Position 7 */
85 "RELAY_NUM Rollover", /* Bit Position 8 */
109 NULL, 86 NULL,
110 NULL, 87 NULL,
111 NULL, 88 NULL,
89 "Replay Timer Timeout", /* Bit Position 12 */
90 "Advisory Non-Fatal", /* Bit Position 13 */
112}; 91};
113 92
114static char *aer_uncorrectable_error_string[] = { 93static const char *aer_uncorrectable_error_string[] = {
115 NULL,
116 NULL,
117 NULL,
118 NULL,
119 "Data Link Protocol ", /* Bit Position 4 */
120 NULL,
121 NULL,
122 NULL,
123 NULL,
124 NULL,
125 NULL,
126 NULL,
127 "Poisoned TLP ", /* Bit Position 12 */
128 "Flow Control Protocol ", /* Bit Position 13 */
129 "Completion Timeout ", /* Bit Position 14 */
130 "Completer Abort ", /* Bit Position 15 */
131 "Unexpected Completion ", /* Bit Position 16 */
132 "Receiver Overflow ", /* Bit Position 17 */
133 "Malformed TLP ", /* Bit Position 18 */
134 "ECRC ", /* Bit Position 19 */
135 "Unsupported Request ", /* Bit Position 20 */
136 NULL, 94 NULL,
137 NULL, 95 NULL,
138 NULL, 96 NULL,
139 NULL, 97 NULL,
98 "Data Link Protocol", /* Bit Position 4 */
140 NULL, 99 NULL,
141 NULL, 100 NULL,
142 NULL, 101 NULL,
@@ -144,19 +103,29 @@ static char *aer_uncorrectable_error_string[] = {
144 NULL, 103 NULL,
145 NULL, 104 NULL,
146 NULL, 105 NULL,
106 "Poisoned TLP", /* Bit Position 12 */
107 "Flow Control Protocol", /* Bit Position 13 */
108 "Completion Timeout", /* Bit Position 14 */
109 "Completer Abort", /* Bit Position 15 */
110 "Unexpected Completion", /* Bit Position 16 */
111 "Receiver Overflow", /* Bit Position 17 */
112 "Malformed TLP", /* Bit Position 18 */
113 "ECRC", /* Bit Position 19 */
114 "Unsupported Request", /* Bit Position 20 */
147}; 115};
148 116
149static char *aer_agent_string[] = { 117static const char *aer_agent_string[] = {
150 "Receiver ID", 118 "Receiver ID",
151 "Requester ID", 119 "Requester ID",
152 "Completer ID", 120 "Completer ID",
153 "Transmitter ID" 121 "Transmitter ID"
154}; 122};
155 123
156static void __aer_print_error(struct aer_err_info *info, struct pci_dev *dev) 124static void __aer_print_error(const char *prefix,
125 struct aer_err_info *info)
157{ 126{
158 int i, status; 127 int i, status;
159 char *errmsg = NULL; 128 const char *errmsg = NULL;
160 129
161 status = (info->status & ~info->mask); 130 status = (info->status & ~info->mask);
162 131
@@ -165,15 +134,17 @@ static void __aer_print_error(struct aer_err_info *info, struct pci_dev *dev)
165 continue; 134 continue;
166 135
167 if (info->severity == AER_CORRECTABLE) 136 if (info->severity == AER_CORRECTABLE)
168 errmsg = aer_correctable_error_string[i]; 137 errmsg = i < ARRAY_SIZE(aer_correctable_error_string) ?
138 aer_correctable_error_string[i] : NULL;
169 else 139 else
170 errmsg = aer_uncorrectable_error_string[i]; 140 errmsg = i < ARRAY_SIZE(aer_uncorrectable_error_string) ?
141 aer_uncorrectable_error_string[i] : NULL;
171 142
172 if (errmsg) 143 if (errmsg)
173 AER_PR(info, dev, " [%2d] %s%s\n", i, errmsg, 144 printk("%s"" [%2d] %-22s%s\n", prefix, i, errmsg,
174 info->first_error == i ? " (First)" : ""); 145 info->first_error == i ? " (First)" : "");
175 else 146 else
176 AER_PR(info, dev, " [%2d] Unknown Error Bit%s\n", i, 147 printk("%s"" [%2d] Unknown Error Bit%s\n", prefix, i,
177 info->first_error == i ? " (First)" : ""); 148 info->first_error == i ? " (First)" : "");
178 } 149 }
179} 150}
@@ -181,11 +152,15 @@ static void __aer_print_error(struct aer_err_info *info, struct pci_dev *dev)
181void aer_print_error(struct pci_dev *dev, struct aer_err_info *info) 152void aer_print_error(struct pci_dev *dev, struct aer_err_info *info)
182{ 153{
183 int id = ((dev->bus->number << 8) | dev->devfn); 154 int id = ((dev->bus->number << 8) | dev->devfn);
155 char prefix[44];
156
157 snprintf(prefix, sizeof(prefix), "%s%s %s: ",
158 (info->severity == AER_CORRECTABLE) ? KERN_WARNING : KERN_ERR,
159 dev_driver_string(&dev->dev), dev_name(&dev->dev));
184 160
185 if (info->status == 0) { 161 if (info->status == 0) {
186 AER_PR(info, dev, 162 printk("%s""PCIe Bus Error: severity=%s, type=Unaccessible, "
187 "PCIe Bus Error: severity=%s, type=Unaccessible, " 163 "id=%04x(Unregistered Agent ID)\n", prefix,
188 "id=%04x(Unregistered Agent ID)\n",
189 aer_error_severity_string[info->severity], id); 164 aer_error_severity_string[info->severity], id);
190 } else { 165 } else {
191 int layer, agent; 166 int layer, agent;
@@ -193,23 +168,22 @@ void aer_print_error(struct pci_dev *dev, struct aer_err_info *info)
193 layer = AER_GET_LAYER_ERROR(info->severity, info->status); 168 layer = AER_GET_LAYER_ERROR(info->severity, info->status);
194 agent = AER_GET_AGENT(info->severity, info->status); 169 agent = AER_GET_AGENT(info->severity, info->status);
195 170
196 AER_PR(info, dev, 171 printk("%s""PCIe Bus Error: severity=%s, type=%s, id=%04x(%s)\n",
197 "PCIe Bus Error: severity=%s, type=%s, id=%04x(%s)\n", 172 prefix, aer_error_severity_string[info->severity],
198 aer_error_severity_string[info->severity],
199 aer_error_layer[layer], id, aer_agent_string[agent]); 173 aer_error_layer[layer], id, aer_agent_string[agent]);
200 174
201 AER_PR(info, dev, 175 printk("%s"" device [%04x:%04x] error status/mask=%08x/%08x\n",
202 " device [%04x:%04x] error status/mask=%08x/%08x\n", 176 prefix, dev->vendor, dev->device,
203 dev->vendor, dev->device, info->status, info->mask); 177 info->status, info->mask);
204 178
205 __aer_print_error(info, dev); 179 __aer_print_error(prefix, info);
206 180
207 if (info->tlp_header_valid) { 181 if (info->tlp_header_valid) {
208 unsigned char *tlp = (unsigned char *) &info->tlp; 182 unsigned char *tlp = (unsigned char *) &info->tlp;
209 AER_PR(info, dev, " TLP Header:" 183 printk("%s"" TLP Header:"
210 " %02x%02x%02x%02x %02x%02x%02x%02x" 184 " %02x%02x%02x%02x %02x%02x%02x%02x"
211 " %02x%02x%02x%02x %02x%02x%02x%02x\n", 185 " %02x%02x%02x%02x %02x%02x%02x%02x\n",
212 *(tlp + 3), *(tlp + 2), *(tlp + 1), *tlp, 186 prefix, *(tlp + 3), *(tlp + 2), *(tlp + 1), *tlp,
213 *(tlp + 7), *(tlp + 6), *(tlp + 5), *(tlp + 4), 187 *(tlp + 7), *(tlp + 6), *(tlp + 5), *(tlp + 4),
214 *(tlp + 11), *(tlp + 10), *(tlp + 9), 188 *(tlp + 11), *(tlp + 10), *(tlp + 9),
215 *(tlp + 8), *(tlp + 15), *(tlp + 14), 189 *(tlp + 8), *(tlp + 15), *(tlp + 14),
@@ -218,8 +192,8 @@ void aer_print_error(struct pci_dev *dev, struct aer_err_info *info)
218 } 192 }
219 193
220 if (info->id && info->error_dev_num > 1 && info->id == id) 194 if (info->id && info->error_dev_num > 1 && info->id == id)
221 AER_PR(info, dev, 195 printk("%s"" Error of this Agent(%04x) is reported first\n",
222 " Error of this Agent(%04x) is reported first\n", id); 196 prefix, id);
223} 197}
224 198
225void aer_print_port_info(struct pci_dev *dev, struct aer_err_info *info) 199void aer_print_port_info(struct pci_dev *dev, struct aer_err_info *info)
@@ -228,3 +202,61 @@ void aer_print_port_info(struct pci_dev *dev, struct aer_err_info *info)
228 info->multi_error_valid ? "Multiple " : "", 202 info->multi_error_valid ? "Multiple " : "",
229 aer_error_severity_string[info->severity], info->id); 203 aer_error_severity_string[info->severity], info->id);
230} 204}
205
206#ifdef CONFIG_ACPI_APEI_PCIEAER
207static int cper_severity_to_aer(int cper_severity)
208{
209 switch (cper_severity) {
210 case CPER_SEV_RECOVERABLE:
211 return AER_NONFATAL;
212 case CPER_SEV_FATAL:
213 return AER_FATAL;
214 default:
215 return AER_CORRECTABLE;
216 }
217}
218
219void cper_print_aer(const char *prefix, int cper_severity,
220 struct aer_capability_regs *aer)
221{
222 int aer_severity, layer, agent, status_strs_size, tlp_header_valid = 0;
223 u32 status, mask;
224 const char **status_strs;
225
226 aer_severity = cper_severity_to_aer(cper_severity);
227 if (aer_severity == AER_CORRECTABLE) {
228 status = aer->cor_status;
229 mask = aer->cor_mask;
230 status_strs = aer_correctable_error_string;
231 status_strs_size = ARRAY_SIZE(aer_correctable_error_string);
232 } else {
233 status = aer->uncor_status;
234 mask = aer->uncor_mask;
235 status_strs = aer_uncorrectable_error_string;
236 status_strs_size = ARRAY_SIZE(aer_uncorrectable_error_string);
237 tlp_header_valid = status & AER_LOG_TLP_MASKS;
238 }
239 layer = AER_GET_LAYER_ERROR(aer_severity, status);
240 agent = AER_GET_AGENT(aer_severity, status);
241 printk("%s""aer_status: 0x%08x, aer_mask: 0x%08x\n",
242 prefix, status, mask);
243 cper_print_bits(prefix, status, status_strs, status_strs_size);
244 printk("%s""aer_layer=%s, aer_agent=%s\n", prefix,
245 aer_error_layer[layer], aer_agent_string[agent]);
246 if (aer_severity != AER_CORRECTABLE)
247 printk("%s""aer_uncor_severity: 0x%08x\n",
248 prefix, aer->uncor_severity);
249 if (tlp_header_valid) {
250 const unsigned char *tlp;
251 tlp = (const unsigned char *)&aer->header_log;
252 printk("%s""aer_tlp_header:"
253 " %02x%02x%02x%02x %02x%02x%02x%02x"
254 " %02x%02x%02x%02x %02x%02x%02x%02x\n",
255 prefix, *(tlp + 3), *(tlp + 2), *(tlp + 1), *tlp,
256 *(tlp + 7), *(tlp + 6), *(tlp + 5), *(tlp + 4),
257 *(tlp + 11), *(tlp + 10), *(tlp + 9),
258 *(tlp + 8), *(tlp + 15), *(tlp + 14),
259 *(tlp + 13), *(tlp + 12));
260 }
261}
262#endif
diff --git a/drivers/thermal/thermal_sys.c b/drivers/thermal/thermal_sys.c
index 713b7ea4a607..fc6f2a5bde01 100644
--- a/drivers/thermal/thermal_sys.c
+++ b/drivers/thermal/thermal_sys.c
@@ -560,7 +560,8 @@ thermal_remove_hwmon_sysfs(struct thermal_zone_device *tz)
560 560
561 tz->hwmon = NULL; 561 tz->hwmon = NULL;
562 device_remove_file(hwmon->device, &tz->temp_input.attr); 562 device_remove_file(hwmon->device, &tz->temp_input.attr);
563 device_remove_file(hwmon->device, &tz->temp_crit.attr); 563 if (tz->ops->get_crit_temp)
564 device_remove_file(hwmon->device, &tz->temp_crit.attr);
564 565
565 mutex_lock(&thermal_list_lock); 566 mutex_lock(&thermal_list_lock);
566 list_del(&tz->hwmon_node); 567 list_del(&tz->hwmon_node);
diff --git a/include/acpi/acoutput.h b/include/acpi/acoutput.h
index ef1cef77d32b..d7bd661bfae7 100644
--- a/include/acpi/acoutput.h
+++ b/include/acpi/acoutput.h
@@ -183,13 +183,19 @@
183 183
184#if defined (ACPI_DEBUG_OUTPUT) || !defined (ACPI_NO_ERROR_MESSAGES) 184#if defined (ACPI_DEBUG_OUTPUT) || !defined (ACPI_NO_ERROR_MESSAGES)
185/* 185/*
186 * Module name is included in both debug and non-debug versions primarily for 186 * The module name is used primarily for error and debug messages.
187 * error messages. The __FILE__ macro is not very useful for this, because it 187 * The __FILE__ macro is not very useful for this, because it
188 * often includes the entire pathname to the module 188 * usually includes the entire pathname to the module making the
189 * debug output difficult to read.
189 */ 190 */
190#define ACPI_MODULE_NAME(name) static const char ACPI_UNUSED_VAR _acpi_module_name[] = name; 191#define ACPI_MODULE_NAME(name) static const char ACPI_UNUSED_VAR _acpi_module_name[] = name;
191#else 192#else
193/*
194 * For the no-debug and no-error-msg cases, we must at least define
195 * a null module name.
196 */
192#define ACPI_MODULE_NAME(name) 197#define ACPI_MODULE_NAME(name)
198#define _acpi_module_name ""
193#endif 199#endif
194 200
195/* 201/*
diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h
index ff103ba96b78..3a10ef5914eb 100644
--- a/include/acpi/acpi_bus.h
+++ b/include/acpi/acpi_bus.h
@@ -250,7 +250,6 @@ struct acpi_device_wakeup {
250 struct acpi_handle_list resources; 250 struct acpi_handle_list resources;
251 struct acpi_device_wakeup_flags flags; 251 struct acpi_device_wakeup_flags flags;
252 int prepare_count; 252 int prepare_count;
253 int run_wake_count;
254}; 253};
255 254
256/* Device */ 255/* Device */
diff --git a/include/acpi/acpixf.h b/include/acpi/acpixf.h
index e46ec95a8ada..f6ad63d25b73 100644
--- a/include/acpi/acpixf.h
+++ b/include/acpi/acpixf.h
@@ -47,7 +47,7 @@
47 47
48/* Current ACPICA subsystem version in YYYYMMDD format */ 48/* Current ACPICA subsystem version in YYYYMMDD format */
49 49
50#define ACPI_CA_VERSION 0x20110112 50#define ACPI_CA_VERSION 0x20110316
51 51
52#include "actypes.h" 52#include "actypes.h"
53#include "actbl.h" 53#include "actbl.h"
diff --git a/include/acpi/actbl.h b/include/acpi/actbl.h
index 7e42bfee0e29..d41c94885211 100644
--- a/include/acpi/actbl.h
+++ b/include/acpi/actbl.h
@@ -343,4 +343,20 @@ struct acpi_table_desc {
343#include <acpi/actbl1.h> 343#include <acpi/actbl1.h>
344#include <acpi/actbl2.h> 344#include <acpi/actbl2.h>
345 345
346/*
347 * Sizes of the various flavors of FADT. We need to look closely
348 * at the FADT length because the version number essentially tells
349 * us nothing because of many BIOS bugs where the version does not
350 * match the expected length. In other words, the length of the
351 * FADT is the bottom line as to what the version really is.
352 *
353 * For reference, the values below are as follows:
354 * FADT V1 size: 0x74
355 * FADT V2 size: 0x84
356 * FADT V3+ size: 0xF4
357 */
358#define ACPI_FADT_V1_SIZE (u32) (ACPI_FADT_OFFSET (flags) + 4)
359#define ACPI_FADT_V2_SIZE (u32) (ACPI_FADT_OFFSET (reserved4[0]) + 3)
360#define ACPI_FADT_V3_SIZE (u32) (sizeof (struct acpi_table_fadt))
361
346#endif /* __ACTBL_H__ */ 362#endif /* __ACTBL_H__ */
diff --git a/include/acpi/actbl2.h b/include/acpi/actbl2.h
index 0fc15dfb2e22..58bdd0545c5a 100644
--- a/include/acpi/actbl2.h
+++ b/include/acpi/actbl2.h
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Name: actbl2.h - ACPI Specification Revision 2.0 Tables 3 * Name: actbl2.h - ACPI Table Definitions (tables not in ACPI spec)
4 * 4 *
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
@@ -716,6 +716,68 @@ struct acpi_table_mchi {
716 716
717/******************************************************************************* 717/*******************************************************************************
718 * 718 *
719 * SLIC - Software Licensing Description Table
720 * Version 1
721 *
722 * Conforms to "OEM Activation 2.0 for Windows Vista Operating Systems",
723 * Copyright 2006
724 *
725 ******************************************************************************/
726
727/* Basic SLIC table is only the common ACPI header */
728
729struct acpi_table_slic {
730 struct acpi_table_header header; /* Common ACPI table header */
731};
732
733/* Common SLIC subtable header */
734
735struct acpi_slic_header {
736 u32 type;
737 u32 length;
738};
739
740/* Values for Type field above */
741
742enum acpi_slic_type {
743 ACPI_SLIC_TYPE_PUBLIC_KEY = 0,
744 ACPI_SLIC_TYPE_WINDOWS_MARKER = 1,
745 ACPI_SLIC_TYPE_RESERVED = 2 /* 2 and greater are reserved */
746};
747
748/*
749 * SLIC Sub-tables, correspond to Type in struct acpi_slic_header
750 */
751
752/* 0: Public Key Structure */
753
754struct acpi_slic_key {
755 struct acpi_slic_header header;
756 u8 key_type;
757 u8 version;
758 u16 reserved;
759 u32 algorithm;
760 char magic[4];
761 u32 bit_length;
762 u32 exponent;
763 u8 modulus[128];
764};
765
766/* 1: Windows Marker Structure */
767
768struct acpi_slic_marker {
769 struct acpi_slic_header header;
770 u32 version;
771 char oem_id[ACPI_OEM_ID_SIZE]; /* ASCII OEM identification */
772 char oem_table_id[ACPI_OEM_TABLE_ID_SIZE]; /* ASCII OEM table identification */
773 char windows_flag[8];
774 u32 slic_version;
775 u8 reserved[16];
776 u8 signature[128];
777};
778
779/*******************************************************************************
780 *
719 * SPCR - Serial Port Console Redirection table 781 * SPCR - Serial Port Console Redirection table
720 * Version 1 782 * Version 1
721 * 783 *
diff --git a/include/acpi/apei.h b/include/acpi/apei.h
index c4dbb132d902..e67b523a50e1 100644
--- a/include/acpi/apei.h
+++ b/include/acpi/apei.h
@@ -30,10 +30,11 @@ int apei_hest_parse(apei_hest_func_t func, void *data);
30 30
31int erst_write(const struct cper_record_header *record); 31int erst_write(const struct cper_record_header *record);
32ssize_t erst_get_record_count(void); 32ssize_t erst_get_record_count(void);
33int erst_get_next_record_id(u64 *record_id); 33int erst_get_record_id_begin(int *pos);
34int erst_get_record_id_next(int *pos, u64 *record_id);
35void erst_get_record_id_end(void);
34ssize_t erst_read(u64 record_id, struct cper_record_header *record, 36ssize_t erst_read(u64 record_id, struct cper_record_header *record,
35 size_t buflen); 37 size_t buflen);
36ssize_t erst_read_next(struct cper_record_header *record, size_t buflen);
37int erst_clear(u64 record_id); 38int erst_clear(u64 record_id);
38 39
39#endif 40#endif
diff --git a/include/linux/acpi_io.h b/include/linux/acpi_io.h
index 7180013a4a3a..4afd7102459d 100644
--- a/include/linux/acpi_io.h
+++ b/include/linux/acpi_io.h
@@ -10,7 +10,6 @@ static inline void __iomem *acpi_os_ioremap(acpi_physical_address phys,
10 return ioremap_cache(phys, size); 10 return ioremap_cache(phys, size);
11} 11}
12 12
13int acpi_os_map_generic_address(struct acpi_generic_address *addr); 13void __iomem *acpi_os_get_iomem(acpi_physical_address phys, unsigned int size);
14void acpi_os_unmap_generic_address(struct acpi_generic_address *addr);
15 14
16#endif 15#endif
diff --git a/include/linux/aer.h b/include/linux/aer.h
index f7df1eefc107..8414de22a779 100644
--- a/include/linux/aer.h
+++ b/include/linux/aer.h
@@ -7,6 +7,28 @@
7#ifndef _AER_H_ 7#ifndef _AER_H_
8#define _AER_H_ 8#define _AER_H_
9 9
10struct aer_header_log_regs {
11 unsigned int dw0;
12 unsigned int dw1;
13 unsigned int dw2;
14 unsigned int dw3;
15};
16
17struct aer_capability_regs {
18 u32 header;
19 u32 uncor_status;
20 u32 uncor_mask;
21 u32 uncor_severity;
22 u32 cor_status;
23 u32 cor_mask;
24 u32 cap_control;
25 struct aer_header_log_regs header_log;
26 u32 root_command;
27 u32 root_status;
28 u16 cor_err_source;
29 u16 uncor_err_source;
30};
31
10#if defined(CONFIG_PCIEAER) 32#if defined(CONFIG_PCIEAER)
11/* pci-e port driver needs this function to enable aer */ 33/* pci-e port driver needs this function to enable aer */
12extern int pci_enable_pcie_error_reporting(struct pci_dev *dev); 34extern int pci_enable_pcie_error_reporting(struct pci_dev *dev);
@@ -27,5 +49,7 @@ static inline int pci_cleanup_aer_uncorrect_error_status(struct pci_dev *dev)
27} 49}
28#endif 50#endif
29 51
52extern void cper_print_aer(const char *prefix, int cper_severity,
53 struct aer_capability_regs *aer);
30#endif //_AER_H_ 54#endif //_AER_H_
31 55
diff --git a/include/linux/cper.h b/include/linux/cper.h
index 3104aaff5dd0..372a25839fd1 100644
--- a/include/linux/cper.h
+++ b/include/linux/cper.h
@@ -388,5 +388,7 @@ struct cper_sec_pcie {
388#pragma pack() 388#pragma pack()
389 389
390u64 cper_next_record_id(void); 390u64 cper_next_record_id(void);
391void cper_print_bits(const char *prefix, unsigned int bits,
392 const char *strs[], unsigned int strs_size);
391 393
392#endif 394#endif