]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
bnxt_en: Add pci shutdown method.
authorMichael Chan <michael.chan@broadcom.com>
Tue, 4 Apr 2017 22:14:08 +0000 (18:14 -0400)
committerSomasundaram Krishnasamy <somasundaram.krishnasamy@oracle.com>
Tue, 11 Jul 2017 00:04:09 +0000 (17:04 -0700)
Orabug: 264025332632559926366387

Add pci shutdown method to put device in the proper WoL and power state.

Signed-off-by: Michael Chan <michael.chan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
(cherry picked from commit d196ece740bf337aa25731cd8cb44660a2a227dd)
Signed-off-by: Brian Maly <brian.maly@oracle.com>
Signed-off-by: Somasundaram Krishnasamy <somasundaram.krishnasamy@oracle.com>
drivers/net/ethernet/broadcom/bnxt/bnxt.c

index ec485b00a86a4e0c9321ef0610e8c6152eb22d69..2ab9091aad768b04680cc52a845f2189de5d89e2 100644 (file)
@@ -7703,6 +7703,10 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
                goto init_err_pci_clean;
 
        bnxt_get_wol_settings(bp);
+       if (bp->flags & BNXT_FLAG_WOL_CAP)
+               device_set_wakeup_enable(&pdev->dev, bp->wol);
+       else
+               device_set_wakeup_capable(&pdev->dev, false);
 
        rc = register_netdev(dev);
        if (rc)
@@ -7727,6 +7731,32 @@ init_err_free:
        return rc;
 }
 
+static void bnxt_shutdown(struct pci_dev *pdev)
+{
+       struct net_device *dev = pci_get_drvdata(pdev);
+       struct bnxt *bp;
+
+       if (!dev)
+               return;
+
+       rtnl_lock();
+       bp = netdev_priv(dev);
+       if (!bp)
+               goto shutdown_exit;
+
+       if (netif_running(dev))
+               dev_close(dev);
+
+       if (system_state == SYSTEM_POWER_OFF) {
+               bnxt_clear_int_mode(bp);
+               pci_wake_from_d3(pdev, bp->wol);
+               pci_set_power_state(pdev, PCI_D3hot);
+       }
+
+shutdown_exit:
+       rtnl_unlock();
+}
+
 /**
  * bnxt_io_error_detected - called when PCI error is detected
  * @pdev: Pointer to PCI device
@@ -7843,6 +7873,7 @@ static struct pci_driver bnxt_pci_driver = {
        .id_table       = bnxt_pci_tbl,
        .probe          = bnxt_init_one,
        .remove         = bnxt_remove_one,
+       .shutdown       = bnxt_shutdown,
        .err_handler    = &bnxt_err_handler,
 #if defined(CONFIG_BNXT_SRIOV)
        .sriov_configure = bnxt_sriov_configure,