Author: jimharris
Date: Tue Mar 26 21:16:53 2013
New Revision: 248762
URL: http://svnweb.freebsd.org/changeset/base/248762

Log:
  Ensure the controller's MDTS is accounted for in max_xfer_size.
  
  The controller's IDENTIFY data contains MDTS (Max Data Transfer Size) to
  allow the controller to specify the maximum I/O data transfer size.  nvme(4)
  already provides a default maximum, but make sure it does not exceed what
  MDTS reports.
  
  Sponsored by: Intel
  Reviewed by:  carl

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

Modified: head/sys/dev/nvme/nvme_ctrlr.c
==============================================================================
--- head/sys/dev/nvme/nvme_ctrlr.c      Tue Mar 26 21:14:51 2013        
(r248761)
+++ head/sys/dev/nvme/nvme_ctrlr.c      Tue Mar 26 21:16:53 2013        
(r248762)
@@ -457,6 +457,14 @@ nvme_ctrlr_identify(struct nvme_controll
                nvme_chatham_populate_cdata(ctrlr);
 #endif
 
+       /*
+        * Use MDTS to ensure our default max_xfer_size doesn't exceed what the
+        *  controller supports.
+        */
+       if (ctrlr->cdata.mdts > 0)
+               ctrlr->max_xfer_size = min(ctrlr->max_xfer_size,
+                   ctrlr->min_page_size * (1 << (ctrlr->cdata.mdts)));
+
        return (0);
 }
 
@@ -923,6 +931,8 @@ nvme_ctrlr_construct(struct nvme_control
        if (cap_hi.bits.dstrd != 0)
                return (ENXIO);
 
+       ctrlr->min_page_size = 1 << (12 + cap_hi.bits.mpsmin);
+
        /* Get ready timeout value from controller, in units of 500ms. */
        cap_lo.raw = nvme_mmio_read_4(ctrlr, cap_lo);
        ctrlr->ready_timeout_in_ms = cap_lo.bits.to * 500;

Modified: head/sys/dev/nvme/nvme_private.h
==============================================================================
--- head/sys/dev/nvme/nvme_private.h    Tue Mar 26 21:14:51 2013        
(r248761)
+++ head/sys/dev/nvme/nvme_private.h    Tue Mar 26 21:16:53 2013        
(r248762)
@@ -265,6 +265,9 @@ struct nvme_controller {
        /** maximum i/o size in bytes */
        uint32_t                max_xfer_size;
 
+       /** minimum page size supported by this controller in bytes */
+       uint32_t                min_page_size;
+
        /** interrupt coalescing time period (in microseconds) */
        uint32_t                int_coal_time;
 
_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to