fm10k: check if PCIe link is restored
authorJacob Keller <jacob.e.keller@intel.com>
Tue, 7 Jun 2016 23:08:58 +0000 (16:08 -0700)
committerJeff Kirsher <jeffrey.t.kirsher@intel.com>
Wed, 20 Jul 2016 22:22:15 +0000 (15:22 -0700)
Sometimes, a VF driver will lose PCIe address access, such as due to
a PF FLR event. In fm10k_detach_subtask, poll and check whether the
PCIe register space is active again and restore the device when it has.

Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
Tested-by: Krishneil Singh <Krishneil.k.singh@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
drivers/net/ethernet/intel/fm10k/fm10k_pci.c

index 5e40460b041df8b59b207338b4a4e13e7e40499d..d4ccb2a0c585df93f943a0cfaa9f1f5417e79aa5 100644 (file)
@@ -123,11 +123,24 @@ static void fm10k_service_timer(unsigned long data)
 static void fm10k_detach_subtask(struct fm10k_intfc *interface)
 {
        struct net_device *netdev = interface->netdev;
+       u32 __iomem *hw_addr;
+       u32 value;
 
        /* do nothing if device is still present or hw_addr is set */
        if (netif_device_present(netdev) || interface->hw.hw_addr)
                return;
 
+       /* check the real address space to see if we've recovered */
+       hw_addr = READ_ONCE(interface->uc_addr);
+       value = readl(hw_addr);
+       if ((~value)) {
+               interface->hw.hw_addr = interface->uc_addr;
+               netif_device_attach(netdev);
+               interface->flags |= FM10K_FLAG_RESET_REQUESTED;
+               netdev_warn(netdev, "PCIe link restored, device now attached\n");
+               return;
+       }
+
        rtnl_lock();
 
        if (netif_running(netdev))