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.
Unified · Split
| @@ -1901,6 +1901,15 @@ static int nvme_user_cmd(struct nvme_dev *dev, struct nvme_ns *ns, · 1900 unmodified lines | |||
| 1901 | return status; | 1901 | return status; |
| 1902 | } | 1902 | } |
| 1903 | 1903 | ||
| 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 | |||
| 1904 | static int nvme_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd, | 1913 | static int nvme_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd, |
| 1905 | unsigned long arg) | 1914 | unsigned long arg) |
| 1906 | { | 1915 | { |
| @@ -2932,6 +2941,8 @@ static long nvme_dev_ioctl(struct file *f, unsigned int cmd, unsigned long arg) · 1025 unmodified lines | |||
| 2932 | case NVME_IOCTL_RESET: | 2941 | case NVME_IOCTL_RESET: |
| 2933 | dev_warn(dev->dev, "resetting controller\n"); | 2942 | dev_warn(dev->dev, "resetting controller\n"); |
| 2934 | return nvme_reset(dev); | 2943 | return nvme_reset(dev); |
| 2944 | case NVME_IOCTL_SUBSYS_RESET: | ||
| 2945 | return nvme_subsys_reset(dev); | ||
| 2935 | default: | 2946 | default: |
| 2936 | return -ENOTTY; | 2947 | return -ENOTTY; |
| 2937 | } | 2948 | } |
| @@ -28,7 +28,7 @@ struct nvme_bar { · 27 unmodified lines | |||
| 28 | __u32 cc; /* Controller Configuration */ | 28 | __u32 cc; /* Controller Configuration */ |
| 29 | __u32 rsvd1; /* Reserved */ | 29 | __u32 rsvd1; /* Reserved */ |
| 30 | __u32 csts; /* Controller Status */ | 30 | __u32 csts; /* Controller Status */ |
| 31 | __u32 rsvd2; /* Reserved */ | 31 | __u32 nssr; /* Subsystem Reset */ |
| 32 | __u32 aqa; /* Admin Queue Attributes */ | 32 | __u32 aqa; /* Admin Queue Attributes */ |
| 33 | __u64 asq; /* Admin SQ Base Address */ | 33 | __u64 asq; /* Admin SQ Base Address */ |
| 34 | __u64 acq; /* Admin CQ Base Address */ | 34 | __u64 acq; /* Admin CQ Base Address */ |
| @@ -584,5 +584,6 @@ struct nvme_passthru_cmd { · 583 unmodified lines | |||
| 584 | #define NVME_IOCTL_SUBMIT_IO _IOW('N', 0x42, struct nvme_user_io) | 584 | #define NVME_IOCTL_SUBMIT_IO _IOW('N', 0x42, struct nvme_user_io) |
| 585 | #define NVME_IOCTL_IO_CMD _IOWR('N', 0x43, struct nvme_passthru_cmd) | 585 | #define NVME_IOCTL_IO_CMD _IOWR('N', 0x43, struct nvme_passthru_cmd) |
| 586 | #define NVME_IOCTL_RESET _IO('N', 0x44) | 586 | #define NVME_IOCTL_RESET _IO('N', 0x44) |
| 587 | #define NVME_IOCTL_SUBSYS_RESET _IO('N', 0x45) | ||
| 587 | 588 | ||
| 588 | #endif /* _UAPI_LINUX_NVME_H */ | 589 | #endif /* _UAPI_LINUX_NVME_H */ |