1. 15 4月, 2016 1 次提交
  2. 10 3月, 2016 3 次提交
    • T
      resource: Export insert_resource and remove_resource · 8095d0f2
      Toshi Kani 提交于
      insert_resource() and remove_resouce() are called by producers
      of resources, such as FW modules and bus drivers.  These modules
      may be implemented as loadable modules.
      
      Export insert_resource() and remove_resouce() so that they can
      be called from such modules.
      
      link: https://lkml.org/lkml/2016/3/8/872Signed-off-by: NToshi Kani <toshi.kani@hpe.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Borislav Petkov <bp@suse.de>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Dan Williams <dan.j.williams@intel.com>
      Signed-off-by: NDan Williams <dan.j.williams@intel.com>
      8095d0f2
    • T
      resource: Add remove_resource interface · ff3cc952
      Toshi Kani 提交于
      insert_resource() and insert_resource_conflict() are called
      by resource producers to insert a new resource.  When there
      is any conflict, they move conflicting resources down to the
      children of the new resource.  There is no destructor of these
      interfaces, however.
      
      Add remove_resource(), which removes a resource previously
      inserted by insert_resource() or insert_resource_conflict(),
      and moves the children up to where they were before.
      
      __release_resource() is changed to have @release_child, so
      that this function can be used for remove_resource() as well.
      
      Also add comments to clarify that these functions are intended
      for producers of resources to avoid any confusion with
      request/release_resource() for consumers.
      Signed-off-by: NToshi Kani <toshi.kani@hpe.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Borislav Petkov <bp@suse.de>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Dan Williams <dan.j.williams@intel.com>
      Signed-off-by: NDan Williams <dan.j.williams@intel.com>
      ff3cc952
    • T
      resource: Change __request_region to inherit from immediate parent · 4e0d8f7e
      Toshi Kani 提交于
      __request_region() sets 'flags' of a new resource from @parent
      as it inherits the parent's attribute.  When a target resource
      has a conflict, this function inserts the new resource entry
      under the conflicted entry by updating @parent.  In this case,
      the new resource entry needs to inherit attribute from the updated
      parent.  This conflict is a typical case since __request_region()
      is used to allocate a new resource from a specific resource range.
      
      For instance, request_mem_region() calls __request_region() with
      @parent set to &iomem_resource, which is the root entry of the
      whole iomem range.  When this request results in inserting a new
      entry "DEV-A" under "BUS-1", "DEV-A" needs to inherit from the
      immediate parent "BUS-1" as it holds specific attribute for the
      range.
      
      root (&iomem_resource)
       :
       + "BUS-1"
          + "DEV-A"
      
      Change __request_region() to set 'flags' and 'desc' of a new entry
      from the immediate parent.
      Signed-off-by: NToshi Kani <toshi.kani@hpe.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Borislav Petkov <bp@suse.de>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Dan Williams <dan.j.williams@intel.com>
      Signed-off-by: NDan Williams <dan.j.williams@intel.com>
      4e0d8f7e
  3. 21 2月, 2016 1 次提交
    • S
      kernel/resource.c: fix muxed resource handling in __request_region() · 59ceeaaf
      Simon Guinot 提交于
      In __request_region, if a conflict with a BUSY and MUXED resource is
      detected, then the caller goes to sleep and waits for the resource to be
      released.  A pointer on the conflicting resource is kept.  At wake-up
      this pointer is used as a parent to retry to request the region.
      
      A first problem is that this pointer might well be invalid (if for
      example the conflicting resource have already been freed).  Another
      problem is that the next call to __request_region() fails to detect a
      remaining conflict.  The previously conflicting resource is passed as a
      parameter and __request_region() will look for a conflict among the
      children of this resource and not at the resource itself.  It is likely
      to succeed anyway, even if there is still a conflict.
      
      Instead, the parent of the conflicting resource should be passed to
      __request_region().
      
      As a fix, this patch doesn't update the parent resource pointer in the
      case we have to wait for a muxed region right after.
      Reported-and-tested-by: NVincent Pelletier <plr.vincent@gmail.com>
      Signed-off-by: NSimon Guinot <simon.guinot@sequanux.org>
      Tested-by: NVincent Donnefort <vdonnefort@gmail.com>
      Cc: stable@kernel.org
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      59ceeaaf
  4. 30 1月, 2016 6 次提交
    • T
      resource: Kill walk_iomem_res() · a8fc4253
      Toshi Kani 提交于
      walk_iomem_res_desc() replaced walk_iomem_res() and there is no
      caller to walk_iomem_res() any more. Kill it. Also remove @name
      from find_next_iomem_res() as it is no longer used.
      Signed-off-by: NToshi Kani <toshi.kani@hpe.com>
      Signed-off-by: NBorislav Petkov <bp@suse.de>
      Acked-by: NDave Young <dyoung@redhat.com>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Brian Gerst <brgerst@gmail.com>
      Cc: Dan Williams <dan.j.williams@intel.com>
      Cc: Denys Vlasenko <dvlasenk@redhat.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Hanjun Guo <hanjun.guo@linaro.org>
      Cc: Jakub Sitnicki <jsitnicki@gmail.com>
      Cc: Jiang Liu <jiang.liu@linux.intel.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Luis R. Rodriguez <mcgrof@suse.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Toshi Kani <toshi.kani@hp.com>
      Cc: Vinod Koul <vinod.koul@intel.com>
      Cc: linux-arch@vger.kernel.org
      Cc: linux-mm <linux-mm@kvack.org>
      Link: http://lkml.kernel.org/r/1453841853-11383-17-git-send-email-bp@alien8.deSigned-off-by: NIngo Molnar <mingo@kernel.org>
      a8fc4253
    • T
      resource: Add walk_iomem_res_desc() · 3f33647c
      Toshi Kani 提交于
      Add a new interface, walk_iomem_res_desc(), which walks through
      the iomem table by identifying a target with @flags and @desc.
      This interface provides the same functionality as
      walk_iomem_res(), but does not use strcmp() to @name for better
      efficiency.
      
      walk_iomem_res() is deprecated and will be removed in a later
      patch.
      Requested-by: NBorislav Petkov <bp@suse.de>
      Signed-off-by: NToshi Kani <toshi.kani@hpe.com>
      [ Fixup comments. ]
      Signed-off-by: NBorislav Petkov <bp@suse.de>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Brian Gerst <brgerst@gmail.com>
      Cc: Dan Williams <dan.j.williams@intel.com>
      Cc: Denys Vlasenko <dvlasenk@redhat.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Hanjun Guo <hanjun.guo@linaro.org>
      Cc: Jakub Sitnicki <jsitnicki@gmail.com>
      Cc: Jiang Liu <jiang.liu@linux.intel.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Luis R. Rodriguez <mcgrof@suse.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Toshi Kani <toshi.kani@hp.com>
      Cc: linux-arch@vger.kernel.org
      Cc: linux-mm <linux-mm@kvack.org>
      Link: http://lkml.kernel.org/r/1453841853-11383-14-git-send-email-bp@alien8.deSigned-off-by: NIngo Molnar <mingo@kernel.org>
      3f33647c
    • T
      memremap: Change region_intersects() to take @flags and @desc · 1c29f25b
      Toshi Kani 提交于
      Change region_intersects() to identify a target with @flags and
      @desc, instead of @name with strcmp().
      
      Change the callers of region_intersects(), memremap() and
      devm_memremap(), to set IORESOURCE_SYSTEM_RAM in @flags and
      IORES_DESC_NONE in @desc when searching System RAM.
      
      Also, export region_intersects() so that the ACPI EINJ error
      injection driver can call this function in a later patch.
      Signed-off-by: NToshi Kani <toshi.kani@hpe.com>
      Signed-off-by: NBorislav Petkov <bp@suse.de>
      Acked-by: NDan Williams <dan.j.williams@intel.com>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Brian Gerst <brgerst@gmail.com>
      Cc: Denys Vlasenko <dvlasenk@redhat.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Jakub Sitnicki <jsitnicki@gmail.com>
      Cc: Jan Kara <jack@suse.cz>
      Cc: Jiang Liu <jiang.liu@linux.intel.com>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
      Cc: Konstantin Khlebnikov <koct9i@gmail.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Luis R. Rodriguez <mcgrof@suse.com>
      Cc: Michal Hocko <mhocko@suse.com>
      Cc: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Tejun Heo <tj@kernel.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Toshi Kani <toshi.kani@hp.com>
      Cc: Vlastimil Babka <vbabka@suse.cz>
      Cc: linux-arch@vger.kernel.org
      Cc: linux-mm <linux-mm@kvack.org>
      Link: http://lkml.kernel.org/r/1453841853-11383-13-git-send-email-bp@alien8.deSigned-off-by: NIngo Molnar <mingo@kernel.org>
      1c29f25b
    • T
      resource: Change walk_system_ram() to use System RAM type · bd7e6cb3
      Toshi Kani 提交于
      Now that all System RAM resource entries have been initialized
      to IORESOURCE_SYSTEM_RAM type, change walk_system_ram_res() and
      walk_system_ram_range() to call find_next_iomem_res() by setting
      @res.flags to IORESOURCE_SYSTEM_RAM and @name to NULL. With this
      change, they walk through the iomem table to find System RAM
      ranges without the need to do strcmp() on the resource names.
      
      No functional change is made to the interfaces.
      Signed-off-by: NToshi Kani <toshi.kani@hpe.com>
      [ Boris: fixup comments. ]
      Signed-off-by: NBorislav Petkov <bp@suse.de>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Brian Gerst <brgerst@gmail.com>
      Cc: Dan Williams <dan.j.williams@intel.com>
      Cc: Denys Vlasenko <dvlasenk@redhat.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Jakub Sitnicki <jsitnicki@gmail.com>
      Cc: Jiang Liu <jiang.liu@linux.intel.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Luis R. Rodriguez <mcgrof@suse.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Toshi Kani <toshi.kani@hp.com>
      Cc: linux-arch@vger.kernel.org
      Cc: linux-mm <linux-mm@kvack.org>
      Link: http://lkml.kernel.org/r/1453841853-11383-11-git-send-email-bp@alien8.deSigned-off-by: NIngo Molnar <mingo@kernel.org>
      bd7e6cb3
    • T
      resource: Add I/O resource descriptor · 43ee493b
      Toshi Kani 提交于
      walk_iomem_res() and region_intersects() still need to use
      strcmp() for searching a resource entry by @name in the iomem
      table.
      
      This patch introduces I/O resource descriptor 'desc' in struct
      resource for the iomem search interfaces. Drivers can assign
      their unique descriptor to a range when they support the search
      interfaces.
      
      Otherwise, 'desc' is set to IORES_DESC_NONE (0). This avoids
      changing most of the drivers as they typically allocate resource
      entries statically, or by calling alloc_resource(), kzalloc(),
      or alloc_bootmem_low(), which set the field to zero by default.
      A later patch will address some drivers that use kmalloc()
      without zero'ing the field.
      
      Also change release_mem_region_adjustable() to set 'desc' when
      its resource entry gets separated. Other resource interfaces are
      also changed to initialize 'desc' explicitly although
      alloc_resource() sets it to 0.
      Signed-off-by: NToshi Kani <toshi.kani@hpe.com>
      Signed-off-by: NBorislav Petkov <bp@suse.de>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Brian Gerst <brgerst@gmail.com>
      Cc: Dan Williams <dan.j.williams@intel.com>
      Cc: Denys Vlasenko <dvlasenk@redhat.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Jakub Sitnicki <jsitnicki@gmail.com>
      Cc: Jiang Liu <jiang.liu@linux.intel.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Luis R. Rodriguez <mcgrof@suse.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Toshi Kani <toshi.kani@hp.com>
      Cc: linux-arch@vger.kernel.org
      Cc: linux-mm <linux-mm@kvack.org>
      Link: http://lkml.kernel.org/r/1453841853-11383-4-git-send-email-bp@alien8.deSigned-off-by: NIngo Molnar <mingo@kernel.org>
      43ee493b
    • T
      resource: Handle resource flags properly · a3650d53
      Toshi Kani 提交于
      I/O resource flags consist of I/O resource types and modifier
      bits. Therefore, checking an I/O resource type in 'flags' must
      be performed with a bitwise operation.
      
      Fix find_next_iomem_res() and region_intersects() that simply
      compare 'flags' against a given value.
      
      Also change __request_region() to set 'res->flags' from
      resource_type() and resource_ext_type() of the parent, so that
      children nodes will inherit the extended I/O resource type.
      Signed-off-by: NToshi Kani <toshi.kani@hpe.com>
      Signed-off-by: NBorislav Petkov <bp@suse.de>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Brian Gerst <brgerst@gmail.com>
      Cc: Dan Williams <dan.j.williams@intel.com>
      Cc: Denys Vlasenko <dvlasenk@redhat.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Jakub Sitnicki <jsitnicki@gmail.com>
      Cc: Jiang Liu <jiang.liu@linux.intel.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Luis R. Rodriguez <mcgrof@suse.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Toshi Kani <toshi.kani@hp.com>
      Cc: Vinod Koul <vinod.koul@intel.com>
      Cc: linux-arch@vger.kernel.org
      Cc: linux-mm <linux-mm@kvack.org>
      Link: http://lkml.kernel.org/r/1453841853-11383-3-git-send-email-bp@alien8.deSigned-off-by: NIngo Molnar <mingo@kernel.org>
      a3650d53
  5. 09 1月, 2016 1 次提交
    • D
      restrict /dev/mem to idle io memory ranges · 90a545e9
      Dan Williams 提交于
      This effectively promotes IORESOURCE_BUSY to IORESOURCE_EXCLUSIVE
      semantics by default.  If userspace really believes it is safe to access
      the memory region it can also perform the extra step of disabling an
      active driver.  This protects device address ranges with read side
      effects and otherwise directs userspace to use the driver.
      
      Persistent memory presents a large "mistake surface" to /dev/mem as now
      accidental writes can corrupt a filesystem.
      
      In general if a device driver is busily using a memory region it already
      informs other parts of the kernel to not touch it via
      request_mem_region().  /dev/mem should honor the same safety restriction
      by default.  Debugging a device driver from userspace becomes more
      difficult with this enabled.  Any application using /dev/mem or mmap of
      sysfs pci resources will now need to perform the extra step of either:
      
      1/ Disabling the driver, for example:
      
         echo <device id> > /dev/bus/<parent bus>/drivers/<driver name>/unbind
      
      2/ Rebooting with "iomem=relaxed" on the command line
      
      3/ Recompiling with CONFIG_IO_STRICT_DEVMEM=n
      
      Traditional users of /dev/mem like dosemu are unaffected because the
      first 1MB of memory is not subject to the IO_STRICT_DEVMEM restriction.
      Legacy X configurations use /dev/mem to talk to graphics hardware, but
      that functionality has since moved to kernel graphics drivers.
      
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Russell King <linux@arm.linux.org.uk>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Acked-by: NKees Cook <keescook@chromium.org>
      Acked-by: NIngo Molnar <mingo@redhat.com>
      Signed-off-by: NDan Williams <dan.j.williams@intel.com>
      90a545e9
  6. 11 8月, 2015 1 次提交
    • D
      mm: enhance region_is_ram() to region_intersects() · 124fe20d
      Dan Williams 提交于
      region_is_ram() is used to prevent the establishment of aliased mappings
      to physical "System RAM" with incompatible cache settings.  However, it
      uses "-1" to indicate both "unknown" memory ranges (ranges not described
      by platform firmware) and "mixed" ranges (where the parameters describe
      a range that partially overlaps "System RAM").
      
      Fix this up by explicitly tracking the "unknown" vs "mixed" resource
      cases and returning REGION_INTERSECTS, REGION_MIXED, or REGION_DISJOINT.
      This re-write also adds support for detecting when the requested region
      completely eclipses all of a resource.  Note, the implementation treats
      overlaps between "unknown" and the requested memory type as
      REGION_INTERSECTS.
      
      Finally, other memory types can be passed in by name, for now the only
      usage "System RAM".
      Suggested-by: NLuis R. Rodriguez <mcgrof@suse.com>
      Reviewed-by: NToshi Kani <toshi.kani@hp.com>
      Signed-off-by: NDan Williams <dan.j.williams@intel.com>
      124fe20d
  7. 22 7月, 2015 1 次提交
  8. 16 4月, 2015 1 次提交
  9. 05 2月, 2015 1 次提交
  10. 14 10月, 2014 1 次提交
    • M
      x86: optimize resource lookups for ioremap · 67cf13ce
      Mike Travis 提交于
      We have a large university system in the UK that is experiencing very long
      delays modprobing the driver for a specific I/O device.  The delay is from
      8-10 minutes per device and there are 31 devices in the system.  This 4 to
      5 hour delay in starting up those I/O devices is very much a burden on the
      customer.
      
      There are two causes for requiring a restart/reload of the drivers.  First
      is periodic preventive maintenance (PM) and the second is if any of the
      devices experience a fatal error.  Both of these trigger this excessively
      long delay in bringing the system back up to full capability.
      
      The problem was tracked down to a very slow IOREMAP operation and the
      excessively long ioresource lookup to insure that the user is not
      attempting to ioremap RAM.  These patches provide a speed up to that
      function.
      
      The modprobe time appears to be affected quite a bit by previous activity
      on the ioresource list, which I suspect is due to cache preloading.  While
      the overall improvement is impacted by other overhead of starting the
      devices, this drastically improves the modprobe time.
      
      Also our system is considerably smaller so the percentages gained will not
      be the same.  Best case improvement with the modprobe on our 20 device
      smallish system was from 'real 5m51.913s' to 'real 0m18.275s'.
      
      This patch (of 2):
      
      Since the ioremap operation is verifying that the specified address range
      is NOT RAM, it will search the entire ioresource list if the condition is
      true.  To make matters worse, it does this one 4k page at a time.  For a
      128M BAR region this is 32 passes to determine the entire region does not
      contain any RAM addresses.
      
      This patch provides another resource lookup function, region_is_ram, that
      searches for the entire region specified, verifying that it is completely
      contained within the resource region.  If it is found, then it is checked
      to be RAM or not, within a single pass.
      
      The return result reflects if it was found or not (-1), and whether it is
      RAM (1) or not (0).  This allows the caller to fallback to the previous
      page by page search if it was not found.
      
      [akpm@linux-foundation.org: fix spellos and typos in comment]
      Signed-off-by: NMike Travis <travis@sgi.com>
      Acked-by: NAlex Thorlton <athorlton@sgi.com>
      Reviewed-by: NCliff Wickman <cpw@sgi.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Mark Salter <msalter@redhat.com>
      Cc: Dave Young <dyoung@redhat.com>
      Cc: Rik van Riel <riel@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Mel Gorman <mgorman@suse.de>
      Cc: Ingo Molnar <mingo@elte.hu>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      67cf13ce
  11. 05 9月, 2014 1 次提交
  12. 30 8月, 2014 1 次提交
    • V
      resource: fix the case of null pointer access · 800df627
      Vivek Goyal 提交于
      Richard and Daniel reported that UML is broken due to changes to
      resource traversal functions.  Problem is that iomem_resource.child can
      be null and new code does not consider that possibility.  Old code used
      a for loop and that loop will not even execute if p was null.
      
      Revert back to for() loop logic and bail out if p is null.
      
      I also moved sibling_only check out of resource_lock. There is no
      reason to keep it inside the lock.
      
      Following is backtrace of the UML crash.
      
      RIP: 0033:[<0000000060039b9f>]
      RSP: 0000000081459da0  EFLAGS: 00010202
      RAX: 0000000000000000 RBX: 00000000219b3fff RCX: 000000006010d1d9
      RDX: 0000000000000001 RSI: 00000000602dfb94 RDI: 0000000081459df8
      RBP: 0000000081459de0 R08: 00000000601b59f4 R09: ffffffff0000ff00
      R10: ffffffff0000ff00 R11: 0000000081459e88 R12: 0000000081459df8
      R13: 00000000219b3fff R14: 00000000602dfb94 R15: 0000000000000000
      Kernel panic - not syncing: Segfault with no mm
      CPU: 0 PID: 1 Comm: swapper Not tainted 3.16.0-10454-g58d08e3b #13
      Stack:
       00000000 000080d0 81459df0 219b3fff
       81459e70 6010d1d9 ffffffff 6033e010
       81459e50 6003a269 81459e30 00000000
      Call Trace:
       [<6010d1d9>] ? kclist_add_private+0x0/0xe7
       [<6003a269>] walk_system_ram_range+0x61/0xb7
       [<6000e859>] ? proc_kcore_init+0x0/0xf1
       [<6010d574>] kcore_update_ram+0x4c/0x168
       [<6010d72e>] ? kclist_add+0x0/0x2e
       [<6000e943>] proc_kcore_init+0xea/0xf1
       [<6000e859>] ? proc_kcore_init+0x0/0xf1
       [<6000e859>] ? proc_kcore_init+0x0/0xf1
       [<600189f0>] do_one_initcall+0x13c/0x204
       [<6004ca46>] ? parse_args+0x1df/0x2e0
       [<6004c82d>] ? parameq+0x0/0x3a
       [<601b5990>] ? strcpy+0x0/0x18
       [<60001e1a>] kernel_init_freeable+0x240/0x31e
       [<6026f1c0>] kernel_init+0x12/0x148
       [<60019fad>] new_thread_handler+0x81/0xa3
      
      Fixes 8c86e70a ("resource: provide new functions to walk
      through resources").
      Reported-by: NDaniel Walter <sahne@0x90.at>
      Tested-by: NRichard Weinberger <richard@nod.at>
      Tested-by: NToralf Förster <toralf.foerster@gmx.de>
      Tested-by: NDaniel Walter <sahne@0x90.at>
      Signed-off-by: NVivek Goyal <vgoyal@redhat.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      800df627
  13. 09 8月, 2014 1 次提交
    • V
      resource: provide new functions to walk through resources · 8c86e70a
      Vivek Goyal 提交于
      I have added two more functions to walk through resources.
      
      Currently walk_system_ram_range() deals with pfn and /proc/iomem can
      contain partial pages.  By dealing in pfn, callback function loses the
      info that last page of a memory range is a partial page and not the full
      page.  So I implemented walk_system_ram_res() which returns u64 values to
      callback functions and now it properly return start and end address.
      
      walk_system_ram_range() uses find_next_system_ram() to find the next ram
      resource.  This in turn only travels through siblings of top level child
      and does not travers through all the nodes of the resoruce tree.  I also
      need another function where I can walk through all the resources, for
      example figure out where "GART" aperture is.  Figure out where ACPI memory
      is.
      
      So I wrote another function walk_iomem_res() which walks through all
      /proc/iomem resources and returns matches as asked by caller.  Caller can
      specify "name" of resource, start and end and flags.
      
      Got rid of find_next_system_ram_res() and instead implemented more generic
      find_next_iomem_res() which can be used to traverse top level children
      only based on an argument.
      Signed-off-by: NVivek Goyal <vgoyal@redhat.com>
      Cc: Yinghai Lu <yinghai@kernel.org>
      Cc: Borislav Petkov <bp@suse.de>
      Cc: Michael Kerrisk <mtk.manpages@gmail.com>
      Cc: Eric Biederman <ebiederm@xmission.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Matthew Garrett <mjg59@srcf.ucam.org>
      Cc: Greg Kroah-Hartman <greg@kroah.com>
      Cc: Dave Young <dyoung@redhat.com>
      Cc: WANG Chao <chaowang@redhat.com>
      Cc: Baoquan He <bhe@redhat.com>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      8c86e70a
  14. 24 5月, 2014 1 次提交
    • B
      resources: Clarify sanity check message · e4c72966
      Bjorn Helgaas 提交于
      The resource map sanity check message is a bit confusing.  Change it to be
      more readable:
      
        -resource map sanity check conflict: 0xfed10000 0xfed15fff 0xfed10000 0xfed13fff pnp 00:01
        +resource sanity check: requesting [mem 0xfed10000-0xfed15fff], which spans more than pnp 00:01 [mem 0xfed10000-0xfed13fff]
      Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
      e4c72966
  15. 04 4月, 2014 1 次提交
  16. 20 3月, 2014 1 次提交
    • B
      resources: Set type in __request_region() · 6404e88e
      Bjorn Helgaas 提交于
      We don't set the type (I/O, memory, etc.) of resources added by
      __request_region(), which leads to confusing messages like this:
      
          address space collision: [io  0x1000-0x107f] conflicts with ACPI CPU throttle [??? 0x00001010-0x00001015 flags 0x80000000]
      
      Set the type of a new resource added by __request_region() (used by
      request_region() and request_mem_region()) to the type of its parent.  This
      makes the resource tree internally consistent and fixes messages like the
      above, where the ACPI CPU throttle resource really is an I/O port region,
      but request_region() didn't fill in the type, so %pR didn't know how to
      print it.
      
      Sample dmesg showing the issue at the link below.
      
      Link: https://bugzilla.kernel.org/show_bug.cgi?id=71611Reported-by: NPaul Bolle <pebolle@tiscali.nl>
      Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
      6404e88e
  17. 27 2月, 2014 1 次提交
    • B
      resource: Add resource_contains() · 5edb93b8
      Bjorn Helgaas 提交于
      We have two identical copies of resource_contains() already, and more
      places that could use it.  This moves it to ioport.h where it can be
      shared.
      
      resource_contains(struct resource *r1, struct resource *r2) returns true
      iff r1 and r2 are the same type (most callers already checked this
      separately) and the r1 address range completely contains r2.
      
      In addition, the new resource_contains() checks that both r1 and r2 have
      addresses assigned to them.  If a resource is IORESOURCE_UNSET, it doesn't
      have a valid address and can't contain or be contained by another resource.
      Some callers already check this or for res->start.
      
      No functional change.
      Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
      5edb93b8
  18. 04 7月, 2013 1 次提交
  19. 07 6月, 2013 1 次提交
    • C
      ACPI/APEI: Add parameter check before error injection · c5a13032
      Chen Gong 提交于
      When param1 is enabled in EINJ but not assigned with a valid
      value, sometimes it will cause the error like below:
      
      APEI: Can not request [mem 0x7aaa7000-0x7aaa7007] for APEI EINJ Trigger registers
      
      It is because some firmware will access target address specified in
      param1 to trigger the error when injecting memory error. This will
      cause resource conflict with regular memory. So It must be removed
      from trigger table resources, but incorrect param1/param2
      combination will stop this action. Add extra check to avoid
      this kind of error.
      Signed-off-by: NChen Gong <gong.chen@linux.intel.com>
      Signed-off-by: NTony Luck <tony.luck@intel.com>
      c5a13032
  20. 30 4月, 2013 3 次提交
    • Y
      mem hotunplug: fix kfree() of bootmem memory · ebff7d8f
      Yasuaki Ishimatsu 提交于
      When hot removing memory presented at boot time, following messages are shown:
      
        kernel BUG at mm/slub.c:3409!
        invalid opcode: 0000 [#1] SMP
        Modules linked in: ebtable_nat ebtables xt_CHECKSUM iptable_mangle bridge stp llc ipmi_devintf ipmi_msghandler sunrpc ipt_REJECT nf_conntrack_ipv4 nf_defrag_ipv4 iptable_filter ip_tables ip6t_REJECT nf_conntrack_ipv6 nf_defrag_ipv6 xt_state nf_conntrack ip6table_filter ip6_tables binfmt_misc vfat fat dm_mirror dm_region_hash dm_log dm_mod vhost_net macvtap macvlan tun uinput iTCO_wdt iTCO_vendor_support coretemp kvm_intel kvm crc32c_intel ghash_clmulni_intel microcode pcspkr sg i2c_i801 lpc_ich mfd_core igb i2c_algo_bit i2c_core e1000e ptp pps_core tpm_infineon ioatdma dca sr_mod cdrom sd_mod crc_t10dif usb_storage megaraid_sas lpfc scsi_transport_fc scsi_tgt scsi_mod
        CPU 0
        Pid: 5091, comm: kworker/0:2 Tainted: G        W    3.9.0-rc6+ #15
        RIP: kfree+0x232/0x240
        Process kworker/0:2 (pid: 5091, threadinfo ffff88084678c000, task ffff88083928ca80)
        Call Trace:
          __release_region+0xd4/0xe0
          __remove_pages+0x52/0x110
          arch_remove_memory+0x89/0xd0
          remove_memory+0xc4/0x100
          acpi_memory_device_remove+0x6d/0xb1
          acpi_device_remove+0x89/0xab
          __device_release_driver+0x7c/0xf0
          device_release_driver+0x2f/0x50
          acpi_bus_device_detach+0x6c/0x70
          acpi_ns_walk_namespace+0x11a/0x250
          acpi_walk_namespace+0xee/0x137
          acpi_bus_trim+0x33/0x7a
          acpi_bus_hot_remove_device+0xc4/0x1a1
          acpi_os_execute_deferred+0x27/0x34
          process_one_work+0x1f7/0x590
          worker_thread+0x11a/0x370
          kthread+0xee/0x100
          ret_from_fork+0x7c/0xb0
        RIP  [<ffffffff811c41d2>] kfree+0x232/0x240
         RSP <ffff88084678d968>
      
      The reason why the messages are shown is to release a resource
      structure, allocated by bootmem, by kfree().  So when we release a
      resource structure, we should check whether it is allocated by bootmem
      or not.
      
      But even if we know a resource structure is allocated by bootmem, we
      cannot release it since SLxB cannot treat it.  So for reusing a resource
      structure, this patch remembers it by using bootmem_resource as follows:
      
      When releasing a resource structure by free_resource(), free_resource()
      checks whether the resource structure is allocated by bootmem or not.
      If it is allocated by bootmem, free_resource() adds it to
      bootmem_resource.  If it is not allocated by bootmem, free_resource()
      release it by kfree().
      
      And when getting a new resource structure by get_resource(),
      get_resource() checks whether bootmem_resource has released resource
      structures or not.  If there is a released resource structure,
      get_resource() returns it.  If there is not a releaed resource
      structure, get_resource() returns new resource structure allocated by
      kzalloc().
      
      [akpm@linux-foundation.org: s/get_resource/alloc_resource/]
      Signed-off-by: NYasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
      Reviewed-by: NToshi Kani <toshi.kani@hp.com>
      Cc: Johannes Weiner <hannes@cmpxchg.org>
      Cc: Ram Pai <linuxram@us.ibm.com>
      Cc: David Rientjes <rientjes@google.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      ebff7d8f
    • T
      resource: add release_mem_region_adjustable() · 825f787b
      Toshi Kani 提交于
      Add release_mem_region_adjustable(), which releases a requested region
      from a currently busy memory resource.  This interface adjusts the
      matched memory resource accordingly even if the requested region does
      not match exactly but still fits into.
      
      This new interface is intended for memory hot-delete.  During bootup,
      memory resources are inserted from the boot descriptor table, such as
      EFI Memory Table and e820.  Each memory resource entry usually covers
      the whole contigous memory range.  Memory hot-delete request, on the
      other hand, may target to a particular range of memory resource, and its
      size can be much smaller than the whole contiguous memory.  Since the
      existing release interfaces like __release_region() require a requested
      region to be exactly matched to a resource entry, they do not allow a
      partial resource to be released.
      
      This new interface is restrictive (i.e.  release under certain
      conditions), which is consistent with other release interfaces,
      __release_region() and __release_resource().  Additional release
      conditions, such as an overlapping region to a resource entry, can be
      supported after they are confirmed as valid cases.
      
      There is no change to the existing interfaces since their restriction is
      valid for I/O resources.
      
      [akpm@linux-foundation.org: use GFP_ATOMIC under write_lock()]
      [akpm@linux-foundation.org: switch back to GFP_KERNEL, less buggily]
      [akpm@linux-foundation.org: remove unneeded and wrong kfree(), per Toshi]
      Signed-off-by: NToshi Kani <toshi.kani@hp.com>
      Reviewed-by : Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
      Cc: David Rientjes <rientjes@google.com>
      Reviewed-by: NRam Pai <linuxram@us.ibm.com>
      Cc: T Makphaibulchoke <tmac@hp.com>
      Cc: Wen Congyang <wency@cn.fujitsu.com>
      Cc: Tang Chen <tangchen@cn.fujitsu.com>
      Cc: Jiang Liu <jiang.liu@huawei.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      825f787b
    • T
      resource: add __adjust_resource() for internal use · ae8e3a91
      Toshi Kani 提交于
      Add __adjust_resource(), which is called by adjust_resource() internally
      after the resource_lock is held.  There is no interface change to
      adjust_resource().  This change allows other functions to call
      __adjust_resource() internally while the resource_lock is held.
      Signed-off-by: NToshi Kani <toshi.kani@hp.com>
      Reviewed-by: NYasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
      Acked-by: NDavid Rientjes <rientjes@google.com>
      Cc: Ram Pai <linuxram@us.ibm.com>
      Cc: T Makphaibulchoke <tmac@hp.com>
      Cc: Wen Congyang <wency@cn.fujitsu.com>
      Cc: Tang Chen <tangchen@cn.fujitsu.com>
      Cc: Jiang Liu <jiang.liu@huawei.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      ae8e3a91
  21. 06 10月, 2012 1 次提交
  22. 31 7月, 2012 1 次提交
    • O
      resource: make sure requested range is included in the root range · 65fed8f6
      Octavian Purdila 提交于
      When the requested range is outside of the root range the logic in
      __reserve_region_with_split will cause an infinite recursion which will
      overflow the stack as seen in the warning bellow.
      
      This particular stack overflow was caused by requesting the
      (100000000-107ffffff) range while the root range was (0-ffffffff).  In
      this case __request_resource would return the whole root range as
      conflict range (i.e.  0-ffffffff).  Then, the logic in
      __reserve_region_with_split would continue the recursion requesting the
      new range as (conflict->end+1, end) which incidentally in this case
      equals the originally requested range.
      
      This patch aborts looking for an usable range when the request does not
      intersect with the root range.  When the request partially overlaps with
      the root range, it ajust the request to fall in the root range and then
      continues with the new request.
      
      When the request is modified or aborted errors and a stack trace are
      logged to allow catching the errors in the upper layers.
      
      [    5.968374] WARNING: at kernel/sched.c:4129 sub_preempt_count+0x63/0x89()
      [    5.975150] Modules linked in:
      [    5.978184] Pid: 1, comm: swapper Not tainted 3.0.22-mid27-00004-gb72c817 #46
      [    5.985324] Call Trace:
      [    5.987759]  [<c1039dfc>] ? console_unlock+0x17b/0x18d
      [    5.992891]  [<c1039620>] warn_slowpath_common+0x48/0x5d
      [    5.998194]  [<c1031758>] ? sub_preempt_count+0x63/0x89
      [    6.003412]  [<c1039644>] warn_slowpath_null+0xf/0x13
      [    6.008453]  [<c1031758>] sub_preempt_count+0x63/0x89
      [    6.013499]  [<c14d60c4>] _raw_spin_unlock+0x27/0x3f
      [    6.018453]  [<c10c6349>] add_partial+0x36/0x3b
      [    6.022973]  [<c10c7c0a>] deactivate_slab+0x96/0xb4
      [    6.027842]  [<c14cf9d9>] __slab_alloc.isra.54.constprop.63+0x204/0x241
      [    6.034456]  [<c103f78f>] ? kzalloc.constprop.5+0x29/0x38
      [    6.039842]  [<c103f78f>] ? kzalloc.constprop.5+0x29/0x38
      [    6.045232]  [<c10c7dc9>] kmem_cache_alloc_trace+0x51/0xb0
      [    6.050710]  [<c103f78f>] ? kzalloc.constprop.5+0x29/0x38
      [    6.056100]  [<c103f78f>] kzalloc.constprop.5+0x29/0x38
      [    6.061320]  [<c17b45e9>] __reserve_region_with_split+0x1c/0xd1
      [    6.067230]  [<c17b4693>] __reserve_region_with_split+0xc6/0xd1
      ...
      [    7.179057]  [<c17b4693>] __reserve_region_with_split+0xc6/0xd1
      [    7.184970]  [<c17b4779>] reserve_region_with_split+0x30/0x42
      [    7.190709]  [<c17a8ebf>] e820_reserve_resources_late+0xd1/0xe9
      [    7.196623]  [<c17c9526>] pcibios_resource_survey+0x23/0x2a
      [    7.202184]  [<c17cad8a>] pcibios_init+0x23/0x35
      [    7.206789]  [<c17ca574>] pci_subsys_init+0x3f/0x44
      [    7.211659]  [<c1002088>] do_one_initcall+0x72/0x122
      [    7.216615]  [<c17ca535>] ? pci_legacy_init+0x3d/0x3d
      [    7.221659]  [<c17a27ff>] kernel_init+0xa6/0x118
      [    7.226265]  [<c17a2759>] ? start_kernel+0x334/0x334
      [    7.231223]  [<c14d7482>] kernel_thread_helper+0x6/0x10
      Signed-off-by: NOctavian Purdila <octavian.purdila@intel.com>
      Signed-off-by: NRam Pai <linuxram@us.ibm.com>
      Cc: Jesse Barnes <jbarnes@virtuousgeek.org>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      65fed8f6
  23. 14 6月, 2012 1 次提交
  24. 01 6月, 2012 1 次提交
  25. 04 2月, 2012 1 次提交
  26. 31 10月, 2011 1 次提交
  27. 30 9月, 2011 1 次提交
    • R
      Resource: fix wrong resource window calculation · 47ea91b4
      Ram Pai 提交于
      __find_resource() incorrectly returns a resource window which overlaps
      an existing allocated window.  This happens when the parent's
      resource-window spans 0x00000000 to 0xffffffff and is entirely allocated
      to all its children resource-windows.
      
      __find_resource() looks for gaps in resource allocation among the
      children resource windows.  When it encounters the last child window it
      blindly tries the range next to one allocated to the last child.  Since
      the last child's window ends at 0xffffffff the calculation overflows,
      leading the algorithm to believe that any window in the range 0x0000000
      to 0xfffffff is available for allocation.  This leads to a conflicting
      window allocation.
      
      Michal Ludvig reported this issue seen on his platform.  The following
      patch fixes the problem and has been verified by Michal.  I believe this
      bug has been there for ages.  It got exposed by git commit 2bbc6942
      ("PCI : ability to relocate assigned pci-resources")
      Signed-off-by: NRam Pai <linuxram@us.ibm.com>
      Tested-by: NMichal Ludvig <mludvig@logix.net.nz>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      47ea91b4
  28. 31 7月, 2011 1 次提交
  29. 07 7月, 2011 1 次提交
  30. 18 12月, 2010 2 次提交