[PATCH] nvme-pci: cleanup nvme_should_reset

Christoph Hellwig hch at lst.de
Thu Mar 16 07:08:57 PDT 2023


Both the comments and the code flow in this function are rather
confusing.  Directly return the expression that the reset is keyed
off, and update a comment to match it.

Signed-off-by: Christoph Hellwig <hch at lst.de>
---
 drivers/nvme/host/pci.c | 16 +++++-----------
 1 file changed, 5 insertions(+), 11 deletions(-)

diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index 04f4c6818f2878..d98cde62128f7d 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -1229,11 +1229,6 @@ static enum rq_end_io_ret abort_endio(struct request *req, blk_status_t error)
 
 static bool nvme_should_reset(struct nvme_dev *dev, u32 csts)
 {
-	/* If true, indicates loss of adapter communication, possibly by a
-	 * NVMe Subsystem reset.
-	 */
-	bool nssro = dev->subsystem && (csts & NVME_CSTS_NSSRO);
-
 	/* If there is a reset/reinit ongoing, we shouldn't reset again. */
 	switch (dev->ctrl.state) {
 	case NVME_CTRL_RESETTING:
@@ -1243,13 +1238,12 @@ static bool nvme_should_reset(struct nvme_dev *dev, u32 csts)
 		break;
 	}
 
-	/* We shouldn't reset unless the controller is on fatal error state
-	 * _or_ if we lost the communication with it.
+	/*
+	 * Don't reset unless the controller is in a fatal error state or
+	 * affected by a subsystem reset.
 	 */
-	if (!(csts & NVME_CSTS_CFS) && !nssro)
-		return false;
-
-	return true;
+	return (csts & NVME_CSTS_CFS) ||
+		(dev->subsystem && (csts & NVME_CSTS_NSSRO));
 }
 
 static void nvme_warn_reset(struct nvme_dev *dev, u32 csts)
-- 
2.39.2




More information about the Linux-nvme mailing list