Module Name: src Committed By: msaitoh Date: Mon Aug 8 08:55:43 UTC 2022
Modified Files: src/sys/dev/pci: if_wm.c Log Message: To avoid releasing mutex temporally, use new wm_set_mdio_slow_mode_hv_locked(). To generate a diff of this commit: cvs rdiff -u -r1.756 -r1.757 src/sys/dev/pci/if_wm.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/dev/pci/if_wm.c diff -u src/sys/dev/pci/if_wm.c:1.756 src/sys/dev/pci/if_wm.c:1.757 --- src/sys/dev/pci/if_wm.c:1.756 Mon Aug 8 08:52:36 2022 +++ src/sys/dev/pci/if_wm.c Mon Aug 8 08:55:42 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: if_wm.c,v 1.756 2022/08/08 08:52:36 msaitoh Exp $ */ +/* $NetBSD: if_wm.c,v 1.757 2022/08/08 08:55:42 msaitoh Exp $ */ /* * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc. @@ -82,7 +82,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.756 2022/08/08 08:52:36 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.757 2022/08/08 08:55:42 msaitoh Exp $"); #ifdef _KERNEL_OPT #include "opt_net_mpsafe.h" @@ -1119,6 +1119,7 @@ static int wm_k1_gig_workaround_hv(struc static int wm_k1_workaround_lv(struct wm_softc *); static int wm_link_stall_workaround_hv(struct wm_softc *); static int wm_set_mdio_slow_mode_hv(struct wm_softc *); +static int wm_set_mdio_slow_mode_hv_locked(struct wm_softc *); static void wm_configure_k1_ich8lan(struct wm_softc *, int); static void wm_reset_init_script_82575(struct wm_softc *); static void wm_reset_mdicnfg_82580(struct wm_softc *); @@ -17136,13 +17137,32 @@ static int wm_set_mdio_slow_mode_hv(struct wm_softc *sc) { int rv; + + rv = sc->phy.acquire(sc); + if (rv != 0) { + device_printf(sc->sc_dev, "%s: failed to get semaphore\n", + __func__); + return rv; + } + + rv = wm_set_mdio_slow_mode_hv_locked(sc); + + sc->phy.release(sc); + + return rv; +} + +static int +wm_set_mdio_slow_mode_hv_locked(struct wm_softc *sc) +{ + int rv; uint16_t reg; - rv = wm_gmii_hv_readreg(sc->sc_dev, 1, HV_KMRN_MODE_CTRL, ®); + rv = wm_gmii_hv_readreg_locked(sc->sc_dev, 1, HV_KMRN_MODE_CTRL, ®); if (rv != 0) return rv; - return wm_gmii_hv_writereg(sc->sc_dev, 1, HV_KMRN_MODE_CTRL, + return wm_gmii_hv_writereg_locked(sc->sc_dev, 1, HV_KMRN_MODE_CTRL, reg | HV_KMRN_MDIO_SLOW); } @@ -17290,11 +17310,11 @@ wm_phy_is_accessible_pchlan(struct wm_so */ rv = 0; if (sc->sc_type < WM_T_PCH_LPT) { - sc->phy.release(sc); - wm_set_mdio_slow_mode_hv(sc); - rv = wm_gmii_hv_readreg(sc->sc_dev, 2, MII_PHYIDR1, &id1); - rv |= wm_gmii_hv_readreg(sc->sc_dev, 2, MII_PHYIDR2, &id2); - sc->phy.acquire(sc); + wm_set_mdio_slow_mode_hv_locked(sc); + rv = wm_gmii_hv_readreg_locked(sc->sc_dev, 2, MII_PHYIDR1, + &id1); + rv |= wm_gmii_hv_readreg_locked(sc->sc_dev, 2, MII_PHYIDR2, + &id2); } if ((rv != 0) || MII_INVALIDID(id1) || MII_INVALIDID(id2)) { device_printf(sc->sc_dev, "XXX return with false\n");