Skip to content

Commit d7b8a21

Browse files
PCI: Add "pci=hpmmiosize" and "pci=hpmmioprefsize" parameters
The existing "pci=hpmemsize=nn[KMG]" kernel parameter overrides the default size of both the non-prefetchable and the prefetchable MMIO windows for hotplug bridges. Add "pci=hpmmiosize=nn[KMG]" to override the default size of only the non-prefetchable MMIO window. Add "pci=hpmmioprefsize=nn[KMG]" to override the default size of only the prefetchable MMIO window. Link: https://lore.kernel.org/r/SL2P216MB0187E4D0055791957B7E2660806B0@SL2P216MB0187.KORP216.PROD.OUTLOOK.COM Signed-off-by: Nicholas Johnson <[email protected]> Signed-off-by: Bjorn Helgaas <[email protected]> Reviewed-by: Mika Westerberg <[email protected]>
1 parent c9c13ba commit d7b8a21

File tree

4 files changed

+39
-17
lines changed

4 files changed

+39
-17
lines changed

Documentation/admin-guide/kernel-parameters.txt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3492,8 +3492,15 @@
34923492
hpiosize=nn[KMG] The fixed amount of bus space which is
34933493
reserved for hotplug bridge's IO window.
34943494
Default size is 256 bytes.
3495+
hpmmiosize=nn[KMG] The fixed amount of bus space which is
3496+
reserved for hotplug bridge's MMIO window.
3497+
Default size is 2 megabytes.
3498+
hpmmioprefsize=nn[KMG] The fixed amount of bus space which is
3499+
reserved for hotplug bridge's MMIO_PREF window.
3500+
Default size is 2 megabytes.
34953501
hpmemsize=nn[KMG] The fixed amount of bus space which is
3496-
reserved for hotplug bridge's memory window.
3502+
reserved for hotplug bridge's MMIO and
3503+
MMIO_PREF window.
34973504
Default size is 2 megabytes.
34983505
hpbussize=nn The minimum amount of additional bus numbers
34993506
reserved for buses below a hotplug bridge.

drivers/pci/pci.c

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,17 @@ unsigned long pci_cardbus_io_size = DEFAULT_CARDBUS_IO_SIZE;
8585
unsigned long pci_cardbus_mem_size = DEFAULT_CARDBUS_MEM_SIZE;
8686

8787
#define DEFAULT_HOTPLUG_IO_SIZE (256)
88-
#define DEFAULT_HOTPLUG_MEM_SIZE (2*1024*1024)
89-
/* pci=hpmemsize=nnM,hpiosize=nn can override this */
88+
#define DEFAULT_HOTPLUG_MMIO_SIZE (2*1024*1024)
89+
#define DEFAULT_HOTPLUG_MMIO_PREF_SIZE (2*1024*1024)
90+
/* hpiosize=nn can override this */
9091
unsigned long pci_hotplug_io_size = DEFAULT_HOTPLUG_IO_SIZE;
91-
unsigned long pci_hotplug_mem_size = DEFAULT_HOTPLUG_MEM_SIZE;
92+
/*
93+
* pci=hpmmiosize=nnM overrides non-prefetchable MMIO size,
94+
* pci=hpmmioprefsize=nnM overrides prefetchable MMIO size;
95+
* pci=hpmemsize=nnM overrides both
96+
*/
97+
unsigned long pci_hotplug_mmio_size = DEFAULT_HOTPLUG_MMIO_SIZE;
98+
unsigned long pci_hotplug_mmio_pref_size = DEFAULT_HOTPLUG_MMIO_PREF_SIZE;
9299

93100
#define DEFAULT_HOTPLUG_BUS_SIZE 1
94101
unsigned long pci_hotplug_bus_size = DEFAULT_HOTPLUG_BUS_SIZE;
@@ -6289,8 +6296,13 @@ static int __init pci_setup(char *str)
62896296
pcie_ecrc_get_policy(str + 5);
62906297
} else if (!strncmp(str, "hpiosize=", 9)) {
62916298
pci_hotplug_io_size = memparse(str + 9, &str);
6299+
} else if (!strncmp(str, "hpmmiosize=", 11)) {
6300+
pci_hotplug_mmio_size = memparse(str + 11, &str);
6301+
} else if (!strncmp(str, "hpmmioprefsize=", 15)) {
6302+
pci_hotplug_mmio_pref_size = memparse(str + 15, &str);
62926303
} else if (!strncmp(str, "hpmemsize=", 10)) {
6293-
pci_hotplug_mem_size = memparse(str + 10, &str);
6304+
pci_hotplug_mmio_size = memparse(str + 10, &str);
6305+
pci_hotplug_mmio_pref_size = pci_hotplug_mmio_size;
62946306
} else if (!strncmp(str, "hpbussize=", 10)) {
62956307
pci_hotplug_bus_size =
62966308
simple_strtoul(str + 10, &str, 0);

drivers/pci/pci.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,8 @@ extern const struct device_type pci_dev_type;
218218
extern const struct attribute_group *pci_bus_groups[];
219219

220220
extern unsigned long pci_hotplug_io_size;
221-
extern unsigned long pci_hotplug_mem_size;
221+
extern unsigned long pci_hotplug_mmio_size;
222+
extern unsigned long pci_hotplug_mmio_pref_size;
222223
extern unsigned long pci_hotplug_bus_size;
223224

224225
/**

drivers/pci/setup-bus.c

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1178,7 +1178,8 @@ void __pci_bus_size_bridges(struct pci_bus *bus, struct list_head *realloc_head)
11781178
{
11791179
struct pci_dev *dev;
11801180
unsigned long mask, prefmask, type2 = 0, type3 = 0;
1181-
resource_size_t additional_mem_size = 0, additional_io_size = 0;
1181+
resource_size_t additional_io_size = 0, additional_mmio_size = 0,
1182+
additional_mmio_pref_size = 0;
11821183
struct resource *b_res;
11831184
int ret;
11841185

@@ -1212,7 +1213,8 @@ void __pci_bus_size_bridges(struct pci_bus *bus, struct list_head *realloc_head)
12121213
pci_bridge_check_ranges(bus);
12131214
if (bus->self->is_hotplug_bridge) {
12141215
additional_io_size = pci_hotplug_io_size;
1215-
additional_mem_size = pci_hotplug_mem_size;
1216+
additional_mmio_size = pci_hotplug_mmio_size;
1217+
additional_mmio_pref_size = pci_hotplug_mmio_pref_size;
12161218
}
12171219
/* Fall through */
12181220
default:
@@ -1230,9 +1232,9 @@ void __pci_bus_size_bridges(struct pci_bus *bus, struct list_head *realloc_head)
12301232
if (b_res[2].flags & IORESOURCE_MEM_64) {
12311233
prefmask |= IORESOURCE_MEM_64;
12321234
ret = pbus_size_mem(bus, prefmask, prefmask,
1233-
prefmask, prefmask,
1234-
realloc_head ? 0 : additional_mem_size,
1235-
additional_mem_size, realloc_head);
1235+
prefmask, prefmask,
1236+
realloc_head ? 0 : additional_mmio_pref_size,
1237+
additional_mmio_pref_size, realloc_head);
12361238

12371239
/*
12381240
* If successful, all non-prefetchable resources
@@ -1254,9 +1256,9 @@ void __pci_bus_size_bridges(struct pci_bus *bus, struct list_head *realloc_head)
12541256
if (!type2) {
12551257
prefmask &= ~IORESOURCE_MEM_64;
12561258
ret = pbus_size_mem(bus, prefmask, prefmask,
1257-
prefmask, prefmask,
1258-
realloc_head ? 0 : additional_mem_size,
1259-
additional_mem_size, realloc_head);
1259+
prefmask, prefmask,
1260+
realloc_head ? 0 : additional_mmio_pref_size,
1261+
additional_mmio_pref_size, realloc_head);
12601262

12611263
/*
12621264
* If successful, only non-prefetchable resources
@@ -1265,7 +1267,7 @@ void __pci_bus_size_bridges(struct pci_bus *bus, struct list_head *realloc_head)
12651267
if (ret == 0)
12661268
mask = prefmask;
12671269
else
1268-
additional_mem_size += additional_mem_size;
1270+
additional_mmio_size += additional_mmio_pref_size;
12691271

12701272
type2 = type3 = IORESOURCE_MEM;
12711273
}
@@ -1285,8 +1287,8 @@ void __pci_bus_size_bridges(struct pci_bus *bus, struct list_head *realloc_head)
12851287
* prefetchable resource in a 64-bit prefetchable window.
12861288
*/
12871289
pbus_size_mem(bus, mask, IORESOURCE_MEM, type2, type3,
1288-
realloc_head ? 0 : additional_mem_size,
1289-
additional_mem_size, realloc_head);
1290+
realloc_head ? 0 : additional_mmio_size,
1291+
additional_mmio_size, realloc_head);
12901292
break;
12911293
}
12921294
}

0 commit comments

Comments
 (0)