svn commit: r257709 - stable/9/sys/dev/nvme

Jim Harris jimharris at FreeBSD.org
Tue Nov 5 15:57:25 UTC 2013


Author: jimharris
Date: Tue Nov  5 15:57:24 2013
New Revision: 257709
URL: http://svnweb.freebsd.org/changeset/base/257709

Log:
  MFC r257534:
  
  Create a unique unit number for each controller and namespace cdev.
  
  Sponsored by:	Intel

Modified:
  stable/9/sys/dev/nvme/nvme_ctrlr.c
  stable/9/sys/dev/nvme/nvme_ns.c
Directory Properties:
  stable/9/sys/   (props changed)
  stable/9/sys/dev/   (props changed)

Modified: stable/9/sys/dev/nvme/nvme_ctrlr.c
==============================================================================
--- stable/9/sys/dev/nvme/nvme_ctrlr.c	Tue Nov  5 15:56:15 2013	(r257708)
+++ stable/9/sys/dev/nvme/nvme_ctrlr.c	Tue Nov  5 15:57:24 2013	(r257709)
@@ -1150,8 +1150,8 @@ intx:
 	if (status != 0)
 		return (status);
 
-	ctrlr->cdev = make_dev(&nvme_ctrlr_cdevsw, 0, UID_ROOT, GID_WHEEL, 0600,
-	    "nvme%d", device_get_unit(dev));
+	ctrlr->cdev = make_dev(&nvme_ctrlr_cdevsw, device_get_unit(dev),
+	    UID_ROOT, GID_WHEEL, 0600, "nvme%d", device_get_unit(dev));
 
 	if (ctrlr->cdev == NULL)
 		return (ENXIO);

Modified: stable/9/sys/dev/nvme/nvme_ns.c
==============================================================================
--- stable/9/sys/dev/nvme/nvme_ns.c	Tue Nov  5 15:56:15 2013	(r257708)
+++ stable/9/sys/dev/nvme/nvme_ns.c	Tue Nov  5 15:57:24 2013	(r257709)
@@ -491,6 +491,7 @@ nvme_ns_construct(struct nvme_namespace 
     struct nvme_controller *ctrlr)
 {
 	struct nvme_completion_poll_status	status;
+	int					unit;
 
 	ns->ctrlr = ctrlr;
 	ns->id = id;
@@ -552,6 +553,12 @@ nvme_ns_construct(struct nvme_namespace 
 	if (ns->cdev != NULL)
 		return (0);
 
+	/*
+	 * Namespace IDs start at 1, so we need to subtract 1 to create a
+	 *  correct unit number.
+	 */
+	unit = device_get_unit(ctrlr->dev) * NVME_MAX_NAMESPACES + ns->id - 1;
+
 /*
  * MAKEDEV_ETERNAL was added in r210923, for cdevs that will never
  *  be destroyed.  This avoids refcounting on the cdev object.
@@ -559,11 +566,11 @@ nvme_ns_construct(struct nvme_namespace 
  *  surprise removal nor namespace deletion.
  */
 #ifdef MAKEDEV_ETERNAL_KLD
-	ns->cdev = make_dev_credf(MAKEDEV_ETERNAL_KLD, &nvme_ns_cdevsw, 0,
+	ns->cdev = make_dev_credf(MAKEDEV_ETERNAL_KLD, &nvme_ns_cdevsw, unit,
 	    NULL, UID_ROOT, GID_WHEEL, 0600, "nvme%dns%d",
 	    device_get_unit(ctrlr->dev), ns->id);
 #else
-	ns->cdev = make_dev_credf(0, &nvme_ns_cdevsw, 0,
+	ns->cdev = make_dev_credf(0, &nvme_ns_cdevsw, unit,
 	    NULL, UID_ROOT, GID_WHEEL, 0600, "nvme%dns%d",
 	    device_get_unit(ctrlr->dev), ns->id);
 #endif


More information about the svn-src-stable-9 mailing list