Author: imp
Date: Wed Dec 11 22:51:02 2019
New Revision: 355631
URL: https://svnweb.freebsd.org/changeset/base/355631

Log:
  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.
  
  MFC After: 2 weeks

Modified:
  head/sys/dev/nvme/nvme.c
  head/sys/dev/nvme/nvme_ctrlr.c

Modified: head/sys/dev/nvme/nvme.c
==============================================================================
--- head/sys/dev/nvme/nvme.c    Wed Dec 11 22:09:22 2019        (r355630)
+++ head/sys/dev/nvme/nvme.c    Wed Dec 11 22:51:02 2019        (r355631)
@@ -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: head/sys/dev/nvme/nvme_ctrlr.c
==============================================================================
--- head/sys/dev/nvme/nvme_ctrlr.c      Wed Dec 11 22:09:22 2019        
(r355630)
+++ head/sys/dev/nvme/nvme_ctrlr.c      Wed Dec 11 22:51:02 2019        
(r355631)
@@ -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);
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "[email protected]"

Reply via email to