diff options
author | Dan Williams <dan.j.williams@intel.com> | 2018-04-09 19:38:01 -0400 |
---|---|---|
committer | Dan Williams <dan.j.williams@intel.com> | 2018-04-16 11:18:51 -0400 |
commit | 718fda67d2f69cc6074b4b6a740a6e4aacd44eff (patch) | |
tree | ec82661354af990009bcf688c528624d527e7eef | |
parent | 55c72ab62e47fc584131901baddb2752e949ebcd (diff) |
tools/testing/nvdimm: support nfit_test_dimm attributes under nfit_test.1
The nfit_test.1 bus provides a pmem topology without blk-aperture
enabling, so it presents different failure modes for label space
handling. Allow custom DSM command error injection.
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
-rw-r--r-- | tools/testing/nvdimm/test/nfit.c | 43 |
1 files changed, 25 insertions, 18 deletions
diff --git a/tools/testing/nvdimm/test/nfit.c b/tools/testing/nvdimm/test/nfit.c index dc6cf5630280..c8c88363311b 100644 --- a/tools/testing/nvdimm/test/nfit.c +++ b/tools/testing/nvdimm/test/nfit.c | |||
@@ -1166,12 +1166,12 @@ static int ars_state_init(struct device *dev, struct ars_state *ars_state) | |||
1166 | 1166 | ||
1167 | static void put_dimms(void *data) | 1167 | static void put_dimms(void *data) |
1168 | { | 1168 | { |
1169 | struct device **dimm_dev = data; | 1169 | struct nfit_test *t = data; |
1170 | int i; | 1170 | int i; |
1171 | 1171 | ||
1172 | for (i = 0; i < NUM_DCR; i++) | 1172 | for (i = 0; i < t->num_dcr; i++) |
1173 | if (dimm_dev[i]) | 1173 | if (t->dimm_dev[i]) |
1174 | device_unregister(dimm_dev[i]); | 1174 | device_unregister(t->dimm_dev[i]); |
1175 | } | 1175 | } |
1176 | 1176 | ||
1177 | static struct class *nfit_test_dimm; | 1177 | static struct class *nfit_test_dimm; |
@@ -1180,13 +1180,11 @@ static int dimm_name_to_id(struct device *dev) | |||
1180 | { | 1180 | { |
1181 | int dimm; | 1181 | int dimm; |
1182 | 1182 | ||
1183 | if (sscanf(dev_name(dev), "test_dimm%d", &dimm) != 1 | 1183 | if (sscanf(dev_name(dev), "test_dimm%d", &dimm) != 1) |
1184 | || dimm >= NUM_DCR || dimm < 0) | ||
1185 | return -ENXIO; | 1184 | return -ENXIO; |
1186 | return dimm; | 1185 | return dimm; |
1187 | } | 1186 | } |
1188 | 1187 | ||
1189 | |||
1190 | static ssize_t handle_show(struct device *dev, struct device_attribute *attr, | 1188 | static ssize_t handle_show(struct device *dev, struct device_attribute *attr, |
1191 | char *buf) | 1189 | char *buf) |
1192 | { | 1190 | { |
@@ -1259,7 +1257,6 @@ static ssize_t fail_cmd_code_store(struct device *dev, struct device_attribute * | |||
1259 | } | 1257 | } |
1260 | static DEVICE_ATTR_RW(fail_cmd_code); | 1258 | static DEVICE_ATTR_RW(fail_cmd_code); |
1261 | 1259 | ||
1262 | |||
1263 | static struct attribute *nfit_test_dimm_attributes[] = { | 1260 | static struct attribute *nfit_test_dimm_attributes[] = { |
1264 | &dev_attr_fail_cmd.attr, | 1261 | &dev_attr_fail_cmd.attr, |
1265 | &dev_attr_fail_cmd_code.attr, | 1262 | &dev_attr_fail_cmd_code.attr, |
@@ -1276,6 +1273,23 @@ static const struct attribute_group *nfit_test_dimm_attribute_groups[] = { | |||
1276 | NULL, | 1273 | NULL, |
1277 | }; | 1274 | }; |
1278 | 1275 | ||
1276 | static int nfit_test_dimm_init(struct nfit_test *t) | ||
1277 | { | ||
1278 | int i; | ||
1279 | |||
1280 | if (devm_add_action_or_reset(&t->pdev.dev, put_dimms, t)) | ||
1281 | return -ENOMEM; | ||
1282 | for (i = 0; i < t->num_dcr; i++) { | ||
1283 | t->dimm_dev[i] = device_create_with_groups(nfit_test_dimm, | ||
1284 | &t->pdev.dev, 0, NULL, | ||
1285 | nfit_test_dimm_attribute_groups, | ||
1286 | "test_dimm%d", i + t->dcr_idx); | ||
1287 | if (!t->dimm_dev[i]) | ||
1288 | return -ENOMEM; | ||
1289 | } | ||
1290 | return 0; | ||
1291 | } | ||
1292 | |||
1279 | static void smart_init(struct nfit_test *t) | 1293 | static void smart_init(struct nfit_test *t) |
1280 | { | 1294 | { |
1281 | int i; | 1295 | int i; |
@@ -1371,17 +1385,8 @@ static int nfit_test0_alloc(struct nfit_test *t) | |||
1371 | if (!t->_fit) | 1385 | if (!t->_fit) |
1372 | return -ENOMEM; | 1386 | return -ENOMEM; |
1373 | 1387 | ||
1374 | if (devm_add_action_or_reset(&t->pdev.dev, put_dimms, t->dimm_dev)) | 1388 | if (nfit_test_dimm_init(t)) |
1375 | return -ENOMEM; | 1389 | return -ENOMEM; |
1376 | for (i = 0; i < NUM_DCR; i++) { | ||
1377 | t->dimm_dev[i] = device_create_with_groups(nfit_test_dimm, | ||
1378 | &t->pdev.dev, 0, NULL, | ||
1379 | nfit_test_dimm_attribute_groups, | ||
1380 | "test_dimm%d", i); | ||
1381 | if (!t->dimm_dev[i]) | ||
1382 | return -ENOMEM; | ||
1383 | } | ||
1384 | |||
1385 | smart_init(t); | 1390 | smart_init(t); |
1386 | return ars_state_init(&t->pdev.dev, &t->ars_state); | 1391 | return ars_state_init(&t->pdev.dev, &t->ars_state); |
1387 | } | 1392 | } |
@@ -1413,6 +1418,8 @@ static int nfit_test1_alloc(struct nfit_test *t) | |||
1413 | if (!t->spa_set[1]) | 1418 | if (!t->spa_set[1]) |
1414 | return -ENOMEM; | 1419 | return -ENOMEM; |
1415 | 1420 | ||
1421 | if (nfit_test_dimm_init(t)) | ||
1422 | return -ENOMEM; | ||
1416 | smart_init(t); | 1423 | smart_init(t); |
1417 | return ars_state_init(&t->pdev.dev, &t->ars_state); | 1424 | return ars_state_init(&t->pdev.dev, &t->ars_state); |
1418 | } | 1425 | } |