Skip to content

Commit 3343962

Browse files
oohalmpe
authored andcommitted
powerpc/eeh: Handle hugepages in ioremap space
In commit 4a7b06c157a2 ("powerpc/eeh: Handle hugepages in ioremap space") support for using hugepages in the vmalloc and ioremap areas was enabled for radix. Unfortunately this broke EEH MMIO error checking. Detection works by inserting a hook which checks the results of the ioreadXX() set of functions. When a read returns a 0xFFs response we need to check for an error which we do by mapping the (virtual) MMIO address back to a physical address, then mapping physical address to a PCI device via an interval tree. When translating virt -> phys we currently assume the ioremap space is only populated by PAGE_SIZE mappings. If a hugepage mapping is found we emit a WARN_ON(), but otherwise handles the check as though a normal page was found. In pathalogical cases such as copying a buffer containing a lot of 0xFFs from BAR memory this can result in the system not booting because it's too busy printing WARN_ON()s. There's no real reason to assume huge pages can't be present and we're prefectly capable of handling them, so do that. Fixes: 4a7b06c157a2 ("powerpc/eeh: Handle hugepages in ioremap space") Reported-by: Sachin Sant <sachinp@linux.vnet.ibm.com> Signed-off-by: Oliver O'Halloran <oohall@gmail.com> Tested-by: Sachin Sant <sachinp@linux.vnet.ibm.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://lore.kernel.org/r/20190710150517.27114-1-oohall@gmail.com
1 parent 73a2b04 commit 3343962

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

arch/powerpc/kernel/eeh.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -367,10 +367,19 @@ static inline unsigned long eeh_token_to_phys(unsigned long token)
367367
ptep = find_init_mm_pte(token, &hugepage_shift);
368368
if (!ptep)
369369
return token;
370-
WARN_ON(hugepage_shift);
371-
pa = pte_pfn(*ptep) << PAGE_SHIFT;
372370

373-
return pa | (token & (PAGE_SIZE-1));
371+
pa = pte_pfn(*ptep);
372+
373+
/* On radix we can do hugepage mappings for io, so handle that */
374+
if (hugepage_shift) {
375+
pa <<= hugepage_shift;
376+
pa |= token & ((1ul << hugepage_shift) - 1);
377+
} else {
378+
pa <<= PAGE_SHIFT;
379+
pa |= token & (PAGE_SIZE - 1);
380+
}
381+
382+
return pa;
374383
}
375384

376385
/*

0 commit comments

Comments
 (0)