* [PATCH v3 0/3] scsi: mvumi: do not free or reuse buffers a timed-out command left with the device
@ 2026-11-17 13:42 Yehyeong Lee
2026-11-17 13:42 ` [PATCH v3 1/3] scsi: mvumi: stop the controller bus-mastering before freeing its buffers Yehyeong Lee
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Yehyeong Lee @ 2026-11-17 13:42 UTC (permalink / raw)
To: mkp, James.Bottomley; +Cc: linux-scsi, linux-kernel, zilin
1/3 stops bus-mastering before mvumi_detach_one() frees the buffers the
controller was given. 2/3 keeps a timed-out internal command's buffers
until then and stops the probe loop from reusing them. 3/3 waits for
the event work before the host is freed.
v2 -> v3, from the Sashiko review of v2:
- 2/3: free the mhba_dev_list entries an aborted probe leaves behind.
- 3/3: clear bus-mastering before mvumi_release_fw() on the probe error
path.
Left for separate patches: the DMA address rebuilt in
mvumi_delete_internal_cmd(), which 7/9 of the series below removes; the
unlocked sync_cmd test in mvumi_issue_blocked_cmd(); and the same
bus-mastering order in mvumi_init_fw()'s error path.
https://lore.kernel.org/all/20261015045213.3975845-1-yhlee@isslab.korea.ac.kr/
This conflicts with that 7/9 only in 2/3; I will rebase whichever goes
in second. I have no mvumi hardware; this was checked with a KUnit
model.
v1:
https://lore.kernel.org/all/20261114014430.489668-1-yhlee@isslab.korea.ac.kr/
v2:
https://lore.kernel.org/all/20261115122153.1446810-1-yhlee@isslab.korea.ac.kr/
Best regards,
Yehyeong Lee
Yehyeong Lee (3):
scsi: mvumi: stop the controller bus-mastering before freeing its
buffers
scsi: mvumi: quarantine a timed-out internal command's buffers
scsi: mvumi: flush the event work before the host is freed
drivers/scsi/mvumi.c | 97 ++++++++++++++++++++++++++++++++++++--------
drivers/scsi/mvumi.h | 3 ++
2 files changed, 84 insertions(+), 16 deletions(-)
base-commit: 23c62304dde29abe92013d85910d03a77dada35d
--
2.43.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v3 1/3] scsi: mvumi: stop the controller bus-mastering before freeing its buffers
2026-11-17 13:42 [PATCH v3 0/3] scsi: mvumi: do not free or reuse buffers a timed-out command left with the device Yehyeong Lee
@ 2026-11-17 13:42 ` Yehyeong Lee
2026-11-17 13:42 ` [PATCH v3 2/3] scsi: mvumi: quarantine a timed-out internal command's buffers Yehyeong Lee
2026-11-17 13:42 ` [PATCH v3 3/3] scsi: mvumi: flush the event work before the host is freed Yehyeong Lee
2 siblings, 0 replies; 6+ messages in thread
From: Yehyeong Lee @ 2026-11-17 13:42 UTC (permalink / raw)
To: mkp, James.Bottomley; +Cc: linux-scsi, linux-kernel, zilin
mvumi_detach_one() frees the controller's buffers before stopping its DMA:
mvumi_release_fw(mhba); /* frees them */
scsi_host_put(host);
pci_disable_device(pdev); /* stops the DMA */
mvumi_release_fw() frees everything on mhba->res_list and the handshake
page. The controller is given those addresses during the handshake and
may read or write them for as long as it is bus-mastering, and only
pci_disable_device() stops that.
Disable the device first. Nothing in mvumi_release_fw() needs it
enabled: it contains no ioread32() or iowrite32() at all.
I have no mvumi hardware.
Fixes: f0c568a478f0 ("[SCSI] mvumi: Add Marvell UMI driver")
Signed-off-by: Yehyeong Lee <yhlee@isslab.korea.ac.kr>
---
drivers/scsi/mvumi.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/scsi/mvumi.c b/drivers/scsi/mvumi.c
index 91c2db697c6913..8d22d370d8608f 100644
--- a/drivers/scsi/mvumi.c
+++ b/drivers/scsi/mvumi.c
@@ -2548,9 +2548,9 @@ static void mvumi_detach_one(struct pci_dev *pdev)
mhba->instancet->disable_intr(mhba);
free_irq(mhba->pdev->irq, mhba);
+ pci_disable_device(pdev);
mvumi_release_fw(mhba);
scsi_host_put(host);
- pci_disable_device(pdev);
dev_dbg(&pdev->dev, "driver is removed!\n");
}
--
2.43.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v3 2/3] scsi: mvumi: quarantine a timed-out internal command's buffers
2026-11-17 13:42 [PATCH v3 0/3] scsi: mvumi: do not free or reuse buffers a timed-out command left with the device Yehyeong Lee
2026-11-17 13:42 ` [PATCH v3 1/3] scsi: mvumi: stop the controller bus-mastering before freeing its buffers Yehyeong Lee
@ 2026-11-17 13:42 ` Yehyeong Lee
2026-11-17 13:42 ` [PATCH v3 3/3] scsi: mvumi: flush the event work before the host is freed Yehyeong Lee
2 siblings, 0 replies; 6+ messages in thread
From: Yehyeong Lee @ 2026-11-17 13:42 UTC (permalink / raw)
To: mkp, James.Bottomley; +Cc: linux-scsi, linux-kernel, zilin
mvumi_issue_blocked_cmd() gives up on an internal command after 45
seconds and returns 0, as on success, without aborting it on the
controller. The callers then free the command frame and data buffer in
mvumi_delete_internal_cmd(), although the controller still holds both
addresses and can write into them when it answers late.
Put both buffers on mhba->res_list instead, so that they are freed at
unload, after the preceding patch has stopped bus-mastering. The cost
is one or two buffers per timed-out command until unload.
mvumi_probe_devices() uses one command for every target id, so after a
timeout the next inquiry would hand the same buffers back to the
controller. Stop the loop there and return -1; mvumi_rescan_bus()
retries on the next event. Both -1 exits now share one exit, which also
frees the command the duplicate-wwid exit leaked (posted on its own by
Zilin Guan [1]) and the mhba_dev_list entries that mvumi_rescan_bus()
drains only on success.
Checked with a KUnit model, without mvumi hardware: a late write to the
buffers gives a KASAN use-after-free in 5 of 5 runs without this patch
and in none of 5 with it. The reuse after a timeout, the leaked command
and the stranded list entries go from 5 of 5 to none of 5 as well.
[1] https://lore.kernel.org/all/20251113150934.758067-1-zilin@seu.edu.cn/
Fixes: f0c568a478f0 ("[SCSI] mvumi: Add Marvell UMI driver")
Signed-off-by: Yehyeong Lee <yhlee@isslab.korea.ac.kr>
---
drivers/scsi/mvumi.c | 80 ++++++++++++++++++++++++++++++++++++--------
drivers/scsi/mvumi.h | 1 +
2 files changed, 67 insertions(+), 14 deletions(-)
diff --git a/drivers/scsi/mvumi.c b/drivers/scsi/mvumi.c
index 8d22d370d8608f..fe3f63a1088dc1 100644
--- a/drivers/scsi/mvumi.c
+++ b/drivers/scsi/mvumi.c
@@ -177,6 +177,29 @@ static void mvumi_release_mem_resource(struct mvumi_hba *mhba)
mhba->fw_flag &= ~MVUMI_FW_ALLOC;
}
+/* The controller may still DMA here; free it once the device is disabled. */
+static void mvumi_quarantine_buf(struct mvumi_hba *mhba, void *virt_addr,
+ dma_addr_t bus_addr, unsigned int size)
+{
+ struct mvumi_res *res = kzalloc_obj(*res);
+ unsigned long flags;
+
+ if (!res) {
+ dev_err(&mhba->pdev->dev,
+ "leaking %u bytes the controller may still write to\n",
+ size);
+ return;
+ }
+ res->type = RESOURCE_UNCACHED_MEMORY;
+ res->virt_addr = virt_addr;
+ res->bus_addr = bus_addr;
+ res->size = size;
+ INIT_LIST_HEAD(&res->entry);
+ spin_lock_irqsave(&mhba->shost->host_lock, flags);
+ list_add_tail(&res->entry, &mhba->res_list);
+ spin_unlock_irqrestore(&mhba->shost->host_lock, flags);
+}
+
/**
* mvumi_make_sgl - Prepares SGL
* @mhba: Adapter soft state
@@ -298,11 +321,19 @@ static void mvumi_delete_internal_cmd(struct mvumi_hba *mhba,
phy_addr = (dma_addr_t) m_sg->baseaddr_l |
(dma_addr_t) ((m_sg->baseaddr_h << 16) << 16);
- dma_free_coherent(&mhba->pdev->dev, size, cmd->data_buf,
- phy_addr);
+ if (cmd->timed_out)
+ mvumi_quarantine_buf(mhba, cmd->data_buf,
+ phy_addr, size);
+ else
+ dma_free_coherent(&mhba->pdev->dev, size,
+ cmd->data_buf, phy_addr);
}
- dma_free_coherent(&mhba->pdev->dev, mhba->ib_max_size,
- cmd->frame, cmd->frame_phys);
+ if (cmd->timed_out)
+ mvumi_quarantine_buf(mhba, cmd->frame, cmd->frame_phys,
+ mhba->ib_max_size);
+ else
+ dma_free_coherent(&mhba->pdev->dev, mhba->ib_max_size,
+ cmd->frame, cmd->frame_phys);
kfree(cmd);
}
}
@@ -734,6 +765,7 @@ static int mvumi_issue_blocked_cmd(struct mvumi_hba *mhba,
if (atomic_read(&cmd->sync_cmd)) {
spin_lock_irqsave(&mhba->shost->host_lock, flags);
atomic_dec(&cmd->sync_cmd);
+ cmd->timed_out = 1;
if (mhba->tag_cmd[cmd->frame->tag]) {
mhba->tag_cmd[cmd->frame->tag] = NULL;
dev_warn(&mhba->pdev->dev, "TIMEOUT:release tag [%d]\n",
@@ -1458,6 +1490,18 @@ static u64 mvumi_inquiry(struct mvumi_hba *mhba,
return wwid;
}
+static void mvumi_free_dev_list(struct mvumi_hba *mhba, struct list_head *head)
+{
+ struct mvumi_device *mv_dev, *dev_next;
+
+ list_for_each_entry_safe(mv_dev, dev_next, head, list) {
+ list_del_init(&mv_dev->list);
+ dev_dbg(&mhba->pdev->dev, "release device(0:%d:0) wwid(%llx)\n",
+ mv_dev->id, mv_dev->wwid);
+ kfree(mv_dev);
+ }
+}
+
static void mvumi_detach_devices(struct mvumi_hba *mhba)
{
struct mvumi_device *mv_dev = NULL , *dev_next;
@@ -1474,12 +1518,7 @@ static void mvumi_detach_devices(struct mvumi_hba *mhba)
mv_dev->id, mv_dev->wwid);
kfree(mv_dev);
}
- list_for_each_entry_safe(mv_dev, dev_next, &mhba->mhba_dev_list, list) {
- list_del_init(&mv_dev->list);
- dev_dbg(&mhba->pdev->dev, "release device(0:%d:0) wwid(%llx)\n",
- mv_dev->id, mv_dev->wwid);
- kfree(mv_dev);
- }
+ mvumi_free_dev_list(mhba, &mhba->mhba_dev_list);
/* detach virtual device */
if (mhba->pdev->device == PCI_DEVICE_ID_MARVELL_MV9580)
@@ -1552,6 +1591,7 @@ static int mvumi_probe_devices(struct mvumi_hba *mhba)
struct mvumi_device *mv_dev = NULL;
struct mvumi_cmd *cmd = NULL;
int found = 0;
+ int ret;
cmd = mvumi_create_internal_cmd(mhba, 64);
if (!cmd)
@@ -1564,6 +1604,11 @@ static int mvumi_probe_devices(struct mvumi_hba *mhba)
for (id = 0; id < maxid; id++) {
wwid = mvumi_inquiry(mhba, id, cmd);
+ /* the controller still owns this command's buffers */
+ if (cmd->timed_out) {
+ ret = -1;
+ goto out;
+ }
if (!wwid) {
/* device no response, remove it */
mvumi_remove_devices(mhba, id);
@@ -1588,17 +1633,24 @@ static int mvumi_probe_devices(struct mvumi_hba *mhba)
dev_dbg(&mhba->pdev->dev,
"probe a new device(0:%d:0)"
" wwid(%llx)\n", id, mv_dev->wwid);
- } else if (found == -1)
- return -1;
- else
+ } else if (found == -1) {
+ ret = -1;
+ goto out;
+ } else {
continue;
+ }
}
}
+ ret = 0;
+out:
if (cmd)
mvumi_delete_internal_cmd(mhba, cmd);
+ /* mvumi_rescan_bus() only drains this list when we return 0 */
+ if (ret)
+ mvumi_free_dev_list(mhba, &mhba->mhba_dev_list);
- return 0;
+ return ret;
}
static int mvumi_rescan_bus(void *data)
diff --git a/drivers/scsi/mvumi.h b/drivers/scsi/mvumi.h
index 1306a4abf19ad2..e248dfc1dd1bb7 100644
--- a/drivers/scsi/mvumi.h
+++ b/drivers/scsi/mvumi.h
@@ -252,6 +252,7 @@ struct mvumi_cmd {
void *data_buf;
unsigned short request_id;
unsigned char cmd_status;
+ unsigned char timed_out;
};
struct mvumi_cmd_priv {
--
2.43.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v3 3/3] scsi: mvumi: flush the event work before the host is freed
2026-11-17 13:42 [PATCH v3 0/3] scsi: mvumi: do not free or reuse buffers a timed-out command left with the device Yehyeong Lee
2026-11-17 13:42 ` [PATCH v3 1/3] scsi: mvumi: stop the controller bus-mastering before freeing its buffers Yehyeong Lee
2026-11-17 13:42 ` [PATCH v3 2/3] scsi: mvumi: quarantine a timed-out internal command's buffers Yehyeong Lee
@ 2026-11-17 13:42 ` Yehyeong Lee
2026-11-17 13:57 ` sashiko-bot
2 siblings, 1 reply; 6+ messages in thread
From: Yehyeong Lee @ 2026-11-17 13:42 UTC (permalink / raw)
To: mkp, James.Bottomley; +Cc: linux-scsi, linux-kernel, zilin
mvumi_launch_events() queues mvumi_scan_events() on the system workqueue
from the interrupt handler. The work dereferences the mvumi_hba and can
wait up to 45 seconds for an internal command, but mvumi_detach_one()
frees the interrupt and calls scsi_host_put(), which frees the
mvumi_hba, without waiting for it.
Give the driver its own workqueue and destroy it in mvumi_detach_one()
after free_irq(), so the work has finished before the host is freed.
mvumi_probe_one() can fail in mvumi_io_attach() with the interrupt
already enabled, so flush the queue there as well after free_irq().
Also clear bus-mastering before mvumi_release_fw() on that path, because
pci_disable_device() runs further down and must not be called twice.
In a KUnit model where the event command is left unanswered and the host
is put during the wait, the work reads the freed host in 5 of 5 runs
without this patch and in none of 5 with it:
[ 107.519931] BUG: KASAN: slab-use-after-free in mvumi_scan_events+0xc83/0xd10
[ 107.519976] Read of size 8 at addr ffff88800a0d8908 by task kworker/0:0/10
[ 107.520007]
[ 107.520033] CPU: 0 UID: 0 PID: 10 Comm: kworker/0:0 Tainted: G B N 7.4.0-rc2-00716-g23c62304dde2-dirty #1 PREEMPT(lazy)
[ 107.520086] Tainted: [B]=BAD_PAGE, [N]=TEST
[ 107.520103] Hardware name: QEMU Ubuntu 24.04 PC v2 (i440FX + PIIX, arch_caps fix, 1996), BIOS 1.16.3-debian-1.16.3-2 04/01/2014
[ 107.520128] Workqueue: events mvumi_scan_events
[ 107.520173] Call Trace:
[ 107.520200] <TASK>
[ 107.520220] dump_stack_lvl+0x53/0x70
[ 107.520290] print_report+0xd0/0x630
[ 107.520356] ? __pfx__raw_spin_lock_irqsave+0x10/0x10
[ 107.520400] ? mvumi_issue_blocked_cmd.isra.0+0x62b/0x940
[ 107.520493] ? mvumi_scan_events+0xc83/0xd10
[ 107.520569] kasan_report+0xe5/0x120
[ 107.520650] ? mvumi_scan_events+0xc83/0xd10
[ 107.520730] mvumi_scan_events+0xc83/0xd10
[ 107.520800] process_one_work+0x697/0x1060
[ 107.520920] ? __pfx___schedule+0x10/0x10
[ 107.520976] ? __pfx_process_one_work+0x10/0x10
[ 107.521032] ? _raw_spin_lock_irq+0x81/0xe0
[ 107.521111] ? __pfx_mvumi_scan_events+0x10/0x10
[ 107.521159] ? assign_work+0x11d/0x370
[ 107.521222] worker_thread+0x45b/0xd10
[ 107.521304] ? __pfx_worker_thread+0x10/0x10
[ 107.521357] kthread+0x2c8/0x3b0
[ 107.521435] ? recalc_sigpending+0x15c/0x1e0
[ 107.521515] ? __pfx_kthread+0x10/0x10
[ 107.521564] ret_from_fork+0x36e/0x5a0
[ 107.521612] ? __pfx_ret_from_fork+0x10/0x10
[ 107.521672] ? __switch_to+0xac3/0xdc0
[ 107.521738] ? __switch_to_asm+0x33/0x70
[ 107.521793] ? __pfx_kthread+0x10/0x10
[ 107.521860] ret_from_fork_asm+0x1a/0x30
[ 107.521922] </TASK>
[ 107.521951]
[ 107.521987] Allocated by task 84:
[ 107.522047] kasan_save_stack+0x33/0x60
[ 107.522101] kasan_save_track+0x14/0x30
[ 107.522179] __kasan_kmalloc+0x8f/0xa0
[ 107.522259] __kmalloc_noprof+0x193/0x450
[ 107.522291] scsi_host_alloc+0x29/0x1290
[ 107.522374] mvt_setup+0x14e/0xa50
[ 107.522441] mvt_event_work_after_put+0x93/0x3f0
[ 107.522475] kunit_try_run_case+0x1ad/0x490
[ 107.522544] kunit_generic_run_threadfn_adapter+0x7b/0xe0
[ 107.522643] kthread+0x2c8/0x3b0
[ 107.522704] ret_from_fork+0x36e/0x5a0
[ 107.522787] ret_from_fork_asm+0x1a/0x30
[ 107.522855]
[ 107.522880] Freed by task 84:
[ 107.522898] kasan_save_stack+0x33/0x60
[ 107.522974] kasan_save_track+0x14/0x30
[ 107.523086] kasan_save_free_info+0x3b/0x60
[ 107.523140] __kasan_slab_free+0x43/0x70
[ 107.523198] kfree+0x121/0x390
[ 107.523275] device_release+0xc8/0x240
[ 107.523349] kobject_put+0x14d/0x280
[ 107.523383] mvt_event_work_after_put+0x22f/0x3f0
[ 107.523459] kunit_try_run_case+0x1ad/0x490
[ 107.523523] kunit_generic_run_threadfn_adapter+0x7b/0xe0
[ 107.523576] kthread+0x2c8/0x3b0
[ 107.523638] ret_from_fork+0x36e/0x5a0
[ 107.523724] ret_from_fork_asm+0x1a/0x30
[ 107.523762]
[ 107.523803] The buggy address belongs to the object at ffff88800a0d8000
[ 107.523803] which belongs to the cache kmalloc-4k of size 4096
[ 107.523833] The buggy address is located 2312 bytes inside of
[ 107.523833] freed 4096-byte region [ffff88800a0d8000, ffff88800a0d9000)
[ 107.523880]
[ 107.523929] The buggy address belongs to the physical page:
[ 107.523978] page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0xa0d8
[ 107.524037] head: order:3 mapcount:0 entire_mapcount:0 nr_pages_mapped:0 pincount:0
[ 107.524111] flags: 0x100000000000040(head|node=0|zone=1)
[ 107.524155] page_type: f5(slab)
[ 107.524248] raw: 0100000000000040 ffff888007042140 dead000000000122 0000000000000000
[ 107.524319] raw: 0000000000000000 0000000000040004 00000000f5000000 0000000000000000
[ 107.524422] head: 0100000000000040 ffff888007042140 dead000000000122 0000000000000000
[ 107.524457] head: 0000000000000000 0000000000040004 00000000f5000000 0000000000000000
[ 107.524543] head: 0100000000000003 fffffffffffffe01 00000000ffffffff 00000000ffffffff
[ 107.524592] head: 0000000000000000 0000000000000000 00000000ffffffff 0000000000000000
[ 107.524625] page dumped because: kasan: bad access detected
[ 107.524660]
[ 107.524681] Memory state around the buggy address:
[ 107.524725] ffff88800a0d8800: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
[ 107.524772] ffff88800a0d8880: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
[ 107.524817] >ffff88800a0d8900: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
[ 107.524862] ^
[ 107.524927] ffff88800a0d8980: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
[ 107.525003] ffff88800a0d8a00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
[ 107.525025] ==================================================================
Fixes: f0c568a478f0 ("[SCSI] mvumi: Add Marvell UMI driver")
Signed-off-by: Yehyeong Lee <yhlee@isslab.korea.ac.kr>
---
drivers/scsi/mvumi.c | 15 ++++++++++++++-
drivers/scsi/mvumi.h | 2 ++
2 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/drivers/scsi/mvumi.c b/drivers/scsi/mvumi.c
index fe3f63a1088dc1..79086e2dd22e39 100644
--- a/drivers/scsi/mvumi.c
+++ b/drivers/scsi/mvumi.c
@@ -1807,7 +1807,7 @@ static void mvumi_launch_events(struct mvumi_hba *mhba, u32 isr_status)
mu_ev->event = APICDB1_EVENT_GETEVENT;
isr_status &= ~(DRBL_EVENT_NOTIFY);
mu_ev->param = NULL;
- schedule_work(&mu_ev->work_q);
+ queue_work(mhba->work_q, &mu_ev->work_q);
}
}
}
@@ -2544,6 +2544,13 @@ static int mvumi_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
mhba->shost = host;
mhba->unique_id = pci_dev_id(pdev);
+ mhba->work_q = alloc_workqueue("mvumi_wq_%d", WQ_PERCPU, 0,
+ host->host_no);
+ if (!mhba->work_q) {
+ ret = -ENOMEM;
+ goto fail_alloc_workqueue;
+ }
+
ret = mvumi_init_fw(mhba);
if (ret)
goto fail_init_fw;
@@ -2570,9 +2577,14 @@ static int mvumi_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
fail_io_attach:
mhba->instancet->disable_intr(mhba);
free_irq(mhba->pdev->irq, mhba);
+ flush_workqueue(mhba->work_q);
fail_init_irq:
+ /* mvumi_release_fw() frees buffers the controller was given */
+ pci_clear_master(pdev);
mvumi_release_fw(mhba);
fail_init_fw:
+ destroy_workqueue(mhba->work_q);
+fail_alloc_workqueue:
scsi_host_put(host);
fail_alloc_instance:
@@ -2600,6 +2612,7 @@ static void mvumi_detach_one(struct pci_dev *pdev)
mhba->instancet->disable_intr(mhba);
free_irq(mhba->pdev->irq, mhba);
+ destroy_workqueue(mhba->work_q);
pci_disable_device(pdev);
mvumi_release_fw(mhba);
scsi_host_put(host);
diff --git a/drivers/scsi/mvumi.h b/drivers/scsi/mvumi.h
index e248dfc1dd1bb7..04cd844851423e 100644
--- a/drivers/scsi/mvumi.h
+++ b/drivers/scsi/mvumi.h
@@ -493,6 +493,8 @@ struct mvumi_hba {
atomic_t fw_outstanding;
struct mvumi_instance_template *instancet;
+ struct workqueue_struct *work_q;
+
void *ib_list;
dma_addr_t ib_list_phys;
--
2.43.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v3 3/3] scsi: mvumi: flush the event work before the host is freed
2026-11-17 13:42 ` [PATCH v3 3/3] scsi: mvumi: flush the event work before the host is freed Yehyeong Lee
@ 2026-11-17 13:57 ` sashiko-bot
2026-11-17 14:05 ` Yehyeong Lee
0 siblings, 1 reply; 6+ messages in thread
From: sashiko-bot @ 2026-11-17 13:57 UTC (permalink / raw)
To: Yehyeong Lee; +Cc: linux-scsi
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] scsi: mvumi: 45s hang draining work_q after free_irq() in
probe and detach
--
commit fea1f9d38eeeed5d46b0fb512a378a51f64fd086
Author: Yehyeong Lee <yhlee@isslab.korea.ac.kr>
scsi: mvumi: flush the event work before the host is freed
This commit gives mvumi its own per-HBA workqueue for event notifications
and drains or destroys it on probe failure and device removal before the
host is freed.
> diff --git a/drivers/scsi/mvumi.c b/drivers/scsi/mvumi.c
> index fe3f63a1088dc..79086e2dd22e3 100644
> --- a/drivers/scsi/mvumi.c
> +++ b/drivers/scsi/mvumi.c
[ ... ]
> @@ -2570,9 +2577,14 @@ static int mvumi_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
> fail_io_attach:
> mhba->instancet->disable_intr(mhba);
> free_irq(mhba->pdev->irq, mhba);
> + flush_workqueue(mhba->work_q);
> fail_init_irq:
> + /* mvumi_release_fw() frees buffers the controller was given */
> + pci_clear_master(pdev);
> mvumi_release_fw(mhba);
> fail_init_fw:
> + destroy_workqueue(mhba->work_q);
> +fail_alloc_workqueue:
> scsi_host_put(host);
>
> fail_alloc_instance:
> @@ -2600,6 +2612,7 @@ static void mvumi_detach_one(struct pci_dev *pdev)
>
> mhba->instancet->disable_intr(mhba);
> free_irq(mhba->pdev->irq, mhba);
> + destroy_workqueue(mhba->work_q);
> pci_disable_device(pdev);
> mvumi_release_fw(mhba);
> scsi_host_put(host);
[Severity: Medium]
Does draining mhba->work_q after disable_intr() and free_irq() cause a
45-second hang when an event work item is pending or in flight?
mvumi_scan_events() calls mvumi_get_event() -> mvumi_issue_blocked_cmd(),
which waits on mhba->int_cmd_wait_q for MVUMI_INTERNAL_CMD_WAIT_TIME * HZ
(45 seconds). That wait queue is only woken by mvumi_complete_internal_cmd()
from mvumi_isr_handler(). Because interrupts have already been masked and
freed in both fail_io_attach and mvumi_detach_one(), any queued
mvumi_scan_events() work item cannot receive its completion interrupt and
blocks until the 45-second timeout expires. In mvumi_detach_one(), a
pending work item will also submit a new APICDB0_EVENT command after
mvumi_flush_cache() has already sent CDB_CORE_SHUTDOWN.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261117134227.2077013-1-yhlee@isslab.korea.ac.kr?part=3
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v3 3/3] scsi: mvumi: flush the event work before the host is freed
2026-11-17 13:57 ` sashiko-bot
@ 2026-11-17 14:05 ` Yehyeong Lee
0 siblings, 0 replies; 6+ messages in thread
From: Yehyeong Lee @ 2026-11-17 14:05 UTC (permalink / raw)
To: sashiko-bot; +Cc: mkp, James.Bottomley, linux-scsi, linux-kernel, zilin
The wait is real. An event work that is still queued or running once
the interrupt is gone can only finish by timing out, so
mvumi_detach_one() and the mvumi_io_attach() failure path can take up
to 45 seconds when an event is outstanding. The work items run
concurrently on the per-CPU queue, so that is one timeout, not one per
event. Without this patch the same work runs on the freed host instead.
The APICDB0_EVENT after CDB_CORE_SHUTDOWN is not new: without this patch
the event work can submit it at any point during or after
mvumi_detach_one().
Both go away if removal first stops the work from issuing commands and
drains it before disable_intr(), so that a command in flight still gets
its interrupt. I will send that as a separate patch on top of this
series rather than respin it.
Best regards,
Yehyeong Lee
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-11-17 14:05 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-17 13:42 [PATCH v3 0/3] scsi: mvumi: do not free or reuse buffers a timed-out command left with the device Yehyeong Lee
2026-11-17 13:42 ` [PATCH v3 1/3] scsi: mvumi: stop the controller bus-mastering before freeing its buffers Yehyeong Lee
2026-11-17 13:42 ` [PATCH v3 2/3] scsi: mvumi: quarantine a timed-out internal command's buffers Yehyeong Lee
2026-11-17 13:42 ` [PATCH v3 3/3] scsi: mvumi: flush the event work before the host is freed Yehyeong Lee
2026-11-17 13:57 ` sashiko-bot
2026-11-17 14:05 ` Yehyeong Lee
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.