Linux block layer
 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
                   ` (4 more replies)
  0 siblings, 5 replies; 8+ 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] 8+ messages in thread

* [PATCH v2 1/3] mtip32xx: initialize svc_wait right after allocating the port
  2026-12-01 17:56 [PATCH v2 0/3] mtip32xx: fix surprise removal handling Bart Van Assche
@ 2026-12-01 17:56 ` 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
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: Bart Van Assche @ 2026-12-01 17:56 UTC (permalink / raw)
  To: Jens Axboe; +Cc: linux-block, Bart Van Assche, Sam Bradshaw, Asai Thambi S P

mtip_hw_init() initializes port->svc_wait only after it has requested the
interrupt and enabled interrupts on the HBA. The interrupt handler wakes
port->svc_wait, e.g. from mtip_process_errors(), so an interrupt that
arrives in between wakes an uninitialized waitqueue.

Initialize the waitqueue immediately after allocating dd->port, before
anything can reach it.

Fixes: 60ec0eecfa89 ("mtip32xx: updates based on feedback")
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/block/mtip32xx/mtip32xx.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/block/mtip32xx/mtip32xx.c b/drivers/block/mtip32xx/mtip32xx.c
index 0d71abbc334e..aa44b13d506b 100644
--- a/drivers/block/mtip32xx/mtip32xx.c
+++ b/drivers/block/mtip32xx/mtip32xx.c
@@ -2726,6 +2726,8 @@ static int mtip_hw_init(struct driver_data *dd)
 	if (!dd->port)
 		return -ENOMEM;
 
+	init_waitqueue_head(&dd->port->svc_wait);
+
 	/* Continue workqueue setup */
 	for (i = 0; i < MTIP_MAX_SLOT_GROUPS; i++)
 		dd->work[i].port = dd->port;
@@ -2815,8 +2817,6 @@ static int mtip_hw_init(struct driver_data *dd)
 	writel(readl(dd->mmio + HOST_CTL) | HOST_IRQ_EN,
 					dd->mmio + HOST_CTL);
 
-	init_waitqueue_head(&dd->port->svc_wait);
-
 	if (test_bit(MTIP_DDF_REMOVE_PENDING_BIT, &dd->dd_flag)) {
 		rv = -EFAULT;
 		goto out3;

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

* [PATCH v2 2/3] mtip32xx: don't mark the disk dead in the irq handler
  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 ` Bart Van Assche
  2026-12-01 17:56 ` [PATCH v2 3/3] mtip32xx: abort commands in flight on surprise removal Bart Van Assche
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: Bart Van Assche @ 2026-12-01 17:56 UTC (permalink / raw)
  To: Jens Axboe
  Cc: linux-block, Bart Van Assche, Josef Bacik, Dave Chinner,
	Christian Brauner, Jan Kara

mtip_check_surprise_removal() calls blk_mark_disk_dead() from the
interrupt handler, which acquires bd_holder_lock and calls into the
holder, which may sleep.

Only record the removal in mtip_check_surprise_removal(): replace the
unsynchronized bool dd->sr with MTIP_DDF_DEAD_BIT so new commands fail
immediately, and wake the service thread with MTIP_PF_SR_BIT. In
mtip_exec_internal_command(), reset int_cmd->status before calling
blk_execute_rq() and treat a non-zero return value as a failure too, since
rejecting a reserved command with BLK_STS_IOERR leaves int_cmd->status
untouched.

In mtip_handle_surprise_removal(), quiesce the queue, wait for the
interrupt handler with synchronize_irq(), flush isr_workq, abort commands
in flight through blk_mq_complete_request(), unquiesce the queue, and only
then mark the disk dead. Doing this in that order matters because
blk_mark_disk_dead() acquires s_umount of a mounted filesystem, whose
holder may be waiting for those commands. 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.
If MTIP_DDF_REMOVE_PENDING_BIT is set, wait for in-progress
mtip_queue_rq() calls with synchronize_rcu() instead of quiescing and
unquiescing the queue, and skip blk_mark_disk_dead() because
mtip_pci_remove() is already tearing down the disk.

Fixes: f55e017c6420 ("block: add a mark_dead holder operation")
Reported-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/block/mtip32xx/mtip32xx.c | 65 +++++++++++++++++++++++++------
 drivers/block/mtip32xx/mtip32xx.h |  9 +++--
 2 files changed, 60 insertions(+), 14 deletions(-)

diff --git a/drivers/block/mtip32xx/mtip32xx.c b/drivers/block/mtip32xx/mtip32xx.c
index aa44b13d506b..24cef62136f1 100644
--- a/drivers/block/mtip32xx/mtip32xx.c
+++ b/drivers/block/mtip32xx/mtip32xx.c
@@ -134,15 +134,17 @@ static bool mtip_check_surprise_removal(struct driver_data *dd)
 {
 	u16 vendor_id = 0;
 
-	if (dd->sr)
+	if (test_bit(MTIP_DDF_DEAD_BIT, &dd->dd_flag))
 		return true;
 
        /* Read the vendorID from the configuration space */
 	pci_read_config_word(dd->pdev, 0x00, &vendor_id);
 	if (vendor_id == 0xFFFF) {
-		dd->sr = true;
-		if (dd->disk)
-			blk_mark_disk_dead(dd->disk);
+		set_bit(MTIP_DDF_DEAD_BIT, &dd->dd_flag);
+		if (dd->port) {
+			set_bit(MTIP_PF_SR_BIT, &dd->port->flags);
+			wake_up_interruptible(&dd->port->svc_wait);
+		}
 		return true; /* device removed */
 	}
 
@@ -998,14 +1000,13 @@ static int mtip_exec_internal_command(struct mtip_port *port,
 	/* Copy the command to the command table */
 	int_cmd = blk_mq_rq_to_pdu(rq);
 	int_cmd->icmd = &icmd;
+	int_cmd->status = BLK_STS_OK;
 	memcpy(int_cmd->command, fis, fis_len*4);
 
 	rq->timeout = timeout;
 
 	/* insert request and run queue */
-	blk_execute_rq(rq, true);
-
-	if (int_cmd->status) {
+	if (blk_execute_rq(rq, true) || int_cmd->status) {
 		dev_err(&dd->pdev->dev, "Internal command [%02X] failed %d\n",
 				fis->command, int_cmd->status);
 		rv = -EIO;
@@ -2439,8 +2440,11 @@ static bool mtip_abort_cmd(struct request *req, void *data)
 	dbg_printk(MTIP_DRV_NAME " Aborting request, tag = %d\n", req->tag);
 
 	clear_bit(req->tag, dd->port->cmds_to_issue);
+	if (blk_mq_request_completed(req))
+		return true;
+
 	cmd->status = BLK_STS_IOERR;
-	mtip_softirq_done_fn(req);
+	blk_mq_complete_request(req);
 	return true;
 }
 
@@ -2453,6 +2457,31 @@ static bool mtip_queue_cmd(struct request *req, void *data)
 	return true;
 }
 
+static void mtip_handle_surprise_removal(struct driver_data *dd)
+{
+	bool removing = test_bit(MTIP_DDF_REMOVE_PENDING_BIT, &dd->dd_flag);
+
+	if (dd->queue) {
+		if (!removing)
+			blk_mq_quiesce_queue(dd->queue);
+		else
+			synchronize_rcu();
+
+		synchronize_irq(dd->pdev->irq);
+		if (dd->isr_workq)
+			flush_workqueue(dd->isr_workq);
+
+		blk_mq_tagset_busy_iter(&dd->tags, mtip_abort_cmd, dd);
+
+		if (!removing)
+			blk_mq_unquiesce_queue(dd->queue);
+	}
+	if (!removing &&
+	    test_bit(MTIP_DDF_INIT_DONE_BIT, &dd->dd_flag) &&
+	    !test_and_set_bit(MTIP_DDF_DISK_DEAD_BIT, &dd->dd_flag))
+		blk_mark_disk_dead(dd->disk);
+}
+
 /*
  * service thread to issue queued commands
  *
@@ -2492,6 +2521,15 @@ static int mtip_service_thread(void *data)
 
 		set_bit(MTIP_PF_SVC_THD_ACTIVE_BIT, &port->flags);
 
+		if (test_and_clear_bit(MTIP_PF_SR_BIT, &port->flags)) {
+			mtip_handle_surprise_removal(dd);
+			clear_bit(MTIP_PF_EH_ACTIVE_BIT, &port->flags);
+			clear_bit(MTIP_PF_TO_ACTIVE_BIT, &port->flags);
+			clear_bit(MTIP_PF_ISSUE_CMDS_BIT, &port->flags);
+			clear_bit(MTIP_PF_REBUILD_BIT, &port->flags);
+			continue;
+		}
+
 restart_eh:
 		/* Demux bits: start with error handling */
 		if (test_bit(MTIP_PF_EH_ACTIVE_BIT, &port->flags)) {
@@ -2848,7 +2886,7 @@ static int mtip_standby_drive(struct driver_data *dd)
 {
 	int rv = 0;
 
-	if (dd->sr || !dd->port)
+	if (test_bit(MTIP_DDF_DEAD_BIT, &dd->dd_flag) || !dd->port)
 		return -ENODEV;
 	/*
 	 * Send standby immediate (E0h) to the drive so that it
@@ -2875,7 +2913,7 @@ static int mtip_standby_drive(struct driver_data *dd)
  */
 static int mtip_hw_exit(struct driver_data *dd)
 {
-	if (!dd->sr) {
+	if (!test_bit(MTIP_DDF_DEAD_BIT, &dd->dd_flag)) {
 		/* de-initialize the port. */
 		mtip_deinit_port(dd->port);
 
@@ -3241,6 +3279,8 @@ static inline bool is_stopped(struct driver_data *dd, struct request *rq)
 		return true;
 	if (test_bit(MTIP_DDF_REBUILD_FAILED_BIT, &dd->dd_flag))
 		return true;
+	if (test_bit(MTIP_DDF_DEAD_BIT, &dd->dd_flag))
+		return true;
 
 	return false;
 }
@@ -3279,6 +3319,9 @@ static blk_status_t mtip_issue_reserved_cmd(struct blk_mq_hw_ctx *hctx,
 		dd->port->command_list + sizeof(struct mtip_cmd_hdr) * rq->tag;
 	struct mtip_cmd_sg *command_sg;
 
+	if (test_bit(MTIP_DDF_DEAD_BIT, &dd->dd_flag))
+		return BLK_STS_IOERR;
+
 	if (mtip_commands_active(dd->port))
 		return BLK_STS_DEV_RESOURCE;
 
@@ -3905,7 +3948,7 @@ static void mtip_pci_remove(struct pci_dev *pdev)
 		kthread_stop(dd->mtip_svc_handler);
 	}
 
-	if (!dd->sr) {
+	if (!test_bit(MTIP_DDF_DEAD_BIT, &dd->dd_flag)) {
 		/*
 		 * Explicitly wait here for IOs to quiesce,
 		 * as mtip_standby_drive usually won't wait for IOs.
diff --git a/drivers/block/mtip32xx/mtip32xx.h b/drivers/block/mtip32xx/mtip32xx.h
index 0963c07b5845..5bc86363a4c7 100644
--- a/drivers/block/mtip32xx/mtip32xx.h
+++ b/drivers/block/mtip32xx/mtip32xx.h
@@ -134,11 +134,13 @@ enum {
 	MTIP_PF_ISSUE_CMDS_BIT      = 5,
 	MTIP_PF_REBUILD_BIT         = 6,
 	MTIP_PF_SVC_THD_STOP_BIT    = 8,
+	MTIP_PF_SR_BIT              = 11, /* surprise removal seen */
 
 	MTIP_PF_SVC_THD_WORK	= ((1 << MTIP_PF_EH_ACTIVE_BIT) |
 				  (1 << MTIP_PF_ISSUE_CMDS_BIT) |
 				  (1 << MTIP_PF_REBUILD_BIT) |
 				  (1 << MTIP_PF_SVC_THD_STOP_BIT) |
+				  (1 << MTIP_PF_SR_BIT) |
 				  (1 << MTIP_PF_TO_ACTIVE_BIT)),
 
 	/* below are bit numbers in 'dd_flag' defined in driver_data */
@@ -150,12 +152,15 @@ enum {
 	MTIP_DDF_RESUME_BIT         = 6,
 	MTIP_DDF_INIT_DONE_BIT      = 7,
 	MTIP_DDF_REBUILD_FAILED_BIT = 8,
+	MTIP_DDF_DEAD_BIT           = 9,
+	MTIP_DDF_DISK_DEAD_BIT      = 10,
 
 	MTIP_DDF_STOP_IO      = ((1 << MTIP_DDF_REMOVE_PENDING_BIT) |
 				(1 << MTIP_DDF_SEC_LOCK_BIT) |
 				(1 << MTIP_DDF_OVER_TEMP_BIT) |
 				(1 << MTIP_DDF_WRITE_PROTECT_BIT) |
-				(1 << MTIP_DDF_REBUILD_FAILED_BIT)),
+				(1 << MTIP_DDF_REBUILD_FAILED_BIT) |
+				(1 << MTIP_DDF_DEAD_BIT)),
 
 };
 
@@ -449,8 +454,6 @@ struct driver_data {
 
 	struct dentry *dfs_node;
 
-	bool sr;
-
 	int numa_node; /* NUMA support */
 
 	char workq_name[32];

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

* [PATCH v2 3/3] mtip32xx: abort commands in flight on surprise removal
  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 ` Bart Van Assche
  2026-12-01 18:48 ` [PATCH v2 0/3] mtip32xx: fix surprise removal handling Jens Axboe
  2026-12-02  6:27 ` Christoph Hellwig
  4 siblings, 0 replies; 8+ messages in thread
From: Bart Van Assche @ 2026-12-01 17:56 UTC (permalink / raw)
  To: Jens Axboe; +Cc: linux-block, Bart Van Assche, Josef Bacik, Hannes Reinecke

mtip_pci_remove() relies on blk_mark_disk_dead(), which only stops new
IO. del_gendisk() waits for the requests the driver still owns, and
nothing completes them for a removed device: the service thread exits as
soon as it sees MTIP_DDF_REMOVE_PENDING_BIT. The removal hangs.

Keep the service thread running until kthread_stop() after del_gendisk()
so it handles a removal seen while the disk is being deleted. Add
dd->sr_mutex and hold it across mtip_handle_surprise_removal() to
serialize the service thread against mtip_pci_remove(). In
mtip_pci_remove(), abort the commands in flight via
mtip_handle_surprise_removal() if MTIP_DDF_DEAD_BIT is already set, and
otherwise acquire and release dd->sr_mutex before calling del_gendisk()
to wait for any in-flight mtip_handle_surprise_removal() call that started
before MTIP_DDF_REMOVE_PENDING_BIT was set. Drop MTIP_PF_REBUILD_BIT once
removal is pending or mtip_ftl_rebuild_poll() returns <= 0 instead of
looping on it.

Fixes: e8b58ef09e84 ("mtip32xx: fix device removal")
Reported-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/block/mtip32xx/mtip32xx.c | 26 ++++++++++++++++++++------
 drivers/block/mtip32xx/mtip32xx.h |  1 +
 2 files changed, 21 insertions(+), 6 deletions(-)

diff --git a/drivers/block/mtip32xx/mtip32xx.c b/drivers/block/mtip32xx/mtip32xx.c
index 24cef62136f1..2b8a60e35d56 100644
--- a/drivers/block/mtip32xx/mtip32xx.c
+++ b/drivers/block/mtip32xx/mtip32xx.c
@@ -2459,7 +2459,10 @@ static bool mtip_queue_cmd(struct request *req, void *data)
 
 static void mtip_handle_surprise_removal(struct driver_data *dd)
 {
-	bool removing = test_bit(MTIP_DDF_REMOVE_PENDING_BIT, &dd->dd_flag);
+	bool removing;
+
+	guard(mutex)(&dd->sr_mutex);
+	removing = test_bit(MTIP_DDF_REMOVE_PENDING_BIT, &dd->dd_flag);
 
 	if (dd->queue) {
 		if (!removing)
@@ -2515,10 +2518,6 @@ static int mtip_service_thread(void *data)
 			test_bit(MTIP_PF_SVC_THD_STOP_BIT, &port->flags))
 			goto st_out;
 
-		if (unlikely(test_bit(MTIP_DDF_REMOVE_PENDING_BIT,
-				&dd->dd_flag)))
-			goto st_out;
-
 		set_bit(MTIP_PF_SVC_THD_ACTIVE_BIT, &port->flags);
 
 		if (test_and_clear_bit(MTIP_PF_SR_BIT, &port->flags)) {
@@ -2599,7 +2598,9 @@ static int mtip_service_thread(void *data)
 		}
 
 		if (test_bit(MTIP_PF_REBUILD_BIT, &port->flags)) {
-			if (mtip_ftl_rebuild_poll(dd) == 0)
+			if (test_bit(MTIP_DDF_REMOVE_PENDING_BIT,
+				     &dd->dd_flag) ||
+			    mtip_ftl_rebuild_poll(dd) <= 0)
 				clear_bit(MTIP_PF_REBUILD_BIT, &port->flags);
 		}
 	}
@@ -3769,6 +3770,7 @@ static int mtip_pci_probe(struct pci_dev *pdev,
 	if (!dd)
 		return -ENOMEM;
 	mutex_init(&dd->ioctl_mutex);
+	mutex_init(&dd->sr_mutex);
 
 	/* Attach the private data to this PCI device.  */
 	pci_set_drvdata(pdev, dd);
@@ -3937,6 +3939,18 @@ static void mtip_pci_remove(struct pci_dev *pdev)
 	set_bit(MTIP_DDF_REMOVE_PENDING_BIT, &dd->dd_flag);
 	mutex_lock(&dd->ioctl_mutex);
 
+	/*
+	 * Wait for any in-flight mtip_handle_surprise_removal() to complete
+	 * before del_gendisk() tears down the queue, and abort any remaining
+	 * requests if surprise removal was already detected.
+	 */
+	if (test_bit(MTIP_DDF_DEAD_BIT, &dd->dd_flag)) {
+		mtip_handle_surprise_removal(dd);
+	} else {
+		mutex_lock(&dd->sr_mutex);
+		mutex_unlock(&dd->sr_mutex);
+	}
+
 	if (test_bit(MTIP_DDF_INIT_DONE_BIT, &dd->dd_flag))
 		del_gendisk(dd->disk);
 
diff --git a/drivers/block/mtip32xx/mtip32xx.h b/drivers/block/mtip32xx/mtip32xx.h
index 5bc86363a4c7..6e8ea053d0b2 100644
--- a/drivers/block/mtip32xx/mtip32xx.h
+++ b/drivers/block/mtip32xx/mtip32xx.h
@@ -439,6 +439,7 @@ struct driver_data {
 
 	struct blk_mq_tag_set tags; /* blk_mq tags */
 	struct mutex ioctl_mutex;
+	struct mutex sr_mutex;
 
 	struct mtip_port *port; /* Pointer to the port data structure. */
 

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

* Re: [PATCH v2 0/3] mtip32xx: fix surprise removal handling
  2026-12-01 17:56 [PATCH v2 0/3] mtip32xx: fix surprise removal handling Bart Van Assche
                   ` (2 preceding siblings ...)
  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 ` Jens Axboe
  2026-12-02  6:27 ` Christoph Hellwig
  4 siblings, 0 replies; 8+ messages in thread
From: Jens Axboe @ 2026-12-01 18:48 UTC (permalink / raw)
  To: Bart Van Assche; +Cc: linux-block


On Tue, 01 Dec 2026 09:56:08 -0800, Bart Van Assche wrote:
> 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.
> 
> [...]

Applied, thanks!

[1/3] mtip32xx: initialize svc_wait right after allocating the port
      commit: d1b361cdd61f4857abb5def5dfc1c07b23368bd1
[2/3] mtip32xx: don't mark the disk dead in the irq handler
      commit: 6d1ba6900cae67d3f28ef07384bd1117f4c4ec0d
[3/3] mtip32xx: abort commands in flight on surprise removal
      commit: 56a097bbf6aee4377f831787b115d1cd58672bd2

Best regards,
-- 
Jens Axboe




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

* Re: [PATCH v2 0/3] mtip32xx: fix surprise removal handling
  2026-12-01 17:56 [PATCH v2 0/3] mtip32xx: fix surprise removal handling Bart Van Assche
                   ` (3 preceding siblings ...)
  2026-12-01 18:48 ` [PATCH v2 0/3] mtip32xx: fix surprise removal handling Jens Axboe
@ 2026-12-02  6:27 ` Christoph Hellwig
  2026-12-02 15:11   ` Bart Van Assche
  2026-12-02 16:03   ` Jens Axboe
  4 siblings, 2 replies; 8+ messages in thread
From: Christoph Hellwig @ 2026-12-02  6:27 UTC (permalink / raw)
  To: Bart Van Assche; +Cc: Jens Axboe, linux-block

On Tue, Dec 01, 2026 at 09:56:08AM -0800, Bart Van Assche wrote:
> Compile-tested only (x86_64, LLVM=1 W=1 with CONFIG_WERROR=y).

Does anyone actually still have this hardware and cares about it?
The driver is pretty bad, and times of all the LLM fixes it would
be great to kill it.  Users could still use the hardware in AHCI
mode (with a potentially big performance degradation).


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

* Re: [PATCH v2 0/3] mtip32xx: fix surprise removal handling
  2026-12-02  6:27 ` Christoph Hellwig
@ 2026-12-02 15:11   ` Bart Van Assche
  2026-12-02 16:03   ` Jens Axboe
  1 sibling, 0 replies; 8+ messages in thread
From: Bart Van Assche @ 2026-12-02 15:11 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: Jens Axboe, linux-block

On 12/1/26 10:27 PM, Christoph Hellwig wrote:
> On Tue, Dec 01, 2026 at 09:56:08AM -0800, Bart Van Assche wrote:
>> Compile-tested only (x86_64, LLVM=1 W=1 with CONFIG_WERROR=y).
> 
> Does anyone actually still have this hardware and cares about it?
> The driver is pretty bad, and times of all the LLM fixes it would
> be great to kill it.  Users could still use the hardware in AHCI
> mode (with a potentially big performance degradation).

+1 for removing the mtip32xx driver. I tried to ask an LLM to identify
and fix all bugs in this driver and it came up with a series of more
than hundred patches. I think this confirms what Christoph wrote,
namely that the quality of the mtip32xx driver is low.

Thanks,

Bart.



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

* Re: [PATCH v2 0/3] mtip32xx: fix surprise removal handling
  2026-12-02  6:27 ` Christoph Hellwig
  2026-12-02 15:11   ` Bart Van Assche
@ 2026-12-02 16:03   ` Jens Axboe
  1 sibling, 0 replies; 8+ messages in thread
From: Jens Axboe @ 2026-12-02 16:03 UTC (permalink / raw)
  To: Christoph Hellwig, Bart Van Assche; +Cc: linux-block

On 12/1/26 11:27 PM, Christoph Hellwig wrote:
> On Tue, Dec 01, 2026 at 09:56:08AM -0800, Bart Van Assche wrote:
>> Compile-tested only (x86_64, LLVM=1 W=1 with CONFIG_WERROR=y).
> 
> Does anyone actually still have this hardware and cares about it?
> The driver is pretty bad, and times of all the LLM fixes it would
> be great to kill it.  Users could still use the hardware in AHCI
> mode (with a potentially big performance degradation).

Agree it's a pretty shit driver. I have probably 8 of these cards!
Since it's a root only kind of thing, I'm not too worried about it.

-- 
Jens Axboe


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

end of thread, other threads:[~2026-12-02 16:03 UTC | newest]

Thread overview: 8+ 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
2026-12-02  6:27 ` Christoph Hellwig
2026-12-02 15:11   ` Bart Van Assche
2026-12-02 16:03   ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox