Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 186202
b: refs/heads/master
c: d96ae53
h: refs/heads/master
v: v3
  • Loading branch information
akpm@linux-foundation.org authored and Linus Torvalds committed Mar 6, 2010
1 parent 15116d4 commit e6c267a
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 25 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 9d8cebd4bcd7c3878462fdfda34bbcdeb4df7ef4
refs/heads/master: d96ae5309165d9ed7c008a178238977b73595cd9
57 changes: 36 additions & 21 deletions trunk/drivers/firmware/memmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,29 +122,53 @@ static int firmware_map_add_entry(u64 start, u64 end,
return 0;
}

/*
* Add memmap entry on sysfs
*/
static int add_sysfs_fw_map_entry(struct firmware_map_entry *entry)
{
static int map_entries_nr;
static struct kset *mmap_kset;

if (!mmap_kset) {
mmap_kset = kset_create_and_add("memmap", NULL, firmware_kobj);
if (!mmap_kset)
return -ENOMEM;
}

entry->kobj.kset = mmap_kset;
if (kobject_add(&entry->kobj, NULL, "%d", map_entries_nr++))
kobject_put(&entry->kobj);

return 0;
}

/**
* firmware_map_add() - Adds a firmware mapping entry.
* firmware_map_add_hotplug() - Adds a firmware mapping entry when we do
* memory hotplug.
* @start: Start of the memory range.
* @end: End of the memory range (inclusive).
* @type: Type of the memory range.
*
* This function uses kmalloc() for memory
* allocation. Use firmware_map_add_early() if you want to use the bootmem
* allocator.
*
* That function must be called before late_initcall.
* Adds a firmware mapping entry. This function is for memory hotplug, it is
* similar to function firmware_map_add_early(). The only difference is that
* it will create the syfs entry dynamically.
*
* Returns 0 on success, or -ENOMEM if no memory could be allocated.
**/
int firmware_map_add(u64 start, u64 end, const char *type)
int __meminit firmware_map_add_hotplug(u64 start, u64 end, const char *type)
{
struct firmware_map_entry *entry;

entry = kmalloc(sizeof(struct firmware_map_entry), GFP_ATOMIC);
entry = kzalloc(sizeof(struct firmware_map_entry), GFP_ATOMIC);
if (!entry)
return -ENOMEM;

return firmware_map_add_entry(start, end, type, entry);
firmware_map_add_entry(start, end, type, entry);
/* create the memmap entry */
add_sysfs_fw_map_entry(entry);

return 0;
}

/**
Expand All @@ -154,7 +178,7 @@ int firmware_map_add(u64 start, u64 end, const char *type)
* @type: Type of the memory range.
*
* Adds a firmware mapping entry. This function uses the bootmem allocator
* for memory allocation. Use firmware_map_add() if you want to use kmalloc().
* for memory allocation.
*
* That function must be called before late_initcall.
*
Expand Down Expand Up @@ -214,19 +238,10 @@ static ssize_t memmap_attr_show(struct kobject *kobj,
*/
static int __init memmap_init(void)
{
int i = 0;
struct firmware_map_entry *entry;
struct kset *memmap_kset;

memmap_kset = kset_create_and_add("memmap", NULL, firmware_kobj);
if (WARN_ON(!memmap_kset))
return -ENOMEM;

list_for_each_entry(entry, &map_entries, list) {
entry->kobj.kset = memmap_kset;
if (kobject_add(&entry->kobj, NULL, "%d", i++))
kobject_put(&entry->kobj);
}
list_for_each_entry(entry, &map_entries, list)
add_sysfs_fw_map_entry(entry);

return 0;
}
Expand Down
6 changes: 3 additions & 3 deletions trunk/include/linux/firmware-map.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@
*/
#ifdef CONFIG_FIRMWARE_MEMMAP

int firmware_map_add(u64 start, u64 end, const char *type);
int firmware_map_add_early(u64 start, u64 end, const char *type);
int firmware_map_add_hotplug(u64 start, u64 end, const char *type);

#else /* CONFIG_FIRMWARE_MEMMAP */

static inline int firmware_map_add(u64 start, u64 end, const char *type)
static inline int firmware_map_add_early(u64 start, u64 end, const char *type)
{
return 0;
}

static inline int firmware_map_add_early(u64 start, u64 end, const char *type)
static inline int firmware_map_add_hotplug(u64 start, u64 end, const char *type)
{
return 0;
}
Expand Down
4 changes: 4 additions & 0 deletions trunk/mm/memory_hotplug.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <linux/pfn.h>
#include <linux/suspend.h>
#include <linux/mm_inline.h>
#include <linux/firmware-map.h>

#include <asm/tlbflush.h>

Expand Down Expand Up @@ -523,6 +524,9 @@ int __ref add_memory(int nid, u64 start, u64 size)
BUG_ON(ret);
}

/* create new memmap entry */
firmware_map_add_hotplug(start, start + size, "System RAM");

goto out;

error:
Expand Down

0 comments on commit e6c267a

Please sign in to comment.