Skip to contentSkip to conversation

PCI: dwc: fix crash seen due to missing ops

PATCH In review Niklas Cassel 4 participants 9 messages Mar 21, 2017 – Apr 4, 2017 1 message not in the archive PCI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 PCI: dwc: fix crash seen due to missing ops

From: Niklas Cassel <[email protected]>

Fix the following crash, seen in dwc/pcie-artpec6.

  Unable to handle kernel NULL pointer dereference at virtual address 00000004
  pgd = c0204000
  [00000004] *pgd=00000000
  Internal error: Oops: 5 [#1] SMP ARM
  Modules linked in:
  CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.11.0-rc3-next-20170321 #1
  Hardware name: Axis ARTPEC-6 Platform
  task: db098000 task.stack: db096000
  PC is at dw_pcie_writel_dbi+0x2c/0xd0
  ...

While at it, fix the same problem for pcie-designware-plat.

Fixes 442ec4c04d12 ("PCI: dwc: all: Split struct pcie_port into host-only and core structures")
---
 drivers/pci/dwc/pcie-artpec6.c         | 4 ++++
 drivers/pci/dwc/pcie-designware-plat.c | 4 ++++
 2 files changed, 8 insertions(+)
drivers/pci/dwc/pcie-artpec6.c +4 -0
index fcd3ef845883..6d23683c0892 100644
@@ -234,6 +234,9 @@ static int artpec6_add_pcie_port(struct artpec6_pcie *artpec6_pcie,
 	return 0;
 }
 
+static const struct dw_pcie_ops dw_pcie_ops = {
+};
+
 static int artpec6_pcie_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
@@ -252,6 +255,7 @@ static int artpec6_pcie_probe(struct platform_device *pdev)
 		return -ENOMEM;
 
 	pci->dev = dev;
+	pci->ops = &dw_pcie_ops;
 
 	artpec6_pcie->pci = pci;
 
drivers/pci/dwc/pcie-designware-plat.c +4 -0
index b6c832ba39dd..f20d494922ab 100644
@@ -86,6 +86,9 @@ static int dw_plat_add_pcie_port(struct pcie_port *pp,
 	return 0;
 }
 
+static const struct dw_pcie_ops dw_pcie_ops = {
+};
+
 static int dw_plat_pcie_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
@@ -103,6 +106,7 @@ static int dw_plat_pcie_probe(struct platform_device *pdev)
 		return -ENOMEM;
 
 	pci->dev = dev;
+	pci->ops = &dw_pcie_ops;
 
 	dw_plat_pcie->pci = pci;
 
Signature · 1 line
2.11.0
#1 lore raw

Hi Niklas,

Às 2:43 PM de 3/21/2017, Niklas Cassel escreveu:

Quoted 62 lines

From: Niklas Cassel <[email protected]>

Fix the following crash, seen in dwc/pcie-artpec6.

  Unable to handle kernel NULL pointer dereference at virtual address 00000004
  pgd = c0204000
  [00000004] *pgd=00000000
  Internal error: Oops: 5 [#1] SMP ARM
  Modules linked in:
  CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.11.0-rc3-next-20170321 #1
  Hardware name: Axis ARTPEC-6 Platform
  task: db098000 task.stack: db096000
  PC is at dw_pcie_writel_dbi+0x2c/0xd0
  ...

While at it, fix the same problem for pcie-designware-plat.

Fixes 442ec4c04d12 ("PCI: dwc: all: Split struct pcie_port into host-only and core structures")
---
 drivers/pci/dwc/pcie-artpec6.c         | 4 ++++
 drivers/pci/dwc/pcie-designware-plat.c | 4 ++++
 2 files changed, 8 insertions(+)
drivers/pci/dwc/pcie-artpec6.c +4 -0
index fcd3ef845883..6d23683c0892 100644
@@ -234,6 +234,9 @@ static int artpec6_add_pcie_port(struct artpec6_pcie *artpec6_pcie,
 	return 0;
 }
 
+static const struct dw_pcie_ops dw_pcie_ops = {
+};
+
 static int artpec6_pcie_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
@@ -252,6 +255,7 @@ static int artpec6_pcie_probe(struct platform_device *pdev)
 		return -ENOMEM;
 
 	pci->dev = dev;
+	pci->ops = &dw_pcie_ops;
 
 	artpec6_pcie->pci = pci;
 
drivers/pci/dwc/pcie-designware-plat.c +3 -0
index b6c832ba39dd..f20d494922ab 100644
@@ -86,6 +86,9 @@ static int dw_plat_add_pcie_port(struct pcie_port *pp,
 	return 0;
 }
 
+static const struct dw_pcie_ops dw_pcie_ops = {
+};
+
 static int dw_plat_pcie_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;

drivers/pci/dwc/pcie-designware-plat.c static int dw_plat_pcie_probe(struct platform_device *pdev) · line 112

Quoted 7 lines
drivers/pci/dwc/pcie-designware-plat.c +1 -0
@@ -103,6 +106,7 @@ static int dw_plat_pcie_probe(struct platform_device *pdev)
 		return -ENOMEM;
 
 	pci->dev = dev;
+	pci->ops = &dw_pcie_ops;
 
 	dw_plat_pcie->pci = pci;
 

In the case of pcie-designware-plat you have the declaration of pci->ops:
https://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci.git/tree/drivers/pci/dwc/pcie-designware-plat.c#n78

and in artpec6 in here:
https://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci.git/tree/drivers/pci/dwc/pcie-artpec6.c#n226

Both declarations are made previously of calling dw_pcie_host_init(), so why do you need this dummy ops in the probe function? I never had that necessity.

Thanks,
Joao

Thanks,

#2 lore raw
Quoted 75 lines · Joao Pinto

Hi Niklas,

Às 2:43 PM de 3/21/2017, Niklas Cassel escreveu:

Quoted 62 lines

From: Niklas Cassel <[email protected]>

Fix the following crash, seen in dwc/pcie-artpec6.

  Unable to handle kernel NULL pointer dereference at virtual address 00000004
  pgd = c0204000
  [00000004] *pgd=00000000
  Internal error: Oops: 5 [#1] SMP ARM
  Modules linked in:
  CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.11.0-rc3-next-20170321 #1
  Hardware name: Axis ARTPEC-6 Platform
  task: db098000 task.stack: db096000
  PC is at dw_pcie_writel_dbi+0x2c/0xd0
  ...

While at it, fix the same problem for pcie-designware-plat.

Fixes 442ec4c04d12 ("PCI: dwc: all: Split struct pcie_port into host-only and core structures")
---
 drivers/pci/dwc/pcie-artpec6.c         | 4 ++++
 drivers/pci/dwc/pcie-designware-plat.c | 4 ++++
 2 files changed, 8 insertions(+)
drivers/pci/dwc/pcie-artpec6.c +4 -0
index fcd3ef845883..6d23683c0892 100644
@@ -234,6 +234,9 @@ static int artpec6_add_pcie_port(struct artpec6_pcie *artpec6_pcie,
 	return 0;
 }
 
+static const struct dw_pcie_ops dw_pcie_ops = {
+};
+
 static int artpec6_pcie_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
@@ -252,6 +255,7 @@ static int artpec6_pcie_probe(struct platform_device *pdev)
 		return -ENOMEM;
 
 	pci->dev = dev;
+	pci->ops = &dw_pcie_ops;
 
 	artpec6_pcie->pci = pci;
 
drivers/pci/dwc/pcie-designware-plat.c +3 -0
index b6c832ba39dd..f20d494922ab 100644
@@ -86,6 +86,9 @@ static int dw_plat_add_pcie_port(struct pcie_port *pp,
 	return 0;
 }
 
+static const struct dw_pcie_ops dw_pcie_ops = {
+};
+
 static int dw_plat_pcie_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;

drivers/pci/dwc/pcie-designware-plat.c static int dw_plat_pcie_probe(struct platform_device *pdev) · line 112

Quoted 7 lines
drivers/pci/dwc/pcie-designware-plat.c +1 -0
@@ -103,6 +106,7 @@ static int dw_plat_pcie_probe(struct platform_device *pdev)
 		return -ENOMEM;
 
 	pci->dev = dev;
+	pci->ops = &dw_pcie_ops;
 
 	dw_plat_pcie->pci = pci;
 

In the case of pcie-designware-plat you have the declaration of pci->ops:
https://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci.git/tree/drivers/pci/dwc/pcie-designware-plat.c#n78

Quoted 5 lines

and in artpec6 in here:
https://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci.git/tree/drivers/pci/dwc/pcie-artpec6.c#n226

Both declarations are made previously of calling dw_pcie_host_init(), so why do you need this dummy ops in the probe function? I never had that necessity.

Hello Joao

Since commit 442ec4c04d12, we now have two different ops, dw_pcie_ops (ops for dw_pcie) and dw_pcie_host_ops (ops for a pcie_port), note that they are different. The dw_pcie_ops is missing for pcie-artpec6 and pcie-designware-plat (since we are using the generic link-up function).

Before commit 442ec4c04d12, dw_pcie_writel_dbi had dw_pcie_host_ops as parameter, after the commit it has dw_pcie_ops as parameter. It should crash on pcie-designware-plat as well, since there are other functions, like dw_pcie_link_up, that assumes that pci->ops != null.

Another alternative to adding the dummy ops would be to add null checks for all uses off pci->ops in pcie-designware.c.
I don't like the idea to sprinkle null checks everywhere pci->ops is used.

One could add a null check in dw_pcie_host_init, but without a dummy ops we would still fail this check, so our drivers would still be non-functional in Linus's tree.

#3 lore raw

Hi,

Quoted 89 lines · Niklas Cassel
Quoted 75 lines · Joao Pinto

Hi Niklas,

Às 2:43 PM de 3/21/2017, Niklas Cassel escreveu:

Quoted 62 lines

From: Niklas Cassel <[email protected]>

Fix the following crash, seen in dwc/pcie-artpec6.

  Unable to handle kernel NULL pointer dereference at virtual address 00000004
  pgd = c0204000
  [00000004] *pgd=00000000
  Internal error: Oops: 5 [#1] SMP ARM
  Modules linked in:
  CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.11.0-rc3-next-20170321 #1
  Hardware name: Axis ARTPEC-6 Platform
  task: db098000 task.stack: db096000
  PC is at dw_pcie_writel_dbi+0x2c/0xd0
  ...

While at it, fix the same problem for pcie-designware-plat.

Fixes 442ec4c04d12 ("PCI: dwc: all: Split struct pcie_port into host-only and core structures")
---
 drivers/pci/dwc/pcie-artpec6.c         | 4 ++++
 drivers/pci/dwc/pcie-designware-plat.c | 4 ++++
 2 files changed, 8 insertions(+)
drivers/pci/dwc/pcie-artpec6.c +4 -0
index fcd3ef845883..6d23683c0892 100644
@@ -234,6 +234,9 @@ static int artpec6_add_pcie_port(struct artpec6_pcie *artpec6_pcie,
 	return 0;
 }
 
+static const struct dw_pcie_ops dw_pcie_ops = {
+};
+
 static int artpec6_pcie_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
@@ -252,6 +255,7 @@ static int artpec6_pcie_probe(struct platform_device *pdev)
 		return -ENOMEM;
 
 	pci->dev = dev;
+	pci->ops = &dw_pcie_ops;
 
 	artpec6_pcie->pci = pci;
 
drivers/pci/dwc/pcie-designware-plat.c +3 -0
index b6c832ba39dd..f20d494922ab 100644
@@ -86,6 +86,9 @@ static int dw_plat_add_pcie_port(struct pcie_port *pp,
 	return 0;
 }
 
+static const struct dw_pcie_ops dw_pcie_ops = {
+};
+
 static int dw_plat_pcie_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;

drivers/pci/dwc/pcie-designware-plat.c static int dw_plat_pcie_probe(struct platform_device *pdev) · line 112

Quoted 7 lines
drivers/pci/dwc/pcie-designware-plat.c +1 -0
@@ -103,6 +106,7 @@ static int dw_plat_pcie_probe(struct platform_device *pdev)
 		return -ENOMEM;
 
 	pci->dev = dev;
+	pci->ops = &dw_pcie_ops;
 
 	dw_plat_pcie->pci = pci;
 

In the case of pcie-designware-plat you have the declaration of pci->ops:
https://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci.git/tree/drivers/pci/dwc/pcie-designware-plat.c#n78

Quoted 5 lines

and in artpec6 in here:
https://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci.git/tree/drivers/pci/dwc/pcie-artpec6.c#n226

Both declarations are made previously of calling dw_pcie_host_init(), so why do you need this dummy ops in the probe function? I never had that necessity.

Hello Joao

Since commit 442ec4c04d12, we now have two different ops, dw_pcie_ops (ops for dw_pcie) and dw_pcie_host_ops (ops for a pcie_port), note that they are different. The dw_pcie_ops is missing for pcie-artpec6 and pcie-designware-plat (since we are using the generic link-up function).

Quoted 8 lines

Before commit 442ec4c04d12, dw_pcie_writel_dbi had dw_pcie_host_ops as parameter, after the commit it has dw_pcie_ops as parameter. It should crash on pcie-designware-plat as well, since there are other functions, like dw_pcie_link_up, that assumes that pci->ops != null.

Another alternative to adding the dummy ops would be to add null checks for all uses off pci->ops in pcie-designware.c.
I don't like the idea to sprinkle null checks everywhere pci->ops is used.

I'm okay either ways.

Quoted 5 lines

One could add a null check in dw_pcie_host_init, but without a dummy ops we would still fail this check, so our drivers would still be non-functional in Linus's tree.

#4 lore raw

Hello Bjorn

I think that it might be a good idea to include this for v4.11. PCIe for artpec-6 SoC works fine on v4.10, if we manage to include this before v4.11 gets released, PCIe for artpec-6 SoC will work fine on v4.11 too.

Regards,
Niklas

On 03/27/2017 07:43 AM, Kishon Vijay Abraham I wrote:
(snip)

Quoted 26 lines
Quoted 8 lines

Hello Joao

Since commit 442ec4c04d12, we now have two different ops, dw_pcie_ops (ops for dw_pcie) and dw_pcie_host_ops (ops for a pcie_port), note that they are different. The dw_pcie_ops is missing for pcie-artpec6 and pcie-designware-plat (since we are using the generic link-up function).

Quoted 8 lines

Before commit 442ec4c04d12, dw_pcie_writel_dbi had dw_pcie_host_ops as parameter, after the commit it has dw_pcie_ops as parameter. It should crash on pcie-designware-plat as well, since there are other functions, like dw_pcie_link_up, that assumes that pci->ops != null.

Another alternative to adding the dummy ops would be to add null checks for all uses off pci->ops in pcie-designware.c.
I don't like the idea to sprinkle null checks everywhere pci->ops is used.

I'm okay either ways.

Quoted 5 lines

One could add a null check in dw_pcie_host_init, but without a dummy ops we would still fail this check, so our drivers would still be non-functional in Linus's tree.

A message that is not in the archive (sent off-list or not yet received): [email protected]

Acked-by
#6 lore raw

Às 7:19 AM de 3/23/2017, Niklas Cassel escreveu:

Quoted 94 lines · Joao Pinto
Quoted 75 lines

Hi Niklas,

Às 2:43 PM de 3/21/2017, Niklas Cassel escreveu:

Quoted 62 lines

From: Niklas Cassel <[email protected]>

Fix the following crash, seen in dwc/pcie-artpec6.

  Unable to handle kernel NULL pointer dereference at virtual address 00000004
  pgd = c0204000
  [00000004] *pgd=00000000
  Internal error: Oops: 5 [#1] SMP ARM
  Modules linked in:
  CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.11.0-rc3-next-20170321 #1
  Hardware name: Axis ARTPEC-6 Platform
  task: db098000 task.stack: db096000
  PC is at dw_pcie_writel_dbi+0x2c/0xd0
  ...

While at it, fix the same problem for pcie-designware-plat.

Fixes 442ec4c04d12 ("PCI: dwc: all: Split struct pcie_port into host-only and core structures")
---
 drivers/pci/dwc/pcie-artpec6.c         | 4 ++++
 drivers/pci/dwc/pcie-designware-plat.c | 4 ++++
 2 files changed, 8 insertions(+)
drivers/pci/dwc/pcie-artpec6.c +4 -0
index fcd3ef845883..6d23683c0892 100644
@@ -234,6 +234,9 @@ static int artpec6_add_pcie_port(struct artpec6_pcie *artpec6_pcie,
 	return 0;
 }
 
+static const struct dw_pcie_ops dw_pcie_ops = {
+};
+
 static int artpec6_pcie_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
@@ -252,6 +255,7 @@ static int artpec6_pcie_probe(struct platform_device *pdev)
 		return -ENOMEM;
 
 	pci->dev = dev;
+	pci->ops = &dw_pcie_ops;
 
 	artpec6_pcie->pci = pci;
 
drivers/pci/dwc/pcie-designware-plat.c +3 -0
index b6c832ba39dd..f20d494922ab 100644
@@ -86,6 +86,9 @@ static int dw_plat_add_pcie_port(struct pcie_port *pp,
 	return 0;
 }
 
+static const struct dw_pcie_ops dw_pcie_ops = {
+};
+
 static int dw_plat_pcie_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;

drivers/pci/dwc/pcie-designware-plat.c static int dw_plat_pcie_probe(struct platform_device *pdev) · line 112

Quoted 7 lines
drivers/pci/dwc/pcie-designware-plat.c +1 -0
@@ -103,6 +106,7 @@ static int dw_plat_pcie_probe(struct platform_device *pdev)
 		return -ENOMEM;
 
 	pci->dev = dev;
+	pci->ops = &dw_pcie_ops;
 
 	dw_plat_pcie->pci = pci;
 

In the case of pcie-designware-plat you have the declaration of pci->ops:
https://urldefense.proofpoint.com/v2/url?u=https-3A__git.kernel.org_pub_scm_linux_kernel_git_helgaas_pci.git_tree_drivers_pci_dwc_pcie-2Ddesignware-2Dplat.c-23n78&d=DwID-g&c=DPL6_X_6JkXFx7AXWqB0tg&r=s2fO0hii0OGNOv9qQy_HRXy-xAJUD1NNoEcc3io_kx0&m=28B2KMSJPmdGukxJhVcT-K6O76mP27iVn-XTqDwJ4p0&s=glxSZ800DErbgYPvxr-U26UBSVliExhaYEW-MIYIs7U&e=

Quoted 5 lines

and in artpec6 in here:
https://urldefense.proofpoint.com/v2/url?u=https-3A__git.kernel.org_pub_scm_linux_kernel_git_helgaas_pci.git_tree_drivers_pci_dwc_pcie-2Dartpec6.c-23n226&d=DwID-g&c=DPL6_X_6JkXFx7AXWqB0tg&r=s2fO0hii0OGNOv9qQy_HRXy-xAJUD1NNoEcc3io_kx0&m=28B2KMSJPmdGukxJhVcT-K6O76mP27iVn-XTqDwJ4p0&s=_9PXmcF7fsBh4pqYI4lOl4kwCY48xSyUzg6VlCDIy9w&e=

Both declarations are made previously of calling dw_pcie_host_init(), so why do you need this dummy ops in the probe function? I never had that necessity.

Hello Joao

Since commit 442ec4c04d12, we now have two different ops, dw_pcie_ops (ops for dw_pcie) and dw_pcie_host_ops (ops for a pcie_port), note that they are different. The dw_pcie_ops is missing for pcie-artpec6 and pcie-designware-plat (since we are using the generic link-up function).

Before commit 442ec4c04d12, dw_pcie_writel_dbi had dw_pcie_host_ops as parameter, after the commit it has dw_pcie_ops as parameter. It should crash on pcie-designware-plat as well, since there are other functions, like dw_pcie_link_up, that assumes that pci->ops != null.

Quoted 7 lines

Another alternative to adding the dummy ops would be to add null checks for all uses off pci->ops in pcie-designware.c.
I don't like the idea to sprinkle null checks everywhere pci->ops is used.

One could add a null check in dw_pcie_host_init, but without a dummy ops we would still fail this check, so our drivers would still be non-functional in Linus's tree.

Agree.

#7 lore raw
In reply to Niklas Cassel
Quoted 15 lines · Niklas Cassel

From: Niklas Cassel <[email protected]>

Fix the following crash, seen in dwc/pcie-artpec6.

  Unable to handle kernel NULL pointer dereference at virtual address 00000004
  pgd = c0204000
  [00000004] *pgd=00000000
  Internal error: Oops: 5 [#1] SMP ARM
  Modules linked in:
  CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.11.0-rc3-next-20170321 #1
  Hardware name: Axis ARTPEC-6 Platform
  task: db098000 task.stack: db096000
  PC is at dw_pcie_writel_dbi+0x2c/0xd0
  ...
Quoted 4 lines

While at it, fix the same problem for pcie-designware-plat.

Fixes 442ec4c04d12 ("PCI: dwc: all: Split struct pcie_port into host-only and core structures")

For artpec6, I think this has already been fixed by Kishon's "PCI: dwc:
artpec6: Populate cpu_addr_fixup ops".

Since both the artpec6 and designware-plat issues were introduced by 442ec4c04d12, which we merged in the v4.11 merge window, I moved Kishon's fix and the designware-plat part of this patch to for-linus for v4.11.

Please double-check my for-linus branch to make sure it has what we need.

Quoted 52 lines
---
 drivers/pci/dwc/pcie-artpec6.c         | 4 ++++
 drivers/pci/dwc/pcie-designware-plat.c | 4 ++++
 2 files changed, 8 insertions(+)
drivers/pci/dwc/pcie-artpec6.c +4 -0
index fcd3ef845883..6d23683c0892 100644
@@ -234,6 +234,9 @@ static int artpec6_add_pcie_port(struct artpec6_pcie *artpec6_pcie,
 	return 0;
 }
 
+static const struct dw_pcie_ops dw_pcie_ops = {
+};
+
 static int artpec6_pcie_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
@@ -252,6 +255,7 @@ static int artpec6_pcie_probe(struct platform_device *pdev)
 		return -ENOMEM;
 
 	pci->dev = dev;
+	pci->ops = &dw_pcie_ops;
 
 	artpec6_pcie->pci = pci;
 
drivers/pci/dwc/pcie-designware-plat.c +4 -0
index b6c832ba39dd..f20d494922ab 100644
@@ -86,6 +86,9 @@ static int dw_plat_add_pcie_port(struct pcie_port *pp,
 	return 0;
 }
 
+static const struct dw_pcie_ops dw_pcie_ops = {
+};
+
 static int dw_plat_pcie_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
@@ -103,6 +106,7 @@ static int dw_plat_pcie_probe(struct platform_device *pdev)
 		return -ENOMEM;
 
 	pci->dev = dev;
+	pci->ops = &dw_pcie_ops;
 
 	dw_plat_pcie->pci = pci;
 
Signature · 1 line
2.11.0
#8 lore raw
Quoted 16 lines · Bjorn Helgaas
Quoted 15 lines · Niklas Cassel

From: Niklas Cassel <[email protected]>

Fix the following crash, seen in dwc/pcie-artpec6.

  Unable to handle kernel NULL pointer dereference at virtual address 00000004
  pgd = c0204000
  [00000004] *pgd=00000000
  Internal error: Oops: 5 [#1] SMP ARM
  Modules linked in:
  CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.11.0-rc3-next-20170321 #1
  Hardware name: Axis ARTPEC-6 Platform
  task: db098000 task.stack: db096000
  PC is at dw_pcie_writel_dbi+0x2c/0xd0
  ...
Quoted 7 lines
Quoted 4 lines

While at it, fix the same problem for pcie-designware-plat.

Fixes 442ec4c04d12 ("PCI: dwc: all: Split struct pcie_port into host-only and core structures")

For artpec6, I think this has already been fixed by Kishon's "PCI: dwc:
artpec6: Populate cpu_addr_fixup ops".

Agreed.

Quoted 4 lines

Since both the artpec6 and designware-plat issues were introduced by 442ec4c04d12, which we merged in the v4.11 merge window, I moved Kishon's fix and the designware-plat part of this patch to for-linus for v4.11.

I didn't think that including "PCI: dwc: designware: Add new *ops* for CPU addr fixup" was an option, but doing so is a cleaner solution imo.

Quoted 2 lines

Please double-check my for-linus branch to make sure it has what we need.

The branch looks good. I did test it, and it works marvelously.

Quoted 53 lines
Quoted 53 lines
---
 drivers/pci/dwc/pcie-artpec6.c         | 4 ++++
 drivers/pci/dwc/pcie-designware-plat.c | 4 ++++
 2 files changed, 8 insertions(+)
drivers/pci/dwc/pcie-artpec6.c +4 -0
index fcd3ef845883..6d23683c0892 100644
@@ -234,6 +234,9 @@ static int artpec6_add_pcie_port(struct artpec6_pcie *artpec6_pcie,
 	return 0;
 }
 
+static const struct dw_pcie_ops dw_pcie_ops = {
+};
+
 static int artpec6_pcie_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
@@ -252,6 +255,7 @@ static int artpec6_pcie_probe(struct platform_device *pdev)
 		return -ENOMEM;
 
 	pci->dev = dev;
+	pci->ops = &dw_pcie_ops;
 
 	artpec6_pcie->pci = pci;
 
drivers/pci/dwc/pcie-designware-plat.c +4 -0
index b6c832ba39dd..f20d494922ab 100644
@@ -86,6 +86,9 @@ static int dw_plat_add_pcie_port(struct pcie_port *pp,
 	return 0;
 }
 
+static const struct dw_pcie_ops dw_pcie_ops = {
+};
+
 static int dw_plat_pcie_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
@@ -103,6 +106,7 @@ static int dw_plat_pcie_probe(struct platform_device *pdev)
 		return -ENOMEM;
 
 	pci->dev = dev;
+	pci->ops = &dw_pcie_ops;
 
 	dw_plat_pcie->pci = pci;
 
Signature · 1 line
2.11.0
#9 lore raw
Quoted 32 lines · Niklas Cassel
Quoted 16 lines · Bjorn Helgaas
Quoted 15 lines · Niklas Cassel

From: Niklas Cassel <[email protected]>

Fix the following crash, seen in dwc/pcie-artpec6.

  Unable to handle kernel NULL pointer dereference at virtual address 00000004
  pgd = c0204000
  [00000004] *pgd=00000000
  Internal error: Oops: 5 [#1] SMP ARM
  Modules linked in:
  CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.11.0-rc3-next-20170321 #1
  Hardware name: Axis ARTPEC-6 Platform
  task: db098000 task.stack: db096000
  PC is at dw_pcie_writel_dbi+0x2c/0xd0
  ...
Quoted 7 lines
Quoted 4 lines

While at it, fix the same problem for pcie-designware-plat.

Fixes 442ec4c04d12 ("PCI: dwc: all: Split struct pcie_port into host-only and core structures")

For artpec6, I think this has already been fixed by Kishon's "PCI: dwc:
artpec6: Populate cpu_addr_fixup ops".

Agreed.

Quoted 4 lines

Since both the artpec6 and designware-plat issues were introduced by 442ec4c04d12, which we merged in the v4.11 merge window, I moved Kishon's fix and the designware-plat part of this patch to for-linus for v4.11.

Quoted 7 lines

I didn't think that including "PCI: dwc: designware: Add new *ops* for CPU addr fixup" was an option, but doing so is a cleaner solution imo.

Quoted 2 lines

Please double-check my for-linus branch to make sure it has what we need.

The branch looks good. I did test it, and it works marvelously.

Thanks a lot for testing it. I had already reconsidered this and decided that I don't really like patches that do two things at once, i.e., the "CPU addr fixup" patch both fixes the CPU addr thing and fixes the NULL pointer dereference as an unintended side effect.

So I ended up putting your original patch on for-linus, then rebasing pci/host-designware on top of for-linus. That way we have your simple patch for v4.11 that fixes the NULL pointer problems, and the CPU addr fixups will go in v4.12 along with the rest of that series. It's much ado about nothing, really, and could go either way.

Quoted 52 lines
Quoted 52 lines
Quoted 52 lines
---
 drivers/pci/dwc/pcie-artpec6.c         | 4 ++++
 drivers/pci/dwc/pcie-designware-plat.c | 4 ++++
 2 files changed, 8 insertions(+)
drivers/pci/dwc/pcie-artpec6.c +4 -0
index fcd3ef845883..6d23683c0892 100644
@@ -234,6 +234,9 @@ static int artpec6_add_pcie_port(struct artpec6_pcie *artpec6_pcie,
 	return 0;
 }
 
+static const struct dw_pcie_ops dw_pcie_ops = {
+};
+
 static int artpec6_pcie_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
@@ -252,6 +255,7 @@ static int artpec6_pcie_probe(struct platform_device *pdev)
 		return -ENOMEM;
 
 	pci->dev = dev;
+	pci->ops = &dw_pcie_ops;
 
 	artpec6_pcie->pci = pci;
 
drivers/pci/dwc/pcie-designware-plat.c +4 -0
index b6c832ba39dd..f20d494922ab 100644
@@ -86,6 +86,9 @@ static int dw_plat_add_pcie_port(struct pcie_port *pp,
 	return 0;
 }
 
+static const struct dw_pcie_ops dw_pcie_ops = {
+};
+
 static int dw_plat_pcie_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
@@ -103,6 +106,7 @@ static int dw_plat_pcie_probe(struct platform_device *pdev)
 		return -ENOMEM;
 
 	pci->dev = dev;
+	pci->ops = &dw_pcie_ops;
 
 	dw_plat_pcie->pci = pci;
 
Signature · 1 line
2.11.0