acpi nfit: make emulation of translate SPA on nfit_test
Subsystems (2)
v4 cover acpi nfit: make emulation of translate SPA on nfit_test
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/[email protected]/msg05863.html
[2] https://www.mail-archive.com/[email protected]/msg05582.html
[3] https://www.mail-archive.com/[email protected]/msg05287.html
----
Thanks,
---
Yasunori Goto
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
PATCH v4 1/3 nfit_test Make private definitions to command emulation
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.
--- include/uapi/linux/ndctl.h | 37 --------------------------- tools/testing/nvdimm/test/nfit_test.h | 47 +++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 37 deletions(-)
include/uapi/linux/ndctl.h +0 -37
@@ -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 ,
tools/testing/nvdimm/test/nfit_test.h +47 -0
53 lines not on this page · raw message
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
PATCH v4 2/3 acpi nfit: Enable to show what feature is supported via ND_CMD_CALL for nfit_test
In reply to Yasunori GotoThough 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.
--- drivers/acpi/nfit/core.c | 1 + drivers/acpi/nfit/nfit.h | 1 + 2 files changed, 2 insertions(+)
drivers/acpi/nfit/core.c +1 -0
@@ -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 ;
drivers/acpi/nfit/nfit.h +1 -0
@@ -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
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
PATCH v4 3/3 acpi nfit: nfit_test supports translate SPA
In reply to Yasunori GotoTo 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.
--- tools/testing/nvdimm/test/nfit.c | 104 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 103 insertions(+), 1 deletion(-)
tools/testing/nvdimm/test/nfit.c +103 -1
@@ -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
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
Quoted 28 lines · Yasunori Goto
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. Butnfit_testdoes 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 fornfit_test. (NFIT_CMD_TRANSLATE_SPA, structnd_cmd_translate_spa, and others)
- Check region by kobj.name instead of usingis_nd_pmem().
Quoted 8 lines
Change log since v1 [3]:
- Separate patch set of kenel from ndctl patch set.
- Change interface viaND_CMD_CALL.[1] https://www.mail-archive.com/[email protected]/msg05863.html
[2] https://www.mail-archive.com/[email protected]/msg05582.html
[3] https://www.mail-archive.com/[email protected]/msg05287.html
Vishal, since you built on top of these can I add your Tested-by or Reviewed-by?
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
Verma, Vishal L
maintainerQuoted 45 lines · Dan Williams
Quoted 35 lines · Yasunori Goto
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. Butnfit_testdoes 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 fornfit_test. (NFIT_CMD_TRANSLATE_SPA, structnd_cmd_translate_spa, and
others)
- Check region by kobj.name instead of usingis_nd_pmem().Change log since v1 [3]:
- Separate patch set of kenel from ndctl patch set.
- Change interface viaND_CMD_CALL.
Quoted 2 lines
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
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm