git: cbedee9bdcda - stable/15 - e1000: defer sysctl-driven reinit to the admin task

From: Kevin Bowling <kbowling_at_FreeBSD.org>
Date: Wed, 12 Aug 2026 20:30:20 UTC
The branch stable/15 has been updated by kbowling:

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

commit cbedee9bdcda72bba3cceead8272c9b75ab90512
Author:     Abdelkader Boudih <seuros@seuros.com>
AuthorDate: 2026-08-05 04:34:13 +0000
Commit:     Kevin Bowling <kbowling@FreeBSD.org>
CommitDate: 2026-08-12 20:29:17 +0000

    e1000: defer sysctl-driven reinit to the admin task
    
    Request the reset through iflib and let the admin task perform the
    stop/init under the context lock, matching what the VF and SR-IOV paths
    already do.
    
    The assertion is compiled out without INVARIANTS, where the same write
    instead resets the MAC and takes the ICH software flag while the queues
    stay live and an ioctl or the admin task may be running.
    
    While here also remove unnecessary em_if_init uses:
    iflib_if_init_locked() already runs after IFDI_RESUME and
    IFDI_MEDIA_CHANGE, so the trailing *_if_init() only added an unstopped
    IFDI_INIT that the following iflib_stop() undoes.
    
    Differential Revision:  https://reviews.freebsd.org/D58628
    
    (cherry picked from commit abdde8b602813753e423610b39be6806da5647e2)
---
 sys/dev/e1000/if_em.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/sys/dev/e1000/if_em.c b/sys/dev/e1000/if_em.c
index 0e850feb879d..1e027861a175 100644
--- a/sys/dev/e1000/if_em.c
+++ b/sys/dev/e1000/if_em.c
@@ -1494,8 +1494,6 @@ em_if_resume(if_ctx_t ctx)
 
 	if (sc->hw.mac.type == e1000_pch2lan)
 		e1000_resume_workarounds_pchlan(&sc->hw);
-	em_if_init(ctx);
-	em_init_manageability(sc);
 
 	return(0);
 }
@@ -2116,8 +2114,6 @@ em_if_media_change(if_ctx_t ctx)
 		device_printf(sc->dev, "Unsupported media type\n");
 	}
 
-	em_if_init(ctx);
-
 	return (0);
 }
 
@@ -5709,6 +5705,16 @@ em_set_flowcntl(SYSCTL_HANDLER_ARGS)
 	return (error);
 }
 
+static void
+em_sysctl_request_reinit(struct e1000_softc *sc)
+{
+	if ((if_getflags(iflib_get_ifp(sc->ctx)) & IFF_UP) == 0)
+		return;
+
+	iflib_request_reset(sc->ctx);
+	iflib_admin_intr_deferred(sc->ctx);
+}
+
 /*
  * Manage DMA Coalesce:
  * Control values:
@@ -5754,7 +5760,7 @@ igb_sysctl_dmac(SYSCTL_HANDLER_ARGS)
 			return (EINVAL);
 	}
 	/* Reinit the interface */
-	em_if_init(sc->ctx);
+	em_sysctl_request_reinit(sc);
 	return (error);
 }
 
@@ -5780,7 +5786,7 @@ em_sysctl_eee(SYSCTL_HANDLER_ARGS)
 		sc->hw.dev_spec.ich8lan.eee_disable = (value != 0);
 	else
 		sc->hw.dev_spec._82575.eee_disable = (value != 0);
-	em_if_init(sc->ctx);
+	em_sysctl_request_reinit(sc);
 
 	return (0);
 }