[openwrt/openwrt] bcm53xx: use upstream fix for PCI iproc driver regression
LEDE Commits
lede-commits at lists.infradead.org
Fri Jan 12 14:30:13 PST 2018
rmilecki pushed a commit to openwrt/openwrt.git, branch master:
https://git.lede-project.org/8cd3370cced499484d1b665b63ae6424e04bf379
commit 8cd3370cced499484d1b665b63ae6424e04bf379
Author: Rafał Miłecki <rafal at milecki.pl>
AuthorDate: Fri Jan 12 23:27:19 2018 +0100
bcm53xx: use upstream fix for PCI iproc driver regression
Signed-off-by: Rafał Miłecki <rafal at milecki.pl>
---
...roc-Fix-NULL-pointer-dereference-for-BCMA.patch | 80 ++++++++++++++++++++++
...982-PCI-iproc-Disable-DMA-mapping-support.patch | 29 --------
2 files changed, 80 insertions(+), 29 deletions(-)
diff --git a/target/linux/bcm53xx/patches-4.14/089-PCI-iproc-Fix-NULL-pointer-dereference-for-BCMA.patch b/target/linux/bcm53xx/patches-4.14/089-PCI-iproc-Fix-NULL-pointer-dereference-for-BCMA.patch
new file mode 100644
index 0000000..2cdefc2
--- /dev/null
+++ b/target/linux/bcm53xx/patches-4.14/089-PCI-iproc-Fix-NULL-pointer-dereference-for-BCMA.patch
@@ -0,0 +1,80 @@
+From 3b65ca50d24ce33cb92d88840e289135c92b40ed Mon Sep 17 00:00:00 2001
+From: Ray Jui <ray.jui at broadcom.com>
+Date: Thu, 11 Jan 2018 12:36:16 -0800
+Subject: [PATCH] PCI: iproc: Fix NULL pointer dereference for BCMA
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+With the inbound DMA mapping supported added, the iProc PCIe driver
+parses DT property "dma-ranges" through call to
+"of_pci_dma_range_parser_init()". In the case of BCMA, this results in a
+NULL pointer deference due to a missing of_node.
+
+Fix this by adding a guard in pcie-iproc-platform.c to only enable the
+inbound DMA mapping logic when DT property "dma-ranges" is present.
+
+Fixes: dd9d4e7498de3 ("PCI: iproc: Add inbound DMA mapping support")
+Reported-by: Rafał Miłecki <rafal at milecki.pl>
+Signed-off-by: Ray Jui <ray.jui at broadcom.com>
+[lorenzo.pieralisi at arm.com: updated commit log]
+Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi at arm.com>
+Tested-by: Rafał Miłecki <rafal at milecki.pl>
+cc: <stable at vger.kernel.org> # 4.10+
+---
+ drivers/pci/host/pcie-iproc-platform.c | 7 +++++++
+ drivers/pci/host/pcie-iproc.c | 8 +++++---
+ drivers/pci/host/pcie-iproc.h | 2 ++
+ 3 files changed, 14 insertions(+), 3 deletions(-)
+
+--- a/drivers/pci/host/pcie-iproc-platform.c
++++ b/drivers/pci/host/pcie-iproc-platform.c
+@@ -92,6 +92,13 @@ static int iproc_pcie_pltfm_probe(struct
+ pcie->need_ob_cfg = true;
+ }
+
++ /*
++ * DT nodes are not used by all platforms that use the iProc PCIe
++ * core driver. For platforms that require explict inbound mapping
++ * configuration, "dma-ranges" would have been present in DT
++ */
++ pcie->need_ib_cfg = of_property_read_bool(np, "dma-ranges");
++
+ /* PHY use is optional */
+ pcie->phy = devm_phy_get(dev, "pcie-phy");
+ if (IS_ERR(pcie->phy)) {
+--- a/drivers/pci/host/pcie-iproc.c
++++ b/drivers/pci/host/pcie-iproc.c
+@@ -1396,9 +1396,11 @@ int iproc_pcie_setup(struct iproc_pcie *
+ }
+ }
+
+- ret = iproc_pcie_map_dma_ranges(pcie);
+- if (ret && ret != -ENOENT)
+- goto err_power_off_phy;
++ if (pcie->need_ib_cfg) {
++ ret = iproc_pcie_map_dma_ranges(pcie);
++ if (ret && ret != -ENOENT)
++ goto err_power_off_phy;
++ }
+
+ #ifdef CONFIG_ARM
+ pcie->sysdata.private_data = pcie;
+--- a/drivers/pci/host/pcie-iproc.h
++++ b/drivers/pci/host/pcie-iproc.h
+@@ -74,6 +74,7 @@ struct iproc_msi;
+ * @ob: outbound mapping related parameters
+ * @ob_map: outbound mapping related parameters specific to the controller
+ *
++ * @need_ib_cfg: indicates SW needs to configure the inbound mapping window
+ * @ib: inbound mapping related parameters
+ * @ib_map: outbound mapping region related parameters
+ *
+@@ -101,6 +102,7 @@ struct iproc_pcie {
+ struct iproc_pcie_ob ob;
+ const struct iproc_pcie_ob_map *ob_map;
+
++ bool need_ib_cfg;
+ struct iproc_pcie_ib ib;
+ const struct iproc_pcie_ib_map *ib_map;
+
diff --git a/target/linux/bcm53xx/patches-4.14/982-PCI-iproc-Disable-DMA-mapping-support.patch b/target/linux/bcm53xx/patches-4.14/982-PCI-iproc-Disable-DMA-mapping-support.patch
deleted file mode 100644
index 8196afb..0000000
--- a/target/linux/bcm53xx/patches-4.14/982-PCI-iproc-Disable-DMA-mapping-support.patch
+++ /dev/null
@@ -1,29 +0,0 @@
-From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal at milecki.pl>
-Date: Fri, 29 Dec 2017 22:39:45 +0100
-Subject: [PATCH] PCI: iproc: Disable DMA mapping support
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-This has been added in commit dd9d4e7498de3 ("PCI: iproc: Add inbound
-DMA mapping support") which causes a crash for bcma case. Function
-pci_dma_range_parser_init calls of_n_addr_cells with a NULL argument
-which causes a NULL pointer dereference.
-
-Signed-off-by: Rafał Miłecki <rafal at milecki.pl>
----
-
---- a/drivers/pci/host/pcie-iproc.c
-+++ b/drivers/pci/host/pcie-iproc.c
-@@ -1396,9 +1396,11 @@ int iproc_pcie_setup(struct iproc_pcie *
- }
- }
-
-+if (0) {
- ret = iproc_pcie_map_dma_ranges(pcie);
- if (ret && ret != -ENOENT)
- goto err_power_off_phy;
-+}
-
- #ifdef CONFIG_ARM
- pcie->sysdata.private_data = pcie;
More information about the lede-commits
mailing list