aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/mpr
diff options
context:
space:
mode:
authorAlexander Motin <mav@FreeBSD.org>2021-09-14 21:37:02 +0000
committerAlexander Motin <mav@FreeBSD.org>2021-09-14 21:40:32 +0000
commit02d8194012a9a0e367a92c7f89567b808bf0e9a8 (patch)
tree052b1077f4b7bc1fc32cd7ef5f6019407181cc45 /sys/dev/mpr
parent5dc5f849be9047309d32c4df8e7ee617c27ec43f (diff)
downloadsrc-02d8194012a9a0e367a92c7f89567b808bf0e9a8.tar.gz
src-02d8194012a9a0e367a92c7f89567b808bf0e9a8.zip
mps/mpr(4): Move xpt_register_async() out of lock.
It fixes lock ordere reversal between SIM and device locks. Also remove registration for AC_FOUND_DEVICE, unused for a while now. MFC after: 1 month
Diffstat (limited to 'sys/dev/mpr')
-rw-r--r--sys/dev/mpr/mpr_sas.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/sys/dev/mpr/mpr_sas.c b/sys/dev/mpr/mpr_sas.c
index a8bb7c90b5c4..9b69e0654ae4 100644
--- a/sys/dev/mpr/mpr_sas.c
+++ b/sys/dev/mpr/mpr_sas.c
@@ -821,6 +821,8 @@ mpr_attach_sas(struct mpr_softc *sc)
callout_init(&sassc->discovery_callout, 1 /*mpsafe*/);
+ mpr_unlock(sc);
+
/*
* Register for async events so we can determine the EEDP
* capabilities of devices.
@@ -835,7 +837,7 @@ mpr_attach_sas(struct mpr_softc *sc)
} else {
int event;
- event = AC_ADVINFO_CHANGED | AC_FOUND_DEVICE;
+ event = AC_ADVINFO_CHANGED;
status = xpt_register_async(event, mprsas_async, sc,
sassc->path);
@@ -855,8 +857,6 @@ mpr_attach_sas(struct mpr_softc *sc)
mpr_printf(sc, "EEDP capabilities disabled.\n");
}
- mpr_unlock(sc);
-
mprsas_register_events(sc);
out:
if (error)
@@ -890,12 +890,6 @@ mpr_detach_sas(struct mpr_softc *sc)
if (sassc->ev_tq != NULL)
taskqueue_free(sassc->ev_tq);
- /* Make sure CAM doesn't wedge if we had to bail out early. */
- mpr_lock(sc);
-
- while (sassc->startup_refcount != 0)
- mprsas_startup_decrement(sassc);
-
/* Deregister our async handler */
if (sassc->path != NULL) {
xpt_register_async(0, mprsas_async, sc, sassc->path);
@@ -903,6 +897,12 @@ mpr_detach_sas(struct mpr_softc *sc)
sassc->path = NULL;
}
+ /* Make sure CAM doesn't wedge if we had to bail out early. */
+ mpr_lock(sc);
+
+ while (sassc->startup_refcount != 0)
+ mprsas_startup_decrement(sassc);
+
if (sassc->flags & MPRSAS_IN_STARTUP)
xpt_release_simq(sassc->sim, 1);
@@ -3326,6 +3326,7 @@ mprsas_async(void *callback_arg, uint32_t code, struct cam_path *path,
sc = (struct mpr_softc *)callback_arg;
+ mpr_lock(sc);
switch (code) {
case AC_ADVINFO_CHANGED: {
struct mprsas_target *target;
@@ -3413,10 +3414,10 @@ mprsas_async(void *callback_arg, uint32_t code, struct cam_path *path,
}
break;
}
- case AC_FOUND_DEVICE:
default:
break;
}
+ mpr_unlock(sc);
}
/*