Skip to contentSkip to conversation

ndctl list show broken nvdimm info.

PATCH In review Yasunori Goto 2 participants 11 messages Aug 4, 2017 – Aug 7, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover ndctl list show broken nvdimm info.

Hello,

I made a patch set to show information of broken NVDIMM.

When a region has a broken block, user need to replace
the NVDIMM which includes the block.
However there is no information to find which DIMM module have the block. Not only ndctl does not have such information, nvdimm driver can not find it.

Fortunately, ACPI 6.2 has new specification of _DSM.
It is "translate spa" which can get NVDIMM handle
and DPA(Dimm Physical Address) from SPA(system Physical Addreess). It helps for ndctl command to find broken NVDIMM.
So, This patch set includes followings.
- support Translate SPA interface,
- ndctl ask DIMM by Translate SPA and show it.

To be honest, since I'm still newbie about the internal of NVDIMM driver and ndctl, I may misunderstand/miss something, and I feel my patch set has likely quick hack....

Especiall, I'm not sure about the followings.

- What is the maximum size of input/output argument table for _DSM for Translate SPA and ioctl()? It seems to depend on max # of ways of mirroring. Since ACPI 6.2 seems not to mention it,
it depends on vedor's decision, I think....
Usually, mirroring is 2 way, but I'm not sure it is the maximum number...

- Though libndctl has many good API, I'm not sure how new APIs should be named.

However, I think progress will be better by getting many others advises than thinking the aboves alone. So, I hope this post is good start to make this feature.

Anyway, please check and comment.

Thanks,
---
Yasunori Goto

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm

#1 lore raw

PATCH 1/5 Remove old enum definition of "Translate Spa"

Remove old enum definition of "Translate Spa".

Translate SPA becomes standard specification on ACPI 6.2, but current definition is likely temporary.
So it is removed.

---
 drivers/acpi/nfit/core.c | 2 --
 1 file changed, 2 deletions(-)
drivers/acpi/nfit/core.c +0 -2
index 19182d0..5334755 100644
@@ -1626,7 +1626,6 @@ static int acpi_nfit_register_dimms(struct acpi_nfit_desc *acpi_desc)
  * these commands.
  */
 enum nfit_aux_cmds {
-        NFIT_CMD_TRANSLATE_SPA = 5,
         NFIT_CMD_ARS_INJECT_SET = 7,
         NFIT_CMD_ARS_INJECT_CLEAR = 8,
         NFIT_CMD_ARS_INJECT_GET = 9,
@@ -1655,7 +1654,6 @@ static void acpi_nfit_init_dsms(struct acpi_nfit_desc *acpi_desc)
 		(1 << ND_CMD_ARS_START) |
 		(1 << ND_CMD_ARS_STATUS) |
 		(1 << ND_CMD_CLEAR_ERROR) |
-		(1 << NFIT_CMD_TRANSLATE_SPA) |
 		(1 << NFIT_CMD_ARS_INJECT_SET) |
 		(1 << NFIT_CMD_ARS_INJECT_CLEAR) |
 		(1 << NFIT_CMD_ARS_INJECT_GET);

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm

#2 lore raw

Re: [RFC/Patch 1/5] Remove old enum definition of "Translate Spa"

Quoted 27 lines · Yasunori Goto

Remove old enum definition of "Translate Spa".

Translate SPA becomes standard specification on ACPI 6.2, but current definition is likely temporary.
So it is removed.

---
 drivers/acpi/nfit/core.c | 2 --
 1 file changed, 2 deletions(-)
drivers/acpi/nfit/core.c +0 -1
index 19182d0..5334755 100644
@@ -1626,7 +1626,6 @@ static int acpi_nfit_register_dimms(struct acpi_nfit_desc *acpi_desc)
  * these commands.
  */
 enum nfit_aux_cmds {
-        NFIT_CMD_TRANSLATE_SPA = 5,
         NFIT_CMD_ARS_INJECT_SET = 7,
         NFIT_CMD_ARS_INJECT_CLEAR = 8,
         NFIT_CMD_ARS_INJECT_GET = 9,

drivers/acpi/nfit/core.c static void acpi_nfit_init_dsms(struct acpi_nfit_desc *acpi_desc) · line 1659

Quoted 7 lines
drivers/acpi/nfit/core.c +0 -1
@@ -1655,7 +1654,6 @@ static void acpi_nfit_init_dsms(struct acpi_nfit_desc *acpi_desc)
                (1 << ND_CMD_ARS_START) |
                (1 << ND_CMD_ARS_STATUS) |
                (1 << ND_CMD_CLEAR_ERROR) |
-               (1 << NFIT_CMD_TRANSLATE_SPA) |
                (1 << NFIT_CMD_ARS_INJECT_SET) |
                (1 << NFIT_CMD_ARS_INJECT_CLEAR) |
                (1 << NFIT_CMD_ARS_INJECT_GET);

Hmm, those definitions are brand new as of the 4.13 kernel, see commit 7db5bb33add5 "libnvdimm, acpi, nfit: Add bus level dsm mask for pass thru". What's going on here is that we stopped defining new ND_CMD numbers for each new DSM that is added to the specification. Instead, we use the ND_CMD_CALL mechanism to wrap these new command payloads and pass them through to the BIOS. So, these definitions are needed to allow that passthrough mechanism to work.
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm

#3 lore raw

Re: [RFC/Patch 1/5] Remove old enum definition of "Translate Spa"

Quoted 36 lines · Yasunori Goto
Quoted 27 lines

Remove old enum definition of "Translate Spa".

Translate SPA becomes standard specification on ACPI 6.2, but current definition is likely temporary.
So it is removed.

---
 drivers/acpi/nfit/core.c | 2 --
 1 file changed, 2 deletions(-)
drivers/acpi/nfit/core.c +0 -1
index 19182d0..5334755 100644
@@ -1626,7 +1626,6 @@ static int acpi_nfit_register_dimms(struct acpi_nfit_desc *acpi_desc)
  * these commands.
  */
 enum nfit_aux_cmds {
-        NFIT_CMD_TRANSLATE_SPA = 5,
         NFIT_CMD_ARS_INJECT_SET = 7,
         NFIT_CMD_ARS_INJECT_CLEAR = 8,
         NFIT_CMD_ARS_INJECT_GET = 9,

drivers/acpi/nfit/core.c static void acpi_nfit_init_dsms(struct acpi_nfit_desc *acpi_desc) · line 1659

Quoted 7 lines
drivers/acpi/nfit/core.c +0 -1
@@ -1655,7 +1654,6 @@ static void acpi_nfit_init_dsms(struct acpi_nfit_desc *acpi_desc)
                (1 << ND_CMD_ARS_START) |
                (1 << ND_CMD_ARS_STATUS) |
                (1 << ND_CMD_CLEAR_ERROR) |
-               (1 << NFIT_CMD_TRANSLATE_SPA) |
                (1 << NFIT_CMD_ARS_INJECT_SET) |
                (1 << NFIT_CMD_ARS_INJECT_CLEAR) |
                (1 << NFIT_CMD_ARS_INJECT_GET);
Quoted 7 lines

Hmm, those definitions are brand new as of the 4.13 kernel, see commit 7db5bb33add5 "libnvdimm, acpi, nfit: Add bus level dsm mask for pass thru". What's going on here is that we stopped defining new ND_CMD numbers for each new DSM that is added to the specification. Instead, we use the ND_CMD_CALL mechanism to wrap these new command payloads and pass them through to the BIOS. So, these definitions are needed to allow that passthrough mechanism to work.

Ah, Ok.
I'll check it.

Thanks,

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm

#4 lore raw

PATCH 2/5 Support Translate SPA for NVDIMM Root Device.

In reply to Yasunori Goto

Support Translate SPA for NVDIMM Root Device.

ACPI 6.2 has new specification on _DSM of NVDIMM Root Device It is "Translate SPA" which translate from system physical address(SPA) to NVDIMM handle and dimm physical address(DPA).

This patch is to support Translate SPA.

---
 drivers/acpi/nfit/core.c   |  7 +++++--
 drivers/nvdimm/bus.c       | 11 ++++++++++-
 include/linux/libnvdimm.h  |  2 +-
 include/uapi/linux/ndctl.h |  4 ++++
 4 files changed, 20 insertions(+), 4 deletions(-)
drivers/acpi/nfit/core.c +5 -2
index 5334755..e8c67a3 100644
@@ -173,6 +173,8 @@ static int xlat_bus_status(void *buf, unsigned int cmd, u32 status)
 		if (clear_err->length > clear_err->cleared)
 			return clear_err->cleared;
 		return 0;
+	case ND_CMD_TRANS_SPA:
+		return 0;
 	default:
 		break;
 	}
@@ -352,7 +354,7 @@ int acpi_nfit_ctl(struct nvdimm_bus_descriptor *nd_desc, struct nvdimm *nvdimm,
 	 * Set fw_status for all the commands with a known format to be
 	 * later interpreted by xlat_status().
 	 */
-	if (i >= 1 && ((cmd >= ND_CMD_ARS_CAP && cmd <= ND_CMD_CLEAR_ERROR)
+	if (i >= 1 && ((cmd >= ND_CMD_ARS_CAP && cmd <= ND_CMD_TRANS_SPA)
 			|| (cmd >= ND_CMD_SMART && cmd <= ND_CMD_VENDOR)))
 		fw_status = *(u32 *) out_obj->buffer.pointer;
 
@@ -1644,7 +1646,7 @@ static void acpi_nfit_init_dsms(struct acpi_nfit_desc *acpi_desc)
 	if (!adev)
 		return;
 
-	for (i = ND_CMD_ARS_CAP; i <= ND_CMD_CLEAR_ERROR; i++)
+	for (i = ND_CMD_ARS_CAP; i <= ND_CMD_TRANS_SPA; i++)
 		if (acpi_check_dsm(adev->handle, guid, 1, 1ULL << i))
 			set_bit(i, &nd_desc->cmd_mask);
 	set_bit(ND_CMD_CALL, &nd_desc->cmd_mask);
@@ -1654,6 +1656,7 @@ static void acpi_nfit_init_dsms(struct acpi_nfit_desc *acpi_desc)
 		(1 << ND_CMD_ARS_START) |
 		(1 << ND_CMD_ARS_STATUS) |
 		(1 << ND_CMD_CLEAR_ERROR) |
+		(1 << ND_CMD_TRANS_SPA) |
 		(1 << NFIT_CMD_ARS_INJECT_SET) |
 		(1 << NFIT_CMD_ARS_INJECT_CLEAR) |
 		(1 << NFIT_CMD_ARS_INJECT_GET);
drivers/nvdimm/bus.c +10 -1
index 937fafa..ef05fe1 100644
@@ -727,6 +727,12 @@ static const struct nd_cmd_desc __nd_cmd_bus_descs[] = {
 		.out_num = 3,
 		.out_sizes = { 4, 4, 8, },
 	},
+	[ND_CMD_TRANS_SPA] = {
+		.in_num = 1,
+		.in_sizes = { 8, },
+		.out_num = 7,
+		.out_sizes = { 2, 2, 1, 3, 8, 4, UINT_MAX, },
+	},
 	[ND_CMD_CALL] = {
 		.in_num = 2,
 		.in_sizes = { sizeof(struct nd_cmd_pkg), UINT_MAX, },
@@ -801,7 +807,9 @@ u32 nd_cmd_out_size(struct nvdimm *nvdimm, int cmd,
 		if (out_field[1] - 8 == remainder)
 			return remainder;
 		return out_field[1] - 4;
-	} else if (cmd == ND_CMD_CALL) {
+	} else if (!nvdimm && cmd == ND_CMD_TRANS_SPA && idx == 6)
+		return out_field[2];
+	else if (cmd == ND_CMD_CALL) {
 		struct nd_cmd_pkg *pkg = (struct nd_cmd_pkg *) in_field;
 
 		return pkg->nd_size_out;
@@ -947,6 +955,7 @@ static int __nd_ioctl(struct nvdimm_bus *nvdimm_bus, struct nvdimm *nvdimm,
 		case ND_CMD_SET_CONFIG_DATA:
 		case ND_CMD_ARS_START:
 		case ND_CMD_CLEAR_ERROR:
+		case ND_CMD_TRANS_SPA:
 		case ND_CMD_CALL:
 			dev_dbg(&nvdimm_bus->dev, "'%s' command while read-only.\n",
 					nvdimm ? nvdimm_cmd_name(cmd)
include/linux/libnvdimm.h +1 -1
index f3d3e6a..c179ed0 100644
@@ -29,7 +29,7 @@ enum {
 
 	/* need to set a limit somewhere, but yes, this is likely overkill */
 	ND_IOCTL_MAX_BUFLEN = SZ_4M,
-	ND_CMD_MAX_ELEM = 5,
+	ND_CMD_MAX_ELEM = 7,
 	ND_CMD_MAX_ENVELOPE = 256,
 	ND_MAX_MAPPINGS = 32,
 
include/uapi/linux/ndctl.h +4 -0
index 6d3c542..91bf129 100644
@@ -190,6 +190,7 @@ enum {
 	ND_CMD_ARS_START = 2,
 	ND_CMD_ARS_STATUS = 3,
 	ND_CMD_CLEAR_ERROR = 4,
+	ND_CMD_TRANS_SPA = 5,
 
 	/* per-dimm commands */
 	ND_CMD_SMART = 1,
@@ -218,6 +219,7 @@ static inline const char *nvdimm_bus_cmd_name(unsigned cmd)
 		[ND_CMD_ARS_START] = "ars_start",
 		[ND_CMD_ARS_STATUS] = "ars_status",
 		[ND_CMD_CLEAR_ERROR] = "clear_error",
+		[ND_CMD_TRANS_SPA] = "trans_spa",
 		[ND_CMD_CALL] = "cmd_call",
 	};
 
@@ -280,6 +282,8 @@ static inline const char *nvdimm_cmd_name(unsigned cmd)
 
 #define ND_IOCTL_CLEAR_ERROR		_IOWR(ND_IOCTL, ND_CMD_CLEAR_ERROR,\
 					struct nd_cmd_clear_error)
+#define ND_IOCTL_TRANS_SPA		_IOWR(ND_IOCTL, ND_CMD_TRANS_SPA,\
+					struct nd_cmd_trans_spa)
 
 #define ND_DEVICE_DIMM 1            /* nd_dimm: container for "config data" */
 #define ND_DEVICE_REGION_PMEM 2     /* nd_region: (parent of PMEM namespaces) */

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm

#5 lore raw

Re: [RFC/Patch 2/5] Support Translate SPA for NVDIMM Root Device.

Quoted 9 lines · Yasunori Goto

Support Translate SPA for NVDIMM Root Device.

ACPI 6.2 has new specification on _DSM of NVDIMM Root Device It is "Translate SPA" which translate from system physical address(SPA) to NVDIMM handle and dimm physical address(DPA).

This patch is to support Translate SPA.

Ah, yes, this is not needed. The Translate SPA command can be submitted via ND_CMD_CALL mechanism.
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm

#6 lore raw

PATCH 3/5 nfit_test supports Translate SPA

In reply to Yasunori Goto

nfit_test supports Translate SPA

To test interface of Translate SPA, nfit_test must emulate it. This test module searches region which includes spa and returns only 1 dimm handle which is last one currently.

---
 drivers/nvdimm/region_devs.c     |  1 +
 tools/testing/nvdimm/test/nfit.c | 80 +++++++++++++++++++++++++++++++++++++++-
 2 files changed, 80 insertions(+), 1 deletion(-)
drivers/nvdimm/region_devs.c +1 -0
index 5954cfb..3c8cc7f 100644
@@ -162,6 +162,7 @@ bool is_nd_pmem(struct device *dev)
 {
 	return dev ? dev->type == &nd_pmem_device_type : false;
 }
+EXPORT_SYMBOL_GPL(is_nd_pmem);
 
 bool is_nd_blk(struct device *dev)
 {
tools/testing/nvdimm/test/nfit.c +79 -1

110 lines not on this page · raw message

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm

#7 lore raw

PATCH 4/5 libndctl Make interfaces to use Translate SPA

In reply to Yasunori Goto

ndctl:libndctl Make interfaces to use Translate SPA.

This patch makes 3 new interfaces :
- to ask bus has translate SPA feature.
- to call translate SPA.
- to find DIMM by SPA address.

Note) I'm not sure how many buffer should be prepared, because
it depends on max # of mirroring way.
This patch assume maxmum # is 4 way.

---
 configure.ac                 |  19 ++++++++
 ndctl/lib/libndctl-private.h |   7 +++
 ndctl/lib/libndctl.c         | 103 ++++++++++++++++++++++++++++++++++++++++++-
 ndctl/lib/libndctl.sym       |   3 ++
 ndctl/libndctl.h.in          |  23 ++++++++++
 ndctl/ndctl.h                |   8 ++++
 6 files changed, 162 insertions(+), 1 deletion(-)
configure.ac +19 -0
index 316f5b7..653fde0 100644
@@ -162,6 +162,25 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
 )
 AM_CONDITIONAL([ENABLE_CLEAR_ERROR], [test "x$enable_clear_err" = "xyes"])
 
+AC_MSG_CHECKING([for TRANSLATE SPA support])
+AC_LANG(C)
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+                       #ifdef HAVE_NDCTL_H
+                       #include <linux/ndctl.h>
+                       #else
+                       #include "ndctl/ndctl.h"
+                       #endif
+                       ]], [[
+                       int x = ND_CMD_TRANS_SPA;
+                       ]]
+               )], [AC_MSG_RESULT([yes])
+                    enable_trans_spa=yes
+                    AC_DEFINE([HAVE_NDCTL_TRANS_SPA], [1],
+                               [Define to 1 if ndctl.h has TRANSLATE SPA support.])
+               ], [AC_MSG_RESULT([no])]
+)
+AM_CONDITIONAL([ENABLE_TRANS_SPA], [test "x$enable_trans_spa" = "xyes"])
+
 AC_MSG_CHECKING([for device DAX support])
 AC_LANG(C)
 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
ndctl/lib/libndctl-private.h +7 -0
index 8f10fbc..a1fcd2f 100644
@@ -196,6 +196,7 @@ struct ndctl_cmd {
 #ifdef HAVE_NDCTL_CLEAR_ERROR
 		struct nd_cmd_clear_error clear_err[0];
 #endif
+		struct nd_cmd_trans_spa trans_spa[0];
 		struct ndn_pkg_hpe1 hpe1[0];
 		struct ndn_pkg_msft msft[0];
 		struct nd_cmd_smart smart[0];
@@ -250,6 +251,12 @@ static const int nd_cmd_clear_error = ND_CMD_CLEAR_ERROR;
 static const int nd_cmd_clear_error;
 #endif
 
+#ifdef HAVE_NDCTL_TRANS_SPA
+static const int nd_cmd_trans_spa = ND_CMD_TRANS_SPA;
+#else
+static const int nd_cmd_trans_spa;
+#endif
+
 static inline struct ndctl_bus *cmd_to_bus(struct ndctl_cmd *cmd)
 {
 	if (cmd->dimm)
ndctl/lib/libndctl.c +102 -1

121 lines not on this page · raw message

ndctl/lib/libndctl.sym +3 -0
index 0e59243..6846f20 100644
@@ -36,6 +36,9 @@ global:
 	ndctl_bus_get_provider;
 	ndctl_bus_get_ctx;
 	ndctl_bus_wait_probe;
+	ndctl_bus_has_trans_spa;
+	ndctl_bus_cmd_trans_spa;
+	ndctl_dimms_get_by_spa;
 	ndctl_dimm_get_first;
 	ndctl_dimm_get_next;
 	ndctl_dimm_get_handle;
ndctl/libndctl.h.in +23 -0
index 200c5cf..3a6256b 100644
@@ -347,6 +347,29 @@ static inline unsigned int ndctl_cmd_smart_threshold_get_spares(
 }
 #endif
 
+#if HAVE_NDCTL_TRANS_SPA == 1
+int ndctl_bus_has_trans_spa(struct ndctl_bus *bus);
+int ndctl_bus_cmd_trans_spa(struct ndctl_bus *bus,
+	unsigned long long addr, unsigned int *handles, unsigned long long *dpas);
+int ndctl_dimms_get_by_spa(struct ndctl_bus *bus,
+	unsigned long long spa, struct ndctl_dimm **dimms);
+#else
+static inline int ndctl_bus_has_trans_spa(struct ndctl_bus *bus)
+{
+	return 0;
+}
+static inline int ndctl_bus_cmd_trans_spa(struct ndctl_bus *bus,
+	unsigned long long addr, unsigned int *handles, unsigned long long *dpas)
+{
+	return 0;
+}
+static inline int ndctl_dimms_get_by_spa(struct ndctl_bus *bus,
+	unsigned long long spa, struct ndctl_dimm **dimms)
+{
+	return 0;
+}
+#endif
+
 struct ndctl_cmd *ndctl_dimm_cmd_new_vendor_specific(struct ndctl_dimm *dimm,
 		unsigned int opcode, size_t input_size, size_t output_size);
 ssize_t ndctl_cmd_vendor_set_input(struct ndctl_cmd *cmd, void *buf,
ndctl/ndctl.h +8 -0
index d70b97d..add0d58 100644
@@ -35,6 +35,9 @@ struct nd_cmd_smart {
 #define ND_SMART_CRITICAL_HEALTH	(1 << 1)
 #define ND_SMART_FATAL_HEALTH		(1 << 2)
 
+#define ND_MIRROR_MAX_WAY 4 /* XXX: assume max mirroring way */
+#define ND_TRANS_SPA_STATUS_INVALID_SPA  2
+
 struct nd_smart_payload {
 	__u32 flags;
 	__u8 reserved0[4];
@@ -190,6 +193,7 @@ enum {
 	ND_CMD_ARS_START = 2,
 	ND_CMD_ARS_STATUS = 3,
 	ND_CMD_CLEAR_ERROR = 4,
+	ND_CMD_TRANS_SPA = 5,
 
 	/* per-dimm commands */
 	ND_CMD_SMART = 1,
@@ -217,6 +221,7 @@ static __inline__ const char *nvdimm_bus_cmd_name(unsigned cmd)
 		[ND_CMD_ARS_START] = "ars_start",
 		[ND_CMD_ARS_STATUS] = "ars_status",
 		[ND_CMD_CLEAR_ERROR] = "clear_error",
+		[ND_CMD_TRANS_SPA] = "trans_spa",
 		[ND_CMD_CALL] = "cmd_call",
 	};
 
@@ -280,6 +285,9 @@ static __inline__ const char *nvdimm_cmd_name(unsigned cmd)
 #define ND_IOCTL_CLEAR_ERROR		_IOWR(ND_IOCTL, ND_CMD_CLEAR_ERROR,\
 					struct nd_cmd_clear_error)
 
+#define ND_IOCTL_TRANS_SPA 		_IOWR(ND_IOCTL, ND_CMD_TRANS_SPA,\
+					struct nd_cmd_trans_spa)
+
 #define ND_DEVICE_DIMM 1            /* nd_dimm: container for "config data" */
 #define ND_DEVICE_REGION_PMEM 2     /* nd_region: (parent of PMEM namespaces) */
 #define ND_DEVICE_REGION_BLK 3      /* nd_region: (parent of BLK namespaces) */

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm

#8 lore raw

Re: [RFC/Patch 4/5] libndctl Make interfaces to use Translate SPA

Quoted 1 line · Yasunori Goto

ndctl:libndctl Make interfaces to use Translate SPA.

A process note, please separate kernel patches and ndctl patches into a different set. The expectation is that all the [PATCH 1/n] to [PATCH n/n] should apply to the same project.

I have typically been marking my ndctl patches with a prefix like [ndctl PATCH 1/n], where the kernel patches just say [PATCH].

Quoted 10 lines

This patch makes 3 new interfaces :
- to ask bus has translate SPA feature.
- to call translate SPA.
- to find DIMM by SPA address.

Note) I'm not sure how many buffer should be prepared, because
it depends on max # of mirroring way.
This patch assume maxmum # is 4 way.

I think it is ok for now to just reserve space for 1-DIMM. When / if mirroring support materializes in the kernel you should then be able to detect how many DIMMs are in the mirror set. Since mirror support would require changes to the Namespace Label specification I think we have time to circle back and fix up ndctl for the multiple DIMM per Translate SPA request case.

Otherwise, the kernel will handle the case where the provided buffer is too small and return an error.
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm

#9 lore raw

Re: [RFC/Patch 4/5] libndctl Make interfaces to use Translate SPA

Quoted 21 lines · Yasunori Goto
Quoted 1 line

ndctl:libndctl Make interfaces to use Translate SPA.

A process note, please separate kernel patches and ndctl patches into a different set. The expectation is that all the [PATCH 1/n] to [PATCH n/n] should apply to the same project.

I have typically been marking my ndctl patches with a prefix like [ndctl PATCH 1/n], where the kernel patches just say [PATCH].

Quoted 10 lines

This patch makes 3 new interfaces :
- to ask bus has translate SPA feature.
- to call translate SPA.
- to find DIMM by SPA address.

Note) I'm not sure how many buffer should be prepared, because
it depends on max # of mirroring way.
This patch assume maxmum # is 4 way.

Quoted 6 lines

I think it is ok for now to just reserve space for 1-DIMM. When / if mirroring support materializes in the kernel you should then be able to detect how many DIMMs are in the mirror set. Since mirror support would require changes to the Namespace Label specification I think we have time to circle back and fix up ndctl for the multiple DIMM per Translate SPA request case.

I see. I'll reserve space for 1-DIMM.

Quoted 4 lines

Otherwise, the kernel will handle the case where the provided buffer is too small and return an error.

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm

#10 lore raw

PATCH 5/5 ndctl: show dimm's name which has badblock by ndctl list command.

In reply to Yasunori Goto

ndctl: show dimm's name which has badblock by ndctl list command.

This patch uses translate SPA interface to get bad dimm info.

Since this patch is likely Proof of Concept, because libnvdimm functions of this feature will change yet. So, I don't think this patch can be merged.

However, I hope this patch is good start for discussion....

---
 util/json.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)
util/json.c +49 -0
index 2b2b5af..b791054 100644
@@ -381,6 +381,22 @@ struct json_object *util_region_badblocks_to_json(struct ndctl_region *region,
 
 	ndctl_region_badblock_foreach(region, bb) {
 		if (flags & UTIL_JSON_MEDIA_ERRORS) {
+			struct ndctl_bus *bus;
+			struct ndctl_dimm *dimms[ND_MIRROR_MAX_WAY];
+			memset(dimms, 0, sizeof(dimms));
+			bus = ndctl_region_get_bus(region);
+			if (ndctl_bus_has_trans_spa(bus)) {
+				int rc;
+				unsigned long long spa;
+				spa = ndctl_region_get_resource(region);
+				if (spa == ULONG_MAX)
+					goto err_array;
+				spa += bb->offset << 9;
+				rc = ndctl_dimms_get_by_spa(bus, spa, dimms);
+				if (rc)
+					goto err_array;
+			}
+
 			jbb = json_object_new_object();
 			if (!jbb)
 				goto err_array;
@@ -395,6 +411,14 @@ struct json_object *util_region_badblocks_to_json(struct ndctl_region *region,
 				goto err;
 			json_object_object_add(jbb, "length", jobj);
 
+			for (int i = 0; i < ND_MIRROR_MAX_WAY; i++) {
+				if (dimms[i]) {
+					jobj = json_object_new_string(ndctl_dimm_get_devname(dimms[i]));
+					if (!jobj)
+						goto err;
+					json_object_object_add(jbb, "dimm", jobj);
+				}
+			}
 			json_object_array_add(jbbs, jbb);
 		}
 
@@ -436,6 +460,8 @@ static struct json_object *dev_badblocks_to_json(struct ndctl_region *region,
 
 	ndctl_region_badblock_foreach(region, bb) {
 		unsigned long long bb_begin, bb_end, begin, end;
+		struct ndctl_bus *bus;
+		struct ndctl_dimm *dimms[ND_MIRROR_MAX_WAY];
 
 		bb_begin = region_begin + (bb->offset << 9);
 		bb_end = bb_begin + (bb->len << 9) - 1;
@@ -453,6 +479,20 @@ static struct json_object *dev_badblocks_to_json(struct ndctl_region *region,
 		else
 			end = bb_end;
 
+		memset(dimms, 0, sizeof(dimms));
+		bus = ndctl_region_get_bus(region);
+		if (ndctl_bus_has_trans_spa(bus)) {
+			int rc;
+			unsigned long long spa;
+			spa = ndctl_region_get_resource(region);
+			if (spa == ULLONG_MAX)
+				goto err_array;
+			spa += bb->offset << 9;
+			rc = ndctl_dimms_get_by_spa(bus, spa, dimms);
+			if (rc)
+				goto err_array;
+		}
+
 		offset = (begin - dev_begin) >> 9;
 		len = (end - begin + 1) >> 9;
 
@@ -472,6 +512,15 @@ static struct json_object *dev_badblocks_to_json(struct ndctl_region *region,
 				goto err;
 			json_object_object_add(jbb, "length", jobj);
 
+			for (int i = 1; i < ND_MIRROR_MAX_WAY; i++) {
+				if (dimms[i]) {
+					jobj = json_object_new_string(ndctl_dimm_get_devname(dimms[i]));
+					if (!jobj)
+						goto err;
+					json_object_object_add(jbb, "dimm", jobj);
+				}
+			}
+
 			json_object_array_add(jbbs, jbb);
 		}
 		bbs += len;

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm