git: 0fa6b2c523ee - stable/14 - e1000: defer sysctl-driven reinit to the admin task

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

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

commit 0fa6b2c523ee763604a842df8da16ebf30888354
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:30:35 +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 867f5cc0cd69..6c489bec5a4c 100644
--- a/sys/dev/e1000/if_em.c
+++ b/sys/dev/e1000/if_em.c
@@ -1487,8 +1487,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);
 }
@@ -2109,8 +2107,6 @@ em_if_media_change(if_ctx_t ctx)
 		device_printf(sc->dev, "Unsupported media type\n");
 	}
 
-	em_if_init(ctx);
-
 	return (0);
 }
 
@@ -5622,6 +5618,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:
@@ -5667,7 +5673,7 @@ igb_sysctl_dmac(SYSCTL_HANDLER_ARGS)
 			return (EINVAL);
 	}
 	/* Reinit the interface */
-	em_if_init(sc->ctx);
+	em_sysctl_request_reinit(sc);
 	return (error);
 }
 
@@ -5693,7 +5699,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);
 }