netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Michael Chan <michael.chan@broadcom.com>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org
Subject: [PATCH net-next 03/12] bnxt_en: Add pci shutdown method.
Date: Tue,  4 Apr 2017 18:14:08 -0400	[thread overview]
Message-ID: <1491344057-12663-4-git-send-email-michael.chan@broadcom.com> (raw)
In-Reply-To: <1491344057-12663-1-git-send-email-michael.chan@broadcom.com>

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

Signed-off-by: Michael Chan <michael.chan@broadcom.com>
---
 drivers/net/ethernet/broadcom/bnxt/bnxt.c | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
index 70cc313..10a9cda 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
@@ -7617,6 +7617,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)
@@ -7641,6 +7645,32 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 	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
@@ -7757,6 +7787,7 @@ static void bnxt_io_resume(struct pci_dev *pdev)
 	.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,
-- 
1.8.3.1

  parent reply	other threads:[~2017-04-04 22:14 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-04 22:14 [PATCH net-next 00/12] bnxt_en: Updates for net-next Michael Chan
2017-04-04 22:14 ` [PATCH net-next 01/12] bnxt_en: Update firmware interface spec to 1.7.6.2 Michael Chan
2017-04-04 22:14 ` [PATCH net-next 02/12] bnxt_en: Add basic WoL infrastructure Michael Chan
2017-04-04 22:14 ` Michael Chan [this message]
2017-04-04 22:14 ` [PATCH net-next 04/12] bnxt_en: Add ethtool get_wol method Michael Chan
2017-04-04 22:14 ` [PATCH net-next 05/12] bnxt_en: Add ethtool set_wol method Michael Chan
2017-04-04 22:14 ` [PATCH net-next 06/12] bnxt_en: Add suspend/resume callbacks Michael Chan
2017-04-04 22:14 ` [PATCH net-next 07/12] bnxt_en: Add basic ethtool -t selftest support Michael Chan
2017-04-04 22:14 ` [PATCH net-next 08/12] bnxt_en: Add ethtool mac loopback self test Michael Chan
2017-04-04 22:14 ` [PATCH net-next 09/12] bnxt_en: Add PHY loopback to ethtool self-test Michael Chan
2017-04-04 22:14 ` [PATCH net-next 10/12] bnxt_en: Add interrupt test to ethtool -t selftest Michael Chan
2017-04-04 22:14 ` [PATCH net-next 11/12] bnxt_en: Use short TX BDs for the XDP TX ring Michael Chan
2017-04-04 22:14 ` [PATCH net-next 12/12] bnxt_en: Cap the msix vector with the max completion rings Michael Chan
2017-04-05 13:24 ` [PATCH net-next 00/12] bnxt_en: Updates for net-next David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1491344057-12663-4-git-send-email-michael.chan@broadcom.com \
    --to=michael.chan@broadcom.com \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).