aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/resource.c
diff options
context:
space:
mode:
authorToshi Kani <toshi.kani@hpe.com>2016-01-26 15:57:26 -0500
committerIngo Molnar <mingo@kernel.org>2016-01-30 03:49:58 -0500
commitbd7e6cb30ced147292d854a54d4a1f5c5a05d927 (patch)
tree340ad7722dfed90766bf927da376d05327669e5a /kernel/resource.c
parent9a975bee4b3945b271bcff18a520d4863c210f8b (diff)
resource: Change walk_system_ram() to use System RAM type
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: Toshi Kani <toshi.kani@hpe.com> [ Boris: fixup comments. ] Signed-off-by: Borislav 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.de Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'kernel/resource.c')
-rw-r--r--kernel/resource.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/kernel/resource.c b/kernel/resource.c
index 61512e972ece..994f1e41269b 100644
--- a/kernel/resource.c
+++ b/kernel/resource.c
@@ -415,11 +415,11 @@ int walk_iomem_res(char *name, unsigned long flags, u64 start, u64 end,
415} 415}
416 416
417/* 417/*
418 * This function calls callback against all memory range of "System RAM" 418 * This function calls the @func callback against all memory ranges of type
419 * which are marked as IORESOURCE_MEM and IORESOUCE_BUSY. 419 * System RAM which are marked as IORESOURCE_SYSTEM_RAM and IORESOUCE_BUSY.
420 * Now, this function is only for "System RAM". This function deals with 420 * Now, this function is only for System RAM, it deals with full ranges and
421 * full ranges and not pfn. If resources are not pfn aligned, dealing 421 * not PFNs. If resources are not PFN-aligned, dealing with PFNs can truncate
422 * with pfn can truncate ranges. 422 * ranges.
423 */ 423 */
424int walk_system_ram_res(u64 start, u64 end, void *arg, 424int walk_system_ram_res(u64 start, u64 end, void *arg,
425 int (*func)(u64, u64, void *)) 425 int (*func)(u64, u64, void *))
@@ -430,10 +430,10 @@ int walk_system_ram_res(u64 start, u64 end, void *arg,
430 430
431 res.start = start; 431 res.start = start;
432 res.end = end; 432 res.end = end;
433 res.flags = IORESOURCE_MEM | IORESOURCE_BUSY; 433 res.flags = IORESOURCE_SYSTEM_RAM | IORESOURCE_BUSY;
434 orig_end = res.end; 434 orig_end = res.end;
435 while ((res.start < res.end) && 435 while ((res.start < res.end) &&
436 (!find_next_iomem_res(&res, "System RAM", true))) { 436 (!find_next_iomem_res(&res, NULL, true))) {
437 ret = (*func)(res.start, res.end, arg); 437 ret = (*func)(res.start, res.end, arg);
438 if (ret) 438 if (ret)
439 break; 439 break;
@@ -446,9 +446,9 @@ int walk_system_ram_res(u64 start, u64 end, void *arg,
446#if !defined(CONFIG_ARCH_HAS_WALK_MEMORY) 446#if !defined(CONFIG_ARCH_HAS_WALK_MEMORY)
447 447
448/* 448/*
449 * This function calls callback against all memory range of "System RAM" 449 * This function calls the @func callback against all memory ranges of type
450 * which are marked as IORESOURCE_MEM and IORESOUCE_BUSY. 450 * System RAM which are marked as IORESOURCE_SYSTEM_RAM and IORESOUCE_BUSY.
451 * Now, this function is only for "System RAM". 451 * It is to be used only for System RAM.
452 */ 452 */
453int walk_system_ram_range(unsigned long start_pfn, unsigned long nr_pages, 453int walk_system_ram_range(unsigned long start_pfn, unsigned long nr_pages,
454 void *arg, int (*func)(unsigned long, unsigned long, void *)) 454 void *arg, int (*func)(unsigned long, unsigned long, void *))
@@ -460,10 +460,10 @@ int walk_system_ram_range(unsigned long start_pfn, unsigned long nr_pages,
460 460
461 res.start = (u64) start_pfn << PAGE_SHIFT; 461 res.start = (u64) start_pfn << PAGE_SHIFT;
462 res.end = ((u64)(start_pfn + nr_pages) << PAGE_SHIFT) - 1; 462 res.end = ((u64)(start_pfn + nr_pages) << PAGE_SHIFT) - 1;
463 res.flags = IORESOURCE_MEM | IORESOURCE_BUSY; 463 res.flags = IORESOURCE_SYSTEM_RAM | IORESOURCE_BUSY;
464 orig_end = res.end; 464 orig_end = res.end;
465 while ((res.start < res.end) && 465 while ((res.start < res.end) &&
466 (find_next_iomem_res(&res, "System RAM", true) >= 0)) { 466 (find_next_iomem_res(&res, NULL, true) >= 0)) {
467 pfn = (res.start + PAGE_SIZE - 1) >> PAGE_SHIFT; 467 pfn = (res.start + PAGE_SIZE - 1) >> PAGE_SHIFT;
468 end_pfn = (res.end + 1) >> PAGE_SHIFT; 468 end_pfn = (res.end + 1) >> PAGE_SHIFT;
469 if (end_pfn > pfn) 469 if (end_pfn > pfn)
@@ -484,7 +484,7 @@ static int __is_ram(unsigned long pfn, unsigned long nr_pages, void *arg)
484} 484}
485/* 485/*
486 * This generic page_is_ram() returns true if specified address is 486 * This generic page_is_ram() returns true if specified address is
487 * registered as "System RAM" in iomem_resource list. 487 * registered as System RAM in iomem_resource list.
488 */ 488 */
489int __weak page_is_ram(unsigned long pfn) 489int __weak page_is_ram(unsigned long pfn)
490{ 490{