From 3b7611dc1d506795f6c765c0748b1d1566d64f57 Mon Sep 17 00:00:00 2001 From: Babu Moger Date: Mon, 21 Mar 2016 10:11:19 -0700 Subject: [PATCH] sparc/PCI: Fix for panic while enabling SR-IOV Orabug: 22659268 We noticed this panic while enabling SR-IOV in sparc. ixgbe 0002:03:00.0 eth4: SR-IOV enabled with 2 VFs ixgbe 0002:03:00.0: Multiqueue Enabled: Rx Queue count = 4, Tx Queue count = 4 ixgbevf: Intel(R) 10 Gigabit PCI Express Virtual Function Network Driver - version 2.12.1-k ixgbevf: Copyright (c) 2009 - 2012 Intel Corporation. Unable to handle kernel NULL pointer dereference tsk->{mm,active_mm}->context = 000000000000160c tsk->{mm,active_mm}->pgd = fff8000408238000 \|/ ____ \|/ "@'/ .. \`@" /_| \__/ |_\ \__U_/ modprobe(3335): Oops [#1] CPU: 2 PID: 3335 Comm: modprobe Tainted: G OE 4.1.12-32.el6uek.sparc64 #1 task: fff8000406f35ca0 ti: fff8000404630000 task.ti: fff8000404630000 TSTATE: 0000008411001606 TPC: 0000000000438ee0 TNPC: 0000000000438f0c Y: 00000000 Tainted: G OE TPC: g0: 0000000080000001 g1: 0000000000000000 g2: 00000000ffffffff g3: 0000000000000003 g4: fff8000406f35ca0 g5: fff800041896a000 g6: fff8000404630000 g7: 0000000000000000 o0: 0000000000000000 o1: 0000000000000300 o2: 000000000000000 1o3: 0000000000000004 o4: fff80004122160d8 o5: 0000000000e37ae5 sp: fff8000404632951 ret_pc: 00000000007215d0 RPC: l0: fff8000404410090 l1: fff800040441013e l2: 00000000007a768c l3: 0000000000000001 l4: fff80004046331d8 l5: fff80004046331f0 l6: e000000000000000 l7: 0040000000000000 i0: fff8000404410090 i1: ffffffffffffffff i2: fff8000404410180 i3: 00000000004ace40 i4: 0000000000000000 i5: 2000000000000000 i6: fff8000404632a0 1i7: 0000000010550ea0 I7: Call Trace: [0000000010550ea0] ixgbevf_probe+0x80/0x4c0 [ixgbevf] [00000000007229d4] local_pci_probe+0x34/0xa0 [0000000000722ae8] pci_call_probe+0xa8/0xe0 [0000000000722dd0] pci_device_probe+0x50/0x80 [000000000079c1c0] really_probe+0x140/0x420 [000000000079c4e4] driver_probe_device+0x44/0xa0 [000000000079c5c8] __driver_attach+0x88/0xa0 [000000000079a3cc] bus_for_each_dev+0x6c/0xa0 [000000000079bd5c] driver_attach+0x1c/0x40 [000000000079ae1c] bus_add_driver+0x17c/0x220 [000000000079cd94] driver_register+0x74/0x120 [0000000000722ebc] __pci_register_driver+0x3c/0x60 [0000000010558048] ixgbevf_init_module+0x48/0x5c [ixgbevf] [0000000000426bb8] do_one_initcall+0xb8/0x200 [00000000004e5f8c] do_init_module+0x4c/0x1c0 [00000000004e6f48] load_module+0x5e8/0x780 Disabling lock debugging due to kernel taint Caller[0000000010550ea0]: ixgbevf_probe+0x80/0x4c0 [ixgbevf] Caller[00000000007229d4]: local_pci_probe+0x34/0xa0 Caller[0000000000722ae8]: pci_call_probe+0xa8/0xe0 Caller[0000000000722dd0]: pci_device_probe+0x50/0x80 Caller[000000000079c1c0]: really_probe+0x140/0x420 Caller[000000000079c4e4]: driver_probe_device+0x44/0xa0 Caller[000000000079c5c8]: __driver_attach+0x88/0xa0 Caller[000000000079a3cc]: bus_for_each_dev+0x6c/0xa0 Caller[000000000079bd5c]: driver_attach+0x1c/0x40 Caller[000000000079ae1c]: bus_add_driver+0x17c/0x220 Caller[000000000079cd94]: driver_register+0x74/0x120 Caller[0000000000722ebc]: __pci_register_driver+0x3c/0x60 Caller[0000000010558048]: ixgbevf_init_module+0x48/0x5c [ixgbevf] Caller[0000000000426bb8]: do_one_initcall+0xb8/0x200 Caller[00000000004e5f8c]: do_init_module+0x4c/0x1c0 Caller[00000000004e6f48]: load_module+0x5e8/0x780 Caller[00000000004e7184]: SyS_init_module+0xa4/0xe0 Caller[0000000000406254]: linux_sparc_syscall+0x34/0x44 Caller[0000000000103490]: 0x103490 Instruction DUMP: 8530b020 80a64002 1860000c 840e4001 80a08001 02400009 90102001 c45e2088 Kernel panic - not syncing: Fatal exception Press Stop-A (L1-A) to return to the boot prom ---[ end Kernel panic - not syncing: Fatal exception Details: Here is the call sequence virtfn_add->__mlx4_init_one->dma_set_mask->dma_supported The panic happened at line 760(file arch/sparc/kernel/iommu.c) 758 int dma_supported(struct device *dev, u64 device_mask) 759 { 760 struct iommu *iommu = dev->archdata.iommu; 761 u64 dma_addr_mask = iommu->dma_addr_mask; 762 763 if (device_mask >= (1UL << 32UL)) 764 return 0; 765 766 if ((device_mask & dma_addr_mask) == dma_addr_mask) 767 return 1; 768 769 #ifdef CONFIG_PCI 770 if (dev_is_pci(dev)) 771 return pci64_dma_supported(to_pci_dev(dev), device_mask); 772 #endif 773 774 return 0; 775 } 776 EXPORT_SYMBOL(dma_supported); Same panic happened with Intel ixgbe driver also. SR-IOV code looks for arch specific data while enabling VFs. When VF device is added, driver probe function makes set of calls to initialize the pci device. Because the VF device is added different way than the normal PF device(which happens via of_create_pci_dev for sparc), some of the arch specific initialization does not happen for VF device. That causes panic when archdata is accessed. To fix this, I have used already defined weak function pcibios_setup_device to copy archdata from PF to VF. Also verified the fix. Signed-off-by: Babu Moger Signed-off-by: Sowmini Varadhan Reviewed-by: Ethan Zhao Signed-off-by: Allen Pais (cherry picked from commit be81c7e3cc48d3ff8b26021be3fd49e997743cbc) --- arch/sparc/kernel/pci.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/arch/sparc/kernel/pci.c b/arch/sparc/kernel/pci.c index 2bcef15b0287..da9eadf93f74 100644 --- a/arch/sparc/kernel/pci.c +++ b/arch/sparc/kernel/pci.c @@ -1030,6 +1030,23 @@ void pcibios_set_master(struct pci_dev *dev) /* No special bus mastering setup handling */ } +#ifdef CONFIG_PCI_IOV +int pcibios_add_device(struct pci_dev *dev) +{ + struct pci_dev *pdev; + + /* Add sriov arch specific initialization here. + * Copy dev_archdata from PF to VF + */ + if (dev->is_virtfn) { + pdev = dev->physfn; + memcpy(&dev->dev.archdata, &pdev->dev.archdata, + sizeof(struct dev_archdata)); + } + return 0; +} +#endif /* CONFIG_PCI_IOV */ + static int __init pcibios_init(void) { pci_dfl_cache_line_size = 64 >> 2; -- 2.50.1