Skip to contentSkip to conversation

nvme: remove CC register read-back during enabling

PATCH In review Keith Busch 3 participants 3 messages Sep 4, 2024 – Sep 23, 2024 NVMe

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nvme: remove CC register read-back during enabling

From: Keith Busch <[email protected]>

Any non-posted read should flush the previous write, so we don't necessarily need to read back the value we just wrote. I've found at least some controllers that respond with 0 for short moments after writing the CC register with EN (enable) cleared, so the read-back is overwriting our valid ctrl_config value and ends up breaking on the subsequent enabling.

---
 drivers/nvme/host/core.c | 5 -----
 1 file changed, 5 deletions(-)
drivers/nvme/host/core.c +0 -5
index 983909a600adb..3172d7dab43bb 100644
@@ -2467,11 +2467,6 @@ int nvme_enable_ctrl(struct nvme_ctrl *ctrl)
 	if (ret)
 		return ret;
 
-	/* Flush write to device (required if transport is PCI) */
-	ret = ctrl->ops->reg_read32(ctrl, NVME_REG_CC, &ctrl->ctrl_config);
-	if (ret)
-		return ret;
-
 	/* CAP value may change after initial CC write */
 	ret = ctrl->ops->reg_read64(ctrl, NVME_REG_CAP, &ctrl->cap);
 	if (ret)
Signature · 1 line
2.43.5
maintainer
#1 lore raw
Quoted 8 lines · Keith Busch

From: Keith Busch <[email protected]>

Any non-posted read should flush the previous write, so we don't necessarily need to read back the value we just wrote. I've found at least some controllers that respond with 0 for short moments after writing the CC register with EN (enable) cleared, so the read-back is overwriting our valid ctrl_config value and ends up breaking on the subsequent enabling.

Ping on this one. Looks okay?

Quoted 19 lines
drivers/nvme/host/core.c +0 -5
index 983909a600adb..3172d7dab43bb 100644
@@ -2467,11 +2467,6 @@ int nvme_enable_ctrl(struct nvme_ctrl *ctrl)
 	if (ret)
 		return ret;
 
-	/* Flush write to device (required if transport is PCI) */
-	ret = ctrl->ops->reg_read32(ctrl, NVME_REG_CC, &ctrl->ctrl_config);
-	if (ret)
-		return ret;
-
 	/* CAP value may change after initial CC write */
 	ret = ctrl->ops->reg_read64(ctrl, NVME_REG_CAP, &ctrl->cap);
 	if (ret)
Signature · 1 line
2.43.5
maintainer Reviewed-by
#2 lore raw
Quoted 11 lines · Keith Busch
Quoted 8 lines · Keith Busch

From: Keith Busch <[email protected]>

Any non-posted read should flush the previous write, so we don't necessarily need to read back the value we just wrote. I've found at least some controllers that respond with 0 for short moments after writing the CC register with EN (enable) cleared, so the read-back is overwriting our valid ctrl_config value and ends up breaking on the subsequent enabling.

Ping on this one. Looks okay?

Looks good: