Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 27 Jul 2015 17:53:12 +0000 (UTC)
From:      Jim Harris <jimharris@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-releng@freebsd.org
Subject:   svn commit: r285922 - releng/10.2/sys/dev/nvme
Message-ID:  <201507271753.t6RHrChN083505@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jimharris
Date: Mon Jul 27 17:53:11 2015
New Revision: 285922
URL: https://svnweb.freebsd.org/changeset/base/285922

Log:
  MFS r285918:
  MFC r285816:
  
    nvme: ensure csts.rdy bit is cleared before returning from nvme_ctrlr_disable
  
  Approved by:	re (gjb)
  Sponsored by:	Intel

Modified:
  releng/10.2/sys/dev/nvme/nvme_ctrlr.c
Directory Properties:
  releng/10.2/   (props changed)

Modified: releng/10.2/sys/dev/nvme/nvme_ctrlr.c
==============================================================================
--- releng/10.2/sys/dev/nvme/nvme_ctrlr.c	Mon Jul 27 17:52:17 2015	(r285921)
+++ releng/10.2/sys/dev/nvme/nvme_ctrlr.c	Mon Jul 27 17:53:11 2015	(r285922)
@@ -1,5 +1,5 @@
 /*-
- * Copyright (C) 2012-2014 Intel Corporation
+ * Copyright (C) 2012-2015 Intel Corporation
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -207,7 +207,7 @@ nvme_ctrlr_fail_req_task(void *arg, int 
 }
 
 static int
-nvme_ctrlr_wait_for_ready(struct nvme_controller *ctrlr)
+nvme_ctrlr_wait_for_ready(struct nvme_controller *ctrlr, int desired_val)
 {
 	int ms_waited;
 	union cc_register cc;
@@ -216,18 +216,19 @@ nvme_ctrlr_wait_for_ready(struct nvme_co
 	cc.raw = nvme_mmio_read_4(ctrlr, cc);
 	csts.raw = nvme_mmio_read_4(ctrlr, csts);
 
-	if (!cc.bits.en) {
-		nvme_printf(ctrlr, "%s called with cc.en = 0\n", __func__);
+	if (cc.bits.en != desired_val) {
+		nvme_printf(ctrlr, "%s called with desired_val = %d "
+		    "but cc.en = %d\n", __func__, desired_val, cc.bits.en);
 		return (ENXIO);
 	}
 
 	ms_waited = 0;
 
-	while (!csts.bits.rdy) {
+	while (csts.bits.rdy != desired_val) {
 		DELAY(1000);
 		if (ms_waited++ > ctrlr->ready_timeout_in_ms) {
-			nvme_printf(ctrlr, "controller did not become ready "
-			    "within %d ms\n", ctrlr->ready_timeout_in_ms);
+			nvme_printf(ctrlr, "controller ready did not become %d "
+			    "within %d ms\n", desired_val, ctrlr->ready_timeout_in_ms);
 			return (ENXIO);
 		}
 		csts.raw = nvme_mmio_read_4(ctrlr, csts);
@@ -246,11 +247,12 @@ nvme_ctrlr_disable(struct nvme_controlle
 	csts.raw = nvme_mmio_read_4(ctrlr, csts);
 
 	if (cc.bits.en == 1 && csts.bits.rdy == 0)
-		nvme_ctrlr_wait_for_ready(ctrlr);
+		nvme_ctrlr_wait_for_ready(ctrlr, 1);
 
 	cc.bits.en = 0;
 	nvme_mmio_write_4(ctrlr, cc, cc.raw);
 	DELAY(5000);
+	nvme_ctrlr_wait_for_ready(ctrlr, 0);
 }
 
 static int
@@ -267,7 +269,7 @@ nvme_ctrlr_enable(struct nvme_controller
 		if (csts.bits.rdy == 1)
 			return (0);
 		else
-			return (nvme_ctrlr_wait_for_ready(ctrlr));
+			return (nvme_ctrlr_wait_for_ready(ctrlr, 1));
 	}
 
 	nvme_mmio_write_8(ctrlr, asq, ctrlr->adminq.cmd_bus_addr);
@@ -295,7 +297,7 @@ nvme_ctrlr_enable(struct nvme_controller
 	nvme_mmio_write_4(ctrlr, cc, cc.raw);
 	DELAY(5000);
 
-	return (nvme_ctrlr_wait_for_ready(ctrlr));
+	return (nvme_ctrlr_wait_for_ready(ctrlr, 1));
 }
 
 int



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