All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4 0/5] PCI: dwc: Support remove
@ 2019-03-29 11:55 ` Jisheng Zhang
  0 siblings, 0 replies; 17+ messages in thread
From: Jisheng Zhang @ 2019-03-29 11:55 UTC (permalink / raw)
  To: Jingoo Han, Gustavo Pimentel, Lorenzo Pieralisi, Bjorn Helgaas
  Cc: linux-pci, linux-kernel, linux-arm-kernel, Robin Murphy

Currently, the PCI dwc host users don't support the remove, but nothing
prevent us from supporting it. To achieve this goal, we need to ensure
we can do necessary clean up work.

Changes since v3:
  - add Gustavo's ACK to patch2, patch5
  - remove IS_ENABLED(CONFIG_PCI_MSI) check

Changes since v2:
  - address all Gustavo's comments
  - add Gustavo's ACK to patch1, patch3, patch4

Changes since v1:
  - address Bjorn's comments, I.E Capitalize, s/irq/IRQ/, s/msi/MSI/


Jisheng Zhang (5):
  PCI: dwc: Fix dw_pcie_free_msi() if msi_irq is invalid
  PCI: dwc: Free the page for MSI IRQ in dw_pcie_free_msi()
  PCI: dwc: Free MSI in the error code path of dw_pcie_host_init()
  PCI: dwc: Use devm_pci_alloc_host_bridge() to simplify the code
  PCI: dwc: Save root bus for driver remove

 .../pci/controller/dwc/pcie-designware-host.c | 60 ++++++++++---------
 drivers/pci/controller/dwc/pcie-designware.h  |  2 +
 2 files changed, 34 insertions(+), 28 deletions(-)

-- 
2.20.1


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

* [PATCH v4 0/5] PCI: dwc: Support remove
@ 2019-03-29 11:55 ` Jisheng Zhang
  0 siblings, 0 replies; 17+ messages in thread
From: Jisheng Zhang @ 2019-03-29 11:55 UTC (permalink / raw)
  To: Jingoo Han, Gustavo Pimentel, Lorenzo Pieralisi, Bjorn Helgaas
  Cc: linux-pci, Robin Murphy, linux-kernel, linux-arm-kernel

Currently, the PCI dwc host users don't support the remove, but nothing
prevent us from supporting it. To achieve this goal, we need to ensure
we can do necessary clean up work.

Changes since v3:
  - add Gustavo's ACK to patch2, patch5
  - remove IS_ENABLED(CONFIG_PCI_MSI) check

Changes since v2:
  - address all Gustavo's comments
  - add Gustavo's ACK to patch1, patch3, patch4

Changes since v1:
  - address Bjorn's comments, I.E Capitalize, s/irq/IRQ/, s/msi/MSI/


Jisheng Zhang (5):
  PCI: dwc: Fix dw_pcie_free_msi() if msi_irq is invalid
  PCI: dwc: Free the page for MSI IRQ in dw_pcie_free_msi()
  PCI: dwc: Free MSI in the error code path of dw_pcie_host_init()
  PCI: dwc: Use devm_pci_alloc_host_bridge() to simplify the code
  PCI: dwc: Save root bus for driver remove

 .../pci/controller/dwc/pcie-designware-host.c | 60 ++++++++++---------
 drivers/pci/controller/dwc/pcie-designware.h  |  2 +
 2 files changed, 34 insertions(+), 28 deletions(-)

-- 
2.20.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH v4 1/5] PCI: dwc: Fix dw_pcie_free_msi() if msi_irq is invalid
  2019-03-29 11:55 ` Jisheng Zhang
  (?)
@ 2019-03-29 11:56   ` Jisheng Zhang
  -1 siblings, 0 replies; 17+ messages in thread
From: Jisheng Zhang @ 2019-03-29 11:56 UTC (permalink / raw)
  To: Jingoo Han, Gustavo Pimentel, Lorenzo Pieralisi, Bjorn Helgaas
  Cc: linux-pci, linux-kernel, linux-arm-kernel, Robin Murphy

We should check msi_irq before calling irq_set_chained_handler() and
irq_set_handler_data().

Signed-off-by: Jisheng Zhang <Jisheng.Zhang@synaptics.com>
Acked-by: Gustavo Pimentel <gustavo.pimentel@synopsys.com>
---
 drivers/pci/controller/dwc/pcie-designware-host.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/pci/controller/dwc/pcie-designware-host.c b/drivers/pci/controller/dwc/pcie-designware-host.c
index 25087d3c9a82..1040939f45b4 100644
--- a/drivers/pci/controller/dwc/pcie-designware-host.c
+++ b/drivers/pci/controller/dwc/pcie-designware-host.c
@@ -298,8 +298,10 @@ int dw_pcie_allocate_domains(struct pcie_port *pp)
 
 void dw_pcie_free_msi(struct pcie_port *pp)
 {
-	irq_set_chained_handler(pp->msi_irq, NULL);
-	irq_set_handler_data(pp->msi_irq, NULL);
+	if (pp->msi_irq) {
+		irq_set_chained_handler(pp->msi_irq, NULL);
+		irq_set_handler_data(pp->msi_irq, NULL);
+	}
 
 	irq_domain_remove(pp->msi_domain);
 	irq_domain_remove(pp->irq_domain);
-- 
2.20.1


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

* [PATCH v4 1/5] PCI: dwc: Fix dw_pcie_free_msi() if msi_irq is invalid
@ 2019-03-29 11:56   ` Jisheng Zhang
  0 siblings, 0 replies; 17+ messages in thread
From: Jisheng Zhang @ 2019-03-29 11:56 UTC (permalink / raw)
  To: Jingoo Han, Gustavo Pimentel, Lorenzo Pieralisi, Bjorn Helgaas
  Cc: linux-pci, Robin Murphy, linux-kernel, linux-arm-kernel

We should check msi_irq before calling irq_set_chained_handler() and
irq_set_handler_data().

Signed-off-by: Jisheng Zhang <Jisheng.Zhang@synaptics.com>
Acked-by: Gustavo Pimentel <gustavo.pimentel@synopsys.com>
---
 drivers/pci/controller/dwc/pcie-designware-host.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/pci/controller/dwc/pcie-designware-host.c b/drivers/pci/controller/dwc/pcie-designware-host.c
index 25087d3c9a82..1040939f45b4 100644
--- a/drivers/pci/controller/dwc/pcie-designware-host.c
+++ b/drivers/pci/controller/dwc/pcie-designware-host.c
@@ -298,8 +298,10 @@ int dw_pcie_allocate_domains(struct pcie_port *pp)
 
 void dw_pcie_free_msi(struct pcie_port *pp)
 {
-	irq_set_chained_handler(pp->msi_irq, NULL);
-	irq_set_handler_data(pp->msi_irq, NULL);
+	if (pp->msi_irq) {
+		irq_set_chained_handler(pp->msi_irq, NULL);
+		irq_set_handler_data(pp->msi_irq, NULL);
+	}
 
 	irq_domain_remove(pp->msi_domain);
 	irq_domain_remove(pp->irq_domain);
-- 
2.20.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH v4 2/5] PCI: dwc: Free the page for MSI IRQ in dw_pcie_free_msi()
  2019-03-29 11:55 ` Jisheng Zhang
@ 2019-03-29 11:57   ` Jisheng Zhang
  -1 siblings, 0 replies; 17+ messages in thread
From: Jisheng Zhang @ 2019-03-29 11:57 UTC (permalink / raw)
  To: Jingoo Han, Gustavo Pimentel, Lorenzo Pieralisi, Bjorn Helgaas
  Cc: linux-pci, linux-kernel, linux-arm-kernel, Robin Murphy

To avoid memory leak, we need to free the page for MSI in
dw_pcie_free_msi().

Signed-off-by: Jisheng Zhang <Jisheng.Zhang@synaptics.com>
Acked-by: Gustavo Pimentel <gustavo.pimentel@synopsys.com>
---
 drivers/pci/controller/dwc/pcie-designware-host.c | 12 ++++++++----
 drivers/pci/controller/dwc/pcie-designware.h      |  1 +
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/drivers/pci/controller/dwc/pcie-designware-host.c b/drivers/pci/controller/dwc/pcie-designware-host.c
index 1040939f45b4..a71b874ae3c0 100644
--- a/drivers/pci/controller/dwc/pcie-designware-host.c
+++ b/drivers/pci/controller/dwc/pcie-designware-host.c
@@ -305,20 +305,24 @@ void dw_pcie_free_msi(struct pcie_port *pp)
 
 	irq_domain_remove(pp->msi_domain);
 	irq_domain_remove(pp->irq_domain);
+
+	if (pp->msi_page)
+		__free_page(pp->msi_page);
 }
 
 void dw_pcie_msi_init(struct pcie_port *pp)
 {
 	struct dw_pcie *pci = to_dw_pcie_from_pp(pp);
 	struct device *dev = pci->dev;
-	struct page *page;
 	u64 msi_target;
 
-	page = alloc_page(GFP_KERNEL);
-	pp->msi_data = dma_map_page(dev, page, 0, PAGE_SIZE, DMA_FROM_DEVICE);
+	pp->msi_page = alloc_page(GFP_KERNEL);
+	pp->msi_data = dma_map_page(dev, pp->msi_page, 0, PAGE_SIZE,
+				    DMA_FROM_DEVICE);
 	if (dma_mapping_error(dev, pp->msi_data)) {
 		dev_err(dev, "Failed to map MSI data\n");
-		__free_page(page);
+		__free_page(pp->msi_page);
+		pp->msi_page = NULL;
 		return;
 	}
 	msi_target = (u64)pp->msi_data;
diff --git a/drivers/pci/controller/dwc/pcie-designware.h b/drivers/pci/controller/dwc/pcie-designware.h
index 377f4c0b52da..6fb0a1879932 100644
--- a/drivers/pci/controller/dwc/pcie-designware.h
+++ b/drivers/pci/controller/dwc/pcie-designware.h
@@ -179,6 +179,7 @@ struct pcie_port {
 	struct irq_domain	*irq_domain;
 	struct irq_domain	*msi_domain;
 	dma_addr_t		msi_data;
+	struct page		*msi_page;
 	u32			num_vectors;
 	u32			irq_mask[MAX_MSI_CTRLS];
 	raw_spinlock_t		lock;
-- 
2.20.1


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

* [PATCH v4 2/5] PCI: dwc: Free the page for MSI IRQ in dw_pcie_free_msi()
@ 2019-03-29 11:57   ` Jisheng Zhang
  0 siblings, 0 replies; 17+ messages in thread
From: Jisheng Zhang @ 2019-03-29 11:57 UTC (permalink / raw)
  To: Jingoo Han, Gustavo Pimentel, Lorenzo Pieralisi, Bjorn Helgaas
  Cc: linux-pci, Robin Murphy, linux-kernel, linux-arm-kernel

To avoid memory leak, we need to free the page for MSI in
dw_pcie_free_msi().

Signed-off-by: Jisheng Zhang <Jisheng.Zhang@synaptics.com>
Acked-by: Gustavo Pimentel <gustavo.pimentel@synopsys.com>
---
 drivers/pci/controller/dwc/pcie-designware-host.c | 12 ++++++++----
 drivers/pci/controller/dwc/pcie-designware.h      |  1 +
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/drivers/pci/controller/dwc/pcie-designware-host.c b/drivers/pci/controller/dwc/pcie-designware-host.c
index 1040939f45b4..a71b874ae3c0 100644
--- a/drivers/pci/controller/dwc/pcie-designware-host.c
+++ b/drivers/pci/controller/dwc/pcie-designware-host.c
@@ -305,20 +305,24 @@ void dw_pcie_free_msi(struct pcie_port *pp)
 
 	irq_domain_remove(pp->msi_domain);
 	irq_domain_remove(pp->irq_domain);
+
+	if (pp->msi_page)
+		__free_page(pp->msi_page);
 }
 
 void dw_pcie_msi_init(struct pcie_port *pp)
 {
 	struct dw_pcie *pci = to_dw_pcie_from_pp(pp);
 	struct device *dev = pci->dev;
-	struct page *page;
 	u64 msi_target;
 
-	page = alloc_page(GFP_KERNEL);
-	pp->msi_data = dma_map_page(dev, page, 0, PAGE_SIZE, DMA_FROM_DEVICE);
+	pp->msi_page = alloc_page(GFP_KERNEL);
+	pp->msi_data = dma_map_page(dev, pp->msi_page, 0, PAGE_SIZE,
+				    DMA_FROM_DEVICE);
 	if (dma_mapping_error(dev, pp->msi_data)) {
 		dev_err(dev, "Failed to map MSI data\n");
-		__free_page(page);
+		__free_page(pp->msi_page);
+		pp->msi_page = NULL;
 		return;
 	}
 	msi_target = (u64)pp->msi_data;
diff --git a/drivers/pci/controller/dwc/pcie-designware.h b/drivers/pci/controller/dwc/pcie-designware.h
index 377f4c0b52da..6fb0a1879932 100644
--- a/drivers/pci/controller/dwc/pcie-designware.h
+++ b/drivers/pci/controller/dwc/pcie-designware.h
@@ -179,6 +179,7 @@ struct pcie_port {
 	struct irq_domain	*irq_domain;
 	struct irq_domain	*msi_domain;
 	dma_addr_t		msi_data;
+	struct page		*msi_page;
 	u32			num_vectors;
 	u32			irq_mask[MAX_MSI_CTRLS];
 	raw_spinlock_t		lock;
-- 
2.20.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH v4 3/5] PCI: dwc: Free MSI in the error code path of dw_pcie_host_init()
  2019-03-29 11:55 ` Jisheng Zhang
@ 2019-03-29 11:57   ` Jisheng Zhang
  -1 siblings, 0 replies; 17+ messages in thread
From: Jisheng Zhang @ 2019-03-29 11:57 UTC (permalink / raw)
  To: Jingoo Han, Gustavo Pimentel, Lorenzo Pieralisi, Bjorn Helgaas
  Cc: linux-pci, linux-kernel, linux-arm-kernel, Robin Murphy

If we ever did some msi related initializations, we need to call
dw_pcie_free_msi() in the error code path.

We also remove the IS_ENABLED(CONFIG_PCI_MSI) check for MSI init,
because pci_msi_enabled() already has a stub for !CONFIG_PCI_MSI.

Signed-off-by: Jisheng Zhang <Jisheng.Zhang@synaptics.com>
Acked-by: Gustavo Pimentel <gustavo.pimentel@synopsys.com>
---
 drivers/pci/controller/dwc/pcie-designware-host.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/pci/controller/dwc/pcie-designware-host.c b/drivers/pci/controller/dwc/pcie-designware-host.c
index a71b874ae3c0..acc9be5cf34a 100644
--- a/drivers/pci/controller/dwc/pcie-designware-host.c
+++ b/drivers/pci/controller/dwc/pcie-designware-host.c
@@ -445,7 +445,7 @@ int dw_pcie_host_init(struct pcie_port *pp)
 	if (ret)
 		pci->num_viewport = 2;
 
-	if (IS_ENABLED(CONFIG_PCI_MSI) && pci_msi_enabled()) {
+	if (pci_msi_enabled()) {
 		/*
 		 * If a specific SoC driver needs to change the
 		 * default number of vectors, it needs to implement
@@ -483,7 +483,7 @@ int dw_pcie_host_init(struct pcie_port *pp)
 	if (pp->ops->host_init) {
 		ret = pp->ops->host_init(pp);
 		if (ret)
-			goto error;
+			goto err_free_msi;
 	}
 
 	pp->root_bus_nr = pp->busn->start;
@@ -497,7 +497,7 @@ int dw_pcie_host_init(struct pcie_port *pp)
 
 	ret = pci_scan_root_bus_bridge(bridge);
 	if (ret)
-		goto error;
+		goto err_free_msi;
 
 	bus = bridge->bus;
 
@@ -513,6 +513,9 @@ int dw_pcie_host_init(struct pcie_port *pp)
 	pci_bus_add_devices(bus);
 	return 0;
 
+err_free_msi:
+	if (pci_msi_enabled() && !pp->ops->msi_host_init)
+		dw_pcie_free_msi(pp);
 error:
 	pci_free_host_bridge(bridge);
 	return ret;
-- 
2.20.1


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

* [PATCH v4 3/5] PCI: dwc: Free MSI in the error code path of dw_pcie_host_init()
@ 2019-03-29 11:57   ` Jisheng Zhang
  0 siblings, 0 replies; 17+ messages in thread
From: Jisheng Zhang @ 2019-03-29 11:57 UTC (permalink / raw)
  To: Jingoo Han, Gustavo Pimentel, Lorenzo Pieralisi, Bjorn Helgaas
  Cc: linux-pci, Robin Murphy, linux-kernel, linux-arm-kernel

If we ever did some msi related initializations, we need to call
dw_pcie_free_msi() in the error code path.

We also remove the IS_ENABLED(CONFIG_PCI_MSI) check for MSI init,
because pci_msi_enabled() already has a stub for !CONFIG_PCI_MSI.

Signed-off-by: Jisheng Zhang <Jisheng.Zhang@synaptics.com>
Acked-by: Gustavo Pimentel <gustavo.pimentel@synopsys.com>
---
 drivers/pci/controller/dwc/pcie-designware-host.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/pci/controller/dwc/pcie-designware-host.c b/drivers/pci/controller/dwc/pcie-designware-host.c
index a71b874ae3c0..acc9be5cf34a 100644
--- a/drivers/pci/controller/dwc/pcie-designware-host.c
+++ b/drivers/pci/controller/dwc/pcie-designware-host.c
@@ -445,7 +445,7 @@ int dw_pcie_host_init(struct pcie_port *pp)
 	if (ret)
 		pci->num_viewport = 2;
 
-	if (IS_ENABLED(CONFIG_PCI_MSI) && pci_msi_enabled()) {
+	if (pci_msi_enabled()) {
 		/*
 		 * If a specific SoC driver needs to change the
 		 * default number of vectors, it needs to implement
@@ -483,7 +483,7 @@ int dw_pcie_host_init(struct pcie_port *pp)
 	if (pp->ops->host_init) {
 		ret = pp->ops->host_init(pp);
 		if (ret)
-			goto error;
+			goto err_free_msi;
 	}
 
 	pp->root_bus_nr = pp->busn->start;
@@ -497,7 +497,7 @@ int dw_pcie_host_init(struct pcie_port *pp)
 
 	ret = pci_scan_root_bus_bridge(bridge);
 	if (ret)
-		goto error;
+		goto err_free_msi;
 
 	bus = bridge->bus;
 
@@ -513,6 +513,9 @@ int dw_pcie_host_init(struct pcie_port *pp)
 	pci_bus_add_devices(bus);
 	return 0;
 
+err_free_msi:
+	if (pci_msi_enabled() && !pp->ops->msi_host_init)
+		dw_pcie_free_msi(pp);
 error:
 	pci_free_host_bridge(bridge);
 	return ret;
-- 
2.20.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH v4 4/5] PCI: dwc: Use devm_pci_alloc_host_bridge() to simplify the code
  2019-03-29 11:55 ` Jisheng Zhang
@ 2019-03-29 11:58   ` Jisheng Zhang
  -1 siblings, 0 replies; 17+ messages in thread
From: Jisheng Zhang @ 2019-03-29 11:58 UTC (permalink / raw)
  To: Jingoo Han, Gustavo Pimentel, Lorenzo Pieralisi, Bjorn Helgaas
  Cc: linux-pci, linux-kernel, linux-arm-kernel, Robin Murphy

Use devm_pci_alloc_host_bridge() to simplify the error code path.

Signed-off-by: Jisheng Zhang <Jisheng.Zhang@synaptics.com>
Acked-by: Gustavo Pimentel <gustavo.pimentel@synopsys.com>
---
 .../pci/controller/dwc/pcie-designware-host.c | 21 +++++++------------
 1 file changed, 8 insertions(+), 13 deletions(-)

diff --git a/drivers/pci/controller/dwc/pcie-designware-host.c b/drivers/pci/controller/dwc/pcie-designware-host.c
index acc9be5cf34a..dcc7405aff9a 100644
--- a/drivers/pci/controller/dwc/pcie-designware-host.c
+++ b/drivers/pci/controller/dwc/pcie-designware-host.c
@@ -358,7 +358,7 @@ int dw_pcie_host_init(struct pcie_port *pp)
 		dev_err(dev, "Missing *config* reg space\n");
 	}
 
-	bridge = pci_alloc_host_bridge(0);
+	bridge = devm_pci_alloc_host_bridge(dev, 0);
 	if (!bridge)
 		return -ENOMEM;
 
@@ -369,7 +369,7 @@ int dw_pcie_host_init(struct pcie_port *pp)
 
 	ret = devm_request_pci_bus_resources(dev, &bridge->windows);
 	if (ret)
-		goto error;
+		return ret;
 
 	/* Get the I/O and memory ranges from DT */
 	resource_list_for_each_entry_safe(win, tmp, &bridge->windows) {
@@ -413,8 +413,7 @@ int dw_pcie_host_init(struct pcie_port *pp)
 						resource_size(pp->cfg));
 		if (!pci->dbi_base) {
 			dev_err(dev, "Error with ioremap\n");
-			ret = -ENOMEM;
-			goto error;
+			return -ENOMEM;
 		}
 	}
 
@@ -425,8 +424,7 @@ int dw_pcie_host_init(struct pcie_port *pp)
 					pp->cfg0_base, pp->cfg0_size);
 		if (!pp->va_cfg0_base) {
 			dev_err(dev, "Error with ioremap in function\n");
-			ret = -ENOMEM;
-			goto error;
+			return -ENOMEM;
 		}
 	}
 
@@ -436,8 +434,7 @@ int dw_pcie_host_init(struct pcie_port *pp)
 						pp->cfg1_size);
 		if (!pp->va_cfg1_base) {
 			dev_err(dev, "Error with ioremap\n");
-			ret = -ENOMEM;
-			goto error;
+			return -ENOMEM;
 		}
 	}
 
@@ -460,14 +457,14 @@ int dw_pcie_host_init(struct pcie_port *pp)
 			    pp->num_vectors == 0) {
 				dev_err(dev,
 					"Invalid number of vectors\n");
-				goto error;
+				return -EINVAL;
 			}
 		}
 
 		if (!pp->ops->msi_host_init) {
 			ret = dw_pcie_allocate_domains(pp);
 			if (ret)
-				goto error;
+				return ret;
 
 			if (pp->msi_irq)
 				irq_set_chained_handler_and_data(pp->msi_irq,
@@ -476,7 +473,7 @@ int dw_pcie_host_init(struct pcie_port *pp)
 		} else {
 			ret = pp->ops->msi_host_init(pp);
 			if (ret < 0)
-				goto error;
+				return ret;
 		}
 	}
 
@@ -516,8 +513,6 @@ int dw_pcie_host_init(struct pcie_port *pp)
 err_free_msi:
 	if (pci_msi_enabled() && !pp->ops->msi_host_init)
 		dw_pcie_free_msi(pp);
-error:
-	pci_free_host_bridge(bridge);
 	return ret;
 }
 
-- 
2.20.1


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

* [PATCH v4 4/5] PCI: dwc: Use devm_pci_alloc_host_bridge() to simplify the code
@ 2019-03-29 11:58   ` Jisheng Zhang
  0 siblings, 0 replies; 17+ messages in thread
From: Jisheng Zhang @ 2019-03-29 11:58 UTC (permalink / raw)
  To: Jingoo Han, Gustavo Pimentel, Lorenzo Pieralisi, Bjorn Helgaas
  Cc: linux-pci, Robin Murphy, linux-kernel, linux-arm-kernel

Use devm_pci_alloc_host_bridge() to simplify the error code path.

Signed-off-by: Jisheng Zhang <Jisheng.Zhang@synaptics.com>
Acked-by: Gustavo Pimentel <gustavo.pimentel@synopsys.com>
---
 .../pci/controller/dwc/pcie-designware-host.c | 21 +++++++------------
 1 file changed, 8 insertions(+), 13 deletions(-)

diff --git a/drivers/pci/controller/dwc/pcie-designware-host.c b/drivers/pci/controller/dwc/pcie-designware-host.c
index acc9be5cf34a..dcc7405aff9a 100644
--- a/drivers/pci/controller/dwc/pcie-designware-host.c
+++ b/drivers/pci/controller/dwc/pcie-designware-host.c
@@ -358,7 +358,7 @@ int dw_pcie_host_init(struct pcie_port *pp)
 		dev_err(dev, "Missing *config* reg space\n");
 	}
 
-	bridge = pci_alloc_host_bridge(0);
+	bridge = devm_pci_alloc_host_bridge(dev, 0);
 	if (!bridge)
 		return -ENOMEM;
 
@@ -369,7 +369,7 @@ int dw_pcie_host_init(struct pcie_port *pp)
 
 	ret = devm_request_pci_bus_resources(dev, &bridge->windows);
 	if (ret)
-		goto error;
+		return ret;
 
 	/* Get the I/O and memory ranges from DT */
 	resource_list_for_each_entry_safe(win, tmp, &bridge->windows) {
@@ -413,8 +413,7 @@ int dw_pcie_host_init(struct pcie_port *pp)
 						resource_size(pp->cfg));
 		if (!pci->dbi_base) {
 			dev_err(dev, "Error with ioremap\n");
-			ret = -ENOMEM;
-			goto error;
+			return -ENOMEM;
 		}
 	}
 
@@ -425,8 +424,7 @@ int dw_pcie_host_init(struct pcie_port *pp)
 					pp->cfg0_base, pp->cfg0_size);
 		if (!pp->va_cfg0_base) {
 			dev_err(dev, "Error with ioremap in function\n");
-			ret = -ENOMEM;
-			goto error;
+			return -ENOMEM;
 		}
 	}
 
@@ -436,8 +434,7 @@ int dw_pcie_host_init(struct pcie_port *pp)
 						pp->cfg1_size);
 		if (!pp->va_cfg1_base) {
 			dev_err(dev, "Error with ioremap\n");
-			ret = -ENOMEM;
-			goto error;
+			return -ENOMEM;
 		}
 	}
 
@@ -460,14 +457,14 @@ int dw_pcie_host_init(struct pcie_port *pp)
 			    pp->num_vectors == 0) {
 				dev_err(dev,
 					"Invalid number of vectors\n");
-				goto error;
+				return -EINVAL;
 			}
 		}
 
 		if (!pp->ops->msi_host_init) {
 			ret = dw_pcie_allocate_domains(pp);
 			if (ret)
-				goto error;
+				return ret;
 
 			if (pp->msi_irq)
 				irq_set_chained_handler_and_data(pp->msi_irq,
@@ -476,7 +473,7 @@ int dw_pcie_host_init(struct pcie_port *pp)
 		} else {
 			ret = pp->ops->msi_host_init(pp);
 			if (ret < 0)
-				goto error;
+				return ret;
 		}
 	}
 
@@ -516,8 +513,6 @@ int dw_pcie_host_init(struct pcie_port *pp)
 err_free_msi:
 	if (pci_msi_enabled() && !pp->ops->msi_host_init)
 		dw_pcie_free_msi(pp);
-error:
-	pci_free_host_bridge(bridge);
 	return ret;
 }
 
-- 
2.20.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH v4 5/5] PCI: dwc: Save root bus for driver remove
  2019-03-29 11:55 ` Jisheng Zhang
@ 2019-03-29 11:59   ` Jisheng Zhang
  -1 siblings, 0 replies; 17+ messages in thread
From: Jisheng Zhang @ 2019-03-29 11:59 UTC (permalink / raw)
  To: Jingoo Han, Gustavo Pimentel, Lorenzo Pieralisi, Bjorn Helgaas
  Cc: linux-pci, linux-kernel, linux-arm-kernel, Robin Murphy

Currently dwc host doesn't support the remove, but nothing prevent us
from supporting it. Save the root bus for clean up work in driver
remove code path.

After this patch, the dwc host users could implement its remove as:

static int foo_pcie_remove(struct platform_device *pdev)
{
	...
	pci_stop_root_bus(pp->root_bus);
	pci_remove_root_bus(pp->root_bus);
	dw_pcie_free_msi(pp);
	...
}

Signed-off-by: Jisheng Zhang <Jisheng.Zhang@synaptics.com>
Acked-by: Gustavo Pimentel <gustavo.pimentel@synopsys.com>
---
 drivers/pci/controller/dwc/pcie-designware-host.c | 12 ++++++------
 drivers/pci/controller/dwc/pcie-designware.h      |  1 +
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/drivers/pci/controller/dwc/pcie-designware-host.c b/drivers/pci/controller/dwc/pcie-designware-host.c
index dcc7405aff9a..3e4169e738a5 100644
--- a/drivers/pci/controller/dwc/pcie-designware-host.c
+++ b/drivers/pci/controller/dwc/pcie-designware-host.c
@@ -341,7 +341,7 @@ int dw_pcie_host_init(struct pcie_port *pp)
 	struct device_node *np = dev->of_node;
 	struct platform_device *pdev = to_platform_device(dev);
 	struct resource_entry *win, *tmp;
-	struct pci_bus *bus, *child;
+	struct pci_bus *child;
 	struct pci_host_bridge *bridge;
 	struct resource *cfg_res;
 	int ret;
@@ -496,18 +496,18 @@ int dw_pcie_host_init(struct pcie_port *pp)
 	if (ret)
 		goto err_free_msi;
 
-	bus = bridge->bus;
+	pp->root_bus = bridge->bus;
 
 	if (pp->ops->scan_bus)
 		pp->ops->scan_bus(pp);
 
-	pci_bus_size_bridges(bus);
-	pci_bus_assign_resources(bus);
+	pci_bus_size_bridges(pp->root_bus);
+	pci_bus_assign_resources(pp->root_bus);
 
-	list_for_each_entry(child, &bus->children, node)
+	list_for_each_entry(child, &pp->root_bus->children, node)
 		pcie_bus_configure_settings(child);
 
-	pci_bus_add_devices(bus);
+	pci_bus_add_devices(pp->root_bus);
 	return 0;
 
 err_free_msi:
diff --git a/drivers/pci/controller/dwc/pcie-designware.h b/drivers/pci/controller/dwc/pcie-designware.h
index 6fb0a1879932..adff0c713665 100644
--- a/drivers/pci/controller/dwc/pcie-designware.h
+++ b/drivers/pci/controller/dwc/pcie-designware.h
@@ -182,6 +182,7 @@ struct pcie_port {
 	struct page		*msi_page;
 	u32			num_vectors;
 	u32			irq_mask[MAX_MSI_CTRLS];
+	struct pci_bus		*root_bus;
 	raw_spinlock_t		lock;
 	DECLARE_BITMAP(msi_irq_in_use, MAX_MSI_IRQS);
 };
-- 
2.20.1


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

* [PATCH v4 5/5] PCI: dwc: Save root bus for driver remove
@ 2019-03-29 11:59   ` Jisheng Zhang
  0 siblings, 0 replies; 17+ messages in thread
From: Jisheng Zhang @ 2019-03-29 11:59 UTC (permalink / raw)
  To: Jingoo Han, Gustavo Pimentel, Lorenzo Pieralisi, Bjorn Helgaas
  Cc: linux-pci, Robin Murphy, linux-kernel, linux-arm-kernel

Currently dwc host doesn't support the remove, but nothing prevent us
from supporting it. Save the root bus for clean up work in driver
remove code path.

After this patch, the dwc host users could implement its remove as:

static int foo_pcie_remove(struct platform_device *pdev)
{
	...
	pci_stop_root_bus(pp->root_bus);
	pci_remove_root_bus(pp->root_bus);
	dw_pcie_free_msi(pp);
	...
}

Signed-off-by: Jisheng Zhang <Jisheng.Zhang@synaptics.com>
Acked-by: Gustavo Pimentel <gustavo.pimentel@synopsys.com>
---
 drivers/pci/controller/dwc/pcie-designware-host.c | 12 ++++++------
 drivers/pci/controller/dwc/pcie-designware.h      |  1 +
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/drivers/pci/controller/dwc/pcie-designware-host.c b/drivers/pci/controller/dwc/pcie-designware-host.c
index dcc7405aff9a..3e4169e738a5 100644
--- a/drivers/pci/controller/dwc/pcie-designware-host.c
+++ b/drivers/pci/controller/dwc/pcie-designware-host.c
@@ -341,7 +341,7 @@ int dw_pcie_host_init(struct pcie_port *pp)
 	struct device_node *np = dev->of_node;
 	struct platform_device *pdev = to_platform_device(dev);
 	struct resource_entry *win, *tmp;
-	struct pci_bus *bus, *child;
+	struct pci_bus *child;
 	struct pci_host_bridge *bridge;
 	struct resource *cfg_res;
 	int ret;
@@ -496,18 +496,18 @@ int dw_pcie_host_init(struct pcie_port *pp)
 	if (ret)
 		goto err_free_msi;
 
-	bus = bridge->bus;
+	pp->root_bus = bridge->bus;
 
 	if (pp->ops->scan_bus)
 		pp->ops->scan_bus(pp);
 
-	pci_bus_size_bridges(bus);
-	pci_bus_assign_resources(bus);
+	pci_bus_size_bridges(pp->root_bus);
+	pci_bus_assign_resources(pp->root_bus);
 
-	list_for_each_entry(child, &bus->children, node)
+	list_for_each_entry(child, &pp->root_bus->children, node)
 		pcie_bus_configure_settings(child);
 
-	pci_bus_add_devices(bus);
+	pci_bus_add_devices(pp->root_bus);
 	return 0;
 
 err_free_msi:
diff --git a/drivers/pci/controller/dwc/pcie-designware.h b/drivers/pci/controller/dwc/pcie-designware.h
index 6fb0a1879932..adff0c713665 100644
--- a/drivers/pci/controller/dwc/pcie-designware.h
+++ b/drivers/pci/controller/dwc/pcie-designware.h
@@ -182,6 +182,7 @@ struct pcie_port {
 	struct page		*msi_page;
 	u32			num_vectors;
 	u32			irq_mask[MAX_MSI_CTRLS];
+	struct pci_bus		*root_bus;
 	raw_spinlock_t		lock;
 	DECLARE_BITMAP(msi_irq_in_use, MAX_MSI_IRQS);
 };
-- 
2.20.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH v4 0/5] PCI: dwc: Support remove
  2019-03-29 11:55 ` Jisheng Zhang
@ 2019-04-01 13:50   ` Lorenzo Pieralisi
  -1 siblings, 0 replies; 17+ messages in thread
From: Lorenzo Pieralisi @ 2019-04-01 13:50 UTC (permalink / raw)
  To: Jisheng Zhang
  Cc: Jingoo Han, Gustavo Pimentel, Bjorn Helgaas, linux-pci,
	linux-kernel, linux-arm-kernel, Robin Murphy

On Fri, Mar 29, 2019 at 11:55:36AM +0000, Jisheng Zhang wrote:
> Currently, the PCI dwc host users don't support the remove, but nothing
> prevent us from supporting it. To achieve this goal, we need to ensure
> we can do necessary clean up work.
> 
> Changes since v3:
>   - add Gustavo's ACK to patch2, patch5
>   - remove IS_ENABLED(CONFIG_PCI_MSI) check
> 
> Changes since v2:
>   - address all Gustavo's comments
>   - add Gustavo's ACK to patch1, patch3, patch4
> 
> Changes since v1:
>   - address Bjorn's comments, I.E Capitalize, s/irq/IRQ/, s/msi/MSI/
> 
> 
> Jisheng Zhang (5):
>   PCI: dwc: Fix dw_pcie_free_msi() if msi_irq is invalid
>   PCI: dwc: Free the page for MSI IRQ in dw_pcie_free_msi()
>   PCI: dwc: Free MSI in the error code path of dw_pcie_host_init()
>   PCI: dwc: Use devm_pci_alloc_host_bridge() to simplify the code
>   PCI: dwc: Save root bus for driver remove
> 
>  .../pci/controller/dwc/pcie-designware-host.c | 60 ++++++++++---------
>  drivers/pci/controller/dwc/pcie-designware.h  |  2 +
>  2 files changed, 34 insertions(+), 28 deletions(-)
 
Applied to pci/dwc for v5.2, thanks.

Lorenzo

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

* Re: [PATCH v4 0/5] PCI: dwc: Support remove
@ 2019-04-01 13:50   ` Lorenzo Pieralisi
  0 siblings, 0 replies; 17+ messages in thread
From: Lorenzo Pieralisi @ 2019-04-01 13:50 UTC (permalink / raw)
  To: Jisheng Zhang
  Cc: Jingoo Han, linux-kernel, linux-pci, Bjorn Helgaas,
	Gustavo Pimentel, Robin Murphy, linux-arm-kernel

On Fri, Mar 29, 2019 at 11:55:36AM +0000, Jisheng Zhang wrote:
> Currently, the PCI dwc host users don't support the remove, but nothing
> prevent us from supporting it. To achieve this goal, we need to ensure
> we can do necessary clean up work.
> 
> Changes since v3:
>   - add Gustavo's ACK to patch2, patch5
>   - remove IS_ENABLED(CONFIG_PCI_MSI) check
> 
> Changes since v2:
>   - address all Gustavo's comments
>   - add Gustavo's ACK to patch1, patch3, patch4
> 
> Changes since v1:
>   - address Bjorn's comments, I.E Capitalize, s/irq/IRQ/, s/msi/MSI/
> 
> 
> Jisheng Zhang (5):
>   PCI: dwc: Fix dw_pcie_free_msi() if msi_irq is invalid
>   PCI: dwc: Free the page for MSI IRQ in dw_pcie_free_msi()
>   PCI: dwc: Free MSI in the error code path of dw_pcie_host_init()
>   PCI: dwc: Use devm_pci_alloc_host_bridge() to simplify the code
>   PCI: dwc: Save root bus for driver remove
> 
>  .../pci/controller/dwc/pcie-designware-host.c | 60 ++++++++++---------
>  drivers/pci/controller/dwc/pcie-designware.h  |  2 +
>  2 files changed, 34 insertions(+), 28 deletions(-)
 
Applied to pci/dwc for v5.2, thanks.

Lorenzo

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH v4 0/5] PCI: dwc: Support remove
  2019-04-01 13:50   ` Lorenzo Pieralisi
@ 2019-04-03 13:36     ` Vidya Sagar
  -1 siblings, 0 replies; 17+ messages in thread
From: Vidya Sagar @ 2019-04-03 13:36 UTC (permalink / raw)
  To: Lorenzo Pieralisi, Jisheng Zhang
  Cc: Jingoo Han, Gustavo Pimentel, Bjorn Helgaas, linux-pci,
	linux-kernel, linux-arm-kernel, Robin Murphy

Verified it with Tegra194 PCIe host controller driver, but had to do
EXPORT_SYMBOL_GPL() for a bunch of APIs.
I'll push changes to export all those APIs as part of Tegra194 PCIe driver patch series.

Thanks
Vidya Sagar

On 4/1/2019 7:20 PM, Lorenzo Pieralisi wrote:
> On Fri, Mar 29, 2019 at 11:55:36AM +0000, Jisheng Zhang wrote:
>> Currently, the PCI dwc host users don't support the remove, but nothing
>> prevent us from supporting it. To achieve this goal, we need to ensure
>> we can do necessary clean up work.
>>
>> Changes since v3:
>>    - add Gustavo's ACK to patch2, patch5
>>    - remove IS_ENABLED(CONFIG_PCI_MSI) check
>>
>> Changes since v2:
>>    - address all Gustavo's comments
>>    - add Gustavo's ACK to patch1, patch3, patch4
>>
>> Changes since v1:
>>    - address Bjorn's comments, I.E Capitalize, s/irq/IRQ/, s/msi/MSI/
>>
>>
>> Jisheng Zhang (5):
>>    PCI: dwc: Fix dw_pcie_free_msi() if msi_irq is invalid
>>    PCI: dwc: Free the page for MSI IRQ in dw_pcie_free_msi()
>>    PCI: dwc: Free MSI in the error code path of dw_pcie_host_init()
>>    PCI: dwc: Use devm_pci_alloc_host_bridge() to simplify the code
>>    PCI: dwc: Save root bus for driver remove
>>
>>   .../pci/controller/dwc/pcie-designware-host.c | 60 ++++++++++---------
>>   drivers/pci/controller/dwc/pcie-designware.h  |  2 +
>>   2 files changed, 34 insertions(+), 28 deletions(-)
>   
> Applied to pci/dwc for v5.2, thanks.
> 
> Lorenzo
> 


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

* Re: [PATCH v4 0/5] PCI: dwc: Support remove
@ 2019-04-03 13:36     ` Vidya Sagar
  0 siblings, 0 replies; 17+ messages in thread
From: Vidya Sagar @ 2019-04-03 13:36 UTC (permalink / raw)
  To: Lorenzo Pieralisi, Jisheng Zhang
  Cc: Jingoo Han, linux-kernel, linux-pci, Bjorn Helgaas,
	Gustavo Pimentel, Robin Murphy, linux-arm-kernel

Verified it with Tegra194 PCIe host controller driver, but had to do
EXPORT_SYMBOL_GPL() for a bunch of APIs.
I'll push changes to export all those APIs as part of Tegra194 PCIe driver patch series.

Thanks
Vidya Sagar

On 4/1/2019 7:20 PM, Lorenzo Pieralisi wrote:
> On Fri, Mar 29, 2019 at 11:55:36AM +0000, Jisheng Zhang wrote:
>> Currently, the PCI dwc host users don't support the remove, but nothing
>> prevent us from supporting it. To achieve this goal, we need to ensure
>> we can do necessary clean up work.
>>
>> Changes since v3:
>>    - add Gustavo's ACK to patch2, patch5
>>    - remove IS_ENABLED(CONFIG_PCI_MSI) check
>>
>> Changes since v2:
>>    - address all Gustavo's comments
>>    - add Gustavo's ACK to patch1, patch3, patch4
>>
>> Changes since v1:
>>    - address Bjorn's comments, I.E Capitalize, s/irq/IRQ/, s/msi/MSI/
>>
>>
>> Jisheng Zhang (5):
>>    PCI: dwc: Fix dw_pcie_free_msi() if msi_irq is invalid
>>    PCI: dwc: Free the page for MSI IRQ in dw_pcie_free_msi()
>>    PCI: dwc: Free MSI in the error code path of dw_pcie_host_init()
>>    PCI: dwc: Use devm_pci_alloc_host_bridge() to simplify the code
>>    PCI: dwc: Save root bus for driver remove
>>
>>   .../pci/controller/dwc/pcie-designware-host.c | 60 ++++++++++---------
>>   drivers/pci/controller/dwc/pcie-designware.h  |  2 +
>>   2 files changed, 34 insertions(+), 28 deletions(-)
>   
> Applied to pci/dwc for v5.2, thanks.
> 
> Lorenzo
> 


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH v4 1/5] PCI: dwc: Fix dw_pcie_free_msi() if msi_irq is invalid
@ 2019-03-29 11:56   ` Jisheng Zhang
  0 siblings, 0 replies; 17+ messages in thread
From: Vidya Sagar @ 2019-04-04 12:20 UTC (permalink / raw)
  To: jingoohan1, gustavo.pimentel, lorenzo.pieralisi, bhelgaas,
	Jisheng.Zhang, thierry.reding
  Cc: mmaddireddy, kthota, linux-pci, linux-kernel, vidyas,
	Robin Murphy, linux-arm-kernel, sagar.tv

From: Jisheng Zhang <Jisheng.Zhang@synaptics.com>

We should check msi_irq before calling irq_set_chained_handler() and
irq_set_handler_data().

Signed-off-by: Jisheng Zhang <Jisheng.Zhang@synaptics.com>
Acked-by: Gustavo Pimentel <gustavo.pimentel@synopsys.com>
---
 drivers/pci/controller/dwc/pcie-designware-host.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/pci/controller/dwc/pcie-designware-host.c b/drivers/pci/controller/dwc/pcie-designware-host.c
index 25087d3c9a82..1040939f45b4 100644
--- a/drivers/pci/controller/dwc/pcie-designware-host.c
+++ b/drivers/pci/controller/dwc/pcie-designware-host.c
@@ -298,8 +298,10 @@ int dw_pcie_allocate_domains(struct pcie_port *pp)
 
 void dw_pcie_free_msi(struct pcie_port *pp)
 {
-	irq_set_chained_handler(pp->msi_irq, NULL);
-	irq_set_handler_data(pp->msi_irq, NULL);
+	if (pp->msi_irq) {
+		irq_set_chained_handler(pp->msi_irq, NULL);
+		irq_set_handler_data(pp->msi_irq, NULL);
+	}
 
 	irq_domain_remove(pp->msi_domain);
 	irq_domain_remove(pp->irq_domain);

From patchwork Fri Mar 29 11:57:17 2019
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Jisheng Zhang <Jisheng.Zhang@synaptics.com>
X-Patchwork-Id: 10876925
Return-Path: <linux-pci-owner@kernel.org>
Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org
 [172.30.200.125])
	by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4708B922
	for <patchwork-linux-pci@patchwork.kernel.org>;
 Fri, 29 Mar 2019 11:57:22 +0000 (UTC)
Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1])
	by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 304DF2906E
	for <patchwork-linux-pci@patchwork.kernel.org>;
 Fri, 29 Mar 2019 11:57:22 +0000 (UTC)
Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486)
	id 1E71C29106; Fri, 29 Mar 2019 11:57:22 +0000 (UTC)
X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on
	pdx-wl-mail.web.codeaurora.org
X-Spam-Level: 
X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED,
	DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1
Received: from vger.kernel.org (vger.kernel.org [209.132.180.67])
	by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B25382906E
	for <patchwork-linux-pci@patchwork.kernel.org>;
 Fri, 29 Mar 2019 11:57:21 +0000 (UTC)
Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
        id S1729482AbfC2L5U (ORCPT
        <rfc822;patchwork-linux-pci@patchwork.kernel.org>);
        Fri, 29 Mar 2019 07:57:20 -0400
Received: from mail-eopbgr790079.outbound.protection.outlook.com
 ([40.107.79.79]:5884
        "EHLO NAM03-CO1-obe.outbound.protection.outlook.com"
        rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP
        id S1729469AbfC2L5U (ORCPT <rfc822;linux-pci@vger.kernel.org>);
        Fri, 29 Mar 2019 07:57:20 -0400
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=Synaptics.onmicrosoft.com; s=selector1-synaptics-com;
 h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;
 bh=bvDpzMGyizyHrjiB0dVAXTb1Ho3YNcs21pjZeXB9wjk=;
 b=lBsKfENCCVCTL2BIua7YOQQS/ax79sNf4m7D9Hl65okWDgza61cTyBKzGHiFdcmxEBBH74BAglUogwD184atBJZUlkyjDgaU8bd0gh/mA66DNB1EkKm/6z3cf4Ap80mxR7zg6UgNOhNnm+D+tajluAaVYSvADZlSCayS23ocN2I=
Received: from BYAPR03MB4773.namprd03.prod.outlook.com (20.179.92.152) by
 BYAPR03MB4677.namprd03.prod.outlook.com (20.179.91.94) with Microsoft SMTP
 Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id
 15.20.1730.18; Fri, 29 Mar 2019 11:57:17 +0000
Received: from BYAPR03MB4773.namprd03.prod.outlook.com
 ([fe80::1a8:1bc4:174b:472b]) by BYAPR03MB4773.namprd03.prod.outlook.com
 ([fe80::1a8:1bc4:174b:472b%2]) with mapi id 15.20.1750.017; Fri, 29 Mar 2019
 11:57:17 +0000
From: Jisheng Zhang <Jisheng.Zhang@synaptics.com>
To: Jingoo Han <jingoohan1@gmail.com>,
        Gustavo Pimentel <gustavo.pimentel@synopsys.com>,
        Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>,
        Bjorn Helgaas <bhelgaas@google.com>
CC: "linux-pci@vger.kernel.org" <linux-pci@vger.kernel.org>,
        "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
        "linux-arm-kernel@lists.infradead.org"
        <linux-arm-kernel@lists.infradead.org>,
        Robin Murphy <robin.murphy@arm.com>
Subject: [PATCH v4 2/5] PCI: dwc: Free the page for MSI IRQ in
 dw_pcie_free_msi()
Thread-Topic: [PATCH v4 2/5] PCI: dwc: Free the page for MSI IRQ in
 dw_pcie_free_msi()
Thread-Index: AQHU5iaOgs5m4jcCLEKOwYgOAI2HSQ==
Date: Fri, 29 Mar 2019 11:57:17 +0000
Message-ID: <20190329194934.6be48292@xhacker.debian>
References: <20190329194750.265f6df6@xhacker.debian>
In-Reply-To: <20190329194750.265f6df6@xhacker.debian>
Accept-Language: en-US
Content-Language: en-US
X-MS-Has-Attach: 
X-MS-TNEF-Correlator: 
x-originating-ip: [124.74.246.114]
x-clientproxiedby: TYAPR01CA0152.jpnprd01.prod.outlook.com
 (2603:1096:404:7e::20) To BYAPR03MB4773.namprd03.prod.outlook.com
 (2603:10b6:a03:134::24)
authentication-results: spf=none (sender IP is )
 smtp.mailfrom=Jisheng.Zhang@synaptics.com;
x-ms-exchange-messagesentrepresentingtype: 1
x-mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-pc-linux-gnu)
x-ms-publictraffictype: Email
x-ms-office365-filtering-correlation-id: d414ebf8-a007-4070-f133-08d6b43db0c4
x-microsoft-antispam: 
 BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(5600127)(711020)(4605104)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020);SRVR:BYAPR03MB4677;
x-ms-traffictypediagnostic: BYAPR03MB4677:
x-microsoft-antispam-prvs: 
 <BYAPR03MB467730024D65E12F378355E4ED5A0@BYAPR03MB4677.namprd03.prod.outlook.com>
x-forefront-prvs: 0991CAB7B3
x-forefront-antispam-report: 
 SFV:NSPM;SFS:(10009020)(136003)(366004)(39860400002)(396003)(346002)(376002)(189003)(199004)(110136005)(53936002)(54906003)(478600001)(97736004)(106356001)(446003)(316002)(105586002)(86362001)(102836004)(7736002)(476003)(9686003)(66066001)(305945005)(11346002)(256004)(71200400001)(3846002)(72206003)(71190400001)(8676002)(50226002)(6116002)(4326008)(25786009)(8936002)(2906002)(6512007)(14454004)(486006)(6436002)(1076003)(81166006)(81156014)(186003)(68736007)(52116002)(26005)(76176011)(99286004)(5660300002)(6506007)(6486002)(386003)(39210200001);DIR:OUT;SFP:1101;SCL:1;SRVR:BYAPR03MB4677;H:BYAPR03MB4773.namprd03.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:0;
received-spf: None (protection.outlook.com: synaptics.com does not designate
 permitted sender hosts)
x-ms-exchange-senderadcheck: 1
x-microsoft-antispam-message-info: 
 qL8/S+G7thLsFOHYWaWKJyCC+SE7awYRREe3BJSDxYzCJLvIvrHVVrLNqe4G1Uoe9nuX5ttDaYvvoqBTww7R4aatkoUNSKb1kAWoKRJ2zdS9y0ltRX77BE2bfm1NDrNlLuRmwBRrE4c3V4CQeFGDcTERNp/cimh00WGhS8K4wMWjl9Sc/x/Q+g7bEkCWuPRqd9NAfMJnvscDCIX2wFB3UkiZLHyke4FGzFUnt2rPH3SmSpZ+PWHrg9GW2M31vMCqnBTigtVmVH2/7PKvY76YoIyMg5QsmZP1PFHHHMaSwU7XonHkBAP8qdXKayID74l8RylON4Jteyzlt7u2rkocdxa4cSxGPR+oCSFCd+CbSHePwVKq7ieIQ6HA5AkYVfjk5Z3mn2pmeohVul/5GKWP/GvbFkrJUHZ6NWA4slnkwRM=
Content-Type: text/plain; charset="us-ascii"
Content-ID: <3D3C0C9B4EF25A44AD8A1CEF9428E6DF@namprd03.prod.outlook.com>
MIME-Version: 1.0
X-OriginatorOrg: synaptics.com
X-MS-Exchange-CrossTenant-Network-Message-Id: 
 d414ebf8-a007-4070-f133-08d6b43db0c4
X-MS-Exchange-CrossTenant-originalarrivaltime: 29 Mar 2019 11:57:17.4017
 (UTC)
X-MS-Exchange-CrossTenant-fromentityheader: Hosted
X-MS-Exchange-CrossTenant-id: 335d1fbc-2124-4173-9863-17e7051a2a0e
X-MS-Exchange-CrossTenant-mailboxtype: HOSTED
X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR03MB4677
Sender: linux-pci-owner@vger.kernel.org
Precedence: bulk
List-ID: <linux-pci.vger.kernel.org>
X-Mailing-List: linux-pci@vger.kernel.org
X-Virus-Scanned: ClamAV using ClamSMTP

To avoid memory leak, we need to free the page for MSI in
dw_pcie_free_msi().

Signed-off-by: Jisheng Zhang <Jisheng.Zhang@synaptics.com>
Acked-by: Gustavo Pimentel <gustavo.pimentel@synopsys.com>
---
 drivers/pci/controller/dwc/pcie-designware-host.c | 12 ++++++++----
 drivers/pci/controller/dwc/pcie-designware.h      |  1 +
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/drivers/pci/controller/dwc/pcie-designware-host.c b/drivers/pci/controller/dwc/pcie-designware-host.c
index 1040939f45b4..a71b874ae3c0 100644
--- a/drivers/pci/controller/dwc/pcie-designware-host.c
+++ b/drivers/pci/controller/dwc/pcie-designware-host.c
@@ -305,20 +305,24 @@ void dw_pcie_free_msi(struct pcie_port *pp)
 
 	irq_domain_remove(pp->msi_domain);
 	irq_domain_remove(pp->irq_domain);
+
+	if (pp->msi_page)
+		__free_page(pp->msi_page);
 }
 
 void dw_pcie_msi_init(struct pcie_port *pp)
 {
 	struct dw_pcie *pci = to_dw_pcie_from_pp(pp);
 	struct device *dev = pci->dev;
-	struct page *page;
 	u64 msi_target;
 
-	page = alloc_page(GFP_KERNEL);
-	pp->msi_data = dma_map_page(dev, page, 0, PAGE_SIZE, DMA_FROM_DEVICE);
+	pp->msi_page = alloc_page(GFP_KERNEL);
+	pp->msi_data = dma_map_page(dev, pp->msi_page, 0, PAGE_SIZE,
+				    DMA_FROM_DEVICE);
 	if (dma_mapping_error(dev, pp->msi_data)) {
 		dev_err(dev, "Failed to map MSI data\n");
-		__free_page(page);
+		__free_page(pp->msi_page);
+		pp->msi_page = NULL;
 		return;
 	}
 	msi_target = (u64)pp->msi_data;
diff --git a/drivers/pci/controller/dwc/pcie-designware.h b/drivers/pci/controller/dwc/pcie-designware.h
index 377f4c0b52da..6fb0a1879932 100644
--- a/drivers/pci/controller/dwc/pcie-designware.h
+++ b/drivers/pci/controller/dwc/pcie-designware.h
@@ -179,6 +179,7 @@ struct pcie_port {
 	struct irq_domain	*irq_domain;
 	struct irq_domain	*msi_domain;
 	dma_addr_t		msi_data;
+	struct page		*msi_page;
 	u32			num_vectors;
 	u32			irq_mask[MAX_MSI_CTRLS];
 	raw_spinlock_t		lock;

From patchwork Fri Mar 29 11:57:54 2019
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Jisheng Zhang <Jisheng.Zhang@synaptics.com>
X-Patchwork-Id: 10876929
Return-Path: <linux-pci-owner@kernel.org>
Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org
 [172.30.200.125])
	by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 49EF315AC
	for <patchwork-linux-pci@patchwork.kernel.org>;
 Fri, 29 Mar 2019 11:57:59 +0000 (UTC)
Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1])
	by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 36F462906E
	for <patchwork-linux-pci@patchwork.kernel.org>;
 Fri, 29 Mar 2019 11:57:59 +0000 (UTC)
Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486)
	id 2B53529110; Fri, 29 Mar 2019 11:57:59 +0000 (UTC)
X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on
	pdx-wl-mail.web.codeaurora.org
X-Spam-Level: 
X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED,
	DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1
Received: from vger.kernel.org (vger.kernel.org [209.132.180.67])
	by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B77512906E
	for <patchwork-linux-pci@patchwork.kernel.org>;
 Fri, 29 Mar 2019 11:57:58 +0000 (UTC)
Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
        id S1729468AbfC2L56 (ORCPT
        <rfc822;patchwork-linux-pci@patchwork.kernel.org>);
        Fri, 29 Mar 2019 07:57:58 -0400
Received: from mail-eopbgr790084.outbound.protection.outlook.com
 ([40.107.79.84]:23352
        "EHLO NAM03-CO1-obe.outbound.protection.outlook.com"
        rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP
        id S1729453AbfC2L56 (ORCPT <rfc822;linux-pci@vger.kernel.org>);
        Fri, 29 Mar 2019 07:57:58 -0400
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=Synaptics.onmicrosoft.com; s=selector1-synaptics-com;
 h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;
 bh=b37RT4uKXDdbkxNeUhAAhSpdbcyTyUQD7FOeyCs8KSw=;
 b=uqWpgKAfCHU3XjcU11CDcG7d9IZMHMS2Eh08QDv/bhdnPxoZt3ye5cUFYVsaYnMhi+CXBMAPhiysuLYqhK6+75NX5PyOrutztOuHRKxg9DpJUcnmE4IWC6H1YOmejtl3+giSOWyxibbZfhp3JnePexY6K+oxuNgnyB3UAfLmoUQ=
Received: from BYAPR03MB4773.namprd03.prod.outlook.com (20.179.92.152) by
 BYAPR03MB4677.namprd03.prod.outlook.com (20.179.91.94) with Microsoft SMTP
 Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id
 15.20.1730.18; Fri, 29 Mar 2019 11:57:54 +0000
Received: from BYAPR03MB4773.namprd03.prod.outlook.com
 ([fe80::1a8:1bc4:174b:472b]) by BYAPR03MB4773.namprd03.prod.outlook.com
 ([fe80::1a8:1bc4:174b:472b%2]) with mapi id 15.20.1750.017; Fri, 29 Mar 2019
 11:57:54 +0000
From: Jisheng Zhang <Jisheng.Zhang@synaptics.com>
To: Jingoo Han <jingoohan1@gmail.com>,
        Gustavo Pimentel <gustavo.pimentel@synopsys.com>,
        Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>,
        Bjorn Helgaas <bhelgaas@google.com>
CC: "linux-pci@vger.kernel.org" <linux-pci@vger.kernel.org>,
        "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
        "linux-arm-kernel@lists.infradead.org"
        <linux-arm-kernel@lists.infradead.org>,
        Robin Murphy <robin.murphy@arm.com>
Subject: [PATCH v4 3/5] PCI: dwc: Free MSI in the error code path of
 dw_pcie_host_init()
Thread-Topic: [PATCH v4 3/5] PCI: dwc: Free MSI in the error code path of
 dw_pcie_host_init()
Thread-Index: AQHU5iakPXqGrGU6TUeWd4NIoGI2eA==
Date: Fri, 29 Mar 2019 11:57:54 +0000
Message-ID: <20190329195014.54e54c45@xhacker.debian>
References: <20190329194750.265f6df6@xhacker.debian>
In-Reply-To: <20190329194750.265f6df6@xhacker.debian>
Accept-Language: en-US
Content-Language: en-US
X-MS-Has-Attach: 
X-MS-TNEF-Correlator: 
x-originating-ip: [124.74.246.114]
x-clientproxiedby: TY2PR01CA0003.jpnprd01.prod.outlook.com
 (2603:1096:404:a::15) To BYAPR03MB4773.namprd03.prod.outlook.com
 (2603:10b6:a03:134::24)
authentication-results: spf=none (sender IP is )
 smtp.mailfrom=Jisheng.Zhang@synaptics.com;
x-ms-exchange-messagesentrepresentingtype: 1
x-mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-pc-linux-gnu)
x-ms-publictraffictype: Email
x-ms-office365-filtering-correlation-id: 60148251-00ad-4915-5425-08d6b43dc6f6
x-microsoft-antispam: 
 BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(5600127)(711020)(4605104)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020);SRVR:BYAPR03MB4677;
x-ms-traffictypediagnostic: BYAPR03MB4677:
x-microsoft-antispam-prvs: 
 <BYAPR03MB4677883E06035160ADBC7987ED5A0@BYAPR03MB4677.namprd03.prod.outlook.com>
x-forefront-prvs: 0991CAB7B3
x-forefront-antispam-report: 
 SFV:NSPM;SFS:(10009020)(136003)(366004)(39860400002)(396003)(346002)(376002)(189003)(199004)(110136005)(53936002)(54906003)(478600001)(97736004)(106356001)(446003)(316002)(105586002)(86362001)(102836004)(7736002)(476003)(9686003)(66066001)(305945005)(11346002)(256004)(71200400001)(3846002)(72206003)(71190400001)(8676002)(50226002)(6116002)(4326008)(25786009)(8936002)(2906002)(6512007)(14454004)(486006)(6436002)(1076003)(81166006)(81156014)(186003)(68736007)(52116002)(26005)(76176011)(99286004)(5660300002)(6506007)(6486002)(386003)(39210200001);DIR:OUT;SFP:1101;SCL:1;SRVR:BYAPR03MB4677;H:BYAPR03MB4773.namprd03.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:0;
received-spf: None (protection.outlook.com: synaptics.com does not designate
 permitted sender hosts)
x-ms-exchange-senderadcheck: 1
x-microsoft-antispam-message-info: 
 XpEU/8iu7x6u9BEOAQxuLy0ANXGqqMmF2KGS/9hlc/aiWj8JCRi3adUUiwxgU9AiOwEJObwsTZxXowHOyTZWCLOASbVvi9A8u3uv2zW1qxI2Xacc+za5DgOk0RCcGSXtR2P40UDg18LhJAAyEWTUtgADTymTRUOkdgE1rnNjiN7YKquePSthJ2qZ7MbLcSgUo2Pjwr4PXPgBFZxYhZfgcaNUfek9f8/D4YJKa/Bg64KbEspxTpOLWebJlUoGNBlGUS1nJDFIOuoDW1iSIgChtnrVEk+76qo5MsHSSdenmgfFvRuIzpe3k4Jicx3GAlqmiMNoeKnmFa4Bna7eFzJ/0gNB8Ckw1/8Hun9AxPbvMOK2oYEmxp+D3DO9Fptj08JUqmb4OrQjw2EijJlwYmF2/l4xN/dfYLam4ZNsFBXBZoA=
Content-Type: text/plain; charset="us-ascii"
Content-ID: <5CF048EA27826E449B67FB5B91E2B4A7@namprd03.prod.outlook.com>
MIME-Version: 1.0
X-OriginatorOrg: synaptics.com
X-MS-Exchange-CrossTenant-Network-Message-Id: 
 60148251-00ad-4915-5425-08d6b43dc6f6
X-MS-Exchange-CrossTenant-originalarrivaltime: 29 Mar 2019 11:57:54.6703
 (UTC)
X-MS-Exchange-CrossTenant-fromentityheader: Hosted
X-MS-Exchange-CrossTenant-id: 335d1fbc-2124-4173-9863-17e7051a2a0e
X-MS-Exchange-CrossTenant-mailboxtype: HOSTED
X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR03MB4677
Sender: linux-pci-owner@vger.kernel.org
Precedence: bulk
List-ID: <linux-pci.vger.kernel.org>
X-Mailing-List: linux-pci@vger.kernel.org
X-Virus-Scanned: ClamAV using ClamSMTP

If we ever did some msi related initializations, we need to call
dw_pcie_free_msi() in the error code path.

We also remove the IS_ENABLED(CONFIG_PCI_MSI) check for MSI init,
because pci_msi_enabled() already has a stub for !CONFIG_PCI_MSI.

Signed-off-by: Jisheng Zhang <Jisheng.Zhang@synaptics.com>
Acked-by: Gustavo Pimentel <gustavo.pimentel@synopsys.com>
---
 drivers/pci/controller/dwc/pcie-designware-host.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/pci/controller/dwc/pcie-designware-host.c b/drivers/pci/controller/dwc/pcie-designware-host.c
index a71b874ae3c0..acc9be5cf34a 100644
--- a/drivers/pci/controller/dwc/pcie-designware-host.c
+++ b/drivers/pci/controller/dwc/pcie-designware-host.c
@@ -445,7 +445,7 @@ int dw_pcie_host_init(struct pcie_port *pp)
 	if (ret)
 		pci->num_viewport = 2;
 
-	if (IS_ENABLED(CONFIG_PCI_MSI) && pci_msi_enabled()) {
+	if (pci_msi_enabled()) {
 		/*
 		 * If a specific SoC driver needs to change the
 		 * default number of vectors, it needs to implement
@@ -483,7 +483,7 @@ int dw_pcie_host_init(struct pcie_port *pp)
 	if (pp->ops->host_init) {
 		ret = pp->ops->host_init(pp);
 		if (ret)
-			goto error;
+			goto err_free_msi;
 	}
 
 	pp->root_bus_nr = pp->busn->start;
@@ -497,7 +497,7 @@ int dw_pcie_host_init(struct pcie_port *pp)
 
 	ret = pci_scan_root_bus_bridge(bridge);
 	if (ret)
-		goto error;
+		goto err_free_msi;
 
 	bus = bridge->bus;
 
@@ -513,6 +513,9 @@ int dw_pcie_host_init(struct pcie_port *pp)
 	pci_bus_add_devices(bus);
 	return 0;
 
+err_free_msi:
+	if (pci_msi_enabled() && !pp->ops->msi_host_init)
+		dw_pcie_free_msi(pp);
 error:
 	pci_free_host_bridge(bridge);
 	return ret;

From patchwork Fri Mar 29 11:58:53 2019
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Jisheng Zhang <Jisheng.Zhang@synaptics.com>
X-Patchwork-Id: 10876933
Return-Path: <linux-pci-owner@kernel.org>
Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org
 [172.30.200.125])
	by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 490CA15AC
	for <patchwork-linux-pci@patchwork.kernel.org>;
 Fri, 29 Mar 2019 11:58:58 +0000 (UTC)
Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1])
	by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 373352906E
	for <patchwork-linux-pci@patchwork.kernel.org>;
 Fri, 29 Mar 2019 11:58:58 +0000 (UTC)
Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486)
	id 2B63829106; Fri, 29 Mar 2019 11:58:58 +0000 (UTC)
X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on
	pdx-wl-mail.web.codeaurora.org
X-Spam-Level: 
X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED,
	DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1
Received: from vger.kernel.org (vger.kernel.org [209.132.180.67])
	by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B07622906E
	for <patchwork-linux-pci@patchwork.kernel.org>;
 Fri, 29 Mar 2019 11:58:57 +0000 (UTC)
Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
        id S1729081AbfC2L64 (ORCPT
        <rfc822;patchwork-linux-pci@patchwork.kernel.org>);
        Fri, 29 Mar 2019 07:58:56 -0400
Received: from mail-eopbgr790058.outbound.protection.outlook.com
 ([40.107.79.58]:33702
        "EHLO NAM03-CO1-obe.outbound.protection.outlook.com"
        rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP
        id S1729406AbfC2L64 (ORCPT <rfc822;linux-pci@vger.kernel.org>);
        Fri, 29 Mar 2019 07:58:56 -0400
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=Synaptics.onmicrosoft.com; s=selector1-synaptics-com;
 h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;
 bh=7v47moEqUBbS6CG9iXSUFR2k+rZtFMLmVbAjCEzZ3P0=;
 b=XnNc5RhCrInW3ZMz6m4s9iYn7y5Ghraj+Wo6fwQ0AZPVkZYnJ4ALD8tJNkPQaiP9/cyTB4gEpDJ0SLfNmiK/7sQP6KrBRbGzV9VI/o010WdOYcgdPEr9BToDXxDkGhTmKIzEXbIzMtTfSeKnTj0p2g+mXjm1gshP1AgEH9fbH/Q=
Received: from BYAPR03MB4773.namprd03.prod.outlook.com (20.179.92.152) by
 BYAPR03MB4677.namprd03.prod.outlook.com (20.179.91.94) with Microsoft SMTP
 Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id
 15.20.1730.18; Fri, 29 Mar 2019 11:58:53 +0000
Received: from BYAPR03MB4773.namprd03.prod.outlook.com
 ([fe80::1a8:1bc4:174b:472b]) by BYAPR03MB4773.namprd03.prod.outlook.com
 ([fe80::1a8:1bc4:174b:472b%2]) with mapi id 15.20.1750.017; Fri, 29 Mar 2019
 11:58:53 +0000
From: Jisheng Zhang <Jisheng.Zhang@synaptics.com>
To: Jingoo Han <jingoohan1@gmail.com>,
        Gustavo Pimentel <gustavo.pimentel@synopsys.com>,
        Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>,
        Bjorn Helgaas <bhelgaas@google.com>
CC: "linux-pci@vger.kernel.org" <linux-pci@vger.kernel.org>,
        "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
        "linux-arm-kernel@lists.infradead.org"
        <linux-arm-kernel@lists.infradead.org>,
        Robin Murphy <robin.murphy@arm.com>
Subject: [PATCH v4 4/5] PCI: dwc: Use devm_pci_alloc_host_bridge() to simplify
 the code
Thread-Topic: [PATCH v4 4/5] PCI: dwc: Use devm_pci_alloc_host_bridge() to
 simplify the code
Thread-Index: AQHU5ibHIJJqTWvLzUuMnrUhdu3x1g==
Date: Fri, 29 Mar 2019 11:58:53 +0000
Message-ID: <20190329195112.11abef0d@xhacker.debian>
References: <20190329194750.265f6df6@xhacker.debian>
In-Reply-To: <20190329194750.265f6df6@xhacker.debian>
Accept-Language: en-US
Content-Language: en-US
X-MS-Has-Attach: 
X-MS-TNEF-Correlator: 
x-originating-ip: [124.74.246.114]
x-clientproxiedby: TY2PR01CA0033.jpnprd01.prod.outlook.com
 (2603:1096:404:ce::21) To BYAPR03MB4773.namprd03.prod.outlook.com
 (2603:10b6:a03:134::24)
authentication-results: spf=none (sender IP is )
 smtp.mailfrom=Jisheng.Zhang@synaptics.com;
x-ms-exchange-messagesentrepresentingtype: 1
x-mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-pc-linux-gnu)
x-ms-publictraffictype: Email
x-ms-office365-filtering-correlation-id: d9e84a40-cc01-4cab-9ab4-08d6b43de9e1
x-microsoft-antispam: 
 BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(5600127)(711020)(4605104)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020);SRVR:BYAPR03MB4677;
x-ms-traffictypediagnostic: BYAPR03MB4677:
x-microsoft-antispam-prvs: 
 <BYAPR03MB467749D8CB51266D69E4166CED5A0@BYAPR03MB4677.namprd03.prod.outlook.com>
x-forefront-prvs: 0991CAB7B3
x-forefront-antispam-report: 
 SFV:NSPM;SFS:(10009020)(136003)(366004)(39860400002)(396003)(346002)(376002)(189003)(199004)(110136005)(53936002)(54906003)(478600001)(97736004)(106356001)(446003)(316002)(105586002)(86362001)(102836004)(7736002)(476003)(9686003)(66066001)(305945005)(11346002)(256004)(14444005)(71200400001)(3846002)(72206003)(71190400001)(8676002)(50226002)(6116002)(4326008)(25786009)(8936002)(2906002)(6512007)(14454004)(486006)(6436002)(1076003)(81166006)(81156014)(186003)(68736007)(52116002)(26005)(76176011)(99286004)(5660300002)(6506007)(6486002)(386003)(39210200001);DIR:OUT;SFP:1101;SCL:1;SRVR:BYAPR03MB4677;H:BYAPR03MB4773.namprd03.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:0;
received-spf: None (protection.outlook.com: synaptics.com does not designate
 permitted sender hosts)
x-ms-exchange-senderadcheck: 1
x-microsoft-antispam-message-info: 
 BZ7niUt8SEoFU8W60tVSqmrLEmH2543h/NThyXb+kNf3Jxi6eITEZAfbuaDfYxrwng71sgpKPfeIIQ8Bl4B6rB8035kVGrxbdbNGF/nONKgFlpEDjfURlKrbJmjTYI7d4yK3Qgf1bE4hmOwv8zIZmOUQd71EvSQ0Cq7jpMk2bWwA6YRiNFsW//ToE3CbxvocEn7zzEZ6D2GVUAfc/pKS06qnFwutBjOCa17lXUJUxLoFyYs45KI0S7stl4RrEZqoBzMJwT1EWFi5O8sVt+XgUV9xMNpu4Q+WSq0DGckX7tTxIcYKU5c83nqSDnhmImxsOejH0uZYlsJAkv4fJUV9R2MB6e3U1s9f2CH7Fkc+SzLRuLzQ31ywZWfncFOb6Uk3ESu2J9EM+m853pFbuSKWy/XB+7TAuXgGyf5O8pJEZ2Q=
Content-Type: text/plain; charset="us-ascii"
Content-ID: <E2856F75F34FEC4E843E0D69B62D1068@namprd03.prod.outlook.com>
MIME-Version: 1.0
X-OriginatorOrg: synaptics.com
X-MS-Exchange-CrossTenant-Network-Message-Id: 
 d9e84a40-cc01-4cab-9ab4-08d6b43de9e1
X-MS-Exchange-CrossTenant-originalarrivaltime: 29 Mar 2019 11:58:53.1666
 (UTC)
X-MS-Exchange-CrossTenant-fromentityheader: Hosted
X-MS-Exchange-CrossTenant-id: 335d1fbc-2124-4173-9863-17e7051a2a0e
X-MS-Exchange-CrossTenant-mailboxtype: HOSTED
X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR03MB4677
Sender: linux-pci-owner@vger.kernel.org
Precedence: bulk
List-ID: <linux-pci.vger.kernel.org>
X-Mailing-List: linux-pci@vger.kernel.org
X-Virus-Scanned: ClamAV using ClamSMTP

Use devm_pci_alloc_host_bridge() to simplify the error code path.

Signed-off-by: Jisheng Zhang <Jisheng.Zhang@synaptics.com>
Acked-by: Gustavo Pimentel <gustavo.pimentel@synopsys.com>
---
 .../pci/controller/dwc/pcie-designware-host.c | 21 +++++++------------
 1 file changed, 8 insertions(+), 13 deletions(-)

diff --git a/drivers/pci/controller/dwc/pcie-designware-host.c b/drivers/pci/controller/dwc/pcie-designware-host.c
index acc9be5cf34a..dcc7405aff9a 100644
--- a/drivers/pci/controller/dwc/pcie-designware-host.c
+++ b/drivers/pci/controller/dwc/pcie-designware-host.c
@@ -358,7 +358,7 @@ int dw_pcie_host_init(struct pcie_port *pp)
 		dev_err(dev, "Missing *config* reg space\n");
 	}
 
-	bridge = pci_alloc_host_bridge(0);
+	bridge = devm_pci_alloc_host_bridge(dev, 0);
 	if (!bridge)
 		return -ENOMEM;
 
@@ -369,7 +369,7 @@ int dw_pcie_host_init(struct pcie_port *pp)
 
 	ret = devm_request_pci_bus_resources(dev, &bridge->windows);
 	if (ret)
-		goto error;
+		return ret;
 
 	/* Get the I/O and memory ranges from DT */
 	resource_list_for_each_entry_safe(win, tmp, &bridge->windows) {
@@ -413,8 +413,7 @@ int dw_pcie_host_init(struct pcie_port *pp)
 						resource_size(pp->cfg));
 		if (!pci->dbi_base) {
 			dev_err(dev, "Error with ioremap\n");
-			ret = -ENOMEM;
-			goto error;
+			return -ENOMEM;
 		}
 	}
 
@@ -425,8 +424,7 @@ int dw_pcie_host_init(struct pcie_port *pp)
 					pp->cfg0_base, pp->cfg0_size);
 		if (!pp->va_cfg0_base) {
 			dev_err(dev, "Error with ioremap in function\n");
-			ret = -ENOMEM;
-			goto error;
+			return -ENOMEM;
 		}
 	}
 
@@ -436,8 +434,7 @@ int dw_pcie_host_init(struct pcie_port *pp)
 						pp->cfg1_size);
 		if (!pp->va_cfg1_base) {
 			dev_err(dev, "Error with ioremap\n");
-			ret = -ENOMEM;
-			goto error;
+			return -ENOMEM;
 		}
 	}
 
@@ -460,14 +457,14 @@ int dw_pcie_host_init(struct pcie_port *pp)
 			    pp->num_vectors == 0) {
 				dev_err(dev,
 					"Invalid number of vectors\n");
-				goto error;
+				return -EINVAL;
 			}
 		}
 
 		if (!pp->ops->msi_host_init) {
 			ret = dw_pcie_allocate_domains(pp);
 			if (ret)
-				goto error;
+				return ret;
 
 			if (pp->msi_irq)
 				irq_set_chained_handler_and_data(pp->msi_irq,
@@ -476,7 +473,7 @@ int dw_pcie_host_init(struct pcie_port *pp)
 		} else {
 			ret = pp->ops->msi_host_init(pp);
 			if (ret < 0)
-				goto error;
+				return ret;
 		}
 	}
 
@@ -516,8 +513,6 @@ int dw_pcie_host_init(struct pcie_port *pp)
 err_free_msi:
 	if (pci_msi_enabled() && !pp->ops->msi_host_init)
 		dw_pcie_free_msi(pp);
-error:
-	pci_free_host_bridge(bridge);
 	return ret;
 }
 

From patchwork Fri Mar 29 11:59:26 2019
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Jisheng Zhang <Jisheng.Zhang@synaptics.com>
X-Patchwork-Id: 10876937
Return-Path: <linux-pci-owner@kernel.org>
Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org
 [172.30.200.125])
	by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B759F922
	for <patchwork-linux-pci@patchwork.kernel.org>;
 Fri, 29 Mar 2019 11:59:31 +0000 (UTC)
Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1])
	by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A040528711
	for <patchwork-linux-pci@patchwork.kernel.org>;
 Fri, 29 Mar 2019 11:59:31 +0000 (UTC)
Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486)
	id 90D6C2876D; Fri, 29 Mar 2019 11:59:31 +0000 (UTC)
X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on
	pdx-wl-mail.web.codeaurora.org
X-Spam-Level: 
X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED,
	DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1
Received: from vger.kernel.org (vger.kernel.org [209.132.180.67])
	by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2092128711
	for <patchwork-linux-pci@patchwork.kernel.org>;
 Fri, 29 Mar 2019 11:59:31 +0000 (UTC)
Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
        id S1729466AbfC2L7a (ORCPT
        <rfc822;patchwork-linux-pci@patchwork.kernel.org>);
        Fri, 29 Mar 2019 07:59:30 -0400
Received: from mail-eopbgr790082.outbound.protection.outlook.com
 ([40.107.79.82]:9959
        "EHLO NAM03-CO1-obe.outbound.protection.outlook.com"
        rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP
        id S1729463AbfC2L73 (ORCPT <rfc822;linux-pci@vger.kernel.org>);
        Fri, 29 Mar 2019 07:59:29 -0400
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=Synaptics.onmicrosoft.com; s=selector1-synaptics-com;
 h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;
 bh=2O3L1y6KM2Q6b0qVANwO0U4VBo4CWXvYKbt3CGrUo3E=;
 b=P8fQvyM7fmLqsDuCx/eTDizZquxrtknLoGA/dIKh+G+20V6lavAupqT8PwUoW0NZfbyfkfa/7lWfxtbVPDkSJ4cB0PxbU6QIz4R0wxKL8eXCixiktr3ISV46JR4DlQi4iB2sMuf7J54kxFlgEbsukUMivHTpfvVRPFZwmBWj/V8=
Received: from BYAPR03MB4773.namprd03.prod.outlook.com (20.179.92.152) by
 BYAPR03MB4677.namprd03.prod.outlook.com (20.179.91.94) with Microsoft SMTP
 Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id
 15.20.1730.18; Fri, 29 Mar 2019 11:59:26 +0000
Received: from BYAPR03MB4773.namprd03.prod.outlook.com
 ([fe80::1a8:1bc4:174b:472b]) by BYAPR03MB4773.namprd03.prod.outlook.com
 ([fe80::1a8:1bc4:174b:472b%2]) with mapi id 15.20.1750.017; Fri, 29 Mar 2019
 11:59:26 +0000
From: Jisheng Zhang <Jisheng.Zhang@synaptics.com>
To: Jingoo Han <jingoohan1@gmail.com>,
        Gustavo Pimentel <gustavo.pimentel@synopsys.com>,
        Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>,
        Bjorn Helgaas <bhelgaas@google.com>
CC: "linux-pci@vger.kernel.org" <linux-pci@vger.kernel.org>,
        "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
        "linux-arm-kernel@lists.infradead.org"
        <linux-arm-kernel@lists.infradead.org>,
        Robin Murphy <robin.murphy@arm.com>
Subject: [PATCH v4 5/5] PCI: dwc: Save root bus for driver remove
Thread-Topic: [PATCH v4 5/5] PCI: dwc: Save root bus for driver remove
Thread-Index: AQHU5ibbnD0hZoEW0kmtfkvI6C/+vA==
Date: Fri, 29 Mar 2019 11:59:26 +0000
Message-ID: <20190329195146.3b15dcac@xhacker.debian>
References: <20190329194750.265f6df6@xhacker.debian>
In-Reply-To: <20190329194750.265f6df6@xhacker.debian>
Accept-Language: en-US
Content-Language: en-US
X-MS-Has-Attach: 
X-MS-TNEF-Correlator: 
x-originating-ip: [124.74.246.114]
x-clientproxiedby: TYXPR01CA0047.jpnprd01.prod.outlook.com
 (2603:1096:403:a::17) To BYAPR03MB4773.namprd03.prod.outlook.com
 (2603:10b6:a03:134::24)
authentication-results: spf=none (sender IP is )
 smtp.mailfrom=Jisheng.Zhang@synaptics.com;
x-ms-exchange-messagesentrepresentingtype: 1
x-mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-pc-linux-gnu)
x-ms-publictraffictype: Email
x-ms-office365-filtering-correlation-id: cf96f3e6-aa27-430c-3406-08d6b43dfdb4
x-microsoft-antispam: 
 BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(5600127)(711020)(4605104)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020);SRVR:BYAPR03MB4677;
x-ms-traffictypediagnostic: BYAPR03MB4677:
x-microsoft-antispam-prvs: 
 <BYAPR03MB46779508F6F375457010D9FEED5A0@BYAPR03MB4677.namprd03.prod.outlook.com>
x-forefront-prvs: 0991CAB7B3
x-forefront-antispam-report: 
 SFV:NSPM;SFS:(10009020)(136003)(366004)(39860400002)(396003)(346002)(376002)(189003)(199004)(110136005)(53936002)(54906003)(478600001)(97736004)(106356001)(446003)(316002)(105586002)(86362001)(102836004)(7736002)(476003)(9686003)(66066001)(305945005)(11346002)(256004)(71200400001)(3846002)(72206003)(71190400001)(8676002)(50226002)(6116002)(4326008)(25786009)(8936002)(2906002)(6512007)(14454004)(486006)(6436002)(1076003)(81166006)(81156014)(186003)(68736007)(52116002)(26005)(76176011)(99286004)(5660300002)(6506007)(6486002)(386003)(39210200001);DIR:OUT;SFP:1101;SCL:1;SRVR:BYAPR03MB4677;H:BYAPR03MB4773.namprd03.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:0;
received-spf: None (protection.outlook.com: synaptics.com does not designate
 permitted sender hosts)
x-ms-exchange-senderadcheck: 1
x-microsoft-antispam-message-info: 
 KLYrOAccSPqrNfrLuFOq0SU49FcPJgz1IkfyTu18TBXBuSopBujyK1MTyZ+YvF6g7kraDgnfp6cAedVDsAWB3JRYPK+red3IZtLgodKtGIGm8pR63Uxx4k5bO6ghelncX446jV63fMNJ64lXTa1yVbmfkalzABSaAPLc2UjUMLHBA4lS4S3pKe8QMZ+ug00LNJZ4Qvq4+TmvGDtIZxKCdzGiy0caw65H+BoVuwMyVDdD/qKtQfXeDTUk9mrTI3iO0UKViyXd3EFPHkSvI2eAsxGS+n7sbEhCXGsl4S/l4zK4Le8h0ZaC++tHOxJcd54Bv/JX16TaoqrIX8Jm8ZPUVuOSzHXA1UE215R/bSHC3j8WnRaOAcCrEUFQfu6YVGZrOTZGYnHUOsNc7JTWnbkwuL5kVMwwUsfQVOF13g3RtgQ=
Content-Type: text/plain; charset="us-ascii"
Content-ID: <41385B38B83CC14EA7F859BE693DD822@namprd03.prod.outlook.com>
MIME-Version: 1.0
X-OriginatorOrg: synaptics.com
X-MS-Exchange-CrossTenant-Network-Message-Id: 
 cf96f3e6-aa27-430c-3406-08d6b43dfdb4
X-MS-Exchange-CrossTenant-originalarrivaltime: 29 Mar 2019 11:59:26.4315
 (UTC)
X-MS-Exchange-CrossTenant-fromentityheader: Hosted
X-MS-Exchange-CrossTenant-id: 335d1fbc-2124-4173-9863-17e7051a2a0e
X-MS-Exchange-CrossTenant-mailboxtype: HOSTED
X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR03MB4677
Sender: linux-pci-owner@vger.kernel.org
Precedence: bulk
List-ID: <linux-pci.vger.kernel.org>
X-Mailing-List: linux-pci@vger.kernel.org
X-Virus-Scanned: ClamAV using ClamSMTP

Currently dwc host doesn't support the remove, but nothing prevent us
from supporting it. Save the root bus for clean up work in driver
remove code path.

After this patch, the dwc host users could implement its remove as:

static int foo_pcie_remove(struct platform_device *pdev)
{
	...
	pci_stop_root_bus(pp->root_bus);
	pci_remove_root_bus(pp->root_bus);
	dw_pcie_free_msi(pp);
	...
}

Signed-off-by: Jisheng Zhang <Jisheng.Zhang@synaptics.com>
Acked-by: Gustavo Pimentel <gustavo.pimentel@synopsys.com>
---
 drivers/pci/controller/dwc/pcie-designware-host.c | 12 ++++++------
 drivers/pci/controller/dwc/pcie-designware.h      |  1 +
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/drivers/pci/controller/dwc/pcie-designware-host.c b/drivers/pci/controller/dwc/pcie-designware-host.c
index dcc7405aff9a..3e4169e738a5 100644
--- a/drivers/pci/controller/dwc/pcie-designware-host.c
+++ b/drivers/pci/controller/dwc/pcie-designware-host.c
@@ -341,7 +341,7 @@ int dw_pcie_host_init(struct pcie_port *pp)
 	struct device_node *np = dev->of_node;
 	struct platform_device *pdev = to_platform_device(dev);
 	struct resource_entry *win, *tmp;
-	struct pci_bus *bus, *child;
+	struct pci_bus *child;
 	struct pci_host_bridge *bridge;
 	struct resource *cfg_res;
 	int ret;
@@ -496,18 +496,18 @@ int dw_pcie_host_init(struct pcie_port *pp)
 	if (ret)
 		goto err_free_msi;
 
-	bus = bridge->bus;
+	pp->root_bus = bridge->bus;
 
 	if (pp->ops->scan_bus)
 		pp->ops->scan_bus(pp);
 
-	pci_bus_size_bridges(bus);
-	pci_bus_assign_resources(bus);
+	pci_bus_size_bridges(pp->root_bus);
+	pci_bus_assign_resources(pp->root_bus);
 
-	list_for_each_entry(child, &bus->children, node)
+	list_for_each_entry(child, &pp->root_bus->children, node)
 		pcie_bus_configure_settings(child);
 
-	pci_bus_add_devices(bus);
+	pci_bus_add_devices(pp->root_bus);
 	return 0;
 
 err_free_msi:
diff --git a/drivers/pci/controller/dwc/pcie-designware.h b/drivers/pci/controller/dwc/pcie-designware.h
index 6fb0a1879932..adff0c713665 100644
--- a/drivers/pci/controller/dwc/pcie-designware.h
+++ b/drivers/pci/controller/dwc/pcie-designware.h
@@ -182,6 +182,7 @@ struct pcie_port {
 	struct page		*msi_page;
 	u32			num_vectors;
 	u32			irq_mask[MAX_MSI_CTRLS];
+	struct pci_bus		*root_bus;
 	raw_spinlock_t		lock;
 	DECLARE_BITMAP(msi_irq_in_use, MAX_MSI_IRQS);
 };

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

end of thread, other threads:[~2019-04-04 12:21 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-29 11:55 [PATCH v4 0/5] PCI: dwc: Support remove Jisheng Zhang
2019-03-29 11:55 ` Jisheng Zhang
2019-03-29 11:56 ` [PATCH v4 1/5] PCI: dwc: Fix dw_pcie_free_msi() if msi_irq is invalid Jisheng Zhang
2019-04-04 12:20   ` Vidya Sagar
2019-03-29 11:56   ` Jisheng Zhang
2019-03-29 11:57 ` [PATCH v4 2/5] PCI: dwc: Free the page for MSI IRQ in dw_pcie_free_msi() Jisheng Zhang
2019-03-29 11:57   ` Jisheng Zhang
2019-03-29 11:57 ` [PATCH v4 3/5] PCI: dwc: Free MSI in the error code path of dw_pcie_host_init() Jisheng Zhang
2019-03-29 11:57   ` Jisheng Zhang
2019-03-29 11:58 ` [PATCH v4 4/5] PCI: dwc: Use devm_pci_alloc_host_bridge() to simplify the code Jisheng Zhang
2019-03-29 11:58   ` Jisheng Zhang
2019-03-29 11:59 ` [PATCH v4 5/5] PCI: dwc: Save root bus for driver remove Jisheng Zhang
2019-03-29 11:59   ` Jisheng Zhang
2019-04-01 13:50 ` [PATCH v4 0/5] PCI: dwc: Support remove Lorenzo Pieralisi
2019-04-01 13:50   ` Lorenzo Pieralisi
2019-04-03 13:36   ` Vidya Sagar
2019-04-03 13:36     ` Vidya Sagar

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.