aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/nvme/nvme_ns.c
diff options
context:
space:
mode:
authorJim Harris <jimharris@FreeBSD.org>2013-04-12 17:41:24 +0000
committerJim Harris <jimharris@FreeBSD.org>2013-04-12 17:41:24 +0000
commit97fafe2580294b580ccdb646aeb4d3b15fa1a28e (patch)
treefb6bf1a0aca6783491a759a0d15129473c7b1303 /sys/dev/nvme/nvme_ns.c
parenta90b8104925e7ae02c81bfde885067bf7d4292e1 (diff)
downloadsrc-97fafe2580294b580ccdb646aeb4d3b15fa1a28e.tar.gz
src-97fafe2580294b580ccdb646aeb4d3b15fa1a28e.zip
Add a mutex to each namespace, for general locking operations on the namespace.
Sponsored by: Intel
Notes
Notes: svn path=/head/; revision=249418
Diffstat (limited to 'sys/dev/nvme/nvme_ns.c')
-rw-r--r--sys/dev/nvme/nvme_ns.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/sys/dev/nvme/nvme_ns.c b/sys/dev/nvme/nvme_ns.c
index 0051699aa677..b49213261784 100644
--- a/sys/dev/nvme/nvme_ns.c
+++ b/sys/dev/nvme/nvme_ns.c
@@ -300,6 +300,17 @@ nvme_ns_construct(struct nvme_namespace *ns, uint16_t id,
ns->ctrlr = ctrlr;
ns->id = id;
+ /*
+ * Namespaces are reconstructed after a controller reset, so check
+ * to make sure we only call mtx_init once on each mtx.
+ *
+ * TODO: Move this somewhere where it gets called at controller
+ * construction time, which is not invoked as part of each
+ * controller reset.
+ */
+ if (!mtx_initialized(&ns->lock))
+ mtx_init(&ns->lock, "nvme ns lock", NULL, MTX_DEF);
+
#ifdef CHATHAM2
if (pci_get_devid(ctrlr->dev) == CHATHAM_PCI_ID)
nvme_ns_populate_chatham_data(ns);