aboutsummaryrefslogtreecommitdiffstats
diff options
-rw-r--r--driver-core/driver-core-add-mutex-for-adding-removing-memory-blocks.patch65
-rw-r--r--driver-core/driver-core-add-section-count-to-memory_block-struct.patch68
-rw-r--r--driver-core/driver-core-move-find_memory_block-routine.patch102
-rw-r--r--series4
4 files changed, 238 insertions, 1 deletions
diff --git a/driver-core/driver-core-add-mutex-for-adding-removing-memory-blocks.patch b/driver-core/driver-core-add-mutex-for-adding-removing-memory-blocks.patch
new file mode 100644
index 00000000000000..3600f974f69777
--- /dev/null
+++ b/driver-core/driver-core-add-mutex-for-adding-removing-memory-blocks.patch
@@ -0,0 +1,65 @@
+From nfont@austin.ibm.com Tue Oct 19 10:58:51 2010
+Message-ID: <4CBDD934.1070204@austin.ibm.com>
+Date: Tue, 19 Oct 2010 12:45:24 -0500
+From: Nathan Fontenot <nfont@austin.ibm.com>
+To: Greg KH <greg@kroah.com>
+CC: Nathan Fontenot <nfonteno@us.ibm.com>
+Subject: Driver core: Add mutex for adding/removing memory blocks
+
+Add a new mutex for use in adding and removing of memory blocks. This
+is needed to avoid any race conditions in which the same memory block could
+be added and removed at the same time.
+
+Signed-off-by: Nathan Fontenot <nfont@austin.ibm.com>
+Reviewed-by: Robin Holt <holt@sgi.com>
+Reviewed-By: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+
+---
+ drivers/base/memory.c | 7 +++++++
+ 1 file changed, 7 insertions(+)
+
+--- a/drivers/base/memory.c
++++ b/drivers/base/memory.c
+@@ -27,6 +27,8 @@
+ #include <asm/atomic.h>
+ #include <asm/uaccess.h>
+
++static DEFINE_MUTEX(mem_sysfs_mutex);
++
+ #define MEMORY_CLASS_NAME "memory"
+
+ static struct sysdev_class memory_sysdev_class = {
+@@ -484,6 +486,8 @@ static int add_memory_block(int nid, str
+ if (!mem)
+ return -ENOMEM;
+
++ mutex_lock(&mem_sysfs_mutex);
++
+ mem->phys_index = __section_nr(section);
+ mem->state = state;
+ mutex_init(&mem->state_mutex);
+@@ -504,6 +508,7 @@ static int add_memory_block(int nid, str
+ ret = register_mem_sect_under_node(mem, nid);
+ }
+
++ mutex_unlock(&mem_sysfs_mutex);
+ return ret;
+ }
+
+@@ -512,6 +517,7 @@ int remove_memory_block(unsigned long no
+ {
+ struct memory_block *mem;
+
++ mutex_lock(&mem_sysfs_mutex);
+ mem = find_memory_block(section);
+ unregister_mem_sect_under_nodes(mem);
+ mem_remove_simple_file(mem, phys_index);
+@@ -520,6 +526,7 @@ int remove_memory_block(unsigned long no
+ mem_remove_simple_file(mem, removable);
+ unregister_memory(mem, section);
+
++ mutex_unlock(&mem_sysfs_mutex);
+ return 0;
+ }
+
diff --git a/driver-core/driver-core-add-section-count-to-memory_block-struct.patch b/driver-core/driver-core-add-section-count-to-memory_block-struct.patch
new file mode 100644
index 00000000000000..c7c13d0ac6cf52
--- /dev/null
+++ b/driver-core/driver-core-add-section-count-to-memory_block-struct.patch
@@ -0,0 +1,68 @@
+From nfont@austin.ibm.com Tue Oct 19 10:59:27 2010
+Message-ID: <4CBDD96B.2010103@austin.ibm.com>
+Date: Tue, 19 Oct 2010 12:46:19 -0500
+From: Nathan Fontenot <nfont@austin.ibm.com>
+To: Greg KH <greg@kroah.com>
+CC: Nathan Fontenot <nfonteno@us.ibm.com>
+Subject: Driver core: Add section count to memory_block struct
+
+Add a section count property to the memory_block struct to track the number
+of memory sections that have been added/removed from a memory block. This
+allows us to know when the last memory section of a memory block has been
+removed so we can remove the memory block.
+
+Signed-off-by: Nathan Fontenot <nfont@austin.ibm.com>
+Reviewed-by: Robin Holt <holt@sgi.com>
+Reviewed-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+
+
+---
+ drivers/base/memory.c | 17 +++++++++++------
+ include/linux/memory.h | 2 ++
+ 2 files changed, 13 insertions(+), 6 deletions(-)
+
+--- a/drivers/base/memory.c
++++ b/drivers/base/memory.c
+@@ -490,6 +490,7 @@ static int add_memory_block(int nid, str
+
+ mem->phys_index = __section_nr(section);
+ mem->state = state;
++ mem->section_count++;
+ mutex_init(&mem->state_mutex);
+ start_pfn = section_nr_to_pfn(mem->phys_index);
+ mem->phys_device = arch_get_memory_phys_device(start_pfn);
+@@ -519,12 +520,16 @@ int remove_memory_block(unsigned long no
+
+ mutex_lock(&mem_sysfs_mutex);
+ mem = find_memory_block(section);
+- unregister_mem_sect_under_nodes(mem);
+- mem_remove_simple_file(mem, phys_index);
+- mem_remove_simple_file(mem, state);
+- mem_remove_simple_file(mem, phys_device);
+- mem_remove_simple_file(mem, removable);
+- unregister_memory(mem, section);
++
++ mem->section_count--;
++ if (mem->section_count == 0) {
++ unregister_mem_sect_under_nodes(mem);
++ mem_remove_simple_file(mem, phys_index);
++ mem_remove_simple_file(mem, state);
++ mem_remove_simple_file(mem, phys_device);
++ mem_remove_simple_file(mem, removable);
++ unregister_memory(mem, section);
++ }
+
+ mutex_unlock(&mem_sysfs_mutex);
+ return 0;
+--- a/include/linux/memory.h
++++ b/include/linux/memory.h
+@@ -23,6 +23,8 @@
+ struct memory_block {
+ unsigned long phys_index;
+ unsigned long state;
++ int section_count;
++
+ /*
+ * This serializes all state change requests. It isn't
+ * held during creation because the control files are
diff --git a/driver-core/driver-core-move-find_memory_block-routine.patch b/driver-core/driver-core-move-find_memory_block-routine.patch
new file mode 100644
index 00000000000000..8f6d9f09e6af70
--- /dev/null
+++ b/driver-core/driver-core-move-find_memory_block-routine.patch
@@ -0,0 +1,102 @@
+From nfont@austin.ibm.com Tue Oct 19 10:58:36 2010
+Message-ID: <4CBDD8F4.9020001@austin.ibm.com>
+Date: Tue, 19 Oct 2010 12:44:20 -0500
+From: Nathan Fontenot <nfont@austin.ibm.com>
+To: Greg KH <greg@kroah.com>
+CC: Nathan Fontenot <nfonteno@us.ibm.com>
+Subject: Driver core: Move find_memory_block routine
+
+Move the find_memory_block() routine up to avoid needing a forward
+declaration in subsequent patches.
+
+Signed-off-by: Nathan Fontenot <nfont@austin.ibm.com>
+Reviewed-by: Robin Holt <holt@sgi.com>
+Reviewed-By: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+
+---
+ drivers/base/memory.c | 66 +++++++++++++++++++++++++-------------------------
+ 1 file changed, 33 insertions(+), 33 deletions(-)
+
+--- a/drivers/base/memory.c
++++ b/drivers/base/memory.c
+@@ -435,39 +435,6 @@ int __weak arch_get_memory_phys_device(u
+ return 0;
+ }
+
+-static int add_memory_block(int nid, struct mem_section *section,
+- unsigned long state, enum mem_add_context context)
+-{
+- struct memory_block *mem = kzalloc(sizeof(*mem), GFP_KERNEL);
+- unsigned long start_pfn;
+- int ret = 0;
+-
+- if (!mem)
+- return -ENOMEM;
+-
+- mem->phys_index = __section_nr(section);
+- mem->state = state;
+- mutex_init(&mem->state_mutex);
+- start_pfn = section_nr_to_pfn(mem->phys_index);
+- mem->phys_device = arch_get_memory_phys_device(start_pfn);
+-
+- ret = register_memory(mem, section);
+- if (!ret)
+- ret = mem_create_simple_file(mem, phys_index);
+- if (!ret)
+- ret = mem_create_simple_file(mem, state);
+- if (!ret)
+- ret = mem_create_simple_file(mem, phys_device);
+- if (!ret)
+- ret = mem_create_simple_file(mem, removable);
+- if (!ret) {
+- if (context == HOTPLUG)
+- ret = register_mem_sect_under_node(mem, nid);
+- }
+-
+- return ret;
+-}
+-
+ struct memory_block *find_memory_block_hinted(struct mem_section *section,
+ struct memory_block *hint)
+ {
+@@ -507,6 +474,39 @@ struct memory_block *find_memory_block(s
+ return find_memory_block_hinted(section, NULL);
+ }
+
++static int add_memory_block(int nid, struct mem_section *section,
++ unsigned long state, enum mem_add_context context)
++{
++ struct memory_block *mem = kzalloc(sizeof(*mem), GFP_KERNEL);
++ unsigned long start_pfn;
++ int ret = 0;
++
++ if (!mem)
++ return -ENOMEM;
++
++ mem->phys_index = __section_nr(section);
++ mem->state = state;
++ mutex_init(&mem->state_mutex);
++ start_pfn = section_nr_to_pfn(mem->phys_index);
++ mem->phys_device = arch_get_memory_phys_device(start_pfn);
++
++ ret = register_memory(mem, section);
++ if (!ret)
++ ret = mem_create_simple_file(mem, phys_index);
++ if (!ret)
++ ret = mem_create_simple_file(mem, state);
++ if (!ret)
++ ret = mem_create_simple_file(mem, phys_device);
++ if (!ret)
++ ret = mem_create_simple_file(mem, removable);
++ if (!ret) {
++ if (context == HOTPLUG)
++ ret = register_mem_sect_under_node(mem, nid);
++ }
++
++ return ret;
++}
++
+ int remove_memory_block(unsigned long node_id, struct mem_section *section,
+ int phys_device)
+ {
diff --git a/series b/series
index f91cdf04d8f166..d31c3859255e3c 100644
--- a/series
+++ b/series
@@ -62,6 +62,9 @@ driver-core/kobject-introduce-kset_find_obj_hinted.patch
driver-core/driver-core-introduce-find_memory_block_hinted-which-utilizes-kset_find_obj_hinted.patch
driver-core/driver-core-convert-link_mem_sections-to-use-find_memory_block_hinted.patch
driver-core/hpilo-despecificate-driver-from-ilo-generation.patch
+driver-core/driver-core-move-find_memory_block-routine.patch
+driver-core/driver-core-add-mutex-for-adding-removing-memory-blocks.patch
+driver-core/driver-core-add-section-count-to-memory_block-struct.patch
#####################################
# TTY patches for after 2.6.36 is out
@@ -260,4 +263,3 @@ usb/mxc_udc-add-workaround-for-engcm09152-for-i.mx35.patch
# staging stuff for next is now in the staging-next tree on git.kernel.org
-