24 Feb, 2013

1 commit

  • When (hot)adding memory into system, /sys/firmware/memmap/X/{end, start,
    type} sysfs files are created. But there is no code to remove these
    files. This patch implements the function to remove them.

    We cannot free firmware_map_entry which is allocated by bootmem because
    there is no way to do so when the system is up. But we can at least
    remember the address of that memory and reuse the storage when the
    memory is added next time.

    This patch also introduces a new list map_entries_bootmem to link the
    map entries allocated by bootmem when they are removed, and a lock to
    protect it. And these entries will be reused when the memory is
    hot-added again.

    The idea is suggestted by Andrew Morton.

    NOTE: It is unsafe to return an entry pointer and release the
    map_entries_lock. So we should not hold the map_entries_lock
    separately in firmware_map_find_entry() and
    firmware_map_remove_entry(). Hold the map_entries_lock across find
    and remove /sys/firmware/memmap/X operation.

    And also, users of these two functions need to be careful to
    hold the lock when using these two functions.

    [tangchen@cn.fujitsu.com: Hold spinlock across find|remove /sys operation]
    [tangchen@cn.fujitsu.com: fix the wrong comments of map_entries]
    [tangchen@cn.fujitsu.com: reuse the storage of /sys/firmware/memmap/X/ allocated by bootmem]
    [tangchen@cn.fujitsu.com: fix section mismatch problem]
    [tangchen@cn.fujitsu.com: fix the doc format in drivers/firmware/memmap.c]
    Signed-off-by: Wen Congyang
    Signed-off-by: Yasuaki Ishimatsu
    Signed-off-by: Tang Chen
    Reviewed-by: Kamezawa Hiroyuki
    Cc: KOSAKI Motohiro
    Cc: Jiang Liu
    Cc: Jianguo Wu
    Cc: Lai Jiangshan
    Cc: Tang Chen
    Cc: Ingo Molnar
    Cc: Thomas Gleixner
    Cc: "H. Peter Anvin"
    Cc: Julian Calaby
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Yasuaki Ishimatsu
     

11 Jan, 2011

1 commit


07 Mar, 2010

1 commit

  • A memmap is a directory in sysfs which includes 3 text files: start, end
    and type. For example:

    start: 0x100000
    end: 0x7e7b1cff
    type: System RAM

    Interface firmware_map_add was not called explicitly. Remove it and add
    function firmware_map_add_hotplug as hotplug interface of memmap.

    Each memory entry has a memmap in sysfs, When we hot-add new memory, sysfs
    does not export memmap entry for it. We add a call in function add_memory
    to function firmware_map_add_hotplug.

    Add a new function add_sysfs_fw_map_entry() to create memmap entry, it
    will be called when initialize memmap and hot-add memory.

    [akpm@linux-foundation.org: un-kernedoc a no longer kerneldoc comment]
    Signed-off-by: Shaohui Zheng
    Acked-by: Andi Kleen
    Acked-by: Yasunori Goto
    Reviewed-by: Wu Fengguang
    Cc: Dave Hansen
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    akpm@linux-foundation.org
     

17 Jun, 2009

1 commit

  • Addresses http://bugzilla.kernel.org/show_bug.cgi?id=13484

    Peer reported:
    | The bug is introduced from kernel 2.6.27, if E820 table reserve the memory
    | above 4G in 32bit OS(BIOS-e820: 00000000fff80000 - 0000000120000000
    | (reserved)), system will report Int 6 error and hang up. The bug is caused by
    | the following code in drivers/firmware/memmap.c, the resource_size_t is 32bit
    | variable in 32bit OS, the BUG_ON() will be invoked to result in the Int 6
    | error. I try the latest 32bit Ubuntu and Fedora distributions, all hit this
    | bug.
    |======
    |static int firmware_map_add_entry(resource_size_t start, resource_size_t end,
    | const char *type,
    | struct firmware_map_entry *entry)

    and it only happen with CONFIG_PHYS_ADDR_T_64BIT is not set.

    it turns out we need to pass u64 instead of resource_size_t for that.

    [akpm@linux-foundation.org: add comment]
    Reported-and-tested-by: Peer Chen
    Signed-off-by: Yinghai Lu
    Cc: Ingo Molnar
    Acked-by: H. Peter Anvin
    Cc: Thomas Gleixner
    Cc:
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Yinghai Lu
     

19 Feb, 2009

1 commit

  • Since I don't work for SUSE any more and the bwalle@suse.de address is
    invalid, correct it in the copyright headers and documentation.

    Signed-off-by: Bernhard Walle
    Cc: Greg KH
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Bernhard Walle
     

13 Aug, 2008

1 commit

  • Various cleanup the drivers/firmware/memmap (after review by AKPM):

    - fix kdoc to conform to the standard
    - move kdoc from header to implementation files
    - remove superfluous WARN_ON() after kmalloc()
    - WARN_ON(x); if (!x) -> if(!WARN_ON(x))
    - improve some comments

    Signed-off-by: Bernhard Walle
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Bernhard Walle
     

08 Jul, 2008

1 commit

  • This patch adds /sys/firmware/memmap interface that represents the BIOS
    (or Firmware) provided memory map. The tree looks like:

    /sys/firmware/memmap/0/start (hex number)
    end (hex number)
    type (string)
    ... /1/start
    end
    type

    With the following shell snippet one can print the memory map in the same form
    the kernel prints itself when booting on x86 (the E820 map).

    --------- 8< --------------------------
    #!/bin/sh
    cd /sys/firmware/memmap
    for dir in * ; do
    start=$(cat $dir/start)
    end=$(cat $dir/end)
    type=$(cat $dir/type)
    printf "%016x-%016x (%s)\n" $start $[ $end +1] "$type"
    done
    --------- >8 --------------------------

    That patch only provides the needed interface:

    1. The sysfs interface.
    2. The structure and enumeration definition.
    3. The function firmware_map_add() and firmware_map_add_early()
    that should be called from architecture code (E820/EFI, for
    example) to add the contents to the interface.

    If the kernel is compiled without CONFIG_FIRMWARE_MEMMAP, the interface does
    nothing without cluttering the architecture-specific code with #ifdef's.

    The purpose of the new interface is kexec: While /proc/iomem represents
    the *used* memory map (e.g. modified via kernel parameters like 'memmap'
    and 'mem'), the /sys/firmware/memmap tree represents the unmodified memory
    map provided via the firmware. So kexec can:

    - use the original memory map for rebooting,
    - use the /proc/iomem for setting up the ELF core headers for kdump
    case that should only represent the memory of the system.

    The patch has been tested on i386 and x86_64.

    Signed-off-by: Bernhard Walle
    Acked-by: Greg KH
    Acked-by: Vivek Goyal
    Cc: kexec@lists.infradead.org
    Cc: yhlu.kernel@gmail.com
    Signed-off-by: Ingo Molnar

    Bernhard Walle