git: 2f733c60ff46 - stable/13 - cxgbe(4): Avoid unsafe hardware access in the ifmedia ioctls.

From: Navdeep Parhar <np_at_FreeBSD.org>
Date: Mon, 28 Feb 2022 06:55:52 UTC
The branch stable/13 has been updated by np:

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

commit 2f733c60ff46f3ce237d6d8b5ac6ebfe6b8645dc
Author:     Navdeep Parhar <np@FreeBSD.org>
AuthorDate: 2022-02-11 23:37:17 +0000
Commit:     Navdeep Parhar <np@FreeBSD.org>
CommitDate: 2022-02-28 06:51:32 +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.
    
    Sponsored by:   Chelsio Communications
    
    (cherry picked from commit 39a36707bd33b86a115651678028baeb616c8365)
---
 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 391bc9de8bfc..e8f82e4aea3b 100644
--- a/sys/dev/cxgbe/t4_main.c
+++ b/sys/dev/cxgbe/t4_main.c
@@ -3227,7 +3227,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);
 	}
@@ -3395,7 +3395,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