From: Bart Van Assche <bvanassche@acm.org>
To: Jens Axboe <axboe@kernel.dk>
Cc: linux-block@vger.kernel.org, Bart Van Assche <bvanassche@acm.org>
Subject: [PATCH v2 0/3] mtip32xx: fix surprise removal handling
Date: Tue, 1 Dec 2026 09:56:08 -0800 [thread overview]
Message-ID: <cover.1796147092.git.bvanassche@acm.org> (raw)
Hi Jens,
This series fixes an initialization order issue and two surprise removal
bugs in the mtip32xx driver:
1. Initialize port->svc_wait immediately after allocating dd->port in
mtip_hw_init(), before requesting the interrupt and enabling
HOST_IRQ_EN, so early interrupts cannot wake an uninitialized
waitqueue.
2. Avoid calling blk_mark_disk_dead() from interrupt context in
mtip_check_surprise_removal(). Record the removal with
MTIP_DDF_DEAD_BIT, wake the service thread with MTIP_PF_SR_BIT, abort
in-flight commands via blk_mq_complete_request(), and mark the disk
dead only afterward so holder callbacks acquiring s_umount cannot
deadlock waiting on those commands.
3. Keep the service thread running across del_gendisk() and abort
in-flight commands from mtip_pci_remove() if surprise removal has
already occurred, preventing del_gendisk() from hanging indefinitely.
Compile-tested only (x86_64, LLVM=1 W=1 with CONFIG_WERROR=y).
Please consider these two patches for the next merge window.
Thanks,
Bart.
Changes compared to v1:
- Add patch 1/3 to initialize port->svc_wait immediately after allocating
dd->port so mtip_check_surprise_removal() cannot wake an uninitialized
waitqueue during mtip_hw_init().
- Place mtip_handle_surprise_removal() above the mtip_service_thread()
function comment instead of between that comment and the function.
- Replace the unsynchronized bool dd->sr with MTIP_DDF_DEAD_BIT across
mtip_check_surprise_removal(), mtip_standby_drive(), mtip_hw_exit(),
and mtip_pci_remove(), and remove dd->sr from struct driver_data.
- Initialize int_cmd->status to BLK_STS_OK and check the return value of
blk_execute_rq() in mtip_exec_internal_command() so direct
BLK_STS_IOERR returns on MTIP_DDF_DEAD_BIT are not ignored or
misreported using stale status.
- Clear the tag bit in port->cmds_to_issue before testing
blk_mq_request_completed() in mtip_abort_cmd() so no stale bit remains
for an already completed request.
- Call synchronize_irq() and flush dd->isr_workq in
mtip_handle_surprise_removal() before iterating busy tags to abort
in-flight commands, preventing races with concurrent completions.
- When MTIP_DDF_REMOVE_PENDING_BIT is set in
mtip_handle_surprise_removal(), wait for in-progress mtip_queue_rq()
calls with synchronize_rcu() instead of quiescing and unquiescing the
queue, and skip blk_mark_disk_dead() while mtip_pci_remove() tears down
the disk.
- Serialize mtip_handle_surprise_removal() with a new dd->sr_mutex
initialized in mtip_pci_probe().
- In mtip_pci_remove(), call mtip_handle_surprise_removal() whenever
MTIP_DDF_DEAD_BIT is set (instead of only when dd->sr &&
!dd->mtip_svc_handler), and otherwise lock and unlock dd->sr_mutex
before del_gendisk() to wait for any in-flight
mtip_handle_surprise_removal() that started before
MTIP_DDF_REMOVE_PENDING_BIT was set.
- Add my Signed-off-by tag to all patches.
Bart Van Assche (3):
mtip32xx: initialize svc_wait right after allocating the port
mtip32xx: don't mark the disk dead in the irq handler
mtip32xx: abort commands in flight on surprise removal
drivers/block/mtip32xx/mtip32xx.c | 93 +++++++++++++++++++++++++------
drivers/block/mtip32xx/mtip32xx.h | 10 +++-
2 files changed, 82 insertions(+), 21 deletions(-)
next reply other threads:[~2026-12-01 17:56 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-01 17:56 Bart Van Assche [this message]
2026-12-01 17:56 ` [PATCH v2 1/3] mtip32xx: initialize svc_wait right after allocating the port Bart Van Assche
2026-12-01 17:56 ` [PATCH v2 2/3] mtip32xx: don't mark the disk dead in the irq handler Bart Van Assche
2026-12-01 17:56 ` [PATCH v2 3/3] mtip32xx: abort commands in flight on surprise removal Bart Van Assche
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=cover.1796147092.git.bvanassche@acm.org \
--to=bvanassche@acm.org \
--cc=axboe@kernel.dk \
--cc=linux-block@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox