linux-nvme.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] NVMe: handle ioremap failure
@ 2013-07-01 16:23 Keith Busch
  2013-07-01 21:00 ` Matthew Wilcox
  0 siblings, 1 reply; 2+ messages in thread
From: Keith Busch @ 2013-07-01 16:23 UTC (permalink / raw)


Decrement the number of queues required for doorbell remapping until
the memory is successfully mapped for that size.

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

diff --git a/drivers/block/nvme-core.c b/drivers/block/nvme-core.c
index 711b51c..aaada3d 100644
--- a/drivers/block/nvme-core.c
+++ b/drivers/block/nvme-core.c
@@ -1686,7 +1686,17 @@ static int nvme_setup_io_queues(struct nvme_dev *dev)
 	db_bar_size = 4096 + ((nr_io_queues + 1) << (dev->db_stride + 3));
 	if (db_bar_size > 8192) {
 		iounmap(dev->bar);
-		dev->bar = ioremap(pci_resource_start(pdev, 0), db_bar_size);
+		while (nr_io_queues > 0) {
+			dev->bar = ioremap(pci_resource_start(pdev, 0), db_bar_size);
+			if (!dev->bar)
+				nr_io_queues--;
+			else
+				break;
+			db_bar_size = 4096 + ((nr_io_queues + 1) << (dev->db_stride + 3));
+		}
+		if (!dev->bar)
+			return -ENOMEM;
+
 		dev->dbs = ((void __iomem *)dev->bar) + 4096;
 		dev->queues[0]->q_db = dev->dbs;
 	}
-- 
1.7.0.4

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-07-01 21:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-07-01 16:23 [PATCH] NVMe: handle ioremap failure Keith Busch
2013-07-01 21:00 ` Matthew Wilcox

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).