* [PATCH v4 0/3] acpi nfit: make emulation of translate SPA on nfit_test
@ 2017-09-22 7:44 Yasunori Goto
2017-09-22 7:46 ` [PATCH v4 1/3] nfit_test Make private definitions to command emulation Yasunori Goto
` (3 more replies)
0 siblings, 4 replies; 6+ messages in thread
From: Yasunori Goto @ 2017-09-22 7:44 UTC (permalink / raw)
To: NVDIMM-ML
Hello
I made a v4 patch set to emulate translate SPA by nfit_test.ko module.
If possible, please merge it.
----
This patch set is to emulate translate SPA feature by nfit_test.ko.
Certainly the nfit acpi driver supports translate SPA interface
via ND_CMD_CALL. But nfit_test does not support it yet.
To test translate SPA with nfit_test, this patch set is needed.
---
Change log since v3 [1]:
- Rebase current libnvdimm-for-next branch.
- Fix over 80 character lines and too much tabs which is pointed
by Verma-san. (Thanks!)
- Since ndctl became to use the name "nfit_cmd" instead of "passthru",
"passthru" is renamed to "nfit_cmd".
Change log since v2 [2]:
- Make private defintion just for nfit_test.
(NFIT_CMD_TRANSLATE_SPA, struct nd_cmd_translate_spa, and others)
- Check region by kobj.name instead of using is_nd_pmem().
Change log since v1 [3]:
- Separate patch set of kenel from ndctl patch set.
- Change interface via ND_CMD_CALL.
[1] https://www.mail-archive.com/linux-nvdimm@lists.01.org/msg05863.html
[2] https://www.mail-archive.com/linux-nvdimm@lists.01.org/msg05582.html
[3] https://www.mail-archive.com/linux-nvdimm@lists.01.org/msg05287.html
----
Thanks,
---
Yasunori Goto
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v4 1/3] nfit_test Make private definitions to command emulation
2017-09-22 7:44 [PATCH v4 0/3] acpi nfit: make emulation of translate SPA on nfit_test Yasunori Goto
@ 2017-09-22 7:46 ` Yasunori Goto
2017-09-22 7:47 ` [PATCH v4 2/3] acpi nfit: Enable to show what feature is supported via ND_CMD_CALL for nfit_test Yasunori Goto
` (2 subsequent siblings)
3 siblings, 0 replies; 6+ messages in thread
From: Yasunori Goto @ 2017-09-22 7:46 UTC (permalink / raw)
To: NVDIMM-ML
Move private definitions to command emulation.
These definitions were originally defined at include/uapi/linux/ndctl.h,
but they are used at only nfit_test emulation now.
Signed-off-by: Yasunori Goto <y-goto@jp.fujitsu.com>
---
include/uapi/linux/ndctl.h | 37 ---------------------------
tools/testing/nvdimm/test/nfit_test.h | 47 +++++++++++++++++++++++++++++++++++
2 files changed, 47 insertions(+), 37 deletions(-)
diff --git a/include/uapi/linux/ndctl.h b/include/uapi/linux/ndctl.h
index 6d3c542..3f03567 100644
--- a/include/uapi/linux/ndctl.h
+++ b/include/uapi/linux/ndctl.h
@@ -145,43 +145,6 @@ struct nd_cmd_clear_error {
__u64 cleared;
} __packed;
-struct nd_cmd_trans_spa {
- __u64 spa;
- __u32 status;
- __u8 flags;
- __u8 _reserved[3];
- __u64 trans_length;
- __u32 num_nvdimms;
- struct nd_nvdimm_device {
- __u32 nfit_device_handle;
- __u32 _reserved;
- __u64 dpa;
- } __packed devices[0];
-
-} __packed;
-
-struct nd_cmd_ars_err_inj {
- __u64 err_inj_spa_range_base;
- __u64 err_inj_spa_range_length;
- __u8 err_inj_options;
- __u32 status;
-} __packed;
-
-struct nd_cmd_ars_err_inj_clr {
- __u64 err_inj_clr_spa_range_base;
- __u64 err_inj_clr_spa_range_length;
- __u32 status;
-} __packed;
-
-struct nd_cmd_ars_err_inj_stat {
- __u32 status;
- __u32 inj_err_rec_count;
- struct nd_error_stat_query_record {
- __u64 err_inj_stat_spa_range_base;
- __u64 err_inj_stat_spa_range_length;
- } __packed record[0];
-} __packed;
-
enum {
ND_CMD_IMPLEMENTED = 0,
diff --git a/tools/testing/nvdimm/test/nfit_test.h b/tools/testing/nvdimm/test/nfit_test.h
index d3d63dd..52c83be9 100644
--- a/tools/testing/nvdimm/test/nfit_test.h
+++ b/tools/testing/nvdimm/test/nfit_test.h
@@ -32,6 +32,53 @@ struct nfit_test_resource {
void *buf;
};
+#define ND_TRANSLATE_SPA_STATUS_INVALID_SPA 2
+
+/* nfit commands */
+enum nfit_cmd_num {
+ NFIT_CMD_TRANSLATE_SPA = 5,
+ NFIT_CMD_ARS_INJECT_SET = 7,
+ NFIT_CMD_ARS_INJECT_CLEAR = 8,
+ NFIT_CMD_ARS_INJECT_GET = 9,
+};
+
+struct nd_cmd_translate_spa {
+ __u64 spa;
+ __u32 status;
+ __u8 flags;
+ __u8 _reserved[3];
+ __u64 translate_length;
+ __u32 num_nvdimms;
+ struct nd_nvdimm_device {
+ __u32 nfit_device_handle;
+ __u32 _reserved;
+ __u64 dpa;
+ } __packed devices[0];
+
+} __packed;
+
+struct nd_cmd_ars_err_inj {
+ __u64 err_inj_spa_range_base;
+ __u64 err_inj_spa_range_length;
+ __u8 err_inj_options;
+ __u32 status;
+} __packed;
+
+struct nd_cmd_ars_err_inj_clr {
+ __u64 err_inj_clr_spa_range_base;
+ __u64 err_inj_clr_spa_range_length;
+ __u32 status;
+} __packed;
+
+struct nd_cmd_ars_err_inj_stat {
+ __u32 status;
+ __u32 inj_err_rec_count;
+ struct nd_error_stat_query_record {
+ __u64 err_inj_stat_spa_range_base;
+ __u64 err_inj_stat_spa_range_length;
+ } __packed record[0];
+} __packed;
+
union acpi_object;
typedef void *acpi_handle;
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v4 2/3] acpi nfit: Enable to show what feature is supported via ND_CMD_CALL for nfit_test
2017-09-22 7:44 [PATCH v4 0/3] acpi nfit: make emulation of translate SPA on nfit_test Yasunori Goto
2017-09-22 7:46 ` [PATCH v4 1/3] nfit_test Make private definitions to command emulation Yasunori Goto
@ 2017-09-22 7:47 ` Yasunori Goto
2017-09-22 7:48 ` [PATCH v4 3/3] acpi nfit: nfit_test supports translate SPA Yasunori Goto
2017-10-06 4:57 ` [PATCH v4 0/3] acpi nfit: make emulation of translate SPA on nfit_test Dan Williams
3 siblings, 0 replies; 6+ messages in thread
From: Yasunori Goto @ 2017-09-22 7:47 UTC (permalink / raw)
To: NVDIMM-ML
Though nfit_test need to show what feature is supported via ND_CMD_CALL on
device/nfit/dsm_mask, currently there is no way to tell it.
This patch makes to enable it.
Signed-off-by: Yasunori Goto <y-goto@jp.fujitsu.com>
---
drivers/acpi/nfit/core.c | 1 +
drivers/acpi/nfit/nfit.h | 1 +
2 files changed, 2 insertions(+)
diff --git a/drivers/acpi/nfit/core.c b/drivers/acpi/nfit/core.c
index 42221e7..f952508 100644
--- a/drivers/acpi/nfit/core.c
+++ b/drivers/acpi/nfit/core.c
@@ -1645,6 +1645,7 @@ static void acpi_nfit_init_dsms(struct acpi_nfit_desc *acpi_desc)
int i;
nd_desc->cmd_mask = acpi_desc->bus_cmd_force_en;
+ nd_desc->bus_dsm_mask = acpi_desc->bus_nfit_cmd_force_en;
adev = to_acpi_dev(acpi_desc);
if (!adev)
return;
diff --git a/drivers/acpi/nfit/nfit.h b/drivers/acpi/nfit/nfit.h
index 54292db..f2c6380 100644
--- a/drivers/acpi/nfit/nfit.h
+++ b/drivers/acpi/nfit/nfit.h
@@ -167,6 +167,7 @@ struct acpi_nfit_desc {
unsigned int init_complete:1;
unsigned long dimm_cmd_force_en;
unsigned long bus_cmd_force_en;
+ unsigned long bus_nfit_cmd_force_en;
int (*blk_do_io)(struct nd_blk_region *ndbr, resource_size_t dpa,
void *iobuf, u64 len, int rw);
};
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v4 3/3] acpi nfit: nfit_test supports translate SPA
2017-09-22 7:44 [PATCH v4 0/3] acpi nfit: make emulation of translate SPA on nfit_test Yasunori Goto
2017-09-22 7:46 ` [PATCH v4 1/3] nfit_test Make private definitions to command emulation Yasunori Goto
2017-09-22 7:47 ` [PATCH v4 2/3] acpi nfit: Enable to show what feature is supported via ND_CMD_CALL for nfit_test Yasunori Goto
@ 2017-09-22 7:48 ` Yasunori Goto
2017-10-06 4:57 ` [PATCH v4 0/3] acpi nfit: make emulation of translate SPA on nfit_test Dan Williams
3 siblings, 0 replies; 6+ messages in thread
From: Yasunori Goto @ 2017-09-22 7:48 UTC (permalink / raw)
To: NVDIMM-ML
To test ndctl list which use interface of Translate SPA,
nfit_test needs to emulates it.
This test module searches region which includes SPA and
returns 1 dimm handle which is last one.
Signed-off-by: Yasunori Goto <y-goto@jp.fujitsu.com>
---
tools/testing/nvdimm/test/nfit.c | 104 ++++++++++++++++++++++++++++++++++++++-
1 file changed, 103 insertions(+), 1 deletion(-)
diff --git a/tools/testing/nvdimm/test/nfit.c b/tools/testing/nvdimm/test/nfit.c
index d20791c..29c0dfe 100644
--- a/tools/testing/nvdimm/test/nfit.c
+++ b/tools/testing/nvdimm/test/nfit.c
@@ -342,6 +342,84 @@ static int nfit_test_cmd_clear_error(struct nd_cmd_clear_error *clear_err,
return 0;
}
+struct region_search_spa {
+ u64 addr;
+ struct nd_region *region;
+};
+
+static int is_region_device(struct device *dev)
+{
+ return !strncmp(dev->kobj.name, "region", 6);
+}
+
+static int nfit_test_search_region_spa(struct device *dev, void *data)
+{
+ struct region_search_spa *ctx = data;
+ struct nd_region *nd_region;
+ resource_size_t ndr_end;
+
+ if (!is_region_device(dev))
+ return 0;
+
+ nd_region = to_nd_region(dev);
+ ndr_end = nd_region->ndr_start + nd_region->ndr_size;
+
+ if (ctx->addr >= nd_region->ndr_start && ctx->addr < ndr_end) {
+ ctx->region = nd_region;
+ return 1;
+ }
+
+ return 0;
+}
+
+static int nfit_test_search_spa(struct nvdimm_bus *bus,
+ struct nd_cmd_translate_spa *spa)
+{
+ int ret;
+ struct nd_region *nd_region = NULL;
+ struct nvdimm *nvdimm = NULL;
+ struct nd_mapping *nd_mapping = NULL;
+ struct region_search_spa ctx = {
+ .addr = spa->spa,
+ .region = NULL,
+ };
+ u64 dpa;
+
+ ret = device_for_each_child(&bus->dev, &ctx,
+ nfit_test_search_region_spa);
+
+ if (!ret)
+ return -ENODEV;
+
+ nd_region = ctx.region;
+
+ dpa = ctx.addr - nd_region->ndr_start;
+
+ /*
+ * last dimm is selected for test
+ */
+ nd_mapping = &nd_region->mapping[nd_region->ndr_mappings - 1];
+ nvdimm = nd_mapping->nvdimm;
+
+ spa->devices[0].nfit_device_handle = handle[nvdimm->id];
+ spa->num_nvdimms = 1;
+ spa->devices[0].dpa = dpa;
+
+ return 0;
+}
+
+static int nfit_test_cmd_translate_spa(struct nvdimm_bus *bus,
+ struct nd_cmd_translate_spa *spa, unsigned int buf_len)
+{
+ if (buf_len < spa->translate_length)
+ return -EINVAL;
+
+ if (nfit_test_search_spa(bus, spa) < 0 || !spa->num_nvdimms)
+ spa->status = 2;
+
+ return 0;
+}
+
static int nfit_test_cmd_smart(struct nd_cmd_smart *smart, unsigned int buf_len)
{
static const struct nd_smart_payload smart_data = {
@@ -449,6 +527,26 @@ static int nfit_test_ctl(struct nvdimm_bus_descriptor *nd_desc,
}
} else {
struct ars_state *ars_state = &t->ars_state;
+ struct nd_cmd_pkg *call_pkg = buf;
+
+ if (!nd_desc)
+ return -ENOTTY;
+
+ if (cmd == ND_CMD_CALL) {
+ func = call_pkg->nd_command;
+
+ buf_len = call_pkg->nd_size_in + call_pkg->nd_size_out;
+ buf = (void *) call_pkg->nd_payload;
+
+ switch (func) {
+ case NFIT_CMD_TRANSLATE_SPA:
+ rc = nfit_test_cmd_translate_spa(
+ acpi_desc->nvdimm_bus, buf, buf_len);
+ return rc;
+ default:
+ return -ENOTTY;
+ }
+ }
if (!nd_desc || !test_bit(cmd, &nd_desc->cmd_mask))
return -ENOTTY;
@@ -1430,7 +1528,9 @@ static void nfit_test0_setup(struct nfit_test *t)
set_bit(ND_CMD_ARS_START, &acpi_desc->bus_cmd_force_en);
set_bit(ND_CMD_ARS_STATUS, &acpi_desc->bus_cmd_force_en);
set_bit(ND_CMD_CLEAR_ERROR, &acpi_desc->bus_cmd_force_en);
+ set_bit(ND_CMD_CALL, &acpi_desc->bus_cmd_force_en);
set_bit(ND_CMD_SMART_THRESHOLD, &acpi_desc->dimm_cmd_force_en);
+ set_bit(NFIT_CMD_TRANSLATE_SPA, &acpi_desc->bus_nfit_cmd_force_en);
}
static void nfit_test1_setup(struct nfit_test *t)
@@ -1616,10 +1716,12 @@ static int nfit_ctl_test(struct device *dev)
.cmd_mask = 1UL << ND_CMD_ARS_CAP
| 1UL << ND_CMD_ARS_START
| 1UL << ND_CMD_ARS_STATUS
- | 1UL << ND_CMD_CLEAR_ERROR,
+ | 1UL << ND_CMD_CLEAR_ERROR
+ | 1UL << ND_CMD_CALL,
.module = THIS_MODULE,
.provider_name = "ACPI.NFIT",
.ndctl = acpi_nfit_ctl,
+ .bus_dsm_mask = 1UL << NFIT_CMD_TRANSLATE_SPA,
},
.dev = &adev->dev,
};
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v4 0/3] acpi nfit: make emulation of translate SPA on nfit_test
2017-09-22 7:44 [PATCH v4 0/3] acpi nfit: make emulation of translate SPA on nfit_test Yasunori Goto
` (2 preceding siblings ...)
2017-09-22 7:48 ` [PATCH v4 3/3] acpi nfit: nfit_test supports translate SPA Yasunori Goto
@ 2017-10-06 4:57 ` Dan Williams
2017-10-06 18:03 ` Verma, Vishal L
3 siblings, 1 reply; 6+ messages in thread
From: Dan Williams @ 2017-10-06 4:57 UTC (permalink / raw)
To: Yasunori Goto; +Cc: NVDIMM-ML
On Fri, Sep 22, 2017 at 12:44 AM, Yasunori Goto <y-goto@jp.fujitsu.com> wrote:
>
> Hello
>
> I made a v4 patch set to emulate translate SPA by nfit_test.ko module.
> If possible, please merge it.
>
> ----
> This patch set is to emulate translate SPA feature by nfit_test.ko.
>
> Certainly the nfit acpi driver supports translate SPA interface
> via ND_CMD_CALL. But nfit_test does not support it yet.
>
> To test translate SPA with nfit_test, this patch set is needed.
>
> ---
> Change log since v3 [1]:
> - Rebase current libnvdimm-for-next branch.
> - Fix over 80 character lines and too much tabs which is pointed
> by Verma-san. (Thanks!)
> - Since ndctl became to use the name "nfit_cmd" instead of "passthru",
> "passthru" is renamed to "nfit_cmd".
>
> Change log since v2 [2]:
> - Make private defintion just for nfit_test.
> (NFIT_CMD_TRANSLATE_SPA, struct nd_cmd_translate_spa, and others)
> - Check region by kobj.name instead of using is_nd_pmem().
>
>
> Change log since v1 [3]:
> - Separate patch set of kenel from ndctl patch set.
> - Change interface via ND_CMD_CALL.
>
> [1] https://www.mail-archive.com/linux-nvdimm@lists.01.org/msg05863.html
> [2] https://www.mail-archive.com/linux-nvdimm@lists.01.org/msg05582.html
> [3] https://www.mail-archive.com/linux-nvdimm@lists.01.org/msg05287.html
>
Vishal, since you built on top of these can I add your Tested-by or Reviewed-by?
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v4 0/3] acpi nfit: make emulation of translate SPA on nfit_test
2017-10-06 4:57 ` [PATCH v4 0/3] acpi nfit: make emulation of translate SPA on nfit_test Dan Williams
@ 2017-10-06 18:03 ` Verma, Vishal L
0 siblings, 0 replies; 6+ messages in thread
From: Verma, Vishal L @ 2017-10-06 18:03 UTC (permalink / raw)
To: Williams, Dan J, y-goto; +Cc: linux-nvdimm
On Thu, 2017-10-05 at 21:57 -0700, Dan Williams wrote:
> On Fri, Sep 22, 2017 at 12:44 AM, Yasunori Goto <y-goto@jp.fujitsu.co
> m> wrote:
> >
> > Hello
> >
> > I made a v4 patch set to emulate translate SPA by nfit_test.ko
> > module.
> > If possible, please merge it.
> >
> > ----
> > This patch set is to emulate translate SPA feature by nfit_test.ko.
> >
> > Certainly the nfit acpi driver supports translate SPA interface
> > via ND_CMD_CALL. But nfit_test does not support it yet.
> >
> > To test translate SPA with nfit_test, this patch set is needed.
> >
> > ---
> > Change log since v3 [1]:
> > - Rebase current libnvdimm-for-next branch.
> > - Fix over 80 character lines and too much tabs which is pointed
> > by Verma-san. (Thanks!)
> > - Since ndctl became to use the name "nfit_cmd" instead of
> > "passthru",
> > "passthru" is renamed to "nfit_cmd".
> >
> > Change log since v2 [2]:
> > - Make private defintion just for nfit_test.
> > (NFIT_CMD_TRANSLATE_SPA, struct nd_cmd_translate_spa, and
> > others)
> > - Check region by kobj.name instead of using is_nd_pmem().
> >
> >
> > Change log since v1 [3]:
> > - Separate patch set of kenel from ndctl patch set.
> > - Change interface via ND_CMD_CALL.
> >
> > [1] https://www.mail-archive.com/linux-nvdimm@lists.01.org/msg05863
> > .html
> > [2] https://www.mail-archive.com/linux-nvdimm@lists.01.org/msg05582
> > .html
> > [3] https://www.mail-archive.com/linux-nvdimm@lists.01.org/msg05287
> > .html
> >
>
> Vishal, since you built on top of these can I add your Tested-by or
> Reviewed-by?
Yes, I meant to send a reveiwed-by, but might've forgotten.
Thanks,
-Vishal
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2017-10-06 18:00 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-22 7:44 [PATCH v4 0/3] acpi nfit: make emulation of translate SPA on nfit_test Yasunori Goto
2017-09-22 7:46 ` [PATCH v4 1/3] nfit_test Make private definitions to command emulation Yasunori Goto
2017-09-22 7:47 ` [PATCH v4 2/3] acpi nfit: Enable to show what feature is supported via ND_CMD_CALL for nfit_test Yasunori Goto
2017-09-22 7:48 ` [PATCH v4 3/3] acpi nfit: nfit_test supports translate SPA Yasunori Goto
2017-10-06 4:57 ` [PATCH v4 0/3] acpi nfit: make emulation of translate SPA on nfit_test Dan Williams
2017-10-06 18:03 ` Verma, Vishal L
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).