linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] PCI: Fix pci_host_bridge initialization
@ 2019-03-18 16:07 Jean-Philippe Brucker
  2019-04-05 22:51 ` Bjorn Helgaas
  0 siblings, 1 reply; 2+ messages in thread
From: Jean-Philippe Brucker @ 2019-03-18 16:07 UTC (permalink / raw)
  To: bhelgaas; +Cc: lorenzo.pieralisi, linux-pci

Two functions allocate a host bridge, devm_pci_alloc_host_bridge() and
pci_alloc_host_bridge(). At the moment, only the unmanaged one
initializes the PCIe feature bits, which prevents from using features
such as hotplug or AER on some systems, when booting with device tree.
Make the initialization code common.

Fixes: 02bfeb484230 ("PCI/portdrv: Simplify PCIe feature permission checking")
Signed-off-by: Jean-Philippe Brucker <jean-philippe.brucker@arm.com>
---
 drivers/pci/probe.c | 23 ++++++++++++++---------
 1 file changed, 14 insertions(+), 9 deletions(-)

diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 2ec0df04e0dc..012250a78da7 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -586,16 +586,9 @@ static void pci_release_host_bridge_dev(struct device *dev)
 	kfree(to_pci_host_bridge(dev));
 }
 
-struct pci_host_bridge *pci_alloc_host_bridge(size_t priv)
+static void pci_init_host_bridge(struct pci_host_bridge *bridge)
 {
-	struct pci_host_bridge *bridge;
-
-	bridge = kzalloc(sizeof(*bridge) + priv, GFP_KERNEL);
-	if (!bridge)
-		return NULL;
-
 	INIT_LIST_HEAD(&bridge->windows);
-	bridge->dev.release = pci_release_host_bridge_dev;
 
 	/*
 	 * We assume we can manage these PCIe features.  Some systems may
@@ -608,6 +601,18 @@ struct pci_host_bridge *pci_alloc_host_bridge(size_t priv)
 	bridge->native_shpc_hotplug = 1;
 	bridge->native_pme = 1;
 	bridge->native_ltr = 1;
+}
+
+struct pci_host_bridge *pci_alloc_host_bridge(size_t priv)
+{
+	struct pci_host_bridge *bridge;
+
+	bridge = kzalloc(sizeof(*bridge) + priv, GFP_KERNEL);
+	if (!bridge)
+		return NULL;
+
+	pci_init_host_bridge(bridge);
+	bridge->dev.release = pci_release_host_bridge_dev;
 
 	return bridge;
 }
@@ -622,7 +627,7 @@ struct pci_host_bridge *devm_pci_alloc_host_bridge(struct device *dev,
 	if (!bridge)
 		return NULL;
 
-	INIT_LIST_HEAD(&bridge->windows);
+	pci_init_host_bridge(bridge);
 	bridge->dev.release = devm_pci_release_host_bridge_dev;
 
 	return bridge;
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] PCI: Fix pci_host_bridge initialization
  2019-03-18 16:07 [PATCH] PCI: Fix pci_host_bridge initialization Jean-Philippe Brucker
@ 2019-04-05 22:51 ` Bjorn Helgaas
  0 siblings, 0 replies; 2+ messages in thread
From: Bjorn Helgaas @ 2019-04-05 22:51 UTC (permalink / raw)
  To: Jean-Philippe Brucker; +Cc: lorenzo.pieralisi, linux-pci, Vidya Sagar

[+cc Vidya -- Jean-Philippe magically fixed the "tangent 2" problem :)]

On Mon, Mar 18, 2019 at 04:07:18PM +0000, Jean-Philippe Brucker wrote:
> Two functions allocate a host bridge, devm_pci_alloc_host_bridge() and
> pci_alloc_host_bridge(). At the moment, only the unmanaged one
> initializes the PCIe feature bits, which prevents from using features
> such as hotplug or AER on some systems, when booting with device tree.
> Make the initialization code common.
> 
> Fixes: 02bfeb484230 ("PCI/portdrv: Simplify PCIe feature permission checking")
> Signed-off-by: Jean-Philippe Brucker <jean-philippe.brucker@arm.com>

Applied with stable tag to pci/enumeration for v5.2, thanks!

> ---
>  drivers/pci/probe.c | 23 ++++++++++++++---------
>  1 file changed, 14 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
> index 2ec0df04e0dc..012250a78da7 100644
> --- a/drivers/pci/probe.c
> +++ b/drivers/pci/probe.c
> @@ -586,16 +586,9 @@ static void pci_release_host_bridge_dev(struct device *dev)
>  	kfree(to_pci_host_bridge(dev));
>  }
>  
> -struct pci_host_bridge *pci_alloc_host_bridge(size_t priv)
> +static void pci_init_host_bridge(struct pci_host_bridge *bridge)
>  {
> -	struct pci_host_bridge *bridge;
> -
> -	bridge = kzalloc(sizeof(*bridge) + priv, GFP_KERNEL);
> -	if (!bridge)
> -		return NULL;
> -
>  	INIT_LIST_HEAD(&bridge->windows);
> -	bridge->dev.release = pci_release_host_bridge_dev;
>  
>  	/*
>  	 * We assume we can manage these PCIe features.  Some systems may
> @@ -608,6 +601,18 @@ struct pci_host_bridge *pci_alloc_host_bridge(size_t priv)
>  	bridge->native_shpc_hotplug = 1;
>  	bridge->native_pme = 1;
>  	bridge->native_ltr = 1;
> +}
> +
> +struct pci_host_bridge *pci_alloc_host_bridge(size_t priv)
> +{
> +	struct pci_host_bridge *bridge;
> +
> +	bridge = kzalloc(sizeof(*bridge) + priv, GFP_KERNEL);
> +	if (!bridge)
> +		return NULL;
> +
> +	pci_init_host_bridge(bridge);
> +	bridge->dev.release = pci_release_host_bridge_dev;
>  
>  	return bridge;
>  }
> @@ -622,7 +627,7 @@ struct pci_host_bridge *devm_pci_alloc_host_bridge(struct device *dev,
>  	if (!bridge)
>  		return NULL;
>  
> -	INIT_LIST_HEAD(&bridge->windows);
> +	pci_init_host_bridge(bridge);
>  	bridge->dev.release = devm_pci_release_host_bridge_dev;
>  
>  	return bridge;
> -- 
> 2.21.0
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-04-05 22:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-18 16:07 [PATCH] PCI: Fix pci_host_bridge initialization Jean-Philippe Brucker
2019-04-05 22:51 ` Bjorn Helgaas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).