Re: [PATCH 3/4] nvme-apple: move blk_mq_update_nr_hw_queues after nvme_unfreeze
From: Yu Kuai <hidden>
Date: 2026-02-10 06:47:59
Also in:
asahi, linux-block, linux-nvme
Hi, 在 2026/2/9 23:35, Keith Busch 写道:
On Mon, Feb 09, 2026 at 03:58:32PM +0100, Christoph Hellwig wrote:quoted
On Mon, Feb 09, 2026 at 04:29:52PM +0800, Yu Kuai wrote:quoted
blk_mq_update_nr_hw_queues() freezes and unfreezes queues internally. When the queue is already frozen before this call (from nvme_start_freeze in apple_nvme_disable), the freeze depth becomes 2. The internal unfreeze only decrements it to 1, leaving the queue still frozen when debugfs_create_files() is called. This triggers WARN_ON_ONCE(q->mq_freeze_depth != 0) in debugfs_create_files() and risks deadlock. Fix this by moving nvme_unfreeze() before blk_mq_update_nr_hw_queues() so the queue is unfrozen before the call, allowing the internal freeze/unfreeze to work correctly. Signed-off-by: Yu Kuai <redacted> --- drivers/nvme/host/apple.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)diff --git a/drivers/nvme/host/apple.c b/drivers/nvme/host/apple.c index 15b3d07f8ccd..1835753ad91a 100644 --- a/drivers/nvme/host/apple.c +++ b/drivers/nvme/host/apple.c@@ -1202,8 +1202,8 @@ static void apple_nvme_reset_work(struct work_struct *work) nvme_unquiesce_io_queues(&anv->ctrl); nvme_wait_freeze(&anv->ctrl); - blk_mq_update_nr_hw_queues(&anv->tagset, 1); nvme_unfreeze(&anv->ctrl); + blk_mq_update_nr_hw_queues(&anv->tagset, 1);Looks good on it's own, but it would also good to align the apple driver with the PCI one here more.I'm pretty sure this series would deadlock nvme-pci, as that driver still leaves the queue frozen when calling blk_mq_update_nr_hw_queues.
Yeah, thanks for the letting me know. It's true I didn't realize nvme-pci still leaves the queue frozen.
We've left it frozen on purpose, though. The idea was to prevent new IO from entering a hw context that's no longer backed by a hardware resourse. Unfreezing prior opens that window up again. Maybe it's not a big deal; I don't often encounter scenarios where the queue count changes after a reset.
Do you think if there are new IO coming between nvme_unfreeze() and blk_mq_update_nr_hw_queues(), will be any race problems? If so, will it be helpful to move nvme_unquiesce_io_queues() after blk_mq_update_nr_hw_queues() so that new IO won't be issued to driver during the race window. I'm not quite familiar with nvme drivers, details will be quite helpful. :) -- Thansk, Kuai