Skip to content

Commit e21c1ca

Browse files
committed
ACPI: acpi_os_allocate() fixes
Replace acpi_in_resume with a more general hack to check irqs_disabled() on any kmalloc() from ACPI. While setting (system_state != SYSTEM_RUNNING) on resume seemed more general, Andrew Morton preferred this approach. http://bugzilla.kernel.org/show_bug.cgi?id=3469 Make acpi_os_allocate() into an inline function to allow /proc/slab_allocators to work. Delete some memset() that could fault on allocation failure. Signed-off-by: Len Brown <len.brown@intel.com>
1 parent b3cf257 commit e21c1ca

6 files changed

Lines changed: 31 additions & 40 deletions

File tree

‎drivers/acpi/osl.c‎

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -136,16 +136,6 @@ void acpi_os_vprintf(const char *fmt, va_list args)
136136
#endif
137137
}
138138

139-
140-
extern int acpi_in_resume;
141-
void *acpi_os_allocate(acpi_size size)
142-
{
143-
if (acpi_in_resume)
144-
return kmalloc(size, GFP_ATOMIC);
145-
else
146-
return kmalloc(size, GFP_KERNEL);
147-
}
148-
149139
acpi_status acpi_os_get_root_pointer(u32 flags, struct acpi_pointer *addr)
150140
{
151141
if (efi_enabled) {
@@ -1115,26 +1105,6 @@ acpi_status acpi_os_release_object(acpi_cache_t * cache, void *object)
11151105
return (AE_OK);
11161106
}
11171107

1118-
/*******************************************************************************
1119-
*
1120-
* FUNCTION: acpi_os_acquire_object
1121-
*
1122-
* PARAMETERS: Cache - Handle to cache object
1123-
* ReturnObject - Where the object is returned
1124-
*
1125-
* RETURN: Status
1126-
*
1127-
* DESCRIPTION: Return a zero-filled object.
1128-
*
1129-
******************************************************************************/
1130-
1131-
void *acpi_os_acquire_object(acpi_cache_t * cache)
1132-
{
1133-
void *object = kmem_cache_zalloc(cache, GFP_KERNEL);
1134-
WARN_ON(!object);
1135-
return object;
1136-
}
1137-
11381108
/******************************************************************************
11391109
*
11401110
* FUNCTION: acpi_os_validate_interface

‎drivers/acpi/parser/psutils.c‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,12 +139,10 @@ union acpi_parse_object *acpi_ps_alloc_op(u16 opcode)
139139
/* The generic op (default) is by far the most common (16 to 1) */
140140

141141
op = acpi_os_acquire_object(acpi_gbl_ps_node_cache);
142-
memset(op, 0, sizeof(struct acpi_parse_obj_common));
143142
} else {
144143
/* Extended parseop */
145144

146145
op = acpi_os_acquire_object(acpi_gbl_ps_node_ext_cache);
147-
memset(op, 0, sizeof(struct acpi_parse_obj_named));
148146
}
149147

150148
/* Initialize the Op */

‎drivers/acpi/pci_link.c‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -780,11 +780,6 @@ static int acpi_pci_link_resume(struct acpi_pci_link *link)
780780
return 0;
781781
}
782782

783-
/*
784-
* FIXME: this is a workaround to avoid nasty warning. It will be removed
785-
* after every device calls pci_disable_device in .resume.
786-
*/
787-
int acpi_in_resume;
788783
static int irqrouter_resume(struct sys_device *dev)
789784
{
790785
struct list_head *node = NULL;
@@ -794,7 +789,6 @@ static int irqrouter_resume(struct sys_device *dev)
794789
/* Make sure SCI is enabled again (Apple firmware bug?) */
795790
acpi_set_register(ACPI_BITREG_SCI_ENABLE, 1, ACPI_MTX_DO_NOT_LOCK);
796791

797-
acpi_in_resume = 1;
798792
list_for_each(node, &acpi_link.entries) {
799793
link = list_entry(node, struct acpi_pci_link, node);
800794
if (!link) {
@@ -803,7 +797,6 @@ static int irqrouter_resume(struct sys_device *dev)
803797
}
804798
acpi_pci_link_resume(link);
805799
}
806-
acpi_in_resume = 0;
807800
return 0;
808801
}
809802

‎drivers/acpi/utilities/utalloc.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,7 @@ acpi_ut_initialize_buffer(struct acpi_buffer * buffer,
285285
return (status);
286286
}
287287

288+
#ifdef NOT_USED_BY_LINUX
288289
/*******************************************************************************
289290
*
290291
* FUNCTION: acpi_ut_allocate
@@ -360,3 +361,4 @@ void *acpi_ut_allocate_zeroed(acpi_size size,
360361

361362
return (allocation);
362363
}
364+
#endif

‎include/acpi/acmacros.h‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -724,9 +724,15 @@
724724

725725
/* Memory allocation */
726726

727+
#ifndef ACPI_ALLOCATE
727728
#define ACPI_ALLOCATE(a) acpi_ut_allocate((acpi_size)(a),_COMPONENT,_acpi_module_name,__LINE__)
729+
#endif
730+
#ifndef ACPI_ALLOCATE_ZEROED
728731
#define ACPI_ALLOCATE_ZEROED(a) acpi_ut_allocate_zeroed((acpi_size)(a), _COMPONENT,_acpi_module_name,__LINE__)
729-
#define ACPI_FREE(a) kfree(a)
732+
#endif
733+
#ifndef ACPI_FREE
734+
#define ACPI_FREE(a) acpio_os_free(a)
735+
#endif
730736
#define ACPI_MEM_TRACKING(a)
731737

732738
#else

‎include/acpi/platform/aclinux.h‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,4 +104,26 @@
104104

105105
static inline acpi_thread_id acpi_os_get_thread_id(void) { return 0; }
106106

107+
/*
108+
* The irqs_disabled() check is for resume from RAM.
109+
* Interrupts are off during resume, just like they are for boot.
110+
* However, boot has (system_state != SYSTEM_RUNNING)
111+
* to quiet __might_sleep() in kmalloc() and resume does not.
112+
*/
113+
#include <acpi/actypes.h>
114+
static inline void *acpi_os_allocate(acpi_size size) {
115+
return kmalloc(size, irqs_disabled() ? GFP_ATOMIC : GFP_KERNEL);
116+
}
117+
static inline void *acpi_os_allocate_zeroed(acpi_size size) {
118+
return kzalloc(size, irqs_disabled() ? GFP_ATOMIC : GFP_KERNEL);
119+
}
120+
121+
static inline void *acpi_os_acquire_object(acpi_cache_t * cache) {
122+
return kmem_cache_zalloc(cache, irqs_disabled() ? GFP_ATOMIC : GFP_KERNEL);
123+
}
124+
125+
#define ACPI_ALLOCATE(a) acpi_os_allocate(a)
126+
#define ACPI_ALLOCATE_ZEROED(a) acpi_os_allocate_zeroed(a)
127+
#define ACPI_FREE(a) kfree(a)
128+
107129
#endif /* __ACLINUX_H__ */

0 commit comments

Comments
 (0)