public inbox for linux-nvme@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH 1/2] wdc: Update device capabilities for clear pcie corr
@ 2019-02-04 19:54 Dong Ho
  2019-02-04 19:54 ` [PATCH 2/2] wdc: Update file parameter checking Dong Ho
  2019-02-06  0:47 ` [PATCH 1/2] wdc: Update device capabilities for clear pcie corr Keith Busch
  0 siblings, 2 replies; 3+ messages in thread
From: Dong Ho @ 2019-02-04 19:54 UTC (permalink / raw)


---
 plugins/wdc/wdc-nvme.c | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/plugins/wdc/wdc-nvme.c b/plugins/wdc/wdc-nvme.c
index 3aeb28b..2f9a541 100644
--- a/plugins/wdc/wdc-nvme.c
+++ b/plugins/wdc/wdc-nvme.c
@@ -682,7 +682,7 @@ static __u64 wdc_get_drive_capabilities(int fd) {
 			capabilities = (WDC_DRIVE_CAP_CAP_DIAG | WDC_DRIVE_CAP_INTERNAL_LOG | WDC_DRIVE_CAP_C1_LOG_PAGE);
 			break;
 		case WDC_NVME_SN200_DEV_ID:
-			capabilities = (WDC_DRIVE_CAP_CAP_DIAG | WDC_DRIVE_CAP_INTERNAL_LOG);
+			capabilities = (WDC_DRIVE_CAP_CAP_DIAG | WDC_DRIVE_CAP_INTERNAL_LOG | WDC_DRIVE_CAP_CLEAR_PCIE);
 
 			/* verify the 0xCA log page is supported */
 			if (wdc_nvme_check_supported_log_page(fd, WDC_NVME_GET_DEVICE_INFO_LOG_OPCODE) == true)
@@ -711,7 +711,7 @@ static __u64 wdc_get_drive_capabilities(int fd) {
 		case WDC_NVME_SN840_DEV_ID:
 			capabilities = (WDC_DRIVE_CAP_CAP_DIAG | WDC_DRIVE_CAP_INTERNAL_LOG |
 					WDC_DRIVE_CAP_DRIVE_STATUS | WDC_DRIVE_CAP_CLEAR_ASSERT |
-					WDC_DRIVE_CAP_RESIZE);
+					WDC_DRIVE_CAP_RESIZE | WDC_DRIVE_CAP_CLEAR_PCIE);
 
 			/* verify the 0xCA log page is supported */
 			if (wdc_nvme_check_supported_log_page(fd, WDC_NVME_GET_DEVICE_INFO_LOG_OPCODE) == true)
@@ -2611,6 +2611,7 @@ static int wdc_clear_pcie_correctable_errors(int argc, char **argv, struct comma
 	char *desc = "Clear PCIE Correctable Errors.";
 	int fd;
 	int ret;
+	__u64 capabilities = 0;
 	struct nvme_passthru_cmd admin_cmd;
 	const struct argconfig_commandline_options command_line_options[] = {
 		{ NULL, '\0', NULL, CFG_NONE, NULL, no_argument, desc },
@@ -2620,8 +2621,17 @@ static int wdc_clear_pcie_correctable_errors(int argc, char **argv, struct comma
 	if (fd < 0)
 		return fd;
 
-	if (!wdc_check_device(fd))
-		return -1;
+	if (!wdc_check_device(fd)) {
+		ret = -1;
+		goto out;
+	}
+
+	capabilities = wdc_get_drive_capabilities(fd);
+	if ((capabilities & WDC_DRIVE_CAP_CLEAR_PCIE) == 0) {
+		fprintf(stderr, "ERROR : WDC: unsupported device for this command\n");
+		ret = -1;
+		goto out;
+	}
 
 	memset(&admin_cmd, 0, sizeof (admin_cmd));
 	admin_cmd.opcode = WDC_NVME_CLEAR_PCIE_CORR_OPCODE;
@@ -2630,6 +2640,7 @@ static int wdc_clear_pcie_correctable_errors(int argc, char **argv, struct comma
 
 	ret = nvme_submit_passthru(fd, NVME_IOCTL_ADMIN_CMD, &admin_cmd);
 	fprintf(stderr, "NVMe Status:%s(%x)\n", nvme_status_to_string(ret), ret);
+out:
 	return ret;
 }
 static int wdc_drive_status(int argc, char **argv, struct command *command,
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/2] wdc: Update file parameter checking
  2019-02-04 19:54 [PATCH 1/2] wdc: Update device capabilities for clear pcie corr Dong Ho
@ 2019-02-04 19:54 ` Dong Ho
  2019-02-06  0:47 ` [PATCH 1/2] wdc: Update device capabilities for clear pcie corr Keith Busch
  1 sibling, 0 replies; 3+ messages in thread
From: Dong Ho @ 2019-02-04 19:54 UTC (permalink / raw)


---
 plugins/wdc/wdc-nvme.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/plugins/wdc/wdc-nvme.c b/plugins/wdc/wdc-nvme.c
index 2f9a541..99ca5bd 100644
--- a/plugins/wdc/wdc-nvme.c
+++ b/plugins/wdc/wdc-nvme.c
@@ -1154,15 +1154,6 @@ static int wdc_do_cap_diag(int fd, char *file, __u32 xfer_size)
 	__u32 e6_log_hdr_size = WDC_NVME_CAP_DIAG_HEADER_TOC_SIZE;
 	struct wdc_e6_log_hdr *log_hdr;
 	__u32 cap_diag_length;
-	int verify_file;
-
- 	/* verify the passed in file name and path is valid before getting the dump data */
-	verify_file = open(file, O_WRONLY | O_CREAT | O_TRUNC, 0666);
-	if (verify_file < 0) {
-		fprintf(stderr, "ERROR : WDC: open : %s\n", strerror(errno));
-		return -1;
-	}
-	close(verify_file);
 
 	log_hdr = (struct wdc_e6_log_hdr *) malloc(e6_log_hdr_size);
 	if (log_hdr == NULL) {
@@ -1608,6 +1599,15 @@ static int wdc_vs_internal_fw_log(int argc, char **argv, struct command *command
 	}
 
 	if (cfg.file != NULL) {
+		int verify_file;
+
+		/* verify the passed in file name and path is valid before getting the dump data */
+		verify_file = open(cfg.file, O_WRONLY | O_CREAT | O_TRUNC, 0666);
+		if (verify_file < 0) {
+			fprintf(stderr, "ERROR : WDC: open : %s\n", strerror(errno));
+			return -1;
+		}
+		close(verify_file);
 		strncpy(f, cfg.file, PATH_MAX - 1);
 	} else {
 		wdc_UtilsGetTime(&timeInfo);
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 1/2] wdc: Update device capabilities for clear pcie corr
  2019-02-04 19:54 [PATCH 1/2] wdc: Update device capabilities for clear pcie corr Dong Ho
  2019-02-04 19:54 ` [PATCH 2/2] wdc: Update file parameter checking Dong Ho
@ 2019-02-06  0:47 ` Keith Busch
  1 sibling, 0 replies; 3+ messages in thread
From: Keith Busch @ 2019-02-06  0:47 UTC (permalink / raw)


Both patches applied, thanks.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-02-06  0:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-02-04 19:54 [PATCH 1/2] wdc: Update device capabilities for clear pcie corr Dong Ho
2019-02-04 19:54 ` [PATCH 2/2] wdc: Update file parameter checking Dong Ho
2019-02-06  0:47 ` [PATCH 1/2] wdc: Update device capabilities for clear pcie corr Keith Busch

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox