Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 22 Jan 2020 00:43:51 +0000 (UTC)
From:      Alexander Motin <mav@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org
Subject:   svn commit: r356955 - stable/12/sys/dev/nvme
Message-ID:  <202001220043.00M0hp2B028975@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mav
Date: Wed Jan 22 00:43:51 2020
New Revision: 356955
URL: https://svnweb.freebsd.org/changeset/base/356955

Log:
  MFC r355631 (by imp): Move reset to the interrutp processing stage
  
  This trims the boot time a bit more for AWS and other platforms that have nvme
  drives. There's no reason too do this inline. This has been in my tree a while,
  but IIRC I talked to Jim Harris about this at one of our face to face meetings.

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

Modified: stable/12/sys/dev/nvme/nvme.c
==============================================================================
--- stable/12/sys/dev/nvme/nvme.c	Wed Jan 22 00:41:18 2020	(r356954)
+++ stable/12/sys/dev/nvme/nvme.c	Wed Jan 22 00:43:51 2020	(r356955)
@@ -130,25 +130,6 @@ nvme_attach(device_t dev)
 	int			status;
 
 	status = nvme_ctrlr_construct(ctrlr, dev);
-
-	if (status != 0) {
-		nvme_ctrlr_destruct(ctrlr, dev);
-		return (status);
-	}
-
-	/*
-	 * Reset controller twice to ensure we do a transition from cc.en==1 to
-	 * cc.en==0.  This is because we don't really know what status the
-	 * controller was left in when boot handed off to OS.  Linux doesn't do
-	 * this, however. If we adopt that policy, see also nvme_ctrlr_resume().
-	 */
-	status = nvme_ctrlr_hw_reset(ctrlr);
-	if (status != 0) {
-		nvme_ctrlr_destruct(ctrlr, dev);
-		return (status);
-	}
-
-	status = nvme_ctrlr_hw_reset(ctrlr);
 	if (status != 0) {
 		nvme_ctrlr_destruct(ctrlr, dev);
 		return (status);

Modified: stable/12/sys/dev/nvme/nvme_ctrlr.c
==============================================================================
--- stable/12/sys/dev/nvme/nvme_ctrlr.c	Wed Jan 22 00:41:18 2020	(r356954)
+++ stable/12/sys/dev/nvme/nvme_ctrlr.c	Wed Jan 22 00:43:51 2020	(r356955)
@@ -909,6 +909,25 @@ void
 nvme_ctrlr_start_config_hook(void *arg)
 {
 	struct nvme_controller *ctrlr = arg;
+	int status;
+
+	/*
+	 * Reset controller twice to ensure we do a transition from cc.en==1 to
+	 * cc.en==0.  This is because we don't really know what status the
+	 * controller was left in when boot handed off to OS.  Linux doesn't do
+	 * this, however. If we adopt that policy, see also nvme_ctrlr_resume().
+	 */
+	status = nvme_ctrlr_hw_reset(ctrlr);
+	if (status != 0) {
+		nvme_ctrlr_fail(ctrlr);
+		return;
+	}
+
+	status = nvme_ctrlr_hw_reset(ctrlr);
+	if (status != 0) {
+		nvme_ctrlr_fail(ctrlr);
+		return;
+	}
 
 	nvme_qpair_reset(&ctrlr->adminq);
 	nvme_admin_qpair_enable(&ctrlr->adminq);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202001220043.00M0hp2B028975>