[RFC PATCH v1 1/3] usb: early: xhci-dbc: Track early_ioremap size separately
From: Umang Jain
Date: Thu Jun 04 2026 - 10:49:37 EST
early_ioremap() only allows to map a fixed number of boot time mappings,
hence, the mapped size should be tracked separately from the PCIe base
address and size.
Signed-off-by: Umang Jain <uajain@xxxxxxxxxx>
---
drivers/usb/early/xhci-dbc.c | 13 +++++++------
drivers/usb/early/xhci-dbc.h | 1 +
2 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/drivers/usb/early/xhci-dbc.c b/drivers/usb/early/xhci-dbc.c
index 41118bba9197..8ce362a90910 100644
--- a/drivers/usb/early/xhci-dbc.c
+++ b/drivers/usb/early/xhci-dbc.c
@@ -86,6 +86,7 @@ static void __iomem * __init xdbc_map_pci_mmio(u32 bus, u32 dev, u32 func)
xdbc.xhci_start = val64;
xdbc.xhci_length = sz64;
base = early_ioremap(val64, sz64);
+ xdbc.xhci_base_length = sz64;
return base;
}
@@ -643,9 +644,9 @@ int __init early_xdbc_parse_parameter(char *s, int keep_early)
offset = xhci_find_next_ext_cap(xdbc.xhci_base, 0, XHCI_EXT_CAPS_DEBUG);
if (!offset) {
pr_notice("xhci host doesn't support debug capability\n");
- early_iounmap(xdbc.xhci_base, xdbc.xhci_length);
+ early_iounmap(xdbc.xhci_base, xdbc.xhci_base_length);
xdbc.xhci_base = NULL;
- xdbc.xhci_length = 0;
+ xdbc.xhci_base_length = 0;
return -ENODEV;
}
@@ -682,9 +683,9 @@ int __init early_xdbc_setup_hardware(void)
xdbc.table_base = NULL;
xdbc.out_buf = NULL;
- early_iounmap(xdbc.xhci_base, xdbc.xhci_length);
+ early_iounmap(xdbc.xhci_base, xdbc.xhci_base_length);
xdbc.xhci_base = NULL;
- xdbc.xhci_length = 0;
+ xdbc.xhci_base_length = 0;
}
return ret;
@@ -987,7 +988,7 @@ static int __init xdbc_init(void)
}
raw_spin_lock_irqsave(&xdbc.lock, flags);
- early_iounmap(xdbc.xhci_base, xdbc.xhci_length);
+ early_iounmap(xdbc.xhci_base, xdbc.xhci_base_length);
xdbc.xhci_base = base;
offset = xhci_find_next_ext_cap(xdbc.xhci_base, 0, XHCI_EXT_CAPS_DEBUG);
xdbc.xdbc_reg = (struct xdbc_regs __iomem *)(xdbc.xhci_base + offset);
@@ -1004,7 +1005,7 @@ static int __init xdbc_init(void)
memblock_phys_free(xdbc.table_dma, PAGE_SIZE);
memblock_phys_free(xdbc.out_dma, PAGE_SIZE);
writel(0, &xdbc.xdbc_reg->control);
- early_iounmap(xdbc.xhci_base, xdbc.xhci_length);
+ early_iounmap(xdbc.xhci_base, xdbc.xhci_base_length);
return ret;
}
diff --git a/drivers/usb/early/xhci-dbc.h b/drivers/usb/early/xhci-dbc.h
index 8b4d71de45fc..e2aefb796084 100644
--- a/drivers/usb/early/xhci-dbc.h
+++ b/drivers/usb/early/xhci-dbc.h
@@ -144,6 +144,7 @@ struct xdbc_state {
u32 dev;
u32 func;
void __iomem *xhci_base;
+ size_t xhci_base_length;
u64 xhci_start;
size_t xhci_length;
int port_number;
--
2.53.0