summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authormsaitoh <msaitoh@NetBSD.org>2022-08-08 08:55:42 +0000
committermsaitoh <msaitoh@NetBSD.org>2022-08-08 08:55:42 +0000
commit8dbd40cd66a7bad4cf58a98f609a2ea808b5d252 (patch)
tree8dc80b1b99570de9a30775d21dc1a26dee4a3a5c /sys/dev
parenta1af0be65277aad5c94372fc4796840d5aa6505f (diff)
To avoid releasing mutex temporally, use new wm_set_mdio_slow_mode_hv_locked().
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/pci/if_wm.c38
1 files changed, 29 insertions, 9 deletions
diff --git a/sys/dev/pci/if_wm.c b/sys/dev/pci/if_wm.c
index a6317545da7..79b470d7273 100644
--- a/sys/dev/pci/if_wm.c
+++ b/sys/dev/pci/if_wm.c
@@ -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(struct wm_softc *, int);
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, &reg);
+ rv = wm_gmii_hv_readreg_locked(sc->sc_dev, 1, HV_KMRN_MODE_CTRL, &reg);
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_softc *sc)
*/
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");