diff options
author | Thomas Klein <tklein@de.ibm.com> | 2008-10-27 05:38:46 -0400 |
---|---|---|
committer | Jeff Garzik <jgarzik@redhat.com> | 2008-10-27 14:49:55 -0400 |
commit | 3fd09c45bfbcf77949ed6db36e67c1681424fedb (patch) | |
tree | 73a5a3122c69c68489905c065e810abe9288e95c /drivers/net/ehea/ehea_qmr.c | |
parent | 74d5e8acd95ae934194303138a43b60005fcfad6 (diff) |
ehea: Detect 16GB hugepages for firmware restriction
All kernel memory which is used for kernel/hardware data transfer must
be registered with firmware using "memory regions". 16GB hugepages
may not be part of a memory region due to firmware restrictions.
This patch modifies the walk_memory_resource callback fn to filter
hugepages and add only standard memory to the busmap which is later
on used for MR registration.
Signed-off-by: Thomas Klein <tklein@de.ibm.com>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
Diffstat (limited to 'drivers/net/ehea/ehea_qmr.c')
-rw-r--r-- | drivers/net/ehea/ehea_qmr.c | 57 |
1 files changed, 52 insertions, 5 deletions
diff --git a/drivers/net/ehea/ehea_qmr.c b/drivers/net/ehea/ehea_qmr.c index 9b61dc9865d1..9d006878f045 100644 --- a/drivers/net/ehea/ehea_qmr.c +++ b/drivers/net/ehea/ehea_qmr.c | |||
@@ -632,10 +632,13 @@ static void ehea_rebuild_busmap(void) | |||
632 | } | 632 | } |
633 | } | 633 | } |
634 | 634 | ||
635 | static int ehea_update_busmap(unsigned long pfn, unsigned long pgnum, int add) | 635 | static int ehea_update_busmap(unsigned long pfn, unsigned long nr_pages, int add) |
636 | { | 636 | { |
637 | unsigned long i, start_section, end_section; | 637 | unsigned long i, start_section, end_section; |
638 | 638 | ||
639 | if (!nr_pages) | ||
640 | return 0; | ||
641 | |||
639 | if (!ehea_bmap) { | 642 | if (!ehea_bmap) { |
640 | ehea_bmap = kzalloc(sizeof(struct ehea_bmap), GFP_KERNEL); | 643 | ehea_bmap = kzalloc(sizeof(struct ehea_bmap), GFP_KERNEL); |
641 | if (!ehea_bmap) | 644 | if (!ehea_bmap) |
@@ -643,7 +646,7 @@ static int ehea_update_busmap(unsigned long pfn, unsigned long pgnum, int add) | |||
643 | } | 646 | } |
644 | 647 | ||
645 | start_section = (pfn * PAGE_SIZE) / EHEA_SECTSIZE; | 648 | start_section = (pfn * PAGE_SIZE) / EHEA_SECTSIZE; |
646 | end_section = start_section + ((pgnum * PAGE_SIZE) / EHEA_SECTSIZE); | 649 | end_section = start_section + ((nr_pages * PAGE_SIZE) / EHEA_SECTSIZE); |
647 | /* Mark entries as valid or invalid only; address is assigned later */ | 650 | /* Mark entries as valid or invalid only; address is assigned later */ |
648 | for (i = start_section; i < end_section; i++) { | 651 | for (i = start_section; i < end_section; i++) { |
649 | u64 flag; | 652 | u64 flag; |
@@ -692,10 +695,54 @@ int ehea_rem_sect_bmap(unsigned long pfn, unsigned long nr_pages) | |||
692 | return ret; | 695 | return ret; |
693 | } | 696 | } |
694 | 697 | ||
695 | static int ehea_create_busmap_callback(unsigned long pfn, | 698 | static int ehea_is_hugepage(unsigned long pfn) |
696 | unsigned long nr_pages, void *arg) | 699 | { |
700 | int page_order; | ||
701 | |||
702 | if (pfn & EHEA_HUGEPAGE_PFN_MASK) | ||
703 | return 0; | ||
704 | |||
705 | page_order = compound_order(pfn_to_page(pfn)); | ||
706 | if (page_order + PAGE_SHIFT != EHEA_HUGEPAGESHIFT) | ||
707 | return 0; | ||
708 | |||
709 | return 1; | ||
710 | } | ||
711 | |||
712 | static int ehea_create_busmap_callback(unsigned long initial_pfn, | ||
713 | unsigned long total_nr_pages, void *arg) | ||
697 | { | 714 | { |
698 | return ehea_update_busmap(pfn, nr_pages, EHEA_BUSMAP_ADD_SECT); | 715 | int ret; |
716 | unsigned long pfn, start_pfn, end_pfn, nr_pages; | ||
717 | |||
718 | if ((total_nr_pages * PAGE_SIZE) < EHEA_HUGEPAGE_SIZE) | ||
719 | return ehea_update_busmap(initial_pfn, total_nr_pages, | ||
720 | EHEA_BUSMAP_ADD_SECT); | ||
721 | |||
722 | /* Given chunk is >= 16GB -> check for hugepages */ | ||
723 | start_pfn = initial_pfn; | ||
724 | end_pfn = initial_pfn + total_nr_pages; | ||
725 | pfn = start_pfn; | ||
726 | |||
727 | while (pfn < end_pfn) { | ||
728 | if (ehea_is_hugepage(pfn)) { | ||
729 | /* Add mem found in front of the hugepage */ | ||
730 | nr_pages = pfn - start_pfn; | ||
731 | ret = ehea_update_busmap(start_pfn, nr_pages, | ||
732 | EHEA_BUSMAP_ADD_SECT); | ||
733 | if (ret) | ||
734 | return ret; | ||
735 | |||
736 | /* Skip the hugepage */ | ||
737 | pfn += (EHEA_HUGEPAGE_SIZE / PAGE_SIZE); | ||
738 | start_pfn = pfn; | ||
739 | } else | ||
740 | pfn += (EHEA_SECTSIZE / PAGE_SIZE); | ||
741 | } | ||
742 | |||
743 | /* Add mem found behind the hugepage(s) */ | ||
744 | nr_pages = pfn - start_pfn; | ||
745 | return ehea_update_busmap(start_pfn, nr_pages, EHEA_BUSMAP_ADD_SECT); | ||
699 | } | 746 | } |
700 | 747 | ||
701 | int ehea_create_busmap(void) | 748 | int ehea_create_busmap(void) |