aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/acpi_memhotplug.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/acpi/acpi_memhotplug.c')
-rw-r--r--drivers/acpi/acpi_memhotplug.c21
1 files changed, 7 insertions, 14 deletions
diff --git a/drivers/acpi/acpi_memhotplug.c b/drivers/acpi/acpi_memhotplug.c
index 81e970adeab3..1dda370f402b 100644
--- a/drivers/acpi/acpi_memhotplug.c
+++ b/drivers/acpi/acpi_memhotplug.c
@@ -129,11 +129,15 @@ acpi_memory_get_device_resources(struct acpi_memory_device *mem_device)
129 struct acpi_memory_info *info, *n; 129 struct acpi_memory_info *info, *n;
130 130
131 131
132 if (!list_empty(&mem_device->res_list))
133 return 0;
134
132 status = acpi_walk_resources(mem_device->device->handle, METHOD_NAME__CRS, 135 status = acpi_walk_resources(mem_device->device->handle, METHOD_NAME__CRS,
133 acpi_memory_get_resource, mem_device); 136 acpi_memory_get_resource, mem_device);
134 if (ACPI_FAILURE(status)) { 137 if (ACPI_FAILURE(status)) {
135 list_for_each_entry_safe(info, n, &mem_device->res_list, list) 138 list_for_each_entry_safe(info, n, &mem_device->res_list, list)
136 kfree(info); 139 kfree(info);
140 INIT_LIST_HEAD(&mem_device->res_list);
137 return -EINVAL; 141 return -EINVAL;
138 } 142 }
139 143
@@ -230,17 +234,10 @@ static int acpi_memory_enable_device(struct acpi_memory_device *mem_device)
230 * (i.e. memory-hot-remove function) 234 * (i.e. memory-hot-remove function)
231 */ 235 */
232 list_for_each_entry(info, &mem_device->res_list, list) { 236 list_for_each_entry(info, &mem_device->res_list, list) {
233 u64 start_pfn, end_pfn; 237 if (info->enabled) { /* just sanity check...*/
234
235 start_pfn = info->start_addr >> PAGE_SHIFT;
236 end_pfn = (info->start_addr + info->length - 1) >> PAGE_SHIFT;
237
238 if (pfn_valid(start_pfn) || pfn_valid(end_pfn)) {
239 /* already enabled. try next area */
240 num_enabled++; 238 num_enabled++;
241 continue; 239 continue;
242 } 240 }
243
244 result = add_memory(node, info->start_addr, info->length); 241 result = add_memory(node, info->start_addr, info->length);
245 if (result) 242 if (result)
246 continue; 243 continue;
@@ -487,10 +484,8 @@ acpi_memory_register_notify_handler(acpi_handle handle,
487 484
488 485
489 status = is_memory_device(handle); 486 status = is_memory_device(handle);
490 if (ACPI_FAILURE(status)){ 487 if (ACPI_FAILURE(status))
491 ACPI_EXCEPTION((AE_INFO, status, "handle is no memory device"));
492 return AE_OK; /* continue */ 488 return AE_OK; /* continue */
493 }
494 489
495 status = acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY, 490 status = acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY,
496 acpi_memory_device_notify, NULL); 491 acpi_memory_device_notify, NULL);
@@ -506,10 +501,8 @@ acpi_memory_deregister_notify_handler(acpi_handle handle,
506 501
507 502
508 status = is_memory_device(handle); 503 status = is_memory_device(handle);
509 if (ACPI_FAILURE(status)){ 504 if (ACPI_FAILURE(status))
510 ACPI_EXCEPTION((AE_INFO, status, "handle is no memory device"));
511 return AE_OK; /* continue */ 505 return AE_OK; /* continue */
512 }
513 506
514 status = acpi_remove_notify_handler(handle, 507 status = acpi_remove_notify_handler(handle,
515 ACPI_SYSTEM_NOTIFY, 508 ACPI_SYSTEM_NOTIFY,