Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

iommu: debug-pagealloc: Use page_ext_get_from_phys()

Instead of calling pfn_valid() and then getting the page, call
the newly added function page_ext_get_from_phys(), which would
also check for MMIO and offline memory and return NULL in that
case.

Signed-off-by: Mostafa Saleh <smostafa@google.com>
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>

authored by

Mostafa Saleh and committed by
Joerg Roedel
a7f1bc23 d414b83d

+14 -17
+14 -17
drivers/iommu/iommu-debug-pagealloc.c
··· 30 30 .need = need_iommu_debug, 31 31 }; 32 32 33 - static struct page_ext *get_iommu_page_ext(phys_addr_t phys) 34 - { 35 - struct page *page = phys_to_page(phys); 36 - struct page_ext *page_ext = page_ext_get(page); 37 - 38 - return page_ext; 39 - } 40 - 41 33 static struct iommu_debug_metadata *get_iommu_data(struct page_ext *page_ext) 42 34 { 43 35 return page_ext_data(page_ext, &page_iommu_debug_ops); ··· 37 45 38 46 static void iommu_debug_inc_page(phys_addr_t phys) 39 47 { 40 - struct page_ext *page_ext = get_iommu_page_ext(phys); 41 - struct iommu_debug_metadata *d = get_iommu_data(page_ext); 48 + struct page_ext *page_ext = page_ext_from_phys(phys); 49 + struct iommu_debug_metadata *d; 42 50 51 + if (!page_ext) 52 + return; 53 + 54 + d = get_iommu_data(page_ext); 43 55 WARN_ON(atomic_inc_return_relaxed(&d->ref) <= 0); 44 56 page_ext_put(page_ext); 45 57 } 46 58 47 59 static void iommu_debug_dec_page(phys_addr_t phys) 48 60 { 49 - struct page_ext *page_ext = get_iommu_page_ext(phys); 50 - struct iommu_debug_metadata *d = get_iommu_data(page_ext); 61 + struct page_ext *page_ext = page_ext_from_phys(phys); 62 + struct iommu_debug_metadata *d; 51 63 64 + if (!page_ext) 65 + return; 66 + 67 + d = get_iommu_data(page_ext); 52 68 WARN_ON(atomic_dec_return_relaxed(&d->ref) < 0); 53 69 page_ext_put(page_ext); 54 70 } ··· 104 104 if (WARN_ON(!phys || check_add_overflow(phys, size, &end))) 105 105 return; 106 106 107 - for (off = 0 ; off < size ; off += page_size) { 108 - if (!pfn_valid(__phys_to_pfn(phys + off))) 109 - continue; 107 + for (off = 0 ; off < size ; off += page_size) 110 108 iommu_debug_inc_page(phys + off); 111 - } 112 109 } 113 110 114 111 static void __iommu_debug_update_iova(struct iommu_domain *domain, ··· 120 123 for (off = 0 ; off < size ; off += page_size) { 121 124 phys_addr_t phys = iommu_iova_to_phys(domain, iova + off); 122 125 123 - if (!phys || !pfn_valid(__phys_to_pfn(phys))) 126 + if (!phys) 124 127 continue; 125 128 126 129 if (inc)