linux-nvme.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: keith.busch@intel.com (Keith Busch)
Subject: [PATCH 4/7] NVMe: Clean-up character device bring-up
Date: Fri, 24 Jan 2014 16:50:51 -0700	[thread overview]
Message-ID: <1390607454-23273-5-git-send-email-keith.busch@intel.com> (raw)
In-Reply-To: <1390607454-23273-1-git-send-email-keith.busch@intel.com>

... because the way for getting an nvme character device up when it the
controller is otherwise unable to create IO queues was a bit tacky.

Signed-off-by: Keith Busch <keith.busch at intel.com>
---
 drivers/block/nvme-core.c |   23 ++++++++++++-----------
 include/linux/nvme.h      |    1 +
 2 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/drivers/block/nvme-core.c b/drivers/block/nvme-core.c
index e9a4acc..076987e 100644
--- a/drivers/block/nvme-core.c
+++ b/drivers/block/nvme-core.c
@@ -1193,6 +1193,7 @@ static int nvme_suspend_queue(struct nvme_queue *nvmeq)
 	irq_set_affinity_hint(vector, NULL);
 	free_irq(vector, nvmeq);
 
+	nvmeq->dev->online_queues--;
 	return 0;
 }
 
@@ -1287,6 +1288,7 @@ static void nvme_init_queue(struct nvme_queue *nvmeq, u16 qid)
 	memset(nvmeq->cmdid_data, 0, extra);
 	memset((void *)nvmeq->cqes, 0, CQ_SIZE(nvmeq->q_depth));
 	nvmeq->q_suspended = 0;
+	nvmeq->dev->online_queues++;
 }
 
 static int nvme_create_queue(struct nvme_queue *nvmeq, int qid)
@@ -1884,7 +1886,7 @@ static int set_queue_count(struct nvme_dev *dev, int count)
 	status = nvme_set_features(dev, NVME_FEAT_NUM_QUEUES, q_count, 0,
 								&result);
 	if (status)
-		return status < 0 ? -EIO : -EBUSY;
+		return status < 0 ? -EIO : 0;
 	return min(result & 0xffff, result >> 16) + 1;
 }
 
@@ -1900,7 +1902,7 @@ static int nvme_setup_io_queues(struct nvme_dev *dev)
 
 	nr_io_queues = num_online_cpus();
 	result = set_queue_count(dev, nr_io_queues);
-	if (result < 0)
+	if (result <= 0)
 		return result;
 	if (result < nr_io_queues)
 		nr_io_queues = result;
@@ -2429,7 +2431,7 @@ static int nvme_dev_start(struct nvme_dev *dev)
 	spin_unlock(&dev_list_lock);
 
 	result = nvme_setup_io_queues(dev);
-	if (result && result != -EBUSY)
+	if (result)
 		goto disable;
 
 	return result;
@@ -2468,9 +2470,9 @@ static int nvme_dev_resume(struct nvme_dev *dev)
 	int ret;
 
 	ret = nvme_dev_start(dev);
-	if (ret && ret != -EBUSY)
+	if (ret)
 		return ret;
-	if (ret == -EBUSY) {
+	if (dev->online_queues < 2) {
 		spin_lock(&dev_list_lock);
 		INIT_WORK(&dev->reset_work, nvme_remove_disks);
 		queue_work(nvme_workq, &dev->reset_work);
@@ -2530,18 +2532,17 @@ static int nvme_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 		goto release;
 
 	result = nvme_dev_start(dev);
-	if (result) {
-		if (result == -EBUSY)
-			goto create_cdev;
+	if (result)
 		goto release_pools;
-	}
 
 	kref_init(&dev->kref);
-	result = nvme_dev_add(dev);
+
+	/* Don't bother adding disks if we don't have online IO queues */
+	if (dev->online_queues > 1)
+		result = nvme_dev_add(dev);
 	if (result)
 		goto shutdown;
 
- create_cdev:
 	scnprintf(dev->name, sizeof(dev->name), "nvme%d", dev->instance);
 	dev->miscdev.minor = MISC_DYNAMIC_MINOR;
 	dev->miscdev.parent = &pdev->dev;
diff --git a/include/linux/nvme.h b/include/linux/nvme.h
index 98d367b..2fef3ce 100644
--- a/include/linux/nvme.h
+++ b/include/linux/nvme.h
@@ -80,6 +80,7 @@ struct nvme_dev {
 	struct dma_pool *prp_small_pool;
 	int instance;
 	int queue_count;
+	unsigned online_queues;
 	u32 db_stride;
 	u32 ctrl_config;
 	struct msix_entry *entry;
-- 
1.7.10.4

  parent reply	other threads:[~2014-01-24 23:50 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-24 23:50 [PATCH 0/7] Fixes and improvements Keith Busch
2014-01-24 23:50 ` [PATCH 1/7] NVMe: Namespace use after free on surprise removal Keith Busch
2014-01-24 23:50 ` [PATCH 2/7] NVMe: RCU access to nvme_queue Keith Busch
2014-01-24 23:50 ` [PATCH 3/7] NVMe: Initialization clean-up Keith Busch
2014-01-24 23:50 ` Keith Busch [this message]
2014-01-24 23:50 ` [PATCH 5/7] NVMe: Per-cpu IO queues Keith Busch
2014-01-31 17:47   ` Matthew Wilcox
2014-01-24 23:50 ` [PATCH 6/7] NVMe: CPU hot plug notification Keith Busch
2014-01-24 23:50 ` [PATCH 7/7] NVMe: Share interrupt vectors among IO queues Keith Busch

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=1390607454-23273-5-git-send-email-keith.busch@intel.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).