All of lore.kernel.org
 help / color / mirror / Atom feed
From: keith.busch@intel.com (Keith Busch)
Subject: [PATCH 1/1]  If device hotplug out, controller status become 0xFFFF_FFFF 1. Controller fatal status become true in nvme_kthread() 2. Ready bit will not be reset to 0 in nvme_wait_ready() for controller disable above two scenarios controller status data is not a valid data, since  device/controller is already removed (hotplug)
Date: Tue, 22 Jul 2014 11:40:52 -0600 (MDT)	[thread overview]
Message-ID: <alpine.LRH.2.03.1407221129110.4703@AMR> (raw)
In-Reply-To: <1406049939-29310-2-git-send-email-mundu2510@gmail.com>

On Tue, 22 Jul 2014, Mundu wrote:
> Signed-off-by: Mundu <mundu2510 at gmail.com>
> ---
> drivers/block/nvme-core.c | 13 +++++++++++--
> 1 file changed, 11 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/block/nvme-core.c b/drivers/block/nvme-core.c
> index 28aec2d..6c6998e 100644
> --- a/drivers/block/nvme-core.c
> +++ b/drivers/block/nvme-core.c
> @@ -1396,10 +1396,14 @@ static int nvme_wait_ready(struct nvme_dev *dev, u64 cap, bool enabled)
> {
> 	unsigned long timeout;
> 	u32 bit = enabled ? NVME_CSTS_RDY : 0;
> +	u32 csts;
>
> 	timeout = ((NVME_CAP_TIMEOUT(cap) + 1) * HZ / 2) + jiffies;
>
> -	while ((readl(&dev->bar->csts) & NVME_CSTS_RDY) != bit) {
> +	while (((csts = readl(&dev->bar->csts)) & NVME_CSTS_RDY) != bit) {
> +		/* If device is hot plugout, csts become 0xFFFFFFFF */
> +		if (csts == -1)
> +			return -ENODEV;

In nvme_dev_map, we already return -ENODEV if reading CSTS returns
-1. That happens before we call nvme_wait_ready. Are you just shorting
the probe in the event someone hot removes a drive the moment after the
driver ioremaps the BAR, but before it enables the device?

> 		msleep(100);
> 		if (fatal_signal_pending(current))
> 			return -EINTR;
> @@ -1905,14 +1909,19 @@ static int nvme_submit_async_req(struct nvme_queue *nvmeq)
> static int nvme_kthread(void *data)
> {
> 	struct nvme_dev *dev, *next;
> +	u32 csts;
>
> 	while (!kthread_should_stop()) {
> 		set_current_state(TASK_INTERRUPTIBLE);
> 		spin_lock(&dev_list_lock);
> 		list_for_each_entry_safe(dev, next, &dev_list, node) {
> 			int i;
> -			if (readl(&dev->bar->csts) & NVME_CSTS_CFS &&
> +			if ((csts = readl(&dev->bar->csts)) & NVME_CSTS_CFS &&
> 							dev->initialized) {
> +				/* If device is hot plugout,
> +				   csts become 0xFFFFFFFF */
> +				if (csts == -1)
> +					continue;

You definitely want to let the reset work get scheduled here instead of
continuing. Some platforms do not support "surprise removal", so this
check guards against that by triggering a reset which will bail on the
device if it appears gone and remove it from pci.

> 				if (work_busy(&dev->reset_work))
> 					continue;
> 				list_del_init(&dev->node);

  reply	other threads:[~2014-07-22 17:40 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-22 17:25 NVMe: Invalid controller status value, device hotplug out Mundu
2014-07-22 17:25 ` [PATCH 1/1] If device hotplug out, controller status become 0xFFFF_FFFF 1. Controller fatal status become true in nvme_kthread() 2. Ready bit will not be reset to 0 in nvme_wait_ready() for controller disable above two scenarios controller status data is not a valid data, since device/controller is already removed (hotplug) Mundu
2014-07-22 17:40   ` Keith Busch [this message]
2014-07-22 17:57     ` mundu agarwal
2014-07-23 14:24 ` NVMe: Invalid controller status value, device hotplug out J Freyensee

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=alpine.LRH.2.03.1407221129110.4703@AMR \
    --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.