History

NVMe: Add nvme subsystem reset IOCTL

Controllers can perform optional subsystem resets as introduced in NVMe 1.1. This patch adds an IOCTL to trigger the subsystem reset by writing "NVMe" to the NSSR register.

Jon Derrick committed 11 years ago

Commit 81f03fe1 parent dfbac8c3 files · +13 −1Browse files

Unified · Split

3 files
  1. drivers/block/nvme-core.c +11 −0
  2. include/linux/nvme.h +1 −1
  3. include/uapi/linux/nvme.h +1 −0
drivers/block/nvme-core.c+11−0
@@ -1901,6 +1901,15 @@ static int nvme_user_cmd(struct nvme_dev *dev, struct nvme_ns *ns, · 1900 unmodified lines
19011901 return status;
19021902 }
19031903
1904+static int nvme_subsys_reset(struct nvme_dev *dev)
1905+{
1906+ if (!dev->subsystem)
1907+ return -ENOTTY;
1908+
1909+ writel(0x4E564D65, &dev->bar->nssr); /* "NVMe" */
1910+ return 0;
1911+}
1912+
19041913 static int nvme_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd,
19051914 unsigned long arg)
19061915 {
@@ -2932,6 +2941,8 @@ static long nvme_dev_ioctl(struct file *f, unsigned int cmd, unsigned long arg) · 1025 unmodified lines
29322941 case NVME_IOCTL_RESET:
29332942 dev_warn(dev->dev, "resetting controller\n");
29342943 return nvme_reset(dev);
2944+ case NVME_IOCTL_SUBSYS_RESET:
2945+ return nvme_subsys_reset(dev);
29352946 default:
29362947 return -ENOTTY;
29372948 }
include/linux/nvme.h+1−1
@@ -28,7 +28,7 @@ struct nvme_bar { · 27 unmodified lines
2828 __u32 cc; /* Controller Configuration */
2929 __u32 rsvd1; /* Reserved */
3030 __u32 csts; /* Controller Status */
31− __u32 rsvd2; /* Reserved */
31+ __u32 nssr; /* Subsystem Reset */
3232 __u32 aqa; /* Admin Queue Attributes */
3333 __u64 asq; /* Admin SQ Base Address */
3434 __u64 acq; /* Admin CQ Base Address */
include/uapi/linux/nvme.h+1−0
@@ -584,5 +584,6 @@ struct nvme_passthru_cmd { · 583 unmodified lines
584584 #define NVME_IOCTL_SUBMIT_IO _IOW('N', 0x42, struct nvme_user_io)
585585 #define NVME_IOCTL_IO_CMD _IOWR('N', 0x43, struct nvme_passthru_cmd)
586586 #define NVME_IOCTL_RESET _IO('N', 0x44)
587+#define NVME_IOCTL_SUBSYS_RESET _IO('N', 0x45)
587588
588589 #endif /* _UAPI_LINUX_NVME_H */