Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F177643089
D61635.1794930517.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
1 KB
Referenced Files
None
Subscribers
None
D61635.1794930517.diff
View Options
diff --git a/sys/dev/nvme/nvme.h b/sys/dev/nvme/nvme.h
--- a/sys/dev/nvme/nvme.h
+++ b/sys/dev/nvme/nvme.h
@@ -190,6 +190,9 @@
#define NVME_CSTS_GET_SHST(csts) \
NVMEV(NVME_CSTS_REG_SHST, csts)
+/* "NVMe" */
+#define NVME_NSSR_REG_NSSRC_VALUE (0x4e564d65)
+
#define NVME_AQA_REG_ASQS_SHIFT (0)
#define NVME_AQA_REG_ASQS_MASK (0xFFF)
#define NVME_AQA_REG_ACQS_SHIFT (16)
diff --git a/sys/dev/nvme/nvme_ctrlr.c b/sys/dev/nvme/nvme_ctrlr.c
--- a/sys/dev/nvme/nvme_ctrlr.c
+++ b/sys/dev/nvme/nvme_ctrlr.c
@@ -461,6 +461,36 @@
return (0);
}
+static int
+nvme_ctrlr_subsystem_reset(struct nvme_controller *ctrlr)
+{
+ uint32_t csts;
+
+ nvme_printf(ctrlr, "attempting NVM subsystem reset\n");
+ pci_save_state(ctrlr->dev);
+ nvme_mmio_write_4(ctrlr, nssr, NVME_NSSR_REG_NSSRC_VALUE);
+ nvme_ctrlr_barrier(ctrlr, BUS_SPACE_BARRIER_WRITE);
+
+ for (int timeout = 0; timeout < ctrlr->ready_timeout_in_ms;
+ timeout += 10) {
+ pause_sbt("nvmenssr", SBT_1MS * 10, 0, C_PREL(1));
+ csts = nvme_mmio_read_4(ctrlr, csts);
+ if (csts != NVME_GONE && NVMEV(NVME_CSTS_REG_RDY, csts) == 0)
+ break;
+ }
+ pci_restore_state(ctrlr->dev);
+
+ csts = nvme_mmio_read_4(ctrlr, csts);
+ if (csts == NVME_GONE) {
+ nvme_printf(ctrlr, "NVM subsystem reset failed\n");
+ nvme_ctrlr_devctl(ctrlr, "NSSR_FAILED", "csts=0x%08x", csts);
+ return (ENXIO);
+ }
+ nvme_printf(ctrlr, "NVM subsystem reset completed\n");
+ nvme_ctrlr_devctl(ctrlr, "NSSR_COMPLETED", "csts=0x%08x", csts);
+ return (0);
+}
+
static int
nvme_ctrlr_hw_reset(struct nvme_controller *ctrlr)
{
@@ -481,6 +511,12 @@
}
err = nvme_ctrlr_disable(ctrlr);
+ if (err != 0 && NVME_CAP_HI_NSSRS(ctrlr->cap_hi) != 0) {
+ err = nvme_ctrlr_subsystem_reset(ctrlr);
+ if (err != 0)
+ goto out;
+ err = nvme_ctrlr_disable(ctrlr);
+ }
if (err != 0)
goto out;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Nov 17, 3:48 PM (18 h, 17 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
41802440
Default Alt Text
D61635.1794930517.diff (1 KB)
Attached To
Mode
D61635: nvme: escalate to an NVM Subsystem Reset when the controller will not disable
Attached
Detach File
Event Timeline