sync code with last improvements from OpenBSD

This commit is contained in:
purplerain 2023-09-30 04:49:59 +00:00
parent 96ee847eba
commit 35f88e7af9
Signed by: purplerain
GPG Key ID: F42C07F07E2E35B7

View File

@ -1,4 +1,4 @@
/* $OpenBSD: if_ixl.c,v 1.88 2023/07/19 20:22:05 jan Exp $ */ /* $OpenBSD: if_ixl.c,v 1.89 2023/09/29 19:44:47 bluhm Exp $ */
/* /*
* Copyright (c) 2013-2015, Intel Corporation * Copyright (c) 2013-2015, Intel Corporation
@ -2074,8 +2074,10 @@ ixl_media_status(struct ifnet *ifp, struct ifmediareq *ifm)
KERNEL_ASSERT_LOCKED(); KERNEL_ASSERT_LOCKED();
mtx_enter(&sc->sc_link_state_mtx);
ifm->ifm_status = sc->sc_media_status; ifm->ifm_status = sc->sc_media_status;
ifm->ifm_active = sc->sc_media_active; ifm->ifm_active = sc->sc_media_active;
mtx_leave(&sc->sc_link_state_mtx);
} }
static void static void
@ -3482,9 +3484,7 @@ ixl_link_state_update_iaq(struct ixl_softc *sc, void *arg)
return; return;
} }
KERNEL_LOCK();
link_state = ixl_set_link_status(sc, iaq); link_state = ixl_set_link_status(sc, iaq);
KERNEL_UNLOCK();
mtx_enter(&sc->sc_link_state_mtx); mtx_enter(&sc->sc_link_state_mtx);
if (ifp->if_link_state != link_state) { if (ifp->if_link_state != link_state) {
ifp->if_link_state = link_state; ifp->if_link_state = link_state;
@ -4468,9 +4468,6 @@ ixl_set_link_status(struct ixl_softc *sc, const struct ixl_aq_desc *iaq)
{ {
const struct ixl_aq_link_status *status; const struct ixl_aq_link_status *status;
const struct ixl_phy_type *itype; const struct ixl_phy_type *itype;
KERNEL_ASSERT_LOCKED();
uint64_t ifm_active = IFM_ETHER; uint64_t ifm_active = IFM_ETHER;
uint64_t ifm_status = IFM_AVALID; uint64_t ifm_status = IFM_AVALID;
int link_state = LINK_STATE_DOWN; int link_state = LINK_STATE_DOWN;
@ -4496,9 +4493,11 @@ ixl_set_link_status(struct ixl_softc *sc, const struct ixl_aq_desc *iaq)
baudrate = ixl_search_link_speed(status->link_speed); baudrate = ixl_search_link_speed(status->link_speed);
done: done:
mtx_enter(&sc->sc_link_state_mtx);
sc->sc_media_active = ifm_active; sc->sc_media_active = ifm_active;
sc->sc_media_status = ifm_status; sc->sc_media_status = ifm_status;
sc->sc_ac.ac_if.if_baudrate = baudrate; sc->sc_ac.ac_if.if_baudrate = baudrate;
mtx_leave(&sc->sc_link_state_mtx);
return (link_state); return (link_state);
} }