* [PATCH] nvme-pci: Skip queue deletion if there are no queues
@ 2018-03-28 18:04 Keith Busch
[not found] ` <e872954fedc943c08ef11451679d5a2c@AUSX13MPS305.AMER.DELL.COM>
2018-04-04 13:00 ` Sagi Grimberg
0 siblings, 2 replies; 5+ messages in thread
From: Keith Busch @ 2018-03-28 18:04 UTC (permalink / raw)
User reported controller always retains CSTS.RDY to 1, which fails
controller disabling when resetting the controller. This is also before
the admin queue is allocated, and trying to disable an unallocated queue
results in a NULL dereference.
Reported-by: Alex Gagniuc <Alex_Gagniuc at Dellteam.com>
Signed-off-by: Keith Busch <keith.busch at intel.com>
---
drivers/nvme/host/pci.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index cef5ce851a92..b110eac1d0e6 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -2200,7 +2200,7 @@ static void nvme_dev_disable(struct nvme_dev *dev, bool shutdown)
nvme_stop_queues(&dev->ctrl);
- if (!dead) {
+ if (!dead && dev->ctrl.queue_count > 0) {
/*
* If the controller is still alive tell it to stop using the
* host memory buffer. In theory the shutdown / reset should
--
2.14.3
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH] nvme-pci: Skip queue deletion if there are no queues
[not found] ` <e872954fedc943c08ef11451679d5a2c@AUSX13MPS305.AMER.DELL.COM>
@ 2018-03-28 20:13 ` Alex G.
2018-03-28 20:22 ` Keith Busch
0 siblings, 1 reply; 5+ messages in thread
From: Alex G. @ 2018-03-28 20:13 UTC (permalink / raw)
Hi Keith,
> User reported controller always retains CSTS.RDY to 1, which fails
> controller disabling when resetting the controller. This is also before
> the admin queue is allocated, and trying to disable an unallocated queue
> results in a NULL dereference.
>
> Reported-by: Alex Gagniuc <Alex_Gagniuc at Dellteam.com>
> Signed-off-by: Keith Busch <keith.busch at intel.com>
> ---
> drivers/nvme/host/pci.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
> index cef5ce851a92..b110eac1d0e6 100644
Which branch am I supposed to be using to test this? It doesn't apply to
mainline.
> --- a/drivers/nvme/host/pci.c
> +++ b/drivers/nvme/host/pci.c
> @@ -2200,7 +2200,7 @@ static void nvme_dev_disable(struct nvme_dev *dev, bool shutdown)
>
> nvme_stop_queues(&dev->ctrl);
>
> - if (!dead) {
> + if (!dead && dev->ctrl.queue_count > 0) {
Is this around the calls to nvme_disable_io_queues() and
nvme_disable_admin_queue()?
Coming as an outsider with limited experience regarding the nvme driver
it seems it might be more robust to move this check to
nvme_disable_admin_queue().
Alex
> /*
> * If the controller is still alive tell it to stop using the
> * host memory buffer. In theory the shutdown / reset should
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH] nvme-pci: Skip queue deletion if there are no queues
2018-03-28 20:13 ` Alex G.
@ 2018-03-28 20:22 ` Keith Busch
2018-03-28 21:02 ` Alex G.
0 siblings, 1 reply; 5+ messages in thread
From: Keith Busch @ 2018-03-28 20:22 UTC (permalink / raw)
On Wed, Mar 28, 2018@03:13:37PM -0500, Alex G. wrote:
> Which branch am I supposed to be using to test this? It doesn't apply to
> mainline.
This is targeted to the 4.17 staging trees (sorry, this doesn't seem to
be a good 4.16 candidate this late in the game). This should apply on
linux-block for-4.17/block here:
https://git.kernel.org/pub/scm/linux/kernel/git/axboe/linux-block.git/log/?h=for-4.17/block
A 4.16 port would would like this:
---
diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index b6f43b738f03..2459067d208b 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -2194,7 +2194,7 @@ static void nvme_dev_disable(struct nvme_dev *dev, bool shutdown)
* Give the controller a chance to complete all entered requests if
* doing a safe shutdown.
*/
- if (!dead) {
+ if (!dead && dev->ctrl.queue_count > 0) {
if (shutdown)
nvme_wait_freeze_timeout(&dev->ctrl, NVME_IO_TIMEOUT);
--
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH] nvme-pci: Skip queue deletion if there are no queues
2018-03-28 20:22 ` Keith Busch
@ 2018-03-28 21:02 ` Alex G.
0 siblings, 0 replies; 5+ messages in thread
From: Alex G. @ 2018-03-28 21:02 UTC (permalink / raw)
On 03/28/2018 03:22 PM, Keith Busch wrote:
> On Wed, Mar 28, 2018@03:13:37PM -0500, Alex G. wrote:
>> Which branch am I supposed to be using to test this? It doesn't apply to
>> mainline.
>
> This is targeted to the 4.17 staging trees (sorry, this doesn't seem to
> be a good 4.16 candidate this late in the game). This should apply on
> linux-block for-4.17/block here:
>
> https://git.kernel.org/pub/scm/linux/kernel/git/axboe/linux-block.git/log/?h=for-4.17/block
Then I should probably test with that.
Tested-by: Alex Gagniuc <Alex_Gagniuc at Dellteam.com>
So I see the check is really meant to protect dereferencing
&dev->queues[0] in nvme_disable_admin_queue(). My previous comment is
still valid then. Successfully tested this approach as well.
Thanks for the quick turn-around.
Alex
>
> A 4.16 port would would like this:
>
> ---
> diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
> index b6f43b738f03..2459067d208b 100644
> --- a/drivers/nvme/host/pci.c
> +++ b/drivers/nvme/host/pci.c
> @@ -2194,7 +2194,7 @@ static void nvme_dev_disable(struct nvme_dev *dev, bool shutdown)
> * Give the controller a chance to complete all entered requests if
> * doing a safe shutdown.
> */
> - if (!dead) {
> + if (!dead && dev->ctrl.queue_count > 0) {
> if (shutdown)
> nvme_wait_freeze_timeout(&dev->ctrl, NVME_IO_TIMEOUT);
>
> --
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH] nvme-pci: Skip queue deletion if there are no queues
2018-03-28 18:04 [PATCH] nvme-pci: Skip queue deletion if there are no queues Keith Busch
[not found] ` <e872954fedc943c08ef11451679d5a2c@AUSX13MPS305.AMER.DELL.COM>
@ 2018-04-04 13:00 ` Sagi Grimberg
1 sibling, 0 replies; 5+ messages in thread
From: Sagi Grimberg @ 2018-04-04 13:00 UTC (permalink / raw)
Reviewed-by: Sagi Grimberg <sagi at grimberg.me>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2018-04-04 13:00 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-03-28 18:04 [PATCH] nvme-pci: Skip queue deletion if there are no queues Keith Busch
[not found] ` <e872954fedc943c08ef11451679d5a2c@AUSX13MPS305.AMER.DELL.COM>
2018-03-28 20:13 ` Alex G.
2018-03-28 20:22 ` Keith Busch
2018-03-28 21:02 ` Alex G.
2018-04-04 13:00 ` Sagi Grimberg
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox