changeset 19403:345a05acc665

12209 nvme driver will iterate beyond the end of the DMA cookie chain Reviewed by: Robert Mustacchi <rm+illumos@fingolfin.org> Reviewed by: Garrett D'Amore <garrett@damore.org> Approved by: Dan McDonald <danmcd@joyent.com>
author Paul Winder <paul@winders.demon.co.uk>
date Mon, 20 Jan 2020 07:33:34 +0000
parents a89a57905c4c
children af0444bfaa3a
files usr/src/uts/common/io/nvme/nvme.c
diffstat 1 files changed, 3 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/usr/src/uts/common/io/nvme/nvme.c	Sun Jan 19 10:41:22 2020 +0000
+++ b/usr/src/uts/common/io/nvme/nvme.c	Mon Jan 20 07:33:34 2020 +0000
@@ -15,6 +15,7 @@
  * Copyright (c) 2016 The MathWorks, Inc.  All rights reserved.
  * Copyright 2018 Joyent, Inc.
  * Copyright 2019 Western Digital Corporation.
+ * Copyright 2020 Racktop Systems.
  */
 
 /*
@@ -3629,12 +3630,12 @@
 		return (DDI_FAILURE);
 
 	cmd->nc_sqe.sqe_dptr.d_prp[0] = xfer->x_dmac.dmac_laddress;
-	ddi_dma_nextcookie(xfer->x_dmah, &xfer->x_dmac);
 
 	if (xfer->x_ndmac == 1) {
 		cmd->nc_sqe.sqe_dptr.d_prp[1] = 0;
 		return (DDI_SUCCESS);
 	} else if (xfer->x_ndmac == 2) {
+		ddi_dma_nextcookie(xfer->x_dmah, &xfer->x_dmac);
 		cmd->nc_sqe.sqe_dptr.d_prp[1] = xfer->x_dmac.dmac_laddress;
 		return (DDI_SUCCESS);
 	}
@@ -3661,8 +3662,8 @@
 	for (prp = (uint64_t *)cmd->nc_dma->nd_memp;
 	    xfer->x_ndmac > 0;
 	    prp++, xfer->x_ndmac--) {
+		ddi_dma_nextcookie(xfer->x_dmah, &xfer->x_dmac);
 		*prp = xfer->x_dmac.dmac_laddress;
-		ddi_dma_nextcookie(xfer->x_dmah, &xfer->x_dmac);
 	}
 
 	(void) ddi_dma_sync(cmd->nc_dma->nd_dmah, 0, cmd->nc_dma->nd_len,