drivers/pci/intel-iommu.c: fix build with older gcc's

drivers/pci/intel-iommu.c: In function `__iommu_calculate_agaw':
drivers/pci/intel-iommu.c:437: sorry, unimplemented: inlining failed in call to 'width_to_agaw': function body not available
drivers/pci/intel-iommu.c:445: sorry, unimplemented: called from here

Move the offending function (and its siblings) to top-of-file, remove the
forward declaration.

Addresses https://bugzilla.kernel.org/show_bug.cgi?id=17441

Reported-by: Martin Mokrejs <mmokrejs@ribosome.natur.cuni.cz>
Cc: David Woodhouse <dwmw2@infradead.org>
Cc: Jesse Barnes <jbarnes@virtuousgeek.org>
Cc: <stable@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by Andrew Morton and committed by Linus Torvalds df08cdc7 e85bfd3a

+43 -47
+43 -47
drivers/pci/intel-iommu.c
··· 71 71 #define DMA_32BIT_PFN IOVA_PFN(DMA_BIT_MASK(32)) 72 72 #define DMA_64BIT_PFN IOVA_PFN(DMA_BIT_MASK(64)) 73 73 74 + /* page table handling */ 75 + #define LEVEL_STRIDE (9) 76 + #define LEVEL_MASK (((u64)1 << LEVEL_STRIDE) - 1) 77 + 78 + static inline int agaw_to_level(int agaw) 79 + { 80 + return agaw + 2; 81 + } 82 + 83 + static inline int agaw_to_width(int agaw) 84 + { 85 + return 30 + agaw * LEVEL_STRIDE; 86 + } 87 + 88 + static inline int width_to_agaw(int width) 89 + { 90 + return (width - 30) / LEVEL_STRIDE; 91 + } 92 + 93 + static inline unsigned int level_to_offset_bits(int level) 94 + { 95 + return (level - 1) * LEVEL_STRIDE; 96 + } 97 + 98 + static inline int pfn_level_offset(unsigned long pfn, int level) 99 + { 100 + return (pfn >> level_to_offset_bits(level)) & LEVEL_MASK; 101 + } 102 + 103 + static inline unsigned long level_mask(int level) 104 + { 105 + return -1UL << level_to_offset_bits(level); 106 + } 107 + 108 + static inline unsigned long level_size(int level) 109 + { 110 + return 1UL << level_to_offset_bits(level); 111 + } 112 + 113 + static inline unsigned long align_to_level(unsigned long pfn, int level) 114 + { 115 + return (pfn + level_size(level) - 1) & level_mask(level); 116 + } 74 117 75 118 /* VT-d pages must always be _smaller_ than MM pages. Otherwise things 76 119 are never going to work. */ ··· 477 434 } 478 435 479 436 480 - static inline int width_to_agaw(int width); 481 - 482 437 static int __iommu_calculate_agaw(struct intel_iommu *iommu, int max_gaw) 483 438 { 484 439 unsigned long sagaw; ··· 685 644 iommu->root_entry = NULL; 686 645 out: 687 646 spin_unlock_irqrestore(&iommu->lock, flags); 688 - } 689 - 690 - /* page table handling */ 691 - #define LEVEL_STRIDE (9) 692 - #define LEVEL_MASK (((u64)1 << LEVEL_STRIDE) - 1) 693 - 694 - static inline int agaw_to_level(int agaw) 695 - { 696 - return agaw + 2; 697 - } 698 - 699 - static inline int agaw_to_width(int agaw) 700 - { 701 - return 30 + agaw * LEVEL_STRIDE; 702 - 703 - } 704 - 705 - static inline int width_to_agaw(int width) 706 - { 707 - return (width - 30) / LEVEL_STRIDE; 708 - } 709 - 710 - static inline unsigned int level_to_offset_bits(int level) 711 - { 712 - return (level - 1) * LEVEL_STRIDE; 713 - } 714 - 715 - static inline int pfn_level_offset(unsigned long pfn, int level) 716 - { 717 - return (pfn >> level_to_offset_bits(level)) & LEVEL_MASK; 718 - } 719 - 720 - static inline unsigned long level_mask(int level) 721 - { 722 - return -1UL << level_to_offset_bits(level); 723 - } 724 - 725 - static inline unsigned long level_size(int level) 726 - { 727 - return 1UL << level_to_offset_bits(level); 728 - } 729 - 730 - static inline unsigned long align_to_level(unsigned long pfn, int level) 731 - { 732 - return (pfn + level_size(level) - 1) & level_mask(level); 733 647 } 734 648 735 649 static struct dma_pte *pfn_to_dma_pte(struct dmar_domain *domain,