From 71e93d15612c61c2e26a169567becf088e71b8ff Mon Sep 17 00:00:00 2001 From: Venki Pallipadi Date: Thu, 13 Mar 2008 17:18:19 -0700 Subject: ACPI: lockdep warning on boot, 2.6.25-rc5 This avoids the harmless WARNING by lockdep in acpi_processor_idle(). The reason for WARNING is because at the depth of idle handling code, some of the idle handlers disable interrupts, some times, while returning from the idle handler. After return, acpi_processor_idle and few other routines in the file did an unconditional local_irq_enable(). With LOCKDEP, enabling irq when it is already enabled generates the below WARNING. > > [ 0.593038] ------------[ cut here ]------------ > > [ 0.593267] WARNING: at kernel/lockdep.c:2035 trace_hardirqs_on+0xa0/0x115() > > [ 0.593596] Modules linked in: > > [ 0.593756] Pid: 0, comm: swapper Not tainted 2.6.25-rc5 #8 > > [ 0.594017] > > [ 0.594017] Call Trace: > > [ 0.594216] [] warn_on_slowpath+0x58/0x6b > > [ 0.594495] [] ? _spin_unlock_irqrestore+0x38/0x47 > > [ 0.594809] [] ? acpi_os_release_lock+0x9/0xb > > [ 0.595103] [] ? acpi_set_register+0x161/0x173 > > [ 0.595401] [] ? acpi_processor_idle+0x1de/0x546 > > [ 0.595706] [] ? default_idle+0x0/0x73 > > [ 0.595970] [] trace_hardirqs_on+0xa0/0x115 > > [ 0.596049] [] ? acpi_processor_idle+0x0/0x546 > > [ 0.596346] [] acpi_processor_idle+0x1de/0x546 > > [ 0.596642] [] ? default_idle+0x0/0x73 > > [ 0.596912] [] ? acpi_processor_idle+0x0/0x546 > > [ 0.597209] [] ? default_idle+0x0/0x73 > > [ 0.597472] [] cpu_idle+0xa7/0xd1 > > [ 0.597717] [] rest_init+0x55/0x57 > > [ 0.597957] [] start_kernel+0x29d/0x2a8 > > [ 0.598215] [] _sinittext+0x1da/0x1e1 > > [ 0.598464] > > [ 0.598546] ---[ end trace 778e504de7e3b1e3 ]--- Signed-off-by: Venkatesh Pallipadi Signed-off-by: Len Brown --- drivers/acpi/processor_idle.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'drivers/acpi') diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c index 6f3b217699e..e8e2d886923 100644 --- a/drivers/acpi/processor_idle.c +++ b/drivers/acpi/processor_idle.c @@ -216,8 +216,10 @@ static void acpi_safe_halt(void) * test NEED_RESCHED: */ smp_mb(); - if (!need_resched()) + if (!need_resched()) { safe_halt(); + local_irq_disable(); + } current_thread_info()->status |= TS_POLLING; } @@ -421,7 +423,9 @@ static void acpi_processor_idle(void) else acpi_safe_halt(); - local_irq_enable(); + if (irqs_disabled()) + local_irq_enable(); + return; } @@ -530,7 +534,9 @@ static void acpi_processor_idle(void) * skew otherwise. */ sleep_ticks = 0xFFFFFFFF; - local_irq_enable(); + if (irqs_disabled()) + local_irq_enable(); + break; case ACPI_STATE_C2: -- cgit v1.2.3 From b8a1bdb14940946fcf0438a6337b2a6c54294fb8 Mon Sep 17 00:00:00 2001 From: Alexey Starikovskiy Date: Mon, 17 Mar 2008 22:37:42 -0400 Subject: ACPI: battery: Don't return -EFAIL on broken packages. Acer BIOS has a bug which is exposed when a dead battery is present. The package template that is used to describe battery status is over-written with sane values when the battery is live. But when the batter is dead, a bogus reference in the template is used. In this case, Linux returns a fault, when instead it should simply return that it doesn't know the missing value. http://bugzilla.kernel.org/show_bug.cgi?id=8573 http://bugzilla.kernel.org/show_bug.cgi?id=10202 Signed-off-by: Alexey Starikovskiy Signed-off-by: Len Brown --- drivers/acpi/battery.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'drivers/acpi') diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c index f6215e80980..d5729d5dc19 100644 --- a/drivers/acpi/battery.c +++ b/drivers/acpi/battery.c @@ -293,13 +293,12 @@ static int extract_package(struct acpi_battery *battery, strncpy(ptr, (u8 *)&element->integer.value, sizeof(acpi_integer)); ptr[sizeof(acpi_integer)] = 0; - } else return -EFAULT; + } else + *ptr = 0; /* don't have value */ } else { - if (element->type == ACPI_TYPE_INTEGER) { - int *x = (int *)((u8 *)battery + - offsets[i].offset); - *x = element->integer.value; - } else return -EFAULT; + int *x = (int *)((u8 *)battery + offsets[i].offset); + *x = (element->type == ACPI_TYPE_INTEGER) ? + element->integer.value : -1; } } return 0; -- cgit v1.2.3 From f0d6752c9fa51d24c86b57c76ec5b2926a716b23 Mon Sep 17 00:00:00 2001 From: Len Brown Date: Tue, 18 Mar 2008 01:43:53 -0400 Subject: Revert "ACPI: video: Ignore ACPI video devices that aren't present in hardware" This reverts commit 3fa2cdcc45a0176de15cac9dbf4ed2834ebf8932. http://bugzilla.kernel.org/show_bug.cgi?id=9995 Signed-off-by: Len Brown --- drivers/acpi/video.c | 31 +------------------------------ 1 file changed, 1 insertion(+), 30 deletions(-) (limited to 'drivers/acpi') diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c index 1bc0c74f275..98f1d4e5598 100644 --- a/drivers/acpi/video.c +++ b/drivers/acpi/video.c @@ -807,40 +807,11 @@ static void acpi_video_bus_find_cap(struct acpi_video_bus *video) static int acpi_video_bus_check(struct acpi_video_bus *video) { acpi_status status = -ENOENT; - long device_id; - struct device *dev; - struct acpi_device *device; + if (!video) return -EINVAL; - device = video->device; - - status = - acpi_evaluate_integer(device->handle, "_ADR", NULL, &device_id); - - if (!ACPI_SUCCESS(status)) - return -ENODEV; - - /* We need to attempt to determine whether the _ADR refers to a - PCI device or not. There's no terribly good way to do this, - so the best we can hope for is to assume that there'll never - be a video device in the host bridge */ - if (device_id >= 0x10000) { - /* It looks like a PCI device. Does it exist? */ - dev = acpi_get_physical_device(device->handle); - } else { - /* It doesn't look like a PCI device. Does its parent - exist? */ - acpi_handle phandle; - if (acpi_get_parent(device->handle, &phandle)) - return -ENODEV; - dev = acpi_get_physical_device(phandle); - } - if (!dev) - return -ENODEV; - put_device(dev); - /* Since there is no HID, CID and so on for VGA driver, we have * to check well known required nodes. */ -- cgit v1.2.3 From abc5a87f4e627e058813a95b112e9f5f21668f9d Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Tue, 4 Mar 2008 15:00:13 -0800 Subject: asus_acpi: remove misleading mask led_out is boolean, so there is no functional change here, but apparently an extra mask with 1 caused some style checkers to flag this as logic bug. Signed-off-by: Julia Lawall Acked-by: Luca Tettamanti Signed-off-by: Andrew Morton Signed-off-by: Len Brown --- drivers/acpi/asus_acpi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/acpi') diff --git a/drivers/acpi/asus_acpi.c b/drivers/acpi/asus_acpi.c index d25ef961415..44ad90c03c2 100644 --- a/drivers/acpi/asus_acpi.c +++ b/drivers/acpi/asus_acpi.c @@ -610,7 +610,7 @@ write_led(const char __user * buffer, unsigned long count, (led_out) ? (hotk->status | ledmask) : (hotk->status & ~ledmask); if (invert) /* invert target value */ - led_out = !led_out & 0x1; + led_out = !led_out; if (!write_acpi_int(hotk->handle, ledname, led_out, NULL)) printk(KERN_WARNING "Asus ACPI: LED (%s) write failed\n", -- cgit v1.2.3 From 77321e624b64f1e5985a20f3cd16b94c96d0dbb4 Mon Sep 17 00:00:00 2001 From: Len Brown Date: Tue, 18 Mar 2008 04:04:35 -0400 Subject: Revert "ACPI: video: Ignore devices that aren't present in hardware" This reverts commit 0119509c4fbc9adcef1472817fda295334612976. http://bugzilla.kernel.org/show_bug.cgi?id=9995 Signed-off-by: Len Brown --- drivers/acpi/video.c | 29 ----------------------------- 1 file changed, 29 deletions(-) (limited to 'drivers/acpi') diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c index 98f1d4e5598..12fb44f1676 100644 --- a/drivers/acpi/video.c +++ b/drivers/acpi/video.c @@ -1337,37 +1337,8 @@ acpi_video_bus_write_DOS(struct file *file, static int acpi_video_bus_add_fs(struct acpi_device *device) { - long device_id; - int status; struct proc_dir_entry *entry = NULL; struct acpi_video_bus *video; - struct device *dev; - - status = - acpi_evaluate_integer(device->handle, "_ADR", NULL, &device_id); - - if (!ACPI_SUCCESS(status)) - return -ENODEV; - - /* We need to attempt to determine whether the _ADR refers to a - PCI device or not. There's no terribly good way to do this, - so the best we can hope for is to assume that there'll never - be a video device in the host bridge */ - if (device_id >= 0x10000) { - /* It looks like a PCI device. Does it exist? */ - dev = acpi_get_physical_device(device->handle); - } else { - /* It doesn't look like a PCI device. Does its parent - exist? */ - acpi_handle phandle; - if (acpi_get_parent(device->handle, &phandle)) - return -ENODEV; - dev = acpi_get_physical_device(phandle); - } - if (!dev) - return -ENODEV; - put_device(dev); - video = acpi_driver_data(device); -- cgit v1.2.3 From 7642d2113098f1270e9f9f0120f44d0035091636 Mon Sep 17 00:00:00 2001 From: Alexey Starikovskiy Date: Thu, 28 Feb 2008 19:17:39 +0300 Subject: ACPI: SBS: remove typo from sbchc.c Signed-off-by: Alexey Starikovskiy Signed-off-by: Len Brown --- drivers/acpi/sbshc.c | 1 - 1 file changed, 1 deletion(-) (limited to 'drivers/acpi') diff --git a/drivers/acpi/sbshc.c b/drivers/acpi/sbshc.c index a2cf3008ce6..bcf2c70fca8 100644 --- a/drivers/acpi/sbshc.c +++ b/drivers/acpi/sbshc.c @@ -130,7 +130,6 @@ static int acpi_smbus_transaction(struct acpi_smb_hc *hc, u8 protocol, goto end; } smb_hc_write(hc, ACPI_SMB_COMMAND, command); - smb_hc_write(hc, ACPI_SMB_COMMAND, command); if (!(protocol & 0x01)) { smb_hc_write(hc, ACPI_SMB_BLOCK_COUNT, length); for (i = 0; i < length; ++i) -- cgit v1.2.3 From 9171f83488940e4ff85f1b7137773eb1f306cdef Mon Sep 17 00:00:00 2001 From: Holger Macht Date: Wed, 12 Mar 2008 01:07:27 +0100 Subject: ACPI: Set flag DOCK_UNDOCKING when triggered via sysfs begin_undock() is only called when triggered via a acpi notify handler (pressing the undock button on the dock station), but complete_undock() is always called after the eject. So if a undock is triggered through a sysfs write, the flag DOCK_UNDOCKING has to be set for the dock station, too. Otherwise this will freeze the system hard. Signed-off-by: Holger Macht Acked-by: Kristen Carlson Accardi Signed-off-by: Andrew Morton Signed-off-by: Len Brown --- drivers/acpi/dock.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers/acpi') diff --git a/drivers/acpi/dock.c b/drivers/acpi/dock.c index 307cef65c24..fa44fb96fc3 100644 --- a/drivers/acpi/dock.c +++ b/drivers/acpi/dock.c @@ -710,6 +710,7 @@ static ssize_t write_undock(struct device *dev, struct device_attribute *attr, if (!count) return -EINVAL; + begin_undock(dock_station); ret = handle_eject_request(dock_station, ACPI_NOTIFY_EJECT_REQUEST); return ret ? ret: count; } -- cgit v1.2.3 From d7a0e1f56472db0825e13f9dd39f0ad79b8c8b3e Mon Sep 17 00:00:00 2001 From: Alexey Starikovskiy Date: Wed, 19 Mar 2008 02:45:12 +0300 Subject: Revert "ACPI: EC: Handle IRQ storm on Acer laptops" This reverts commit 2c81ce4c9c37b910210f2640c28e98a0c398dc26. It caused several new troubles (eg suspend slowdown bisected down to this patch by Pavel Machek), so just revert it for now. Signed-off-by: Alexey Starikovskiy Cc: Pavel Machek Signed-off-by: Linus Torvalds --- drivers/acpi/ec.c | 11 ----------- 1 file changed, 11 deletions(-) (limited to 'drivers/acpi') diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c index e7e197e3a4f..7222a18a031 100644 --- a/drivers/acpi/ec.c +++ b/drivers/acpi/ec.c @@ -129,7 +129,6 @@ static struct acpi_ec { struct mutex lock; wait_queue_head_t wait; struct list_head list; - atomic_t irq_count; u8 handlers_installed; } *boot_ec, *first_ec; @@ -182,8 +181,6 @@ static int acpi_ec_wait(struct acpi_ec *ec, enum ec_event event, int force_poll) { int ret = 0; - atomic_set(&ec->irq_count, 0); - if (unlikely(event == ACPI_EC_EVENT_OBF_1 && test_bit(EC_FLAGS_NO_OBF1_GPE, &ec->flags))) force_poll = 1; @@ -230,7 +227,6 @@ static int acpi_ec_wait(struct acpi_ec *ec, enum ec_event event, int force_poll) while (time_before(jiffies, delay)) { if (acpi_ec_check_status(ec, event)) goto end; - msleep(5); } } pr_err(PREFIX "acpi_ec_wait timeout," @@ -533,13 +529,6 @@ static u32 acpi_ec_gpe_handler(void *data) struct acpi_ec *ec = data; pr_debug(PREFIX "~~~> interrupt\n"); - atomic_inc(&ec->irq_count); - if (atomic_read(&ec->irq_count) > 5) { - pr_err(PREFIX "GPE storm detected, disabling EC GPE\n"); - acpi_disable_gpe(NULL, ec->gpe, ACPI_ISR); - clear_bit(EC_FLAGS_GPE_MODE, &ec->flags); - return ACPI_INTERRUPT_HANDLED; - } clear_bit(EC_FLAGS_WAIT_GPE, &ec->flags); if (test_bit(EC_FLAGS_GPE_MODE, &ec->flags)) wake_up(&ec->wait); -- cgit v1.2.3 From b97d4803400a4442b0e4ae14d0bd8e83994b9004 Mon Sep 17 00:00:00 2001 From: Bjorn Helgaas Date: Tue, 25 Mar 2008 11:21:11 -0600 Subject: ACPI: fix Medion _PRT quirk (use "ISA_", not "ISA") This fixes the builtin RTL8139 NIC on the Medion MD9580-F laptop. The BIOS reports the interrupt routing incorrectly. I recently added a quirk to work around this, and this patch fixes a typo in the quirk. We pad every ACPI pathname component to four characters, so ".ISA." will never match anything. We need ".ISA_." instead. Thank you Johann-Nikolaus Andreae for patiently testing this patch. See http://bugzilla.kernel.org/show_bug.cgi?id=4773 Signed-off-by: Bjorn Helgaas Signed-off-by: Linus Torvalds --- drivers/acpi/pci_irq.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/acpi') diff --git a/drivers/acpi/pci_irq.c b/drivers/acpi/pci_irq.c index 7af414a3c63..89022a74fae 100644 --- a/drivers/acpi/pci_irq.c +++ b/drivers/acpi/pci_irq.c @@ -131,8 +131,8 @@ struct prt_quirk { */ static struct prt_quirk prt_quirks[] = { { medion_md9580, 0, 0, 9, 'A', - "\\_SB_.PCI0.ISA.LNKA", - "\\_SB_.PCI0.ISA.LNKB"}, + "\\_SB_.PCI0.ISA_.LNKA", + "\\_SB_.PCI0.ISA_.LNKB"}, { dell_optiplex, 0, 0, 0xd, 'A', "\\_SB_.LNKB", "\\_SB_.LNKA"}, -- cgit v1.2.3 From 5c9fcb5deef4d3a49798d76c48b726d2e3c7df72 Mon Sep 17 00:00:00 2001 From: Zhang Rui Date: Thu, 20 Mar 2008 16:40:32 +0800 Subject: ACPI: fix a regression of ACPI device driver autoloading commit 3620f2f2f39e7870cf1a4fb2e34063a142f28716 sets the cid of ACPI video/dock/bay device and leaves the hid empty. As a result, "modalias" should export the cid for devices which don't have a hid. ACPI Video driver is not autoloaded with commit 3620f2f2f39e7870cf1a4fb2e34063a142f28716 applied. "cat /sys/.../device:03(acpi video bus)/modalias" shows nothing. ACPI Video driver is autoloaded after revert that commit. "cat /sys/.../LNXVIDEO:0x/modalias" shows "acpi:LNXVIDEO:" ACPI Video driver is autoloaded with commit 3620f2f2f39e7870cf1a4fb2e34063a142f28716 and this patch applied. "cat /sys/.../device:03(acpi video bus)/modalias" shows "acpi:LNXVIDEO:" Signed-off-by: Zhang Rui Acked-by: Thomas Renninger Signed-off-by: Len Brown --- drivers/acpi/scan.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'drivers/acpi') diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index 57570ac4780..e6ce262b5d4 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c @@ -39,20 +39,26 @@ static int create_modalias(struct acpi_device *acpi_dev, char *modalias, int size) { int len; + int count; - if (!acpi_dev->flags.hardware_id) + if (!acpi_dev->flags.hardware_id && !acpi_dev->flags.compatible_ids) return -ENODEV; - len = snprintf(modalias, size, "acpi:%s:", - acpi_dev->pnp.hardware_id); - if (len < 0 || len >= size) - return -EINVAL; + len = snprintf(modalias, size, "acpi:"); size -= len; + if (acpi_dev->flags.hardware_id) { + count = snprintf(&modalias[len], size, "%s:", + acpi_dev->pnp.hardware_id); + if (count < 0 || count >= size) + return -EINVAL; + len += count; + size -= count; + } + if (acpi_dev->flags.compatible_ids) { struct acpi_compatible_id_list *cid_list; int i; - int count; cid_list = acpi_dev->pnp.cid_list; for (i = 0; i < cid_list->count; i++) { -- cgit v1.2.3 From 996520c1fdd2948addb629be56c9febf2967e02b Mon Sep 17 00:00:00 2001 From: Venki Pallipadi Date: Mon, 24 Mar 2008 14:24:10 -0700 Subject: ACPI: fix mis-merge -- invoke acpi_unlazy_tlb() only on C3 entry This original patch http://ussg.iu.edu/hypermail/linux/kernel/0712.2/1451.html was intending to add acpi_unlazy_tlb() to acpi_idle_enter_bm(), which is used for C3 entry. But it was merged incorrectly as commmit bde6f5f59c2b2b48a7a849c129d5b48838fe77ee 'x86: voluntary leave_mm before entering ACPI C3' so the call was instead added to acpi_idle_enter_simple() (which is C2 entry routine), probably due to identical context in that function. Move the call back to acpi_idle_enter_bm(). Signed-off-by: Venkatesh Pallipadi Signed-off-by: Len Brown --- drivers/acpi/processor_idle.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'drivers/acpi') diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c index e8e2d886923..1468f1e92ca 100644 --- a/drivers/acpi/processor_idle.c +++ b/drivers/acpi/processor_idle.c @@ -1487,7 +1487,6 @@ static int acpi_idle_enter_simple(struct cpuidle_device *dev, return 0; } - acpi_unlazy_tlb(smp_processor_id()); /* * Must be done before busmaster disable as we might need to * access HPET ! @@ -1577,6 +1576,8 @@ static int acpi_idle_enter_bm(struct cpuidle_device *dev, return 0; } + acpi_unlazy_tlb(smp_processor_id()); + /* Tell the scheduler that we are going deep-idle: */ sched_clock_idle_sleep_event(); /* -- cgit v1.2.3 From 8e92b6605da989c0aa8ff7e33306f36f0efd957c Mon Sep 17 00:00:00 2001 From: Venki Pallipadi Date: Fri, 29 Feb 2008 10:24:32 -0800 Subject: cpuidle: fix 100% C0 statistics regression commit 9b12e18cdc1553de62d931e73443c806347cd974 'ACPI: cpuidle: Support C1 idle time accounting' was implicated in a 100% C0 idle regression. http://bugzilla.kernel.org/show_bug.cgi?id=10076 It pointed out a potential problem where the menu governor may get confused by the C-state residency time from poll idle or C1 idle, where this timing info is not accurate. This inaccuracy is due to interrupts being handled before we account for C-state exit. Do not mark TIME_VALID for CO poll state. Mark C1 time as valid only with the MWAIT (CSTATE_FFH) entry method. This makes governors use the timing information only when it is correct and eliminates any wrong policy decisions that may result from invalid timing information. Signed-off-by: Venkatesh Pallipadi Signed-off-by: Len Brown --- drivers/acpi/processor_idle.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'drivers/acpi') diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c index 1468f1e92ca..788da9781f8 100644 --- a/drivers/acpi/processor_idle.c +++ b/drivers/acpi/processor_idle.c @@ -1693,7 +1693,9 @@ static int acpi_processor_setup_cpuidle(struct acpi_processor *pr) switch (cx->type) { case ACPI_STATE_C1: state->flags |= CPUIDLE_FLAG_SHALLOW; - state->flags |= CPUIDLE_FLAG_TIME_VALID; + if (cx->entry_method == ACPI_CSTATE_FFH) + state->flags |= CPUIDLE_FLAG_TIME_VALID; + state->enter = acpi_idle_enter_c1; dev->safe_state = state; break; -- cgit v1.2.3 From 1192aeb957402b45f311895f124e4ca41206843c Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Thu, 27 Mar 2008 01:48:22 -0400 Subject: ACPI: drivers/acpi: elide a non-zero test on a result that is never 0 The function thermal_cooling_device_register always returns either a valid pointer or a value made with ERR_PTR, so a test for non-zero on the result will always succeed. The problem was found using the following semantic match. (http://www.emn.fr/x-info/coccinelle/) // @a@ expression E, E1; statement S,S1; position p; @@ E = thermal_cooling_device_register(...) ... when != E = E1 if@p (E) S else S1 @n@ position a.p; expression E,E1; statement S,S1; @@ E = NULL ... when != E = E1 if@p (E) S else S1 @depends on !n@ expression E; statement S,S1; position a.p; @@ * if@p (E) S else S1 // Signed-off-by: Julia Lawall Signed-off-by: Andrew Morton Signed-off-by: Len Brown --- drivers/acpi/fan.c | 34 ++++++++++++++++------------------ drivers/acpi/processor_core.c | 30 ++++++++++++++---------------- drivers/acpi/video.c | 28 +++++++++++++--------------- 3 files changed, 43 insertions(+), 49 deletions(-) (limited to 'drivers/acpi') diff --git a/drivers/acpi/fan.c b/drivers/acpi/fan.c index c8e3cba423e..4d535c50d82 100644 --- a/drivers/acpi/fan.c +++ b/drivers/acpi/fan.c @@ -260,24 +260,22 @@ static int acpi_fan_add(struct acpi_device *device) result = PTR_ERR(cdev); goto end; } - if (cdev) { - printk(KERN_INFO PREFIX - "%s is registered as cooling_device%d\n", - device->dev.bus_id, cdev->id); - - acpi_driver_data(device) = cdev; - result = sysfs_create_link(&device->dev.kobj, - &cdev->device.kobj, - "thermal_cooling"); - if (result) - return result; - - result = sysfs_create_link(&cdev->device.kobj, - &device->dev.kobj, - "device"); - if (result) - return result; - } + printk(KERN_INFO PREFIX + "%s is registered as cooling_device%d\n", + device->dev.bus_id, cdev->id); + + acpi_driver_data(device) = cdev; + result = sysfs_create_link(&device->dev.kobj, + &cdev->device.kobj, + "thermal_cooling"); + if (result) + return result; + + result = sysfs_create_link(&cdev->device.kobj, + &device->dev.kobj, + "device"); + if (result) + return result; result = acpi_fan_add_fs(device); if (result) diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c index 36a68fa114e..3a136f6c66a 100644 --- a/drivers/acpi/processor_core.c +++ b/drivers/acpi/processor_core.c @@ -674,22 +674,20 @@ static int __cpuinit acpi_processor_start(struct acpi_device *device) result = PTR_ERR(pr->cdev); goto end; } - if (pr->cdev) { - printk(KERN_INFO PREFIX - "%s is registered as cooling_device%d\n", - device->dev.bus_id, pr->cdev->id); - - result = sysfs_create_link(&device->dev.kobj, - &pr->cdev->device.kobj, - "thermal_cooling"); - if (result) - return result; - result = sysfs_create_link(&pr->cdev->device.kobj, - &device->dev.kobj, - "device"); - if (result) - return result; - } + printk(KERN_INFO PREFIX + "%s is registered as cooling_device%d\n", + device->dev.bus_id, pr->cdev->id); + + result = sysfs_create_link(&device->dev.kobj, + &pr->cdev->device.kobj, + "thermal_cooling"); + if (result) + return result; + result = sysfs_create_link(&pr->cdev->device.kobj, + &device->dev.kobj, + "device"); + if (result) + return result; if (pr->flags.throttling) { printk(KERN_INFO PREFIX "%s [%s] (supports", diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c index 12fb44f1676..fe09b57de61 100644 --- a/drivers/acpi/video.c +++ b/drivers/acpi/video.c @@ -734,21 +734,19 @@ static void acpi_video_device_find_cap(struct acpi_video_device *device) if (IS_ERR(device->cdev)) return; - if (device->cdev) { - printk(KERN_INFO PREFIX - "%s is registered as cooling_device%d\n", - device->dev->dev.bus_id, device->cdev->id); - result = sysfs_create_link(&device->dev->dev.kobj, - &device->cdev->device.kobj, - "thermal_cooling"); - if (result) - printk(KERN_ERR PREFIX "Create sysfs link\n"); - result = sysfs_create_link(&device->cdev->device.kobj, - &device->dev->dev.kobj, - "device"); - if (result) - printk(KERN_ERR PREFIX "Create sysfs link\n"); - } + printk(KERN_INFO PREFIX + "%s is registered as cooling_device%d\n", + device->dev->dev.bus_id, device->cdev->id); + result = sysfs_create_link(&device->dev->dev.kobj, + &device->cdev->device.kobj, + "thermal_cooling"); + if (result) + printk(KERN_ERR PREFIX "Create sysfs link\n"); + result = sysfs_create_link(&device->cdev->device.kobj, + &device->dev->dev.kobj, + "device"); + if (result) + printk(KERN_ERR PREFIX "Create sysfs link\n"); } if (device->cap._DCS && device->cap._DSS){ static int count = 0; -- cgit v1.2.3 From 48d3d8263c491822d50e64547bae5f6b4a54ec59 Mon Sep 17 00:00:00 2001 From: Ingo Molnar Date: Fri, 28 Mar 2008 14:28:03 +0100 Subject: revert "ACPI: drivers/acpi: elide a non-zero test on a result that is never 0" Revert commit 1192aeb957402b45f311895f124e4ca41206843c ("ACPI: drivers/acpi: elide a non-zero test on a result that is never 0") because it turns out that thermal_cooling_device_register() does actually return NULL if CONFIG_THERMAL is turned off (then the routine turns into a dummy inline routine in the header files that returns NULL unconditionally). This was found with randconfig testing, causing a crash during bootup: initcall 0x78878534 ran for 13 msecs: acpi_button_init+0x0/0x51() Calling initcall 0x78878585: acpi_fan_init+0x0/0x2c() BUG: unable to handle kernel NULL pointer dereference at 00000000 IP: [<782b8ad0>] acpi_fan_add+0x7d/0xfd *pde = 00000000 Oops: 0000 [#1] Modules linked in: Pid: 1, comm: swapper Not tainted (2.6.25-rc7-sched-devel.git-x86-latest.git #14) EIP: 0060:[<782b8ad0>] EFLAGS: 00010246 CPU: 0 EIP is at acpi_fan_add+0x7d/0xfd EAX: b787c718 EBX: b787c400 ECX: b782ceb4 EDX: 00000007 ESI: 00000000 EDI: b787c6f4 EBP: b782cee0 ESP: b782cecc DS: 007b ES: 007b FS: 0000 GS: 0000 SS: 0068 Process swapper (pid: 1, ti=b782c000 task=b7846000 task.ti=b782c000) Stack: b787c459 00000000 b787c400 78790888 b787c60c b782cef8 782b6fb8 ffffffda b787c60c 00000000 78790958 b782cf0c 783005d7 b787c60c 78790958 78790584 b782cf1c 783007f6 b782cf28 00000000 b782cf40 782ffc4a 78790958 b794d558 Call Trace: [<782b6fb8>] ? acpi_device_probe+0x3e/0xdb [<783005d7>] ? driver_probe_device+0x82/0xfc [<783007f6>] ? __driver_attach+0x3a/0x70 [<782ffc4a>] ? bus_for_each_dev+0x3e/0x60 [<7830048c>] ? driver_attach+0x14/0x16 [<783007bc>] ? __driver_attach+0x0/0x70 [<7830006a>] ? bus_add_driver+0x9d/0x1b0 [<783008c3>] ? driver_register+0x47/0xa3 [<7813db00>] ? timespec_to_ktime+0x9/0xc [<782b7331>] ? acpi_bus_register_driver+0x3a/0x3c [<78878592>] ? acpi_fan_init+0xd/0x2c [<78863656>] ? kernel_init+0xac/0x1f9 [<788635aa>] ? kernel_init+0x0/0x1f9 [<78114563>] ? kernel_thread_helper+0x7/0x10 ======================= Code: 6e 78 e8 57 44 e7 ff 58 e9 93 00 00 00 8b 55 f0 8d bb f4 02 00 00 80 4b 2d 10 8b 03 e8 87 cb ff ff 8d 83 18 03 00 00 80 63 2d ef 35 00 00 00 00 50 68 e8 9c 6e 78 e8 22 44 e7 ff b9 b6 9c 6e EIP: [<782b8ad0>] acpi_fan_add+0x7d/0xfd SS:ESP 0068:b782cecc ---[ end trace 778e504de7e3b1e3 ]--- Kernel panic - not syncing: Attempted to kill init! Signed-off-by: Ingo Molnar Acked-by: Julia Lawall Signed-off-by: Linus Torvalds --- drivers/acpi/fan.c | 34 ++++++++++++++++++---------------- drivers/acpi/processor_core.c | 30 ++++++++++++++++-------------- drivers/acpi/video.c | 28 +++++++++++++++------------- 3 files changed, 49 insertions(+), 43 deletions(-) (limited to 'drivers/acpi') diff --git a/drivers/acpi/fan.c b/drivers/acpi/fan.c index 4d535c50d82..c8e3cba423e 100644 --- a/drivers/acpi/fan.c +++ b/drivers/acpi/fan.c @@ -260,22 +260,24 @@ static int acpi_fan_add(struct acpi_device *device) result = PTR_ERR(cdev); goto end; } - printk(KERN_INFO PREFIX - "%s is registered as cooling_device%d\n", - device->dev.bus_id, cdev->id); - - acpi_driver_data(device) = cdev; - result = sysfs_create_link(&device->dev.kobj, - &cdev->device.kobj, - "thermal_cooling"); - if (result) - return result; - - result = sysfs_create_link(&cdev->device.kobj, - &device->dev.kobj, - "device"); - if (result) - return result; + if (cdev) { + printk(KERN_INFO PREFIX + "%s is registered as cooling_device%d\n", + device->dev.bus_id, cdev->id); + + acpi_driver_data(device) = cdev; + result = sysfs_create_link(&device->dev.kobj, + &cdev->device.kobj, + "thermal_cooling"); + if (result) + return result; + + result = sysfs_create_link(&cdev->device.kobj, + &device->dev.kobj, + "device"); + if (result) + return result; + } result = acpi_fan_add_fs(device); if (result) diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c index 3a136f6c66a..36a68fa114e 100644 --- a/drivers/acpi/processor_core.c +++ b/drivers/acpi/processor_core.c @@ -674,20 +674,22 @@ static int __cpuinit acpi_processor_start(struct acpi_device *device) result = PTR_ERR(pr->cdev); goto end; } - printk(KERN_INFO PREFIX - "%s is registered as cooling_device%d\n", - device->dev.bus_id, pr->cdev->id); - - result = sysfs_create_link(&device->dev.kobj, - &pr->cdev->device.kobj, - "thermal_cooling"); - if (result) - return result; - result = sysfs_create_link(&pr->cdev->device.kobj, - &device->dev.kobj, - "device"); - if (result) - return result; + if (pr->cdev) { + printk(KERN_INFO PREFIX + "%s is registered as cooling_device%d\n", + device->dev.bus_id, pr->cdev->id); + + result = sysfs_create_link(&device->dev.kobj, + &pr->cdev->device.kobj, + "thermal_cooling"); + if (result) + return result; + result = sysfs_create_link(&pr->cdev->device.kobj, + &device->dev.kobj, + "device"); + if (result) + return result; + } if (pr->flags.throttling) { printk(KERN_INFO PREFIX "%s [%s] (supports", diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c index fe09b57de61..12fb44f1676 100644 --- a/drivers/acpi/video.c +++ b/drivers/acpi/video.c @@ -734,19 +734,21 @@ static void acpi_video_device_find_cap(struct acpi_video_device *device) if (IS_ERR(device->cdev)) return; - printk(KERN_INFO PREFIX - "%s is registered as cooling_device%d\n", - device->dev->dev.bus_id, device->cdev->id); - result = sysfs_create_link(&device->dev->dev.kobj, - &device->cdev->device.kobj, - "thermal_cooling"); - if (result) - printk(KERN_ERR PREFIX "Create sysfs link\n"); - result = sysfs_create_link(&device->cdev->device.kobj, - &device->dev->dev.kobj, - "device"); - if (result) - printk(KERN_ERR PREFIX "Create sysfs link\n"); + if (device->cdev) { + printk(KERN_INFO PREFIX + "%s is registered as cooling_device%d\n", + device->dev->dev.bus_id, device->cdev->id); + result = sysfs_create_link(&device->dev->dev.kobj, + &device->cdev->device.kobj, + "thermal_cooling"); + if (result) + printk(KERN_ERR PREFIX "Create sysfs link\n"); + result = sysfs_create_link(&device->cdev->device.kobj, + &device->dev->dev.kobj, + "device"); + if (result) + printk(KERN_ERR PREFIX "Create sysfs link\n"); + } } if (device->cap._DCS && device->cap._DSS){ static int count = 0; -- cgit v1.2.3 From 7731ce63d9a863c987dd87b0425451fff0e6cdc8 Mon Sep 17 00:00:00 2001 From: "Rafael J. Wysocki" Date: Sun, 30 Mar 2008 02:19:07 +0100 Subject: ACPI PM: Restore the 2.6.24 suspend ordering MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Some time ago it turned out that our suspend code ordering broke some NVidia-based systems that hung if _PTS was executed with one of the PCI devices, specifically a USB controller, in a low power state. Then, it was noticed that the suspend code ordering was not compliant with ACPI 1.0, although it was compliant with ACPI 2.0 (and later), and it was argued that the code had to be changed for that reason (ref. http://bugzilla.kernel.org/show_bug.cgi?id=9528). So we did, but evidently we did wrong, because it's now turning out that some systems have been broken by this change. Refs: http://bugzilla.kernel.org/show_bug.cgi?id=10340 https://bugzilla.novell.com/show_bug.cgi?id=374217#c16 [ I said at that time that something like this might happend, but the majority of people involved thought that it was improbable due to the necessity to preserve the compliance of hardware with ACPI 1.0. ] This actually is a quite serious regression from 2.6.24. Moreover, the ACPI 1.0 ordering of suspend code introduced another issue that I have only noticed recently. Namely, if the suspend of one of devices fails, the already suspended devices will be resumed without executing _WAK before, which leads to problems on some systems (for example, in such situations thermal management is broken on my HP nx6325). Consequently, it also breaks suspend debugging on the affected systems. Note also, that the requirement to execute _PTS before suspending devices does not really make sense, because the device in question may be put into a low power state at run time for a reason unrelated to a system-wide suspend. For the reasons outlined above, the change of the suspend ordering should be reverted, which is done by the patch below. [ Felix Möller: "I am the reporter from the original Novell Bug: https://bugzilla.novell.com/show_bug.cgi?id=374217 I just tried current git head (two hours ago) with the patch (the one from the beginning of this thread) from Rafael and without it. With the patch my MacBook does suspend without it does not." ] Signed-off-by: Rafael J. Wysocki Tested-by: Felix Möller Signed-off-by: Linus Torvalds --- drivers/acpi/sleep/main.c | 71 ++++++++++------------------------------------- 1 file changed, 14 insertions(+), 57 deletions(-) (limited to 'drivers/acpi') diff --git a/drivers/acpi/sleep/main.c b/drivers/acpi/sleep/main.c index d2f71a54726..71183eea790 100644 --- a/drivers/acpi/sleep/main.c +++ b/drivers/acpi/sleep/main.c @@ -26,21 +26,6 @@ u8 sleep_states[ACPI_S_STATE_COUNT]; #ifdef CONFIG_PM_SLEEP static u32 acpi_target_sleep_state = ACPI_STATE_S0; -static bool acpi_sleep_finish_wake_up; - -/* - * ACPI 2.0 and later want us to execute _PTS after suspending devices, so we - * allow the user to request that behavior by using the 'acpi_new_pts_ordering' - * kernel command line option that causes the following variable to be set. - */ -static bool new_pts_ordering; - -static int __init acpi_new_pts_ordering(char *str) -{ - new_pts_ordering = true; - return 1; -} -__setup("acpi_new_pts_ordering", acpi_new_pts_ordering); #endif static int acpi_sleep_prepare(u32 acpi_state) @@ -91,14 +76,6 @@ static int acpi_pm_begin(suspend_state_t pm_state) if (sleep_states[acpi_state]) { acpi_target_sleep_state = acpi_state; - if (new_pts_ordering) - return 0; - - error = acpi_sleep_prepare(acpi_state); - if (error) - acpi_target_sleep_state = ACPI_STATE_S0; - else - acpi_sleep_finish_wake_up = true; } else { printk(KERN_ERR "ACPI does not support this state: %d\n", pm_state); @@ -116,14 +93,11 @@ static int acpi_pm_begin(suspend_state_t pm_state) static int acpi_pm_prepare(void) { - if (new_pts_ordering) { - int error = acpi_sleep_prepare(acpi_target_sleep_state); + int error = acpi_sleep_prepare(acpi_target_sleep_state); - if (error) { - acpi_target_sleep_state = ACPI_STATE_S0; - return error; - } - acpi_sleep_finish_wake_up = true; + if (error) { + acpi_target_sleep_state = ACPI_STATE_S0; + return error; } return ACPI_SUCCESS(acpi_hw_disable_all_gpes()) ? 0 : -EFAULT; @@ -212,7 +186,6 @@ static void acpi_pm_finish(void) acpi_set_firmware_waking_vector((acpi_physical_address) 0); acpi_target_sleep_state = ACPI_STATE_S0; - acpi_sleep_finish_wake_up = false; #ifdef CONFIG_X86 if (init_8259A_after_S1) { @@ -229,11 +202,10 @@ static void acpi_pm_finish(void) static void acpi_pm_end(void) { /* - * This is necessary in case acpi_pm_finish() is not called directly - * during a failing transition to a sleep state. + * This is necessary in case acpi_pm_finish() is not called during a + * failing transition to a sleep state. */ - if (acpi_sleep_finish_wake_up) - acpi_pm_finish(); + acpi_target_sleep_state = ACPI_STATE_S0; } static int acpi_pm_state_valid(suspend_state_t pm_state) @@ -285,31 +257,18 @@ static struct dmi_system_id __initdata acpisleep_dmi_table[] = { #ifdef CONFIG_HIBERNATION static int acpi_hibernation_begin(void) { - int error; - acpi_target_sleep_state = ACPI_STATE_S4; - if (new_pts_ordering) - return 0; - error = acpi_sleep_prepare(ACPI_STATE_S4); - if (error) - acpi_target_sleep_state = ACPI_STATE_S0; - else - acpi_sleep_finish_wake_up = true; - - return error; + return 0; } static int acpi_hibernation_prepare(void) { - if (new_pts_ordering) { - int error = acpi_sleep_prepare(ACPI_STATE_S4); + int error = acpi_sleep_prepare(ACPI_STATE_S4); - if (error) { - acpi_target_sleep_state = ACPI_STATE_S0; - return error; - } - acpi_sleep_finish_wake_up = true; + if (error) { + acpi_target_sleep_state = ACPI_STATE_S0; + return error; } return ACPI_SUCCESS(acpi_hw_disable_all_gpes()) ? 0 : -EFAULT; @@ -353,17 +312,15 @@ static void acpi_hibernation_finish(void) acpi_set_firmware_waking_vector((acpi_physical_address) 0); acpi_target_sleep_state = ACPI_STATE_S0; - acpi_sleep_finish_wake_up = false; } static void acpi_hibernation_end(void) { /* * This is necessary in case acpi_hibernation_finish() is not called - * directly during a failing transition to the sleep state. + * during a failing transition to the sleep state. */ - if (acpi_sleep_finish_wake_up) - acpi_hibernation_finish(); + acpi_target_sleep_state = ACPI_STATE_S0; } static int acpi_hibernation_pre_restore(void) -- cgit v1.2.3