aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/acpi')
-rw-r--r--drivers/acpi/acpi_pad.c37
-rw-r--r--drivers/acpi/sleep.c29
-rw-r--r--drivers/acpi/video.c51
3 files changed, 87 insertions, 30 deletions
diff --git a/drivers/acpi/acpi_pad.c b/drivers/acpi/acpi_pad.c
index 97991ac6f5fc..7e52295f1ecc 100644
--- a/drivers/acpi/acpi_pad.c
+++ b/drivers/acpi/acpi_pad.c
@@ -208,7 +208,7 @@ static int power_saving_thread(void *data)
208 * the mechanism only works when all CPUs have RT task running, 208 * the mechanism only works when all CPUs have RT task running,
209 * as if one CPU hasn't RT task, RT task from other CPUs will 209 * as if one CPU hasn't RT task, RT task from other CPUs will
210 * borrow CPU time from this CPU and cause RT task use > 95% 210 * borrow CPU time from this CPU and cause RT task use > 95%
211 * CPU time. To make 'avoid staration' work, takes a nap here. 211 * CPU time. To make 'avoid starvation' work, takes a nap here.
212 */ 212 */
213 if (do_sleep) 213 if (do_sleep)
214 schedule_timeout_killable(HZ * idle_pct / 100); 214 schedule_timeout_killable(HZ * idle_pct / 100);
@@ -222,14 +222,18 @@ static struct task_struct *ps_tsks[NR_CPUS];
222static unsigned int ps_tsk_num; 222static unsigned int ps_tsk_num;
223static int create_power_saving_task(void) 223static int create_power_saving_task(void)
224{ 224{
225 int rc = -ENOMEM;
226
225 ps_tsks[ps_tsk_num] = kthread_run(power_saving_thread, 227 ps_tsks[ps_tsk_num] = kthread_run(power_saving_thread,
226 (void *)(unsigned long)ps_tsk_num, 228 (void *)(unsigned long)ps_tsk_num,
227 "power_saving/%d", ps_tsk_num); 229 "power_saving/%d", ps_tsk_num);
228 if (ps_tsks[ps_tsk_num]) { 230 rc = IS_ERR(ps_tsks[ps_tsk_num]) ? PTR_ERR(ps_tsks[ps_tsk_num]) : 0;
231 if (!rc)
229 ps_tsk_num++; 232 ps_tsk_num++;
230 return 0; 233 else
231 } 234 ps_tsks[ps_tsk_num] = NULL;
232 return -EINVAL; 235
236 return rc;
233} 237}
234 238
235static void destroy_power_saving_task(void) 239static void destroy_power_saving_task(void)
@@ -237,6 +241,7 @@ static void destroy_power_saving_task(void)
237 if (ps_tsk_num > 0) { 241 if (ps_tsk_num > 0) {
238 ps_tsk_num--; 242 ps_tsk_num--;
239 kthread_stop(ps_tsks[ps_tsk_num]); 243 kthread_stop(ps_tsks[ps_tsk_num]);
244 ps_tsks[ps_tsk_num] = NULL;
240 } 245 }
241} 246}
242 247
@@ -253,7 +258,7 @@ static void set_power_saving_task_num(unsigned int num)
253 } 258 }
254} 259}
255 260
256static int acpi_pad_idle_cpus(unsigned int num_cpus) 261static void acpi_pad_idle_cpus(unsigned int num_cpus)
257{ 262{
258 get_online_cpus(); 263 get_online_cpus();
259 264
@@ -261,7 +266,6 @@ static int acpi_pad_idle_cpus(unsigned int num_cpus)
261 set_power_saving_task_num(num_cpus); 266 set_power_saving_task_num(num_cpus);
262 267
263 put_online_cpus(); 268 put_online_cpus();
264 return 0;
265} 269}
266 270
267static uint32_t acpi_pad_idle_cpus_num(void) 271static uint32_t acpi_pad_idle_cpus_num(void)
@@ -369,19 +373,21 @@ static void acpi_pad_remove_sysfs(struct acpi_device *device)
369static int acpi_pad_pur(acpi_handle handle, int *num_cpus) 373static int acpi_pad_pur(acpi_handle handle, int *num_cpus)
370{ 374{
371 struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL}; 375 struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL};
372 acpi_status status;
373 union acpi_object *package; 376 union acpi_object *package;
374 int rev, num, ret = -EINVAL; 377 int rev, num, ret = -EINVAL;
375 378
376 status = acpi_evaluate_object(handle, "_PUR", NULL, &buffer); 379 if (ACPI_FAILURE(acpi_evaluate_object(handle, "_PUR", NULL, &buffer)))
377 if (ACPI_FAILURE(status)) 380 return -EINVAL;
381
382 if (!buffer.length || !buffer.pointer)
378 return -EINVAL; 383 return -EINVAL;
384
379 package = buffer.pointer; 385 package = buffer.pointer;
380 if (package->type != ACPI_TYPE_PACKAGE || package->package.count != 2) 386 if (package->type != ACPI_TYPE_PACKAGE || package->package.count != 2)
381 goto out; 387 goto out;
382 rev = package->package.elements[0].integer.value; 388 rev = package->package.elements[0].integer.value;
383 num = package->package.elements[1].integer.value; 389 num = package->package.elements[1].integer.value;
384 if (rev != 1) 390 if (rev != 1 || num < 0)
385 goto out; 391 goto out;
386 *num_cpus = num; 392 *num_cpus = num;
387 ret = 0; 393 ret = 0;
@@ -410,7 +416,7 @@ static void acpi_pad_ost(acpi_handle handle, int stat,
410 416
411static void acpi_pad_handle_notify(acpi_handle handle) 417static void acpi_pad_handle_notify(acpi_handle handle)
412{ 418{
413 int num_cpus, ret; 419 int num_cpus;
414 uint32_t idle_cpus; 420 uint32_t idle_cpus;
415 421
416 mutex_lock(&isolated_cpus_lock); 422 mutex_lock(&isolated_cpus_lock);
@@ -418,12 +424,9 @@ static void acpi_pad_handle_notify(acpi_handle handle)
418 mutex_unlock(&isolated_cpus_lock); 424 mutex_unlock(&isolated_cpus_lock);
419 return; 425 return;
420 } 426 }
421 ret = acpi_pad_idle_cpus(num_cpus); 427 acpi_pad_idle_cpus(num_cpus);
422 idle_cpus = acpi_pad_idle_cpus_num(); 428 idle_cpus = acpi_pad_idle_cpus_num();
423 if (!ret) 429 acpi_pad_ost(handle, 0, idle_cpus);
424 acpi_pad_ost(handle, 0, idle_cpus);
425 else
426 acpi_pad_ost(handle, 1, 0);
427 mutex_unlock(&isolated_cpus_lock); 430 mutex_unlock(&isolated_cpus_lock);
428} 431}
429 432
diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c
index 5f2c379ab7bf..79d33d908b5a 100644
--- a/drivers/acpi/sleep.c
+++ b/drivers/acpi/sleep.c
@@ -81,6 +81,23 @@ static int acpi_sleep_prepare(u32 acpi_state)
81#ifdef CONFIG_ACPI_SLEEP 81#ifdef CONFIG_ACPI_SLEEP
82static u32 acpi_target_sleep_state = ACPI_STATE_S0; 82static u32 acpi_target_sleep_state = ACPI_STATE_S0;
83/* 83/*
84 * According to the ACPI specification the BIOS should make sure that ACPI is
85 * enabled and SCI_EN bit is set on wake-up from S1 - S3 sleep states. Still,
86 * some BIOSes don't do that and therefore we use acpi_enable() to enable ACPI
87 * on such systems during resume. Unfortunately that doesn't help in
88 * particularly pathological cases in which SCI_EN has to be set directly on
89 * resume, although the specification states very clearly that this flag is
90 * owned by the hardware. The set_sci_en_on_resume variable will be set in such
91 * cases.
92 */
93static bool set_sci_en_on_resume;
94
95void __init acpi_set_sci_en_on_resume(void)
96{
97 set_sci_en_on_resume = true;
98}
99
100/*
84 * ACPI 1.0 wants us to execute _PTS before suspending devices, so we allow the 101 * ACPI 1.0 wants us to execute _PTS before suspending devices, so we allow the
85 * user to request that behavior by using the 'acpi_old_suspend_ordering' 102 * user to request that behavior by using the 'acpi_old_suspend_ordering'
86 * kernel command line option that causes the following variable to be set. 103 * kernel command line option that causes the following variable to be set.
@@ -170,18 +187,6 @@ static void acpi_pm_end(void)
170#endif /* CONFIG_ACPI_SLEEP */ 187#endif /* CONFIG_ACPI_SLEEP */
171 188
172#ifdef CONFIG_SUSPEND 189#ifdef CONFIG_SUSPEND
173/*
174 * According to the ACPI specification the BIOS should make sure that ACPI is
175 * enabled and SCI_EN bit is set on wake-up from S1 - S3 sleep states. Still,
176 * some BIOSes don't do that and therefore we use acpi_enable() to enable ACPI
177 * on such systems during resume. Unfortunately that doesn't help in
178 * particularly pathological cases in which SCI_EN has to be set directly on
179 * resume, although the specification states very clearly that this flag is
180 * owned by the hardware. The set_sci_en_on_resume variable will be set in such
181 * cases.
182 */
183static bool set_sci_en_on_resume;
184
185extern void do_suspend_lowlevel(void); 190extern void do_suspend_lowlevel(void);
186 191
187static u32 acpi_suspend_states[] = { 192static u32 acpi_suspend_states[] = {
diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c
index 05dff631591c..b765790b32be 100644
--- a/drivers/acpi/video.c
+++ b/drivers/acpi/video.c
@@ -78,6 +78,13 @@ MODULE_LICENSE("GPL");
78static int brightness_switch_enabled = 1; 78static int brightness_switch_enabled = 1;
79module_param(brightness_switch_enabled, bool, 0644); 79module_param(brightness_switch_enabled, bool, 0644);
80 80
81/*
82 * By default, we don't allow duplicate ACPI video bus devices
83 * under the same VGA controller
84 */
85static int allow_duplicates;
86module_param(allow_duplicates, bool, 0644);
87
81static int register_count = 0; 88static int register_count = 0;
82static int acpi_video_bus_add(struct acpi_device *device); 89static int acpi_video_bus_add(struct acpi_device *device);
83static int acpi_video_bus_remove(struct acpi_device *device, int type); 90static int acpi_video_bus_remove(struct acpi_device *device, int type);
@@ -999,8 +1006,10 @@ static void acpi_video_device_find_cap(struct acpi_video_device *device)
999 sprintf(name, "acpi_video%d", count++); 1006 sprintf(name, "acpi_video%d", count++);
1000 device->backlight = backlight_device_register(name, 1007 device->backlight = backlight_device_register(name,
1001 NULL, device, &acpi_backlight_ops); 1008 NULL, device, &acpi_backlight_ops);
1002 device->backlight->props.max_brightness = device->brightness->count-3;
1003 kfree(name); 1009 kfree(name);
1010 if (IS_ERR(device->backlight))
1011 return;
1012 device->backlight->props.max_brightness = device->brightness->count-3;
1004 1013
1005 result = sysfs_create_link(&device->backlight->dev.kobj, 1014 result = sysfs_create_link(&device->backlight->dev.kobj,
1006 &device->dev->dev.kobj, "device"); 1015 &device->dev->dev.kobj, "device");
@@ -1979,6 +1988,10 @@ acpi_video_switch_brightness(struct acpi_video_device *device, int event)
1979 unsigned long long level_current, level_next; 1988 unsigned long long level_current, level_next;
1980 int result = -EINVAL; 1989 int result = -EINVAL;
1981 1990
1991 /* no warning message if acpi_backlight=vendor is used */
1992 if (!acpi_video_backlight_support())
1993 return 0;
1994
1982 if (!device->brightness) 1995 if (!device->brightness)
1983 goto out; 1996 goto out;
1984 1997
@@ -2233,11 +2246,47 @@ static int acpi_video_resume(struct acpi_device *device)
2233 return AE_OK; 2246 return AE_OK;
2234} 2247}
2235 2248
2249static acpi_status
2250acpi_video_bus_match(acpi_handle handle, u32 level, void *context,
2251 void **return_value)
2252{
2253 struct acpi_device *device = context;
2254 struct acpi_device *sibling;
2255 int result;
2256
2257 if (handle == device->handle)
2258 return AE_CTRL_TERMINATE;
2259
2260 result = acpi_bus_get_device(handle, &sibling);
2261 if (result)
2262 return AE_OK;
2263
2264 if (!strcmp(acpi_device_name(sibling), ACPI_VIDEO_BUS_NAME))
2265 return AE_ALREADY_EXISTS;
2266
2267 return AE_OK;
2268}
2269
2236static int acpi_video_bus_add(struct acpi_device *device) 2270static int acpi_video_bus_add(struct acpi_device *device)
2237{ 2271{
2238 struct acpi_video_bus *video; 2272 struct acpi_video_bus *video;
2239 struct input_dev *input; 2273 struct input_dev *input;
2240 int error; 2274 int error;
2275 acpi_status status;
2276
2277 status = acpi_walk_namespace(ACPI_TYPE_DEVICE,
2278 device->parent->handle, 1,
2279 acpi_video_bus_match, NULL,
2280 device, NULL);
2281 if (status == AE_ALREADY_EXISTS) {
2282 printk(KERN_WARNING FW_BUG
2283 "Duplicate ACPI video bus devices for the"
2284 " same VGA controller, please try module "
2285 "parameter \"video.allow_duplicates=1\""
2286 "if the current driver doesn't work.\n");
2287 if (!allow_duplicates)
2288 return -ENODEV;
2289 }
2241 2290
2242 video = kzalloc(sizeof(struct acpi_video_bus), GFP_KERNEL); 2291 video = kzalloc(sizeof(struct acpi_video_bus), GFP_KERNEL);
2243 if (!video) 2292 if (!video)