aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2014-06-20 00:58:57 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2014-06-20 00:58:57 -0400
commit3c8fb50445833b93f69b6b703a29aae3523cad0c (patch)
treeb865e35364eb5dd68ca29bcab1775fb6c01a3263
parent4ef61076f849ce13af88670f7362a5c9477c2747 (diff)
parent2ba87ea132a7364dbeb71126f3d7b8ec8e59d0e9 (diff)
Merge tag 'pm+acpi-3.16-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm
Pull ACPI and power management fixes from Rafael Wysocki: "These are fixes mostly (ia64 regression related to the ACPI enumeration of devices, cpufreq regressions, fix for I2C controllers included in Intel SoCs, mvebu cpuidle driver fix related to sysfs) plus additional kernel command line arguments from Kees to make it possible to build kernel images with hibernation and the kernel address space randomization included simultaneously, a new ACPI battery driver quirk for a system with a broken BIOS and a couple of ACPI core cleanups. Specifics: - Fix for an ia64 regression introduced during the 3.11 cycle by a commit that modified the hardware initialization ordering and made device discovery fail on some systems. - Fix for a build problem on systems where the cpufreq-cpu0 driver is built-in and the cpu-thermal driver is modular from Arnd Bergmann. - Fix for a recently introduced computational mistake in the intel_pstate driver that leads to excessive rounding errors from Doug Smythies. - Fix for a failure code path in cpufreq_update_policy() that fails to unlock the locks acquired previously from Aaron Plattner. - Fix for the cpuidle mvebu driver to use shorter state names which will prevent the sysfs interface from returning mangled strings. From Gregory Clement. - ACPI LPSS driver fix to make sure that the I2C controllers included in BayTrail SoCs are not held in the reset state while they are being probed from Mika Westerberg. - New kernel command line arguments making it possible to build kernel images with hibernation and kASLR included at the same time and to select which of them will be used via the command line (they are still functionally mutually exclusive, though). From Kees Cook. - ACPI battery driver quirk for Acer Aspire V5-573G that fails to send battery status change notifications timely from Alexander Mezin. - Two ACPI core cleanups from Christoph Jaeger and Fabian Frederick" * tag 'pm+acpi-3.16-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: cpuidle: mvebu: Fix the name of the states cpufreq: unlock when failing cpufreq_update_policy() intel_pstate: Correct rounding in busy calculation ACPI: use kstrto*() instead of simple_strto*() ACPI / processor replace __attribute__((packed)) by __packed ACPI / battery: add quirk for Acer Aspire V5-573G ACPI / battery: use callback for setting up quirks ACPI / LPSS: Take I2C host controllers out of reset x86, kaslr: boot-time selectable with hibernation PM / hibernate: introduce "nohibernate" boot parameter cpufreq: cpufreq-cpu0: fix CPU_THERMAL dependency ACPI / ia64 / sba_iommu: Restore the working initialization ordering
-rw-r--r--Documentation/kernel-parameters.txt14
-rw-r--r--arch/ia64/hp/common/sba_iommu.c64
-rw-r--r--arch/x86/Kconfig1
-rw-r--r--arch/x86/boot/compressed/aslr.c9
-rw-r--r--drivers/acpi/acpi_lpss.c15
-rw-r--r--drivers/acpi/battery.c39
-rw-r--r--drivers/acpi/osl.c3
-rw-r--r--drivers/acpi/tables.c3
-rw-r--r--drivers/cpufreq/Kconfig2
-rw-r--r--drivers/cpufreq/cpufreq.c10
-rw-r--r--drivers/cpufreq/intel_pstate.c5
-rw-r--r--drivers/cpuidle/cpuidle-armada-370-xp.c4
-rw-r--r--include/acpi/processor.h10
-rw-r--r--include/linux/suspend.h2
-rw-r--r--kernel/power/hibernate.c37
-rw-r--r--kernel/power/main.c6
-rw-r--r--kernel/power/user.c3
17 files changed, 167 insertions, 60 deletions
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
index 6eaa9cdb7094..884904975d0b 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -1474,6 +1474,13 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
1474 js= [HW,JOY] Analog joystick 1474 js= [HW,JOY] Analog joystick
1475 See Documentation/input/joystick.txt. 1475 See Documentation/input/joystick.txt.
1476 1476
1477 kaslr/nokaslr [X86]
1478 Enable/disable kernel and module base offset ASLR
1479 (Address Space Layout Randomization) if built into
1480 the kernel. When CONFIG_HIBERNATION is selected,
1481 kASLR is disabled by default. When kASLR is enabled,
1482 hibernation will be disabled.
1483
1477 keepinitrd [HW,ARM] 1484 keepinitrd [HW,ARM]
1478 1485
1479 kernelcore=nn[KMG] [KNL,X86,IA-64,PPC] This parameter 1486 kernelcore=nn[KMG] [KNL,X86,IA-64,PPC] This parameter
@@ -2110,10 +2117,6 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
2110 noapic [SMP,APIC] Tells the kernel to not make use of any 2117 noapic [SMP,APIC] Tells the kernel to not make use of any
2111 IOAPICs that may be present in the system. 2118 IOAPICs that may be present in the system.
2112 2119
2113 nokaslr [X86]
2114 Disable kernel and module base offset ASLR (Address
2115 Space Layout Randomization) if built into the kernel.
2116
2117 noautogroup Disable scheduler automatic task group creation. 2120 noautogroup Disable scheduler automatic task group creation.
2118 2121
2119 nobats [PPC] Do not use BATs for mapping kernel lowmem 2122 nobats [PPC] Do not use BATs for mapping kernel lowmem
@@ -2184,6 +2187,8 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
2184 in certain environments such as networked servers or 2187 in certain environments such as networked servers or
2185 real-time systems. 2188 real-time systems.
2186 2189
2190 nohibernate [HIBERNATION] Disable hibernation and resume.
2191
2187 nohz= [KNL] Boottime enable/disable dynamic ticks 2192 nohz= [KNL] Boottime enable/disable dynamic ticks
2188 Valid arguments: on, off 2193 Valid arguments: on, off
2189 Default: on 2194 Default: on
@@ -2980,6 +2985,7 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
2980 noresume Don't check if there's a hibernation image 2985 noresume Don't check if there's a hibernation image
2981 present during boot. 2986 present during boot.
2982 nocompress Don't compress/decompress hibernation images. 2987 nocompress Don't compress/decompress hibernation images.
2988 no Disable hibernation and resume.
2983 2989
2984 retain_initrd [RAM] Keep initrd memory after extraction 2990 retain_initrd [RAM] Keep initrd memory after extraction
2985 2991
diff --git a/arch/ia64/hp/common/sba_iommu.c b/arch/ia64/hp/common/sba_iommu.c
index 1a871b78e570..344387a55406 100644
--- a/arch/ia64/hp/common/sba_iommu.c
+++ b/arch/ia64/hp/common/sba_iommu.c
@@ -242,7 +242,7 @@ struct ioc {
242 struct pci_dev *sac_only_dev; 242 struct pci_dev *sac_only_dev;
243}; 243};
244 244
245static struct ioc *ioc_list; 245static struct ioc *ioc_list, *ioc_found;
246static int reserve_sba_gart = 1; 246static int reserve_sba_gart = 1;
247 247
248static SBA_INLINE void sba_mark_invalid(struct ioc *, dma_addr_t, size_t); 248static SBA_INLINE void sba_mark_invalid(struct ioc *, dma_addr_t, size_t);
@@ -1809,20 +1809,13 @@ static struct ioc_iommu ioc_iommu_info[] __initdata = {
1809 { SX2000_IOC_ID, "sx2000", NULL }, 1809 { SX2000_IOC_ID, "sx2000", NULL },
1810}; 1810};
1811 1811
1812static struct ioc * 1812static void ioc_init(unsigned long hpa, struct ioc *ioc)
1813ioc_init(unsigned long hpa, void *handle)
1814{ 1813{
1815 struct ioc *ioc;
1816 struct ioc_iommu *info; 1814 struct ioc_iommu *info;
1817 1815
1818 ioc = kzalloc(sizeof(*ioc), GFP_KERNEL);
1819 if (!ioc)
1820 return NULL;
1821
1822 ioc->next = ioc_list; 1816 ioc->next = ioc_list;
1823 ioc_list = ioc; 1817 ioc_list = ioc;
1824 1818
1825 ioc->handle = handle;
1826 ioc->ioc_hpa = ioremap(hpa, 0x1000); 1819 ioc->ioc_hpa = ioremap(hpa, 0x1000);
1827 1820
1828 ioc->func_id = READ_REG(ioc->ioc_hpa + IOC_FUNC_ID); 1821 ioc->func_id = READ_REG(ioc->ioc_hpa + IOC_FUNC_ID);
@@ -1863,8 +1856,6 @@ ioc_init(unsigned long hpa, void *handle)
1863 "%s %d.%d HPA 0x%lx IOVA space %dMb at 0x%lx\n", 1856 "%s %d.%d HPA 0x%lx IOVA space %dMb at 0x%lx\n",
1864 ioc->name, (ioc->rev >> 4) & 0xF, ioc->rev & 0xF, 1857 ioc->name, (ioc->rev >> 4) & 0xF, ioc->rev & 0xF,
1865 hpa, ioc->iov_size >> 20, ioc->ibase); 1858 hpa, ioc->iov_size >> 20, ioc->ibase);
1866
1867 return ioc;
1868} 1859}
1869 1860
1870 1861
@@ -2031,22 +2022,21 @@ sba_map_ioc_to_node(struct ioc *ioc, acpi_handle handle)
2031#endif 2022#endif
2032} 2023}
2033 2024
2034static int 2025static void acpi_sba_ioc_add(struct ioc *ioc)
2035acpi_sba_ioc_add(struct acpi_device *device,
2036 const struct acpi_device_id *not_used)
2037{ 2026{
2038 struct ioc *ioc; 2027 acpi_handle handle = ioc->handle;
2039 acpi_status status; 2028 acpi_status status;
2040 u64 hpa, length; 2029 u64 hpa, length;
2041 struct acpi_device_info *adi; 2030 struct acpi_device_info *adi;
2042 2031
2043 status = hp_acpi_csr_space(device->handle, &hpa, &length); 2032 ioc_found = ioc->next;
2033 status = hp_acpi_csr_space(handle, &hpa, &length);
2044 if (ACPI_FAILURE(status)) 2034 if (ACPI_FAILURE(status))
2045 return 1; 2035 goto err;
2046 2036
2047 status = acpi_get_object_info(device->handle, &adi); 2037 status = acpi_get_object_info(handle, &adi);
2048 if (ACPI_FAILURE(status)) 2038 if (ACPI_FAILURE(status))
2049 return 1; 2039 goto err;
2050 2040
2051 /* 2041 /*
2052 * For HWP0001, only SBA appears in ACPI namespace. It encloses the PCI 2042 * For HWP0001, only SBA appears in ACPI namespace. It encloses the PCI
@@ -2067,13 +2057,13 @@ acpi_sba_ioc_add(struct acpi_device *device,
2067 if (!iovp_shift) 2057 if (!iovp_shift)
2068 iovp_shift = 12; 2058 iovp_shift = 12;
2069 2059
2070 ioc = ioc_init(hpa, device->handle); 2060 ioc_init(hpa, ioc);
2071 if (!ioc)
2072 return 1;
2073
2074 /* setup NUMA node association */ 2061 /* setup NUMA node association */
2075 sba_map_ioc_to_node(ioc, device->handle); 2062 sba_map_ioc_to_node(ioc, handle);
2076 return 0; 2063 return;
2064
2065 err:
2066 kfree(ioc);
2077} 2067}
2078 2068
2079static const struct acpi_device_id hp_ioc_iommu_device_ids[] = { 2069static const struct acpi_device_id hp_ioc_iommu_device_ids[] = {
@@ -2081,9 +2071,26 @@ static const struct acpi_device_id hp_ioc_iommu_device_ids[] = {
2081 {"HWP0004", 0}, 2071 {"HWP0004", 0},
2082 {"", 0}, 2072 {"", 0},
2083}; 2073};
2074
2075static int acpi_sba_ioc_attach(struct acpi_device *device,
2076 const struct acpi_device_id *not_used)
2077{
2078 struct ioc *ioc;
2079
2080 ioc = kzalloc(sizeof(*ioc), GFP_KERNEL);
2081 if (!ioc)
2082 return -ENOMEM;
2083
2084 ioc->next = ioc_found;
2085 ioc_found = ioc;
2086 ioc->handle = device->handle;
2087 return 1;
2088}
2089
2090
2084static struct acpi_scan_handler acpi_sba_ioc_handler = { 2091static struct acpi_scan_handler acpi_sba_ioc_handler = {
2085 .ids = hp_ioc_iommu_device_ids, 2092 .ids = hp_ioc_iommu_device_ids,
2086 .attach = acpi_sba_ioc_add, 2093 .attach = acpi_sba_ioc_attach,
2087}; 2094};
2088 2095
2089static int __init acpi_sba_ioc_init_acpi(void) 2096static int __init acpi_sba_ioc_init_acpi(void)
@@ -2118,9 +2125,12 @@ sba_init(void)
2118#endif 2125#endif
2119 2126
2120 /* 2127 /*
2121 * ioc_list should be populated by the acpi_sba_ioc_handler's .attach() 2128 * ioc_found should be populated by the acpi_sba_ioc_handler's .attach()
2122 * routine, but that only happens if acpi_scan_init() has already run. 2129 * routine, but that only happens if acpi_scan_init() has already run.
2123 */ 2130 */
2131 while (ioc_found)
2132 acpi_sba_ioc_add(ioc_found);
2133
2124 if (!ioc_list) { 2134 if (!ioc_list) {
2125#ifdef CONFIG_IA64_GENERIC 2135#ifdef CONFIG_IA64_GENERIC
2126 /* 2136 /*
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index fcefdda5136d..a8f749ef0fdc 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -1672,7 +1672,6 @@ config RELOCATABLE
1672config RANDOMIZE_BASE 1672config RANDOMIZE_BASE
1673 bool "Randomize the address of the kernel image" 1673 bool "Randomize the address of the kernel image"
1674 depends on RELOCATABLE 1674 depends on RELOCATABLE
1675 depends on !HIBERNATION
1676 default n 1675 default n
1677 ---help--- 1676 ---help---
1678 Randomizes the physical and virtual address at which the 1677 Randomizes the physical and virtual address at which the
diff --git a/arch/x86/boot/compressed/aslr.c b/arch/x86/boot/compressed/aslr.c
index 4dbf967da50d..fc6091abedb7 100644
--- a/arch/x86/boot/compressed/aslr.c
+++ b/arch/x86/boot/compressed/aslr.c
@@ -289,10 +289,17 @@ unsigned char *choose_kernel_location(unsigned char *input,
289 unsigned long choice = (unsigned long)output; 289 unsigned long choice = (unsigned long)output;
290 unsigned long random; 290 unsigned long random;
291 291
292#ifdef CONFIG_HIBERNATION
293 if (!cmdline_find_option_bool("kaslr")) {
294 debug_putstr("KASLR disabled by default...\n");
295 goto out;
296 }
297#else
292 if (cmdline_find_option_bool("nokaslr")) { 298 if (cmdline_find_option_bool("nokaslr")) {
293 debug_putstr("KASLR disabled...\n"); 299 debug_putstr("KASLR disabled by cmdline...\n");
294 goto out; 300 goto out;
295 } 301 }
302#endif
296 303
297 /* Record the various known unsafe memory ranges. */ 304 /* Record the various known unsafe memory ranges. */
298 mem_avoid_init((unsigned long)input, input_size, 305 mem_avoid_init((unsigned long)input, input_size,
diff --git a/drivers/acpi/acpi_lpss.c b/drivers/acpi/acpi_lpss.c
index 63407d264885..9cb65b0e7597 100644
--- a/drivers/acpi/acpi_lpss.c
+++ b/drivers/acpi/acpi_lpss.c
@@ -34,6 +34,9 @@ ACPI_MODULE_NAME("acpi_lpss");
34 34
35/* Offsets relative to LPSS_PRIVATE_OFFSET */ 35/* Offsets relative to LPSS_PRIVATE_OFFSET */
36#define LPSS_CLK_DIVIDER_DEF_MASK (BIT(1) | BIT(16)) 36#define LPSS_CLK_DIVIDER_DEF_MASK (BIT(1) | BIT(16))
37#define LPSS_RESETS 0x04
38#define LPSS_RESETS_RESET_FUNC BIT(0)
39#define LPSS_RESETS_RESET_APB BIT(1)
37#define LPSS_GENERAL 0x08 40#define LPSS_GENERAL 0x08
38#define LPSS_GENERAL_LTR_MODE_SW BIT(2) 41#define LPSS_GENERAL_LTR_MODE_SW BIT(2)
39#define LPSS_GENERAL_UART_RTS_OVRD BIT(3) 42#define LPSS_GENERAL_UART_RTS_OVRD BIT(3)
@@ -99,6 +102,17 @@ static void lpss_uart_setup(struct lpss_private_data *pdata)
99 writel(reg | LPSS_GENERAL_UART_RTS_OVRD, pdata->mmio_base + offset); 102 writel(reg | LPSS_GENERAL_UART_RTS_OVRD, pdata->mmio_base + offset);
100} 103}
101 104
105static void lpss_i2c_setup(struct lpss_private_data *pdata)
106{
107 unsigned int offset;
108 u32 val;
109
110 offset = pdata->dev_desc->prv_offset + LPSS_RESETS;
111 val = readl(pdata->mmio_base + offset);
112 val |= LPSS_RESETS_RESET_APB | LPSS_RESETS_RESET_FUNC;
113 writel(val, pdata->mmio_base + offset);
114}
115
102static struct lpss_device_desc lpt_dev_desc = { 116static struct lpss_device_desc lpt_dev_desc = {
103 .clk_required = true, 117 .clk_required = true,
104 .prv_offset = 0x800, 118 .prv_offset = 0x800,
@@ -171,6 +185,7 @@ static struct lpss_device_desc byt_i2c_dev_desc = {
171 .prv_offset = 0x800, 185 .prv_offset = 0x800,
172 .save_ctx = true, 186 .save_ctx = true,
173 .shared_clock = &i2c_clock, 187 .shared_clock = &i2c_clock,
188 .setup = lpss_i2c_setup,
174}; 189};
175 190
176#else 191#else
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index e48fc98e71c4..0d7116f34b95 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -32,6 +32,7 @@
32#include <linux/jiffies.h> 32#include <linux/jiffies.h>
33#include <linux/async.h> 33#include <linux/async.h>
34#include <linux/dmi.h> 34#include <linux/dmi.h>
35#include <linux/delay.h>
35#include <linux/slab.h> 36#include <linux/slab.h>
36#include <linux/suspend.h> 37#include <linux/suspend.h>
37#include <asm/unaligned.h> 38#include <asm/unaligned.h>
@@ -70,6 +71,7 @@ MODULE_DESCRIPTION("ACPI Battery Driver");
70MODULE_LICENSE("GPL"); 71MODULE_LICENSE("GPL");
71 72
72static int battery_bix_broken_package; 73static int battery_bix_broken_package;
74static int battery_notification_delay_ms;
73static unsigned int cache_time = 1000; 75static unsigned int cache_time = 1000;
74module_param(cache_time, uint, 0644); 76module_param(cache_time, uint, 0644);
75MODULE_PARM_DESC(cache_time, "cache time in milliseconds"); 77MODULE_PARM_DESC(cache_time, "cache time in milliseconds");
@@ -930,7 +932,10 @@ static ssize_t acpi_battery_write_alarm(struct file *file,
930 goto end; 932 goto end;
931 } 933 }
932 alarm_string[count] = '\0'; 934 alarm_string[count] = '\0';
933 battery->alarm = simple_strtol(alarm_string, NULL, 0); 935 if (kstrtoint(alarm_string, 0, &battery->alarm)) {
936 result = -EINVAL;
937 goto end;
938 }
934 result = acpi_battery_set_alarm(battery); 939 result = acpi_battery_set_alarm(battery);
935 end: 940 end:
936 if (!result) 941 if (!result)
@@ -1062,6 +1067,14 @@ static void acpi_battery_notify(struct acpi_device *device, u32 event)
1062 if (!battery) 1067 if (!battery)
1063 return; 1068 return;
1064 old = battery->bat.dev; 1069 old = battery->bat.dev;
1070 /*
1071 * On Acer Aspire V5-573G notifications are sometimes triggered too
1072 * early. For example, when AC is unplugged and notification is
1073 * triggered, battery state is still reported as "Full", and changes to
1074 * "Discharging" only after short delay, without any notification.
1075 */
1076 if (battery_notification_delay_ms > 0)
1077 msleep(battery_notification_delay_ms);
1065 if (event == ACPI_BATTERY_NOTIFY_INFO) 1078 if (event == ACPI_BATTERY_NOTIFY_INFO)
1066 acpi_battery_refresh(battery); 1079 acpi_battery_refresh(battery);
1067 acpi_battery_update(battery, false); 1080 acpi_battery_update(battery, false);
@@ -1106,14 +1119,35 @@ static int battery_notify(struct notifier_block *nb,
1106 return 0; 1119 return 0;
1107} 1120}
1108 1121
1122static int battery_bix_broken_package_quirk(const struct dmi_system_id *d)
1123{
1124 battery_bix_broken_package = 1;
1125 return 0;
1126}
1127
1128static int battery_notification_delay_quirk(const struct dmi_system_id *d)
1129{
1130 battery_notification_delay_ms = 1000;
1131 return 0;
1132}
1133
1109static struct dmi_system_id bat_dmi_table[] = { 1134static struct dmi_system_id bat_dmi_table[] = {
1110 { 1135 {
1136 .callback = battery_bix_broken_package_quirk,
1111 .ident = "NEC LZ750/LS", 1137 .ident = "NEC LZ750/LS",
1112 .matches = { 1138 .matches = {
1113 DMI_MATCH(DMI_SYS_VENDOR, "NEC"), 1139 DMI_MATCH(DMI_SYS_VENDOR, "NEC"),
1114 DMI_MATCH(DMI_PRODUCT_NAME, "PC-LZ750LS"), 1140 DMI_MATCH(DMI_PRODUCT_NAME, "PC-LZ750LS"),
1115 }, 1141 },
1116 }, 1142 },
1143 {
1144 .callback = battery_notification_delay_quirk,
1145 .ident = "Acer Aspire V5-573G",
1146 .matches = {
1147 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
1148 DMI_MATCH(DMI_PRODUCT_NAME, "Aspire V5-573G"),
1149 },
1150 },
1117 {}, 1151 {},
1118}; 1152};
1119 1153
@@ -1227,8 +1261,7 @@ static void __init acpi_battery_init_async(void *unused, async_cookie_t cookie)
1227 if (acpi_disabled) 1261 if (acpi_disabled)
1228 return; 1262 return;
1229 1263
1230 if (dmi_check_system(bat_dmi_table)) 1264 dmi_check_system(bat_dmi_table);
1231 battery_bix_broken_package = 1;
1232 1265
1233#ifdef CONFIG_ACPI_PROCFS_POWER 1266#ifdef CONFIG_ACPI_PROCFS_POWER
1234 acpi_battery_dir = acpi_lock_battery_dir(); 1267 acpi_battery_dir = acpi_lock_battery_dir();
diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c
index 3f2bdc812d23..bad25b070fe0 100644
--- a/drivers/acpi/osl.c
+++ b/drivers/acpi/osl.c
@@ -235,7 +235,8 @@ void acpi_os_vprintf(const char *fmt, va_list args)
235static unsigned long acpi_rsdp; 235static unsigned long acpi_rsdp;
236static int __init setup_acpi_rsdp(char *arg) 236static int __init setup_acpi_rsdp(char *arg)
237{ 237{
238 acpi_rsdp = simple_strtoul(arg, NULL, 16); 238 if (kstrtoul(arg, 16, &acpi_rsdp))
239 return -EINVAL;
239 return 0; 240 return 0;
240} 241}
241early_param("acpi_rsdp", setup_acpi_rsdp); 242early_param("acpi_rsdp", setup_acpi_rsdp);
diff --git a/drivers/acpi/tables.c b/drivers/acpi/tables.c
index 05550ba44d32..6d5a6cda0734 100644
--- a/drivers/acpi/tables.c
+++ b/drivers/acpi/tables.c
@@ -360,7 +360,8 @@ static int __init acpi_parse_apic_instance(char *str)
360 if (!str) 360 if (!str)
361 return -EINVAL; 361 return -EINVAL;
362 362
363 acpi_apic_instance = simple_strtoul(str, NULL, 0); 363 if (kstrtoint(str, 0, &acpi_apic_instance))
364 return -EINVAL;
364 365
365 pr_notice("Shall use APIC/MADT table %d\n", acpi_apic_instance); 366 pr_notice("Shall use APIC/MADT table %d\n", acpi_apic_instance);
366 367
diff --git a/drivers/cpufreq/Kconfig b/drivers/cpufreq/Kconfig
index e473d6555f96..ffe350f86bca 100644
--- a/drivers/cpufreq/Kconfig
+++ b/drivers/cpufreq/Kconfig
@@ -186,6 +186,8 @@ config CPU_FREQ_GOV_CONSERVATIVE
186config GENERIC_CPUFREQ_CPU0 186config GENERIC_CPUFREQ_CPU0
187 tristate "Generic CPU0 cpufreq driver" 187 tristate "Generic CPU0 cpufreq driver"
188 depends on HAVE_CLK && OF 188 depends on HAVE_CLK && OF
189 # if CPU_THERMAL is on and THERMAL=m, CPU0 cannot be =y:
190 depends on !CPU_THERMAL || THERMAL
189 select PM_OPP 191 select PM_OPP
190 help 192 help
191 This adds a generic cpufreq driver for CPU0 frequency management. 193 This adds a generic cpufreq driver for CPU0 frequency management.
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index aed2b0cb83dc..62259d27f03e 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -2242,10 +2242,8 @@ int cpufreq_update_policy(unsigned int cpu)
2242 struct cpufreq_policy new_policy; 2242 struct cpufreq_policy new_policy;
2243 int ret; 2243 int ret;
2244 2244
2245 if (!policy) { 2245 if (!policy)
2246 ret = -ENODEV; 2246 return -ENODEV;
2247 goto no_policy;
2248 }
2249 2247
2250 down_write(&policy->rwsem); 2248 down_write(&policy->rwsem);
2251 2249
@@ -2264,7 +2262,7 @@ int cpufreq_update_policy(unsigned int cpu)
2264 new_policy.cur = cpufreq_driver->get(cpu); 2262 new_policy.cur = cpufreq_driver->get(cpu);
2265 if (WARN_ON(!new_policy.cur)) { 2263 if (WARN_ON(!new_policy.cur)) {
2266 ret = -EIO; 2264 ret = -EIO;
2267 goto no_policy; 2265 goto unlock;
2268 } 2266 }
2269 2267
2270 if (!policy->cur) { 2268 if (!policy->cur) {
@@ -2279,10 +2277,10 @@ int cpufreq_update_policy(unsigned int cpu)
2279 2277
2280 ret = cpufreq_set_policy(policy, &new_policy); 2278 ret = cpufreq_set_policy(policy, &new_policy);
2281 2279
2280unlock:
2282 up_write(&policy->rwsem); 2281 up_write(&policy->rwsem);
2283 2282
2284 cpufreq_cpu_put(policy); 2283 cpufreq_cpu_put(policy);
2285no_policy:
2286 return ret; 2284 return ret;
2287} 2285}
2288EXPORT_SYMBOL(cpufreq_update_policy); 2286EXPORT_SYMBOL(cpufreq_update_policy);
diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
index 4e7f492ad583..924bb2d42b1c 100644
--- a/drivers/cpufreq/intel_pstate.c
+++ b/drivers/cpufreq/intel_pstate.c
@@ -196,10 +196,7 @@ static signed int pid_calc(struct _pid *pid, int32_t busy)
196 pid->last_err = fp_error; 196 pid->last_err = fp_error;
197 197
198 result = pterm + mul_fp(pid->integral, pid->i_gain) + dterm; 198 result = pterm + mul_fp(pid->integral, pid->i_gain) + dterm;
199 if (result >= 0) 199 result = result + (1 << (FRAC_BITS-1));
200 result = result + (1 << (FRAC_BITS-1));
201 else
202 result = result - (1 << (FRAC_BITS-1));
203 return (signed int)fp_toint(result); 200 return (signed int)fp_toint(result);
204} 201}
205 202
diff --git a/drivers/cpuidle/cpuidle-armada-370-xp.c b/drivers/cpuidle/cpuidle-armada-370-xp.c
index 28587d0f3947..a5fba0287bfb 100644
--- a/drivers/cpuidle/cpuidle-armada-370-xp.c
+++ b/drivers/cpuidle/cpuidle-armada-370-xp.c
@@ -55,7 +55,7 @@ static struct cpuidle_driver armada_370_xp_idle_driver = {
55 .power_usage = 50, 55 .power_usage = 50,
56 .target_residency = 100, 56 .target_residency = 100,
57 .flags = CPUIDLE_FLAG_TIME_VALID, 57 .flags = CPUIDLE_FLAG_TIME_VALID,
58 .name = "MV CPU IDLE", 58 .name = "Idle",
59 .desc = "CPU power down", 59 .desc = "CPU power down",
60 }, 60 },
61 .states[2] = { 61 .states[2] = {
@@ -65,7 +65,7 @@ static struct cpuidle_driver armada_370_xp_idle_driver = {
65 .target_residency = 1000, 65 .target_residency = 1000,
66 .flags = CPUIDLE_FLAG_TIME_VALID | 66 .flags = CPUIDLE_FLAG_TIME_VALID |
67 ARMADA_370_XP_FLAG_DEEP_IDLE, 67 ARMADA_370_XP_FLAG_DEEP_IDLE,
68 .name = "MV CPU DEEP IDLE", 68 .name = "Deep idle",
69 .desc = "CPU and L2 Fabric power down", 69 .desc = "CPU and L2 Fabric power down",
70 }, 70 },
71 .state_count = ARMADA_370_XP_MAX_STATES, 71 .state_count = ARMADA_370_XP_MAX_STATES,
diff --git a/include/acpi/processor.h b/include/acpi/processor.h
index 6eb1d3cb5104..9b9b6f29bbf3 100644
--- a/include/acpi/processor.h
+++ b/include/acpi/processor.h
@@ -53,7 +53,7 @@ struct acpi_power_register {
53 u8 bit_offset; 53 u8 bit_offset;
54 u8 access_size; 54 u8 access_size;
55 u64 address; 55 u64 address;
56} __attribute__ ((packed)); 56} __packed;
57 57
58struct acpi_processor_cx { 58struct acpi_processor_cx {
59 u8 valid; 59 u8 valid;
@@ -83,7 +83,7 @@ struct acpi_psd_package {
83 u64 domain; 83 u64 domain;
84 u64 coord_type; 84 u64 coord_type;
85 u64 num_processors; 85 u64 num_processors;
86} __attribute__ ((packed)); 86} __packed;
87 87
88struct acpi_pct_register { 88struct acpi_pct_register {
89 u8 descriptor; 89 u8 descriptor;
@@ -93,7 +93,7 @@ struct acpi_pct_register {
93 u8 bit_offset; 93 u8 bit_offset;
94 u8 reserved; 94 u8 reserved;
95 u64 address; 95 u64 address;
96} __attribute__ ((packed)); 96} __packed;
97 97
98struct acpi_processor_px { 98struct acpi_processor_px {
99 u64 core_frequency; /* megahertz */ 99 u64 core_frequency; /* megahertz */
@@ -124,7 +124,7 @@ struct acpi_tsd_package {
124 u64 domain; 124 u64 domain;
125 u64 coord_type; 125 u64 coord_type;
126 u64 num_processors; 126 u64 num_processors;
127} __attribute__ ((packed)); 127} __packed;
128 128
129struct acpi_ptc_register { 129struct acpi_ptc_register {
130 u8 descriptor; 130 u8 descriptor;
@@ -134,7 +134,7 @@ struct acpi_ptc_register {
134 u8 bit_offset; 134 u8 bit_offset;
135 u8 reserved; 135 u8 reserved;
136 u64 address; 136 u64 address;
137} __attribute__ ((packed)); 137} __packed;
138 138
139struct acpi_processor_tx_tss { 139struct acpi_processor_tx_tss {
140 u64 freqpercentage; /* */ 140 u64 freqpercentage; /* */
diff --git a/include/linux/suspend.h b/include/linux/suspend.h
index f76994b9396c..519064e0c943 100644
--- a/include/linux/suspend.h
+++ b/include/linux/suspend.h
@@ -327,6 +327,7 @@ extern unsigned long get_safe_page(gfp_t gfp_mask);
327extern void hibernation_set_ops(const struct platform_hibernation_ops *ops); 327extern void hibernation_set_ops(const struct platform_hibernation_ops *ops);
328extern int hibernate(void); 328extern int hibernate(void);
329extern bool system_entering_hibernation(void); 329extern bool system_entering_hibernation(void);
330extern bool hibernation_available(void);
330asmlinkage int swsusp_save(void); 331asmlinkage int swsusp_save(void);
331extern struct pbe *restore_pblist; 332extern struct pbe *restore_pblist;
332#else /* CONFIG_HIBERNATION */ 333#else /* CONFIG_HIBERNATION */
@@ -339,6 +340,7 @@ static inline void swsusp_unset_page_free(struct page *p) {}
339static inline void hibernation_set_ops(const struct platform_hibernation_ops *ops) {} 340static inline void hibernation_set_ops(const struct platform_hibernation_ops *ops) {}
340static inline int hibernate(void) { return -ENOSYS; } 341static inline int hibernate(void) { return -ENOSYS; }
341static inline bool system_entering_hibernation(void) { return false; } 342static inline bool system_entering_hibernation(void) { return false; }
343static inline bool hibernation_available(void) { return false; }
342#endif /* CONFIG_HIBERNATION */ 344#endif /* CONFIG_HIBERNATION */
343 345
344/* Hibernation and suspend events */ 346/* Hibernation and suspend events */
diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c
index 49e0a20fd010..fcc2611d3f14 100644
--- a/kernel/power/hibernate.c
+++ b/kernel/power/hibernate.c
@@ -35,6 +35,7 @@
35 35
36static int nocompress; 36static int nocompress;
37static int noresume; 37static int noresume;
38static int nohibernate;
38static int resume_wait; 39static int resume_wait;
39static unsigned int resume_delay; 40static unsigned int resume_delay;
40static char resume_file[256] = CONFIG_PM_STD_PARTITION; 41static char resume_file[256] = CONFIG_PM_STD_PARTITION;
@@ -62,6 +63,11 @@ bool freezer_test_done;
62 63
63static const struct platform_hibernation_ops *hibernation_ops; 64static const struct platform_hibernation_ops *hibernation_ops;
64 65
66bool hibernation_available(void)
67{
68 return (nohibernate == 0);
69}
70
65/** 71/**
66 * hibernation_set_ops - Set the global hibernate operations. 72 * hibernation_set_ops - Set the global hibernate operations.
67 * @ops: Hibernation operations to use in subsequent hibernation transitions. 73 * @ops: Hibernation operations to use in subsequent hibernation transitions.
@@ -642,6 +648,11 @@ int hibernate(void)
642{ 648{
643 int error; 649 int error;
644 650
651 if (!hibernation_available()) {
652 pr_debug("PM: Hibernation not available.\n");
653 return -EPERM;
654 }
655
645 lock_system_sleep(); 656 lock_system_sleep();
646 /* The snapshot device should not be opened while we're running */ 657 /* The snapshot device should not be opened while we're running */
647 if (!atomic_add_unless(&snapshot_device_available, -1, 0)) { 658 if (!atomic_add_unless(&snapshot_device_available, -1, 0)) {
@@ -734,7 +745,7 @@ static int software_resume(void)
734 /* 745 /*
735 * If the user said "noresume".. bail out early. 746 * If the user said "noresume".. bail out early.
736 */ 747 */
737 if (noresume) 748 if (noresume || !hibernation_available())
738 return 0; 749 return 0;
739 750
740 /* 751 /*
@@ -900,6 +911,9 @@ static ssize_t disk_show(struct kobject *kobj, struct kobj_attribute *attr,
900 int i; 911 int i;
901 char *start = buf; 912 char *start = buf;
902 913
914 if (!hibernation_available())
915 return sprintf(buf, "[disabled]\n");
916
903 for (i = HIBERNATION_FIRST; i <= HIBERNATION_MAX; i++) { 917 for (i = HIBERNATION_FIRST; i <= HIBERNATION_MAX; i++) {
904 if (!hibernation_modes[i]) 918 if (!hibernation_modes[i])
905 continue; 919 continue;
@@ -934,6 +948,9 @@ static ssize_t disk_store(struct kobject *kobj, struct kobj_attribute *attr,
934 char *p; 948 char *p;
935 int mode = HIBERNATION_INVALID; 949 int mode = HIBERNATION_INVALID;
936 950
951 if (!hibernation_available())
952 return -EPERM;
953
937 p = memchr(buf, '\n', n); 954 p = memchr(buf, '\n', n);
938 len = p ? p - buf : n; 955 len = p ? p - buf : n;
939 956
@@ -1101,6 +1118,10 @@ static int __init hibernate_setup(char *str)
1101 noresume = 1; 1118 noresume = 1;
1102 else if (!strncmp(str, "nocompress", 10)) 1119 else if (!strncmp(str, "nocompress", 10))
1103 nocompress = 1; 1120 nocompress = 1;
1121 else if (!strncmp(str, "no", 2)) {
1122 noresume = 1;
1123 nohibernate = 1;
1124 }
1104 return 1; 1125 return 1;
1105} 1126}
1106 1127
@@ -1125,9 +1146,23 @@ static int __init resumedelay_setup(char *str)
1125 return 1; 1146 return 1;
1126} 1147}
1127 1148
1149static int __init nohibernate_setup(char *str)
1150{
1151 noresume = 1;
1152 nohibernate = 1;
1153 return 1;
1154}
1155
1156static int __init kaslr_nohibernate_setup(char *str)
1157{
1158 return nohibernate_setup(str);
1159}
1160
1128__setup("noresume", noresume_setup); 1161__setup("noresume", noresume_setup);
1129__setup("resume_offset=", resume_offset_setup); 1162__setup("resume_offset=", resume_offset_setup);
1130__setup("resume=", resume_setup); 1163__setup("resume=", resume_setup);
1131__setup("hibernate=", hibernate_setup); 1164__setup("hibernate=", hibernate_setup);
1132__setup("resumewait", resumewait_setup); 1165__setup("resumewait", resumewait_setup);
1133__setup("resumedelay=", resumedelay_setup); 1166__setup("resumedelay=", resumedelay_setup);
1167__setup("nohibernate", nohibernate_setup);
1168__setup("kaslr", kaslr_nohibernate_setup);
diff --git a/kernel/power/main.c b/kernel/power/main.c
index 573410d6647e..8e90f330f139 100644
--- a/kernel/power/main.c
+++ b/kernel/power/main.c
@@ -300,13 +300,11 @@ static ssize_t state_show(struct kobject *kobj, struct kobj_attribute *attr,
300 s += sprintf(s,"%s ", pm_states[i].label); 300 s += sprintf(s,"%s ", pm_states[i].label);
301 301
302#endif 302#endif
303#ifdef CONFIG_HIBERNATION 303 if (hibernation_available())
304 s += sprintf(s, "%s\n", "disk"); 304 s += sprintf(s, "disk ");
305#else
306 if (s != buf) 305 if (s != buf)
307 /* convert the last space to a newline */ 306 /* convert the last space to a newline */
308 *(s-1) = '\n'; 307 *(s-1) = '\n';
309#endif
310 return (s - buf); 308 return (s - buf);
311} 309}
312 310
diff --git a/kernel/power/user.c b/kernel/power/user.c
index 98d357584cd6..526e8911460a 100644
--- a/kernel/power/user.c
+++ b/kernel/power/user.c
@@ -49,6 +49,9 @@ static int snapshot_open(struct inode *inode, struct file *filp)
49 struct snapshot_data *data; 49 struct snapshot_data *data;
50 int error; 50 int error;
51 51
52 if (!hibernation_available())
53 return -EPERM;
54
52 lock_system_sleep(); 55 lock_system_sleep();
53 56
54 if (!atomic_add_unless(&snapshot_device_available, -1, 0)) { 57 if (!atomic_add_unless(&snapshot_device_available, -1, 0)) {