From: keith.busch@intel.com (Keith Busch)
Subject: [PATCH] nvme: nvme_remove should cancel the reset_work before setting the ctrl state
Date: Tue, 5 Dec 2017 13:09:52 -0700 [thread overview]
Message-ID: <20171205200952.GA20019@localhost.localdomain> (raw)
In-Reply-To: <1512500495-16147-1-git-send-email-thomas.tai@oracle.com>
On Tue, Dec 05, 2017@12:01:35PM -0700, Thomas Tai wrote:
> During nvme_probe, a reset_work task is queued up
> for execution. When removing the nvme during unbinding,
> the remove function set the ctrl state to NVME_CTRL_DELETING
> and then cancel the reset_work. The correct sequence should
> have been cancel the reset_work first then change the state.
>
> Otherwise, if the reset_work happens to schedule to work,
> the NVME_CTRL_DELETING causes the reset_work function to
> fail with "failed to make controller live".
The message seems to make sense. You requested to unbind the driver
before the controller went live.
> diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
> index a11cfd4..e2d10f9 100644
> --- a/drivers/nvme/host/pci.c
> +++ b/drivers/nvme/host/pci.c
> @@ -2534,9 +2534,9 @@ static void nvme_remove(struct pci_dev *pdev)
> {
> struct nvme_dev *dev = pci_get_drvdata(pdev);
>
> - nvme_change_ctrl_state(&dev->ctrl, NVME_CTRL_DELETING);
>
> cancel_work_sync(&dev->ctrl.reset_work);
> + nvme_change_ctrl_state(&dev->ctrl, NVME_CTRL_DELETING);
> pci_set_drvdata(pdev, NULL);
The state is changed before synchronously cancelling the reset work so
that nvme_remove is guaranteed another reset can't possibly occur while
we're deleting the controller. This change provies a small window for
which that could happen, and bad things will happen if it does.
next prev parent reply other threads:[~2017-12-05 20:09 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-05 19:01 [PATCH] nvme: nvme_remove should cancel the reset_work before setting the ctrl state Thomas Tai
2017-12-05 20:09 ` Keith Busch [this message]
2017-12-05 20:43 ` Thomas Tai
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=20171205200952.GA20019@localhost.localdomain \
--to=keith.busch@intel.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 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.