Blob Blame History Raw
From 224c60c8d8843dce4d69b52e4966618f438ee261 Mon Sep 17 00:00:00 2001
From: Xiaowei Bao <xiaowei.bao@nxp.com>
Date: Wed, 25 Sep 2019 22:55:17 +0100
Subject: [PATCH 3/3] PCI: mobiveil: ls_pcie_g4: fix SError when accessing
 config space

Patch-mainline: Not yet, Applied to Russell King's git
References: fate#326572

While the Mellanox driver is binding, the following kernel panic
occurred:

SError Interrupt on CPU1, code 0xbf000002 -- SError
CPU: 1 PID: 1 Comm: swapper/0 Not tainted 5.3.0+ #392
Hardware name: SolidRun LX2160A COM express type 7 module (DT)
pstate: 60400085 (nZCv daIf +PAN -UAO)
pc : pci_generic_config_read+0xb0/0xc0
lr : pci_generic_config_read+0x1c/0xc0
sp : ffffff8010f9baf0
x29: ffffff8010f9baf0 x28: ffffff8010d620a0
x27: ffffff8010d79000 x26: ffffff8010d62000
x25: ffffff8010cb06d4 x24: 0000000000000000
x23: ffffff8010e499b8 x22: ffffff8010f9bbaf
x21: 0000000000000000 x20: ffffffe2eda11800
x19: ffffff8010f62158 x18: ffffff8010bdede0
x17: ffffff8010bdede8 x16: ffffff8010b96970
x15: ffffffffffffffff x14: ffffffffff000000
x13: ffffffffffffffff x12: 0000000000000030
x11: 0101010101010101 x10: 7f7f7f7f7f7f7f7f
x9 : 2dff716475687163 x8 : ffffffffffffffff
x7 : fefefefefefefefe x6 : 0000000000000000
x5 : 0000000000000000 x4 : ffffff8010f9bb6c
x3 : 0000000000000001 x2 : 0000000000000003
x1 : 0000000000000000 x0 : 0000000000000000
Kernel panic - not syncing: Asynchronous SError Interrupt
CPU: 1 PID: 1 Comm: swapper/0 Not tainted 5.3.0+ #392
Hardware name: SolidRun LX2160A COM express type 7 module (DT)
Call trace:
 dump_backtrace+0x0/0x120
 show_stack+0x14/0x1c
 dump_stack+0x9c/0xc0
 panic+0x148/0x34c
 print_tainted+0x0/0xa8
 arm64_serror_panic+0x74/0x80
 do_serror+0x8c/0x13c
 el1_error+0xbc/0x160
 pci_generic_config_read+0xb0/0xc0
 pci_bus_read_config_byte+0x64/0x90
 pci_read_config_byte+0x40/0x48
 pci_assign_irq+0x34/0xc8
 pci_device_probe+0x28/0x148
 really_probe+0x1c4/0x2d0
 driver_probe_device+0x58/0xfc
 device_driver_attach+0x68/0x70
 __driver_attach+0x94/0xdc
 bus_for_each_dev+0x50/0xa0
 driver_attach+0x20/0x28
 bus_add_driver+0x14c/0x200
 driver_register+0x6c/0x124
 __pci_register_driver+0x48/0x50
 mlx4_init+0x154/0x180
 do_one_initcall+0x30/0x250
 kernel_init_freeable+0x23c/0x32c
 kernel_init+0x10/0xfc
 ret_from_fork+0x10/0x18
SMP: stopping secondary CPUs
Kernel Offset: disabled
CPU features: 0x0002,21006008
Memory Limit: none

which appears to be due to:

        pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &pin);

in pci_assign_irq().  Avoiding that access just moves the SError later
(e.g. while accessing the command register in pci_enable_device()
instead.)

This patch resolves the SError problem by preventing configuration
accesses triggering a SError interrupt.

Reported-by: Russell King <rmk+kernel@armlinux.org.uk>
Tested-by: Russell King <rmk+kernel@armlinux.org.uk>
Signed-off-by: Xiaowei Bao <xiaowei.bao@nxp.com>
[description modified -- rmk]
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
Signed-off-by: Mian Yousaf Kaukab <yousaf.kaukab@suse.com>
---
 drivers/pci/host/mobiveil/pcie-layerscape-gen4.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/pci/host/mobiveil/pcie-layerscape-gen4.c b/drivers/pci/host/mobiveil/pcie-layerscape-gen4.c
index 923a06b20eac..2195d7d97db0 100644
--- a/drivers/pci/host/mobiveil/pcie-layerscape-gen4.c
+++ b/drivers/pci/host/mobiveil/pcie-layerscape-gen4.c
@@ -243,13 +243,13 @@ static int ls_pcie_g4_read_other_conf(struct pci_bus *bus, unsigned int devfn,
 	struct ls_pcie_g4 *pcie = to_ls_pcie_g4(pci);
 	int ret;
 
-	if (pcie->rev == REV_1_0 && where == PCI_VENDOR_ID)
+	if (pcie->rev == REV_1_0)
 		ls_pcie_g4_lut_writel(pcie, PCIE_LUT_GCR,
 				      0 << PCIE_LUT_GCR_RRE);
 
 	ret = pci_generic_config_read(bus, devfn, where, size, val);
 
-	if (pcie->rev == REV_1_0 && where == PCI_VENDOR_ID)
+	if (pcie->rev == REV_1_0)
 		ls_pcie_g4_lut_writel(pcie, PCIE_LUT_GCR,
 				      1 << PCIE_LUT_GCR_RRE);
 
-- 
2.16.4