public inbox for linux-block@vger.kernel.org
 help / color / mirror / Atom feed
From: Nilay Shroff <nilay@linux.ibm.com>
To: Keith Busch <kbusch@kernel.org>, Christoph Hellwig <hch@lst.de>
Cc: Yu Kuai <yukuai@fnnas.com>,
	axboe@kernel.dk, sagi@grimberg.me, sven@kernel.org, j@jannau.net,
	linux-block@vger.kernel.org, linux-nvme@lists.infradead.org,
	tj@kernel.org, ming.lei@redhat.com, neal@gompa.dev,
	asahi@lists.linux.dev, linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH 3/4] nvme-apple: move blk_mq_update_nr_hw_queues after nvme_unfreeze
Date: Tue, 10 Feb 2026 13:40:54 +0530	[thread overview]
Message-ID: <ac55db2a-ab90-460d-9efa-e13c5a3f498d@linux.ibm.com> (raw)
In-Reply-To: <aYn-xwFHCpd7sITJ@kbusch-mbp>



On 2/9/26 9:05 PM, Keith Busch wrote:
> On Mon, Feb 09, 2026 at 03:58:32PM +0100, Christoph Hellwig wrote:
>> On Mon, Feb 09, 2026 at 04:29:52PM +0800, Yu Kuai wrote:
>>> 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 <yukuai@fnnas.com>
>>> ---
>>>  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.
> 
> 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.

If an I/O were to slip through during the brief window between unfreeze
and the subsequent freeze inside blk_mq_update_nr_hw_queues(), wouldn’t
it still fail because the NVMe queues have already been suspended earlier
in the reset path? My understanding is that when the controller reset
reduces the number of online NVMe queues, the queues that are no longer
backed by hardware remain in the suspended state. As a result, any I/O
that reaches them before nr_hw_queues is updated should be rejected in
nvme_queue_rq(). And if that’s the case, then allowing a small unfreeze
window before updating the nr_hw_queue count shouldn’t result in a deadlock.
What do you think?

Thanks,
--Nilay


  parent reply	other threads:[~2026-02-10  8:11 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-09  8:29 [PATCH 0/4] blk-mq/nvme: fix debugfs creation with frozen queue Yu Kuai
2026-02-09  8:29 ` [PATCH 1/4] nvme-rdma: move blk_mq_update_nr_hw_queues after nvme_unfreeze Yu Kuai
2026-02-09 14:57   ` Christoph Hellwig
2026-02-11  7:21   ` Nilay Shroff
2026-02-09  8:29 ` [PATCH 2/4] nvme-tcp: " Yu Kuai
2026-02-09 14:57   ` Christoph Hellwig
2026-02-11  7:22   ` Nilay Shroff
2026-02-09  8:29 ` [PATCH 3/4] nvme-apple: " Yu Kuai
2026-02-09 14:58   ` Christoph Hellwig
2026-02-09 15:35     ` Keith Busch
2026-02-10  6:47       ` Yu Kuai
2026-02-10 15:09         ` Keith Busch
2026-02-10 15:41           ` Christoph Hellwig
2026-02-10 16:01             ` Keith Busch
2026-02-10 16:28               ` Daniel Wagner
2026-02-11  1:57                 ` Yu Kuai
2026-02-11 12:57                   ` Keith Busch
2026-02-10  8:10       ` Nilay Shroff [this message]
2026-02-10 15:12         ` Keith Busch
2026-02-11  7:23   ` Nilay Shroff
2026-02-09  8:29 ` [PATCH 4/4] blk-mq: use blk_queue_enter/exit to protect debugfs file creation Yu Kuai
2026-02-09 14:59   ` Christoph Hellwig
2026-02-09 16:40   ` Bart Van Assche
2026-02-09 17:33     ` Keith Busch
2026-02-09 17:51       ` Bart Van Assche
2026-02-10  6:59         ` Yu Kuai
2026-02-10 15:41       ` Christoph Hellwig
2026-02-11  7:20   ` Nilay Shroff
2026-02-11  8:06     ` Yu Kuai

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=ac55db2a-ab90-460d-9efa-e13c5a3f498d@linux.ibm.com \
    --to=nilay@linux.ibm.com \
    --cc=asahi@lists.linux.dev \
    --cc=axboe@kernel.dk \
    --cc=hch@lst.de \
    --cc=j@jannau.net \
    --cc=kbusch@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=ming.lei@redhat.com \
    --cc=neal@gompa.dev \
    --cc=sagi@grimberg.me \
    --cc=sven@kernel.org \
    --cc=tj@kernel.org \
    --cc=yukuai@fnnas.com \
    /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