git: mrsas(4): Fix lost wakeups by restoring two wait queues
Aaron LI
aly at crater.dragonflybsd.org
Thu Oct 15 17:57:28 PDT 2026
commit fdfb91da8b6b1e38f33a717e044483bcb04ebfc9
Author: Aaron LI <aly at aaronly.me>
Date: Thu Oct 15 20:07:18 2026 +0800
mrsas(4): Fix lost wakeups by restoring two wait queues
mrsas(4) is a port of the Linux megaraid_sas driver (see e.g. v3.13).
The port translated Linux's wake_up(), which wakes every non-exclusive
waiters on a wait queue, as wakeup_one(), which wakes only one. It also
collapsed Linux driver's two wait queues ('int_cmd_wait_q' for internal
DCMDs and 'abort_cmd_wait_q' for aborts) into the single 'sc->chan'
channel.
Both loops wait on a per-command predicate (cmd->cmd_status), so a
single wakeup on a shared channel can wake the wrong thread and drop the
wakeup for the command that actually completed. With two blocked
commands outstanding, one of them then times out after
MRSAS_INTERNAL_CMD_WAIT_TIME even though it completed.
Fix the problem by correct the two porting issues:
* internal DCMDs continue to use 'sc->int_chan' that is renamed from
'sc->chan', woken by mrsas_wakeup();
* aborts use a new 'sc->abort_chan', woken by mrsas_complete_abort();
* both use wakeup(), matching the original Linux's wake_up() semantics.
In addition, remove the meaniningless 'sc->chan = (void *)&cmd'
assignments. This also fixes the following '-Wdangling-pointer'
warnings from GCC 12.5. Also change the channel type from 'void *' to
'u_int8_t' since only its address in the struct matters, so this makes
the dangling-pointer class of bug structurally impossible.
```
/usr/src/sys/dev/raid/mrsas/mrsas.c: In function 'mrsas_issue_blocked_cmd':
/usr/src/sys/dev/raid/mrsas/mrsas.c:2880:14: warning: storing the address of local variable 'cmd' in '*sc.chan' [-Wdangling-pointer=]
2880 | sc->chan = (void*)&cmd;
| ~~~~~~~~~^~~~~~~~~~~~~
/usr/src/sys/dev/raid/mrsas/mrsas.c:2865:75: note: 'cmd' declared here
2865 | int mrsas_issue_blocked_cmd(struct mrsas_softc *sc, struct mrsas_mfi_cmd *cmd)
| ~~~~~~~~~~~~~~~~~~~~~~^~~
/usr/src/sys/dev/raid/mrsas/mrsas.c:2865:75: note: 'sc' declared here
```
Assisted-by: DeepSeek-v4.1-flash (with Pi Coding Agent)
Summary of changes:
sys/dev/raid/mrsas/mrsas.c | 20 ++++----------------
sys/dev/raid/mrsas/mrsas.h | 5 +++--
2 files changed, 7 insertions(+), 18 deletions(-)
http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/fdfb91da8b6b1e38f33a717e044483bcb04ebfc9
--
DragonFly BSD source repository
More information about the Commits
mailing list