Skip to contentSkip to conversation

some fixes about acpi_memhotplug

PATCH Superseded Wen Congyang 3 participants 21 messages Jun 26, 2012 – Jun 28, 2012

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover some fixes about acpi_memhotplug

Wen Congyang (8):
fix memory leak when memory device is unbound from the module
acpi_memhotplug
free memory device if acpi_memory_enable_device() failed remove memory info from list before freeing it
donot allow to eject the memory device if it is being used don't print message if request_resource() failed
bind the memory device when the driver is being loaded auto bind the memory device which is hotpluged before the driver is
loaded
release memory resources if hotadd_new_pgdat() failed

 drivers/acpi/acpi_memhotplug.c |  106 ++++++++++++++++++++++++++++++----------
 mm/memory_hotplug.c            |    3 +-
 2 files changed, 81 insertions(+), 28 deletions(-)
#1 lore raw

PATCH 1/8 fix memory leak when memory device is unbound from the module acpi_memhotplug

We allocate memory to store acpi_memory_info, so we should free it before freeing mem_device.

---
 drivers/acpi/acpi_memhotplug.c |   18 +++++++++++++-----
 1 files changed, 13 insertions(+), 5 deletions(-)
drivers/acpi/acpi_memhotplug.c +13 -5
index d985713..f6831d1 100644
@@ -399,6 +399,18 @@ static void acpi_memory_device_notify(acpi_handle handle, u32 event, void *data)
 	return;
 }
 
+static void acpi_free_memory_device(struct acpi_memory_device *mem_device)
+{
+	struct acpi_memory_info *info, *n;
+
+	if (!mem_device)
+		return;
+
+	list_for_each_entry_safe(info, n, &mem_device->res_list, list)
+		kfree(info);
+	kfree(mem_device);
+}
+
 static int acpi_memory_device_add(struct acpi_device *device)
 {
 	int result;
@@ -451,14 +463,10 @@ static int acpi_memory_device_add(struct acpi_device *device)
 
 static int acpi_memory_device_remove(struct acpi_device *device, int type)
 {
-	struct acpi_memory_device *mem_device = NULL;
-
-
 	if (!device || !acpi_driver_data(device))
 		return -EINVAL;
 
-	mem_device = acpi_driver_data(device);
-	kfree(mem_device);
+	acpi_free_memory_device(acpi_driver_data(device));
 
 	return 0;
 }
Signature · 1 line
1.7.1
#2 lore raw

Re: [PATCH 1/8] fix memory leak when memory device is unbound from the module acpi_memhotplug

Quoted 13 lines · Wen Congyang

We allocate memory to store acpi_memory_info, so we should free it before freeing mem_device.

---
 drivers/acpi/acpi_memhotplug.c |   18 +++++++++++++-----
 1 files changed, 13 insertions(+), 5 deletions(-)
drivers/acpi/acpi_memhotplug.c +0 -0
index d985713..f6831d1 100644

drivers/acpi/acpi_memhotplug.c static void acpi_memory_device_notify(acpi_handle handle, u32 event, void *data) · line 403

Quoted 5 lines
drivers/acpi/acpi_memhotplug.c +2 -0
@@ -399,6 +399,18 @@ static void acpi_memory_device_notify(acpi_handle handle, u32 event, void *data)
 	return;
 }
 
+static void acpi_free_memory_device(struct acpi_memory_device *mem_device)
+{

The function that allocates struct acpi_memory_device is acpi_memory_device_add(), shouldn't this be called acpi_memory_device_free()?

drivers/acpi/acpi_memhotplug.c static void acpi_memory_device_notify(acpi_handle handle, u32 event, void *data) · line 410

Quoted 7 lines
drivers/acpi/acpi_memhotplug.c +7 -0
+	struct acpi_memory_info *info, *n;
+
+	if (!mem_device)
+		return;
+
+	list_for_each_entry_safe(info, n, &mem_device->res_list, list)
+		kfree(info);

Duplicates code from acpi_memory_get_device_resources(), should be moved into a seperate function.

Quoted 22 lines
drivers/acpi/acpi_memhotplug.c +4 -5
+	kfree(mem_device);
+}
+
 static int acpi_memory_device_add(struct acpi_device *device)
 {
 	int result;
@@ -451,14 +463,10 @@ static int acpi_memory_device_add(struct acpi_device *device)
 
 static int acpi_memory_device_remove(struct acpi_device *device, int type)
 {
-	struct acpi_memory_device *mem_device = NULL;
-
-
 	if (!device || !acpi_driver_data(device))
 		return -EINVAL;
 
-	mem_device = acpi_driver_data(device);
-	kfree(mem_device);
+	acpi_free_memory_device(acpi_driver_data(device));
 
 	return 0;
 }
#3 lore raw

PATCH 2/8 free memory device if acpi_memory_enable_device() failed

In reply to Wen Congyang

If acpi_memory_enable_device() fails, acpi_memory_enable_device() will return a non-zero value, which means we fail to bind the memory device to this driver. So we should free memory device before acpi_memory_device_add() returns.

---
 drivers/acpi/acpi_memhotplug.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
drivers/acpi/acpi_memhotplug.c +3 -1
index f6831d1..bb7bc66 100644
@@ -454,9 +454,11 @@ static int acpi_memory_device_add(struct acpi_device *device)
 	if (!acpi_memory_check_device(mem_device)) {
 		/* call add_memory func */
 		result = acpi_memory_enable_device(mem_device);
-		if (result)
+		if (result) {
 			printk(KERN_ERR PREFIX
 				"Error in acpi_memory_enable_device\n");
+			acpi_free_memory_device(mem_device);
+		}
 	}
 	return result;
 }
Signature · 1 line
1.7.1
Acked-by on v1 2/8
#4 lore raw

Re: [PATCH 2/8] free memory device if acpi_memory_enable_device() failed

Quoted 6 lines · Wen Congyang

If acpi_memory_enable_device() fails, acpi_memory_enable_device() will return a non-zero value, which means we fail to bind the memory device to this driver. So we should free memory device before acpi_memory_device_add() returns.

#5 lore raw

PATCH 3/8 remove memory info from list before freeing it

In reply to Wen Congyang

We free info, but we forget to remove it from the list. It will cause unexpected problem when we access the list next time.

---
 drivers/acpi/acpi_memhotplug.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
drivers/acpi/acpi_memhotplug.c +1 -0
index bb7bc66..a325bb9 100644
@@ -322,6 +322,7 @@ static int acpi_memory_disable_device(struct acpi_memory_device *mem_device)
 			if (result)
 				return result;
 		}
+		list_del(&info->list);
 		kfree(info);
 	}
 
Signature · 1 line
1.7.1
#7 lore raw

PATCH 4/8 donot allow to eject the memory device if it is being used

In reply to Wen Congyang

We eject the memory device even if it is in use. It is very dangerous, and it will cause the kernel panicked.

---
 drivers/acpi/acpi_memhotplug.c |   34 +++++++++++++++++++++++++++-------
 1 files changed, 27 insertions(+), 7 deletions(-)
drivers/acpi/acpi_memhotplug.c +27 -7
index a325bb9..2e5d5ab 100644
@@ -78,6 +78,7 @@ struct acpi_memory_info {
 	unsigned short caching;	/* memory cache attribute */
 	unsigned short write_protect;	/* memory read/write attribute */
 	unsigned int enabled:1;
+	unsigned int failed:1;
 };
 
 struct acpi_memory_device {
@@ -251,9 +252,19 @@ static int acpi_memory_enable_device(struct acpi_memory_device *mem_device)
 			node = memory_add_physaddr_to_nid(info->start_addr);
 
 		result = add_memory(node, info->start_addr, info->length);
-		if (result)
+
+		/*
+		 * If the memory block has been used by the kernel, add_memory()
+		 * returns -EEXIST. If add_memory() returns the other error, it
+		 * means that this memory block is not used by the kernel.
+		 */
+		if (result && result != -EEXIST) {
+			info->failed = 1;
 			continue;
-		info->enabled = 1;
+		}
+
+		if (!result)
+			info->enabled = 1;
 		num_enabled++;
 	}
 	if (!num_enabled) {
@@ -317,11 +328,20 @@ static int acpi_memory_disable_device(struct acpi_memory_device *mem_device)
 	 * Note: Assume that this function returns zero on success
 	 */
 	list_for_each_entry_safe(info, n, &mem_device->res_list, list) {
-		if (info->enabled) {
-			result = remove_memory(info->start_addr, info->length);
-			if (result)
-				return result;
-		}
+		if (info->failed)
+			/* The kernel does not use this memory block */
+			continue;
+
+		if (!info->enabled)
+			/*
+			 * The kernel uses this memory block, but it may be not
+			 * managed by us.
+			 */
+			return -EBUSY;
+
+		result = remove_memory(info->start_addr, info->length);
+		if (result)
+			return result;
 		list_del(&info->list);
 		kfree(info);
 	}
Signature · 1 line
1.7.1
#8 lore raw

Re: [PATCH 4/8] donot allow to eject the memory device if it is being used

Quoted 24 lines · Wen Congyang
drivers/acpi/acpi_memhotplug.c +8 -1
index a325bb9..2e5d5ab 100644
@@ -78,6 +78,7 @@ struct acpi_memory_info {
 	unsigned short caching;	/* memory cache attribute */
 	unsigned short write_protect;	/* memory read/write attribute */
 	unsigned int enabled:1;
+	unsigned int failed:1;
 };
 
 struct acpi_memory_device {
@@ -251,9 +252,19 @@ static int acpi_memory_enable_device(struct acpi_memory_device *mem_device)
 			node = memory_add_physaddr_to_nid(info->start_addr);
 
 		result = add_memory(node, info->start_addr, info->length);
-		if (result)
+
+		/*
+		 * If the memory block has been used by the kernel, add_memory()
+		 * returns -EEXIST. If add_memory() returns the other error, it
+		 * means that this memory block is not used by the kernel.
+		 */
+		if (result && result != -EEXIST) {

drivers/acpi/acpi_memhotplug.c static int acpi_memory_enable_device(struct acpi_memory_device *mem_device) · line 270

Quoted 10 lines
drivers/acpi/acpi_memhotplug.c +5 -1
+			info->failed = 1;
 			continue;
-		info->enabled = 1;
+		}
+
+		if (!result)
+			info->enabled = 1;
 		num_enabled++;
 	}
 	if (!num_enabled) {

num_enabled should only be incremented for result == 0.

#9 lore raw

Re: [PATCH 4/8] donot allow to eject the memory device if it is being used

At 06/27/2012 12:21 PM, David Rientjes Wrote:

Quoted 30 lines · Wen Congyang
Quoted 29 lines
drivers/acpi/acpi_memhotplug.c +10 -2
index a325bb9..2e5d5ab 100644
@@ -78,6 +78,7 @@ struct acpi_memory_info {
 	unsigned short caching;	/* memory cache attribute */
 	unsigned short write_protect;	/* memory read/write attribute */
 	unsigned int enabled:1;
+	unsigned int failed:1;
 };
 
 struct acpi_memory_device {
@@ -251,9 +252,19 @@ static int acpi_memory_enable_device(struct acpi_memory_device *mem_device)
 			node = memory_add_physaddr_to_nid(info->start_addr);
 
 		result = add_memory(node, info->start_addr, info->length);
-		if (result)
+
+		/*
+		 * If the memory block has been used by the kernel, add_memory()
+		 * returns -EEXIST. If add_memory() returns the other error, it
+		 * means that this memory block is not used by the kernel.
+		 */
+		if (result && result != -EEXIST) {
+			info->failed = 1;
 			continue;
-		info->enabled = 1;
+		}
Quoted 9 lines

drivers/acpi/acpi_memhotplug.c static int acpi_memory_enable_device(struct acpi_memory_device *mem_device) · line 270

Quoted 6 lines
drivers/acpi/acpi_memhotplug.c +3 -0
+
+		if (!result)
+			info->enabled = 1;
 		num_enabled++;
 	}
 	if (!num_enabled) {

num_enabled should only be incremented for result == 0.

If num_enabled is not incremented for result == -EEXIST, this device is not managed by this module, and it is not able to be hot removed. Another problem is the user will see a strange message: add_memory failed

Thanks
Wen Congyang

#10 lore raw

PATCH 5/8 don't print message if request_resource() failed

In reply to Wen Congyang

If register_memory_resource() fails, the caller(add_memory()) will return -EEXIST, and add_memory() returns -EEXIST only when register_memory_resource() fails. The function acpi_memory_enable_device() doesn't treat such erro as a fetal error, and don't want this message. The function that calls add_memory() has printed message if add_memory() failed, so don't print message in register_memory_resource().

---
 mm/memory_hotplug.c |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)
mm/memory_hotplug.c +0 -1
index 0d7e3ec..2a14d35 100644
@@ -74,7 +74,6 @@ static struct resource *register_memory_resource(u64 start, u64 size)
 	res->end = start + size - 1;
 	res->flags = IORESOURCE_MEM | IORESOURCE_BUSY;
 	if (request_resource(&iomem_resource, res) < 0) {
-		printk("System RAM resource %pR cannot be added\n", res);
 		kfree(res);
 		res = NULL;
 	}
Signature · 1 line
1.7.1
#11 lore raw

Re: [PATCH 5/8] don't print message if request_resource() failed

Quoted 7 lines · Wen Congyang

If register_memory_resource() fails, the caller(add_memory()) will return -EEXIST, and add_memory() returns -EEXIST only when register_memory_resource() fails. The function acpi_memory_enable_device() doesn't treat such erro as a fetal error, and don't want this message. The function that calls add_memory() has printed message if add_memory() failed, so don't print message in register_memory_resource().

That may be true for acpi_memory_enable_device(), but have you checked other callers to add_memory()?

#12 lore raw

Re: [PATCH 5/8] don't print message if request_resource() failed

At 06/27/2012 12:23 PM, David Rientjes Wrote:

Quoted 10 lines · Wen Congyang
Quoted 8 lines

If register_memory_resource() fails, the caller(add_memory()) will return -EEXIST, and add_memory() returns -EEXIST only when register_memory_resource() fails. The function acpi_memory_enable_device() doesn't treat such erro as a fetal error, and don't want this message. The function that calls add_memory() has printed message if add_memory() failed, so don't print message in register_memory_resource().

Quoted 3 lines

That may be true for acpi_memory_enable_device(), but have you checked other callers to add_memory()?

There are four functions that call add_memory():
1. acpi_memory_enable_device()
2. memory_probe_store()
This caller is the callback of system call write. The user can get the return value by errno.
3. add_memory_merged()
This caller does not check the return value. I guess add_memory() always successes in this place.
4. bp_state reserve_additional_memory()
This caller prints message if add_memory() failed.

So I think we can remove this message...

Thanks
Wen Congyang

#13 lore raw

PATCH 6/8 bind the memory device when the driver is being loaded

In reply to Wen Congyang

We introduce acpi_hotmem_initialized to avoid strange add_memory fail message. The stranged add_memory fail message is printed in register_memory_resource(). We have removed this message in the previous patch, so we can remove it(it is very useful to the next patch).

---
 drivers/acpi/acpi_memhotplug.c |   12 ------------
 1 files changed, 0 insertions(+), 12 deletions(-)
drivers/acpi/acpi_memhotplug.c +0 -12
index 2e5d5ab..148c88a 100644
@@ -87,8 +87,6 @@ struct acpi_memory_device {
 	struct list_head res_list;
 };
 
-static int acpi_hotmem_initialized;
-
 static acpi_status
 acpi_memory_get_resource(struct acpi_resource *resource, void *context)
 {
@@ -463,15 +461,6 @@ static int acpi_memory_device_add(struct acpi_device *device)
 
 	printk(KERN_DEBUG "%s \n", acpi_device_name(device));
 
-	/*
-	 * Early boot code has recognized memory area by EFI/E820.
-	 * If DSDT shows these memory devices on boot, hotplug is not necessary
-	 * for them. So, it just returns until completion of this driver's
-	 * start up.
-	 */
-	if (!acpi_hotmem_initialized)
-		return 0;
-
 	if (!acpi_memory_check_device(mem_device)) {
 		/* call add_memory func */
 		result = acpi_memory_enable_device(mem_device);
@@ -578,7 +567,6 @@ static int __init acpi_memory_device_init(void)
 		return -ENODEV;
 	}
 
-	acpi_hotmem_initialized = 1;
 	return 0;
 }
 
Signature · 1 line
1.7.1
#14 lore raw

Re: [PATCH 6/8] bind the memory device when the driver is being loaded

Quoted 1 line · Wen Congyang

We introduce acpi_hotmem_initialized to avoid strange add_memory fail message.

We had

Quoted 1 line

The stranged add_memory fail message is printed in register_memory_resource().

The strange

Quoted 1 line

We have removed this message in the previous patch, so we can remove

Don't say previous patch as it is unclear in the git tree which one that is. Instead say "remove this message in 'don't print message if request_resource() failed' patch.

Quoted 1 line

it(it is very useful to the next patch).

And ditto on the 'next patch' - it is not clear in git what is the next patch.

Quoted 50 lines
---
 drivers/acpi/acpi_memhotplug.c |   12 ------------
 1 files changed, 0 insertions(+), 12 deletions(-)
drivers/acpi/acpi_memhotplug.c +0 -12
index 2e5d5ab..148c88a 100644
@@ -87,8 +87,6 @@ struct acpi_memory_device {
 	struct list_head res_list;
 };
 
-static int acpi_hotmem_initialized;
-
 static acpi_status
 acpi_memory_get_resource(struct acpi_resource *resource, void *context)
 {
@@ -463,15 +461,6 @@ static int acpi_memory_device_add(struct acpi_device *device)
 
 	printk(KERN_DEBUG "%s \n", acpi_device_name(device));
 
-	/*
-	 * Early boot code has recognized memory area by EFI/E820.
-	 * If DSDT shows these memory devices on boot, hotplug is not necessary
-	 * for them. So, it just returns until completion of this driver's
-	 * start up.
-	 */
-	if (!acpi_hotmem_initialized)
-		return 0;
-
 	if (!acpi_memory_check_device(mem_device)) {
 		/* call add_memory func */
 		result = acpi_memory_enable_device(mem_device);
@@ -578,7 +567,6 @@ static int __init acpi_memory_device_init(void)
 		return -ENODEV;
 	}
 
-	acpi_hotmem_initialized = 1;
 	return 0;
 }
 
Signature · 6 lines
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#15 lore raw

Re: [PATCH 6/8] bind the memory device when the driver is being loaded

In reply to Wen Congyang
Quoted 5 lines · Wen Congyang

We introduce acpi_hotmem_initialized to avoid strange add_memory fail message. The stranged add_memory fail message is printed in register_memory_resource(). We have removed this message in the previous patch, so we can remove it(it is very useful to the next patch).

I don't think you can legitimately remove that message, see my comment in the previous patch. There are many callers to add_memory() and it seems like this workaround solves most of the pain for acpi, so maybe we can just live with it?

#16 lore raw

PATCH 7/8 auto bind the memory device which is hotpluged before the driver is loaded

In reply to Wen Congyang

If the memory device is hotpluged before the driver is loaded, the user cannot see this device under the directory /sys/bus/acpi/devices/, and the user cannot bind it by hand after the driver is loaded. This patch introduces a new feature to bind such device when is driver is being loaded.

---
 drivers/acpi/acpi_memhotplug.c |   37 ++++++++++++++++++++++++++++++++++++-
 1 files changed, 36 insertions(+), 1 deletions(-)
drivers/acpi/acpi_memhotplug.c +36 -1
index 148c88a..a682657 100644
@@ -52,6 +52,9 @@ MODULE_LICENSE("GPL");
 #define MEMORY_POWER_ON_STATE	1
 #define MEMORY_POWER_OFF_STATE	2
 
+static bool auto_probe;
+module_param(auto_probe, bool, S_IRUGO | S_IWUSR);
+
 static int acpi_memory_device_add(struct acpi_device *device);
 static int acpi_memory_device_remove(struct acpi_device *device, int type);
 
@@ -515,12 +518,44 @@ acpi_memory_register_notify_handler(acpi_handle handle,
 				    u32 level, void *ctxt, void **retv)
 {
 	acpi_status status;
-
+	struct acpi_memory_device *mem_device = NULL;
+	unsigned long long current_status;
 
 	status = is_memory_device(handle);
 	if (ACPI_FAILURE(status))
 		return AE_OK;	/* continue */
 
+	if (auto_probe) {
+		if (acpi_memory_get_device(handle, &mem_device))
+			goto install;
+
+		/* Get device present/absent information from the _STA */
+		status = acpi_evaluate_integer(mem_device->device->handle,
+					       "_STA", NULL, &current_status);
+		if (ACPI_FAILURE(status))
+			goto install;
+
+		/*
+		 * Check for device status. Device should be
+		 * present/enabled/functioning.
+		 */
+		if (!((current_status & ACPI_STA_DEVICE_PRESENT)
+		      && (current_status & ACPI_STA_DEVICE_ENABLED)
+		      && (current_status & ACPI_STA_DEVICE_FUNCTIONING)))
+			goto install;
+
+		/* We have bound this device while we register the dirver */
+		if (mem_device->state == MEMORY_POWER_ON_STATE)
+			goto install;
+
+		ACPI_DEBUG_PRINT((ACPI_DB_INFO,
+				  "\nauto probe memory device\n"));
+
+		if (acpi_memory_enable_device(mem_device))
+			pr_err(PREFIX "Cannot enable memory device\n");
+	}
+
+install:
 	status = acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY,
 					     acpi_memory_device_notify, NULL);
 	/* continue */
Signature · 1 line
1.7.1
#17 lore raw

Re: [PATCH 7/8] auto bind the memory device which is hotpluged before the driver is loaded

Quoted 3 lines · Wen Congyang

If the memory device is hotpluged before the driver is loaded, the user cannot see this device under the directory /sys/bus/acpi/devices/, and the user cannot bind it by hand after the driver is loaded.

Why not? Can the user rmmod acpi_memhotplug and modprobe it?

Quoted 1 line

This patch introduces a new feature to bind such device when is driver

s/when is/when the/

Quoted 22 lines

is being loaded.

---
 drivers/acpi/acpi_memhotplug.c |   37 ++++++++++++++++++++++++++++++++++++-
 1 files changed, 36 insertions(+), 1 deletions(-)
drivers/acpi/acpi_memhotplug.c +3 -0
index 148c88a..a682657 100644
@@ -52,6 +52,9 @@ MODULE_LICENSE("GPL");
 #define MEMORY_POWER_ON_STATE	1
 #define MEMORY_POWER_OFF_STATE	2
 
+static bool auto_probe;
+module_param(auto_probe, bool, S_IRUGO | S_IWUSR);
+
 static int acpi_memory_device_add(struct acpi_device *device);
 static int acpi_memory_device_remove(struct acpi_device *device, int type);
 

drivers/acpi/acpi_memhotplug.c acpi_memory_register_notify_handler(acpi_handle handle, · line 522

Quoted 6 lines
drivers/acpi/acpi_memhotplug.c +2 -1
@@ -515,12 +518,44 @@ acpi_memory_register_notify_handler(acpi_handle handle,
 				    u32 level, void *ctxt, void **retv)
 {
 	acpi_status status;
-
+	struct acpi_memory_device *mem_device = NULL;
+	unsigned long long current_status;

Can it just be unsigned long?

Quoted 12 lines
drivers/acpi/acpi_memhotplug.c +7 -0
 	status = is_memory_device(handle);
 	if (ACPI_FAILURE(status))
 		return AE_OK;	/* continue */
 
+	if (auto_probe) {
+		if (acpi_memory_get_device(handle, &mem_device))
+			goto install;
+
+		/* Get device present/absent information from the _STA */
+		status = acpi_evaluate_integer(mem_device->device->handle,
+					       "_STA", NULL, &current_status);

drivers/acpi/acpi_memhotplug.c acpi_memory_register_notify_handler(acpi_handle handle, · line 544

Quoted 10 lines
drivers/acpi/acpi_memhotplug.c +10 -0
+		if (ACPI_FAILURE(status))
+			goto install;
+
+		/*
+		 * Check for device status. Device should be
+		 * present/enabled/functioning.
+		 */
+		if (!((current_status & ACPI_STA_DEVICE_PRESENT)
+		      && (current_status & ACPI_STA_DEVICE_ENABLED)
+		      && (current_status & ACPI_STA_DEVICE_FUNCTIONING)))

Can you make this:
!(current_status & (ACPI_STA_DEVICE_PRESENT | ACPI_STA_DEVICE_ENABLED | ACPI_STA_DEVICE_FUNCTIONING))

instead?

drivers/acpi/acpi_memhotplug.c acpi_memory_register_notify_handler(acpi_handle handle, · line 547

Quoted 3 lines
drivers/acpi/acpi_memhotplug.c +3 -0
+			goto install;
+
+		/* We have bound this device while we register the dirver */

driver.

drivers/acpi/acpi_memhotplug.c acpi_memory_register_notify_handler(acpi_handle handle, · line 555

Quoted 8 lines
drivers/acpi/acpi_memhotplug.c +8 -0
+		if (mem_device->state == MEMORY_POWER_ON_STATE)
+			goto install;
+
+		ACPI_DEBUG_PRINT((ACPI_DB_INFO,
+				  "\nauto probe memory device\n"));
+
+		if (acpi_memory_enable_device(mem_device))
+			pr_err(PREFIX "Cannot enable memory device\n");

Would it be prudent to provide more information? Like which device could not be enabled? And perhaps the reason why it could not be enabled?

Quoted 13 lines
drivers/acpi/acpi_memhotplug.c +3 -0
+	}
+
+install:
 	status = acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY,
 					     acpi_memory_device_notify, NULL);
 	/* continue */
Signature · 6 lines
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#18 lore raw

Re: [PATCH 7/8] auto bind the memory device which is hotpluged before the driver is loaded

Quoted 14 lines · Konrad Rzeszutek Wilk
Quoted 14 lines
drivers/acpi/acpi_memhotplug.c +3 -0
index 148c88a..a682657 100644
@@ -52,6 +52,9 @@ MODULE_LICENSE("GPL");
 #define MEMORY_POWER_ON_STATE	1
 #define MEMORY_POWER_OFF_STATE	2
 
+static bool auto_probe;
+module_param(auto_probe, bool, S_IRUGO | S_IWUSR);
+
 static int acpi_memory_device_add(struct acpi_device *device);
 static int acpi_memory_device_remove(struct acpi_device *device, int type);
 
Quoted 10 lines

drivers/acpi/acpi_memhotplug.c acpi_memory_register_notify_handler(acpi_handle handle, · line 522

Quoted 7 lines
drivers/acpi/acpi_memhotplug.c +2 -1
@@ -515,12 +518,44 @@ acpi_memory_register_notify_handler(acpi_handle handle,
 				    u32 level, void *ctxt, void **retv)
 {
 	acpi_status status;
-
+	struct acpi_memory_device *mem_device = NULL;
+	unsigned long long current_status;

Can it just be unsigned long?

Not on 32-bit, the ACPI 2.0 and later specs can handle 64 bit integers.

#19 lore raw

PATCH 8/8 release memory resources if hotadd_new_pgdat() failed

In reply to Wen Congyang

We should goto error to release memory resource if hotadd_new_pgdat() failed.

---
 mm/memory_hotplug.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
mm/memory_hotplug.c +1 -1
index 2a14d35..3796690 100644
@@ -617,7 +617,7 @@ int __ref add_memory(int nid, u64 start, u64 size)
 		pgdat = hotadd_new_pgdat(nid, start);
 		ret = -ENOMEM;
 		if (!pgdat)
-			goto out;
+			goto error;
 		new_pgdat = 1;
 	}
 
Signature · 1 line
1.7.1
Acked-by on v1 8/8
#20 lore raw

Re: [PATCH 8/8] release memory resources if hotadd_new_pgdat() failed

Quoted 12 lines · Wen Congyang

We should goto error to release memory resource if hotadd_new_pgdat() failed.

---
 mm/memory_hotplug.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
mm/memory_hotplug.c +0 -0
index 2a14d35..3796690 100644

mm/memory_hotplug.c int __ref add_memory(int nid, u64 start, u64 size) · line 623

Quoted 8 lines
mm/memory_hotplug.c +1 -1
@@ -617,7 +617,7 @@ int __ref add_memory(int nid, u64 start, u64 size)
 		pgdat = hotadd_new_pgdat(nid, start);
 		ret = -ENOMEM;
 		if (!pgdat)
-			goto out;
+			goto error;
 		new_pgdat = 1;
 	}
 

This is a generic memory hotplug patch and doesn't rely on the rest of the series, so let's cc the maintainer, Andrew Morton <[email protected]>.