[ltp] [PATCH 1/2] Thinkpad Suspend Powersave: Fix ACPI's GFP_KERNEL allocations in contexts that can sleep
linux-thinkpad@linux-thinkpad.org
linux-thinkpad@linux-thinkpad.org
Wed, 16 Mar 2005 10:16:03 -0500
This fixes a problem originally reported by Christian Borntraeger where
during the wakeup from a suspend-to-ram, several "sleeping function
called from invalid context" warning messages are issued. Unlike a
previous patch which attempted to solve this problem, we avoid doing an
GFP_ATOMIC kmalloc() except when explicitly necessary.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Index: src/drivers/acpi/osl.c
===================================================================
--- src.orig/drivers/acpi/osl.c 2005-03-14 09:38:15.000000000 -0500
+++ src/drivers/acpi/osl.c 2005-03-14 09:38:18.000000000 -0500
@@ -145,7 +145,7 @@
void *
acpi_os_allocate(acpi_size size)
{
- return kmalloc(size, GFP_KERNEL);
+ return kmalloc(size, in_atomic() ? GFP_ATOMIC : GFP_KERNEL);
}
void
@@ -905,7 +905,7 @@
ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Waiting for semaphore[%p|%d|%d]\n", handle, units, timeout));
- if (in_atomic())
+ if (in_atomic() || irqs_disabled())
timeout = 0;
switch (timeout)
Index: src/drivers/acpi/pci_link.c
===================================================================
--- src.orig/drivers/acpi/pci_link.c 2005-03-14 09:38:15.000000000 -0500
+++ src/drivers/acpi/pci_link.c 2005-03-14 09:38:18.000000000 -0500
@@ -36,6 +36,7 @@
#include <linux/types.h>
#include <linux/proc_fs.h>
#include <linux/spinlock.h>
+#include <linux/interrupt.h>
#include <linux/pm.h>
#include <linux/pci.h>
@@ -315,7 +316,8 @@
if (!link || !irq)
return_VALUE(-EINVAL);
- resource = kmalloc( sizeof(*resource)+1, GFP_KERNEL);
+ resource = kmalloc( sizeof(*resource)+1,
+ in_atomic() ? GFP_ATOMIC : GFP_KERNEL);
if(!resource)
return_VALUE(-ENOMEM);
Index: src/drivers/acpi/utils.c
===================================================================
--- src.orig/drivers/acpi/utils.c 2005-03-14 09:38:15.000000000 -0500
+++ src/drivers/acpi/utils.c 2005-03-14 09:38:18.000000000 -0500
@@ -27,6 +27,7 @@
#include <linux/module.h>
#include <linux/init.h>
#include <linux/types.h>
+#include <linux/interrupt.h>
#include <acpi/acpi_bus.h>
#include <acpi/acpi_drivers.h>
@@ -252,7 +253,8 @@
if (!data)
return_ACPI_STATUS(AE_BAD_PARAMETER);
- element = kmalloc(sizeof(union acpi_object), GFP_KERNEL);
+ element = kmalloc(sizeof(union acpi_object),
+ in_atomic() ? GFP_ATOMIC : GFP_KERNEL);
if(!element)
return_ACPI_STATUS(AE_NO_MEMORY);