git: 9600aa31aa63 - main - nvme: use NVME_GONE rather than hard-coded 0xffffffff

Warner Losh imp at FreeBSD.org
Mon Feb 8 20:10:20 UTC 2021


The branch main has been updated by imp:

URL: https://cgit.FreeBSD.org/src/commit/?id=9600aa31aa633bbb9e8a56d91a781d5a7ce2bff6

commit 9600aa31aa633bbb9e8a56d91a781d5a7ce2bff6
Author:     Warner Losh <imp at FreeBSD.org>
AuthorDate: 2021-02-08 20:08:48 +0000
Commit:     Warner Losh <imp at FreeBSD.org>
CommitDate: 2021-02-08 20:08:48 +0000

    nvme: use NVME_GONE rather than hard-coded 0xffffffff
    
    Make it clearer that the value 0xfffffff is being used to detect the device is
    gone. We use it other places in the driver for other meanings.
---
 sys/dev/nvme/nvme_ctrlr.c   | 6 +++---
 sys/dev/nvme/nvme_private.h | 2 ++
 sys/dev/nvme/nvme_qpair.c   | 2 +-
 3 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/sys/dev/nvme/nvme_ctrlr.c b/sys/dev/nvme/nvme_ctrlr.c
index 2bd7074ee378..c0e6c408ab56 100644
--- a/sys/dev/nvme/nvme_ctrlr.c
+++ b/sys/dev/nvme/nvme_ctrlr.c
@@ -261,7 +261,7 @@ nvme_ctrlr_wait_for_ready(struct nvme_controller *ctrlr, int desired_val)
 	ms_waited = 0;
 	while (1) {
 		csts = nvme_mmio_read_4(ctrlr, csts);
-		if (csts == 0xffffffff)		/* Hot unplug. */
+		if (csts == NVME_GONE)		/* Hot unplug. */
 			return (ENXIO);
 		if (((csts >> NVME_CSTS_REG_RDY_SHIFT) & NVME_CSTS_REG_RDY_MASK)
 		    == desired_val)
@@ -1471,7 +1471,7 @@ nvme_ctrlr_destruct(struct nvme_controller *ctrlr, device_t dev)
 	 * Check whether it is a hot unplug or a clean driver detach.
 	 * If device is not there any more, skip any shutdown commands.
 	 */
-	gone = (nvme_mmio_read_4(ctrlr, csts) == 0xffffffff);
+	gone = (nvme_mmio_read_4(ctrlr, csts) == NVME_GONE);
 	if (gone)
 		nvme_ctrlr_fail(ctrlr);
 	else
@@ -1549,7 +1549,7 @@ nvme_ctrlr_shutdown(struct nvme_controller *ctrlr)
 	    ((uint64_t)ctrlr->cdata.rtd3e * hz + 999999) / 1000000;
 	while (1) {
 		csts = nvme_mmio_read_4(ctrlr, csts);
-		if (csts == 0xffffffff)		/* Hot unplug. */
+		if (csts == NVME_GONE)		/* Hot unplug. */
 			break;
 		if (NVME_CSTS_GET_SHST(csts) == NVME_SHST_COMPLETE)
 			break;
diff --git a/sys/dev/nvme/nvme_private.h b/sys/dev/nvme/nvme_private.h
index d44f1989dd71..6c1d293f047d 100644
--- a/sys/dev/nvme/nvme_private.h
+++ b/sys/dev/nvme/nvme_private.h
@@ -104,6 +104,8 @@ MALLOC_DECLARE(M_NVME);
 #define CACHE_LINE_SIZE		(64)
 #endif
 
+#define NVME_GONE		0xfffffffful
+
 extern int32_t		nvme_retry_count;
 extern bool		nvme_verbose_cmd_dump;
 
diff --git a/sys/dev/nvme/nvme_qpair.c b/sys/dev/nvme/nvme_qpair.c
index 45b1568a4c5a..0726ca248442 100644
--- a/sys/dev/nvme/nvme_qpair.c
+++ b/sys/dev/nvme/nvme_qpair.c
@@ -945,7 +945,7 @@ nvme_timeout(void *arg)
 		    nvme_abort_complete, tr);
 	} else {
 		nvme_printf(ctrlr, "Resetting controller due to a timeout%s.\n",
-		    (csts == 0xffffffff) ? " and possible hot unplug" :
+		    (csts == NVME_GONE) ? " and possible hot unplug" :
 		    (cfs ? " and fatal error status" : ""));
 		nvme_ctrlr_reset(ctrlr);
 	}


More information about the dev-commits-src-all mailing list