acpi nfit: make emulation of translate SPA on nfit_test
Subsystems (2)
cover acpi nfit: make emulation of translate SPA on nfit_test
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 v1 [1]:
- Separate patch set of kenel from ndctl patch set.
- Change interface via ND_CMD_CALL.
[1] 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 1/3 acpi nfit: move definitions which nfit_test will use
To use nfit_test.ko can use the definition of NFIT_CMD_TRANSLATE_SPA, the defintion is moved from nfit/core.c to ndctl.h.
Probably, other NFIT_CMD_XXX defintions will be used by nfit_test.ko in future. move them to ndctl.h at this time.
--- drivers/acpi/nfit/core.c | 11 ----------- include/uapi/linux/ndctl.h | 11 +++++++++++ 2 files changed, 11 insertions(+), 11 deletions(-)
drivers/acpi/nfit/core.c +0 -11
@@ -1621,17 +1621,6 @@ static int acpi_nfit_register_dimms(struct acpi_nfit_desc *acpi_desc) acpi_desc); } -/* -* These constants are private because there are no kernel consumers of -* 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 , -}; -static void acpi_nfit_init_dsms (struct acpi_nfit_desc *acpi_desc) {struct nvdimm_bus_descriptor *nd_desc = &acpi_desc->nd_desc;
include/uapi/linux/ndctl.h +11 -0
@@ -204,6 +204,17 @@ enum { ND_CMD_CALL = 10, }; +/* +* Though These constants are mainly used by acpi nfit driver, +* they are defined here for nfit_test.ko to be able to use them. +*/ +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 , +}; +enum {ND_ARS_VOLATILE =1 ,ND_ARS_PERSISTENT =2 ,
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
Re: [PATCH 1/3] acpi nfit: move definitions which nfit_test will use
Quoted 41 lines · Yasunori Goto
To use nfit_test.ko can use the definition of
NFIT_CMD_TRANSLATE_SPA, the defintion is moved fromnfit/core.ctondctl.h.Probably, other
NFIT_CMD_XXXdefintions will be used by nfit_test.ko in future. move them tondctl.hat this time.--- drivers/acpi/nfit/core.c | 11 ----------- include/uapi/linux/ndctl.h | 11 +++++++++++ 2 files changed, 11 insertions(+), 11 deletions(-)drivers/acpi/nfit/core.c +0
-11@@ -1621,17 +1621,6 @@ static int acpi_nfit_register_dimms(struct acpi_nfit_desc *acpi_desc) acpi_desc); } -/* -* These constants are private because there are no kernel consumers of -* 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 , -}; -static void acpi_nfit_init_dsms (struct acpi_nfit_desc *acpi_desc) {struct nvdimm_bus_descriptor *nd_desc = &acpi_desc->nd_desc;include/uapi/linux/ndctl.h +0
-0@@ -204,6 +204,17 @@ enum { ND_CMD_CALL = 10, };
include/uapi/linux/ndctl.h enum { · line 215
Quoted 10 lines
include/uapi/linux/ndctl.h +9
-0+/* +* Though These constants are mainly used by acpi nfit driver, +* they are defined here for nfit_test.ko to be able to use them. +*/ +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 ,
Like I mentioned in the ndctl patches let's instead move these to a libndctl-nfit.h header. There's no need for the kernel to export these command numbers since it only passes them through to the acpi device.
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
PATCH 2/3 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
@@ -1630,6 +1630,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_sub_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_sub_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 3/3 acpi nfit: nfit_test supports translate SPA
In reply to Yasunori Gotonfit_test supports translate SPA
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.
--- drivers/nvdimm/region_devs.c | 1 + tools/testing/nvdimm/test/nfit.c | 98 +++++++++++++++++++++++++++++++++++++++- 2 files changed, 98 insertions(+), 1 deletion(-)
drivers/nvdimm/region_devs.c +1 -0
@@ -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 +97 -1
126 lines not on this page · raw message
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
Re: [PATCH 3/3] acpi nfit: nfit_test supports translate SPA
Quoted 21 lines · Yasunori Goto
nfit_testsupports translate SPATo test ndctl list which use interface of Translate SPA,
nfit_testneeds 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 <[email protected]>--- drivers/nvdimm/region_devs.c | 1 + tools/testing/nvdimm/test/nfit.c | 98 +++++++++++++++++++++++++++++++++++++++- 2 files changed, 98 insertions(+), 1 deletion(-)drivers/nvdimm/region_devs.c +0
-0
drivers/nvdimm/region_devs.c bool is_nd_pmem(struct device *dev) · line 165
Quoted 4 lines
drivers/nvdimm/region_devs.c +1
-0@@ -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);
Only a quick comment here because I need to run, but I'd like to find a way to support this without exporting this internal detail. We should be able to do this by just looking through the data that nfit_test registered with the acpi driver at init time. I'll try to think of a more concrete recommendation, but I do want the end solution to keep is_nd_pmem private to the libnvdimm core if at all possible.
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
Re: [PATCH 3/3] acpi nfit: nfit_test supports translate SPA
Quoted 27 lines · Yasunori Goto
Quoted 21 lines
nfit_testsupports translate SPATo test ndctl list which use interface of Translate SPA,
nfit_testneeds 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 <[email protected]>--- drivers/nvdimm/region_devs.c | 1 + tools/testing/nvdimm/test/nfit.c | 98 +++++++++++++++++++++++++++++++++++++++- 2 files changed, 98 insertions(+), 1 deletion(-)drivers/nvdimm/region_devs.c +0
-0drivers/nvdimm/region_devs.c bool is_nd_pmem(struct device *dev) · line 165
Quoted 4 lines
drivers/nvdimm/region_devs.c +1
-0@@ -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);
Quoted 8 lines
Only a quick comment here because I need to run, but I'd like to find a way to support this without exporting this internal detail. We should be able to do this by just looking through the data that
nfit_testregistered with the acpi driver at init time. I'll try to think of a more concrete recommendation, but I do want the end solution to keepis_nd_pmemprivate to the libnvdimm core if at all possible.
Ok, I'll reconsider it.
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
Re: [PATCH 3/3] acpi nfit: nfit_test supports translate SPA
In reply to Yasunori GotoQuoted 8 lines · Yasunori Goto
nfit_testsupports translate SPATo test ndctl list which use interface of Translate SPA,
nfit_testneeds to emulates it.
This test module searches region which includes SPA and returns 1 dimm handle which is last one.
Quoted 7 lines
Signed-off-by Yasunori Goto <[email protected]>---
drivers/nvdimm/region_devs.c | 1 +
tools/testing/nvdimm/test/nfit.c | 98
+++++++++++++++++++++++++++++++++++++++-2 files changed, 98 insertions(+), 1 deletion(-)
A few >80 character lines in this, but other than that, looks good to me. You can run patches through scripts/checkpatch.pl in the kernel tree to catch problems like this.
Quoted 52 lines
drivers/nvdimm/region_devs.c +1
-0@@ -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);
boolis_nd_blk(struct device *dev)
{tools/testing/nvdimm/test/nfit.c +0
-0@@ -342,6 +342,78 @@ static int nfit_test_cmd_clear_error(struct nd_cmd_clear_error *clear_err, return 0; }tools/testing/nvdimm/test/nfit.c +6
-0+struct region_search_spa { +u64 addr; +struct nd_region *region; +}; + +static int nfit_test_search_region_spa(struct device *dev, void*data)
tools/testing/nvdimm/test/nfit.c +12
-0+{ +struct region_search_spa *ctx = data; +struct nd_region *nd_region; +resource_size_t ndr_end; + +if (!is_nd_pmem (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){
tools/testing/nvdimm/test/nfit.c +8
-0+ ctx->region = nd_region; +return 1 ; + } + +return 0 ; +} + +static int nfit_test_search_spa(struct nvdimm_bus *bus, struct
Quoted 1 line
nd_cmd_trans_spa*spa)
Over 80 char, you can split the line after 'bus' here.
Quoted 43 lines
tools/testing/nvdimm/test/nfit.c +12
-0+{ +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);80 ch
tools/testing/nvdimm/test/nfit.c +12
-0+ +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];
tools/testing/nvdimm/test/nfit.c +10
-0+ 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_trans_spa*spa,80 ch
tools/testing/nvdimm/test/nfit.c static int nfit_test_cmd_clear_error(struct nd_cmd_clear_error *clear_err, · line 405
Quoted 1 line
tools/testing/nvdimm/test/nfit.c +1
-0+ unsigned int buf_len)
By convention, the second line starts after just two tab stops in this file.
Quoted 40 lines
tools/testing/nvdimm/test/nfit.c +11
-0+{ + +if (buf_len < spa->trans_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 structnd_smart_payloadsmart_data= {tools/testing/nvdimm/test/nfit.c +14
-0@@ -449,6 +521,26 @@ static int nfit_test_ctl(structnvdimm_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,80 ch
tools/testing/nvdimm/test/nfit.c +1
-0+ buf,
Quoted 1 line
buf_len);
and a couple extra tab stops here.
Quoted 39 lines
tools/testing/nvdimm/test/nfit.c +5
-0+return rc; +default : +return -ENOTTY ; + } + }
if (!nd_desc || !test_bit(cmd,&nd_desc->cmd_mask)) return-ENOTTY;tools/testing/nvdimm/test/nfit.c +1
-0@@ -1430,7 +1522,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-
Quoted 1 line
dimm_cmd_force_en);tools/testing/nvdimm/test/nfit.c +1
-0+ set_bit(NFIT_CMD_TRANSLATE_SPA, &acpi_desc-Quoted 1 line
bus_sub_cmd_force_en);}
static voidnfit_test1_setup(struct nfit_test *t)tools/testing/nvdimm/test/nfit.c +0
-0@@ -1616,10 +1710,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_STATUStools/testing/nvdimm/test/nfit.c +2
-1- | 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,tools/testing/nvdimm/test/nfit.c +1
-0+ .bus_dsm_mask = 1UL <<
NFIT_CMD_TRANSLATE_SPA,
},
.dev =&adev->dev,
};
Quoted 4 lines
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
Quoted 11 lines · Yasunori Goto
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 v1 [1]:
- Separate patch set of kenel from ndctl patch set.
- Change interface viaND_CMD_CALL.
Other than the few checkpatch type issues, the series looks good to me.
Quoted 13 lines
[1] https://www.mail-archive.com/[email protected]/msg05287.ht
ml----
Thanks,
---
Yasunori Goto
Quoted 4 lines
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm