aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJon Derrick <jonathan.derrick@intel.com>2017-08-16 03:51:29 -0400
committerChristoph Hellwig <hch@lst.de>2017-08-28 15:38:18 -0400
commitdbf86b39005d26b21c52a23720e15fb850d71cdc (patch)
tree1d7d0d819fe95cc24dae0fe1641203edb71c1d59
parent62346eaeb2f1a0524b35eaa2f479596f40491165 (diff)
nvme: add support for NVMe 1.3 Timestamp Feature
NVME's Timestamp feature allows controllers to be aware of the epoch time in milliseconds. This patch adds the set features hook for various transports through the identify path, so that resets and resumes can update the controller as necessary. Signed-off-by: Jon Derrick <jonathan.derrick@intel.com> [hch: rebased on top of nvme-4.13 error handling changes, changed nvme_configure_timestamp to return the status] Signed-off-by: Christoph Hellwig <hch@lst.de>
-rw-r--r--drivers/nvme/host/core.c21
-rw-r--r--include/linux/nvme.h2
2 files changed, 23 insertions, 0 deletions
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index a6afeedc009a..0b979e16655e 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -1507,6 +1507,23 @@ static void nvme_set_queue_limits(struct nvme_ctrl *ctrl,
1507 blk_queue_write_cache(q, vwc, vwc); 1507 blk_queue_write_cache(q, vwc, vwc);
1508} 1508}
1509 1509
1510static int nvme_configure_timestamp(struct nvme_ctrl *ctrl)
1511{
1512 __le64 ts;
1513 int ret;
1514
1515 if (!(ctrl->oncs & NVME_CTRL_ONCS_TIMESTAMP))
1516 return 0;
1517
1518 ts = cpu_to_le64(ktime_to_ms(ktime_get_real()));
1519 ret = nvme_set_features(ctrl, NVME_FEAT_TIMESTAMP, 0, &ts, sizeof(ts),
1520 NULL);
1521 if (ret)
1522 dev_warn_once(ctrl->device,
1523 "could not set timestamp (%d)\n", ret);
1524 return ret;
1525}
1526
1510static int nvme_configure_apst(struct nvme_ctrl *ctrl) 1527static int nvme_configure_apst(struct nvme_ctrl *ctrl)
1511{ 1528{
1512 /* 1529 /*
@@ -1861,6 +1878,10 @@ int nvme_init_identify(struct nvme_ctrl *ctrl)
1861 ret = nvme_configure_apst(ctrl); 1878 ret = nvme_configure_apst(ctrl);
1862 if (ret < 0) 1879 if (ret < 0)
1863 return ret; 1880 return ret;
1881
1882 ret = nvme_configure_timestamp(ctrl);
1883 if (ret < 0)
1884 return ret;
1864 1885
1865 ret = nvme_configure_directives(ctrl); 1886 ret = nvme_configure_directives(ctrl);
1866 if (ret < 0) 1887 if (ret < 0)
diff --git a/include/linux/nvme.h b/include/linux/nvme.h
index 1d79046bf9d4..a12b47073273 100644
--- a/include/linux/nvme.h
+++ b/include/linux/nvme.h
@@ -254,6 +254,7 @@ enum {
254 NVME_CTRL_ONCS_WRITE_UNCORRECTABLE = 1 << 1, 254 NVME_CTRL_ONCS_WRITE_UNCORRECTABLE = 1 << 1,
255 NVME_CTRL_ONCS_DSM = 1 << 2, 255 NVME_CTRL_ONCS_DSM = 1 << 2,
256 NVME_CTRL_ONCS_WRITE_ZEROES = 1 << 3, 256 NVME_CTRL_ONCS_WRITE_ZEROES = 1 << 3,
257 NVME_CTRL_ONCS_TIMESTAMP = 1 << 6,
257 NVME_CTRL_VWC_PRESENT = 1 << 0, 258 NVME_CTRL_VWC_PRESENT = 1 << 0,
258 NVME_CTRL_OACS_SEC_SUPP = 1 << 0, 259 NVME_CTRL_OACS_SEC_SUPP = 1 << 0,
259 NVME_CTRL_OACS_DIRECTIVES = 1 << 5, 260 NVME_CTRL_OACS_DIRECTIVES = 1 << 5,
@@ -688,6 +689,7 @@ enum {
688 NVME_FEAT_ASYNC_EVENT = 0x0b, 689 NVME_FEAT_ASYNC_EVENT = 0x0b,
689 NVME_FEAT_AUTO_PST = 0x0c, 690 NVME_FEAT_AUTO_PST = 0x0c,
690 NVME_FEAT_HOST_MEM_BUF = 0x0d, 691 NVME_FEAT_HOST_MEM_BUF = 0x0d,
692 NVME_FEAT_TIMESTAMP = 0x0e,
691 NVME_FEAT_KATO = 0x0f, 693 NVME_FEAT_KATO = 0x0f,
692 NVME_FEAT_SW_PROGRESS = 0x80, 694 NVME_FEAT_SW_PROGRESS = 0x80,
693 NVME_FEAT_HOST_ID = 0x81, 695 NVME_FEAT_HOST_ID = 0x81,