git: a8dc67388ae1 - main - cxgbe(4): Add a knob to request that clocks be gated on suspend.

From: Navdeep Parhar <np_at_FreeBSD.org>
Date: Tue, 16 Aug 2022 08:57:21 UTC
The branch main has been updated by np:

URL: https://cgit.FreeBSD.org/src/commit/?id=a8dc67388ae11a3bbb0175acb3ef9f6478d0c233

commit a8dc67388ae11a3bbb0175acb3ef9f6478d0c233
Author:     Navdeep Parhar <np@FreeBSD.org>
AuthorDate: 2022-08-16 07:48:21 +0000
Commit:     Navdeep Parhar <np@FreeBSD.org>
CommitDate: 2022-08-16 08:08:35 +0000

    cxgbe(4): Add a knob to request that clocks be gated on suspend.
    
    MFC after:      3 months
    Sponsored by:   Chelsio Communications
---
 sys/dev/cxgbe/t4_main.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/sys/dev/cxgbe/t4_main.c b/sys/dev/cxgbe/t4_main.c
index 27403b681208..47caab160d29 100644
--- a/sys/dev/cxgbe/t4_main.c
+++ b/sys/dev/cxgbe/t4_main.c
@@ -626,6 +626,10 @@ static int t4_reset_on_fatal_err = 0;
 SYSCTL_INT(_hw_cxgbe, OID_AUTO, reset_on_fatal_err, CTLFLAG_RWTUN,
     &t4_reset_on_fatal_err, 0, "reset adapter on fatal errors");
 
+static int t4_clock_gate_on_suspend = 0;
+SYSCTL_INT(_hw_cxgbe, OID_AUTO, clock_gate_on_suspend, CTLFLAG_RWTUN,
+    &t4_clock_gate_on_suspend, 0, "gate the clock on suspend");
+
 static int t4_tx_vm_wr = 0;
 SYSCTL_INT(_hw_cxgbe, OID_AUTO, tx_vm_wr, CTLFLAG_RWTUN, &t4_tx_vm_wr, 0,
     "Use VM work requests to transmit packets.");
@@ -1996,6 +2000,12 @@ t4_suspend(device_t dev)
 	sc->reset_thread = NULL;
 	mtx_unlock(&sc->reg_lock);
 
+	if (t4_clock_gate_on_suspend) {
+		t4_set_reg_field(sc, A_PMU_PART_CG_PWRMODE, F_MA_PART_CGEN |
+		    F_LE_PART_CGEN | F_EDC1_PART_CGEN | F_EDC0_PART_CGEN |
+		    F_TP_PART_CGEN | F_PDP_PART_CGEN | F_SGE_PART_CGEN, 0);
+	}
+
 	CH_ALERT(sc, "suspend completed.\n");
 done:
 	end_synchronized_op(sc, 0);