aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2014-08-06 23:34:19 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2014-08-06 23:34:19 -0400
commit7725131982477bffff8ffdea143434dcc69f5d90 (patch)
tree099440f6a8b11c8221ea99effec4c22818b3b577 /drivers
parent6b22df74f7af62137772c280791c932855f7635b (diff)
parent7ef97e0e3a0f4b02601dde384127cc85d27e46e2 (diff)
Merge tag 'pm+acpi-3.17-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm
Pull ACPI and power management updates from Rafael Wysocki: "Again, ACPICA leads the pack (47 commits), followed by cpufreq (18 commits) and system suspend/hibernation (9 commits). From the new code perspective, the ACPICA update brings ACPI 5.1 to the table, including a new device configuration object called _DSD (Device Specific Data) that will hopefully help us to operate device properties like Device Trees do (at least to some extent) and changes related to supporting ACPI on ARM. Apart from that we have hibernation changes making it use radix trees to store memory bitmaps which should speed up some operations carried out by it quite significantly. We also have some power management changes related to suspend-to-idle (the "freeze" sleep state) support and more preliminary changes needed to support ACPI on ARM (outside of ACPICA). The rest is fixes and cleanups pretty much everywhere. Specifics: - ACPICA update to upstream version 20140724. That includes ACPI 5.1 material (support for the _CCA and _DSD predefined names, changes related to the DMAR and PCCT tables and ARM support among other things) and cleanups related to using ACPICA's header files. A major part of it is related to acpidump and the core code used by that utility. Changes from Bob Moore, David E Box, Lv Zheng, Sascha Wildner, Tomasz Nowicki, Hanjun Guo. - Radix trees for memory bitmaps used by the hibernation core from Joerg Roedel. - Support for waking up the system from suspend-to-idle (also known as the "freeze" sleep state) using ACPI-based PCI wakeup signaling (Rafael J Wysocki). - Fixes for issues related to ACPI button events (Rafael J Wysocki). - New device ID for an ACPI-enumerated device included into the Wildcat Point PCH from Jie Yang. - ACPI video updates related to backlight handling from Hans de Goede and Linus Torvalds. - Preliminary changes needed to support ACPI on ARM from Hanjun Guo and Graeme Gregory. - ACPI PNP core cleanups from Arjun Sreedharan and Zhang Rui. - Cleanups related to ACPI_COMPANION() and ACPI_HANDLE() macros (Rafael J Wysocki). - ACPI-based device hotplug cleanups from Wei Yongjun and Rafael J Wysocki. - Cleanups and improvements related to system suspend from Lan Tianyu, Randy Dunlap and Rafael J Wysocki. - ACPI battery cleanup from Wei Yongjun. - cpufreq core fixes from Viresh Kumar. - Elimination of a deadband effect from the cpufreq ondemand governor and intel_pstate driver cleanups from Stratos Karafotis. - 350MHz CPU support for the powernow-k6 cpufreq driver from Mikulas Patocka. - Fix for the imx6 cpufreq driver from Anson Huang. - cpuidle core and governor cleanups from Daniel Lezcano, Sandeep Tripathy and Mohammad Merajul Islam Molla. - Build fix for the big_little cpuidle driver from Sachin Kamat. - Configuration fix for the Operation Performance Points (OPP) framework from Mark Brown. - APM cleanup from Jean Delvare. - cpupower utility fixes and cleanups from Peter Senna Tschudin, Andrey Utkin, Himangi Saraogi, Rickard Strandqvist, Thomas Renninger" * tag 'pm+acpi-3.17-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: (118 commits) ACPI / LPSS: add LPSS device for Wildcat Point PCH ACPI / PNP: Replace faulty is_hex_digit() by isxdigit() ACPICA: Update version to 20140724. ACPICA: ACPI 5.1: Update for PCCT table changes. ACPICA/ARM: ACPI 5.1: Update for GTDT table changes. ACPICA/ARM: ACPI 5.1: Update for MADT changes. ACPICA/ARM: ACPI 5.1: Update for FADT changes. ACPICA: ACPI 5.1: Support for the _CCA predifined name. ACPICA: ACPI 5.1: New notify value for System Affinity Update. ACPICA: ACPI 5.1: Support for the _DSD predefined name. ACPICA: Debug object: Add current value of Timer() to debug line prefix. ACPICA: acpihelp: Add UUID support, restructure some existing files. ACPICA: Utilities: Fix local printf issue. ACPICA: Tables: Update for DMAR table changes. ACPICA: Remove some extraneous printf arguments. ACPICA: Update for comments/formatting. No functional changes. ACPICA: Disassembler: Add support for the ToUUID opererator (macro). ACPICA: Remove a redundant cast to acpi_size for ACPI_OFFSET() macro. ACPICA: Work around an ancient GCC bug. ACPI / processor: Make it possible to get local x2apic id via _MAT ...
Diffstat (limited to 'drivers')
-rw-r--r--drivers/acpi/Kconfig6
-rw-r--r--drivers/acpi/Makefile1
-rw-r--r--drivers/acpi/acpi_extlog.c18
-rw-r--r--drivers/acpi/acpi_lpss.c10
-rw-r--r--drivers/acpi/acpi_pnp.c8
-rw-r--r--drivers/acpi/acpi_processor.c2
-rw-r--r--drivers/acpi/acpica/Makefile10
-rw-r--r--drivers/acpi/acpica/acapps.h9
-rw-r--r--drivers/acpi/acpica/acdebug.h3
-rw-r--r--drivers/acpi/acpica/acglobal.h8
-rw-r--r--drivers/acpi/acpica/aclocal.h18
-rw-r--r--drivers/acpi/acpica/acpredef.h16
-rw-r--r--drivers/acpi/acpica/acutils.h48
-rw-r--r--drivers/acpi/acpica/evgpe.c32
-rw-r--r--drivers/acpi/acpica/evxfgpe.c61
-rw-r--r--drivers/acpi/acpica/exdebug.c11
-rw-r--r--drivers/acpi/acpica/exdump.c6
-rw-r--r--drivers/acpi/acpica/exfield.c26
-rw-r--r--drivers/acpi/acpica/hwregs.c3
-rw-r--r--drivers/acpi/acpica/nsobject.c10
-rw-r--r--drivers/acpi/acpica/utbuffer.c128
-rw-r--r--drivers/acpi/acpica/utcopy.c6
-rw-r--r--drivers/acpi/acpica/utdebug.c26
-rw-r--r--drivers/acpi/acpica/utdecode.c32
-rw-r--r--drivers/acpi/acpica/utfileio.c331
-rw-r--r--drivers/acpi/acpica/utglobal.c146
-rw-r--r--drivers/acpi/acpica/uthex.c100
-rw-r--r--drivers/acpi/acpica/utinit.c145
-rw-r--r--drivers/acpi/acpica/utprint.c664
-rw-r--r--drivers/acpi/acpica/utuuid.c96
-rw-r--r--drivers/acpi/apei/apei-internal.h10
-rw-r--r--drivers/acpi/apei/ghes.c32
-rw-r--r--drivers/acpi/battery.c1
-rw-r--r--drivers/acpi/blacklist.c68
-rw-r--r--drivers/acpi/bus.c3
-rw-r--r--drivers/acpi/button.c25
-rw-r--r--drivers/acpi/device_pm.c148
-rw-r--r--drivers/acpi/internal.h7
-rw-r--r--drivers/acpi/osl.c4
-rw-r--r--drivers/acpi/pci_root.c2
-rw-r--r--drivers/acpi/processor_core.c200
-rw-r--r--drivers/acpi/processor_pdc.c206
-rw-r--r--drivers/acpi/scan.c33
-rw-r--r--drivers/acpi/sleep.c5
-rw-r--r--drivers/acpi/video.c121
-rw-r--r--drivers/base/power/main.c5
-rw-r--r--drivers/cpufreq/cpufreq.c74
-rw-r--r--drivers/cpufreq/cpufreq_ondemand.c11
-rw-r--r--drivers/cpufreq/freq_table.c12
-rw-r--r--drivers/cpufreq/imx6q-cpufreq.c35
-rw-r--r--drivers/cpufreq/intel_pstate.c131
-rw-r--r--drivers/cpufreq/powernow-k6.c1
-rw-r--r--drivers/cpuidle/Kconfig7
-rw-r--r--drivers/cpuidle/Kconfig.arm1
-rw-r--r--drivers/cpuidle/cpuidle.c2
-rw-r--r--drivers/cpuidle/driver.c11
-rw-r--r--drivers/cpuidle/governors/ladder.c4
-rw-r--r--drivers/cpuidle/governors/menu.c1
-rw-r--r--drivers/cpuidle/sysfs.c2
-rw-r--r--drivers/devfreq/Kconfig1
-rw-r--r--drivers/firmware/efi/cper.c20
-rw-r--r--drivers/iommu/dmar.c28
-rw-r--r--drivers/pci/hotplug/acpiphp_glue.c33
-rw-r--r--drivers/pci/pci-acpi.c76
-rw-r--r--drivers/pnp/pnpacpi/core.c91
65 files changed, 2432 insertions, 959 deletions
diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig
index 206942b8d105..d0f3265fb85d 100644
--- a/drivers/acpi/Kconfig
+++ b/drivers/acpi/Kconfig
@@ -42,6 +42,12 @@ menuconfig ACPI
42 42
43if ACPI 43if ACPI
44 44
45config ACPI_LEGACY_TABLES_LOOKUP
46 bool
47
48config ARCH_MIGHT_HAVE_ACPI_PDC
49 bool
50
45config ACPI_SLEEP 51config ACPI_SLEEP
46 bool 52 bool
47 depends on SUSPEND || HIBERNATION 53 depends on SUSPEND || HIBERNATION
diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile
index ea55e0179f81..505d4d79fe3e 100644
--- a/drivers/acpi/Makefile
+++ b/drivers/acpi/Makefile
@@ -36,6 +36,7 @@ acpi-y += scan.o
36acpi-y += resource.o 36acpi-y += resource.o
37acpi-y += acpi_processor.o 37acpi-y += acpi_processor.o
38acpi-y += processor_core.o 38acpi-y += processor_core.o
39acpi-$(CONFIG_ARCH_MIGHT_HAVE_ACPI_PDC) += processor_pdc.o
39acpi-y += ec.o 40acpi-y += ec.o
40acpi-$(CONFIG_ACPI_DOCK) += dock.o 41acpi-$(CONFIG_ACPI_DOCK) += dock.o
41acpi-y += pci_root.o pci_link.o pci_irq.o 42acpi-y += pci_root.o pci_link.o pci_irq.o
diff --git a/drivers/acpi/acpi_extlog.c b/drivers/acpi/acpi_extlog.c
index 0ad6f389d922..b3842ffc19ba 100644
--- a/drivers/acpi/acpi_extlog.c
+++ b/drivers/acpi/acpi_extlog.c
@@ -71,11 +71,11 @@ static u32 l1_percpu_entry;
71#define ELOG_ENTRY_ADDR(phyaddr) \ 71#define ELOG_ENTRY_ADDR(phyaddr) \
72 (phyaddr - elog_base + (u8 *)elog_addr) 72 (phyaddr - elog_base + (u8 *)elog_addr)
73 73
74static struct acpi_generic_status *extlog_elog_entry_check(int cpu, int bank) 74static struct acpi_hest_generic_status *extlog_elog_entry_check(int cpu, int bank)
75{ 75{
76 int idx; 76 int idx;
77 u64 data; 77 u64 data;
78 struct acpi_generic_status *estatus; 78 struct acpi_hest_generic_status *estatus;
79 79
80 WARN_ON(cpu < 0); 80 WARN_ON(cpu < 0);
81 idx = ELOG_IDX(cpu, bank); 81 idx = ELOG_IDX(cpu, bank);
@@ -84,7 +84,7 @@ static struct acpi_generic_status *extlog_elog_entry_check(int cpu, int bank)
84 return NULL; 84 return NULL;
85 85
86 data &= EXT_ELOG_ENTRY_MASK; 86 data &= EXT_ELOG_ENTRY_MASK;
87 estatus = (struct acpi_generic_status *)ELOG_ENTRY_ADDR(data); 87 estatus = (struct acpi_hest_generic_status *)ELOG_ENTRY_ADDR(data);
88 88
89 /* if no valid data in elog entry, just return */ 89 /* if no valid data in elog entry, just return */
90 if (estatus->block_status == 0) 90 if (estatus->block_status == 0)
@@ -94,7 +94,7 @@ static struct acpi_generic_status *extlog_elog_entry_check(int cpu, int bank)
94} 94}
95 95
96static void __print_extlog_rcd(const char *pfx, 96static void __print_extlog_rcd(const char *pfx,
97 struct acpi_generic_status *estatus, int cpu) 97 struct acpi_hest_generic_status *estatus, int cpu)
98{ 98{
99 static atomic_t seqno; 99 static atomic_t seqno;
100 unsigned int curr_seqno; 100 unsigned int curr_seqno;
@@ -113,7 +113,7 @@ static void __print_extlog_rcd(const char *pfx,
113} 113}
114 114
115static int print_extlog_rcd(const char *pfx, 115static int print_extlog_rcd(const char *pfx,
116 struct acpi_generic_status *estatus, int cpu) 116 struct acpi_hest_generic_status *estatus, int cpu)
117{ 117{
118 /* Not more than 2 messages every 5 seconds */ 118 /* Not more than 2 messages every 5 seconds */
119 static DEFINE_RATELIMIT_STATE(ratelimit_corrected, 5*HZ, 2); 119 static DEFINE_RATELIMIT_STATE(ratelimit_corrected, 5*HZ, 2);
@@ -139,8 +139,8 @@ static int extlog_print(struct notifier_block *nb, unsigned long val,
139 struct mce *mce = (struct mce *)data; 139 struct mce *mce = (struct mce *)data;
140 int bank = mce->bank; 140 int bank = mce->bank;
141 int cpu = mce->extcpu; 141 int cpu = mce->extcpu;
142 struct acpi_generic_status *estatus, *tmp; 142 struct acpi_hest_generic_status *estatus, *tmp;
143 struct acpi_generic_data *gdata; 143 struct acpi_hest_generic_data *gdata;
144 const uuid_le *fru_id = &NULL_UUID_LE; 144 const uuid_le *fru_id = &NULL_UUID_LE;
145 char *fru_text = ""; 145 char *fru_text = "";
146 uuid_le *sec_type; 146 uuid_le *sec_type;
@@ -154,7 +154,7 @@ static int extlog_print(struct notifier_block *nb, unsigned long val,
154 /* clear record status to enable BIOS to update it again */ 154 /* clear record status to enable BIOS to update it again */
155 estatus->block_status = 0; 155 estatus->block_status = 0;
156 156
157 tmp = (struct acpi_generic_status *)elog_buf; 157 tmp = (struct acpi_hest_generic_status *)elog_buf;
158 158
159 if (!ras_userspace_consumers()) { 159 if (!ras_userspace_consumers()) {
160 print_extlog_rcd(NULL, tmp, cpu); 160 print_extlog_rcd(NULL, tmp, cpu);
@@ -163,7 +163,7 @@ static int extlog_print(struct notifier_block *nb, unsigned long val,
163 163
164 /* log event via trace */ 164 /* log event via trace */
165 err_seq++; 165 err_seq++;
166 gdata = (struct acpi_generic_data *)(tmp + 1); 166 gdata = (struct acpi_hest_generic_data *)(tmp + 1);
167 if (gdata->validation_bits & CPER_SEC_VALID_FRU_ID) 167 if (gdata->validation_bits & CPER_SEC_VALID_FRU_ID)
168 fru_id = (uuid_le *)gdata->fru_id; 168 fru_id = (uuid_le *)gdata->fru_id;
169 if (gdata->validation_bits & CPER_SEC_VALID_FRU_TEXT) 169 if (gdata->validation_bits & CPER_SEC_VALID_FRU_TEXT)
diff --git a/drivers/acpi/acpi_lpss.c b/drivers/acpi/acpi_lpss.c
index 9cb65b0e7597..ce06149088c5 100644
--- a/drivers/acpi/acpi_lpss.c
+++ b/drivers/acpi/acpi_lpss.c
@@ -113,6 +113,14 @@ static void lpss_i2c_setup(struct lpss_private_data *pdata)
113 writel(val, pdata->mmio_base + offset); 113 writel(val, pdata->mmio_base + offset);
114} 114}
115 115
116static struct lpss_device_desc wpt_dev_desc = {
117 .clk_required = true,
118 .prv_offset = 0x800,
119 .ltr_required = true,
120 .clk_divider = true,
121 .clk_gate = true,
122};
123
116static struct lpss_device_desc lpt_dev_desc = { 124static struct lpss_device_desc lpt_dev_desc = {
117 .clk_required = true, 125 .clk_required = true,
118 .prv_offset = 0x800, 126 .prv_offset = 0x800,
@@ -226,6 +234,8 @@ static const struct acpi_device_id acpi_lpss_device_ids[] = {
226 { "INT3436", LPSS_ADDR(lpt_sdio_dev_desc) }, 234 { "INT3436", LPSS_ADDR(lpt_sdio_dev_desc) },
227 { "INT3437", }, 235 { "INT3437", },
228 236
237 { "INT3438", LPSS_ADDR(wpt_dev_desc) },
238
229 { } 239 { }
230}; 240};
231 241
diff --git a/drivers/acpi/acpi_pnp.c b/drivers/acpi/acpi_pnp.c
index 4ddb0dca56f6..996fa1959eea 100644
--- a/drivers/acpi/acpi_pnp.c
+++ b/drivers/acpi/acpi_pnp.c
@@ -12,6 +12,7 @@
12 12
13#include <linux/acpi.h> 13#include <linux/acpi.h>
14#include <linux/module.h> 14#include <linux/module.h>
15#include <linux/ctype.h>
15 16
16static const struct acpi_device_id acpi_pnp_device_ids[] = { 17static const struct acpi_device_id acpi_pnp_device_ids[] = {
17 /* soc_button_array */ 18 /* soc_button_array */
@@ -320,11 +321,6 @@ static const struct acpi_device_id acpi_pnp_device_ids[] = {
320 {""}, 321 {""},
321}; 322};
322 323
323static bool is_hex_digit(char c)
324{
325 return (c >= 0 && c <= '9') || (c >= 'A' && c <= 'F');
326}
327
328static bool matching_id(char *idstr, char *list_id) 324static bool matching_id(char *idstr, char *list_id)
329{ 325{
330 int i; 326 int i;
@@ -335,7 +331,7 @@ static bool matching_id(char *idstr, char *list_id)
335 for (i = 3; i < 7; i++) { 331 for (i = 3; i < 7; i++) {
336 char c = toupper(idstr[i]); 332 char c = toupper(idstr[i]);
337 333
338 if (!is_hex_digit(c) 334 if (!isxdigit(c)
339 || (list_id[i] != 'X' && c != toupper(list_id[i]))) 335 || (list_id[i] != 'X' && c != toupper(list_id[i])))
340 return false; 336 return false;
341 } 337 }
diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processor.c
index 1c085742644f..1fdf5e07a1c7 100644
--- a/drivers/acpi/acpi_processor.c
+++ b/drivers/acpi/acpi_processor.c
@@ -268,7 +268,7 @@ static int acpi_processor_get_info(struct acpi_device *device)
268 pr->apic_id = apic_id; 268 pr->apic_id = apic_id;
269 269
270 cpu_index = acpi_map_cpuid(pr->apic_id, pr->acpi_id); 270 cpu_index = acpi_map_cpuid(pr->apic_id, pr->acpi_id);
271 if (!cpu0_initialized && !acpi_lapic) { 271 if (!cpu0_initialized && !acpi_has_cpu_in_madt()) {
272 cpu0_initialized = 1; 272 cpu0_initialized = 1;
273 /* Handle UP system running SMP kernel, with no LAPIC in MADT */ 273 /* Handle UP system running SMP kernel, with no LAPIC in MADT */
274 if ((cpu_index == -1) && (num_online_cpus() == 1)) 274 if ((cpu_index == -1) && (num_online_cpus() == 1))
diff --git a/drivers/acpi/acpica/Makefile b/drivers/acpi/acpica/Makefile
index 8bb43f06e11f..c1a963581dc0 100644
--- a/drivers/acpi/acpica/Makefile
+++ b/drivers/acpi/acpica/Makefile
@@ -2,7 +2,7 @@
2# Makefile for ACPICA Core interpreter 2# Makefile for ACPICA Core interpreter
3# 3#
4 4
5ccflags-y := -Os 5ccflags-y := -Os -DBUILDING_ACPICA
6ccflags-$(CONFIG_ACPI_DEBUG) += -DACPI_DEBUG_OUTPUT 6ccflags-$(CONFIG_ACPI_DEBUG) += -DACPI_DEBUG_OUTPUT
7 7
8# use acpi.o to put all files here into acpi.o modparam namespace 8# use acpi.o to put all files here into acpi.o modparam namespace
@@ -157,6 +157,7 @@ acpi-y += \
157 uterror.o \ 157 uterror.o \
158 uteval.o \ 158 uteval.o \
159 utglobal.o \ 159 utglobal.o \
160 uthex.o \
160 utids.o \ 161 utids.o \
161 utinit.o \ 162 utinit.o \
162 utlock.o \ 163 utlock.o \
@@ -175,5 +176,10 @@ acpi-y += \
175 utxferror.o \ 176 utxferror.o \
176 utxfmutex.o 177 utxfmutex.o
177 178
178acpi-$(ACPI_FUTURE_USAGE) += uttrack.o utcache.o 179acpi-$(ACPI_FUTURE_USAGE) += \
180 utcache.o \
181 utfileio.o \
182 utprint.o \
183 uttrack.o \
184 utuuid.o
179 185
diff --git a/drivers/acpi/acpica/acapps.h b/drivers/acpi/acpica/acapps.h
index 8698ffba6f39..3d2c88289da9 100644
--- a/drivers/acpi/acpica/acapps.h
+++ b/drivers/acpi/acpica/acapps.h
@@ -79,10 +79,13 @@
79/* Macros for usage messages */ 79/* Macros for usage messages */
80 80
81#define ACPI_USAGE_HEADER(usage) \ 81#define ACPI_USAGE_HEADER(usage) \
82 printf ("Usage: %s\nOptions:\n", usage); 82 acpi_os_printf ("Usage: %s\nOptions:\n", usage);
83
84#define ACPI_USAGE_TEXT(description) \
85 acpi_os_printf (description);
83 86
84#define ACPI_OPTION(name, description) \ 87#define ACPI_OPTION(name, description) \
85 printf (" %-18s%s\n", name, description); 88 acpi_os_printf (" %-18s%s\n", name, description);
86 89
87#define FILE_SUFFIX_DISASSEMBLY "dsl" 90#define FILE_SUFFIX_DISASSEMBLY "dsl"
88#define ACPI_TABLE_FILE_SUFFIX ".dat" 91#define ACPI_TABLE_FILE_SUFFIX ".dat"
@@ -102,7 +105,7 @@ extern char *acpi_gbl_optarg;
102/* 105/*
103 * cmfsize - Common get file size function 106 * cmfsize - Common get file size function
104 */ 107 */
105u32 cm_get_file_size(FILE * file); 108u32 cm_get_file_size(ACPI_FILE file);
106 109
107#ifndef ACPI_DUMP_APP 110#ifndef ACPI_DUMP_APP
108/* 111/*
diff --git a/drivers/acpi/acpica/acdebug.h b/drivers/acpi/acpica/acdebug.h
index 68a91eb0fa48..1d026ff1683f 100644
--- a/drivers/acpi/acpica/acdebug.h
+++ b/drivers/acpi/acpica/acdebug.h
@@ -233,9 +233,6 @@ acpi_status acpi_db_load_acpi_table(char *filename);
233acpi_status 233acpi_status
234acpi_db_get_table_from_file(char *filename, struct acpi_table_header **table); 234acpi_db_get_table_from_file(char *filename, struct acpi_table_header **table);
235 235
236acpi_status
237acpi_db_read_table_from_file(char *filename, struct acpi_table_header **table);
238
239/* 236/*
240 * dbhistry - debugger HISTORY command 237 * dbhistry - debugger HISTORY command
241 */ 238 */
diff --git a/drivers/acpi/acpica/acglobal.h b/drivers/acpi/acpica/acglobal.h
index 115eedcade1e..ebf02cc10a43 100644
--- a/drivers/acpi/acpica/acglobal.h
+++ b/drivers/acpi/acpica/acglobal.h
@@ -297,7 +297,7 @@ ACPI_GLOBAL(u32, acpi_gbl_trace_dbg_layer);
297 * 297 *
298 ****************************************************************************/ 298 ****************************************************************************/
299 299
300ACPI_GLOBAL(u8, acpi_gbl_db_output_flags); 300ACPI_INIT_GLOBAL(u8, acpi_gbl_db_output_flags, ACPI_DB_CONSOLE_OUTPUT);
301 301
302#ifdef ACPI_DISASSEMBLER 302#ifdef ACPI_DISASSEMBLER
303 303
@@ -362,6 +362,12 @@ ACPI_GLOBAL(u32, acpi_gbl_num_objects);
362#ifdef ACPI_APPLICATION 362#ifdef ACPI_APPLICATION
363 363
364ACPI_INIT_GLOBAL(ACPI_FILE, acpi_gbl_debug_file, NULL); 364ACPI_INIT_GLOBAL(ACPI_FILE, acpi_gbl_debug_file, NULL);
365ACPI_INIT_GLOBAL(ACPI_FILE, acpi_gbl_output_file, NULL);
366
367/* Print buffer */
368
369ACPI_GLOBAL(acpi_spinlock, acpi_gbl_print_lock); /* For print buffer */
370ACPI_GLOBAL(char, acpi_gbl_print_buffer[1024]);
365 371
366#endif /* ACPI_APPLICATION */ 372#endif /* ACPI_APPLICATION */
367 373
diff --git a/drivers/acpi/acpica/aclocal.h b/drivers/acpi/acpica/aclocal.h
index 91f801a2e689..1f9aba5fb81f 100644
--- a/drivers/acpi/acpica/aclocal.h
+++ b/drivers/acpi/acpica/aclocal.h
@@ -730,12 +730,13 @@ union acpi_parse_value {
730#define ACPI_DASM_STRING 0x02 /* Buffer is a ASCII string */ 730#define ACPI_DASM_STRING 0x02 /* Buffer is a ASCII string */
731#define ACPI_DASM_UNICODE 0x03 /* Buffer is a Unicode string */ 731#define ACPI_DASM_UNICODE 0x03 /* Buffer is a Unicode string */
732#define ACPI_DASM_PLD_METHOD 0x04 /* Buffer is a _PLD method bit-packed buffer */ 732#define ACPI_DASM_PLD_METHOD 0x04 /* Buffer is a _PLD method bit-packed buffer */
733#define ACPI_DASM_EISAID 0x05 /* Integer is an EISAID */ 733#define ACPI_DASM_UUID 0x05 /* Buffer is a UUID/GUID */
734#define ACPI_DASM_MATCHOP 0x06 /* Parent opcode is a Match() operator */ 734#define ACPI_DASM_EISAID 0x06 /* Integer is an EISAID */
735#define ACPI_DASM_LNOT_PREFIX 0x07 /* Start of a Lnot_equal (etc.) pair of opcodes */ 735#define ACPI_DASM_MATCHOP 0x07 /* Parent opcode is a Match() operator */
736#define ACPI_DASM_LNOT_SUFFIX 0x08 /* End of a Lnot_equal (etc.) pair of opcodes */ 736#define ACPI_DASM_LNOT_PREFIX 0x08 /* Start of a Lnot_equal (etc.) pair of opcodes */
737#define ACPI_DASM_HID_STRING 0x09 /* String is a _HID or _CID */ 737#define ACPI_DASM_LNOT_SUFFIX 0x09 /* End of a Lnot_equal (etc.) pair of opcodes */
738#define ACPI_DASM_IGNORE 0x0A /* Not used at this time */ 738#define ACPI_DASM_HID_STRING 0x0A /* String is a _HID or _CID */
739#define ACPI_DASM_IGNORE 0x0B /* Not used at this time */
739 740
740/* 741/*
741 * Generic operation (for example: If, While, Store) 742 * Generic operation (for example: If, While, Store)
@@ -1154,4 +1155,9 @@ struct ah_device_id {
1154 char *description; 1155 char *description;
1155}; 1156};
1156 1157
1158struct ah_uuid {
1159 char *description;
1160 char *string;
1161};
1162
1157#endif /* __ACLOCAL_H__ */ 1163#endif /* __ACLOCAL_H__ */
diff --git a/drivers/acpi/acpica/acpredef.h b/drivers/acpi/acpica/acpredef.h
index bd08817cafd8..bd3908d26c4f 100644
--- a/drivers/acpi/acpica/acpredef.h
+++ b/drivers/acpi/acpica/acpredef.h
@@ -105,6 +105,11 @@
105 * count = 0 (optional) 105 * count = 0 (optional)
106 * (Used for _DLM) 106 * (Used for _DLM)
107 * 107 *
108 * ACPI_PTYPE2_UUID_PAIR: Each subpackage is preceded by a UUID Buffer. The UUID
109 * defines the format of the package. Zero-length parent package is
110 * allowed.
111 * (Used for _DSD)
112 *
108 *****************************************************************************/ 113 *****************************************************************************/
109 114
110enum acpi_return_package_types { 115enum acpi_return_package_types {
@@ -117,7 +122,8 @@ enum acpi_return_package_types {
117 ACPI_PTYPE2_FIXED = 7, 122 ACPI_PTYPE2_FIXED = 7,
118 ACPI_PTYPE2_MIN = 8, 123 ACPI_PTYPE2_MIN = 8,
119 ACPI_PTYPE2_REV_FIXED = 9, 124 ACPI_PTYPE2_REV_FIXED = 9,
120 ACPI_PTYPE2_FIX_VAR = 10 125 ACPI_PTYPE2_FIX_VAR = 10,
126 ACPI_PTYPE2_UUID_PAIR = 11
121}; 127};
122 128
123/* Support macros for users of the predefined info table */ 129/* Support macros for users of the predefined info table */
@@ -364,6 +370,9 @@ const union acpi_predefined_info acpi_gbl_predefined_methods[] = {
364 {{"_CBA", METHOD_0ARGS, 370 {{"_CBA", METHOD_0ARGS,
365 METHOD_RETURNS(ACPI_RTYPE_INTEGER)}}, /* See PCI firmware spec 3.0 */ 371 METHOD_RETURNS(ACPI_RTYPE_INTEGER)}}, /* See PCI firmware spec 3.0 */
366 372
373 {{"_CCA", METHOD_0ARGS,
374 METHOD_RETURNS(ACPI_RTYPE_INTEGER)}}, /* ACPI 5.1 */
375
367 {{"_CDM", METHOD_0ARGS, 376 {{"_CDM", METHOD_0ARGS,
368 METHOD_RETURNS(ACPI_RTYPE_INTEGER)}}, 377 METHOD_RETURNS(ACPI_RTYPE_INTEGER)}},
369 378
@@ -436,6 +445,11 @@ const union acpi_predefined_info acpi_gbl_predefined_methods[] = {
436 {{"_DOS", METHOD_1ARGS(ACPI_TYPE_INTEGER), 445 {{"_DOS", METHOD_1ARGS(ACPI_TYPE_INTEGER),
437 METHOD_NO_RETURN_VALUE}}, 446 METHOD_NO_RETURN_VALUE}},
438 447
448 {{"_DSD", METHOD_0ARGS,
449 METHOD_RETURNS(ACPI_RTYPE_PACKAGE)}}, /* Variable-length (Pkgs) each: 1 Buf, 1 Pkg */
450 PACKAGE_INFO(ACPI_PTYPE2_UUID_PAIR, ACPI_RTYPE_BUFFER, 1,
451 ACPI_RTYPE_PACKAGE, 1, 0),
452
439 {{"_DSM", 453 {{"_DSM",
440 METHOD_4ARGS(ACPI_TYPE_BUFFER, ACPI_TYPE_INTEGER, ACPI_TYPE_INTEGER, 454 METHOD_4ARGS(ACPI_TYPE_BUFFER, ACPI_TYPE_INTEGER, ACPI_TYPE_INTEGER,
441 ACPI_TYPE_PACKAGE), 455 ACPI_TYPE_PACKAGE),
diff --git a/drivers/acpi/acpica/acutils.h b/drivers/acpi/acpica/acutils.h
index 1e256c5bda20..486d342e74b6 100644
--- a/drivers/acpi/acpica/acutils.h
+++ b/drivers/acpi/acpica/acutils.h
@@ -95,7 +95,6 @@ extern const char *acpi_gbl_pt_decode[];
95#ifdef ACPI_ASL_COMPILER 95#ifdef ACPI_ASL_COMPILER
96 96
97#include <stdio.h> 97#include <stdio.h>
98extern FILE *acpi_gbl_output_file;
99 98
100#define ACPI_MSG_REDIRECT_BEGIN \ 99#define ACPI_MSG_REDIRECT_BEGIN \
101 FILE *output_file = acpi_gbl_output_file; \ 100 FILE *output_file = acpi_gbl_output_file; \
@@ -195,6 +194,8 @@ char *acpi_ut_get_event_name(u32 event_id);
195 194
196char acpi_ut_hex_to_ascii_char(u64 integer, u32 position); 195char acpi_ut_hex_to_ascii_char(u64 integer, u32 position);
197 196
197u8 acpi_ut_ascii_char_to_hex(int hex_char);
198
198u8 acpi_ut_valid_object_type(acpi_object_type type); 199u8 acpi_ut_valid_object_type(acpi_object_type type);
199 200
200/* 201/*
@@ -211,6 +212,8 @@ void acpi_ut_subsystem_shutdown(void);
211 212
212acpi_size acpi_ut_strlen(const char *string); 213acpi_size acpi_ut_strlen(const char *string);
213 214
215char *acpi_ut_strchr(const char *string, int ch);
216
214char *acpi_ut_strcpy(char *dst_string, const char *src_string); 217char *acpi_ut_strcpy(char *dst_string, const char *src_string);
215 218
216char *acpi_ut_strncpy(char *dst_string, 219char *acpi_ut_strncpy(char *dst_string,
@@ -257,7 +260,7 @@ extern const u8 _acpi_ctype[];
257#define ACPI_IS_XDIGIT(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_XD)) 260#define ACPI_IS_XDIGIT(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_XD))
258#define ACPI_IS_UPPER(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_UP)) 261#define ACPI_IS_UPPER(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_UP))
259#define ACPI_IS_LOWER(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_LO)) 262#define ACPI_IS_LOWER(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_LO))
260#define ACPI_IS_PRINT(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_LO | _ACPI_UP | _ACPI_DI | _ACPI_SP | _ACPI_PU)) 263#define ACPI_IS_PRINT(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_LO | _ACPI_UP | _ACPI_DI | _ACPI_XS | _ACPI_PU))
261#define ACPI_IS_ALPHA(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_LO | _ACPI_UP)) 264#define ACPI_IS_ALPHA(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_LO | _ACPI_UP))
262 265
263#endif /* !ACPI_USE_SYSTEM_CLIBRARY */ 266#endif /* !ACPI_USE_SYSTEM_CLIBRARY */
@@ -352,6 +355,13 @@ acpi_ut_debug_dump_buffer(u8 *buffer, u32 count, u32 display, u32 component_id);
352 355
353void acpi_ut_dump_buffer(u8 *buffer, u32 count, u32 display, u32 offset); 356void acpi_ut_dump_buffer(u8 *buffer, u32 count, u32 display, u32 offset);
354 357
358#ifdef ACPI_APPLICATION
359void
360acpi_ut_dump_buffer_to_file(ACPI_FILE file,
361 u8 *buffer,
362 u32 count, u32 display, u32 base_offset);
363#endif
364
355void acpi_ut_report_error(char *module_name, u32 line_number); 365void acpi_ut_report_error(char *module_name, u32 line_number);
356 366
357void acpi_ut_report_info(char *module_name, u32 line_number); 367void acpi_ut_report_info(char *module_name, u32 line_number);
@@ -394,6 +404,14 @@ acpi_ut_execute_power_methods(struct acpi_namespace_node *device_node,
394 u8 method_count, u8 *out_values); 404 u8 method_count, u8 *out_values);
395 405
396/* 406/*
407 * utfileio - file operations
408 */
409#ifdef ACPI_APPLICATION
410acpi_status
411acpi_ut_read_table_from_file(char *filename, struct acpi_table_header **table);
412#endif
413
414/*
397 * utids - device ID support 415 * utids - device ID support
398 */ 416 */
399acpi_status 417acpi_status
@@ -743,4 +761,30 @@ const struct ah_predefined_name *acpi_ah_match_predefined_name(char *nameseg);
743 761
744const struct ah_device_id *acpi_ah_match_hardware_id(char *hid); 762const struct ah_device_id *acpi_ah_match_hardware_id(char *hid);
745 763
764const char *acpi_ah_match_uuid(u8 *data);
765
766/*
767 * utprint - printf/vprintf output functions
768 */
769const char *acpi_ut_scan_number(const char *string, u64 *number_ptr);
770
771const char *acpi_ut_print_number(char *string, u64 number);
772
773int
774acpi_ut_vsnprintf(char *string,
775 acpi_size size, const char *format, va_list args);
776
777int acpi_ut_snprintf(char *string, acpi_size size, const char *format, ...);
778
779#ifdef ACPI_APPLICATION
780int acpi_ut_file_vprintf(ACPI_FILE file, const char *format, va_list args);
781
782int acpi_ut_file_printf(ACPI_FILE file, const char *format, ...);
783#endif
784
785/*
786 * utuuid -- UUID support functions
787 */
788void acpi_ut_convert_string_to_uuid(char *in_string, u8 *uuid_buffer);
789
746#endif /* _ACUTILS_H */ 790#endif /* _ACUTILS_H */
diff --git a/drivers/acpi/acpica/evgpe.c b/drivers/acpi/acpica/evgpe.c
index 48f70013b488..e4ba4dec86af 100644
--- a/drivers/acpi/acpica/evgpe.c
+++ b/drivers/acpi/acpica/evgpe.c
@@ -698,21 +698,6 @@ acpi_ev_gpe_dispatch(struct acpi_namespace_node *gpe_device,
698 } 698 }
699 699
700 /* 700 /*
701 * If edge-triggered, clear the GPE status bit now. Note that
702 * level-triggered events are cleared after the GPE is serviced.
703 */
704 if ((gpe_event_info->flags & ACPI_GPE_XRUPT_TYPE_MASK) ==
705 ACPI_GPE_EDGE_TRIGGERED) {
706 status = acpi_hw_clear_gpe(gpe_event_info);
707 if (ACPI_FAILURE(status)) {
708 ACPI_EXCEPTION((AE_INFO, status,
709 "Unable to clear GPE %02X",
710 gpe_number));
711 return_UINT32(ACPI_INTERRUPT_NOT_HANDLED);
712 }
713 }
714
715 /*
716 * Always disable the GPE so that it does not keep firing before 701 * Always disable the GPE so that it does not keep firing before
717 * any asynchronous activity completes (either from the execution 702 * any asynchronous activity completes (either from the execution
718 * of a GPE method or an asynchronous GPE handler.) 703 * of a GPE method or an asynchronous GPE handler.)
@@ -729,6 +714,23 @@ acpi_ev_gpe_dispatch(struct acpi_namespace_node *gpe_device,
729 } 714 }
730 715
731 /* 716 /*
717 * If edge-triggered, clear the GPE status bit now. Note that
718 * level-triggered events are cleared after the GPE is serviced.
719 */
720 if ((gpe_event_info->flags & ACPI_GPE_XRUPT_TYPE_MASK) ==
721 ACPI_GPE_EDGE_TRIGGERED) {
722 status = acpi_hw_clear_gpe(gpe_event_info);
723 if (ACPI_FAILURE(status)) {
724 ACPI_EXCEPTION((AE_INFO, status,
725 "Unable to clear GPE %02X",
726 gpe_number));
727 (void)acpi_hw_low_set_gpe(gpe_event_info,
728 ACPI_GPE_CONDITIONAL_ENABLE);
729 return_UINT32(ACPI_INTERRUPT_NOT_HANDLED);
730 }
731 }
732
733 /*
732 * Dispatch the GPE to either an installed handler or the control 734 * Dispatch the GPE to either an installed handler or the control
733 * method associated with this GPE (_Lxx or _Exx). If a handler 735 * method associated with this GPE (_Lxx or _Exx). If a handler
734 * exists, we invoke it and do not attempt to run the method. 736 * exists, we invoke it and do not attempt to run the method.
diff --git a/drivers/acpi/acpica/evxfgpe.c b/drivers/acpi/acpica/evxfgpe.c
index cb534faf5369..0cf159cc6e6d 100644
--- a/drivers/acpi/acpica/evxfgpe.c
+++ b/drivers/acpi/acpica/evxfgpe.c
@@ -126,11 +126,19 @@ acpi_status acpi_enable_gpe(acpi_handle gpe_device, u32 gpe_number)
126 126
127 flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock); 127 flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
128 128
129 /* Ensure that we have a valid GPE number */ 129 /*
130 130 * Ensure that we have a valid GPE number and that there is some way
131 * of handling the GPE (handler or a GPE method). In other words, we
132 * won't allow a valid GPE to be enabled if there is no way to handle it.
133 */
131 gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number); 134 gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number);
132 if (gpe_event_info) { 135 if (gpe_event_info) {
133 status = acpi_ev_add_gpe_reference(gpe_event_info); 136 if ((gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) !=
137 ACPI_GPE_DISPATCH_NONE) {
138 status = acpi_ev_add_gpe_reference(gpe_event_info);
139 } else {
140 status = AE_NO_HANDLER;
141 }
134 } 142 }
135 143
136 acpi_os_release_lock(acpi_gbl_gpe_lock, flags); 144 acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
@@ -179,6 +187,53 @@ ACPI_EXPORT_SYMBOL(acpi_disable_gpe)
179 187
180/******************************************************************************* 188/*******************************************************************************
181 * 189 *
190 * FUNCTION: acpi_mark_gpe_for_wake
191 *
192 * PARAMETERS: gpe_device - Parent GPE Device. NULL for GPE0/GPE1
193 * gpe_number - GPE level within the GPE block
194 *
195 * RETURN: Status
196 *
197 * DESCRIPTION: Mark a GPE as having the ability to wake the system. Simply
198 * sets the ACPI_GPE_CAN_WAKE flag.
199 *
200 * Some potential callers of acpi_setup_gpe_for_wake may know in advance that
201 * there won't be any notify handlers installed for device wake notifications
202 * from the given GPE (one example is a button GPE in Linux). For these cases,
203 * acpi_mark_gpe_for_wake should be used instead of acpi_setup_gpe_for_wake.
204 * This will set the ACPI_GPE_CAN_WAKE flag for the GPE without trying to
205 * setup implicit wake notification for it (since there's no handler method).
206 *
207 ******************************************************************************/
208acpi_status acpi_mark_gpe_for_wake(acpi_handle gpe_device, u32 gpe_number)
209{
210 struct acpi_gpe_event_info *gpe_event_info;
211 acpi_status status = AE_BAD_PARAMETER;
212 acpi_cpu_flags flags;
213
214 ACPI_FUNCTION_TRACE(acpi_mark_gpe_for_wake);
215
216 flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
217
218 /* Ensure that we have a valid GPE number */
219
220 gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number);
221 if (gpe_event_info) {
222
223 /* Mark the GPE as a possible wake event */
224
225 gpe_event_info->flags |= ACPI_GPE_CAN_WAKE;
226 status = AE_OK;
227 }
228
229 acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
230 return_ACPI_STATUS(status);
231}
232
233ACPI_EXPORT_SYMBOL(acpi_mark_gpe_for_wake)
234
235/*******************************************************************************
236 *
182 * FUNCTION: acpi_setup_gpe_for_wake 237 * FUNCTION: acpi_setup_gpe_for_wake
183 * 238 *
184 * PARAMETERS: wake_device - Device associated with the GPE (via _PRW) 239 * PARAMETERS: wake_device - Device associated with the GPE (via _PRW)
diff --git a/drivers/acpi/acpica/exdebug.c b/drivers/acpi/acpica/exdebug.c
index 4cfc3d3b5c97..6fbfad47518c 100644
--- a/drivers/acpi/acpica/exdebug.c
+++ b/drivers/acpi/acpica/exdebug.c
@@ -75,6 +75,7 @@ acpi_ex_do_debug_object(union acpi_operand_object *source_desc,
75 u32 level, u32 index) 75 u32 level, u32 index)
76{ 76{
77 u32 i; 77 u32 i;
78 u32 timer;
78 79
79 ACPI_FUNCTION_TRACE_PTR(ex_do_debug_object, source_desc); 80 ACPI_FUNCTION_TRACE_PTR(ex_do_debug_object, source_desc);
80 81
@@ -86,11 +87,19 @@ acpi_ex_do_debug_object(union acpi_operand_object *source_desc,
86 } 87 }
87 88
88 /* 89 /*
90 * We will emit the current timer value (in microseconds) with each
91 * debug output. Only need the lower 26 bits. This allows for 67
92 * million microseconds or 67 seconds before rollover.
93 */
94 timer = ((u32)acpi_os_get_timer() / 10); /* (100 nanoseconds to microseconds) */
95 timer &= 0x03FFFFFF;
96
97 /*
89 * Print line header as long as we are not in the middle of an 98 * Print line header as long as we are not in the middle of an
90 * object display 99 * object display
91 */ 100 */
92 if (!((level > 0) && index == 0)) { 101 if (!((level > 0) && index == 0)) {
93 acpi_os_printf("[ACPI Debug] %*s", level, " "); 102 acpi_os_printf("[ACPI Debug %.8u] %*s", timer, level, " ");
94 } 103 }
95 104
96 /* Display the index for package output only */ 105 /* Display the index for package output only */
diff --git a/drivers/acpi/acpica/exdump.c b/drivers/acpi/acpica/exdump.c
index 925202acc3e4..0f23c3f2678e 100644
--- a/drivers/acpi/acpica/exdump.c
+++ b/drivers/acpi/acpica/exdump.c
@@ -494,7 +494,7 @@ acpi_ex_dump_object(union acpi_operand_object *obj_desc,
494 } 494 }
495 } 495 }
496 496
497 acpi_os_printf("\n", next); 497 acpi_os_printf("\n");
498 break; 498 break;
499 499
500 case ACPI_EXD_HDLR_LIST: 500 case ACPI_EXD_HDLR_LIST:
@@ -528,7 +528,7 @@ acpi_ex_dump_object(union acpi_operand_object *obj_desc,
528 } 528 }
529 } 529 }
530 530
531 acpi_os_printf("\n", next); 531 acpi_os_printf("\n");
532 break; 532 break;
533 533
534 case ACPI_EXD_RGN_LIST: 534 case ACPI_EXD_RGN_LIST:
@@ -562,7 +562,7 @@ acpi_ex_dump_object(union acpi_operand_object *obj_desc,
562 } 562 }
563 } 563 }
564 564
565 acpi_os_printf("\n", next); 565 acpi_os_printf("\n");
566 break; 566 break;
567 567
568 case ACPI_EXD_NODE: 568 case ACPI_EXD_NODE:
diff --git a/drivers/acpi/acpica/exfield.c b/drivers/acpi/acpica/exfield.c
index 12878e1982f7..6907ce0c704c 100644
--- a/drivers/acpi/acpica/exfield.c
+++ b/drivers/acpi/acpica/exfield.c
@@ -56,7 +56,7 @@ acpi_ex_get_serial_access_length(u32 accessor_type, u32 access_length);
56 56
57/******************************************************************************* 57/*******************************************************************************
58 * 58 *
59 * FUNCTION: acpi_get_serial_access_bytes 59 * FUNCTION: acpi_ex_get_serial_access_length
60 * 60 *
61 * PARAMETERS: accessor_type - The type of the protocol indicated by region 61 * PARAMETERS: accessor_type - The type of the protocol indicated by region
62 * field access attributes 62 * field access attributes
@@ -103,7 +103,7 @@ acpi_ex_get_serial_access_length(u32 accessor_type, u32 access_length)
103 case AML_FIELD_ATTRIB_BLOCK_CALL: 103 case AML_FIELD_ATTRIB_BLOCK_CALL:
104 default: 104 default:
105 105
106 length = ACPI_GSBUS_BUFFER_SIZE; 106 length = ACPI_GSBUS_BUFFER_SIZE - 2;
107 break; 107 break;
108 } 108 }
109 109
@@ -186,12 +186,11 @@ acpi_ex_read_data_from_field(struct acpi_walk_state * walk_state,
186 access_length); 186 access_length);
187 187
188 /* 188 /*
189 * Add additional 2 bytes for modeled generic_serial_bus data buffer: 189 * Add additional 2 bytes for the generic_serial_bus data buffer:
190 * typedef struct { 190 *
191 * BYTEStatus; // Byte 0 of the data buffer 191 * Status; (Byte 0 of the data buffer)
192 * BYTELength; // Byte 1 of the data buffer 192 * Length; (Byte 1 of the data buffer)
193 * BYTE[x-1]Data; // Bytes 2-x of the arbitrary length data buffer, 193 * Data[x-1]; (Bytes 2-x of the arbitrary length data buffer)
194 * }
195 */ 194 */
196 length += 2; 195 length += 2;
197 function = ACPI_READ | (accessor_type << 16); 196 function = ACPI_READ | (accessor_type << 16);
@@ -368,12 +367,11 @@ acpi_ex_write_data_to_field(union acpi_operand_object *source_desc,
368 access_length); 367 access_length);
369 368
370 /* 369 /*
371 * Add additional 2 bytes for modeled generic_serial_bus data buffer: 370 * Add additional 2 bytes for the generic_serial_bus data buffer:
372 * typedef struct { 371 *
373 * BYTEStatus; // Byte 0 of the data buffer 372 * Status; (Byte 0 of the data buffer)
374 * BYTELength; // Byte 1 of the data buffer 373 * Length; (Byte 1 of the data buffer)
375 * BYTE[x-1]Data; // Bytes 2-x of the arbitrary length data buffer, 374 * Data[x-1]; (Bytes 2-x of the arbitrary length data buffer)
376 * }
377 */ 375 */
378 length += 2; 376 length += 2;
379 function = ACPI_WRITE | (accessor_type << 16); 377 function = ACPI_WRITE | (accessor_type << 16);
diff --git a/drivers/acpi/acpica/hwregs.c b/drivers/acpi/acpica/hwregs.c
index e0fd9b4978cd..a4c34d2c556b 100644
--- a/drivers/acpi/acpica/hwregs.c
+++ b/drivers/acpi/acpica/hwregs.c
@@ -278,8 +278,9 @@ acpi_status acpi_hw_clear_acpi_status(void)
278 278
279 acpi_os_release_lock(acpi_gbl_hardware_lock, lock_flags); 279 acpi_os_release_lock(acpi_gbl_hardware_lock, lock_flags);
280 280
281 if (ACPI_FAILURE(status)) 281 if (ACPI_FAILURE(status)) {
282 goto exit; 282 goto exit;
283 }
283 284
284 /* Clear the GPE Bits in all GPE registers in all GPE blocks */ 285 /* Clear the GPE Bits in all GPE registers in all GPE blocks */
285 286
diff --git a/drivers/acpi/acpica/nsobject.c b/drivers/acpi/acpica/nsobject.c
index fe54a8c73b8c..a42ee9d6970d 100644
--- a/drivers/acpi/acpica/nsobject.c
+++ b/drivers/acpi/acpica/nsobject.c
@@ -237,6 +237,16 @@ void acpi_ns_detach_object(struct acpi_namespace_node *node)
237 (node->object->common.type != ACPI_TYPE_LOCAL_DATA)) { 237 (node->object->common.type != ACPI_TYPE_LOCAL_DATA)) {
238 node->object = node->object->common.next_object; 238 node->object = node->object->common.next_object;
239 } 239 }
240
241 /*
242 * Detach the object from any data objects (which are still held by
243 * the namespace node)
244 */
245 if (obj_desc->common.next_object &&
246 ((obj_desc->common.next_object)->common.type ==
247 ACPI_TYPE_LOCAL_DATA)) {
248 obj_desc->common.next_object = NULL;
249 }
240 } 250 }
241 251
242 /* Reset the node type to untyped */ 252 /* Reset the node type to untyped */
diff --git a/drivers/acpi/acpica/utbuffer.c b/drivers/acpi/acpica/utbuffer.c
index 3c1699740653..038ea887f562 100644
--- a/drivers/acpi/acpica/utbuffer.c
+++ b/drivers/acpi/acpica/utbuffer.c
@@ -199,3 +199,131 @@ acpi_ut_debug_dump_buffer(u8 *buffer, u32 count, u32 display, u32 component_id)
199 199
200 acpi_ut_dump_buffer(buffer, count, display, 0); 200 acpi_ut_dump_buffer(buffer, count, display, 0);
201} 201}
202
203#ifdef ACPI_APPLICATION
204/*******************************************************************************
205 *
206 * FUNCTION: acpi_ut_dump_buffer_to_file
207 *
208 * PARAMETERS: file - File descriptor
209 * buffer - Buffer to dump
210 * count - Amount to dump, in bytes
211 * display - BYTE, WORD, DWORD, or QWORD display:
212 * DB_BYTE_DISPLAY
213 * DB_WORD_DISPLAY
214 * DB_DWORD_DISPLAY
215 * DB_QWORD_DISPLAY
216 * base_offset - Beginning buffer offset (display only)
217 *
218 * RETURN: None
219 *
220 * DESCRIPTION: Generic dump buffer in both hex and ascii to a file.
221 *
222 ******************************************************************************/
223
224void
225acpi_ut_dump_buffer_to_file(ACPI_FILE file,
226 u8 *buffer, u32 count, u32 display, u32 base_offset)
227{
228 u32 i = 0;
229 u32 j;
230 u32 temp32;
231 u8 buf_char;
232
233 if (!buffer) {
234 acpi_ut_file_printf(file,
235 "Null Buffer Pointer in DumpBuffer!\n");
236 return;
237 }
238
239 if ((count < 4) || (count & 0x01)) {
240 display = DB_BYTE_DISPLAY;
241 }
242
243 /* Nasty little dump buffer routine! */
244
245 while (i < count) {
246
247 /* Print current offset */
248
249 acpi_ut_file_printf(file, "%6.4X: ", (base_offset + i));
250
251 /* Print 16 hex chars */
252
253 for (j = 0; j < 16;) {
254 if (i + j >= count) {
255
256 /* Dump fill spaces */
257
258 acpi_ut_file_printf(file, "%*s",
259 ((display * 2) + 1), " ");
260 j += display;
261 continue;
262 }
263
264 switch (display) {
265 case DB_BYTE_DISPLAY:
266 default: /* Default is BYTE display */
267
268 acpi_ut_file_printf(file, "%02X ",
269 buffer[(acpi_size) i + j]);
270 break;
271
272 case DB_WORD_DISPLAY:
273
274 ACPI_MOVE_16_TO_32(&temp32,
275 &buffer[(acpi_size) i + j]);
276 acpi_ut_file_printf(file, "%04X ", temp32);
277 break;
278
279 case DB_DWORD_DISPLAY:
280
281 ACPI_MOVE_32_TO_32(&temp32,
282 &buffer[(acpi_size) i + j]);
283 acpi_ut_file_printf(file, "%08X ", temp32);
284 break;
285
286 case DB_QWORD_DISPLAY:
287
288 ACPI_MOVE_32_TO_32(&temp32,
289 &buffer[(acpi_size) i + j]);
290 acpi_ut_file_printf(file, "%08X", temp32);
291
292 ACPI_MOVE_32_TO_32(&temp32,
293 &buffer[(acpi_size) i + j +
294 4]);
295 acpi_ut_file_printf(file, "%08X ", temp32);
296 break;
297 }
298
299 j += display;
300 }
301
302 /*
303 * Print the ASCII equivalent characters but watch out for the bad
304 * unprintable ones (printable chars are 0x20 through 0x7E)
305 */
306 acpi_ut_file_printf(file, " ");
307 for (j = 0; j < 16; j++) {
308 if (i + j >= count) {
309 acpi_ut_file_printf(file, "\n");
310 return;
311 }
312
313 buf_char = buffer[(acpi_size) i + j];
314 if (ACPI_IS_PRINT(buf_char)) {
315 acpi_ut_file_printf(file, "%c", buf_char);
316 } else {
317 acpi_ut_file_printf(file, ".");
318 }
319 }
320
321 /* Done with that line. */
322
323 acpi_ut_file_printf(file, "\n");
324 i += 16;
325 }
326
327 return;
328}
329#endif
diff --git a/drivers/acpi/acpica/utcopy.c b/drivers/acpi/acpica/utcopy.c
index 270c16464dd9..ff601c0f7c7a 100644
--- a/drivers/acpi/acpica/utcopy.c
+++ b/drivers/acpi/acpica/utcopy.c
@@ -1001,5 +1001,11 @@ acpi_ut_copy_iobject_to_iobject(union acpi_operand_object *source_desc,
1001 status = acpi_ut_copy_simple_object(source_desc, *dest_desc); 1001 status = acpi_ut_copy_simple_object(source_desc, *dest_desc);
1002 } 1002 }
1003 1003
1004 /* Delete the allocated object if copy failed */
1005
1006 if (ACPI_FAILURE(status)) {
1007 acpi_ut_remove_reference(*dest_desc);
1008 }
1009
1004 return_ACPI_STATUS(status); 1010 return_ACPI_STATUS(status);
1005} 1011}
diff --git a/drivers/acpi/acpica/utdebug.c b/drivers/acpi/acpica/utdebug.c
index 21a20ac5b1e1..e516254c63b2 100644
--- a/drivers/acpi/acpica/utdebug.c
+++ b/drivers/acpi/acpica/utdebug.c
@@ -561,3 +561,29 @@ acpi_ut_ptr_exit(u32 line_number,
561} 561}
562 562
563#endif 563#endif
564
565#ifdef ACPI_APPLICATION
566/*******************************************************************************
567 *
568 * FUNCTION: acpi_log_error
569 *
570 * PARAMETERS: format - Printf format field
571 * ... - Optional printf arguments
572 *
573 * RETURN: None
574 *
575 * DESCRIPTION: Print error message to the console, used by applications.
576 *
577 ******************************************************************************/
578
579void ACPI_INTERNAL_VAR_XFACE acpi_log_error(const char *format, ...)
580{
581 va_list args;
582
583 va_start(args, format);
584 (void)acpi_ut_file_vprintf(ACPI_FILE_ERR, format, args);
585 va_end(args);
586}
587
588ACPI_EXPORT_SYMBOL(acpi_log_error)
589#endif
diff --git a/drivers/acpi/acpica/utdecode.c b/drivers/acpi/acpica/utdecode.c
index 90ec37c473c6..40e923e675fc 100644
--- a/drivers/acpi/acpica/utdecode.c
+++ b/drivers/acpi/acpica/utdecode.c
@@ -88,33 +88,6 @@ const u8 acpi_gbl_ns_properties[ACPI_NUM_NS_TYPES] = {
88 88
89/******************************************************************************* 89/*******************************************************************************
90 * 90 *
91 * FUNCTION: acpi_ut_hex_to_ascii_char
92 *
93 * PARAMETERS: integer - Contains the hex digit
94 * position - bit position of the digit within the
95 * integer (multiple of 4)
96 *
97 * RETURN: The converted Ascii character
98 *
99 * DESCRIPTION: Convert a hex digit to an Ascii character
100 *
101 ******************************************************************************/
102
103/* Hex to ASCII conversion table */
104
105static const char acpi_gbl_hex_to_ascii[] = {
106 '0', '1', '2', '3', '4', '5', '6', '7',
107 '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'
108};
109
110char acpi_ut_hex_to_ascii_char(u64 integer, u32 position)
111{
112
113 return (acpi_gbl_hex_to_ascii[(integer >> position) & 0xF]);
114}
115
116/*******************************************************************************
117 *
118 * FUNCTION: acpi_ut_get_region_name 91 * FUNCTION: acpi_ut_get_region_name
119 * 92 *
120 * PARAMETERS: Space ID - ID for the region 93 * PARAMETERS: Space ID - ID for the region
@@ -475,7 +448,8 @@ static const char *acpi_gbl_generic_notify[ACPI_NOTIFY_MAX + 1] = {
475 /* 09 */ "Device PLD Check", 448 /* 09 */ "Device PLD Check",
476 /* 0A */ "Reserved", 449 /* 0A */ "Reserved",
477 /* 0B */ "System Locality Update", 450 /* 0B */ "System Locality Update",
478 /* 0C */ "Shutdown Request" 451 /* 0C */ "Shutdown Request",
452 /* 0D */ "System Resource Affinity Update"
479}; 453};
480 454
481static const char *acpi_gbl_device_notify[4] = { 455static const char *acpi_gbl_device_notify[4] = {
@@ -502,7 +476,7 @@ static const char *acpi_gbl_thermal_notify[4] = {
502const char *acpi_ut_get_notify_name(u32 notify_value, acpi_object_type type) 476const char *acpi_ut_get_notify_name(u32 notify_value, acpi_object_type type)
503{ 477{
504 478
505 /* 00 - 0C are common to all object types */ 479 /* 00 - 0D are common to all object types */
506 480
507 if (notify_value <= ACPI_NOTIFY_MAX) { 481 if (notify_value <= ACPI_NOTIFY_MAX) {
508 return (acpi_gbl_generic_notify[notify_value]); 482 return (acpi_gbl_generic_notify[notify_value]);
diff --git a/drivers/acpi/acpica/utfileio.c b/drivers/acpi/acpica/utfileio.c
new file mode 100644
index 000000000000..4e263a8cc6f0
--- /dev/null
+++ b/drivers/acpi/acpica/utfileio.c
@@ -0,0 +1,331 @@
1/*******************************************************************************
2 *
3 * Module Name: utfileio - simple file I/O routines
4 *
5 ******************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2014, 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 "actables.h"
47#include "acapps.h"
48
49#ifdef ACPI_ASL_COMPILER
50#include "aslcompiler.h"
51#endif
52
53#define _COMPONENT ACPI_CA_DEBUGGER
54ACPI_MODULE_NAME("utfileio")
55
56#ifdef ACPI_APPLICATION
57/* Local prototypes */
58static acpi_status
59acpi_ut_check_text_mode_corruption(u8 *table,
60 u32 table_length, u32 file_length);
61
62static acpi_status
63acpi_ut_read_table(FILE * fp,
64 struct acpi_table_header **table, u32 *table_length);
65
66/*******************************************************************************
67 *
68 * FUNCTION: acpi_ut_check_text_mode_corruption
69 *
70 * PARAMETERS: table - Table buffer
71 * table_length - Length of table from the table header
72 * file_length - Length of the file that contains the table
73 *
74 * RETURN: Status
75 *
76 * DESCRIPTION: Check table for text mode file corruption where all linefeed
77 * characters (LF) have been replaced by carriage return linefeed
78 * pairs (CR/LF).
79 *
80 ******************************************************************************/
81
82static acpi_status
83acpi_ut_check_text_mode_corruption(u8 *table, u32 table_length, u32 file_length)
84{
85 u32 i;
86 u32 pairs = 0;
87
88 if (table_length != file_length) {
89 ACPI_WARNING((AE_INFO,
90 "File length (0x%X) is not the same as the table length (0x%X)",
91 file_length, table_length));
92 }
93
94 /* Scan entire table to determine if each LF has been prefixed with a CR */
95
96 for (i = 1; i < file_length; i++) {
97 if (table[i] == 0x0A) {
98 if (table[i - 1] != 0x0D) {
99
100 /* The LF does not have a preceding CR, table not corrupted */
101
102 return (AE_OK);
103 } else {
104 /* Found a CR/LF pair */
105
106 pairs++;
107 }
108 i++;
109 }
110 }
111
112 if (!pairs) {
113 return (AE_OK);
114 }
115
116 /*
117 * Entire table scanned, each CR is part of a CR/LF pair --
118 * meaning that the table was treated as a text file somewhere.
119 *
120 * NOTE: We can't "fix" the table, because any existing CR/LF pairs in the
121 * original table are left untouched by the text conversion process --
122 * meaning that we cannot simply replace CR/LF pairs with LFs.
123 */
124 acpi_os_printf("Table has been corrupted by text mode conversion\n");
125 acpi_os_printf("All LFs (%u) were changed to CR/LF pairs\n", pairs);
126 acpi_os_printf("Table cannot be repaired!\n");
127 return (AE_BAD_VALUE);
128}
129
130/*******************************************************************************
131 *
132 * FUNCTION: acpi_ut_read_table
133 *
134 * PARAMETERS: fp - File that contains table
135 * table - Return value, buffer with table
136 * table_length - Return value, length of table
137 *
138 * RETURN: Status
139 *
140 * DESCRIPTION: Load the DSDT from the file pointer
141 *
142 ******************************************************************************/
143
144static acpi_status
145acpi_ut_read_table(FILE * fp,
146 struct acpi_table_header **table, u32 *table_length)
147{
148 struct acpi_table_header table_header;
149 u32 actual;
150 acpi_status status;
151 u32 file_size;
152 u8 standard_header = TRUE;
153 s32 count;
154
155 /* Get the file size */
156
157 file_size = cm_get_file_size(fp);
158 if (file_size == ACPI_UINT32_MAX) {
159 return (AE_ERROR);
160 }
161
162 if (file_size < 4) {
163 return (AE_BAD_HEADER);
164 }
165
166 /* Read the signature */
167
168 fseek(fp, 0, SEEK_SET);
169
170 count = fread(&table_header, 1, sizeof(struct acpi_table_header), fp);
171 if (count != sizeof(struct acpi_table_header)) {
172 acpi_os_printf("Could not read the table header\n");
173 return (AE_BAD_HEADER);
174 }
175
176 /* The RSDP table does not have standard ACPI header */
177
178 if (ACPI_VALIDATE_RSDP_SIG(table_header.signature)) {
179 *table_length = file_size;
180 standard_header = FALSE;
181 } else {
182
183#if 0
184 /* Validate the table header/length */
185
186 status = acpi_tb_validate_table_header(&table_header);
187 if (ACPI_FAILURE(status)) {
188 acpi_os_printf("Table header is invalid!\n");
189 return (status);
190 }
191#endif
192
193 /* File size must be at least as long as the Header-specified length */
194
195 if (table_header.length > file_size) {
196 acpi_os_printf
197 ("TableHeader length [0x%X] greater than the input file size [0x%X]\n",
198 table_header.length, file_size);
199
200#ifdef ACPI_ASL_COMPILER
201 status = fl_check_for_ascii(fp, NULL, FALSE);
202 if (ACPI_SUCCESS(status)) {
203 acpi_os_printf
204 ("File appears to be ASCII only, must be binary\n");
205 }
206#endif
207 return (AE_BAD_HEADER);
208 }
209#ifdef ACPI_OBSOLETE_CODE
210 /* We only support a limited number of table types */
211
212 if (!ACPI_COMPARE_NAME
213 ((char *)table_header.signature, ACPI_SIG_DSDT)
214 && !ACPI_COMPARE_NAME((char *)table_header.signature,
215 ACPI_SIG_PSDT)
216 && !ACPI_COMPARE_NAME((char *)table_header.signature,
217 ACPI_SIG_SSDT)) {
218 acpi_os_printf
219 ("Table signature [%4.4s] is invalid or not supported\n",
220 (char *)table_header.signature);
221 ACPI_DUMP_BUFFER(&table_header,
222 sizeof(struct acpi_table_header));
223 return (AE_ERROR);
224 }
225#endif
226
227 *table_length = table_header.length;
228 }
229
230 /* Allocate a buffer for the table */
231
232 *table = acpi_os_allocate((size_t) file_size);
233 if (!*table) {
234 acpi_os_printf
235 ("Could not allocate memory for ACPI table %4.4s (size=0x%X)\n",
236 table_header.signature, *table_length);
237 return (AE_NO_MEMORY);
238 }
239
240 /* Get the rest of the table */
241
242 fseek(fp, 0, SEEK_SET);
243 actual = fread(*table, 1, (size_t) file_size, fp);
244 if (actual == file_size) {
245 if (standard_header) {
246
247 /* Now validate the checksum */
248
249 status = acpi_tb_verify_checksum((void *)*table,
250 ACPI_CAST_PTR(struct
251 acpi_table_header,
252 *table)->
253 length);
254
255 if (status == AE_BAD_CHECKSUM) {
256 status =
257 acpi_ut_check_text_mode_corruption((u8 *)
258 *table,
259 file_size,
260 (*table)->
261 length);
262 return (status);
263 }
264 }
265 return (AE_OK);
266 }
267
268 if (actual > 0) {
269 acpi_os_printf("Warning - reading table, asked for %X got %X\n",
270 file_size, actual);
271 return (AE_OK);
272 }
273
274 acpi_os_printf("Error - could not read the table file\n");
275 acpi_os_free(*table);
276 *table = NULL;
277 *table_length = 0;
278 return (AE_ERROR);
279}
280
281/*******************************************************************************
282 *
283 * FUNCTION: acpi_ut_read_table_from_file
284 *
285 * PARAMETERS: filename - File where table is located
286 * table - Where a pointer to the table is returned
287 *
288 * RETURN: Status
289 *
290 * DESCRIPTION: Get an ACPI table from a file
291 *
292 ******************************************************************************/
293
294acpi_status
295acpi_ut_read_table_from_file(char *filename, struct acpi_table_header ** table)
296{
297 FILE *file;
298 u32 file_size;
299 u32 table_length;
300 acpi_status status = AE_ERROR;
301
302 /* Open the file, get current size */
303
304 file = fopen(filename, "rb");
305 if (!file) {
306 perror("Could not open input file");
307 return (status);
308 }
309
310 file_size = cm_get_file_size(file);
311 if (file_size == ACPI_UINT32_MAX) {
312 goto exit;
313 }
314
315 /* Get the entire file */
316
317 fprintf(stderr,
318 "Loading Acpi table from file %10s - Length %.8u (%06X)\n",
319 filename, file_size, file_size);
320
321 status = acpi_ut_read_table(file, table, &table_length);
322 if (ACPI_FAILURE(status)) {
323 acpi_os_printf("Could not get table from the file\n");
324 }
325
326exit:
327 fclose(file);
328 return (status);
329}
330
331#endif
diff --git a/drivers/acpi/acpica/utglobal.c b/drivers/acpi/acpica/utglobal.c
index d69be3cb3fae..77ceac715f28 100644
--- a/drivers/acpi/acpica/utglobal.c
+++ b/drivers/acpi/acpica/utglobal.c
@@ -214,152 +214,6 @@ struct acpi_fixed_event_info acpi_gbl_fixed_event_info[ACPI_NUM_FIXED_EVENTS] =
214}; 214};
215#endif /* !ACPI_REDUCED_HARDWARE */ 215#endif /* !ACPI_REDUCED_HARDWARE */
216 216
217/*******************************************************************************
218 *
219 * FUNCTION: acpi_ut_init_globals
220 *
221 * PARAMETERS: None
222 *
223 * RETURN: Status
224 *
225 * DESCRIPTION: Initialize ACPICA globals. All globals that require specific
226 * initialization should be initialized here. This allows for
227 * a warm restart.
228 *
229 ******************************************************************************/
230
231acpi_status acpi_ut_init_globals(void)
232{
233 acpi_status status;
234 u32 i;
235
236 ACPI_FUNCTION_TRACE(ut_init_globals);
237
238 /* Create all memory caches */
239
240 status = acpi_ut_create_caches();
241 if (ACPI_FAILURE(status)) {
242 return_ACPI_STATUS(status);
243 }
244
245 /* Address Range lists */
246
247 for (i = 0; i < ACPI_ADDRESS_RANGE_MAX; i++) {
248 acpi_gbl_address_range_list[i] = NULL;
249 }
250
251 /* Mutex locked flags */
252
253 for (i = 0; i < ACPI_NUM_MUTEX; i++) {
254 acpi_gbl_mutex_info[i].mutex = NULL;
255 acpi_gbl_mutex_info[i].thread_id = ACPI_MUTEX_NOT_ACQUIRED;
256 acpi_gbl_mutex_info[i].use_count = 0;
257 }
258
259 for (i = 0; i < ACPI_NUM_OWNERID_MASKS; i++) {
260 acpi_gbl_owner_id_mask[i] = 0;
261 }
262
263 /* Last owner_ID is never valid */
264
265 acpi_gbl_owner_id_mask[ACPI_NUM_OWNERID_MASKS - 1] = 0x80000000;
266
267 /* Event counters */
268
269 acpi_method_count = 0;
270 acpi_sci_count = 0;
271 acpi_gpe_count = 0;
272
273 for (i = 0; i < ACPI_NUM_FIXED_EVENTS; i++) {
274 acpi_fixed_event_count[i] = 0;
275 }
276
277#if (!ACPI_REDUCED_HARDWARE)
278
279 /* GPE/SCI support */
280
281 acpi_gbl_all_gpes_initialized = FALSE;
282 acpi_gbl_gpe_xrupt_list_head = NULL;
283 acpi_gbl_gpe_fadt_blocks[0] = NULL;
284 acpi_gbl_gpe_fadt_blocks[1] = NULL;
285 acpi_current_gpe_count = 0;
286
287 acpi_gbl_global_event_handler = NULL;
288 acpi_gbl_sci_handler_list = NULL;
289
290#endif /* !ACPI_REDUCED_HARDWARE */
291
292 /* Global handlers */
293
294 acpi_gbl_global_notify[0].handler = NULL;
295 acpi_gbl_global_notify[1].handler = NULL;
296 acpi_gbl_exception_handler = NULL;
297 acpi_gbl_init_handler = NULL;
298 acpi_gbl_table_handler = NULL;
299 acpi_gbl_interface_handler = NULL;
300
301 /* Global Lock support */
302
303 acpi_gbl_global_lock_semaphore = NULL;
304 acpi_gbl_global_lock_mutex = NULL;
305 acpi_gbl_global_lock_acquired = FALSE;
306 acpi_gbl_global_lock_handle = 0;
307 acpi_gbl_global_lock_present = FALSE;
308
309 /* Miscellaneous variables */
310
311 acpi_gbl_DSDT = NULL;
312 acpi_gbl_cm_single_step = FALSE;
313 acpi_gbl_shutdown = FALSE;
314 acpi_gbl_ns_lookup_count = 0;
315 acpi_gbl_ps_find_count = 0;
316 acpi_gbl_acpi_hardware_present = TRUE;
317 acpi_gbl_last_owner_id_index = 0;
318 acpi_gbl_next_owner_id_offset = 0;
319 acpi_gbl_trace_dbg_level = 0;
320 acpi_gbl_trace_dbg_layer = 0;
321 acpi_gbl_debugger_configuration = DEBUGGER_THREADING;
322 acpi_gbl_db_output_flags = ACPI_DB_CONSOLE_OUTPUT;
323 acpi_gbl_osi_mutex = NULL;
324 acpi_gbl_reg_methods_executed = FALSE;
325
326 /* Hardware oriented */
327
328 acpi_gbl_events_initialized = FALSE;
329 acpi_gbl_system_awake_and_running = TRUE;
330
331 /* Namespace */
332
333 acpi_gbl_module_code_list = NULL;
334 acpi_gbl_root_node = NULL;
335 acpi_gbl_root_node_struct.name.integer = ACPI_ROOT_NAME;
336 acpi_gbl_root_node_struct.descriptor_type = ACPI_DESC_TYPE_NAMED;
337 acpi_gbl_root_node_struct.type = ACPI_TYPE_DEVICE;
338 acpi_gbl_root_node_struct.parent = NULL;
339 acpi_gbl_root_node_struct.child = NULL;
340 acpi_gbl_root_node_struct.peer = NULL;
341 acpi_gbl_root_node_struct.object = NULL;
342
343#ifdef ACPI_DISASSEMBLER
344 acpi_gbl_external_list = NULL;
345 acpi_gbl_num_external_methods = 0;
346 acpi_gbl_resolved_external_methods = 0;
347#endif
348
349#ifdef ACPI_DEBUG_OUTPUT
350 acpi_gbl_lowest_stack_pointer = ACPI_CAST_PTR(acpi_size, ACPI_SIZE_MAX);
351#endif
352
353#ifdef ACPI_DBG_TRACK_ALLOCATIONS
354 acpi_gbl_display_final_mem_stats = FALSE;
355 acpi_gbl_disable_mem_tracking = FALSE;
356#endif
357
358 ACPI_DEBUGGER_EXEC(acpi_gbl_db_terminate_threads = FALSE);
359
360 return_ACPI_STATUS(AE_OK);
361}
362
363/* Public globals */ 217/* Public globals */
364 218
365ACPI_EXPORT_SYMBOL(acpi_gbl_FADT) 219ACPI_EXPORT_SYMBOL(acpi_gbl_FADT)
diff --git a/drivers/acpi/acpica/uthex.c b/drivers/acpi/acpica/uthex.c
new file mode 100644
index 000000000000..9afa9441b183
--- /dev/null
+++ b/drivers/acpi/acpica/uthex.c
@@ -0,0 +1,100 @@
1/******************************************************************************
2 *
3 * Module Name: uthex -- Hex/ASCII support functions
4 *
5 *****************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2014, 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
47#define _COMPONENT ACPI_COMPILER
48ACPI_MODULE_NAME("uthex")
49
50/* Hex to ASCII conversion table */
51static char acpi_gbl_hex_to_ascii[] = {
52 '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D',
53 'E', 'F'
54};
55
56/*******************************************************************************
57 *
58 * FUNCTION: acpi_ut_hex_to_ascii_char
59 *
60 * PARAMETERS: integer - Contains the hex digit
61 * position - bit position of the digit within the
62 * integer (multiple of 4)
63 *
64 * RETURN: The converted Ascii character
65 *
66 * DESCRIPTION: Convert a hex digit to an Ascii character
67 *
68 ******************************************************************************/
69
70char acpi_ut_hex_to_ascii_char(u64 integer, u32 position)
71{
72
73 return (acpi_gbl_hex_to_ascii[(integer >> position) & 0xF]);
74}
75
76/*******************************************************************************
77 *
78 * FUNCTION: acpi_ut_hex_char_to_value
79 *
80 * PARAMETERS: ascii_char - Hex character in Ascii
81 *
82 * RETURN: The binary value of the ascii/hex character
83 *
84 * DESCRIPTION: Perform ascii-to-hex translation
85 *
86 ******************************************************************************/
87
88u8 acpi_ut_ascii_char_to_hex(int hex_char)
89{
90
91 if (hex_char <= 0x39) {
92 return ((u8)(hex_char - 0x30));
93 }
94
95 if (hex_char <= 0x46) {
96 return ((u8)(hex_char - 0x37));
97 }
98
99 return ((u8)(hex_char - 0x57));
100}
diff --git a/drivers/acpi/acpica/utinit.c b/drivers/acpi/acpica/utinit.c
index 5f56fc49021e..77120ec9ea86 100644
--- a/drivers/acpi/acpica/utinit.c
+++ b/drivers/acpi/acpica/utinit.c
@@ -102,6 +102,151 @@ static void acpi_ut_free_gpe_lists(void)
102} 102}
103#endif /* !ACPI_REDUCED_HARDWARE */ 103#endif /* !ACPI_REDUCED_HARDWARE */
104 104
105/*******************************************************************************
106 *
107 * FUNCTION: acpi_ut_init_globals
108 *
109 * PARAMETERS: None
110 *
111 * RETURN: Status
112 *
113 * DESCRIPTION: Initialize ACPICA globals. All globals that require specific
114 * initialization should be initialized here. This allows for
115 * a warm restart.
116 *
117 ******************************************************************************/
118
119acpi_status acpi_ut_init_globals(void)
120{
121 acpi_status status;
122 u32 i;
123
124 ACPI_FUNCTION_TRACE(ut_init_globals);
125
126 /* Create all memory caches */
127
128 status = acpi_ut_create_caches();
129 if (ACPI_FAILURE(status)) {
130 return_ACPI_STATUS(status);
131 }
132
133 /* Address Range lists */
134
135 for (i = 0; i < ACPI_ADDRESS_RANGE_MAX; i++) {
136 acpi_gbl_address_range_list[i] = NULL;
137 }
138
139 /* Mutex locked flags */
140
141 for (i = 0; i < ACPI_NUM_MUTEX; i++) {
142 acpi_gbl_mutex_info[i].mutex = NULL;
143 acpi_gbl_mutex_info[i].thread_id = ACPI_MUTEX_NOT_ACQUIRED;
144 acpi_gbl_mutex_info[i].use_count = 0;
145 }
146
147 for (i = 0; i < ACPI_NUM_OWNERID_MASKS; i++) {
148 acpi_gbl_owner_id_mask[i] = 0;
149 }
150
151 /* Last owner_ID is never valid */
152
153 acpi_gbl_owner_id_mask[ACPI_NUM_OWNERID_MASKS - 1] = 0x80000000;
154
155 /* Event counters */
156
157 acpi_method_count = 0;
158 acpi_sci_count = 0;
159 acpi_gpe_count = 0;
160
161 for (i = 0; i < ACPI_NUM_FIXED_EVENTS; i++) {
162 acpi_fixed_event_count[i] = 0;
163 }
164
165#if (!ACPI_REDUCED_HARDWARE)
166
167 /* GPE/SCI support */
168
169 acpi_gbl_all_gpes_initialized = FALSE;
170 acpi_gbl_gpe_xrupt_list_head = NULL;
171 acpi_gbl_gpe_fadt_blocks[0] = NULL;
172 acpi_gbl_gpe_fadt_blocks[1] = NULL;
173 acpi_current_gpe_count = 0;
174
175 acpi_gbl_global_event_handler = NULL;
176 acpi_gbl_sci_handler_list = NULL;
177
178#endif /* !ACPI_REDUCED_HARDWARE */
179
180 /* Global handlers */
181
182 acpi_gbl_global_notify[0].handler = NULL;
183 acpi_gbl_global_notify[1].handler = NULL;
184 acpi_gbl_exception_handler = NULL;
185 acpi_gbl_init_handler = NULL;
186 acpi_gbl_table_handler = NULL;
187 acpi_gbl_interface_handler = NULL;
188
189 /* Global Lock support */
190
191 acpi_gbl_global_lock_semaphore = NULL;
192 acpi_gbl_global_lock_mutex = NULL;
193 acpi_gbl_global_lock_acquired = FALSE;
194 acpi_gbl_global_lock_handle = 0;
195 acpi_gbl_global_lock_present = FALSE;
196
197 /* Miscellaneous variables */
198
199 acpi_gbl_DSDT = NULL;
200 acpi_gbl_cm_single_step = FALSE;
201 acpi_gbl_shutdown = FALSE;
202 acpi_gbl_ns_lookup_count = 0;
203 acpi_gbl_ps_find_count = 0;
204 acpi_gbl_acpi_hardware_present = TRUE;
205 acpi_gbl_last_owner_id_index = 0;
206 acpi_gbl_next_owner_id_offset = 0;
207 acpi_gbl_trace_dbg_level = 0;
208 acpi_gbl_trace_dbg_layer = 0;
209 acpi_gbl_debugger_configuration = DEBUGGER_THREADING;
210 acpi_gbl_osi_mutex = NULL;
211 acpi_gbl_reg_methods_executed = FALSE;
212
213 /* Hardware oriented */
214
215 acpi_gbl_events_initialized = FALSE;
216 acpi_gbl_system_awake_and_running = TRUE;
217
218 /* Namespace */
219
220 acpi_gbl_module_code_list = NULL;
221 acpi_gbl_root_node = NULL;
222 acpi_gbl_root_node_struct.name.integer = ACPI_ROOT_NAME;
223 acpi_gbl_root_node_struct.descriptor_type = ACPI_DESC_TYPE_NAMED;
224 acpi_gbl_root_node_struct.type = ACPI_TYPE_DEVICE;
225 acpi_gbl_root_node_struct.parent = NULL;
226 acpi_gbl_root_node_struct.child = NULL;
227 acpi_gbl_root_node_struct.peer = NULL;
228 acpi_gbl_root_node_struct.object = NULL;
229
230#ifdef ACPI_DISASSEMBLER
231 acpi_gbl_external_list = NULL;
232 acpi_gbl_num_external_methods = 0;
233 acpi_gbl_resolved_external_methods = 0;
234#endif
235
236#ifdef ACPI_DEBUG_OUTPUT
237 acpi_gbl_lowest_stack_pointer = ACPI_CAST_PTR(acpi_size, ACPI_SIZE_MAX);
238#endif
239
240#ifdef ACPI_DBG_TRACK_ALLOCATIONS
241 acpi_gbl_display_final_mem_stats = FALSE;
242 acpi_gbl_disable_mem_tracking = FALSE;
243#endif
244
245 ACPI_DEBUGGER_EXEC(acpi_gbl_db_terminate_threads = FALSE);
246
247 return_ACPI_STATUS(AE_OK);
248}
249
105/****************************************************************************** 250/******************************************************************************
106 * 251 *
107 * FUNCTION: acpi_ut_terminate 252 * FUNCTION: acpi_ut_terminate
diff --git a/drivers/acpi/acpica/utprint.c b/drivers/acpi/acpica/utprint.c
new file mode 100644
index 000000000000..0ce3f5a0dd67
--- /dev/null
+++ b/drivers/acpi/acpica/utprint.c
@@ -0,0 +1,664 @@
1/******************************************************************************
2 *
3 * Module Name: utprint - Formatted printing routines
4 *
5 *****************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2014, 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
47#define _COMPONENT ACPI_UTILITIES
48ACPI_MODULE_NAME("utprint")
49
50#define ACPI_FORMAT_SIGN 0x01
51#define ACPI_FORMAT_SIGN_PLUS 0x02
52#define ACPI_FORMAT_SIGN_PLUS_SPACE 0x04
53#define ACPI_FORMAT_ZERO 0x08
54#define ACPI_FORMAT_LEFT 0x10
55#define ACPI_FORMAT_UPPER 0x20
56#define ACPI_FORMAT_PREFIX 0x40
57/* Local prototypes */
58static acpi_size
59acpi_ut_bound_string_length(const char *string, acpi_size count);
60
61static char *acpi_ut_bound_string_output(char *string, const char *end, char c);
62
63static char *acpi_ut_format_number(char *string,
64 char *end,
65 u64 number,
66 u8 base, s32 width, s32 precision, u8 type);
67
68static char *acpi_ut_put_number(char *string, u64 number, u8 base, u8 upper);
69
70/* Module globals */
71
72static const char acpi_gbl_lower_hex_digits[] = "0123456789abcdef";
73static const char acpi_gbl_upper_hex_digits[] = "0123456789ABCDEF";
74
75/*******************************************************************************
76 *
77 * FUNCTION: acpi_ut_bound_string_length
78 *
79 * PARAMETERS: string - String with boundary
80 * count - Boundary of the string
81 *
82 * RETURN: Length of the string. Less than or equal to Count.
83 *
84 * DESCRIPTION: Calculate the length of a string with boundary.
85 *
86 ******************************************************************************/
87
88static acpi_size
89acpi_ut_bound_string_length(const char *string, acpi_size count)
90{
91 u32 length = 0;
92
93 while (*string && count) {
94 length++;
95 string++;
96 count--;
97 }
98
99 return (length);
100}
101
102/*******************************************************************************
103 *
104 * FUNCTION: acpi_ut_bound_string_output
105 *
106 * PARAMETERS: string - String with boundary
107 * end - Boundary of the string
108 * c - Character to be output to the string
109 *
110 * RETURN: Updated position for next valid character
111 *
112 * DESCRIPTION: Output a character into a string with boundary check.
113 *
114 ******************************************************************************/
115
116static char *acpi_ut_bound_string_output(char *string, const char *end, char c)
117{
118
119 if (string < end) {
120 *string = c;
121 }
122
123 ++string;
124 return (string);
125}
126
127/*******************************************************************************
128 *
129 * FUNCTION: acpi_ut_put_number
130 *
131 * PARAMETERS: string - Buffer to hold reverse-ordered string
132 * number - Integer to be converted
133 * base - Base of the integer
134 * upper - Whether or not using upper cased digits
135 *
136 * RETURN: Updated position for next valid character
137 *
138 * DESCRIPTION: Convert an integer into a string, note that, the string holds a
139 * reversed ordered number without the trailing zero.
140 *
141 ******************************************************************************/
142
143static char *acpi_ut_put_number(char *string, u64 number, u8 base, u8 upper)
144{
145 const char *digits;
146 u64 digit_index;
147 char *pos;
148
149 pos = string;
150 digits = upper ? acpi_gbl_upper_hex_digits : acpi_gbl_lower_hex_digits;
151
152 if (number == 0) {
153 *(pos++) = '0';
154 } else {
155 while (number) {
156 (void)acpi_ut_divide(number, base, &number,
157 &digit_index);
158 *(pos++) = digits[digit_index];
159 }
160 }
161
162 /* *(Pos++) = '0'; */
163 return (pos);
164}
165
166/*******************************************************************************
167 *
168 * FUNCTION: acpi_ut_scan_number
169 *
170 * PARAMETERS: string - String buffer
171 * number_ptr - Where the number is returned
172 *
173 * RETURN: Updated position for next valid character
174 *
175 * DESCRIPTION: Scan a string for a decimal integer.
176 *
177 ******************************************************************************/
178
179const char *acpi_ut_scan_number(const char *string, u64 *number_ptr)
180{
181 u64 number = 0;
182
183 while (ACPI_IS_DIGIT(*string)) {
184 number *= 10;
185 number += *(string++) - '0';
186 }
187
188 *number_ptr = number;
189 return (string);
190}
191
192/*******************************************************************************
193 *
194 * FUNCTION: acpi_ut_print_number
195 *
196 * PARAMETERS: string - String buffer
197 * number - The number to be converted
198 *
199 * RETURN: Updated position for next valid character
200 *
201 * DESCRIPTION: Print a decimal integer into a string.
202 *
203 ******************************************************************************/
204
205const char *acpi_ut_print_number(char *string, u64 number)
206{
207 char ascii_string[20];
208 const char *pos1;
209 char *pos2;
210
211 pos1 = acpi_ut_put_number(ascii_string, number, 10, FALSE);
212 pos2 = string;
213
214 while (pos1 != ascii_string) {
215 *(pos2++) = *(--pos1);
216 }
217
218 *pos2 = 0;
219 return (string);
220}
221
222/*******************************************************************************
223 *
224 * FUNCTION: acpi_ut_format_number
225 *
226 * PARAMETERS: string - String buffer with boundary
227 * end - Boundary of the string
228 * number - The number to be converted
229 * base - Base of the integer
230 * width - Field width
231 * precision - Precision of the integer
232 * type - Special printing flags
233 *
234 * RETURN: Updated position for next valid character
235 *
236 * DESCRIPTION: Print an integer into a string with any base and any precision.
237 *
238 ******************************************************************************/
239
240static char *acpi_ut_format_number(char *string,
241 char *end,
242 u64 number,
243 u8 base, s32 width, s32 precision, u8 type)
244{
245 char *pos;
246 char sign;
247 char zero;
248 u8 need_prefix;
249 u8 upper;
250 s32 i;
251 char reversed_string[66];
252
253 /* Parameter validation */
254
255 if (base < 2 || base > 16) {
256 return (NULL);
257 }
258
259 if (type & ACPI_FORMAT_LEFT) {
260 type &= ~ACPI_FORMAT_ZERO;
261 }
262
263 need_prefix = ((type & ACPI_FORMAT_PREFIX)
264 && base != 10) ? TRUE : FALSE;
265 upper = (type & ACPI_FORMAT_UPPER) ? TRUE : FALSE;
266 zero = (type & ACPI_FORMAT_ZERO) ? '0' : ' ';
267
268 /* Calculate size according to sign and prefix */
269
270 sign = '\0';
271 if (type & ACPI_FORMAT_SIGN) {
272 if ((s64) number < 0) {
273 sign = '-';
274 number = -(s64) number;
275 width--;
276 } else if (type & ACPI_FORMAT_SIGN_PLUS) {
277 sign = '+';
278 width--;
279 } else if (type & ACPI_FORMAT_SIGN_PLUS_SPACE) {
280 sign = ' ';
281 width--;
282 }
283 }
284 if (need_prefix) {
285 width--;
286 if (base == 16) {
287 width--;
288 }
289 }
290
291 /* Generate full string in reverse order */
292
293 pos = acpi_ut_put_number(reversed_string, number, base, upper);
294 i = ACPI_PTR_DIFF(pos, reversed_string);
295
296 /* Printing 100 using %2d gives "100", not "00" */
297
298 if (i > precision) {
299 precision = i;
300 }
301
302 width -= precision;
303
304 /* Output the string */
305
306 if (!(type & (ACPI_FORMAT_ZERO | ACPI_FORMAT_LEFT))) {
307 while (--width >= 0) {
308 string = acpi_ut_bound_string_output(string, end, ' ');
309 }
310 }
311 if (sign) {
312 string = acpi_ut_bound_string_output(string, end, sign);
313 }
314 if (need_prefix) {
315 string = acpi_ut_bound_string_output(string, end, '0');
316 if (base == 16) {
317 string = acpi_ut_bound_string_output(string, end,
318 upper ? 'X' : 'x');
319 }
320 }
321 if (!(type & ACPI_FORMAT_LEFT)) {
322 while (--width >= 0) {
323 string = acpi_ut_bound_string_output(string, end, zero);
324 }
325 }
326
327 while (i <= --precision) {
328 string = acpi_ut_bound_string_output(string, end, '0');
329 }
330 while (--i >= 0) {
331 string = acpi_ut_bound_string_output(string, end,
332 reversed_string[i]);
333 }
334 while (--width >= 0) {
335 string = acpi_ut_bound_string_output(string, end, ' ');
336 }
337
338 return (string);
339}
340
341/*******************************************************************************
342 *
343 * FUNCTION: acpi_ut_vsnprintf
344 *
345 * PARAMETERS: string - String with boundary
346 * size - Boundary of the string
347 * format - Standard printf format
348 * args - Argument list
349 *
350 * RETURN: Number of bytes actually written.
351 *
352 * DESCRIPTION: Formatted output to a string using argument list pointer.
353 *
354 ******************************************************************************/
355
356int
357acpi_ut_vsnprintf(char *string,
358 acpi_size size, const char *format, va_list args)
359{
360 u8 base = 10;
361 u8 type = 0;
362 s32 width = -1;
363 s32 precision = -1;
364 char qualifier = 0;
365 u64 number;
366 char *pos;
367 char *end;
368 char c;
369 const char *s;
370 const void *p;
371 s32 length;
372 int i;
373
374 pos = string;
375 end = string + size;
376
377 for (; *format; ++format) {
378 if (*format != '%') {
379 pos = acpi_ut_bound_string_output(pos, end, *format);
380 continue;
381 }
382
383 /* Process sign */
384
385 do {
386 ++format;
387 if (*format == '#') {
388 type |= ACPI_FORMAT_PREFIX;
389 } else if (*format == '0') {
390 type |= ACPI_FORMAT_ZERO;
391 } else if (*format == '+') {
392 type |= ACPI_FORMAT_SIGN_PLUS;
393 } else if (*format == ' ') {
394 type |= ACPI_FORMAT_SIGN_PLUS_SPACE;
395 } else if (*format == '-') {
396 type |= ACPI_FORMAT_LEFT;
397 } else {
398 break;
399 }
400 } while (1);
401
402 /* Process width */
403
404 width = -1;
405 if (ACPI_IS_DIGIT(*format)) {
406 format = acpi_ut_scan_number(format, &number);
407 width = (s32) number;
408 } else if (*format == '*') {
409 ++format;
410 width = va_arg(args, int);
411 if (width < 0) {
412 width = -width;
413 type |= ACPI_FORMAT_LEFT;
414 }
415 }
416
417 /* Process precision */
418
419 precision = -1;
420 if (*format == '.') {
421 ++format;
422 if (ACPI_IS_DIGIT(*format)) {
423 format = acpi_ut_scan_number(format, &number);
424 precision = (s32) number;
425 } else if (*format == '*') {
426 ++format;
427 precision = va_arg(args, int);
428 }
429 if (precision < 0) {
430 precision = 0;
431 }
432 }
433
434 /* Process qualifier */
435
436 qualifier = -1;
437 if (*format == 'h' || *format == 'l' || *format == 'L') {
438 qualifier = *format;
439 ++format;
440
441 if (qualifier == 'l' && *format == 'l') {
442 qualifier = 'L';
443 ++format;
444 }
445 }
446
447 switch (*format) {
448 case '%':
449
450 pos = acpi_ut_bound_string_output(pos, end, '%');
451 continue;
452
453 case 'c':
454
455 if (!(type & ACPI_FORMAT_LEFT)) {
456 while (--width > 0) {
457 pos =
458 acpi_ut_bound_string_output(pos,
459 end,
460 ' ');
461 }
462 }
463
464 c = (char)va_arg(args, int);
465 pos = acpi_ut_bound_string_output(pos, end, c);
466
467 while (--width > 0) {
468 pos =
469 acpi_ut_bound_string_output(pos, end, ' ');
470 }
471 continue;
472
473 case 's':
474
475 s = va_arg(args, char *);
476 if (!s) {
477 s = "<NULL>";
478 }
479 length = acpi_ut_bound_string_length(s, precision);
480 if (!(type & ACPI_FORMAT_LEFT)) {
481 while (length < width--) {
482 pos =
483 acpi_ut_bound_string_output(pos,
484 end,
485 ' ');
486 }
487 }
488 for (i = 0; i < length; ++i) {
489 pos = acpi_ut_bound_string_output(pos, end, *s);
490 ++s;
491 }
492 while (length < width--) {
493 pos =
494 acpi_ut_bound_string_output(pos, end, ' ');
495 }
496 continue;
497
498 case 'o':
499
500 base = 8;
501 break;
502
503 case 'X':
504
505 type |= ACPI_FORMAT_UPPER;
506
507 case 'x':
508
509 base = 16;
510 break;
511
512 case 'd':
513 case 'i':
514
515 type |= ACPI_FORMAT_SIGN;
516
517 case 'u':
518
519 break;
520
521 case 'p':
522
523 if (width == -1) {
524 width = 2 * sizeof(void *);
525 type |= ACPI_FORMAT_ZERO;
526 }
527
528 p = va_arg(args, void *);
529 pos = acpi_ut_format_number(pos, end,
530 ACPI_TO_INTEGER(p), 16,
531 width, precision, type);
532 continue;
533
534 default:
535
536 pos = acpi_ut_bound_string_output(pos, end, '%');
537 if (*format) {
538 pos =
539 acpi_ut_bound_string_output(pos, end,
540 *format);
541 } else {
542 --format;
543 }
544 continue;
545 }
546
547 if (qualifier == 'L') {
548 number = va_arg(args, u64);
549 if (type & ACPI_FORMAT_SIGN) {
550 number = (s64) number;
551 }
552 } else if (qualifier == 'l') {
553 number = va_arg(args, unsigned long);
554 if (type & ACPI_FORMAT_SIGN) {
555 number = (s32) number;
556 }
557 } else if (qualifier == 'h') {
558 number = (u16)va_arg(args, int);
559 if (type & ACPI_FORMAT_SIGN) {
560 number = (s16) number;
561 }
562 } else {
563 number = va_arg(args, unsigned int);
564 if (type & ACPI_FORMAT_SIGN) {
565 number = (signed int)number;
566 }
567 }
568
569 pos = acpi_ut_format_number(pos, end, number, base,
570 width, precision, type);
571 }
572
573 if (size > 0) {
574 if (pos < end) {
575 *pos = '\0';
576 } else {
577 end[-1] = '\0';
578 }
579 }
580
581 return (ACPI_PTR_DIFF(pos, string));
582}
583
584/*******************************************************************************
585 *
586 * FUNCTION: acpi_ut_snprintf
587 *
588 * PARAMETERS: string - String with boundary
589 * size - Boundary of the string
590 * Format, ... - Standard printf format
591 *
592 * RETURN: Number of bytes actually written.
593 *
594 * DESCRIPTION: Formatted output to a string.
595 *
596 ******************************************************************************/
597
598int acpi_ut_snprintf(char *string, acpi_size size, const char *format, ...)
599{
600 va_list args;
601 int length;
602
603 va_start(args, format);
604 length = acpi_ut_vsnprintf(string, size, format, args);
605 va_end(args);
606
607 return (length);
608}
609
610#ifdef ACPI_APPLICATION
611/*******************************************************************************
612 *
613 * FUNCTION: acpi_ut_file_vprintf
614 *
615 * PARAMETERS: file - File descriptor
616 * format - Standard printf format
617 * args - Argument list
618 *
619 * RETURN: Number of bytes actually written.
620 *
621 * DESCRIPTION: Formatted output to a file using argument list pointer.
622 *
623 ******************************************************************************/
624
625int acpi_ut_file_vprintf(ACPI_FILE file, const char *format, va_list args)
626{
627 acpi_cpu_flags flags;
628 int length;
629
630 flags = acpi_os_acquire_lock(acpi_gbl_print_lock);
631 length = acpi_ut_vsnprintf(acpi_gbl_print_buffer,
632 sizeof(acpi_gbl_print_buffer), format, args);
633
634 (void)acpi_os_write_file(file, acpi_gbl_print_buffer, length, 1);
635 acpi_os_release_lock(acpi_gbl_print_lock, flags);
636
637 return (length);
638}
639
640/*******************************************************************************
641 *
642 * FUNCTION: acpi_ut_file_printf
643 *
644 * PARAMETERS: file - File descriptor
645 * Format, ... - Standard printf format
646 *
647 * RETURN: Number of bytes actually written.
648 *
649 * DESCRIPTION: Formatted output to a file.
650 *
651 ******************************************************************************/
652
653int acpi_ut_file_printf(ACPI_FILE file, const char *format, ...)
654{
655 va_list args;
656 int length;
657
658 va_start(args, format);
659 length = acpi_ut_file_vprintf(file, format, args);
660 va_end(args);
661
662 return (length);
663}
664#endif
diff --git a/drivers/acpi/acpica/utuuid.c b/drivers/acpi/acpica/utuuid.c
new file mode 100644
index 000000000000..4dc33130f134
--- /dev/null
+++ b/drivers/acpi/acpica/utuuid.c
@@ -0,0 +1,96 @@
1/******************************************************************************
2 *
3 * Module Name: utuuid -- UUID support functions
4 *
5 *****************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2014, 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
47#define _COMPONENT ACPI_COMPILER
48ACPI_MODULE_NAME("utuuid")
49
50/*
51 * UUID support functions.
52 *
53 * This table is used to convert an input UUID ascii string to a 16 byte
54 * buffer and the reverse. The table maps a UUID buffer index 0-15 to
55 * the index within the 36-byte UUID string where the associated 2-byte
56 * hex value can be found.
57 *
58 * 36-byte UUID strings are of the form:
59 * aabbccdd-eeff-gghh-iijj-kkllmmnnoopp
60 * Where aa-pp are one byte hex numbers, made up of two hex digits
61 *
62 * Note: This table is basically the inverse of the string-to-offset table
63 * found in the ACPI spec in the description of the to_UUID macro.
64 */
65const u8 acpi_gbl_map_to_uuid_offset[UUID_BUFFER_LENGTH] = {
66 6, 4, 2, 0, 11, 9, 16, 14, 19, 21, 24, 26, 28, 30, 32, 34
67};
68
69/*******************************************************************************
70 *
71 * FUNCTION: acpi_ut_convert_string_to_uuid
72 *
73 * PARAMETERS: in_string - 36-byte formatted UUID string
74 * uuid_buffer - Where the 16-byte UUID buffer is returned
75 *
76 * RETURN: None. Output data is returned in the uuid_buffer
77 *
78 * DESCRIPTION: Convert a 36-byte formatted UUID string to 16-byte UUID buffer
79 *
80 ******************************************************************************/
81
82void acpi_ut_convert_string_to_uuid(char *in_string, u8 *uuid_buffer)
83{
84 u32 i;
85
86 for (i = 0; i < UUID_BUFFER_LENGTH; i++) {
87 uuid_buffer[i] =
88 (acpi_ut_ascii_char_to_hex
89 (in_string[acpi_gbl_map_to_uuid_offset[i]]) << 4);
90
91 uuid_buffer[i] |=
92 acpi_ut_ascii_char_to_hex(in_string
93 [acpi_gbl_map_to_uuid_offset[i] +
94 1]);
95 }
96}
diff --git a/drivers/acpi/apei/apei-internal.h b/drivers/acpi/apei/apei-internal.h
index e5bcd919d4e6..16129c78b489 100644
--- a/drivers/acpi/apei/apei-internal.h
+++ b/drivers/acpi/apei/apei-internal.h
@@ -121,11 +121,11 @@ struct dentry;
121struct dentry *apei_get_debugfs_dir(void); 121struct dentry *apei_get_debugfs_dir(void);
122 122
123#define apei_estatus_for_each_section(estatus, section) \ 123#define apei_estatus_for_each_section(estatus, section) \
124 for (section = (struct acpi_generic_data *)(estatus + 1); \ 124 for (section = (struct acpi_hest_generic_data *)(estatus + 1); \
125 (void *)section - (void *)estatus < estatus->data_length; \ 125 (void *)section - (void *)estatus < estatus->data_length; \
126 section = (void *)(section+1) + section->error_data_length) 126 section = (void *)(section+1) + section->error_data_length)
127 127
128static inline u32 cper_estatus_len(struct acpi_generic_status *estatus) 128static inline u32 cper_estatus_len(struct acpi_hest_generic_status *estatus)
129{ 129{
130 if (estatus->raw_data_length) 130 if (estatus->raw_data_length)
131 return estatus->raw_data_offset + \ 131 return estatus->raw_data_offset + \
@@ -135,9 +135,9 @@ static inline u32 cper_estatus_len(struct acpi_generic_status *estatus)
135} 135}
136 136
137void cper_estatus_print(const char *pfx, 137void cper_estatus_print(const char *pfx,
138 const struct acpi_generic_status *estatus); 138 const struct acpi_hest_generic_status *estatus);
139int cper_estatus_check_header(const struct acpi_generic_status *estatus); 139int cper_estatus_check_header(const struct acpi_hest_generic_status *estatus);
140int cper_estatus_check(const struct acpi_generic_status *estatus); 140int cper_estatus_check(const struct acpi_hest_generic_status *estatus);
141 141
142int apei_osc_setup(void); 142int apei_osc_setup(void);
143#endif 143#endif
diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c
index e05d84e7b06d..fc5f780bb61d 100644
--- a/drivers/acpi/apei/ghes.c
+++ b/drivers/acpi/apei/ghes.c
@@ -74,13 +74,13 @@
74#define GHES_ESTATUS_CACHE_LEN(estatus_len) \ 74#define GHES_ESTATUS_CACHE_LEN(estatus_len) \
75 (sizeof(struct ghes_estatus_cache) + (estatus_len)) 75 (sizeof(struct ghes_estatus_cache) + (estatus_len))
76#define GHES_ESTATUS_FROM_CACHE(estatus_cache) \ 76#define GHES_ESTATUS_FROM_CACHE(estatus_cache) \
77 ((struct acpi_generic_status *) \ 77 ((struct acpi_hest_generic_status *) \
78 ((struct ghes_estatus_cache *)(estatus_cache) + 1)) 78 ((struct ghes_estatus_cache *)(estatus_cache) + 1))
79 79
80#define GHES_ESTATUS_NODE_LEN(estatus_len) \ 80#define GHES_ESTATUS_NODE_LEN(estatus_len) \
81 (sizeof(struct ghes_estatus_node) + (estatus_len)) 81 (sizeof(struct ghes_estatus_node) + (estatus_len))
82#define GHES_ESTATUS_FROM_NODE(estatus_node) \ 82#define GHES_ESTATUS_FROM_NODE(estatus_node) \
83 ((struct acpi_generic_status *) \ 83 ((struct acpi_hest_generic_status *) \
84 ((struct ghes_estatus_node *)(estatus_node) + 1)) 84 ((struct ghes_estatus_node *)(estatus_node) + 1))
85 85
86bool ghes_disable; 86bool ghes_disable;
@@ -388,7 +388,7 @@ static void ghes_clear_estatus(struct ghes *ghes)
388 ghes->flags &= ~GHES_TO_CLEAR; 388 ghes->flags &= ~GHES_TO_CLEAR;
389} 389}
390 390
391static void ghes_handle_memory_failure(struct acpi_generic_data *gdata, int sev) 391static void ghes_handle_memory_failure(struct acpi_hest_generic_data *gdata, int sev)
392{ 392{
393#ifdef CONFIG_ACPI_APEI_MEMORY_FAILURE 393#ifdef CONFIG_ACPI_APEI_MEMORY_FAILURE
394 unsigned long pfn; 394 unsigned long pfn;
@@ -421,10 +421,10 @@ static void ghes_handle_memory_failure(struct acpi_generic_data *gdata, int sev)
421} 421}
422 422
423static void ghes_do_proc(struct ghes *ghes, 423static void ghes_do_proc(struct ghes *ghes,
424 const struct acpi_generic_status *estatus) 424 const struct acpi_hest_generic_status *estatus)
425{ 425{
426 int sev, sec_sev; 426 int sev, sec_sev;
427 struct acpi_generic_data *gdata; 427 struct acpi_hest_generic_data *gdata;
428 428
429 sev = ghes_severity(estatus->error_severity); 429 sev = ghes_severity(estatus->error_severity);
430 apei_estatus_for_each_section(estatus, gdata) { 430 apei_estatus_for_each_section(estatus, gdata) {
@@ -476,7 +476,7 @@ static void ghes_do_proc(struct ghes *ghes,
476 476
477static void __ghes_print_estatus(const char *pfx, 477static void __ghes_print_estatus(const char *pfx,
478 const struct acpi_hest_generic *generic, 478 const struct acpi_hest_generic *generic,
479 const struct acpi_generic_status *estatus) 479 const struct acpi_hest_generic_status *estatus)
480{ 480{
481 static atomic_t seqno; 481 static atomic_t seqno;
482 unsigned int curr_seqno; 482 unsigned int curr_seqno;
@@ -498,7 +498,7 @@ static void __ghes_print_estatus(const char *pfx,
498 498
499static int ghes_print_estatus(const char *pfx, 499static int ghes_print_estatus(const char *pfx,
500 const struct acpi_hest_generic *generic, 500 const struct acpi_hest_generic *generic,
501 const struct acpi_generic_status *estatus) 501 const struct acpi_hest_generic_status *estatus)
502{ 502{
503 /* Not more than 2 messages every 5 seconds */ 503 /* Not more than 2 messages every 5 seconds */
504 static DEFINE_RATELIMIT_STATE(ratelimit_corrected, 5*HZ, 2); 504 static DEFINE_RATELIMIT_STATE(ratelimit_corrected, 5*HZ, 2);
@@ -520,13 +520,13 @@ static int ghes_print_estatus(const char *pfx,
520 * GHES error status reporting throttle, to report more kinds of 520 * GHES error status reporting throttle, to report more kinds of
521 * errors, instead of just most frequently occurred errors. 521 * errors, instead of just most frequently occurred errors.
522 */ 522 */
523static int ghes_estatus_cached(struct acpi_generic_status *estatus) 523static int ghes_estatus_cached(struct acpi_hest_generic_status *estatus)
524{ 524{
525 u32 len; 525 u32 len;
526 int i, cached = 0; 526 int i, cached = 0;
527 unsigned long long now; 527 unsigned long long now;
528 struct ghes_estatus_cache *cache; 528 struct ghes_estatus_cache *cache;
529 struct acpi_generic_status *cache_estatus; 529 struct acpi_hest_generic_status *cache_estatus;
530 530
531 len = cper_estatus_len(estatus); 531 len = cper_estatus_len(estatus);
532 rcu_read_lock(); 532 rcu_read_lock();
@@ -551,12 +551,12 @@ static int ghes_estatus_cached(struct acpi_generic_status *estatus)
551 551
552static struct ghes_estatus_cache *ghes_estatus_cache_alloc( 552static struct ghes_estatus_cache *ghes_estatus_cache_alloc(
553 struct acpi_hest_generic *generic, 553 struct acpi_hest_generic *generic,
554 struct acpi_generic_status *estatus) 554 struct acpi_hest_generic_status *estatus)
555{ 555{
556 int alloced; 556 int alloced;
557 u32 len, cache_len; 557 u32 len, cache_len;
558 struct ghes_estatus_cache *cache; 558 struct ghes_estatus_cache *cache;
559 struct acpi_generic_status *cache_estatus; 559 struct acpi_hest_generic_status *cache_estatus;
560 560
561 alloced = atomic_add_return(1, &ghes_estatus_cache_alloced); 561 alloced = atomic_add_return(1, &ghes_estatus_cache_alloced);
562 if (alloced > GHES_ESTATUS_CACHE_ALLOCED_MAX) { 562 if (alloced > GHES_ESTATUS_CACHE_ALLOCED_MAX) {
@@ -599,7 +599,7 @@ static void ghes_estatus_cache_rcu_free(struct rcu_head *head)
599 599
600static void ghes_estatus_cache_add( 600static void ghes_estatus_cache_add(
601 struct acpi_hest_generic *generic, 601 struct acpi_hest_generic *generic,
602 struct acpi_generic_status *estatus) 602 struct acpi_hest_generic_status *estatus)
603{ 603{
604 int i, slot = -1, count; 604 int i, slot = -1, count;
605 unsigned long long now, duration, period, max_period = 0; 605 unsigned long long now, duration, period, max_period = 0;
@@ -757,7 +757,7 @@ static void ghes_proc_in_irq(struct irq_work *irq_work)
757 struct llist_node *llnode, *next; 757 struct llist_node *llnode, *next;
758 struct ghes_estatus_node *estatus_node; 758 struct ghes_estatus_node *estatus_node;
759 struct acpi_hest_generic *generic; 759 struct acpi_hest_generic *generic;
760 struct acpi_generic_status *estatus; 760 struct acpi_hest_generic_status *estatus;
761 u32 len, node_len; 761 u32 len, node_len;
762 762
763 llnode = llist_del_all(&ghes_estatus_llist); 763 llnode = llist_del_all(&ghes_estatus_llist);
@@ -790,7 +790,7 @@ static void ghes_print_queued_estatus(void)
790 struct llist_node *llnode; 790 struct llist_node *llnode;
791 struct ghes_estatus_node *estatus_node; 791 struct ghes_estatus_node *estatus_node;
792 struct acpi_hest_generic *generic; 792 struct acpi_hest_generic *generic;
793 struct acpi_generic_status *estatus; 793 struct acpi_hest_generic_status *estatus;
794 u32 len, node_len; 794 u32 len, node_len;
795 795
796 llnode = llist_del_all(&ghes_estatus_llist); 796 llnode = llist_del_all(&ghes_estatus_llist);
@@ -849,7 +849,7 @@ static int ghes_notify_nmi(unsigned int cmd, struct pt_regs *regs)
849#ifdef CONFIG_ARCH_HAVE_NMI_SAFE_CMPXCHG 849#ifdef CONFIG_ARCH_HAVE_NMI_SAFE_CMPXCHG
850 u32 len, node_len; 850 u32 len, node_len;
851 struct ghes_estatus_node *estatus_node; 851 struct ghes_estatus_node *estatus_node;
852 struct acpi_generic_status *estatus; 852 struct acpi_hest_generic_status *estatus;
853#endif 853#endif
854 if (!(ghes->flags & GHES_TO_CLEAR)) 854 if (!(ghes->flags & GHES_TO_CLEAR))
855 continue; 855 continue;
@@ -991,7 +991,7 @@ static int ghes_probe(struct platform_device *ghes_dev)
991 991
992 rc = -EIO; 992 rc = -EIO;
993 if (generic->error_block_length < 993 if (generic->error_block_length <
994 sizeof(struct acpi_generic_status)) { 994 sizeof(struct acpi_hest_generic_status)) {
995 pr_warning(FW_BUG GHES_PFX "Invalid error block length: %u for generic hardware error source: %d\n", 995 pr_warning(FW_BUG GHES_PFX "Invalid error block length: %u for generic hardware error source: %d\n",
996 generic->error_block_length, 996 generic->error_block_length,
997 generic->header.source_id); 997 generic->header.source_id);
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index 130f513e08c9..48bcf38a0ea8 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -35,7 +35,6 @@
35#include <linux/delay.h> 35#include <linux/delay.h>
36#include <linux/slab.h> 36#include <linux/slab.h>
37#include <linux/suspend.h> 37#include <linux/suspend.h>
38#include <linux/delay.h>
39#include <asm/unaligned.h> 38#include <asm/unaligned.h>
40 39
41#ifdef CONFIG_ACPI_PROCFS_POWER 40#ifdef CONFIG_ACPI_PROCFS_POWER
diff --git a/drivers/acpi/blacklist.c b/drivers/acpi/blacklist.c
index 3d8413d02a97..36eb42e3b0bb 100644
--- a/drivers/acpi/blacklist.c
+++ b/drivers/acpi/blacklist.c
@@ -247,75 +247,11 @@ static struct dmi_system_id acpi_osi_dmi_table[] __initdata = {
247 }, 247 },
248 248
249 /* 249 /*
250 * The following machines have broken backlight support when reporting 250 * These machines will power on immediately after shutdown when
251 * the Windows 2012 OSI, so disable it until their support is fixed. 251 * reporting the Windows 2012 OSI.
252 */ 252 */
253 { 253 {
254 .callback = dmi_disable_osi_win8, 254 .callback = dmi_disable_osi_win8,
255 .ident = "ASUS Zenbook Prime UX31A",
256 .matches = {
257 DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
258 DMI_MATCH(DMI_PRODUCT_NAME, "UX31A"),
259 },
260 },
261 {
262 .callback = dmi_disable_osi_win8,
263 .ident = "ThinkPad Edge E530",
264 .matches = {
265 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
266 DMI_MATCH(DMI_PRODUCT_VERSION, "3259A2G"),
267 },
268 },
269 {
270 .callback = dmi_disable_osi_win8,
271 .ident = "ThinkPad Edge E530",
272 .matches = {
273 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
274 DMI_MATCH(DMI_PRODUCT_VERSION, "3259CTO"),
275 },
276 },
277 {
278 .callback = dmi_disable_osi_win8,
279 .ident = "ThinkPad Edge E530",
280 .matches = {
281 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
282 DMI_MATCH(DMI_PRODUCT_VERSION, "3259HJG"),
283 },
284 },
285 {
286 .callback = dmi_disable_osi_win8,
287 .ident = "Acer Aspire V5-573G",
288 .matches = {
289 DMI_MATCH(DMI_SYS_VENDOR, "Acer Aspire"),
290 DMI_MATCH(DMI_PRODUCT_VERSION, "V5-573G/Dazzle_HW"),
291 },
292 },
293 {
294 .callback = dmi_disable_osi_win8,
295 .ident = "Acer Aspire V5-572G",
296 .matches = {
297 DMI_MATCH(DMI_SYS_VENDOR, "Acer Aspire"),
298 DMI_MATCH(DMI_PRODUCT_VERSION, "V5-572G/Dazzle_CX"),
299 },
300 },
301 {
302 .callback = dmi_disable_osi_win8,
303 .ident = "ThinkPad T431s",
304 .matches = {
305 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
306 DMI_MATCH(DMI_PRODUCT_VERSION, "20AACTO1WW"),
307 },
308 },
309 {
310 .callback = dmi_disable_osi_win8,
311 .ident = "ThinkPad T430",
312 .matches = {
313 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
314 DMI_MATCH(DMI_PRODUCT_VERSION, "2349D15"),
315 },
316 },
317 {
318 .callback = dmi_disable_osi_win8,
319 .ident = "Dell Inspiron 7737", 255 .ident = "Dell Inspiron 7737",
320 .matches = { 256 .matches = {
321 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), 257 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
index c5bc8cfe09fa..8581f5b84f48 100644
--- a/drivers/acpi/bus.c
+++ b/drivers/acpi/bus.c
@@ -477,9 +477,6 @@ static int __init acpi_bus_init_irq(void)
477 return 0; 477 return 0;
478} 478}
479 479
480u8 acpi_gbl_permanent_mmap;
481
482
483void __init acpi_early_init(void) 480void __init acpi_early_init(void)
484{ 481{
485 acpi_status status; 482 acpi_status status;
diff --git a/drivers/acpi/button.c b/drivers/acpi/button.c
index db35594d4df7..6d5d1832a588 100644
--- a/drivers/acpi/button.c
+++ b/drivers/acpi/button.c
@@ -79,11 +79,13 @@ static int acpi_button_remove(struct acpi_device *device);
79static void acpi_button_notify(struct acpi_device *device, u32 event); 79static void acpi_button_notify(struct acpi_device *device, u32 event);
80 80
81#ifdef CONFIG_PM_SLEEP 81#ifdef CONFIG_PM_SLEEP
82static int acpi_button_suspend(struct device *dev);
82static int acpi_button_resume(struct device *dev); 83static int acpi_button_resume(struct device *dev);
83#else 84#else
85#define acpi_button_suspend NULL
84#define acpi_button_resume NULL 86#define acpi_button_resume NULL
85#endif 87#endif
86static SIMPLE_DEV_PM_OPS(acpi_button_pm, NULL, acpi_button_resume); 88static SIMPLE_DEV_PM_OPS(acpi_button_pm, acpi_button_suspend, acpi_button_resume);
87 89
88static struct acpi_driver acpi_button_driver = { 90static struct acpi_driver acpi_button_driver = {
89 .name = "button", 91 .name = "button",
@@ -102,6 +104,7 @@ struct acpi_button {
102 struct input_dev *input; 104 struct input_dev *input;
103 char phys[32]; /* for input device */ 105 char phys[32]; /* for input device */
104 unsigned long pushed; 106 unsigned long pushed;
107 bool suspended;
105}; 108};
106 109
107static BLOCKING_NOTIFIER_HEAD(acpi_lid_notifier); 110static BLOCKING_NOTIFIER_HEAD(acpi_lid_notifier);
@@ -293,15 +296,19 @@ static void acpi_button_notify(struct acpi_device *device, u32 event)
293 if (button->type == ACPI_BUTTON_TYPE_LID) { 296 if (button->type == ACPI_BUTTON_TYPE_LID) {
294 acpi_lid_send_state(device); 297 acpi_lid_send_state(device);
295 } else { 298 } else {
296 int keycode = test_bit(KEY_SLEEP, input->keybit) ? 299 int keycode;
297 KEY_SLEEP : KEY_POWER; 300
301 pm_wakeup_event(&device->dev, 0);
302 if (button->suspended)
303 break;
298 304
305 keycode = test_bit(KEY_SLEEP, input->keybit) ?
306 KEY_SLEEP : KEY_POWER;
299 input_report_key(input, keycode, 1); 307 input_report_key(input, keycode, 1);
300 input_sync(input); 308 input_sync(input);
301 input_report_key(input, keycode, 0); 309 input_report_key(input, keycode, 0);
302 input_sync(input); 310 input_sync(input);
303 311
304 pm_wakeup_event(&device->dev, 0);
305 acpi_bus_generate_netlink_event( 312 acpi_bus_generate_netlink_event(
306 device->pnp.device_class, 313 device->pnp.device_class,
307 dev_name(&device->dev), 314 dev_name(&device->dev),
@@ -316,11 +323,21 @@ static void acpi_button_notify(struct acpi_device *device, u32 event)
316} 323}
317 324
318#ifdef CONFIG_PM_SLEEP 325#ifdef CONFIG_PM_SLEEP
326static int acpi_button_suspend(struct device *dev)
327{
328 struct acpi_device *device = to_acpi_device(dev);
329 struct acpi_button *button = acpi_driver_data(device);
330
331 button->suspended = true;
332 return 0;
333}
334
319static int acpi_button_resume(struct device *dev) 335static int acpi_button_resume(struct device *dev)
320{ 336{
321 struct acpi_device *device = to_acpi_device(dev); 337 struct acpi_device *device = to_acpi_device(dev);
322 struct acpi_button *button = acpi_driver_data(device); 338 struct acpi_button *button = acpi_driver_data(device);
323 339
340 button->suspended = false;
324 if (button->type == ACPI_BUTTON_TYPE_LID) 341 if (button->type == ACPI_BUTTON_TYPE_LID)
325 return acpi_lid_send_state(device); 342 return acpi_lid_send_state(device);
326 return 0; 343 return 0;
diff --git a/drivers/acpi/device_pm.c b/drivers/acpi/device_pm.c
index 49a51277f81d..67075f800e34 100644
--- a/drivers/acpi/device_pm.c
+++ b/drivers/acpi/device_pm.c
@@ -367,29 +367,61 @@ EXPORT_SYMBOL(acpi_bus_power_manageable);
367#ifdef CONFIG_PM 367#ifdef CONFIG_PM
368static DEFINE_MUTEX(acpi_pm_notifier_lock); 368static DEFINE_MUTEX(acpi_pm_notifier_lock);
369 369
370static void acpi_pm_notify_handler(acpi_handle handle, u32 val, void *not_used)
371{
372 struct acpi_device *adev;
373
374 if (val != ACPI_NOTIFY_DEVICE_WAKE)
375 return;
376
377 adev = acpi_bus_get_acpi_device(handle);
378 if (!adev)
379 return;
380
381 mutex_lock(&acpi_pm_notifier_lock);
382
383 if (adev->wakeup.flags.notifier_present) {
384 __pm_wakeup_event(adev->wakeup.ws, 0);
385 if (adev->wakeup.context.work.func)
386 queue_pm_work(&adev->wakeup.context.work);
387 }
388
389 mutex_unlock(&acpi_pm_notifier_lock);
390
391 acpi_bus_put_acpi_device(adev);
392}
393
370/** 394/**
371 * acpi_add_pm_notifier - Register PM notifier for given ACPI device. 395 * acpi_add_pm_notifier - Register PM notify handler for given ACPI device.
372 * @adev: ACPI device to add the notifier for. 396 * @adev: ACPI device to add the notify handler for.
373 * @context: Context information to pass to the notifier routine. 397 * @dev: Device to generate a wakeup event for while handling the notification.
398 * @work_func: Work function to execute when handling the notification.
374 * 399 *
375 * NOTE: @adev need not be a run-wake or wakeup device to be a valid source of 400 * NOTE: @adev need not be a run-wake or wakeup device to be a valid source of
376 * PM wakeup events. For example, wakeup events may be generated for bridges 401 * PM wakeup events. For example, wakeup events may be generated for bridges
377 * if one of the devices below the bridge is signaling wakeup, even if the 402 * if one of the devices below the bridge is signaling wakeup, even if the
378 * bridge itself doesn't have a wakeup GPE associated with it. 403 * bridge itself doesn't have a wakeup GPE associated with it.
379 */ 404 */
380acpi_status acpi_add_pm_notifier(struct acpi_device *adev, 405acpi_status acpi_add_pm_notifier(struct acpi_device *adev, struct device *dev,
381 acpi_notify_handler handler, void *context) 406 void (*work_func)(struct work_struct *work))
382{ 407{
383 acpi_status status = AE_ALREADY_EXISTS; 408 acpi_status status = AE_ALREADY_EXISTS;
384 409
410 if (!dev && !work_func)
411 return AE_BAD_PARAMETER;
412
385 mutex_lock(&acpi_pm_notifier_lock); 413 mutex_lock(&acpi_pm_notifier_lock);
386 414
387 if (adev->wakeup.flags.notifier_present) 415 if (adev->wakeup.flags.notifier_present)
388 goto out; 416 goto out;
389 417
390 status = acpi_install_notify_handler(adev->handle, 418 adev->wakeup.ws = wakeup_source_register(dev_name(&adev->dev));
391 ACPI_SYSTEM_NOTIFY, 419 adev->wakeup.context.dev = dev;
392 handler, context); 420 if (work_func)
421 INIT_WORK(&adev->wakeup.context.work, work_func);
422
423 status = acpi_install_notify_handler(adev->handle, ACPI_SYSTEM_NOTIFY,
424 acpi_pm_notify_handler, NULL);
393 if (ACPI_FAILURE(status)) 425 if (ACPI_FAILURE(status))
394 goto out; 426 goto out;
395 427
@@ -404,8 +436,7 @@ acpi_status acpi_add_pm_notifier(struct acpi_device *adev,
404 * acpi_remove_pm_notifier - Unregister PM notifier from given ACPI device. 436 * acpi_remove_pm_notifier - Unregister PM notifier from given ACPI device.
405 * @adev: ACPI device to remove the notifier from. 437 * @adev: ACPI device to remove the notifier from.
406 */ 438 */
407acpi_status acpi_remove_pm_notifier(struct acpi_device *adev, 439acpi_status acpi_remove_pm_notifier(struct acpi_device *adev)
408 acpi_notify_handler handler)
409{ 440{
410 acpi_status status = AE_BAD_PARAMETER; 441 acpi_status status = AE_BAD_PARAMETER;
411 442
@@ -416,10 +447,17 @@ acpi_status acpi_remove_pm_notifier(struct acpi_device *adev,
416 447
417 status = acpi_remove_notify_handler(adev->handle, 448 status = acpi_remove_notify_handler(adev->handle,
418 ACPI_SYSTEM_NOTIFY, 449 ACPI_SYSTEM_NOTIFY,
419 handler); 450 acpi_pm_notify_handler);
420 if (ACPI_FAILURE(status)) 451 if (ACPI_FAILURE(status))
421 goto out; 452 goto out;
422 453
454 if (adev->wakeup.context.work.func) {
455 cancel_work_sync(&adev->wakeup.context.work);
456 adev->wakeup.context.work.func = NULL;
457 }
458 adev->wakeup.context.dev = NULL;
459 wakeup_source_unregister(adev->wakeup.ws);
460
423 adev->wakeup.flags.notifier_present = false; 461 adev->wakeup.flags.notifier_present = false;
424 462
425 out: 463 out:
@@ -558,7 +596,6 @@ static int acpi_dev_pm_get_state(struct device *dev, struct acpi_device *adev,
558 */ 596 */
559int acpi_pm_device_sleep_state(struct device *dev, int *d_min_p, int d_max_in) 597int acpi_pm_device_sleep_state(struct device *dev, int *d_min_p, int d_max_in)
560{ 598{
561 acpi_handle handle = ACPI_HANDLE(dev);
562 struct acpi_device *adev; 599 struct acpi_device *adev;
563 int ret, d_min, d_max; 600 int ret, d_min, d_max;
564 601
@@ -573,8 +610,9 @@ int acpi_pm_device_sleep_state(struct device *dev, int *d_min_p, int d_max_in)
573 d_max_in = ACPI_STATE_D3_HOT; 610 d_max_in = ACPI_STATE_D3_HOT;
574 } 611 }
575 612
576 if (!handle || acpi_bus_get_device(handle, &adev)) { 613 adev = ACPI_COMPANION(dev);
577 dev_dbg(dev, "ACPI handle without context in %s!\n", __func__); 614 if (!adev) {
615 dev_dbg(dev, "ACPI companion missing in %s!\n", __func__);
578 return -ENODEV; 616 return -ENODEV;
579 } 617 }
580 618
@@ -600,26 +638,25 @@ int acpi_pm_device_sleep_state(struct device *dev, int *d_min_p, int d_max_in)
600} 638}
601EXPORT_SYMBOL(acpi_pm_device_sleep_state); 639EXPORT_SYMBOL(acpi_pm_device_sleep_state);
602 640
603#ifdef CONFIG_PM_RUNTIME
604/** 641/**
605 * acpi_wakeup_device - Wakeup notification handler for ACPI devices. 642 * acpi_pm_notify_work_func - ACPI devices wakeup notification work function.
606 * @handle: ACPI handle of the device the notification is for. 643 * @work: Work item to handle.
607 * @event: Type of the signaled event.
608 * @context: Device corresponding to @handle.
609 */ 644 */
610static void acpi_wakeup_device(acpi_handle handle, u32 event, void *context) 645static void acpi_pm_notify_work_func(struct work_struct *work)
611{ 646{
612 struct device *dev = context; 647 struct device *dev;
613 648
614 if (event == ACPI_NOTIFY_DEVICE_WAKE && dev) { 649 dev = container_of(work, struct acpi_device_wakeup_context, work)->dev;
650 if (dev) {
615 pm_wakeup_event(dev, 0); 651 pm_wakeup_event(dev, 0);
616 pm_runtime_resume(dev); 652 pm_runtime_resume(dev);
617 } 653 }
618} 654}
619 655
620/** 656/**
621 * __acpi_device_run_wake - Enable/disable runtime remote wakeup for device. 657 * acpi_device_wakeup - Enable/disable wakeup functionality for device.
622 * @adev: ACPI device to enable/disable the remote wakeup for. 658 * @adev: ACPI device to enable/disable wakeup functionality for.
659 * @target_state: State the system is transitioning into.
623 * @enable: Whether to enable or disable the wakeup functionality. 660 * @enable: Whether to enable or disable the wakeup functionality.
624 * 661 *
625 * Enable/disable the GPE associated with @adev so that it can generate 662 * Enable/disable the GPE associated with @adev so that it can generate
@@ -629,7 +666,8 @@ static void acpi_wakeup_device(acpi_handle handle, u32 event, void *context)
629 * Callers must ensure that @adev is a valid ACPI device node before executing 666 * Callers must ensure that @adev is a valid ACPI device node before executing
630 * this function. 667 * this function.
631 */ 668 */
632int __acpi_device_run_wake(struct acpi_device *adev, bool enable) 669static int acpi_device_wakeup(struct acpi_device *adev, u32 target_state,
670 bool enable)
633{ 671{
634 struct acpi_device_wakeup *wakeup = &adev->wakeup; 672 struct acpi_device_wakeup *wakeup = &adev->wakeup;
635 673
@@ -637,7 +675,7 @@ int __acpi_device_run_wake(struct acpi_device *adev, bool enable)
637 acpi_status res; 675 acpi_status res;
638 int error; 676 int error;
639 677
640 error = acpi_enable_wakeup_device_power(adev, ACPI_STATE_S0); 678 error = acpi_enable_wakeup_device_power(adev, target_state);
641 if (error) 679 if (error)
642 return error; 680 return error;
643 681
@@ -653,6 +691,7 @@ int __acpi_device_run_wake(struct acpi_device *adev, bool enable)
653 return 0; 691 return 0;
654} 692}
655 693
694#ifdef CONFIG_PM_RUNTIME
656/** 695/**
657 * acpi_pm_device_run_wake - Enable/disable remote wakeup for given device. 696 * acpi_pm_device_run_wake - Enable/disable remote wakeup for given device.
658 * @dev: Device to enable/disable the platform to wake up. 697 * @dev: Device to enable/disable the platform to wake up.
@@ -661,63 +700,42 @@ int __acpi_device_run_wake(struct acpi_device *adev, bool enable)
661int acpi_pm_device_run_wake(struct device *phys_dev, bool enable) 700int acpi_pm_device_run_wake(struct device *phys_dev, bool enable)
662{ 701{
663 struct acpi_device *adev; 702 struct acpi_device *adev;
664 acpi_handle handle;
665 703
666 if (!device_run_wake(phys_dev)) 704 if (!device_run_wake(phys_dev))
667 return -EINVAL; 705 return -EINVAL;
668 706
669 handle = ACPI_HANDLE(phys_dev); 707 adev = ACPI_COMPANION(phys_dev);
670 if (!handle || acpi_bus_get_device(handle, &adev)) { 708 if (!adev) {
671 dev_dbg(phys_dev, "ACPI handle without context in %s!\n", 709 dev_dbg(phys_dev, "ACPI companion missing in %s!\n", __func__);
672 __func__);
673 return -ENODEV; 710 return -ENODEV;
674 } 711 }
675 712
676 return __acpi_device_run_wake(adev, enable); 713 return acpi_device_wakeup(adev, enable, ACPI_STATE_S0);
677} 714}
678EXPORT_SYMBOL(acpi_pm_device_run_wake); 715EXPORT_SYMBOL(acpi_pm_device_run_wake);
679#else
680static inline void acpi_wakeup_device(acpi_handle handle, u32 event,
681 void *context) {}
682#endif /* CONFIG_PM_RUNTIME */ 716#endif /* CONFIG_PM_RUNTIME */
683 717
684#ifdef CONFIG_PM_SLEEP 718#ifdef CONFIG_PM_SLEEP
685/** 719/**
686 * __acpi_device_sleep_wake - Enable or disable device to wake up the system.
687 * @dev: Device to enable/desible to wake up the system.
688 * @target_state: System state the device is supposed to wake up from.
689 * @enable: Whether to enable or disable @dev to wake up the system.
690 */
691int __acpi_device_sleep_wake(struct acpi_device *adev, u32 target_state,
692 bool enable)
693{
694 return enable ?
695 acpi_enable_wakeup_device_power(adev, target_state) :
696 acpi_disable_wakeup_device_power(adev);
697}
698
699/**
700 * acpi_pm_device_sleep_wake - Enable or disable device to wake up the system. 720 * acpi_pm_device_sleep_wake - Enable or disable device to wake up the system.
701 * @dev: Device to enable/desible to wake up the system from sleep states. 721 * @dev: Device to enable/desible to wake up the system from sleep states.
702 * @enable: Whether to enable or disable @dev to wake up the system. 722 * @enable: Whether to enable or disable @dev to wake up the system.
703 */ 723 */
704int acpi_pm_device_sleep_wake(struct device *dev, bool enable) 724int acpi_pm_device_sleep_wake(struct device *dev, bool enable)
705{ 725{
706 acpi_handle handle;
707 struct acpi_device *adev; 726 struct acpi_device *adev;
708 int error; 727 int error;
709 728
710 if (!device_can_wakeup(dev)) 729 if (!device_can_wakeup(dev))
711 return -EINVAL; 730 return -EINVAL;
712 731
713 handle = ACPI_HANDLE(dev); 732 adev = ACPI_COMPANION(dev);
714 if (!handle || acpi_bus_get_device(handle, &adev)) { 733 if (!adev) {
715 dev_dbg(dev, "ACPI handle without context in %s!\n", __func__); 734 dev_dbg(dev, "ACPI companion missing in %s!\n", __func__);
716 return -ENODEV; 735 return -ENODEV;
717 } 736 }
718 737
719 error = __acpi_device_sleep_wake(adev, acpi_target_system_state(), 738 error = acpi_device_wakeup(adev, acpi_target_system_state(), enable);
720 enable);
721 if (!error) 739 if (!error)
722 dev_info(dev, "System wakeup %s by ACPI\n", 740 dev_info(dev, "System wakeup %s by ACPI\n",
723 enable ? "enabled" : "disabled"); 741 enable ? "enabled" : "disabled");
@@ -775,13 +793,13 @@ int acpi_dev_runtime_suspend(struct device *dev)
775 793
776 remote_wakeup = dev_pm_qos_flags(dev, PM_QOS_FLAG_REMOTE_WAKEUP) > 794 remote_wakeup = dev_pm_qos_flags(dev, PM_QOS_FLAG_REMOTE_WAKEUP) >
777 PM_QOS_FLAGS_NONE; 795 PM_QOS_FLAGS_NONE;
778 error = __acpi_device_run_wake(adev, remote_wakeup); 796 error = acpi_device_wakeup(adev, ACPI_STATE_S0, remote_wakeup);
779 if (remote_wakeup && error) 797 if (remote_wakeup && error)
780 return -EAGAIN; 798 return -EAGAIN;
781 799
782 error = acpi_dev_pm_low_power(dev, adev, ACPI_STATE_S0); 800 error = acpi_dev_pm_low_power(dev, adev, ACPI_STATE_S0);
783 if (error) 801 if (error)
784 __acpi_device_run_wake(adev, false); 802 acpi_device_wakeup(adev, ACPI_STATE_S0, false);
785 803
786 return error; 804 return error;
787} 805}
@@ -804,7 +822,7 @@ int acpi_dev_runtime_resume(struct device *dev)
804 return 0; 822 return 0;
805 823
806 error = acpi_dev_pm_full_power(adev); 824 error = acpi_dev_pm_full_power(adev);
807 __acpi_device_run_wake(adev, false); 825 acpi_device_wakeup(adev, ACPI_STATE_S0, false);
808 return error; 826 return error;
809} 827}
810EXPORT_SYMBOL_GPL(acpi_dev_runtime_resume); 828EXPORT_SYMBOL_GPL(acpi_dev_runtime_resume);
@@ -860,13 +878,13 @@ int acpi_dev_suspend_late(struct device *dev)
860 878
861 target_state = acpi_target_system_state(); 879 target_state = acpi_target_system_state();
862 wakeup = device_may_wakeup(dev); 880 wakeup = device_may_wakeup(dev);
863 error = __acpi_device_sleep_wake(adev, target_state, wakeup); 881 error = acpi_device_wakeup(adev, target_state, wakeup);
864 if (wakeup && error) 882 if (wakeup && error)
865 return error; 883 return error;
866 884
867 error = acpi_dev_pm_low_power(dev, adev, target_state); 885 error = acpi_dev_pm_low_power(dev, adev, target_state);
868 if (error) 886 if (error)
869 __acpi_device_sleep_wake(adev, ACPI_STATE_UNKNOWN, false); 887 acpi_device_wakeup(adev, ACPI_STATE_UNKNOWN, false);
870 888
871 return error; 889 return error;
872} 890}
@@ -889,7 +907,7 @@ int acpi_dev_resume_early(struct device *dev)
889 return 0; 907 return 0;
890 908
891 error = acpi_dev_pm_full_power(adev); 909 error = acpi_dev_pm_full_power(adev);
892 __acpi_device_sleep_wake(adev, ACPI_STATE_UNKNOWN, false); 910 acpi_device_wakeup(adev, ACPI_STATE_UNKNOWN, false);
893 return error; 911 return error;
894} 912}
895EXPORT_SYMBOL_GPL(acpi_dev_resume_early); 913EXPORT_SYMBOL_GPL(acpi_dev_resume_early);
@@ -1048,11 +1066,11 @@ int acpi_dev_pm_attach(struct device *dev, bool power_on)
1048 if (dev->pm_domain) 1066 if (dev->pm_domain)
1049 return -EEXIST; 1067 return -EEXIST;
1050 1068
1051 acpi_add_pm_notifier(adev, acpi_wakeup_device, dev); 1069 acpi_add_pm_notifier(adev, dev, acpi_pm_notify_work_func);
1052 dev->pm_domain = &acpi_general_pm_domain; 1070 dev->pm_domain = &acpi_general_pm_domain;
1053 if (power_on) { 1071 if (power_on) {
1054 acpi_dev_pm_full_power(adev); 1072 acpi_dev_pm_full_power(adev);
1055 __acpi_device_run_wake(adev, false); 1073 acpi_device_wakeup(adev, ACPI_STATE_S0, false);
1056 } 1074 }
1057 return 0; 1075 return 0;
1058} 1076}
@@ -1076,7 +1094,7 @@ void acpi_dev_pm_detach(struct device *dev, bool power_off)
1076 1094
1077 if (adev && dev->pm_domain == &acpi_general_pm_domain) { 1095 if (adev && dev->pm_domain == &acpi_general_pm_domain) {
1078 dev->pm_domain = NULL; 1096 dev->pm_domain = NULL;
1079 acpi_remove_pm_notifier(adev, acpi_wakeup_device); 1097 acpi_remove_pm_notifier(adev);
1080 if (power_off) { 1098 if (power_off) {
1081 /* 1099 /*
1082 * If the device's PM QoS resume latency limit or flags 1100 * If the device's PM QoS resume latency limit or flags
@@ -1086,7 +1104,7 @@ void acpi_dev_pm_detach(struct device *dev, bool power_off)
1086 */ 1104 */
1087 dev_pm_qos_hide_latency_limit(dev); 1105 dev_pm_qos_hide_latency_limit(dev);
1088 dev_pm_qos_hide_flags(dev); 1106 dev_pm_qos_hide_flags(dev);
1089 __acpi_device_run_wake(adev, false); 1107 acpi_device_wakeup(adev, ACPI_STATE_S0, false);
1090 acpi_dev_pm_low_power(dev, adev, ACPI_STATE_S0); 1108 acpi_dev_pm_low_power(dev, adev, ACPI_STATE_S0);
1091 } 1109 }
1092 } 1110 }
diff --git a/drivers/acpi/internal.h b/drivers/acpi/internal.h
index 7de5b603f272..4c5cf77e7576 100644
--- a/drivers/acpi/internal.h
+++ b/drivers/acpi/internal.h
@@ -84,8 +84,6 @@ void acpi_init_device_object(struct acpi_device *device, acpi_handle handle,
84 int type, unsigned long long sta); 84 int type, unsigned long long sta);
85void acpi_device_add_finalize(struct acpi_device *device); 85void acpi_device_add_finalize(struct acpi_device *device);
86void acpi_free_pnp_ids(struct acpi_device_pnp *pnp); 86void acpi_free_pnp_ids(struct acpi_device_pnp *pnp);
87int acpi_bind_one(struct device *dev, struct acpi_device *adev);
88int acpi_unbind_one(struct device *dev);
89bool acpi_device_is_present(struct acpi_device *adev); 87bool acpi_device_is_present(struct acpi_device *adev);
90bool acpi_device_is_battery(struct acpi_device *adev); 88bool acpi_device_is_battery(struct acpi_device *adev);
91 89
@@ -108,7 +106,12 @@ int acpi_power_transition(struct acpi_device *device, int state);
108int acpi_device_update_power(struct acpi_device *device, int *state_p); 106int acpi_device_update_power(struct acpi_device *device, int *state_p);
109 107
110int acpi_wakeup_device_init(void); 108int acpi_wakeup_device_init(void);
109
110#ifdef CONFIG_ARCH_MIGHT_HAVE_ACPI_PDC
111void acpi_early_processor_set_pdc(void); 111void acpi_early_processor_set_pdc(void);
112#else
113static inline void acpi_early_processor_set_pdc(void) {}
114#endif
112 115
113/* -------------------------------------------------------------------------- 116/* --------------------------------------------------------------------------
114 Embedded Controller 117 Embedded Controller
diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c
index bad25b070fe0..3abe9b223ba7 100644
--- a/drivers/acpi/osl.c
+++ b/drivers/acpi/osl.c
@@ -259,12 +259,14 @@ acpi_physical_address __init acpi_os_get_root_pointer(void)
259 "System description tables not found\n"); 259 "System description tables not found\n");
260 return 0; 260 return 0;
261 } 261 }
262 } else { 262 } else if (IS_ENABLED(CONFIG_ACPI_LEGACY_TABLES_LOOKUP)) {
263 acpi_physical_address pa = 0; 263 acpi_physical_address pa = 0;
264 264
265 acpi_find_root_pointer(&pa); 265 acpi_find_root_pointer(&pa);
266 return pa; 266 return pa;
267 } 267 }
268
269 return 0;
268} 270}
269 271
270/* Must be called with 'acpi_ioremap_lock' or RCU read lock held. */ 272/* Must be called with 'acpi_ioremap_lock' or RCU read lock held. */
diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c
index d388f13d48b4..e6ae603ed1a1 100644
--- a/drivers/acpi/pci_root.c
+++ b/drivers/acpi/pci_root.c
@@ -593,7 +593,7 @@ static int acpi_pci_root_add(struct acpi_device *device,
593 if (no_aspm) 593 if (no_aspm)
594 pcie_no_aspm(); 594 pcie_no_aspm();
595 595
596 pci_acpi_add_bus_pm_notifier(device, root->bus); 596 pci_acpi_add_bus_pm_notifier(device);
597 if (device->wakeup.flags.run_wake) 597 if (device->wakeup.flags.run_wake)
598 device_set_run_wake(root->bus->bridge, true); 598 device_set_run_wake(root->bus->bridge, true);
599 599
diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c
index 71e2065639a6..e32321ce9a5c 100644
--- a/drivers/acpi/processor_core.c
+++ b/drivers/acpi/processor_core.c
@@ -4,17 +4,11 @@
4 * 4 *
5 * Alex Chiang <achiang@hp.com> 5 * Alex Chiang <achiang@hp.com>
6 * - Unified x86/ia64 implementations 6 * - Unified x86/ia64 implementations
7 * Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>
8 * - Added _PDC for platforms with Intel CPUs
9 */ 7 */
10#include <linux/export.h> 8#include <linux/export.h>
11#include <linux/dmi.h>
12#include <linux/slab.h>
13#include <linux/acpi.h> 9#include <linux/acpi.h>
14#include <acpi/processor.h> 10#include <acpi/processor.h>
15 11
16#include "internal.h"
17
18#define _COMPONENT ACPI_PROCESSOR_COMPONENT 12#define _COMPONENT ACPI_PROCESSOR_COMPONENT
19ACPI_MODULE_NAME("processor_core"); 13ACPI_MODULE_NAME("processor_core");
20 14
@@ -135,6 +129,8 @@ static int map_mat_entry(acpi_handle handle, int type, u32 acpi_id)
135 map_lapic_id(header, acpi_id, &apic_id); 129 map_lapic_id(header, acpi_id, &apic_id);
136 } else if (header->type == ACPI_MADT_TYPE_LOCAL_SAPIC) { 130 } else if (header->type == ACPI_MADT_TYPE_LOCAL_SAPIC) {
137 map_lsapic_id(header, type, acpi_id, &apic_id); 131 map_lsapic_id(header, type, acpi_id, &apic_id);
132 } else if (header->type == ACPI_MADT_TYPE_LOCAL_X2APIC) {
133 map_x2apic_id(header, type, acpi_id, &apic_id);
138 } 134 }
139 135
140exit: 136exit:
@@ -208,195 +204,3 @@ int acpi_get_cpuid(acpi_handle handle, int type, u32 acpi_id)
208 return acpi_map_cpuid(apic_id, acpi_id); 204 return acpi_map_cpuid(apic_id, acpi_id);
209} 205}
210EXPORT_SYMBOL_GPL(acpi_get_cpuid); 206EXPORT_SYMBOL_GPL(acpi_get_cpuid);
211
212static bool __init processor_physically_present(acpi_handle handle)
213{
214 int cpuid, type;
215 u32 acpi_id;
216 acpi_status status;
217 acpi_object_type acpi_type;
218 unsigned long long tmp;
219 union acpi_object object = { 0 };
220 struct acpi_buffer buffer = { sizeof(union acpi_object), &object };
221
222 status = acpi_get_type(handle, &acpi_type);
223 if (ACPI_FAILURE(status))
224 return false;
225
226 switch (acpi_type) {
227 case ACPI_TYPE_PROCESSOR:
228 status = acpi_evaluate_object(handle, NULL, NULL, &buffer);
229 if (ACPI_FAILURE(status))
230 return false;
231 acpi_id = object.processor.proc_id;
232 break;
233 case ACPI_TYPE_DEVICE:
234 status = acpi_evaluate_integer(handle, "_UID", NULL, &tmp);
235 if (ACPI_FAILURE(status))
236 return false;
237 acpi_id = tmp;
238 break;
239 default:
240 return false;
241 }
242
243 type = (acpi_type == ACPI_TYPE_DEVICE) ? 1 : 0;
244 cpuid = acpi_get_cpuid(handle, type, acpi_id);
245
246 if (cpuid == -1)
247 return false;
248
249 return true;
250}
251
252static void acpi_set_pdc_bits(u32 *buf)
253{
254 buf[0] = ACPI_PDC_REVISION_ID;
255 buf[1] = 1;
256
257 /* Enable coordination with firmware's _TSD info */
258 buf[2] = ACPI_PDC_SMP_T_SWCOORD;
259
260 /* Twiddle arch-specific bits needed for _PDC */
261 arch_acpi_set_pdc_bits(buf);
262}
263
264static struct acpi_object_list *acpi_processor_alloc_pdc(void)
265{
266 struct acpi_object_list *obj_list;
267 union acpi_object *obj;
268 u32 *buf;
269
270 /* allocate and initialize pdc. It will be used later. */
271 obj_list = kmalloc(sizeof(struct acpi_object_list), GFP_KERNEL);
272 if (!obj_list) {
273 printk(KERN_ERR "Memory allocation error\n");
274 return NULL;
275 }
276
277 obj = kmalloc(sizeof(union acpi_object), GFP_KERNEL);
278 if (!obj) {
279 printk(KERN_ERR "Memory allocation error\n");
280 kfree(obj_list);
281 return NULL;
282 }
283
284 buf = kmalloc(12, GFP_KERNEL);
285 if (!buf) {
286 printk(KERN_ERR "Memory allocation error\n");
287 kfree(obj);
288 kfree(obj_list);
289 return NULL;
290 }
291
292 acpi_set_pdc_bits(buf);
293
294 obj->type = ACPI_TYPE_BUFFER;
295 obj->buffer.length = 12;
296 obj->buffer.pointer = (u8 *) buf;
297 obj_list->count = 1;
298 obj_list->pointer = obj;
299
300 return obj_list;
301}
302
303/*
304 * _PDC is required for a BIOS-OS handshake for most of the newer
305 * ACPI processor features.
306 */
307static acpi_status
308acpi_processor_eval_pdc(acpi_handle handle, struct acpi_object_list *pdc_in)
309{
310 acpi_status status = AE_OK;
311
312 if (boot_option_idle_override == IDLE_NOMWAIT) {
313 /*
314 * If mwait is disabled for CPU C-states, the C2C3_FFH access
315 * mode will be disabled in the parameter of _PDC object.
316 * Of course C1_FFH access mode will also be disabled.
317 */
318 union acpi_object *obj;
319 u32 *buffer = NULL;
320
321 obj = pdc_in->pointer;
322 buffer = (u32 *)(obj->buffer.pointer);
323 buffer[2] &= ~(ACPI_PDC_C_C2C3_FFH | ACPI_PDC_C_C1_FFH);
324
325 }
326 status = acpi_evaluate_object(handle, "_PDC", pdc_in, NULL);
327
328 if (ACPI_FAILURE(status))
329 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
330 "Could not evaluate _PDC, using legacy perf. control.\n"));
331
332 return status;
333}
334
335void acpi_processor_set_pdc(acpi_handle handle)
336{
337 struct acpi_object_list *obj_list;
338
339 if (arch_has_acpi_pdc() == false)
340 return;
341
342 obj_list = acpi_processor_alloc_pdc();
343 if (!obj_list)
344 return;
345
346 acpi_processor_eval_pdc(handle, obj_list);
347
348 kfree(obj_list->pointer->buffer.pointer);
349 kfree(obj_list->pointer);
350 kfree(obj_list);
351}
352
353static acpi_status __init
354early_init_pdc(acpi_handle handle, u32 lvl, void *context, void **rv)
355{
356 if (processor_physically_present(handle) == false)
357 return AE_OK;
358
359 acpi_processor_set_pdc(handle);
360 return AE_OK;
361}
362
363#if defined(CONFIG_X86) || defined(CONFIG_IA64)
364static int __init set_no_mwait(const struct dmi_system_id *id)
365{
366 pr_notice(PREFIX "%s detected - disabling mwait for CPU C-states\n",
367 id->ident);
368 boot_option_idle_override = IDLE_NOMWAIT;
369 return 0;
370}
371
372static struct dmi_system_id processor_idle_dmi_table[] __initdata = {
373 {
374 set_no_mwait, "Extensa 5220", {
375 DMI_MATCH(DMI_BIOS_VENDOR, "Phoenix Technologies LTD"),
376 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
377 DMI_MATCH(DMI_PRODUCT_VERSION, "0100"),
378 DMI_MATCH(DMI_BOARD_NAME, "Columbia") }, NULL},
379 {},
380};
381
382static void __init processor_dmi_check(void)
383{
384 /*
385 * Check whether the system is DMI table. If yes, OSPM
386 * should not use mwait for CPU-states.
387 */
388 dmi_check_system(processor_idle_dmi_table);
389}
390#else
391static inline void processor_dmi_check(void) {}
392#endif
393
394void __init acpi_early_processor_set_pdc(void)
395{
396 processor_dmi_check();
397
398 acpi_walk_namespace(ACPI_TYPE_PROCESSOR, ACPI_ROOT_OBJECT,
399 ACPI_UINT32_MAX,
400 early_init_pdc, NULL, NULL, NULL);
401 acpi_get_devices(ACPI_PROCESSOR_DEVICE_HID, early_init_pdc, NULL, NULL);
402}
diff --git a/drivers/acpi/processor_pdc.c b/drivers/acpi/processor_pdc.c
new file mode 100644
index 000000000000..e5dd80800930
--- /dev/null
+++ b/drivers/acpi/processor_pdc.c
@@ -0,0 +1,206 @@
1/*
2 * Copyright (C) 2005 Intel Corporation
3 * Copyright (C) 2009 Hewlett-Packard Development Company, L.P.
4 *
5 * Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>
6 * - Added _PDC for platforms with Intel CPUs
7 */
8
9#define pr_fmt(fmt) "ACPI: " fmt
10
11#include <linux/dmi.h>
12#include <linux/slab.h>
13#include <linux/acpi.h>
14#include <acpi/processor.h>
15
16#include "internal.h"
17
18#define _COMPONENT ACPI_PROCESSOR_COMPONENT
19ACPI_MODULE_NAME("processor_pdc");
20
21static bool __init processor_physically_present(acpi_handle handle)
22{
23 int cpuid, type;
24 u32 acpi_id;
25 acpi_status status;
26 acpi_object_type acpi_type;
27 unsigned long long tmp;
28 union acpi_object object = { 0 };
29 struct acpi_buffer buffer = { sizeof(union acpi_object), &object };
30
31 status = acpi_get_type(handle, &acpi_type);
32 if (ACPI_FAILURE(status))
33 return false;
34
35 switch (acpi_type) {
36 case ACPI_TYPE_PROCESSOR:
37 status = acpi_evaluate_object(handle, NULL, NULL, &buffer);
38 if (ACPI_FAILURE(status))
39 return false;
40 acpi_id = object.processor.proc_id;
41 break;
42 case ACPI_TYPE_DEVICE:
43 status = acpi_evaluate_integer(handle, "_UID", NULL, &tmp);
44 if (ACPI_FAILURE(status))
45 return false;
46 acpi_id = tmp;
47 break;
48 default:
49 return false;
50 }
51
52 type = (acpi_type == ACPI_TYPE_DEVICE) ? 1 : 0;
53 cpuid = acpi_get_cpuid(handle, type, acpi_id);
54
55 if (cpuid == -1)
56 return false;
57
58 return true;
59}
60
61static void acpi_set_pdc_bits(u32 *buf)
62{
63 buf[0] = ACPI_PDC_REVISION_ID;
64 buf[1] = 1;
65
66 /* Enable coordination with firmware's _TSD info */
67 buf[2] = ACPI_PDC_SMP_T_SWCOORD;
68
69 /* Twiddle arch-specific bits needed for _PDC */
70 arch_acpi_set_pdc_bits(buf);
71}
72
73static struct acpi_object_list *acpi_processor_alloc_pdc(void)
74{
75 struct acpi_object_list *obj_list;
76 union acpi_object *obj;
77 u32 *buf;
78
79 /* allocate and initialize pdc. It will be used later. */
80 obj_list = kmalloc(sizeof(struct acpi_object_list), GFP_KERNEL);
81 if (!obj_list)
82 goto out;
83
84 obj = kmalloc(sizeof(union acpi_object), GFP_KERNEL);
85 if (!obj) {
86 kfree(obj_list);
87 goto out;
88 }
89
90 buf = kmalloc(12, GFP_KERNEL);
91 if (!buf) {
92 kfree(obj);
93 kfree(obj_list);
94 goto out;
95 }
96
97 acpi_set_pdc_bits(buf);
98
99 obj->type = ACPI_TYPE_BUFFER;
100 obj->buffer.length = 12;
101 obj->buffer.pointer = (u8 *) buf;
102 obj_list->count = 1;
103 obj_list->pointer = obj;
104
105 return obj_list;
106out:
107 pr_err("Memory allocation error\n");
108 return NULL;
109}
110
111/*
112 * _PDC is required for a BIOS-OS handshake for most of the newer
113 * ACPI processor features.
114 */
115static acpi_status
116acpi_processor_eval_pdc(acpi_handle handle, struct acpi_object_list *pdc_in)
117{
118 acpi_status status = AE_OK;
119
120 if (boot_option_idle_override == IDLE_NOMWAIT) {
121 /*
122 * If mwait is disabled for CPU C-states, the C2C3_FFH access
123 * mode will be disabled in the parameter of _PDC object.
124 * Of course C1_FFH access mode will also be disabled.
125 */
126 union acpi_object *obj;
127 u32 *buffer = NULL;
128
129 obj = pdc_in->pointer;
130 buffer = (u32 *)(obj->buffer.pointer);
131 buffer[2] &= ~(ACPI_PDC_C_C2C3_FFH | ACPI_PDC_C_C1_FFH);
132
133 }
134 status = acpi_evaluate_object(handle, "_PDC", pdc_in, NULL);
135
136 if (ACPI_FAILURE(status))
137 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
138 "Could not evaluate _PDC, using legacy perf. control.\n"));
139
140 return status;
141}
142
143void acpi_processor_set_pdc(acpi_handle handle)
144{
145 struct acpi_object_list *obj_list;
146
147 if (arch_has_acpi_pdc() == false)
148 return;
149
150 obj_list = acpi_processor_alloc_pdc();
151 if (!obj_list)
152 return;
153
154 acpi_processor_eval_pdc(handle, obj_list);
155
156 kfree(obj_list->pointer->buffer.pointer);
157 kfree(obj_list->pointer);
158 kfree(obj_list);
159}
160
161static acpi_status __init
162early_init_pdc(acpi_handle handle, u32 lvl, void *context, void **rv)
163{
164 if (processor_physically_present(handle) == false)
165 return AE_OK;
166
167 acpi_processor_set_pdc(handle);
168 return AE_OK;
169}
170
171static int __init set_no_mwait(const struct dmi_system_id *id)
172{
173 pr_notice("%s detected - disabling mwait for CPU C-states\n",
174 id->ident);
175 boot_option_idle_override = IDLE_NOMWAIT;
176 return 0;
177}
178
179static struct dmi_system_id processor_idle_dmi_table[] __initdata = {
180 {
181 set_no_mwait, "Extensa 5220", {
182 DMI_MATCH(DMI_BIOS_VENDOR, "Phoenix Technologies LTD"),
183 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
184 DMI_MATCH(DMI_PRODUCT_VERSION, "0100"),
185 DMI_MATCH(DMI_BOARD_NAME, "Columbia") }, NULL},
186 {},
187};
188
189static void __init processor_dmi_check(void)
190{
191 /*
192 * Check whether the system is DMI table. If yes, OSPM
193 * should not use mwait for CPU-states.
194 */
195 dmi_check_system(processor_idle_dmi_table);
196}
197
198void __init acpi_early_processor_set_pdc(void)
199{
200 processor_dmi_check();
201
202 acpi_walk_namespace(ACPI_TYPE_PROCESSOR, ACPI_ROOT_OBJECT,
203 ACPI_UINT32_MAX,
204 early_init_pdc, NULL, NULL, NULL);
205 acpi_get_devices(ACPI_PROCESSOR_DEVICE_HID, early_init_pdc, NULL, NULL);
206}
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index f775fa0d850f..5d592e17d760 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -77,7 +77,9 @@ void acpi_initialize_hp_context(struct acpi_device *adev,
77 void (*uevent)(struct acpi_device *, u32)) 77 void (*uevent)(struct acpi_device *, u32))
78{ 78{
79 acpi_lock_hp_context(); 79 acpi_lock_hp_context();
80 acpi_set_hp_context(adev, hp, notify, uevent, NULL); 80 hp->notify = notify;
81 hp->uevent = uevent;
82 acpi_set_hp_context(adev, hp);
81 acpi_unlock_hp_context(); 83 acpi_unlock_hp_context();
82} 84}
83EXPORT_SYMBOL_GPL(acpi_initialize_hp_context); 85EXPORT_SYMBOL_GPL(acpi_initialize_hp_context);
@@ -1421,14 +1423,13 @@ static int acpi_bus_extract_wakeup_device_power_package(acpi_handle handle,
1421 wakeup->sleep_state = sleep_state; 1423 wakeup->sleep_state = sleep_state;
1422 } 1424 }
1423 } 1425 }
1424 acpi_setup_gpe_for_wake(handle, wakeup->gpe_device, wakeup->gpe_number);
1425 1426
1426 out: 1427 out:
1427 kfree(buffer.pointer); 1428 kfree(buffer.pointer);
1428 return err; 1429 return err;
1429} 1430}
1430 1431
1431static void acpi_bus_set_run_wake_flags(struct acpi_device *device) 1432static void acpi_wakeup_gpe_init(struct acpi_device *device)
1432{ 1433{
1433 struct acpi_device_id button_device_ids[] = { 1434 struct acpi_device_id button_device_ids[] = {
1434 {"PNP0C0C", 0}, 1435 {"PNP0C0C", 0},
@@ -1436,29 +1437,33 @@ static void acpi_bus_set_run_wake_flags(struct acpi_device *device)
1436 {"PNP0C0E", 0}, 1437 {"PNP0C0E", 0},
1437 {"", 0}, 1438 {"", 0},
1438 }; 1439 };
1440 struct acpi_device_wakeup *wakeup = &device->wakeup;
1439 acpi_status status; 1441 acpi_status status;
1440 acpi_event_status event_status; 1442 acpi_event_status event_status;
1441 1443
1442 device->wakeup.flags.notifier_present = 0; 1444 wakeup->flags.notifier_present = 0;
1443 1445
1444 /* Power button, Lid switch always enable wakeup */ 1446 /* Power button, Lid switch always enable wakeup */
1445 if (!acpi_match_device_ids(device, button_device_ids)) { 1447 if (!acpi_match_device_ids(device, button_device_ids)) {
1446 device->wakeup.flags.run_wake = 1; 1448 wakeup->flags.run_wake = 1;
1447 if (!acpi_match_device_ids(device, &button_device_ids[1])) { 1449 if (!acpi_match_device_ids(device, &button_device_ids[1])) {
1448 /* Do not use Lid/sleep button for S5 wakeup */ 1450 /* Do not use Lid/sleep button for S5 wakeup */
1449 if (device->wakeup.sleep_state == ACPI_STATE_S5) 1451 if (wakeup->sleep_state == ACPI_STATE_S5)
1450 device->wakeup.sleep_state = ACPI_STATE_S4; 1452 wakeup->sleep_state = ACPI_STATE_S4;
1451 } 1453 }
1454 acpi_mark_gpe_for_wake(wakeup->gpe_device, wakeup->gpe_number);
1452 device_set_wakeup_capable(&device->dev, true); 1455 device_set_wakeup_capable(&device->dev, true);
1453 return; 1456 return;
1454 } 1457 }
1455 1458
1456 status = acpi_get_gpe_status(device->wakeup.gpe_device, 1459 acpi_setup_gpe_for_wake(device->handle, wakeup->gpe_device,
1457 device->wakeup.gpe_number, 1460 wakeup->gpe_number);
1458 &event_status); 1461 status = acpi_get_gpe_status(wakeup->gpe_device, wakeup->gpe_number,
1459 if (status == AE_OK) 1462 &event_status);
1460 device->wakeup.flags.run_wake = 1463 if (ACPI_FAILURE(status))
1461 !!(event_status & ACPI_EVENT_FLAG_HANDLE); 1464 return;
1465
1466 wakeup->flags.run_wake = !!(event_status & ACPI_EVENT_FLAG_HANDLE);
1462} 1467}
1463 1468
1464static void acpi_bus_get_wakeup_device_flags(struct acpi_device *device) 1469static void acpi_bus_get_wakeup_device_flags(struct acpi_device *device)
@@ -1478,7 +1483,7 @@ static void acpi_bus_get_wakeup_device_flags(struct acpi_device *device)
1478 1483
1479 device->wakeup.flags.valid = 1; 1484 device->wakeup.flags.valid = 1;
1480 device->wakeup.prepare_count = 0; 1485 device->wakeup.prepare_count = 0;
1481 acpi_bus_set_run_wake_flags(device); 1486 acpi_wakeup_gpe_init(device);
1482 /* Call _PSW/_DSW object to disable its ability to wake the sleeping 1487 /* Call _PSW/_DSW object to disable its ability to wake the sleeping
1483 * system for the ACPI device with the _PRW object. 1488 * system for the ACPI device with the _PRW object.
1484 * The _PSW object is depreciated in ACPI 3.0 and is replaced by _DSW. 1489 * The _PSW object is depreciated in ACPI 3.0 and is replaced by _DSW.
diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c
index b3e3cc73ba79..54da4a3fe65e 100644
--- a/drivers/acpi/sleep.c
+++ b/drivers/acpi/sleep.c
@@ -322,6 +322,11 @@ static struct dmi_system_id acpisleep_dmi_table[] __initdata = {
322 322
323static void acpi_sleep_dmi_check(void) 323static void acpi_sleep_dmi_check(void)
324{ 324{
325 int year;
326
327 if (dmi_get_date(DMI_BIOS_DATE, &year, NULL, NULL) && year >= 2012)
328 acpi_nvs_nosave_s3();
329
325 dmi_check_system(acpisleep_dmi_table); 330 dmi_check_system(acpisleep_dmi_table);
326} 331}
327 332
diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c
index 350d52a8f781..826884392e6b 100644
--- a/drivers/acpi/video.c
+++ b/drivers/acpi/video.c
@@ -204,6 +204,8 @@ struct acpi_video_device {
204 struct acpi_video_device_flags flags; 204 struct acpi_video_device_flags flags;
205 struct acpi_video_device_cap cap; 205 struct acpi_video_device_cap cap;
206 struct list_head entry; 206 struct list_head entry;
207 struct delayed_work switch_brightness_work;
208 int switch_brightness_event;
207 struct acpi_video_bus *video; 209 struct acpi_video_bus *video;
208 struct acpi_device *dev; 210 struct acpi_device *dev;
209 struct acpi_video_device_brightness *brightness; 211 struct acpi_video_device_brightness *brightness;
@@ -230,8 +232,7 @@ static int acpi_video_device_lcd_get_level_current(
230 unsigned long long *level, bool raw); 232 unsigned long long *level, bool raw);
231static int acpi_video_get_next_level(struct acpi_video_device *device, 233static int acpi_video_get_next_level(struct acpi_video_device *device,
232 u32 level_current, u32 event); 234 u32 level_current, u32 event);
233static int acpi_video_switch_brightness(struct acpi_video_device *device, 235static void acpi_video_switch_brightness(struct work_struct *work);
234 int event);
235 236
236static bool acpi_video_use_native_backlight(void) 237static bool acpi_video_use_native_backlight(void)
237{ 238{
@@ -275,6 +276,7 @@ static int acpi_video_set_brightness(struct backlight_device *bd)
275 int request_level = bd->props.brightness + 2; 276 int request_level = bd->props.brightness + 2;
276 struct acpi_video_device *vd = bl_get_data(bd); 277 struct acpi_video_device *vd = bl_get_data(bd);
277 278
279 cancel_delayed_work(&vd->switch_brightness_work);
278 return acpi_video_device_lcd_set_level(vd, 280 return acpi_video_device_lcd_set_level(vd,
279 vd->brightness->levels[request_level]); 281 vd->brightness->levels[request_level]);
280} 282}
@@ -461,6 +463,14 @@ static struct dmi_system_id video_dmi_table[] __initdata = {
461 }, 463 },
462 { 464 {
463 .callback = video_set_use_native_backlight, 465 .callback = video_set_use_native_backlight,
466 .ident = "ThinkPad X230",
467 .matches = {
468 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
469 DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad X230"),
470 },
471 },
472 {
473 .callback = video_set_use_native_backlight,
464 .ident = "ThinkPad T430 and T430s", 474 .ident = "ThinkPad T430 and T430s",
465 .matches = { 475 .matches = {
466 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"), 476 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
@@ -469,10 +479,42 @@ static struct dmi_system_id video_dmi_table[] __initdata = {
469 }, 479 },
470 { 480 {
471 .callback = video_set_use_native_backlight, 481 .callback = video_set_use_native_backlight,
472 .ident = "ThinkPad X230", 482 .ident = "ThinkPad T430",
473 .matches = { 483 .matches = {
474 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"), 484 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
475 DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad X230"), 485 DMI_MATCH(DMI_PRODUCT_VERSION, "2349D15"),
486 },
487 },
488 {
489 .callback = video_set_use_native_backlight,
490 .ident = "ThinkPad T431s",
491 .matches = {
492 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
493 DMI_MATCH(DMI_PRODUCT_VERSION, "20AACTO1WW"),
494 },
495 },
496 {
497 .callback = video_set_use_native_backlight,
498 .ident = "ThinkPad Edge E530",
499 .matches = {
500 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
501 DMI_MATCH(DMI_PRODUCT_VERSION, "3259A2G"),
502 },
503 },
504 {
505 .callback = video_set_use_native_backlight,
506 .ident = "ThinkPad Edge E530",
507 .matches = {
508 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
509 DMI_MATCH(DMI_PRODUCT_VERSION, "3259CTO"),
510 },
511 },
512 {
513 .callback = video_set_use_native_backlight,
514 .ident = "ThinkPad Edge E530",
515 .matches = {
516 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
517 DMI_MATCH(DMI_PRODUCT_VERSION, "3259HJG"),
476 }, 518 },
477 }, 519 },
478 { 520 {
@@ -572,6 +614,30 @@ static struct dmi_system_id video_dmi_table[] __initdata = {
572 }, 614 },
573 }, 615 },
574 { 616 {
617 .callback = video_set_use_native_backlight,
618 .ident = "Acer Aspire V5-572G",
619 .matches = {
620 DMI_MATCH(DMI_SYS_VENDOR, "Acer Aspire"),
621 DMI_MATCH(DMI_PRODUCT_VERSION, "V5-572G/Dazzle_CX"),
622 },
623 },
624 {
625 .callback = video_set_use_native_backlight,
626 .ident = "Acer Aspire V5-573G",
627 .matches = {
628 DMI_MATCH(DMI_SYS_VENDOR, "Acer Aspire"),
629 DMI_MATCH(DMI_PRODUCT_VERSION, "V5-573G/Dazzle_HW"),
630 },
631 },
632 {
633 .callback = video_set_use_native_backlight,
634 .ident = "ASUS Zenbook Prime UX31A",
635 .matches = {
636 DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
637 DMI_MATCH(DMI_PRODUCT_NAME, "UX31A"),
638 },
639 },
640 {
575 .callback = video_set_use_native_backlight, 641 .callback = video_set_use_native_backlight,
576 .ident = "HP ProBook 4340s", 642 .ident = "HP ProBook 4340s",
577 .matches = { 643 .matches = {
@@ -607,6 +673,15 @@ static struct dmi_system_id video_dmi_table[] __initdata = {
607 }, 673 },
608 { 674 {
609 .callback = video_set_use_native_backlight, 675 .callback = video_set_use_native_backlight,
676 .ident = "HP EliteBook 2014 models",
677 .matches = {
678 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
679 DMI_MATCH(DMI_PRODUCT_NAME, "HP EliteBook "),
680 DMI_MATCH(DMI_PRODUCT_NAME, " G2"),
681 },
682 },
683 {
684 .callback = video_set_use_native_backlight,
610 .ident = "HP ZBook 14", 685 .ident = "HP ZBook 14",
611 .matches = { 686 .matches = {
612 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"), 687 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
@@ -1188,6 +1263,8 @@ acpi_video_bus_get_one_device(struct acpi_device *device,
1188 data->device_id = device_id; 1263 data->device_id = device_id;
1189 data->video = video; 1264 data->video = video;
1190 data->dev = device; 1265 data->dev = device;
1266 INIT_DELAYED_WORK(&data->switch_brightness_work,
1267 acpi_video_switch_brightness);
1191 1268
1192 attribute = acpi_video_get_device_attr(video, device_id); 1269 attribute = acpi_video_get_device_attr(video, device_id);
1193 1270
@@ -1410,15 +1487,18 @@ acpi_video_get_next_level(struct acpi_video_device *device,
1410 } 1487 }
1411} 1488}
1412 1489
1413static int 1490static void
1414acpi_video_switch_brightness(struct acpi_video_device *device, int event) 1491acpi_video_switch_brightness(struct work_struct *work)
1415{ 1492{
1493 struct acpi_video_device *device = container_of(to_delayed_work(work),
1494 struct acpi_video_device, switch_brightness_work);
1416 unsigned long long level_current, level_next; 1495 unsigned long long level_current, level_next;
1496 int event = device->switch_brightness_event;
1417 int result = -EINVAL; 1497 int result = -EINVAL;
1418 1498
1419 /* no warning message if acpi_backlight=vendor or a quirk is used */ 1499 /* no warning message if acpi_backlight=vendor or a quirk is used */
1420 if (!acpi_video_verify_backlight_support()) 1500 if (!acpi_video_verify_backlight_support())
1421 return 0; 1501 return;
1422 1502
1423 if (!device->brightness) 1503 if (!device->brightness)
1424 goto out; 1504 goto out;
@@ -1440,8 +1520,6 @@ acpi_video_switch_brightness(struct acpi_video_device *device, int event)
1440out: 1520out:
1441 if (result) 1521 if (result)
1442 printk(KERN_ERR PREFIX "Failed to switch the brightness\n"); 1522 printk(KERN_ERR PREFIX "Failed to switch the brightness\n");
1443
1444 return result;
1445} 1523}
1446 1524
1447int acpi_video_get_edid(struct acpi_device *device, int type, int device_id, 1525int acpi_video_get_edid(struct acpi_device *device, int type, int device_id,
@@ -1609,6 +1687,16 @@ static void acpi_video_bus_notify(struct acpi_device *device, u32 event)
1609 return; 1687 return;
1610} 1688}
1611 1689
1690static void brightness_switch_event(struct acpi_video_device *video_device,
1691 u32 event)
1692{
1693 if (!brightness_switch_enabled)
1694 return;
1695
1696 video_device->switch_brightness_event = event;
1697 schedule_delayed_work(&video_device->switch_brightness_work, HZ / 10);
1698}
1699
1612static void acpi_video_device_notify(acpi_handle handle, u32 event, void *data) 1700static void acpi_video_device_notify(acpi_handle handle, u32 event, void *data)
1613{ 1701{
1614 struct acpi_video_device *video_device = data; 1702 struct acpi_video_device *video_device = data;
@@ -1626,28 +1714,23 @@ static void acpi_video_device_notify(acpi_handle handle, u32 event, void *data)
1626 1714
1627 switch (event) { 1715 switch (event) {
1628 case ACPI_VIDEO_NOTIFY_CYCLE_BRIGHTNESS: /* Cycle brightness */ 1716 case ACPI_VIDEO_NOTIFY_CYCLE_BRIGHTNESS: /* Cycle brightness */
1629 if (brightness_switch_enabled) 1717 brightness_switch_event(video_device, event);
1630 acpi_video_switch_brightness(video_device, event);
1631 keycode = KEY_BRIGHTNESS_CYCLE; 1718 keycode = KEY_BRIGHTNESS_CYCLE;
1632 break; 1719 break;
1633 case ACPI_VIDEO_NOTIFY_INC_BRIGHTNESS: /* Increase brightness */ 1720 case ACPI_VIDEO_NOTIFY_INC_BRIGHTNESS: /* Increase brightness */
1634 if (brightness_switch_enabled) 1721 brightness_switch_event(video_device, event);
1635 acpi_video_switch_brightness(video_device, event);
1636 keycode = KEY_BRIGHTNESSUP; 1722 keycode = KEY_BRIGHTNESSUP;
1637 break; 1723 break;
1638 case ACPI_VIDEO_NOTIFY_DEC_BRIGHTNESS: /* Decrease brightness */ 1724 case ACPI_VIDEO_NOTIFY_DEC_BRIGHTNESS: /* Decrease brightness */
1639 if (brightness_switch_enabled) 1725 brightness_switch_event(video_device, event);
1640 acpi_video_switch_brightness(video_device, event);
1641 keycode = KEY_BRIGHTNESSDOWN; 1726 keycode = KEY_BRIGHTNESSDOWN;
1642 break; 1727 break;
1643 case ACPI_VIDEO_NOTIFY_ZERO_BRIGHTNESS: /* zero brightness */ 1728 case ACPI_VIDEO_NOTIFY_ZERO_BRIGHTNESS: /* zero brightness */
1644 if (brightness_switch_enabled) 1729 brightness_switch_event(video_device, event);
1645 acpi_video_switch_brightness(video_device, event);
1646 keycode = KEY_BRIGHTNESS_ZERO; 1730 keycode = KEY_BRIGHTNESS_ZERO;
1647 break; 1731 break;
1648 case ACPI_VIDEO_NOTIFY_DISPLAY_OFF: /* display device off */ 1732 case ACPI_VIDEO_NOTIFY_DISPLAY_OFF: /* display device off */
1649 if (brightness_switch_enabled) 1733 brightness_switch_event(video_device, event);
1650 acpi_video_switch_brightness(video_device, event);
1651 keycode = KEY_DISPLAY_OFF; 1734 keycode = KEY_DISPLAY_OFF;
1652 break; 1735 break;
1653 default: 1736 default:
diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c
index bf412961a934..b67d9aef9fe4 100644
--- a/drivers/base/power/main.c
+++ b/drivers/base/power/main.c
@@ -465,6 +465,7 @@ static void dpm_watchdog_clear(struct dpm_watchdog *wd)
465 * device_resume_noirq - Execute an "early resume" callback for given device. 465 * device_resume_noirq - Execute an "early resume" callback for given device.
466 * @dev: Device to handle. 466 * @dev: Device to handle.
467 * @state: PM transition of the system being carried out. 467 * @state: PM transition of the system being carried out.
468 * @async: If true, the device is being resumed asynchronously.
468 * 469 *
469 * The driver of @dev will not receive interrupts while this function is being 470 * The driver of @dev will not receive interrupts while this function is being
470 * executed. 471 * executed.
@@ -594,6 +595,7 @@ static void dpm_resume_noirq(pm_message_t state)
594 * device_resume_early - Execute an "early resume" callback for given device. 595 * device_resume_early - Execute an "early resume" callback for given device.
595 * @dev: Device to handle. 596 * @dev: Device to handle.
596 * @state: PM transition of the system being carried out. 597 * @state: PM transition of the system being carried out.
598 * @async: If true, the device is being resumed asynchronously.
597 * 599 *
598 * Runtime PM is disabled for @dev while this function is being executed. 600 * Runtime PM is disabled for @dev while this function is being executed.
599 */ 601 */
@@ -1004,6 +1006,7 @@ static pm_message_t resume_event(pm_message_t sleep_state)
1004 * device_suspend_noirq - Execute a "late suspend" callback for given device. 1006 * device_suspend_noirq - Execute a "late suspend" callback for given device.
1005 * @dev: Device to handle. 1007 * @dev: Device to handle.
1006 * @state: PM transition of the system being carried out. 1008 * @state: PM transition of the system being carried out.
1009 * @async: If true, the device is being suspended asynchronously.
1007 * 1010 *
1008 * The driver of @dev will not receive interrupts while this function is being 1011 * The driver of @dev will not receive interrupts while this function is being
1009 * executed. 1012 * executed.
@@ -1144,6 +1147,7 @@ static int dpm_suspend_noirq(pm_message_t state)
1144 * device_suspend_late - Execute a "late suspend" callback for given device. 1147 * device_suspend_late - Execute a "late suspend" callback for given device.
1145 * @dev: Device to handle. 1148 * @dev: Device to handle.
1146 * @state: PM transition of the system being carried out. 1149 * @state: PM transition of the system being carried out.
1150 * @async: If true, the device is being suspended asynchronously.
1147 * 1151 *
1148 * Runtime PM is disabled for @dev while this function is being executed. 1152 * Runtime PM is disabled for @dev while this function is being executed.
1149 */ 1153 */
@@ -1298,6 +1302,7 @@ EXPORT_SYMBOL_GPL(dpm_suspend_end);
1298 * @dev: Device to suspend. 1302 * @dev: Device to suspend.
1299 * @state: PM transition of the system being carried out. 1303 * @state: PM transition of the system being carried out.
1300 * @cb: Suspend callback to execute. 1304 * @cb: Suspend callback to execute.
1305 * @info: string description of caller.
1301 */ 1306 */
1302static int legacy_suspend(struct device *dev, pm_message_t state, 1307static int legacy_suspend(struct device *dev, pm_message_t state,
1303 int (*cb)(struct device *dev, pm_message_t state), 1308 int (*cb)(struct device *dev, pm_message_t state),
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 6f024852c6fb..d9fdeddcef96 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -1076,10 +1076,20 @@ static void cpufreq_policy_free(struct cpufreq_policy *policy)
1076 kfree(policy); 1076 kfree(policy);
1077} 1077}
1078 1078
1079static void update_policy_cpu(struct cpufreq_policy *policy, unsigned int cpu) 1079static int update_policy_cpu(struct cpufreq_policy *policy, unsigned int cpu,
1080 struct device *cpu_dev)
1080{ 1081{
1082 int ret;
1083
1081 if (WARN_ON(cpu == policy->cpu)) 1084 if (WARN_ON(cpu == policy->cpu))
1082 return; 1085 return 0;
1086
1087 /* Move kobject to the new policy->cpu */
1088 ret = kobject_move(&policy->kobj, &cpu_dev->kobj);
1089 if (ret) {
1090 pr_err("%s: Failed to move kobj: %d\n", __func__, ret);
1091 return ret;
1092 }
1083 1093
1084 down_write(&policy->rwsem); 1094 down_write(&policy->rwsem);
1085 1095
@@ -1090,6 +1100,8 @@ static void update_policy_cpu(struct cpufreq_policy *policy, unsigned int cpu)
1090 1100
1091 blocking_notifier_call_chain(&cpufreq_policy_notifier_list, 1101 blocking_notifier_call_chain(&cpufreq_policy_notifier_list,
1092 CPUFREQ_UPDATE_POLICY_CPU, policy); 1102 CPUFREQ_UPDATE_POLICY_CPU, policy);
1103
1104 return 0;
1093} 1105}
1094 1106
1095static int __cpufreq_add_dev(struct device *dev, struct subsys_interface *sif) 1107static int __cpufreq_add_dev(struct device *dev, struct subsys_interface *sif)
@@ -1153,12 +1165,10 @@ static int __cpufreq_add_dev(struct device *dev, struct subsys_interface *sif)
1153 * the creation of a brand new one. So we need to perform this update 1165 * the creation of a brand new one. So we need to perform this update
1154 * by invoking update_policy_cpu(). 1166 * by invoking update_policy_cpu().
1155 */ 1167 */
1156 if (recover_policy && cpu != policy->cpu) { 1168 if (recover_policy && cpu != policy->cpu)
1157 update_policy_cpu(policy, cpu); 1169 WARN_ON(update_policy_cpu(policy, cpu, dev));
1158 WARN_ON(kobject_move(&policy->kobj, &dev->kobj)); 1170 else
1159 } else {
1160 policy->cpu = cpu; 1171 policy->cpu = cpu;
1161 }
1162 1172
1163 cpumask_copy(policy->cpus, cpumask_of(cpu)); 1173 cpumask_copy(policy->cpus, cpumask_of(cpu));
1164 1174
@@ -1309,38 +1319,11 @@ static int cpufreq_add_dev(struct device *dev, struct subsys_interface *sif)
1309 return __cpufreq_add_dev(dev, sif); 1319 return __cpufreq_add_dev(dev, sif);
1310} 1320}
1311 1321
1312static int cpufreq_nominate_new_policy_cpu(struct cpufreq_policy *policy,
1313 unsigned int old_cpu)
1314{
1315 struct device *cpu_dev;
1316 int ret;
1317
1318 /* first sibling now owns the new sysfs dir */
1319 cpu_dev = get_cpu_device(cpumask_any_but(policy->cpus, old_cpu));
1320
1321 sysfs_remove_link(&cpu_dev->kobj, "cpufreq");
1322 ret = kobject_move(&policy->kobj, &cpu_dev->kobj);
1323 if (ret) {
1324 pr_err("%s: Failed to move kobj: %d\n", __func__, ret);
1325
1326 down_write(&policy->rwsem);
1327 cpumask_set_cpu(old_cpu, policy->cpus);
1328 up_write(&policy->rwsem);
1329
1330 ret = sysfs_create_link(&cpu_dev->kobj, &policy->kobj,
1331 "cpufreq");
1332
1333 return -EINVAL;
1334 }
1335
1336 return cpu_dev->id;
1337}
1338
1339static int __cpufreq_remove_dev_prepare(struct device *dev, 1322static int __cpufreq_remove_dev_prepare(struct device *dev,
1340 struct subsys_interface *sif) 1323 struct subsys_interface *sif)
1341{ 1324{
1342 unsigned int cpu = dev->id, cpus; 1325 unsigned int cpu = dev->id, cpus;
1343 int new_cpu, ret; 1326 int ret;
1344 unsigned long flags; 1327 unsigned long flags;
1345 struct cpufreq_policy *policy; 1328 struct cpufreq_policy *policy;
1346 1329
@@ -1380,14 +1363,23 @@ static int __cpufreq_remove_dev_prepare(struct device *dev,
1380 if (cpu != policy->cpu) { 1363 if (cpu != policy->cpu) {
1381 sysfs_remove_link(&dev->kobj, "cpufreq"); 1364 sysfs_remove_link(&dev->kobj, "cpufreq");
1382 } else if (cpus > 1) { 1365 } else if (cpus > 1) {
1383 new_cpu = cpufreq_nominate_new_policy_cpu(policy, cpu); 1366 /* Nominate new CPU */
1384 if (new_cpu >= 0) { 1367 int new_cpu = cpumask_any_but(policy->cpus, cpu);
1385 update_policy_cpu(policy, new_cpu); 1368 struct device *cpu_dev = get_cpu_device(new_cpu);
1386 1369
1387 if (!cpufreq_suspended) 1370 sysfs_remove_link(&cpu_dev->kobj, "cpufreq");
1388 pr_debug("%s: policy Kobject moved to cpu: %d from: %d\n", 1371 ret = update_policy_cpu(policy, new_cpu, cpu_dev);
1389 __func__, new_cpu, cpu); 1372 if (ret) {
1373 if (sysfs_create_link(&cpu_dev->kobj, &policy->kobj,
1374 "cpufreq"))
1375 pr_err("%s: Failed to restore kobj link to cpu:%d\n",
1376 __func__, cpu_dev->id);
1377 return ret;
1390 } 1378 }
1379
1380 if (!cpufreq_suspended)
1381 pr_debug("%s: policy Kobject moved to cpu: %d from: %d\n",
1382 __func__, new_cpu, cpu);
1391 } else if (cpufreq_driver->stop_cpu && cpufreq_driver->setpolicy) { 1383 } else if (cpufreq_driver->stop_cpu && cpufreq_driver->setpolicy) {
1392 cpufreq_driver->stop_cpu(policy); 1384 cpufreq_driver->stop_cpu(policy);
1393 } 1385 }
diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c
index 18d409189092..ad3f38fd3eb9 100644
--- a/drivers/cpufreq/cpufreq_ondemand.c
+++ b/drivers/cpufreq/cpufreq_ondemand.c
@@ -170,21 +170,24 @@ static void od_check_cpu(int cpu, unsigned int load)
170 dbs_freq_increase(policy, policy->max); 170 dbs_freq_increase(policy, policy->max);
171 } else { 171 } else {
172 /* Calculate the next frequency proportional to load */ 172 /* Calculate the next frequency proportional to load */
173 unsigned int freq_next; 173 unsigned int freq_next, min_f, max_f;
174 freq_next = load * policy->cpuinfo.max_freq / 100; 174
175 min_f = policy->cpuinfo.min_freq;
176 max_f = policy->cpuinfo.max_freq;
177 freq_next = min_f + load * (max_f - min_f) / 100;
175 178
176 /* No longer fully busy, reset rate_mult */ 179 /* No longer fully busy, reset rate_mult */
177 dbs_info->rate_mult = 1; 180 dbs_info->rate_mult = 1;
178 181
179 if (!od_tuners->powersave_bias) { 182 if (!od_tuners->powersave_bias) {
180 __cpufreq_driver_target(policy, freq_next, 183 __cpufreq_driver_target(policy, freq_next,
181 CPUFREQ_RELATION_L); 184 CPUFREQ_RELATION_C);
182 return; 185 return;
183 } 186 }
184 187
185 freq_next = od_ops.powersave_bias_target(policy, freq_next, 188 freq_next = od_ops.powersave_bias_target(policy, freq_next,
186 CPUFREQ_RELATION_L); 189 CPUFREQ_RELATION_L);
187 __cpufreq_driver_target(policy, freq_next, CPUFREQ_RELATION_L); 190 __cpufreq_driver_target(policy, freq_next, CPUFREQ_RELATION_C);
188 } 191 }
189} 192}
190 193
diff --git a/drivers/cpufreq/freq_table.c b/drivers/cpufreq/freq_table.c
index 1632981c4b25..df14766a8e06 100644
--- a/drivers/cpufreq/freq_table.c
+++ b/drivers/cpufreq/freq_table.c
@@ -117,7 +117,7 @@ int cpufreq_frequency_table_target(struct cpufreq_policy *policy,
117 .frequency = 0, 117 .frequency = 0,
118 }; 118 };
119 struct cpufreq_frequency_table *pos; 119 struct cpufreq_frequency_table *pos;
120 unsigned int freq, i = 0; 120 unsigned int freq, diff, i = 0;
121 121
122 pr_debug("request for target %u kHz (relation: %u) for cpu %u\n", 122 pr_debug("request for target %u kHz (relation: %u) for cpu %u\n",
123 target_freq, relation, policy->cpu); 123 target_freq, relation, policy->cpu);
@@ -127,6 +127,7 @@ int cpufreq_frequency_table_target(struct cpufreq_policy *policy,
127 suboptimal.frequency = ~0; 127 suboptimal.frequency = ~0;
128 break; 128 break;
129 case CPUFREQ_RELATION_L: 129 case CPUFREQ_RELATION_L:
130 case CPUFREQ_RELATION_C:
130 optimal.frequency = ~0; 131 optimal.frequency = ~0;
131 break; 132 break;
132 } 133 }
@@ -168,6 +169,15 @@ int cpufreq_frequency_table_target(struct cpufreq_policy *policy,
168 } 169 }
169 } 170 }
170 break; 171 break;
172 case CPUFREQ_RELATION_C:
173 diff = abs(freq - target_freq);
174 if (diff < optimal.frequency ||
175 (diff == optimal.frequency &&
176 freq > table[optimal.driver_data].frequency)) {
177 optimal.frequency = diff;
178 optimal.driver_data = i;
179 }
180 break;
171 } 181 }
172 } 182 }
173 if (optimal.driver_data > i) { 183 if (optimal.driver_data > i) {
diff --git a/drivers/cpufreq/imx6q-cpufreq.c b/drivers/cpufreq/imx6q-cpufreq.c
index af366c21d4b4..c2d30765bf3d 100644
--- a/drivers/cpufreq/imx6q-cpufreq.c
+++ b/drivers/cpufreq/imx6q-cpufreq.c
@@ -66,10 +66,12 @@ static int imx6q_set_target(struct cpufreq_policy *policy, unsigned int index)
66 66
67 /* scaling up? scale voltage before frequency */ 67 /* scaling up? scale voltage before frequency */
68 if (new_freq > old_freq) { 68 if (new_freq > old_freq) {
69 ret = regulator_set_voltage_tol(pu_reg, imx6_soc_volt[index], 0); 69 if (!IS_ERR(pu_reg)) {
70 if (ret) { 70 ret = regulator_set_voltage_tol(pu_reg, imx6_soc_volt[index], 0);
71 dev_err(cpu_dev, "failed to scale vddpu up: %d\n", ret); 71 if (ret) {
72 return ret; 72 dev_err(cpu_dev, "failed to scale vddpu up: %d\n", ret);
73 return ret;
74 }
73 } 75 }
74 ret = regulator_set_voltage_tol(soc_reg, imx6_soc_volt[index], 0); 76 ret = regulator_set_voltage_tol(soc_reg, imx6_soc_volt[index], 0);
75 if (ret) { 77 if (ret) {
@@ -121,10 +123,12 @@ static int imx6q_set_target(struct cpufreq_policy *policy, unsigned int index)
121 dev_warn(cpu_dev, "failed to scale vddsoc down: %d\n", ret); 123 dev_warn(cpu_dev, "failed to scale vddsoc down: %d\n", ret);
122 ret = 0; 124 ret = 0;
123 } 125 }
124 ret = regulator_set_voltage_tol(pu_reg, imx6_soc_volt[index], 0); 126 if (!IS_ERR(pu_reg)) {
125 if (ret) { 127 ret = regulator_set_voltage_tol(pu_reg, imx6_soc_volt[index], 0);
126 dev_warn(cpu_dev, "failed to scale vddpu down: %d\n", ret); 128 if (ret) {
127 ret = 0; 129 dev_warn(cpu_dev, "failed to scale vddpu down: %d\n", ret);
130 ret = 0;
131 }
128 } 132 }
129 } 133 }
130 134
@@ -182,9 +186,9 @@ static int imx6q_cpufreq_probe(struct platform_device *pdev)
182 } 186 }
183 187
184 arm_reg = regulator_get(cpu_dev, "arm"); 188 arm_reg = regulator_get(cpu_dev, "arm");
185 pu_reg = regulator_get(cpu_dev, "pu"); 189 pu_reg = regulator_get_optional(cpu_dev, "pu");
186 soc_reg = regulator_get(cpu_dev, "soc"); 190 soc_reg = regulator_get(cpu_dev, "soc");
187 if (IS_ERR(arm_reg) || IS_ERR(pu_reg) || IS_ERR(soc_reg)) { 191 if (IS_ERR(arm_reg) || IS_ERR(soc_reg)) {
188 dev_err(cpu_dev, "failed to get regulators\n"); 192 dev_err(cpu_dev, "failed to get regulators\n");
189 ret = -ENOENT; 193 ret = -ENOENT;
190 goto put_reg; 194 goto put_reg;
@@ -268,9 +272,11 @@ soc_opp_out:
268 ret = regulator_set_voltage_time(soc_reg, imx6_soc_volt[0], imx6_soc_volt[num - 1]); 272 ret = regulator_set_voltage_time(soc_reg, imx6_soc_volt[0], imx6_soc_volt[num - 1]);
269 if (ret > 0) 273 if (ret > 0)
270 transition_latency += ret * 1000; 274 transition_latency += ret * 1000;
271 ret = regulator_set_voltage_time(pu_reg, imx6_soc_volt[0], imx6_soc_volt[num - 1]); 275 if (!IS_ERR(pu_reg)) {
272 if (ret > 0) 276 ret = regulator_set_voltage_time(pu_reg, imx6_soc_volt[0], imx6_soc_volt[num - 1]);
273 transition_latency += ret * 1000; 277 if (ret > 0)
278 transition_latency += ret * 1000;
279 }
274 280
275 /* 281 /*
276 * OPP is maintained in order of increasing frequency, and 282 * OPP is maintained in order of increasing frequency, and
@@ -327,7 +333,8 @@ static int imx6q_cpufreq_remove(struct platform_device *pdev)
327 cpufreq_unregister_driver(&imx6q_cpufreq_driver); 333 cpufreq_unregister_driver(&imx6q_cpufreq_driver);
328 dev_pm_opp_free_cpufreq_table(cpu_dev, &freq_table); 334 dev_pm_opp_free_cpufreq_table(cpu_dev, &freq_table);
329 regulator_put(arm_reg); 335 regulator_put(arm_reg);
330 regulator_put(pu_reg); 336 if (!IS_ERR(pu_reg))
337 regulator_put(pu_reg);
331 regulator_put(soc_reg); 338 regulator_put(soc_reg);
332 clk_put(arm_clk); 339 clk_put(arm_clk);
333 clk_put(pll1_sys_clk); 340 clk_put(pll1_sys_clk);
diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
index 86631cb6f7de..c5eac949760d 100644
--- a/drivers/cpufreq/intel_pstate.c
+++ b/drivers/cpufreq/intel_pstate.c
@@ -37,7 +37,6 @@
37#define BYT_TURBO_RATIOS 0x66c 37#define BYT_TURBO_RATIOS 0x66c
38#define BYT_TURBO_VIDS 0x66d 38#define BYT_TURBO_VIDS 0x66d
39 39
40
41#define FRAC_BITS 8 40#define FRAC_BITS 8
42#define int_tofp(X) ((int64_t)(X) << FRAC_BITS) 41#define int_tofp(X) ((int64_t)(X) << FRAC_BITS)
43#define fp_toint(X) ((X) >> FRAC_BITS) 42#define fp_toint(X) ((X) >> FRAC_BITS)
@@ -50,7 +49,7 @@ static inline int32_t mul_fp(int32_t x, int32_t y)
50 49
51static inline int32_t div_fp(int32_t x, int32_t y) 50static inline int32_t div_fp(int32_t x, int32_t y)
52{ 51{
53 return div_s64((int64_t)x << FRAC_BITS, (int64_t)y); 52 return div_s64((int64_t)x << FRAC_BITS, y);
54} 53}
55 54
56struct sample { 55struct sample {
@@ -148,7 +147,7 @@ static struct perf_limits limits = {
148}; 147};
149 148
150static inline void pid_reset(struct _pid *pid, int setpoint, int busy, 149static inline void pid_reset(struct _pid *pid, int setpoint, int busy,
151 int deadband, int integral) { 150 int deadband, int integral) {
152 pid->setpoint = setpoint; 151 pid->setpoint = setpoint;
153 pid->deadband = deadband; 152 pid->deadband = deadband;
154 pid->integral = int_tofp(integral); 153 pid->integral = int_tofp(integral);
@@ -167,7 +166,6 @@ static inline void pid_i_gain_set(struct _pid *pid, int percent)
167 166
168static inline void pid_d_gain_set(struct _pid *pid, int percent) 167static inline void pid_d_gain_set(struct _pid *pid, int percent)
169{ 168{
170
171 pid->d_gain = div_fp(int_tofp(percent), int_tofp(100)); 169 pid->d_gain = div_fp(int_tofp(percent), int_tofp(100));
172} 170}
173 171
@@ -207,16 +205,13 @@ static inline void intel_pstate_busy_pid_reset(struct cpudata *cpu)
207 pid_d_gain_set(&cpu->pid, pid_params.d_gain_pct); 205 pid_d_gain_set(&cpu->pid, pid_params.d_gain_pct);
208 pid_i_gain_set(&cpu->pid, pid_params.i_gain_pct); 206 pid_i_gain_set(&cpu->pid, pid_params.i_gain_pct);
209 207
210 pid_reset(&cpu->pid, 208 pid_reset(&cpu->pid, pid_params.setpoint, 100, pid_params.deadband, 0);
211 pid_params.setpoint,
212 100,
213 pid_params.deadband,
214 0);
215} 209}
216 210
217static inline void intel_pstate_reset_all_pid(void) 211static inline void intel_pstate_reset_all_pid(void)
218{ 212{
219 unsigned int cpu; 213 unsigned int cpu;
214
220 for_each_online_cpu(cpu) { 215 for_each_online_cpu(cpu) {
221 if (all_cpu_data[cpu]) 216 if (all_cpu_data[cpu])
222 intel_pstate_busy_pid_reset(all_cpu_data[cpu]); 217 intel_pstate_busy_pid_reset(all_cpu_data[cpu]);
@@ -230,13 +225,13 @@ static int pid_param_set(void *data, u64 val)
230 intel_pstate_reset_all_pid(); 225 intel_pstate_reset_all_pid();
231 return 0; 226 return 0;
232} 227}
228
233static int pid_param_get(void *data, u64 *val) 229static int pid_param_get(void *data, u64 *val)
234{ 230{
235 *val = *(u32 *)data; 231 *val = *(u32 *)data;
236 return 0; 232 return 0;
237} 233}
238DEFINE_SIMPLE_ATTRIBUTE(fops_pid_param, pid_param_get, 234DEFINE_SIMPLE_ATTRIBUTE(fops_pid_param, pid_param_get, pid_param_set, "%llu\n");
239 pid_param_set, "%llu\n");
240 235
241struct pid_param { 236struct pid_param {
242 char *name; 237 char *name;
@@ -253,9 +248,9 @@ static struct pid_param pid_files[] = {
253 {NULL, NULL} 248 {NULL, NULL}
254}; 249};
255 250
256static struct dentry *debugfs_parent; 251static void __init intel_pstate_debug_expose_params(void)
257static void intel_pstate_debug_expose_params(void)
258{ 252{
253 struct dentry *debugfs_parent;
259 int i = 0; 254 int i = 0;
260 255
261 debugfs_parent = debugfs_create_dir("pstate_snb", NULL); 256 debugfs_parent = debugfs_create_dir("pstate_snb", NULL);
@@ -263,8 +258,8 @@ static void intel_pstate_debug_expose_params(void)
263 return; 258 return;
264 while (pid_files[i].name) { 259 while (pid_files[i].name) {
265 debugfs_create_file(pid_files[i].name, 0660, 260 debugfs_create_file(pid_files[i].name, 0660,
266 debugfs_parent, pid_files[i].value, 261 debugfs_parent, pid_files[i].value,
267 &fops_pid_param); 262 &fops_pid_param);
268 i++; 263 i++;
269 } 264 }
270} 265}
@@ -280,10 +275,11 @@ static void intel_pstate_debug_expose_params(void)
280 } 275 }
281 276
282static ssize_t store_no_turbo(struct kobject *a, struct attribute *b, 277static ssize_t store_no_turbo(struct kobject *a, struct attribute *b,
283 const char *buf, size_t count) 278 const char *buf, size_t count)
284{ 279{
285 unsigned int input; 280 unsigned int input;
286 int ret; 281 int ret;
282
287 ret = sscanf(buf, "%u", &input); 283 ret = sscanf(buf, "%u", &input);
288 if (ret != 1) 284 if (ret != 1)
289 return -EINVAL; 285 return -EINVAL;
@@ -296,10 +292,11 @@ static ssize_t store_no_turbo(struct kobject *a, struct attribute *b,
296} 292}
297 293
298static ssize_t store_max_perf_pct(struct kobject *a, struct attribute *b, 294static ssize_t store_max_perf_pct(struct kobject *a, struct attribute *b,
299 const char *buf, size_t count) 295 const char *buf, size_t count)
300{ 296{
301 unsigned int input; 297 unsigned int input;
302 int ret; 298 int ret;
299
303 ret = sscanf(buf, "%u", &input); 300 ret = sscanf(buf, "%u", &input);
304 if (ret != 1) 301 if (ret != 1)
305 return -EINVAL; 302 return -EINVAL;
@@ -307,14 +304,16 @@ static ssize_t store_max_perf_pct(struct kobject *a, struct attribute *b,
307 limits.max_sysfs_pct = clamp_t(int, input, 0 , 100); 304 limits.max_sysfs_pct = clamp_t(int, input, 0 , 100);
308 limits.max_perf_pct = min(limits.max_policy_pct, limits.max_sysfs_pct); 305 limits.max_perf_pct = min(limits.max_policy_pct, limits.max_sysfs_pct);
309 limits.max_perf = div_fp(int_tofp(limits.max_perf_pct), int_tofp(100)); 306 limits.max_perf = div_fp(int_tofp(limits.max_perf_pct), int_tofp(100));
307
310 return count; 308 return count;
311} 309}
312 310
313static ssize_t store_min_perf_pct(struct kobject *a, struct attribute *b, 311static ssize_t store_min_perf_pct(struct kobject *a, struct attribute *b,
314 const char *buf, size_t count) 312 const char *buf, size_t count)
315{ 313{
316 unsigned int input; 314 unsigned int input;
317 int ret; 315 int ret;
316
318 ret = sscanf(buf, "%u", &input); 317 ret = sscanf(buf, "%u", &input);
319 if (ret != 1) 318 if (ret != 1)
320 return -EINVAL; 319 return -EINVAL;
@@ -342,17 +341,16 @@ static struct attribute *intel_pstate_attributes[] = {
342static struct attribute_group intel_pstate_attr_group = { 341static struct attribute_group intel_pstate_attr_group = {
343 .attrs = intel_pstate_attributes, 342 .attrs = intel_pstate_attributes,
344}; 343};
345static struct kobject *intel_pstate_kobject;
346 344
347static void intel_pstate_sysfs_expose_params(void) 345static void __init intel_pstate_sysfs_expose_params(void)
348{ 346{
347 struct kobject *intel_pstate_kobject;
349 int rc; 348 int rc;
350 349
351 intel_pstate_kobject = kobject_create_and_add("intel_pstate", 350 intel_pstate_kobject = kobject_create_and_add("intel_pstate",
352 &cpu_subsys.dev_root->kobj); 351 &cpu_subsys.dev_root->kobj);
353 BUG_ON(!intel_pstate_kobject); 352 BUG_ON(!intel_pstate_kobject);
354 rc = sysfs_create_group(intel_pstate_kobject, 353 rc = sysfs_create_group(intel_pstate_kobject, &intel_pstate_attr_group);
355 &intel_pstate_attr_group);
356 BUG_ON(rc); 354 BUG_ON(rc);
357} 355}
358 356
@@ -360,6 +358,7 @@ static void intel_pstate_sysfs_expose_params(void)
360static int byt_get_min_pstate(void) 358static int byt_get_min_pstate(void)
361{ 359{
362 u64 value; 360 u64 value;
361
363 rdmsrl(BYT_RATIOS, value); 362 rdmsrl(BYT_RATIOS, value);
364 return (value >> 8) & 0x7F; 363 return (value >> 8) & 0x7F;
365} 364}
@@ -367,6 +366,7 @@ static int byt_get_min_pstate(void)
367static int byt_get_max_pstate(void) 366static int byt_get_max_pstate(void)
368{ 367{
369 u64 value; 368 u64 value;
369
370 rdmsrl(BYT_RATIOS, value); 370 rdmsrl(BYT_RATIOS, value);
371 return (value >> 16) & 0x7F; 371 return (value >> 16) & 0x7F;
372} 372}
@@ -374,6 +374,7 @@ static int byt_get_max_pstate(void)
374static int byt_get_turbo_pstate(void) 374static int byt_get_turbo_pstate(void)
375{ 375{
376 u64 value; 376 u64 value;
377
377 rdmsrl(BYT_TURBO_RATIOS, value); 378 rdmsrl(BYT_TURBO_RATIOS, value);
378 return value & 0x7F; 379 return value & 0x7F;
379} 380}
@@ -407,7 +408,6 @@ static void byt_get_vid(struct cpudata *cpudata)
407{ 408{
408 u64 value; 409 u64 value;
409 410
410
411 rdmsrl(BYT_VIDS, value); 411 rdmsrl(BYT_VIDS, value);
412 cpudata->vid.min = int_tofp((value >> 8) & 0x7f); 412 cpudata->vid.min = int_tofp((value >> 8) & 0x7f);
413 cpudata->vid.max = int_tofp((value >> 16) & 0x7f); 413 cpudata->vid.max = int_tofp((value >> 16) & 0x7f);
@@ -420,10 +420,10 @@ static void byt_get_vid(struct cpudata *cpudata)
420 cpudata->vid.turbo = value & 0x7f; 420 cpudata->vid.turbo = value & 0x7f;
421} 421}
422 422
423
424static int core_get_min_pstate(void) 423static int core_get_min_pstate(void)
425{ 424{
426 u64 value; 425 u64 value;
426
427 rdmsrl(MSR_PLATFORM_INFO, value); 427 rdmsrl(MSR_PLATFORM_INFO, value);
428 return (value >> 40) & 0xFF; 428 return (value >> 40) & 0xFF;
429} 429}
@@ -431,6 +431,7 @@ static int core_get_min_pstate(void)
431static int core_get_max_pstate(void) 431static int core_get_max_pstate(void)
432{ 432{
433 u64 value; 433 u64 value;
434
434 rdmsrl(MSR_PLATFORM_INFO, value); 435 rdmsrl(MSR_PLATFORM_INFO, value);
435 return (value >> 8) & 0xFF; 436 return (value >> 8) & 0xFF;
436} 437}
@@ -439,9 +440,10 @@ static int core_get_turbo_pstate(void)
439{ 440{
440 u64 value; 441 u64 value;
441 int nont, ret; 442 int nont, ret;
443
442 rdmsrl(MSR_NHM_TURBO_RATIO_LIMIT, value); 444 rdmsrl(MSR_NHM_TURBO_RATIO_LIMIT, value);
443 nont = core_get_max_pstate(); 445 nont = core_get_max_pstate();
444 ret = ((value) & 255); 446 ret = (value) & 255;
445 if (ret <= nont) 447 if (ret <= nont)
446 ret = nont; 448 ret = nont;
447 return ret; 449 return ret;
@@ -493,12 +495,12 @@ static struct cpu_defaults byt_params = {
493 }, 495 },
494}; 496};
495 497
496
497static void intel_pstate_get_min_max(struct cpudata *cpu, int *min, int *max) 498static void intel_pstate_get_min_max(struct cpudata *cpu, int *min, int *max)
498{ 499{
499 int max_perf = cpu->pstate.turbo_pstate; 500 int max_perf = cpu->pstate.turbo_pstate;
500 int max_perf_adj; 501 int max_perf_adj;
501 int min_perf; 502 int min_perf;
503
502 if (limits.no_turbo) 504 if (limits.no_turbo)
503 max_perf = cpu->pstate.max_pstate; 505 max_perf = cpu->pstate.max_pstate;
504 506
@@ -507,8 +509,7 @@ static void intel_pstate_get_min_max(struct cpudata *cpu, int *min, int *max)
507 cpu->pstate.min_pstate, cpu->pstate.turbo_pstate); 509 cpu->pstate.min_pstate, cpu->pstate.turbo_pstate);
508 510
509 min_perf = fp_toint(mul_fp(int_tofp(max_perf), limits.min_perf)); 511 min_perf = fp_toint(mul_fp(int_tofp(max_perf), limits.min_perf));
510 *min = clamp_t(int, min_perf, 512 *min = clamp_t(int, min_perf, cpu->pstate.min_pstate, max_perf);
511 cpu->pstate.min_pstate, max_perf);
512} 513}
513 514
514static void intel_pstate_set_pstate(struct cpudata *cpu, int pstate) 515static void intel_pstate_set_pstate(struct cpudata *cpu, int pstate)
@@ -529,21 +530,6 @@ static void intel_pstate_set_pstate(struct cpudata *cpu, int pstate)
529 pstate_funcs.set(cpu, pstate); 530 pstate_funcs.set(cpu, pstate);
530} 531}
531 532
532static inline void intel_pstate_pstate_increase(struct cpudata *cpu, int steps)
533{
534 int target;
535 target = cpu->pstate.current_pstate + steps;
536
537 intel_pstate_set_pstate(cpu, target);
538}
539
540static inline void intel_pstate_pstate_decrease(struct cpudata *cpu, int steps)
541{
542 int target;
543 target = cpu->pstate.current_pstate - steps;
544 intel_pstate_set_pstate(cpu, target);
545}
546
547static void intel_pstate_get_cpu_pstates(struct cpudata *cpu) 533static void intel_pstate_get_cpu_pstates(struct cpudata *cpu)
548{ 534{
549 cpu->pstate.min_pstate = pstate_funcs.get_min(); 535 cpu->pstate.min_pstate = pstate_funcs.get_min();
@@ -559,13 +545,9 @@ static inline void intel_pstate_calc_busy(struct cpudata *cpu)
559{ 545{
560 struct sample *sample = &cpu->sample; 546 struct sample *sample = &cpu->sample;
561 int64_t core_pct; 547 int64_t core_pct;
562 int32_t rem;
563 548
564 core_pct = int_tofp(sample->aperf) * int_tofp(100); 549 core_pct = int_tofp(sample->aperf) * int_tofp(100);
565 core_pct = div_u64_rem(core_pct, int_tofp(sample->mperf), &rem); 550 core_pct = div64_u64(core_pct, int_tofp(sample->mperf));
566
567 if ((rem << 1) >= int_tofp(sample->mperf))
568 core_pct += 1;
569 551
570 sample->freq = fp_toint( 552 sample->freq = fp_toint(
571 mul_fp(int_tofp(cpu->pstate.max_pstate * 1000), core_pct)); 553 mul_fp(int_tofp(cpu->pstate.max_pstate * 1000), core_pct));
@@ -576,12 +558,12 @@ static inline void intel_pstate_calc_busy(struct cpudata *cpu)
576static inline void intel_pstate_sample(struct cpudata *cpu) 558static inline void intel_pstate_sample(struct cpudata *cpu)
577{ 559{
578 u64 aperf, mperf; 560 u64 aperf, mperf;
561 unsigned long flags;
579 562
563 local_irq_save(flags);
580 rdmsrl(MSR_IA32_APERF, aperf); 564 rdmsrl(MSR_IA32_APERF, aperf);
581 rdmsrl(MSR_IA32_MPERF, mperf); 565 rdmsrl(MSR_IA32_MPERF, mperf);
582 566 local_irq_restore(flags);
583 aperf = aperf >> FRAC_BITS;
584 mperf = mperf >> FRAC_BITS;
585 567
586 cpu->last_sample_time = cpu->sample.time; 568 cpu->last_sample_time = cpu->sample.time;
587 cpu->sample.time = ktime_get(); 569 cpu->sample.time = ktime_get();
@@ -598,10 +580,9 @@ static inline void intel_pstate_sample(struct cpudata *cpu)
598 580
599static inline void intel_pstate_set_sample_time(struct cpudata *cpu) 581static inline void intel_pstate_set_sample_time(struct cpudata *cpu)
600{ 582{
601 int sample_time, delay; 583 int delay;
602 584
603 sample_time = pid_params.sample_rate_ms; 585 delay = msecs_to_jiffies(pid_params.sample_rate_ms);
604 delay = msecs_to_jiffies(sample_time);
605 mod_timer_pinned(&cpu->timer, jiffies + delay); 586 mod_timer_pinned(&cpu->timer, jiffies + delay);
606} 587}
607 588
@@ -616,12 +597,12 @@ static inline int32_t intel_pstate_get_scaled_busy(struct cpudata *cpu)
616 current_pstate = int_tofp(cpu->pstate.current_pstate); 597 current_pstate = int_tofp(cpu->pstate.current_pstate);
617 core_busy = mul_fp(core_busy, div_fp(max_pstate, current_pstate)); 598 core_busy = mul_fp(core_busy, div_fp(max_pstate, current_pstate));
618 599
619 sample_time = (pid_params.sample_rate_ms * USEC_PER_MSEC); 600 sample_time = pid_params.sample_rate_ms * USEC_PER_MSEC;
620 duration_us = (u32) ktime_us_delta(cpu->sample.time, 601 duration_us = (u32) ktime_us_delta(cpu->sample.time,
621 cpu->last_sample_time); 602 cpu->last_sample_time);
622 if (duration_us > sample_time * 3) { 603 if (duration_us > sample_time * 3) {
623 sample_ratio = div_fp(int_tofp(sample_time), 604 sample_ratio = div_fp(int_tofp(sample_time),
624 int_tofp(duration_us)); 605 int_tofp(duration_us));
625 core_busy = mul_fp(core_busy, sample_ratio); 606 core_busy = mul_fp(core_busy, sample_ratio);
626 } 607 }
627 608
@@ -632,20 +613,15 @@ static inline void intel_pstate_adjust_busy_pstate(struct cpudata *cpu)
632{ 613{
633 int32_t busy_scaled; 614 int32_t busy_scaled;
634 struct _pid *pid; 615 struct _pid *pid;
635 signed int ctl = 0; 616 signed int ctl;
636 int steps;
637 617
638 pid = &cpu->pid; 618 pid = &cpu->pid;
639 busy_scaled = intel_pstate_get_scaled_busy(cpu); 619 busy_scaled = intel_pstate_get_scaled_busy(cpu);
640 620
641 ctl = pid_calc(pid, busy_scaled); 621 ctl = pid_calc(pid, busy_scaled);
642 622
643 steps = abs(ctl); 623 /* Negative values of ctl increase the pstate and vice versa */
644 624 intel_pstate_set_pstate(cpu, cpu->pstate.current_pstate - ctl);
645 if (ctl < 0)
646 intel_pstate_pstate_increase(cpu, steps);
647 else
648 intel_pstate_pstate_decrease(cpu, steps);
649} 625}
650 626
651static void intel_pstate_timer_func(unsigned long __data) 627static void intel_pstate_timer_func(unsigned long __data)
@@ -705,8 +681,7 @@ static int intel_pstate_init_cpu(unsigned int cpunum)
705 681
706 init_timer_deferrable(&cpu->timer); 682 init_timer_deferrable(&cpu->timer);
707 cpu->timer.function = intel_pstate_timer_func; 683 cpu->timer.function = intel_pstate_timer_func;
708 cpu->timer.data = 684 cpu->timer.data = (unsigned long)cpu;
709 (unsigned long)cpu;
710 cpu->timer.expires = jiffies + HZ/100; 685 cpu->timer.expires = jiffies + HZ/100;
711 intel_pstate_busy_pid_reset(cpu); 686 intel_pstate_busy_pid_reset(cpu);
712 intel_pstate_sample(cpu); 687 intel_pstate_sample(cpu);
@@ -751,7 +726,7 @@ static int intel_pstate_set_policy(struct cpufreq_policy *policy)
751 limits.min_perf_pct = clamp_t(int, limits.min_perf_pct, 0 , 100); 726 limits.min_perf_pct = clamp_t(int, limits.min_perf_pct, 0 , 100);
752 limits.min_perf = div_fp(int_tofp(limits.min_perf_pct), int_tofp(100)); 727 limits.min_perf = div_fp(int_tofp(limits.min_perf_pct), int_tofp(100));
753 728
754 limits.max_policy_pct = policy->max * 100 / policy->cpuinfo.max_freq; 729 limits.max_policy_pct = (policy->max * 100) / policy->cpuinfo.max_freq;
755 limits.max_policy_pct = clamp_t(int, limits.max_policy_pct, 0 , 100); 730 limits.max_policy_pct = clamp_t(int, limits.max_policy_pct, 0 , 100);
756 limits.max_perf_pct = min(limits.max_policy_pct, limits.max_sysfs_pct); 731 limits.max_perf_pct = min(limits.max_policy_pct, limits.max_sysfs_pct);
757 limits.max_perf = div_fp(int_tofp(limits.max_perf_pct), int_tofp(100)); 732 limits.max_perf = div_fp(int_tofp(limits.max_perf_pct), int_tofp(100));
@@ -763,8 +738,8 @@ static int intel_pstate_verify_policy(struct cpufreq_policy *policy)
763{ 738{
764 cpufreq_verify_within_cpu_limits(policy); 739 cpufreq_verify_within_cpu_limits(policy);
765 740
766 if ((policy->policy != CPUFREQ_POLICY_POWERSAVE) && 741 if (policy->policy != CPUFREQ_POLICY_POWERSAVE &&
767 (policy->policy != CPUFREQ_POLICY_PERFORMANCE)) 742 policy->policy != CPUFREQ_POLICY_PERFORMANCE)
768 return -EINVAL; 743 return -EINVAL;
769 744
770 return 0; 745 return 0;
@@ -797,7 +772,7 @@ static int intel_pstate_cpu_init(struct cpufreq_policy *policy)
797 772
798 rdmsrl(MSR_IA32_MISC_ENABLE, misc_en); 773 rdmsrl(MSR_IA32_MISC_ENABLE, misc_en);
799 if (misc_en & MSR_IA32_MISC_ENABLE_TURBO_DISABLE || 774 if (misc_en & MSR_IA32_MISC_ENABLE_TURBO_DISABLE ||
800 cpu->pstate.max_pstate == cpu->pstate.turbo_pstate) { 775 cpu->pstate.max_pstate == cpu->pstate.turbo_pstate) {
801 limits.turbo_disabled = 1; 776 limits.turbo_disabled = 1;
802 limits.no_turbo = 1; 777 limits.no_turbo = 1;
803 } 778 }
@@ -839,8 +814,8 @@ static int intel_pstate_msrs_not_valid(void)
839 rdmsrl(MSR_IA32_MPERF, mperf); 814 rdmsrl(MSR_IA32_MPERF, mperf);
840 815
841 if (!pstate_funcs.get_max() || 816 if (!pstate_funcs.get_max() ||
842 !pstate_funcs.get_min() || 817 !pstate_funcs.get_min() ||
843 !pstate_funcs.get_turbo()) 818 !pstate_funcs.get_turbo())
844 return -ENODEV; 819 return -ENODEV;
845 820
846 rdmsrl(MSR_IA32_APERF, tmp); 821 rdmsrl(MSR_IA32_APERF, tmp);
@@ -922,14 +897,14 @@ static bool intel_pstate_platform_pwr_mgmt_exists(void)
922 struct acpi_table_header hdr; 897 struct acpi_table_header hdr;
923 struct hw_vendor_info *v_info; 898 struct hw_vendor_info *v_info;
924 899
925 if (acpi_disabled 900 if (acpi_disabled ||
926 || ACPI_FAILURE(acpi_get_table_header(ACPI_SIG_FADT, 0, &hdr))) 901 ACPI_FAILURE(acpi_get_table_header(ACPI_SIG_FADT, 0, &hdr)))
927 return false; 902 return false;
928 903
929 for (v_info = vendor_info; v_info->valid; v_info++) { 904 for (v_info = vendor_info; v_info->valid; v_info++) {
930 if (!strncmp(hdr.oem_id, v_info->oem_id, ACPI_OEM_ID_SIZE) 905 if (!strncmp(hdr.oem_id, v_info->oem_id, ACPI_OEM_ID_SIZE) &&
931 && !strncmp(hdr.oem_table_id, v_info->oem_table_id, ACPI_OEM_TABLE_ID_SIZE) 906 !strncmp(hdr.oem_table_id, v_info->oem_table_id, ACPI_OEM_TABLE_ID_SIZE) &&
932 && intel_pstate_no_acpi_pss()) 907 intel_pstate_no_acpi_pss())
933 return true; 908 return true;
934 } 909 }
935 910
diff --git a/drivers/cpufreq/powernow-k6.c b/drivers/cpufreq/powernow-k6.c
index c8012bc86910..f91027259c3c 100644
--- a/drivers/cpufreq/powernow-k6.c
+++ b/drivers/cpufreq/powernow-k6.c
@@ -55,6 +55,7 @@ static const struct {
55 unsigned freq; 55 unsigned freq;
56 unsigned mult; 56 unsigned mult;
57} usual_frequency_table[] = { 57} usual_frequency_table[] = {
58 { 350000, 35 }, // 100 * 3.5
58 { 400000, 40 }, // 100 * 4 59 { 400000, 40 }, // 100 * 4
59 { 450000, 45 }, // 100 * 4.5 60 { 450000, 45 }, // 100 * 4.5
60 { 475000, 50 }, // 95 * 5 61 { 475000, 50 }, // 95 * 5
diff --git a/drivers/cpuidle/Kconfig b/drivers/cpuidle/Kconfig
index 1b96fb91d32c..32748c36c477 100644
--- a/drivers/cpuidle/Kconfig
+++ b/drivers/cpuidle/Kconfig
@@ -15,12 +15,7 @@ config CPU_IDLE
15if CPU_IDLE 15if CPU_IDLE
16 16
17config CPU_IDLE_MULTIPLE_DRIVERS 17config CPU_IDLE_MULTIPLE_DRIVERS
18 bool "Support multiple cpuidle drivers" 18 bool
19 default n
20 help
21 Allows the cpuidle framework to use different drivers for each CPU.
22 This is useful if you have a system with different CPU latencies and
23 states. If unsure say N.
24 19
25config CPU_IDLE_GOV_LADDER 20config CPU_IDLE_GOV_LADDER
26 bool "Ladder governor (for periodic timer tick)" 21 bool "Ladder governor (for periodic timer tick)"
diff --git a/drivers/cpuidle/Kconfig.arm b/drivers/cpuidle/Kconfig.arm
index b6d69e899f5d..a186dec8e5df 100644
--- a/drivers/cpuidle/Kconfig.arm
+++ b/drivers/cpuidle/Kconfig.arm
@@ -10,6 +10,7 @@ config ARM_ARMADA_370_XP_CPUIDLE
10config ARM_BIG_LITTLE_CPUIDLE 10config ARM_BIG_LITTLE_CPUIDLE
11 bool "Support for ARM big.LITTLE processors" 11 bool "Support for ARM big.LITTLE processors"
12 depends on ARCH_VEXPRESS_TC2_PM 12 depends on ARCH_VEXPRESS_TC2_PM
13 depends on MCPM
13 select ARM_CPU_SUSPEND 14 select ARM_CPU_SUSPEND
14 select CPU_IDLE_MULTIPLE_DRIVERS 15 select CPU_IDLE_MULTIPLE_DRIVERS
15 help 16 help
diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
index cb7019977c50..ee9df5e3f5eb 100644
--- a/drivers/cpuidle/cpuidle.c
+++ b/drivers/cpuidle/cpuidle.c
@@ -119,11 +119,13 @@ int cpuidle_enter_state(struct cpuidle_device *dev, struct cpuidle_driver *drv,
119 ktime_t time_start, time_end; 119 ktime_t time_start, time_end;
120 s64 diff; 120 s64 diff;
121 121
122 trace_cpu_idle_rcuidle(index, dev->cpu);
122 time_start = ktime_get(); 123 time_start = ktime_get();
123 124
124 entered_state = target_state->enter(dev, drv, index); 125 entered_state = target_state->enter(dev, drv, index);
125 126
126 time_end = ktime_get(); 127 time_end = ktime_get();
128 trace_cpu_idle_rcuidle(PWR_EVENT_EXIT, dev->cpu);
127 129
128 if (!cpuidle_state_is_coupled(dev, drv, entered_state)) 130 if (!cpuidle_state_is_coupled(dev, drv, entered_state))
129 local_irq_enable(); 131 local_irq_enable();
diff --git a/drivers/cpuidle/driver.c b/drivers/cpuidle/driver.c
index 9634f20e3926..e431d11abf8d 100644
--- a/drivers/cpuidle/driver.c
+++ b/drivers/cpuidle/driver.c
@@ -182,10 +182,6 @@ static void __cpuidle_driver_init(struct cpuidle_driver *drv)
182static int poll_idle(struct cpuidle_device *dev, 182static int poll_idle(struct cpuidle_device *dev,
183 struct cpuidle_driver *drv, int index) 183 struct cpuidle_driver *drv, int index)
184{ 184{
185 ktime_t t1, t2;
186 s64 diff;
187
188 t1 = ktime_get();
189 local_irq_enable(); 185 local_irq_enable();
190 if (!current_set_polling_and_test()) { 186 if (!current_set_polling_and_test()) {
191 while (!need_resched()) 187 while (!need_resched())
@@ -193,13 +189,6 @@ static int poll_idle(struct cpuidle_device *dev,
193 } 189 }
194 current_clr_polling(); 190 current_clr_polling();
195 191
196 t2 = ktime_get();
197 diff = ktime_to_us(ktime_sub(t2, t1));
198 if (diff > INT_MAX)
199 diff = INT_MAX;
200
201 dev->last_residency = (int) diff;
202
203 return index; 192 return index;
204} 193}
205 194
diff --git a/drivers/cpuidle/governors/ladder.c b/drivers/cpuidle/governors/ladder.c
index 9f08e8cce1af..044ee0df5871 100644
--- a/drivers/cpuidle/governors/ladder.c
+++ b/drivers/cpuidle/governors/ladder.c
@@ -144,7 +144,7 @@ static int ladder_enable_device(struct cpuidle_driver *drv,
144 144
145 ldev->last_state_idx = CPUIDLE_DRIVER_STATE_START; 145 ldev->last_state_idx = CPUIDLE_DRIVER_STATE_START;
146 146
147 for (i = 0; i < drv->state_count; i++) { 147 for (i = CPUIDLE_DRIVER_STATE_START; i < drv->state_count; i++) {
148 state = &drv->states[i]; 148 state = &drv->states[i];
149 lstate = &ldev->states[i]; 149 lstate = &ldev->states[i];
150 150
@@ -156,7 +156,7 @@ static int ladder_enable_device(struct cpuidle_driver *drv,
156 156
157 if (i < drv->state_count - 1) 157 if (i < drv->state_count - 1)
158 lstate->threshold.promotion_time = state->exit_latency; 158 lstate->threshold.promotion_time = state->exit_latency;
159 if (i > 0) 159 if (i > CPUIDLE_DRIVER_STATE_START)
160 lstate->threshold.demotion_time = state->exit_latency; 160 lstate->threshold.demotion_time = state->exit_latency;
161 } 161 }
162 162
diff --git a/drivers/cpuidle/governors/menu.c b/drivers/cpuidle/governors/menu.c
index c4f80c15a48d..c3732fa74f82 100644
--- a/drivers/cpuidle/governors/menu.c
+++ b/drivers/cpuidle/governors/menu.c
@@ -35,7 +35,6 @@
35#define RESOLUTION 1024 35#define RESOLUTION 1024
36#define DECAY 8 36#define DECAY 8
37#define MAX_INTERESTING 50000 37#define MAX_INTERESTING 50000
38#define STDDEV_THRESH 400
39 38
40 39
41/* 40/*
diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c
index efe2f175168f..97c5903b4606 100644
--- a/drivers/cpuidle/sysfs.c
+++ b/drivers/cpuidle/sysfs.c
@@ -445,7 +445,7 @@ static void cpuidle_remove_state_sysfs(struct cpuidle_device *device)
445 445
446#define define_one_driver_ro(_name, show) \ 446#define define_one_driver_ro(_name, show) \
447 static struct cpuidle_driver_attr attr_driver_##_name = \ 447 static struct cpuidle_driver_attr attr_driver_##_name = \
448 __ATTR(_name, 0644, show, NULL) 448 __ATTR(_name, 0444, show, NULL)
449 449
450struct cpuidle_driver_kobj { 450struct cpuidle_driver_kobj {
451 struct cpuidle_driver *drv; 451 struct cpuidle_driver *drv;
diff --git a/drivers/devfreq/Kconfig b/drivers/devfreq/Kconfig
index 49e74c1fc639..3dced0a9eae3 100644
--- a/drivers/devfreq/Kconfig
+++ b/drivers/devfreq/Kconfig
@@ -68,7 +68,6 @@ comment "DEVFREQ Drivers"
68config ARM_EXYNOS4_BUS_DEVFREQ 68config ARM_EXYNOS4_BUS_DEVFREQ
69 bool "ARM Exynos4210/4212/4412 Memory Bus DEVFREQ Driver" 69 bool "ARM Exynos4210/4212/4412 Memory Bus DEVFREQ Driver"
70 depends on (CPU_EXYNOS4210 || SOC_EXYNOS4212 || SOC_EXYNOS4412) && !ARCH_MULTIPLATFORM 70 depends on (CPU_EXYNOS4210 || SOC_EXYNOS4212 || SOC_EXYNOS4412) && !ARCH_MULTIPLATFORM
71 select ARCH_HAS_OPP
72 select DEVFREQ_GOV_SIMPLE_ONDEMAND 71 select DEVFREQ_GOV_SIMPLE_ONDEMAND
73 select PM_OPP 72 select PM_OPP
74 help 73 help
diff --git a/drivers/firmware/efi/cper.c b/drivers/firmware/efi/cper.c
index 437e6fd47311..5b53d6183b6b 100644
--- a/drivers/firmware/efi/cper.c
+++ b/drivers/firmware/efi/cper.c
@@ -344,7 +344,7 @@ static const char * const pcie_port_type_strs[] = {
344}; 344};
345 345
346static void cper_print_pcie(const char *pfx, const struct cper_sec_pcie *pcie, 346static void cper_print_pcie(const char *pfx, const struct cper_sec_pcie *pcie,
347 const struct acpi_generic_data *gdata) 347 const struct acpi_hest_generic_data *gdata)
348{ 348{
349 if (pcie->validation_bits & CPER_PCIE_VALID_PORT_TYPE) 349 if (pcie->validation_bits & CPER_PCIE_VALID_PORT_TYPE)
350 printk("%s""port_type: %d, %s\n", pfx, pcie->port_type, 350 printk("%s""port_type: %d, %s\n", pfx, pcie->port_type,
@@ -380,7 +380,7 @@ static void cper_print_pcie(const char *pfx, const struct cper_sec_pcie *pcie,
380} 380}
381 381
382static void cper_estatus_print_section( 382static void cper_estatus_print_section(
383 const char *pfx, const struct acpi_generic_data *gdata, int sec_no) 383 const char *pfx, const struct acpi_hest_generic_data *gdata, int sec_no)
384{ 384{
385 uuid_le *sec_type = (uuid_le *)gdata->section_type; 385 uuid_le *sec_type = (uuid_le *)gdata->section_type;
386 __u16 severity; 386 __u16 severity;
@@ -426,9 +426,9 @@ err_section_too_small:
426} 426}
427 427
428void cper_estatus_print(const char *pfx, 428void cper_estatus_print(const char *pfx,
429 const struct acpi_generic_status *estatus) 429 const struct acpi_hest_generic_status *estatus)
430{ 430{
431 struct acpi_generic_data *gdata; 431 struct acpi_hest_generic_data *gdata;
432 unsigned int data_len, gedata_len; 432 unsigned int data_len, gedata_len;
433 int sec_no = 0; 433 int sec_no = 0;
434 char newpfx[64]; 434 char newpfx[64];
@@ -441,7 +441,7 @@ void cper_estatus_print(const char *pfx,
441 "and requires no further action"); 441 "and requires no further action");
442 printk("%s""event severity: %s\n", pfx, cper_severity_str(severity)); 442 printk("%s""event severity: %s\n", pfx, cper_severity_str(severity));
443 data_len = estatus->data_length; 443 data_len = estatus->data_length;
444 gdata = (struct acpi_generic_data *)(estatus + 1); 444 gdata = (struct acpi_hest_generic_data *)(estatus + 1);
445 snprintf(newpfx, sizeof(newpfx), "%s%s", pfx, INDENT_SP); 445 snprintf(newpfx, sizeof(newpfx), "%s%s", pfx, INDENT_SP);
446 while (data_len >= sizeof(*gdata)) { 446 while (data_len >= sizeof(*gdata)) {
447 gedata_len = gdata->error_data_length; 447 gedata_len = gdata->error_data_length;
@@ -453,10 +453,10 @@ void cper_estatus_print(const char *pfx,
453} 453}
454EXPORT_SYMBOL_GPL(cper_estatus_print); 454EXPORT_SYMBOL_GPL(cper_estatus_print);
455 455
456int cper_estatus_check_header(const struct acpi_generic_status *estatus) 456int cper_estatus_check_header(const struct acpi_hest_generic_status *estatus)
457{ 457{
458 if (estatus->data_length && 458 if (estatus->data_length &&
459 estatus->data_length < sizeof(struct acpi_generic_data)) 459 estatus->data_length < sizeof(struct acpi_hest_generic_data))
460 return -EINVAL; 460 return -EINVAL;
461 if (estatus->raw_data_length && 461 if (estatus->raw_data_length &&
462 estatus->raw_data_offset < sizeof(*estatus) + estatus->data_length) 462 estatus->raw_data_offset < sizeof(*estatus) + estatus->data_length)
@@ -466,9 +466,9 @@ int cper_estatus_check_header(const struct acpi_generic_status *estatus)
466} 466}
467EXPORT_SYMBOL_GPL(cper_estatus_check_header); 467EXPORT_SYMBOL_GPL(cper_estatus_check_header);
468 468
469int cper_estatus_check(const struct acpi_generic_status *estatus) 469int cper_estatus_check(const struct acpi_hest_generic_status *estatus)
470{ 470{
471 struct acpi_generic_data *gdata; 471 struct acpi_hest_generic_data *gdata;
472 unsigned int data_len, gedata_len; 472 unsigned int data_len, gedata_len;
473 int rc; 473 int rc;
474 474
@@ -476,7 +476,7 @@ int cper_estatus_check(const struct acpi_generic_status *estatus)
476 if (rc) 476 if (rc)
477 return rc; 477 return rc;
478 data_len = estatus->data_length; 478 data_len = estatus->data_length;
479 gdata = (struct acpi_generic_data *)(estatus + 1); 479 gdata = (struct acpi_hest_generic_data *)(estatus + 1);
480 while (data_len >= sizeof(*gdata)) { 480 while (data_len >= sizeof(*gdata)) {
481 gedata_len = gdata->error_data_length; 481 gedata_len = gdata->error_data_length;
482 if (gedata_len > data_len - sizeof(*gdata)) 482 if (gedata_len > data_len - sizeof(*gdata))
diff --git a/drivers/iommu/dmar.c b/drivers/iommu/dmar.c
index 4306885f48b1..60ab474bfff3 100644
--- a/drivers/iommu/dmar.c
+++ b/drivers/iommu/dmar.c
@@ -85,7 +85,7 @@ void *dmar_alloc_dev_scope(void *start, void *end, int *cnt)
85 *cnt = 0; 85 *cnt = 0;
86 while (start < end) { 86 while (start < end) {
87 scope = start; 87 scope = start;
88 if (scope->entry_type == ACPI_DMAR_SCOPE_TYPE_ACPI || 88 if (scope->entry_type == ACPI_DMAR_SCOPE_TYPE_NAMESPACE ||
89 scope->entry_type == ACPI_DMAR_SCOPE_TYPE_ENDPOINT || 89 scope->entry_type == ACPI_DMAR_SCOPE_TYPE_ENDPOINT ||
90 scope->entry_type == ACPI_DMAR_SCOPE_TYPE_BRIDGE) 90 scope->entry_type == ACPI_DMAR_SCOPE_TYPE_BRIDGE)
91 (*cnt)++; 91 (*cnt)++;
@@ -381,7 +381,7 @@ static int __init dmar_parse_one_andd(struct acpi_dmar_header *header)
381 struct acpi_dmar_andd *andd = (void *)header; 381 struct acpi_dmar_andd *andd = (void *)header;
382 382
383 /* Check for NUL termination within the designated length */ 383 /* Check for NUL termination within the designated length */
384 if (strnlen(andd->object_name, header->length - 8) == header->length - 8) { 384 if (strnlen(andd->device_name, header->length - 8) == header->length - 8) {
385 WARN_TAINT(1, TAINT_FIRMWARE_WORKAROUND, 385 WARN_TAINT(1, TAINT_FIRMWARE_WORKAROUND,
386 "Your BIOS is broken; ANDD object name is not NUL-terminated\n" 386 "Your BIOS is broken; ANDD object name is not NUL-terminated\n"
387 "BIOS vendor: %s; Ver: %s; Product Version: %s\n", 387 "BIOS vendor: %s; Ver: %s; Product Version: %s\n",
@@ -391,7 +391,7 @@ static int __init dmar_parse_one_andd(struct acpi_dmar_header *header)
391 return -EINVAL; 391 return -EINVAL;
392 } 392 }
393 pr_info("ANDD device: %x name: %s\n", andd->device_number, 393 pr_info("ANDD device: %x name: %s\n", andd->device_number,
394 andd->object_name); 394 andd->device_name);
395 395
396 return 0; 396 return 0;
397} 397}
@@ -449,17 +449,17 @@ dmar_table_print_dmar_entry(struct acpi_dmar_header *header)
449 (unsigned long long)rmrr->base_address, 449 (unsigned long long)rmrr->base_address,
450 (unsigned long long)rmrr->end_address); 450 (unsigned long long)rmrr->end_address);
451 break; 451 break;
452 case ACPI_DMAR_TYPE_ATSR: 452 case ACPI_DMAR_TYPE_ROOT_ATS:
453 atsr = container_of(header, struct acpi_dmar_atsr, header); 453 atsr = container_of(header, struct acpi_dmar_atsr, header);
454 pr_info("ATSR flags: %#x\n", atsr->flags); 454 pr_info("ATSR flags: %#x\n", atsr->flags);
455 break; 455 break;
456 case ACPI_DMAR_HARDWARE_AFFINITY: 456 case ACPI_DMAR_TYPE_HARDWARE_AFFINITY:
457 rhsa = container_of(header, struct acpi_dmar_rhsa, header); 457 rhsa = container_of(header, struct acpi_dmar_rhsa, header);
458 pr_info("RHSA base: %#016Lx proximity domain: %#x\n", 458 pr_info("RHSA base: %#016Lx proximity domain: %#x\n",
459 (unsigned long long)rhsa->base_address, 459 (unsigned long long)rhsa->base_address,
460 rhsa->proximity_domain); 460 rhsa->proximity_domain);
461 break; 461 break;
462 case ACPI_DMAR_TYPE_ANDD: 462 case ACPI_DMAR_TYPE_NAMESPACE:
463 /* We don't print this here because we need to sanity-check 463 /* We don't print this here because we need to sanity-check
464 it first. So print it in dmar_parse_one_andd() instead. */ 464 it first. So print it in dmar_parse_one_andd() instead. */
465 break; 465 break;
@@ -540,15 +540,15 @@ parse_dmar_table(void)
540 case ACPI_DMAR_TYPE_RESERVED_MEMORY: 540 case ACPI_DMAR_TYPE_RESERVED_MEMORY:
541 ret = dmar_parse_one_rmrr(entry_header); 541 ret = dmar_parse_one_rmrr(entry_header);
542 break; 542 break;
543 case ACPI_DMAR_TYPE_ATSR: 543 case ACPI_DMAR_TYPE_ROOT_ATS:
544 ret = dmar_parse_one_atsr(entry_header); 544 ret = dmar_parse_one_atsr(entry_header);
545 break; 545 break;
546 case ACPI_DMAR_HARDWARE_AFFINITY: 546 case ACPI_DMAR_TYPE_HARDWARE_AFFINITY:
547#ifdef CONFIG_ACPI_NUMA 547#ifdef CONFIG_ACPI_NUMA
548 ret = dmar_parse_one_rhsa(entry_header); 548 ret = dmar_parse_one_rhsa(entry_header);
549#endif 549#endif
550 break; 550 break;
551 case ACPI_DMAR_TYPE_ANDD: 551 case ACPI_DMAR_TYPE_NAMESPACE:
552 ret = dmar_parse_one_andd(entry_header); 552 ret = dmar_parse_one_andd(entry_header);
553 break; 553 break;
554 default: 554 default:
@@ -632,7 +632,7 @@ static void __init dmar_acpi_insert_dev_scope(u8 device_number,
632 for (scope = (void *)(drhd + 1); 632 for (scope = (void *)(drhd + 1);
633 (unsigned long)scope < ((unsigned long)drhd) + drhd->header.length; 633 (unsigned long)scope < ((unsigned long)drhd) + drhd->header.length;
634 scope = ((void *)scope) + scope->length) { 634 scope = ((void *)scope) + scope->length) {
635 if (scope->entry_type != ACPI_DMAR_SCOPE_TYPE_ACPI) 635 if (scope->entry_type != ACPI_DMAR_SCOPE_TYPE_NAMESPACE)
636 continue; 636 continue;
637 if (scope->enumeration_id != device_number) 637 if (scope->enumeration_id != device_number)
638 continue; 638 continue;
@@ -667,21 +667,21 @@ static int __init dmar_acpi_dev_scope_init(void)
667 for (andd = (void *)dmar_tbl + sizeof(struct acpi_table_dmar); 667 for (andd = (void *)dmar_tbl + sizeof(struct acpi_table_dmar);
668 ((unsigned long)andd) < ((unsigned long)dmar_tbl) + dmar_tbl->length; 668 ((unsigned long)andd) < ((unsigned long)dmar_tbl) + dmar_tbl->length;
669 andd = ((void *)andd) + andd->header.length) { 669 andd = ((void *)andd) + andd->header.length) {
670 if (andd->header.type == ACPI_DMAR_TYPE_ANDD) { 670 if (andd->header.type == ACPI_DMAR_TYPE_NAMESPACE) {
671 acpi_handle h; 671 acpi_handle h;
672 struct acpi_device *adev; 672 struct acpi_device *adev;
673 673
674 if (!ACPI_SUCCESS(acpi_get_handle(ACPI_ROOT_OBJECT, 674 if (!ACPI_SUCCESS(acpi_get_handle(ACPI_ROOT_OBJECT,
675 andd->object_name, 675 andd->device_name,
676 &h))) { 676 &h))) {
677 pr_err("Failed to find handle for ACPI object %s\n", 677 pr_err("Failed to find handle for ACPI object %s\n",
678 andd->object_name); 678 andd->device_name);
679 continue; 679 continue;
680 } 680 }
681 acpi_bus_get_device(h, &adev); 681 acpi_bus_get_device(h, &adev);
682 if (!adev) { 682 if (!adev) {
683 pr_err("Failed to get device for ACPI object %s\n", 683 pr_err("Failed to get device for ACPI object %s\n",
684 andd->object_name); 684 andd->device_name);
685 continue; 685 continue;
686 } 686 }
687 dmar_acpi_insert_dev_scope(andd->device_number, adev); 687 dmar_acpi_insert_dev_scope(andd->device_number, adev);
diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c
index 602d153c7055..70741c8c46a0 100644
--- a/drivers/pci/hotplug/acpiphp_glue.c
+++ b/drivers/pci/hotplug/acpiphp_glue.c
@@ -80,8 +80,9 @@ static struct acpiphp_context *acpiphp_init_context(struct acpi_device *adev)
80 return NULL; 80 return NULL;
81 81
82 context->refcount = 1; 82 context->refcount = 1;
83 acpi_set_hp_context(adev, &context->hp, acpiphp_hotplug_notify, NULL, 83 context->hp.notify = acpiphp_hotplug_notify;
84 acpiphp_post_dock_fixup); 84 context->hp.fixup = acpiphp_post_dock_fixup;
85 acpi_set_hp_context(adev, &context->hp);
85 return context; 86 return context;
86} 87}
87 88
@@ -369,20 +370,6 @@ static acpi_status acpiphp_add_context(acpi_handle handle, u32 lvl, void *data,
369 return AE_OK; 370 return AE_OK;
370} 371}
371 372
372static struct acpiphp_bridge *acpiphp_dev_to_bridge(struct acpi_device *adev)
373{
374 struct acpiphp_bridge *bridge = NULL;
375
376 acpi_lock_hp_context();
377 if (adev->hp) {
378 bridge = to_acpiphp_root_context(adev->hp)->root_bridge;
379 if (bridge)
380 get_bridge(bridge);
381 }
382 acpi_unlock_hp_context();
383 return bridge;
384}
385
386static void cleanup_bridge(struct acpiphp_bridge *bridge) 373static void cleanup_bridge(struct acpiphp_bridge *bridge)
387{ 374{
388 struct acpiphp_slot *slot; 375 struct acpiphp_slot *slot;
@@ -753,9 +740,15 @@ static void acpiphp_sanitize_bus(struct pci_bus *bus)
753 740
754void acpiphp_check_host_bridge(struct acpi_device *adev) 741void acpiphp_check_host_bridge(struct acpi_device *adev)
755{ 742{
756 struct acpiphp_bridge *bridge; 743 struct acpiphp_bridge *bridge = NULL;
757 744
758 bridge = acpiphp_dev_to_bridge(adev); 745 acpi_lock_hp_context();
746 if (adev->hp) {
747 bridge = to_acpiphp_root_context(adev->hp)->root_bridge;
748 if (bridge)
749 get_bridge(bridge);
750 }
751 acpi_unlock_hp_context();
759 if (bridge) { 752 if (bridge) {
760 pci_lock_rescan_remove(); 753 pci_lock_rescan_remove();
761 754
@@ -884,7 +877,7 @@ void acpiphp_enumerate_slots(struct pci_bus *bus)
884 goto err; 877 goto err;
885 878
886 root_context->root_bridge = bridge; 879 root_context->root_bridge = bridge;
887 acpi_set_hp_context(adev, &root_context->hp, NULL, NULL, NULL); 880 acpi_set_hp_context(adev, &root_context->hp);
888 } else { 881 } else {
889 struct acpiphp_context *context; 882 struct acpiphp_context *context;
890 883
@@ -927,7 +920,7 @@ void acpiphp_enumerate_slots(struct pci_bus *bus)
927 kfree(bridge); 920 kfree(bridge);
928} 921}
929 922
930void acpiphp_drop_bridge(struct acpiphp_bridge *bridge) 923static void acpiphp_drop_bridge(struct acpiphp_bridge *bridge)
931{ 924{
932 if (pci_is_root_bus(bridge->pci_bus)) { 925 if (pci_is_root_bus(bridge->pci_bus)) {
933 struct acpiphp_root_context *root_context; 926 struct acpiphp_root_context *root_context;
diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c
index ca4927ba8433..37263b0ebfe3 100644
--- a/drivers/pci/pci-acpi.c
+++ b/drivers/pci/pci-acpi.c
@@ -18,31 +18,31 @@
18#include "pci.h" 18#include "pci.h"
19 19
20/** 20/**
21 * pci_acpi_wake_bus - Wake-up notification handler for root buses. 21 * pci_acpi_wake_bus - Root bus wakeup notification fork function.
22 * @handle: ACPI handle of a device the notification is for. 22 * @work: Work item to handle.
23 * @event: Type of the signaled event.
24 * @context: PCI root bus to wake up devices on.
25 */ 23 */
26static void pci_acpi_wake_bus(acpi_handle handle, u32 event, void *context) 24static void pci_acpi_wake_bus(struct work_struct *work)
27{ 25{
28 struct pci_bus *pci_bus = context; 26 struct acpi_device *adev;
27 struct acpi_pci_root *root;
29 28
30 if (event == ACPI_NOTIFY_DEVICE_WAKE && pci_bus) 29 adev = container_of(work, struct acpi_device, wakeup.context.work);
31 pci_pme_wakeup_bus(pci_bus); 30 root = acpi_driver_data(adev);
31 pci_pme_wakeup_bus(root->bus);
32} 32}
33 33
34/** 34/**
35 * pci_acpi_wake_dev - Wake-up notification handler for PCI devices. 35 * pci_acpi_wake_dev - PCI device wakeup notification work function.
36 * @handle: ACPI handle of a device the notification is for. 36 * @handle: ACPI handle of a device the notification is for.
37 * @event: Type of the signaled event. 37 * @work: Work item to handle.
38 * @context: PCI device object to wake up.
39 */ 38 */
40static void pci_acpi_wake_dev(acpi_handle handle, u32 event, void *context) 39static void pci_acpi_wake_dev(struct work_struct *work)
41{ 40{
42 struct pci_dev *pci_dev = context; 41 struct acpi_device_wakeup_context *context;
42 struct pci_dev *pci_dev;
43 43
44 if (event != ACPI_NOTIFY_DEVICE_WAKE || !pci_dev) 44 context = container_of(work, struct acpi_device_wakeup_context, work);
45 return; 45 pci_dev = to_pci_dev(context->dev);
46 46
47 if (pci_dev->pme_poll) 47 if (pci_dev->pme_poll)
48 pci_dev->pme_poll = false; 48 pci_dev->pme_poll = false;
@@ -65,23 +65,12 @@ static void pci_acpi_wake_dev(acpi_handle handle, u32 event, void *context)
65} 65}
66 66
67/** 67/**
68 * pci_acpi_add_bus_pm_notifier - Register PM notifier for given PCI bus. 68 * pci_acpi_add_bus_pm_notifier - Register PM notifier for root PCI bus.
69 * @dev: ACPI device to add the notifier for. 69 * @dev: PCI root bridge ACPI device.
70 * @pci_bus: PCI bus to walk checking for PME status if an event is signaled.
71 */
72acpi_status pci_acpi_add_bus_pm_notifier(struct acpi_device *dev,
73 struct pci_bus *pci_bus)
74{
75 return acpi_add_pm_notifier(dev, pci_acpi_wake_bus, pci_bus);
76}
77
78/**
79 * pci_acpi_remove_bus_pm_notifier - Unregister PCI bus PM notifier.
80 * @dev: ACPI device to remove the notifier from.
81 */ 70 */
82acpi_status pci_acpi_remove_bus_pm_notifier(struct acpi_device *dev) 71acpi_status pci_acpi_add_bus_pm_notifier(struct acpi_device *dev)
83{ 72{
84 return acpi_remove_pm_notifier(dev, pci_acpi_wake_bus); 73 return acpi_add_pm_notifier(dev, NULL, pci_acpi_wake_bus);
85} 74}
86 75
87/** 76/**
@@ -92,16 +81,7 @@ acpi_status pci_acpi_remove_bus_pm_notifier(struct acpi_device *dev)
92acpi_status pci_acpi_add_pm_notifier(struct acpi_device *dev, 81acpi_status pci_acpi_add_pm_notifier(struct acpi_device *dev,
93 struct pci_dev *pci_dev) 82 struct pci_dev *pci_dev)
94{ 83{
95 return acpi_add_pm_notifier(dev, pci_acpi_wake_dev, pci_dev); 84 return acpi_add_pm_notifier(dev, &pci_dev->dev, pci_acpi_wake_dev);
96}
97
98/**
99 * pci_acpi_remove_pm_notifier - Unregister PCI device PM notifier.
100 * @dev: ACPI device to remove the notifier from.
101 */
102acpi_status pci_acpi_remove_pm_notifier(struct acpi_device *dev)
103{
104 return acpi_remove_pm_notifier(dev, pci_acpi_wake_dev);
105} 85}
106 86
107phys_addr_t acpi_pci_root_get_mcfg_addr(acpi_handle handle) 87phys_addr_t acpi_pci_root_get_mcfg_addr(acpi_handle handle)
@@ -170,14 +150,13 @@ static pci_power_t acpi_pci_choose_state(struct pci_dev *pdev)
170 150
171static bool acpi_pci_power_manageable(struct pci_dev *dev) 151static bool acpi_pci_power_manageable(struct pci_dev *dev)
172{ 152{
173 acpi_handle handle = ACPI_HANDLE(&dev->dev); 153 struct acpi_device *adev = ACPI_COMPANION(&dev->dev);
174 154 return adev ? acpi_device_power_manageable(adev) : false;
175 return handle ? acpi_bus_power_manageable(handle) : false;
176} 155}
177 156
178static int acpi_pci_set_power_state(struct pci_dev *dev, pci_power_t state) 157static int acpi_pci_set_power_state(struct pci_dev *dev, pci_power_t state)
179{ 158{
180 acpi_handle handle = ACPI_HANDLE(&dev->dev); 159 struct acpi_device *adev = ACPI_COMPANION(&dev->dev);
181 static const u8 state_conv[] = { 160 static const u8 state_conv[] = {
182 [PCI_D0] = ACPI_STATE_D0, 161 [PCI_D0] = ACPI_STATE_D0,
183 [PCI_D1] = ACPI_STATE_D1, 162 [PCI_D1] = ACPI_STATE_D1,
@@ -188,7 +167,7 @@ static int acpi_pci_set_power_state(struct pci_dev *dev, pci_power_t state)
188 int error = -EINVAL; 167 int error = -EINVAL;
189 168
190 /* If the ACPI device has _EJ0, ignore the device */ 169 /* If the ACPI device has _EJ0, ignore the device */
191 if (!handle || acpi_has_method(handle, "_EJ0")) 170 if (!adev || acpi_has_method(adev->handle, "_EJ0"))
192 return -ENODEV; 171 return -ENODEV;
193 172
194 switch (state) { 173 switch (state) {
@@ -202,7 +181,7 @@ static int acpi_pci_set_power_state(struct pci_dev *dev, pci_power_t state)
202 case PCI_D1: 181 case PCI_D1:
203 case PCI_D2: 182 case PCI_D2:
204 case PCI_D3hot: 183 case PCI_D3hot:
205 error = acpi_bus_set_power(handle, state_conv[state]); 184 error = acpi_device_set_power(adev, state_conv[state]);
206 } 185 }
207 186
208 if (!error) 187 if (!error)
@@ -214,9 +193,8 @@ static int acpi_pci_set_power_state(struct pci_dev *dev, pci_power_t state)
214 193
215static bool acpi_pci_can_wakeup(struct pci_dev *dev) 194static bool acpi_pci_can_wakeup(struct pci_dev *dev)
216{ 195{
217 acpi_handle handle = ACPI_HANDLE(&dev->dev); 196 struct acpi_device *adev = ACPI_COMPANION(&dev->dev);
218 197 return adev ? acpi_device_can_wakeup(adev) : false;
219 return handle ? acpi_bus_can_wakeup(handle) : false;
220} 198}
221 199
222static void acpi_pci_propagate_wakeup_enable(struct pci_bus *bus, bool enable) 200static void acpi_pci_propagate_wakeup_enable(struct pci_bus *bus, bool enable)
diff --git a/drivers/pnp/pnpacpi/core.c b/drivers/pnp/pnpacpi/core.c
index a5c6cb773e5f..d2b780aade89 100644
--- a/drivers/pnp/pnpacpi/core.c
+++ b/drivers/pnp/pnpacpi/core.c
@@ -67,8 +67,8 @@ static int pnpacpi_set_resources(struct pnp_dev *dev)
67 67
68 pnp_dbg(&dev->dev, "set resources\n"); 68 pnp_dbg(&dev->dev, "set resources\n");
69 69
70 handle = ACPI_HANDLE(&dev->dev); 70 acpi_dev = ACPI_COMPANION(&dev->dev);
71 if (!handle || acpi_bus_get_device(handle, &acpi_dev)) { 71 if (!acpi_dev) {
72 dev_dbg(&dev->dev, "ACPI device not found in %s!\n", __func__); 72 dev_dbg(&dev->dev, "ACPI device not found in %s!\n", __func__);
73 return -ENODEV; 73 return -ENODEV;
74 } 74 }
@@ -76,6 +76,7 @@ static int pnpacpi_set_resources(struct pnp_dev *dev)
76 if (WARN_ON_ONCE(acpi_dev != dev->data)) 76 if (WARN_ON_ONCE(acpi_dev != dev->data))
77 dev->data = acpi_dev; 77 dev->data = acpi_dev;
78 78
79 handle = acpi_dev->handle;
79 if (acpi_has_method(handle, METHOD_NAME__SRS)) { 80 if (acpi_has_method(handle, METHOD_NAME__SRS)) {
80 struct acpi_buffer buffer; 81 struct acpi_buffer buffer;
81 82
@@ -93,8 +94,8 @@ static int pnpacpi_set_resources(struct pnp_dev *dev)
93 } 94 }
94 kfree(buffer.pointer); 95 kfree(buffer.pointer);
95 } 96 }
96 if (!ret && acpi_bus_power_manageable(handle)) 97 if (!ret && acpi_device_power_manageable(acpi_dev))
97 ret = acpi_bus_set_power(handle, ACPI_STATE_D0); 98 ret = acpi_device_set_power(acpi_dev, ACPI_STATE_D0);
98 99
99 return ret; 100 return ret;
100} 101}
@@ -102,23 +103,22 @@ static int pnpacpi_set_resources(struct pnp_dev *dev)
102static int pnpacpi_disable_resources(struct pnp_dev *dev) 103static int pnpacpi_disable_resources(struct pnp_dev *dev)
103{ 104{
104 struct acpi_device *acpi_dev; 105 struct acpi_device *acpi_dev;
105 acpi_handle handle;
106 acpi_status status; 106 acpi_status status;
107 107
108 dev_dbg(&dev->dev, "disable resources\n"); 108 dev_dbg(&dev->dev, "disable resources\n");
109 109
110 handle = ACPI_HANDLE(&dev->dev); 110 acpi_dev = ACPI_COMPANION(&dev->dev);
111 if (!handle || acpi_bus_get_device(handle, &acpi_dev)) { 111 if (!acpi_dev) {
112 dev_dbg(&dev->dev, "ACPI device not found in %s!\n", __func__); 112 dev_dbg(&dev->dev, "ACPI device not found in %s!\n", __func__);
113 return 0; 113 return 0;
114 } 114 }
115 115
116 /* acpi_unregister_gsi(pnp_irq(dev, 0)); */ 116 /* acpi_unregister_gsi(pnp_irq(dev, 0)); */
117 if (acpi_bus_power_manageable(handle)) 117 if (acpi_device_power_manageable(acpi_dev))
118 acpi_bus_set_power(handle, ACPI_STATE_D3_COLD); 118 acpi_device_set_power(acpi_dev, ACPI_STATE_D3_COLD);
119 119
120 /* continue even if acpi_bus_set_power() fails */ 120 /* continue even if acpi_device_set_power() fails */
121 status = acpi_evaluate_object(handle, "_DIS", NULL, NULL); 121 status = acpi_evaluate_object(acpi_dev->handle, "_DIS", NULL, NULL);
122 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) 122 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND)
123 return -ENODEV; 123 return -ENODEV;
124 124
@@ -128,26 +128,22 @@ static int pnpacpi_disable_resources(struct pnp_dev *dev)
128#ifdef CONFIG_ACPI_SLEEP 128#ifdef CONFIG_ACPI_SLEEP
129static bool pnpacpi_can_wakeup(struct pnp_dev *dev) 129static bool pnpacpi_can_wakeup(struct pnp_dev *dev)
130{ 130{
131 struct acpi_device *acpi_dev; 131 struct acpi_device *acpi_dev = ACPI_COMPANION(&dev->dev);
132 acpi_handle handle;
133 132
134 handle = ACPI_HANDLE(&dev->dev); 133 if (!acpi_dev) {
135 if (!handle || acpi_bus_get_device(handle, &acpi_dev)) {
136 dev_dbg(&dev->dev, "ACPI device not found in %s!\n", __func__); 134 dev_dbg(&dev->dev, "ACPI device not found in %s!\n", __func__);
137 return false; 135 return false;
138 } 136 }
139 137
140 return acpi_bus_can_wakeup(handle); 138 return acpi_bus_can_wakeup(acpi_dev->handle);
141} 139}
142 140
143static int pnpacpi_suspend(struct pnp_dev *dev, pm_message_t state) 141static int pnpacpi_suspend(struct pnp_dev *dev, pm_message_t state)
144{ 142{
145 struct acpi_device *acpi_dev; 143 struct acpi_device *acpi_dev = ACPI_COMPANION(&dev->dev);
146 acpi_handle handle;
147 int error = 0; 144 int error = 0;
148 145
149 handle = ACPI_HANDLE(&dev->dev); 146 if (!acpi_dev) {
150 if (!handle || acpi_bus_get_device(handle, &acpi_dev)) {
151 dev_dbg(&dev->dev, "ACPI device not found in %s!\n", __func__); 147 dev_dbg(&dev->dev, "ACPI device not found in %s!\n", __func__);
152 return 0; 148 return 0;
153 } 149 }
@@ -159,7 +155,7 @@ static int pnpacpi_suspend(struct pnp_dev *dev, pm_message_t state)
159 return error; 155 return error;
160 } 156 }
161 157
162 if (acpi_bus_power_manageable(handle)) { 158 if (acpi_device_power_manageable(acpi_dev)) {
163 int power_state = acpi_pm_device_sleep_state(&dev->dev, NULL, 159 int power_state = acpi_pm_device_sleep_state(&dev->dev, NULL,
164 ACPI_STATE_D3_COLD); 160 ACPI_STATE_D3_COLD);
165 if (power_state < 0) 161 if (power_state < 0)
@@ -167,12 +163,12 @@ static int pnpacpi_suspend(struct pnp_dev *dev, pm_message_t state)
167 ACPI_STATE_D0 : ACPI_STATE_D3_COLD; 163 ACPI_STATE_D0 : ACPI_STATE_D3_COLD;
168 164
169 /* 165 /*
170 * acpi_bus_set_power() often fails (keyboard port can't be 166 * acpi_device_set_power() can fail (keyboard port can't be
171 * powered-down?), and in any case, our return value is ignored 167 * powered-down?), and in any case, our return value is ignored
172 * by pnp_bus_suspend(). Hence we don't revert the wakeup 168 * by pnp_bus_suspend(). Hence we don't revert the wakeup
173 * setting if the set_power fails. 169 * setting if the set_power fails.
174 */ 170 */
175 error = acpi_bus_set_power(handle, power_state); 171 error = acpi_device_set_power(acpi_dev, power_state);
176 } 172 }
177 173
178 return error; 174 return error;
@@ -180,11 +176,10 @@ static int pnpacpi_suspend(struct pnp_dev *dev, pm_message_t state)
180 176
181static int pnpacpi_resume(struct pnp_dev *dev) 177static int pnpacpi_resume(struct pnp_dev *dev)
182{ 178{
183 struct acpi_device *acpi_dev; 179 struct acpi_device *acpi_dev = ACPI_COMPANION(&dev->dev);
184 acpi_handle handle = ACPI_HANDLE(&dev->dev);
185 int error = 0; 180 int error = 0;
186 181
187 if (!handle || acpi_bus_get_device(handle, &acpi_dev)) { 182 if (!acpi_dev) {
188 dev_dbg(&dev->dev, "ACPI device not found in %s!\n", __func__); 183 dev_dbg(&dev->dev, "ACPI device not found in %s!\n", __func__);
189 return -ENODEV; 184 return -ENODEV;
190 } 185 }
@@ -192,8 +187,8 @@ static int pnpacpi_resume(struct pnp_dev *dev)
192 if (device_may_wakeup(&dev->dev)) 187 if (device_may_wakeup(&dev->dev))
193 acpi_pm_device_sleep_wake(&dev->dev, false); 188 acpi_pm_device_sleep_wake(&dev->dev, false);
194 189
195 if (acpi_bus_power_manageable(handle)) 190 if (acpi_device_power_manageable(acpi_dev))
196 error = acpi_bus_set_power(handle, ACPI_STATE_D0); 191 error = acpi_device_set_power(acpi_dev, ACPI_STATE_D0);
197 192
198 return error; 193 return error;
199} 194}
@@ -295,9 +290,11 @@ static int __init pnpacpi_add_device(struct acpi_device *device)
295 return error; 290 return error;
296 } 291 }
297 292
293 error = acpi_bind_one(&dev->dev, device);
294
298 num++; 295 num++;
299 296
300 return 0; 297 return error;
301} 298}
302 299
303static acpi_status __init pnpacpi_add_device_handler(acpi_handle handle, 300static acpi_status __init pnpacpi_add_device_handler(acpi_handle handle,
@@ -313,40 +310,6 @@ static acpi_status __init pnpacpi_add_device_handler(acpi_handle handle,
313 return AE_OK; 310 return AE_OK;
314} 311}
315 312
316static int __init acpi_pnp_match(struct device *dev, void *_pnp)
317{
318 struct acpi_device *acpi = to_acpi_device(dev);
319 struct pnp_dev *pnp = _pnp;
320
321 /* true means it matched */
322 return pnp->data == acpi;
323}
324
325static struct acpi_device * __init acpi_pnp_find_companion(struct device *dev)
326{
327 dev = bus_find_device(&acpi_bus_type, NULL, to_pnp_dev(dev),
328 acpi_pnp_match);
329 if (!dev)
330 return NULL;
331
332 put_device(dev);
333 return to_acpi_device(dev);
334}
335
336/* complete initialization of a PNPACPI device includes having
337 * pnpdev->dev.archdata.acpi_handle point to its ACPI sibling.
338 */
339static bool acpi_pnp_bus_match(struct device *dev)
340{
341 return dev->bus == &pnp_bus_type;
342}
343
344static struct acpi_bus_type __initdata acpi_pnp_bus = {
345 .name = "PNP",
346 .match = acpi_pnp_bus_match,
347 .find_companion = acpi_pnp_find_companion,
348};
349
350int pnpacpi_disabled __initdata; 313int pnpacpi_disabled __initdata;
351static int __init pnpacpi_init(void) 314static int __init pnpacpi_init(void)
352{ 315{
@@ -356,10 +319,8 @@ static int __init pnpacpi_init(void)
356 } 319 }
357 printk(KERN_INFO "pnp: PnP ACPI init\n"); 320 printk(KERN_INFO "pnp: PnP ACPI init\n");
358 pnp_register_protocol(&pnpacpi_protocol); 321 pnp_register_protocol(&pnpacpi_protocol);
359 register_acpi_bus_type(&acpi_pnp_bus);
360 acpi_get_devices(NULL, pnpacpi_add_device_handler, NULL, NULL); 322 acpi_get_devices(NULL, pnpacpi_add_device_handler, NULL, NULL);
361 printk(KERN_INFO "pnp: PnP ACPI: found %d devices\n", num); 323 printk(KERN_INFO "pnp: PnP ACPI: found %d devices\n", num);
362 unregister_acpi_bus_type(&acpi_pnp_bus);
363 pnp_platform_devices = 1; 324 pnp_platform_devices = 1;
364 return 0; 325 return 0;
365} 326}