diff options
author | Toshi Kani <toshi.kani@hpe.com> | 2016-01-26 15:57:28 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2016-01-30 03:49:58 -0500 |
commit | 1c29f25bf5d6c557017f619b638c619cbbf798c4 (patch) | |
tree | c386106beb5a9dde06fbbdc3c81e47c7f91e77da /kernel/resource.c | |
parent | 05fee7cfab7fa9d57e71f00bdd8fcff0cf5044a0 (diff) |
memremap: Change region_intersects() to take @flags and @desc
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: Toshi Kani <toshi.kani@hpe.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Acked-by: Dan 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.de
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'kernel/resource.c')
-rw-r--r-- | kernel/resource.c | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/kernel/resource.c b/kernel/resource.c index 994f1e41269b..0041cedc47d6 100644 --- a/kernel/resource.c +++ b/kernel/resource.c | |||
@@ -496,31 +496,34 @@ EXPORT_SYMBOL_GPL(page_is_ram); | |||
496 | * region_intersects() - determine intersection of region with known resources | 496 | * region_intersects() - determine intersection of region with known resources |
497 | * @start: region start address | 497 | * @start: region start address |
498 | * @size: size of region | 498 | * @size: size of region |
499 | * @name: name of resource (in iomem_resource) | 499 | * @flags: flags of resource (in iomem_resource) |
500 | * @desc: descriptor of resource (in iomem_resource) or IORES_DESC_NONE | ||
500 | * | 501 | * |
501 | * Check if the specified region partially overlaps or fully eclipses a | 502 | * Check if the specified region partially overlaps or fully eclipses a |
502 | * resource identified by @name. Return REGION_DISJOINT if the region | 503 | * resource identified by @flags and @desc (optional with IORES_DESC_NONE). |
503 | * does not overlap @name, return REGION_MIXED if the region overlaps | 504 | * Return REGION_DISJOINT if the region does not overlap @flags/@desc, |
504 | * @type and another resource, and return REGION_INTERSECTS if the | 505 | * return REGION_MIXED if the region overlaps @flags/@desc and another |
505 | * region overlaps @type and no other defined resource. Note, that | 506 | * resource, and return REGION_INTERSECTS if the region overlaps @flags/@desc |
506 | * REGION_INTERSECTS is also returned in the case when the specified | 507 | * and no other defined resource. Note that REGION_INTERSECTS is also |
507 | * region overlaps RAM and undefined memory holes. | 508 | * returned in the case when the specified region overlaps RAM and undefined |
509 | * memory holes. | ||
508 | * | 510 | * |
509 | * region_intersect() is used by memory remapping functions to ensure | 511 | * region_intersect() is used by memory remapping functions to ensure |
510 | * the user is not remapping RAM and is a vast speed up over walking | 512 | * the user is not remapping RAM and is a vast speed up over walking |
511 | * through the resource table page by page. | 513 | * through the resource table page by page. |
512 | */ | 514 | */ |
513 | int region_intersects(resource_size_t start, size_t size, const char *name) | 515 | int region_intersects(resource_size_t start, size_t size, unsigned long flags, |
516 | unsigned long desc) | ||
514 | { | 517 | { |
515 | unsigned long flags = IORESOURCE_MEM | IORESOURCE_BUSY; | ||
516 | resource_size_t end = start + size - 1; | 518 | resource_size_t end = start + size - 1; |
517 | int type = 0; int other = 0; | 519 | int type = 0; int other = 0; |
518 | struct resource *p; | 520 | struct resource *p; |
519 | 521 | ||
520 | read_lock(&resource_lock); | 522 | read_lock(&resource_lock); |
521 | for (p = iomem_resource.child; p ; p = p->sibling) { | 523 | for (p = iomem_resource.child; p ; p = p->sibling) { |
522 | bool is_type = strcmp(p->name, name) == 0 && | 524 | bool is_type = (((p->flags & flags) == flags) && |
523 | ((p->flags & flags) == flags); | 525 | ((desc == IORES_DESC_NONE) || |
526 | (desc == p->desc))); | ||
524 | 527 | ||
525 | if (start >= p->start && start <= p->end) | 528 | if (start >= p->start && start <= p->end) |
526 | is_type ? type++ : other++; | 529 | is_type ? type++ : other++; |
@@ -539,6 +542,7 @@ int region_intersects(resource_size_t start, size_t size, const char *name) | |||
539 | 542 | ||
540 | return REGION_DISJOINT; | 543 | return REGION_DISJOINT; |
541 | } | 544 | } |
545 | EXPORT_SYMBOL_GPL(region_intersects); | ||
542 | 546 | ||
543 | void __weak arch_remove_reservations(struct resource *avail) | 547 | void __weak arch_remove_reservations(struct resource *avail) |
544 | { | 548 | { |