git: 39a36707bd33 - main - cxgbe(4): Avoid unsafe hardware access in the ifmedia ioctls.

From: Navdeep Parhar <np_at_FreeBSD.org>
Date: Sat, 12 Feb 2022 01:50:11 UTC
The branch main has been updated by np:

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

commit 39a36707bd33b86a115651678028baeb616c8365
Author:     Navdeep Parhar <np@FreeBSD.org>
AuthorDate: 2022-02-11 23:37:17 +0000
Commit:     Navdeep Parhar <np@FreeBSD.org>
CommitDate: 2022-02-12 00:35:27 +0000

    cxgbe(4): Avoid unsafe hardware access in the ifmedia ioctls.
    
    The hardware is unavailable when the device is suspended or in the
    middle of a reset.
    
    MFC after:      1 week
    Sponsored by:   Chelsio Communications
---
 sys/dev/cxgbe/t4_main.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sys/dev/cxgbe/t4_main.c b/sys/dev/cxgbe/t4_main.c
index e7f6c239266b..08e9b32cf4d2 100644
--- a/sys/dev/cxgbe/t4_main.c
+++ b/sys/dev/cxgbe/t4_main.c
@@ -3165,7 +3165,7 @@ cxgbe_media_change(struct ifnet *ifp)
 		if (IFM_OPTIONS(ifm->ifm_media) & IFM_ETH_TXPAUSE)
 			lc->requested_fc |= PAUSE_TX;
 	}
-	if (pi->up_vis > 0) {
+	if (pi->up_vis > 0 && !hw_off_limits(sc)) {
 		fixup_link_config(pi);
 		rc = apply_link_config(pi);
 	}
@@ -3333,7 +3333,7 @@ cxgbe_media_status(struct ifnet *ifp, struct ifmediareq *ifmr)
 		return;
 	PORT_LOCK(pi);
 
-	if (pi->up_vis == 0) {
+	if (pi->up_vis == 0 && !hw_off_limits(sc)) {
 		/*
 		 * If all the interfaces are administratively down the firmware
 		 * does not report transceiver changes.  Refresh port info here