diff mbox series

[v8,5/6] PCI: Add hp_mmio_size and hp_mmio_pref_size parameters

Message ID SL2P216MB0187C45A8B38504D855A1DEA80C00@SL2P216MB0187.KORP216.PROD.OUTLOOK.COM (mailing list archive)
State New, archived
Delegated to: Bjorn Helgaas
Headers show
Series Patch series to support Thunderbolt without any BIOS support | expand

Commit Message

Nicholas Johnson July 26, 2019, 12:54 p.m. UTC
Add kernel parameter pci=hpmmiosize=nn[KMG] to set MMIO bridge window
size for hotplug bridges.

Add kernel parameter pci=hpmmioprefsize=nn[KMG] to set MMIO_PREF bridge
window size for hotplug bridges.

Leave pci=hpmemsize=nn[KMG] unchanged, to prevent disruptions to
existing users. This sets both MMIO and MMIO_PREF to the same size.

The two new parameters conform to the style of pci=hpiosize=nn[KMG].

Signed-off-by: Nicholas Johnson <nicholas.johnson-opensource@outlook.com.au>
---
 .../admin-guide/kernel-parameters.txt         |  9 ++++++-
 drivers/pci/pci.c                             | 17 ++++++++++---
 drivers/pci/setup-bus.c                       | 25 +++++++++++--------
 include/linux/pci.h                           |  3 ++-
 4 files changed, 38 insertions(+), 16 deletions(-)

Comments

Mika Westerberg Oct. 8, 2019, 12:16 p.m. UTC | #1
On Fri, Jul 26, 2019 at 12:54:44PM +0000, Nicholas Johnson wrote:
> Add kernel parameter pci=hpmmiosize=nn[KMG] to set MMIO bridge window
> size for hotplug bridges.
> 
> Add kernel parameter pci=hpmmioprefsize=nn[KMG] to set MMIO_PREF bridge
> window size for hotplug bridges.
> 
> Leave pci=hpmemsize=nn[KMG] unchanged, to prevent disruptions to
> existing users. This sets both MMIO and MMIO_PREF to the same size.
> 
> The two new parameters conform to the style of pci=hpiosize=nn[KMG].
> 
> Signed-off-by: Nicholas Johnson <nicholas.johnson-opensource@outlook.com.au>

This does not apply anymore because of 003d3b2c5f83 ("PCI: Make
pci_hotplug_io_size, mem_size, and bus_size private") so I think you
need to rebase this on top of current mainline.

> ---
>  .../admin-guide/kernel-parameters.txt         |  9 ++++++-
>  drivers/pci/pci.c                             | 17 ++++++++++---
>  drivers/pci/setup-bus.c                       | 25 +++++++++++--------
>  include/linux/pci.h                           |  3 ++-
>  4 files changed, 38 insertions(+), 16 deletions(-)
> 
> diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
> index 46b826fcb..9bc54cb99 100644
> --- a/Documentation/admin-guide/kernel-parameters.txt
> +++ b/Documentation/admin-guide/kernel-parameters.txt
> @@ -3467,8 +3467,15 @@
>  		hpiosize=nn[KMG]	The fixed amount of bus space which is
>  				reserved for hotplug bridge's IO window.
>  				Default size is 256 bytes.
> +		hpmmiosize=nn[KMG]	The fixed amount of bus space which is
> +				reserved for hotplug bridge's MMIO window.
> +				Default size is 2 megabytes.
> +		hpmmioprefsize=nn[KMG]	The fixed amount of bus space which is
> +				reserved for hotplug bridge's MMIO_PREF window.
> +				Default size is 2 megabytes.
>  		hpmemsize=nn[KMG]	The fixed amount of bus space which is
> -				reserved for hotplug bridge's memory window.
> +				reserved for hotplug bridge's MMIO and
> +				MMIO_PREF window.
>  				Default size is 2 megabytes.
>  		hpbussize=nn	The minimum amount of additional bus numbers
>  				reserved for buses below a hotplug bridge.
> diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
> index 29ed5ec1a..6b3857cad 100644
> --- a/drivers/pci/pci.c
> +++ b/drivers/pci/pci.c
> @@ -85,10 +85,12 @@ unsigned long pci_cardbus_io_size = DEFAULT_CARDBUS_IO_SIZE;
>  unsigned long pci_cardbus_mem_size = DEFAULT_CARDBUS_MEM_SIZE;
>  
>  #define DEFAULT_HOTPLUG_IO_SIZE		(256)
> -#define DEFAULT_HOTPLUG_MEM_SIZE	(2*1024*1024)
> +#define DEFAULT_HOTPLUG_MMIO_SIZE	(2*1024*1024)
> +#define DEFAULT_HOTPLUG_MMIO_PREF_SIZE	(2*1024*1024)
>  /* pci=hpmemsize=nnM,hpiosize=nn can override this */
>  unsigned long pci_hotplug_io_size  = DEFAULT_HOTPLUG_IO_SIZE;
> -unsigned long pci_hotplug_mem_size = DEFAULT_HOTPLUG_MEM_SIZE;
> +unsigned long pci_hotplug_mmio_size = DEFAULT_HOTPLUG_MMIO_SIZE;
> +unsigned long pci_hotplug_mmio_pref_size = DEFAULT_HOTPLUG_MMIO_PREF_SIZE;
>  
>  #define DEFAULT_HOTPLUG_BUS_SIZE	1
>  unsigned long pci_hotplug_bus_size = DEFAULT_HOTPLUG_BUS_SIZE;
> @@ -6281,8 +6283,17 @@ static int __init pci_setup(char *str)
>  				pcie_ecrc_get_policy(str + 5);
>  			} else if (!strncmp(str, "hpiosize=", 9)) {
>  				pci_hotplug_io_size = memparse(str + 9, &str);
> +			} else if (!strncmp(str, "hpmmiosize=", 11)) {
> +				pci_hotplug_mmio_size =
> +					memparse(str + 11, &str);

I would keep this in single line disregarding the 80 char limit.

> +			} else if (!strncmp(str, "hpmmioprefsize=", 15)) {
> +				pci_hotplug_mmio_pref_size =
> +					memparse(str + 15, &str);

Ditto

>  			} else if (!strncmp(str, "hpmemsize=", 10)) {
> -				pci_hotplug_mem_size = memparse(str + 10, &str);
> +				pci_hotplug_mmio_size =
> +					memparse(str + 10, &str);
Ditto.

> +				pci_hotplug_mmio_pref_size =
> +					memparse(str + 10, &str);

Ditto.

>  			} else if (!strncmp(str, "hpbussize=", 10)) {
>  				pci_hotplug_bus_size =
>  					simple_strtoul(str + 10, &str, 0);
> diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c
> index 7e1dc892a..345ecf16d 100644
> --- a/drivers/pci/setup-bus.c
> +++ b/drivers/pci/setup-bus.c
> @@ -1178,7 +1178,8 @@ void __pci_bus_size_bridges(struct pci_bus *bus, struct list_head *realloc_head)
>  {
>  	struct pci_dev *dev;
>  	unsigned long mask, prefmask, type2 = 0, type3 = 0;
> -	resource_size_t additional_mem_size = 0, additional_io_size = 0;
> +	resource_size_t additional_io_size = 0, additional_mmio_size = 0,
> +		additional_mmio_pref_size = 0;

Maybe align them like

	resource_size_t additional_io_size = 0, additional_mmio_size = 0,
			additional_mmio_pref_size = 0;

>  	struct resource *b_res;
>  	int ret;
>  
> @@ -1212,7 +1213,8 @@ void __pci_bus_size_bridges(struct pci_bus *bus, struct list_head *realloc_head)
>  		pci_bridge_check_ranges(bus);
>  		if (bus->self->is_hotplug_bridge) {
>  			additional_io_size  = pci_hotplug_io_size;
> -			additional_mem_size = pci_hotplug_mem_size;
> +			additional_mmio_size = pci_hotplug_mmio_size;
> +			additional_mmio_pref_size = pci_hotplug_mmio_pref_size;
>  		}
>  		/* Fall through */
>  	default:
> @@ -1230,9 +1232,9 @@ void __pci_bus_size_bridges(struct pci_bus *bus, struct list_head *realloc_head)
>  		if (b_res[2].flags & IORESOURCE_MEM_64) {
>  			prefmask |= IORESOURCE_MEM_64;
>  			ret = pbus_size_mem(bus, prefmask, prefmask,
> -				  prefmask, prefmask,
> -				  realloc_head ? 0 : additional_mem_size,
> -				  additional_mem_size, realloc_head);
> +				prefmask, prefmask,
> +				realloc_head ? 0 : additional_mmio_pref_size,
> +				additional_mmio_pref_size, realloc_head);
>  
>  			/*
>  			 * If successful, all non-prefetchable resources
> @@ -1254,9 +1256,9 @@ void __pci_bus_size_bridges(struct pci_bus *bus, struct list_head *realloc_head)
>  		if (!type2) {
>  			prefmask &= ~IORESOURCE_MEM_64;
>  			ret = pbus_size_mem(bus, prefmask, prefmask,
> -					 prefmask, prefmask,
> -					 realloc_head ? 0 : additional_mem_size,
> -					 additional_mem_size, realloc_head);
> +				prefmask, prefmask,
> +				realloc_head ? 0 : additional_mmio_pref_size,
> +				additional_mmio_pref_size, realloc_head);
>  
>  			/*
>  			 * If successful, only non-prefetchable resources
> @@ -1265,7 +1267,8 @@ void __pci_bus_size_bridges(struct pci_bus *bus, struct list_head *realloc_head)
>  			if (ret == 0)
>  				mask = prefmask;
>  			else
> -				additional_mem_size += additional_mem_size;
> +				additional_mmio_size +=
> +					additional_mmio_pref_size;

Here also looks better if you put them single line.

>  
>  			type2 = type3 = IORESOURCE_MEM;
>  		}
> @@ -1285,8 +1288,8 @@ void __pci_bus_size_bridges(struct pci_bus *bus, struct list_head *realloc_head)
>  		 * prefetchable resource in a 64-bit prefetchable window.
>  		 */
>  		pbus_size_mem(bus, mask, IORESOURCE_MEM, type2, type3,
> -				realloc_head ? 0 : additional_mem_size,
> -				additional_mem_size, realloc_head);
> +			realloc_head ? 0 : additional_mmio_size,
> +			additional_mmio_size, realloc_head);
>  		break;
>  	}
>  }
> diff --git a/include/linux/pci.h b/include/linux/pci.h
> index 9e700d9f9..1bde5763a 100644
> --- a/include/linux/pci.h
> +++ b/include/linux/pci.h
> @@ -2031,7 +2031,8 @@ extern u8 pci_dfl_cache_line_size;
>  extern u8 pci_cache_line_size;
>  
>  extern unsigned long pci_hotplug_io_size;
> -extern unsigned long pci_hotplug_mem_size;
> +extern unsigned long pci_hotplug_mmio_size;
> +extern unsigned long pci_hotplug_mmio_pref_size;
>  extern unsigned long pci_hotplug_bus_size;
>  
>  /* Architecture-specific versions may override these (weak) */
> -- 
> 2.22.0
Nicholas Johnson Oct. 23, 2019, 9:25 a.m. UTC | #2
On Tue, Oct 08, 2019 at 03:16:23PM +0300, mika.westerberg@linux.intel.com wrote:
> On Fri, Jul 26, 2019 at 12:54:44PM +0000, Nicholas Johnson wrote:
> > Add kernel parameter pci=hpmmiosize=nn[KMG] to set MMIO bridge window
> > size for hotplug bridges.
> > 
> > Add kernel parameter pci=hpmmioprefsize=nn[KMG] to set MMIO_PREF bridge
> > window size for hotplug bridges.
> > 
> > Leave pci=hpmemsize=nn[KMG] unchanged, to prevent disruptions to
> > existing users. This sets both MMIO and MMIO_PREF to the same size.
> > 
> > The two new parameters conform to the style of pci=hpiosize=nn[KMG].
> > 
> > Signed-off-by: Nicholas Johnson <nicholas.johnson-opensource@outlook.com.au>
> 
> This does not apply anymore because of 003d3b2c5f83 ("PCI: Make
> pci_hotplug_io_size, mem_size, and bus_size private") so I think you
> need to rebase this on top of current mainline.
Yes, that was the first thing I noticed when doing Linux 5.4. Despite 
not posting straight away, I did compile straight away. I did just 
re-post this patch on its own (breaking away from the series).

It is nice how I no longer need to modify anything outside of 
drivers/pci and Documentation/ directories because of 003d3b2c5f83, 
which may make it easier to get signed off. It also means that 
re-applying the patch no longer triggers a full kernel recompile.

I should have read the following advice first, but I will make changes 
and re-post.

> 
> > ---
> >  .../admin-guide/kernel-parameters.txt         |  9 ++++++-
> >  drivers/pci/pci.c                             | 17 ++++++++++---
> >  drivers/pci/setup-bus.c                       | 25 +++++++++++--------
> >  include/linux/pci.h                           |  3 ++-
> >  4 files changed, 38 insertions(+), 16 deletions(-)
> > 
> > diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
> > index 46b826fcb..9bc54cb99 100644
> > --- a/Documentation/admin-guide/kernel-parameters.txt
> > +++ b/Documentation/admin-guide/kernel-parameters.txt
> > @@ -3467,8 +3467,15 @@
> >  		hpiosize=nn[KMG]	The fixed amount of bus space which is
> >  				reserved for hotplug bridge's IO window.
> >  				Default size is 256 bytes.
> > +		hpmmiosize=nn[KMG]	The fixed amount of bus space which is
> > +				reserved for hotplug bridge's MMIO window.
> > +				Default size is 2 megabytes.
> > +		hpmmioprefsize=nn[KMG]	The fixed amount of bus space which is
> > +				reserved for hotplug bridge's MMIO_PREF window.
> > +				Default size is 2 megabytes.
> >  		hpmemsize=nn[KMG]	The fixed amount of bus space which is
> > -				reserved for hotplug bridge's memory window.
> > +				reserved for hotplug bridge's MMIO and
> > +				MMIO_PREF window.
> >  				Default size is 2 megabytes.
> >  		hpbussize=nn	The minimum amount of additional bus numbers
> >  				reserved for buses below a hotplug bridge.
> > diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
> > index 29ed5ec1a..6b3857cad 100644
> > --- a/drivers/pci/pci.c
> > +++ b/drivers/pci/pci.c
> > @@ -85,10 +85,12 @@ unsigned long pci_cardbus_io_size = DEFAULT_CARDBUS_IO_SIZE;
> >  unsigned long pci_cardbus_mem_size = DEFAULT_CARDBUS_MEM_SIZE;
> >  
> >  #define DEFAULT_HOTPLUG_IO_SIZE		(256)
> > -#define DEFAULT_HOTPLUG_MEM_SIZE	(2*1024*1024)
> > +#define DEFAULT_HOTPLUG_MMIO_SIZE	(2*1024*1024)
> > +#define DEFAULT_HOTPLUG_MMIO_PREF_SIZE	(2*1024*1024)
> >  /* pci=hpmemsize=nnM,hpiosize=nn can override this */
> >  unsigned long pci_hotplug_io_size  = DEFAULT_HOTPLUG_IO_SIZE;
> > -unsigned long pci_hotplug_mem_size = DEFAULT_HOTPLUG_MEM_SIZE;
> > +unsigned long pci_hotplug_mmio_size = DEFAULT_HOTPLUG_MMIO_SIZE;
> > +unsigned long pci_hotplug_mmio_pref_size = DEFAULT_HOTPLUG_MMIO_PREF_SIZE;
> >  
> >  #define DEFAULT_HOTPLUG_BUS_SIZE	1
> >  unsigned long pci_hotplug_bus_size = DEFAULT_HOTPLUG_BUS_SIZE;
> > @@ -6281,8 +6283,17 @@ static int __init pci_setup(char *str)
> >  				pcie_ecrc_get_policy(str + 5);
> >  			} else if (!strncmp(str, "hpiosize=", 9)) {
> >  				pci_hotplug_io_size = memparse(str + 9, &str);
> > +			} else if (!strncmp(str, "hpmmiosize=", 11)) {
> > +				pci_hotplug_mmio_size =
> > +					memparse(str + 11, &str);
> 
> I would keep this in single line disregarding the 80 char limit.
> 
> > +			} else if (!strncmp(str, "hpmmioprefsize=", 15)) {
> > +				pci_hotplug_mmio_pref_size =
> > +					memparse(str + 15, &str);
> 
> Ditto
> 
> >  			} else if (!strncmp(str, "hpmemsize=", 10)) {
> > -				pci_hotplug_mem_size = memparse(str + 10, &str);
> > +				pci_hotplug_mmio_size =
> > +					memparse(str + 10, &str);
> Ditto.
> 
> > +				pci_hotplug_mmio_pref_size =
> > +					memparse(str + 10, &str);
> 
> Ditto.
> 
> >  			} else if (!strncmp(str, "hpbussize=", 10)) {
> >  				pci_hotplug_bus_size =
> >  					simple_strtoul(str + 10, &str, 0);
> > diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c
> > index 7e1dc892a..345ecf16d 100644
> > --- a/drivers/pci/setup-bus.c
> > +++ b/drivers/pci/setup-bus.c
> > @@ -1178,7 +1178,8 @@ void __pci_bus_size_bridges(struct pci_bus *bus, struct list_head *realloc_head)
> >  {
> >  	struct pci_dev *dev;
> >  	unsigned long mask, prefmask, type2 = 0, type3 = 0;
> > -	resource_size_t additional_mem_size = 0, additional_io_size = 0;
> > +	resource_size_t additional_io_size = 0, additional_mmio_size = 0,
> > +		additional_mmio_pref_size = 0;
> 
> Maybe align them like
> 
> 	resource_size_t additional_io_size = 0, additional_mmio_size = 0,
> 			additional_mmio_pref_size = 0;
> 
> >  	struct resource *b_res;
> >  	int ret;
> >  
> > @@ -1212,7 +1213,8 @@ void __pci_bus_size_bridges(struct pci_bus *bus, struct list_head *realloc_head)
> >  		pci_bridge_check_ranges(bus);
> >  		if (bus->self->is_hotplug_bridge) {
> >  			additional_io_size  = pci_hotplug_io_size;
> > -			additional_mem_size = pci_hotplug_mem_size;
> > +			additional_mmio_size = pci_hotplug_mmio_size;
> > +			additional_mmio_pref_size = pci_hotplug_mmio_pref_size;
> >  		}
> >  		/* Fall through */
> >  	default:
> > @@ -1230,9 +1232,9 @@ void __pci_bus_size_bridges(struct pci_bus *bus, struct list_head *realloc_head)
> >  		if (b_res[2].flags & IORESOURCE_MEM_64) {
> >  			prefmask |= IORESOURCE_MEM_64;
> >  			ret = pbus_size_mem(bus, prefmask, prefmask,
> > -				  prefmask, prefmask,
> > -				  realloc_head ? 0 : additional_mem_size,
> > -				  additional_mem_size, realloc_head);
> > +				prefmask, prefmask,
> > +				realloc_head ? 0 : additional_mmio_pref_size,
> > +				additional_mmio_pref_size, realloc_head);
> >  
> >  			/*
> >  			 * If successful, all non-prefetchable resources
> > @@ -1254,9 +1256,9 @@ void __pci_bus_size_bridges(struct pci_bus *bus, struct list_head *realloc_head)
> >  		if (!type2) {
> >  			prefmask &= ~IORESOURCE_MEM_64;
> >  			ret = pbus_size_mem(bus, prefmask, prefmask,
> > -					 prefmask, prefmask,
> > -					 realloc_head ? 0 : additional_mem_size,
> > -					 additional_mem_size, realloc_head);
> > +				prefmask, prefmask,
> > +				realloc_head ? 0 : additional_mmio_pref_size,
> > +				additional_mmio_pref_size, realloc_head);
> >  
> >  			/*
> >  			 * If successful, only non-prefetchable resources
> > @@ -1265,7 +1267,8 @@ void __pci_bus_size_bridges(struct pci_bus *bus, struct list_head *realloc_head)
> >  			if (ret == 0)
> >  				mask = prefmask;
> >  			else
> > -				additional_mem_size += additional_mem_size;
> > +				additional_mmio_size +=
> > +					additional_mmio_pref_size;
> 
> Here also looks better if you put them single line.
> 
> >  
> >  			type2 = type3 = IORESOURCE_MEM;
> >  		}
> > @@ -1285,8 +1288,8 @@ void __pci_bus_size_bridges(struct pci_bus *bus, struct list_head *realloc_head)
> >  		 * prefetchable resource in a 64-bit prefetchable window.
> >  		 */
> >  		pbus_size_mem(bus, mask, IORESOURCE_MEM, type2, type3,
> > -				realloc_head ? 0 : additional_mem_size,
> > -				additional_mem_size, realloc_head);
> > +			realloc_head ? 0 : additional_mmio_size,
> > +			additional_mmio_size, realloc_head);
> >  		break;
> >  	}
> >  }
> > diff --git a/include/linux/pci.h b/include/linux/pci.h
> > index 9e700d9f9..1bde5763a 100644
> > --- a/include/linux/pci.h
> > +++ b/include/linux/pci.h
> > @@ -2031,7 +2031,8 @@ extern u8 pci_dfl_cache_line_size;
> >  extern u8 pci_cache_line_size;
> >  
> >  extern unsigned long pci_hotplug_io_size;
> > -extern unsigned long pci_hotplug_mem_size;
> > +extern unsigned long pci_hotplug_mmio_size;
> > +extern unsigned long pci_hotplug_mmio_pref_size;
> >  extern unsigned long pci_hotplug_bus_size;
> >  
> >  /* Architecture-specific versions may override these (weak) */
> > -- 
> > 2.22.0

Okay, so basically alignment and ignore the 80-character rule in a heap 
of cases. That seems easy enough.

Thanks for reviewing.
diff mbox series

Patch

diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index 46b826fcb..9bc54cb99 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -3467,8 +3467,15 @@ 
 		hpiosize=nn[KMG]	The fixed amount of bus space which is
 				reserved for hotplug bridge's IO window.
 				Default size is 256 bytes.
+		hpmmiosize=nn[KMG]	The fixed amount of bus space which is
+				reserved for hotplug bridge's MMIO window.
+				Default size is 2 megabytes.
+		hpmmioprefsize=nn[KMG]	The fixed amount of bus space which is
+				reserved for hotplug bridge's MMIO_PREF window.
+				Default size is 2 megabytes.
 		hpmemsize=nn[KMG]	The fixed amount of bus space which is
-				reserved for hotplug bridge's memory window.
+				reserved for hotplug bridge's MMIO and
+				MMIO_PREF window.
 				Default size is 2 megabytes.
 		hpbussize=nn	The minimum amount of additional bus numbers
 				reserved for buses below a hotplug bridge.
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 29ed5ec1a..6b3857cad 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -85,10 +85,12 @@  unsigned long pci_cardbus_io_size = DEFAULT_CARDBUS_IO_SIZE;
 unsigned long pci_cardbus_mem_size = DEFAULT_CARDBUS_MEM_SIZE;
 
 #define DEFAULT_HOTPLUG_IO_SIZE		(256)
-#define DEFAULT_HOTPLUG_MEM_SIZE	(2*1024*1024)
+#define DEFAULT_HOTPLUG_MMIO_SIZE	(2*1024*1024)
+#define DEFAULT_HOTPLUG_MMIO_PREF_SIZE	(2*1024*1024)
 /* pci=hpmemsize=nnM,hpiosize=nn can override this */
 unsigned long pci_hotplug_io_size  = DEFAULT_HOTPLUG_IO_SIZE;
-unsigned long pci_hotplug_mem_size = DEFAULT_HOTPLUG_MEM_SIZE;
+unsigned long pci_hotplug_mmio_size = DEFAULT_HOTPLUG_MMIO_SIZE;
+unsigned long pci_hotplug_mmio_pref_size = DEFAULT_HOTPLUG_MMIO_PREF_SIZE;
 
 #define DEFAULT_HOTPLUG_BUS_SIZE	1
 unsigned long pci_hotplug_bus_size = DEFAULT_HOTPLUG_BUS_SIZE;
@@ -6281,8 +6283,17 @@  static int __init pci_setup(char *str)
 				pcie_ecrc_get_policy(str + 5);
 			} else if (!strncmp(str, "hpiosize=", 9)) {
 				pci_hotplug_io_size = memparse(str + 9, &str);
+			} else if (!strncmp(str, "hpmmiosize=", 11)) {
+				pci_hotplug_mmio_size =
+					memparse(str + 11, &str);
+			} else if (!strncmp(str, "hpmmioprefsize=", 15)) {
+				pci_hotplug_mmio_pref_size =
+					memparse(str + 15, &str);
 			} else if (!strncmp(str, "hpmemsize=", 10)) {
-				pci_hotplug_mem_size = memparse(str + 10, &str);
+				pci_hotplug_mmio_size =
+					memparse(str + 10, &str);
+				pci_hotplug_mmio_pref_size =
+					memparse(str + 10, &str);
 			} else if (!strncmp(str, "hpbussize=", 10)) {
 				pci_hotplug_bus_size =
 					simple_strtoul(str + 10, &str, 0);
diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c
index 7e1dc892a..345ecf16d 100644
--- a/drivers/pci/setup-bus.c
+++ b/drivers/pci/setup-bus.c
@@ -1178,7 +1178,8 @@  void __pci_bus_size_bridges(struct pci_bus *bus, struct list_head *realloc_head)
 {
 	struct pci_dev *dev;
 	unsigned long mask, prefmask, type2 = 0, type3 = 0;
-	resource_size_t additional_mem_size = 0, additional_io_size = 0;
+	resource_size_t additional_io_size = 0, additional_mmio_size = 0,
+		additional_mmio_pref_size = 0;
 	struct resource *b_res;
 	int ret;
 
@@ -1212,7 +1213,8 @@  void __pci_bus_size_bridges(struct pci_bus *bus, struct list_head *realloc_head)
 		pci_bridge_check_ranges(bus);
 		if (bus->self->is_hotplug_bridge) {
 			additional_io_size  = pci_hotplug_io_size;
-			additional_mem_size = pci_hotplug_mem_size;
+			additional_mmio_size = pci_hotplug_mmio_size;
+			additional_mmio_pref_size = pci_hotplug_mmio_pref_size;
 		}
 		/* Fall through */
 	default:
@@ -1230,9 +1232,9 @@  void __pci_bus_size_bridges(struct pci_bus *bus, struct list_head *realloc_head)
 		if (b_res[2].flags & IORESOURCE_MEM_64) {
 			prefmask |= IORESOURCE_MEM_64;
 			ret = pbus_size_mem(bus, prefmask, prefmask,
-				  prefmask, prefmask,
-				  realloc_head ? 0 : additional_mem_size,
-				  additional_mem_size, realloc_head);
+				prefmask, prefmask,
+				realloc_head ? 0 : additional_mmio_pref_size,
+				additional_mmio_pref_size, realloc_head);
 
 			/*
 			 * If successful, all non-prefetchable resources
@@ -1254,9 +1256,9 @@  void __pci_bus_size_bridges(struct pci_bus *bus, struct list_head *realloc_head)
 		if (!type2) {
 			prefmask &= ~IORESOURCE_MEM_64;
 			ret = pbus_size_mem(bus, prefmask, prefmask,
-					 prefmask, prefmask,
-					 realloc_head ? 0 : additional_mem_size,
-					 additional_mem_size, realloc_head);
+				prefmask, prefmask,
+				realloc_head ? 0 : additional_mmio_pref_size,
+				additional_mmio_pref_size, realloc_head);
 
 			/*
 			 * If successful, only non-prefetchable resources
@@ -1265,7 +1267,8 @@  void __pci_bus_size_bridges(struct pci_bus *bus, struct list_head *realloc_head)
 			if (ret == 0)
 				mask = prefmask;
 			else
-				additional_mem_size += additional_mem_size;
+				additional_mmio_size +=
+					additional_mmio_pref_size;
 
 			type2 = type3 = IORESOURCE_MEM;
 		}
@@ -1285,8 +1288,8 @@  void __pci_bus_size_bridges(struct pci_bus *bus, struct list_head *realloc_head)
 		 * prefetchable resource in a 64-bit prefetchable window.
 		 */
 		pbus_size_mem(bus, mask, IORESOURCE_MEM, type2, type3,
-				realloc_head ? 0 : additional_mem_size,
-				additional_mem_size, realloc_head);
+			realloc_head ? 0 : additional_mmio_size,
+			additional_mmio_size, realloc_head);
 		break;
 	}
 }
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 9e700d9f9..1bde5763a 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -2031,7 +2031,8 @@  extern u8 pci_dfl_cache_line_size;
 extern u8 pci_cache_line_size;
 
 extern unsigned long pci_hotplug_io_size;
-extern unsigned long pci_hotplug_mem_size;
+extern unsigned long pci_hotplug_mmio_size;
+extern unsigned long pci_hotplug_mmio_pref_size;
 extern unsigned long pci_hotplug_bus_size;
 
 /* Architecture-specific versions may override these (weak) */