HomeFreeBSD

mpi3mr: Don't hold fwevt_lock over call to taskqueue_drain

Description

mpi3mr: Don't hold fwevt_lock over call to taskqueue_drain

Holding fwevt_lock when we call taskqueue_drain can lead to deadlock
because it's draining a queue needs fwevt_lock to do work, so that other
thread will try to take out the lock and block, making the thread never
finish and taskqueue_drain never complete. There's a witness
warning/error for this which was exposed when the lock was converted to
a MTX_DEF lock from a MTX_SPIN prior to committing to the FreeBSD tree.

The lock appears to be to protect against additional items being added
to the event list while we're doing a reset. Since the taskqueue is
blocked, items can get added to the list, but won't be processed during
the reset, but there is still a (likely small) race between the
taskqueue_drain and the taskqueue_block calls where an interrupt could
fire on another CPU, resulting in a task being enqueued and started
before the block can take effect. The only way to fix that race is to
turn off interrupt processing during a reset. So we replace a deadlock
with a smaller race.

Sponsored by: Netflix
Reviewed by: sumit.saxena_broadcom.com, mav, jhb
Differential Revision: https://reviews.freebsd.org/D42537

(cherry picked from commit b411372b7d17ae7e5d6c944732d41b979bde2ac4)

Details

Provenance
impAuthored on Nov 29 2023, 1:48 AM
mavCommitted on Jan 19 2024, 5:16 PM
Reviewer
sumit.saxena_broadcom.com
Differential Revision
D42537: mpi3mr: Don't hold fwevt_lock over call to taskqueue_drain
Parents
rG4f30677080c3: ispfw(4): Update and add firmware
Branches
Unknown
Tags
Unknown