All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/3] mtip32xx: fix surprise removal handling
@ 2026-12-01 17:56 Bart Van Assche
  2026-12-01 17:56 ` [PATCH v2 1/3] mtip32xx: initialize svc_wait right after allocating the port Bart Van Assche
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Bart Van Assche @ 2026-12-01 17:56 UTC (permalink / raw)
  To: Jens Axboe; +Cc: linux-block, Bart Van Assche

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(-)


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-12-01 18:48 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-01 17:56 [PATCH v2 0/3] mtip32xx: fix surprise removal handling Bart Van Assche
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
2026-12-01 18:48 ` [PATCH v2 0/3] mtip32xx: fix surprise removal handling Jens Axboe

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.