ioremap() called early from pnv_pci_init_ioda_phb()
From: Qian Cai
Date: Fri May 08 2020 - 10:39:14 EST
Booting POWER9 PowerNV has this message,
"ioremap() called early from pnv_pci_init_ioda_phb+0x420/0xdfc. Use early_ioremap() insteadâ
but use the patch below will result in leaks because it will never call early_iounmap() anywhere. However, it looks me it was by design that phb->regs mapping would be there forever where it would be used in pnv_ioda_get_inval_reg(), so is just that check_early_ioremap_leak() initcall too strong?
--- a/arch/powerpc/platforms/powernv/pci-ioda.c
+++ b/arch/powerpc/platforms/powernv/pci-ioda.c
@@ -36,6 +36,7 @@
#include <asm/firmware.h>
#include <asm/pnv-pci.h>
#include <asm/mmzone.h>
+#include <asm/early_ioremap.h>
#include <misc/cxl-base.h>
@@ -3827,7 +3828,7 @@ static void __init pnv_pci_init_ioda_phb(struct device_node *np,
/* Get registers */
if (!of_address_to_resource(np, 0, &r)) {
phb->regs_phys = r.start;
- phb->regs = ioremap(r.start, resource_size(&r));
+ phb->regs = early_ioremap(r.start, resource_size(&r));
if (phb->regs == NULL)
pr_err(" Failed to map registers !\nâ);
[ 23.080069][ T1] ------------[ cut here ]------------
[ 23.080089][ T1] Debug warning: early ioremap leak of 10 areas detected.
[ 23.080089][ T1] please boot with early_ioremap_debug and report the dmesg.
[ 23.080157][ T1] WARNING: CPU: 4 PID: 1 at mm/early_ioremap.c:99 check_early_ioremap_leak+0xd4/0x108
[ 23.080171][ T1] Modules linked in:
[ 23.080192][ T1] CPU: 4 PID: 1 Comm: swapper/0 Not tainted 5.7.0-rc4-next-20200508+ #4
[ 23.080214][ T1] NIP: c00000000103f2d8 LR: c00000000103f2d4 CTR: 0000000000000000
[ 23.080226][ T1] REGS: c00000003df0f860 TRAP: 0700 Not tainted (5.7.0-rc4-next-20200508+)
[ 23.080259][ T1] MSR: 9000000000029033 <SF,HV,EE,ME,IR,DR,RI,LE> CR: 48000222 XER: 20040000
[ 23.080296][ T1] CFAR: c00000000010d5a8 IRQMASK: 0
[ 23.080296][ T1] GPR00: c00000000103f2d4 c00000003df0faf0 c000000001689400 0000000000000072
[ 23.080296][ T1] GPR04: 0000000000000006 0000000000000000 c00000003df0f7e4 0000000000000004
[ 23.080296][ T1] GPR08: 0000001ffbb60000 0000000000000000 c00000003dee6680 0000000000000002
[ 23.080296][ T1] GPR12: 0000000000000000 c000001fffffae00 c000000001057860 c0000000010578b0
[ 23.080296][ T1] GPR16: c000000001002d38 c0000000014f0660 c0000000014f0680 c0000000014f06a0
[ 23.080296][ T1] GPR20: c0000000014f06c0 c0000000014f06e0 c0000000014f0700 c0000000014f0720
[ 23.080296][ T1] GPR24: c000000000c4bc30 c000000486b82000 c0000000015a0fe0 c0000000015a0fc0
[ 23.080296][ T1] GPR28: 0000000000000010 0000000000000010 c000000001061e30 000000000000000a
[ 23.080507][ T1] NIP [c00000000103f2d8] check_early_ioremap_leak+0xd4/0x108
[ 23.080530][ T1] LR [c00000000103f2d4] check_early_ioremap_leak+0xd0/0x108
[ 23.080552][ T1] Call Trace:
[ 23.080571][ T1] [c00000003df0faf0] [c00000000103f2d4] check_early_ioremap_leak+0xd0/0x108 (unreliable)
[ 23.080607][ T1] [c00000003df0fb80] [c00000000001130c] do_one_initcall+0xcc/0x660
[ 23.080648][ T1] [c00000003df0fc80] [c000000001004c18] kernel_init_freeable+0x480/0x568
[ 23.080681][ T1] [c00000003df0fdb0] [c000000000012180] kernel_init+0x24/0x194
[ 23.080713][ T1] [c00000003df0fe20] [c00000000000cb28] ret_from_kernel_thread+0x5c/0x74
This is from the early_ioremap_debug dmesg.
[ 0.000000][ T0] ------------[ cut here ]------------
[ 0.000000][ T0] __early_ioremap(0x000600c3c0010000, 00010000) [0] => 00000000 + ffffffffffbe0000
[ 0.000000][ T0] WARNING: CPU: 0 PID: 0 at mm/early_ioremap.c:162 __early_ioremap+0x2d8/0x408
[ 0.000000][ T0] Modules linked in:
[ 0.000000][ T0] CPU: 0 PID: 0 Comm: swapper Not tainted 5.7.0-rc4-next-20200508+ #4
[ 0.000000][ T0] NIP: c00000000103f5e4 LR: c00000000103f5e0 CTR: c0000000001e77f0
[ 0.000000][ T0] REGS: c00000000168f980 TRAP: 0700 Not tainted (5.7.0-rc4-next-20200508+)
[ 0.000000][ T0] MSR: 9000000000021033 <SF,HV,ME,IR,DR,RI,LE> CR: 28000248 XER: 20040000
[ 0.000000][ T0] CFAR: c00000000010d5a8 IRQMASK: 1
[ 0.000000][ T0] GPR00: c00000000103f5e0 c00000000168fc10 c000000001689400 0000000000000050
[ 0.000000][ T0] GPR04: c00000000152f6f8 0000000000000000 c00000000168f904 0000000000000000
[ 0.000000][ T0] GPR08: 0000000000000000 0000000000000000 c00000000162f600 0000000000000002
[ 0.000000][ T0] GPR12: c0000000001e77f0 c000000005b30000 0000000000000000 0000000000000000
[ 0.000000][ T0] GPR16: 0000000000000000 0000000000000000 0000000000000000 0000000000001000
[ 0.000000][ T0] GPR20: 0000000000000000 80000000000001ae 0000000000000000 0000000000000000
[ 0.000000][ T0] GPR24: 0000000000010000 c000000001061da8 0000000000000008 0000000000000008
[ 0.000000][ T0] GPR28: 0000000000000000 c000000001061db0 0000000000000000 c000000001061eb8
[ 0.000000][ T0] NIP [c00000000103f5e4] __early_ioremap+0x2d8/0x408
[ 0.000000][ T0] LR [c00000000103f5e0] __early_ioremap+0x2d4/0x408
[ 0.000000][ T0] Call Trace:
[ 0.000000][ T0] [c00000000168fc10] [c00000000103f5e0] __early_ioremap+0x2d4/0x408 (unreliable)
[ 0.000000][ T0] [c00000000168fcf0] [c00000000101d010] pnv_pci_init_ioda_phb+0x420/0xdfc
[ 0.000000][ T0] [c00000000168fe10] [c00000000101c9b8] pnv_pci_init+0x12c/0x264
[ 0.000000][ T0] [c00000000168fe40] [c000000001016c40] pnv_setup_arch+0x2e4/0x330
[ 0.000000][ T0] [c00000000168fe80] [c000000001009dd0] setup_arch+0x3a0/0x3ec
[ 0.000000][ T0] [c00000000168fef0] [c000000001003ed0] start_kernel+0xb0/0x978
[ 0.000000][ T0] [c00000000168ff90] [c00000000000c790] start_here_common+0x1c/0x8c
[ 0.000000][ T0] Instruction dump:
[ 0.000000][ T0] 7d39ba14 3c82ff3c 3c62ff54 7f06c378 7f88e378 7fc7f378 38a10068 e9290110
[ 0.000000][ T0] 38849e90 3863e8f0 4b0cdf65 60000000 <0fe00000> 2bbe000f 409d0018 3c62fff1
[ 0.000000][ T0] irq event stamp: 0
[ 0.000000][ T0] hardirqs last enabled at (0): [<0000000000000000>] 0x0
[ 0.000000][ T0] hardirqs last disabled at (0): [<0000000000000000>] 0x0
[ 0.000000][ T0] softirqs last enabled at (0): [<0000000000000000>] 0x0
[ 0.000000][ T0] softirqs last disabled at (0): [<0000000000000000>] 0x0