aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2018-08-25 21:13:10 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2018-08-25 21:13:10 -0400
commit828bf6e904eb8fc8969333568802689fbbf07a40 (patch)
tree669784db5c100f75698f2a4511d31047dd0b3d50 /tools
parentb326272010b6656210193d7ab93fa184087e8ee1 (diff)
parent286e87718103acdf85f4ed323a37e4839a8a7c05 (diff)
Merge tag 'libnvdimm-for-4.19_misc' of gitolite.kernel.org:pub/scm/linux/kernel/git/nvdimm/nvdimm
Pull libnvdimm updates from Dave Jiang: "Collection of misc libnvdimm patches for 4.19 submission: - Adding support to read locked nvdimm capacity. - Change test code to make DSM failure code injection an override. - Add support for calculate maximum contiguous area for namespace. - Add support for queueing a short ARS when there is on going ARS for nvdimm. - Allow NULL to be passed in to ->direct_access() for kaddr and pfn params. - Improve smart injection support for nvdimm emulation testing. - Fix test code that supports for emulating controller temperature. - Fix hang on error before devm_memremap_pages() - Fix a bug that causes user memory corruption when data returned to user for ars_status. - Maintainer updates for Ross Zwisler emails and adding Jan Kara to fsdax" * tag 'libnvdimm-for-4.19_misc' of gitolite.kernel.org:pub/scm/linux/kernel/git/nvdimm/nvdimm: libnvdimm: fix ars_status output length calculation device-dax: avoid hang on error before devm_memremap_pages() tools/testing/nvdimm: improve emulation of smart injection filesystem-dax: Do not request kaddr and pfn when not required md/dm-writecache: Don't request pointer dummy_addr when not required dax/super: Do not request a pointer kaddr when not required tools/testing/nvdimm: kaddr and pfn can be NULL to ->direct_access() s390, dcssblk: kaddr and pfn can be NULL to ->direct_access() libnvdimm, pmem: kaddr and pfn can be NULL to ->direct_access() acpi/nfit: queue issuing of ars when an uc error notification comes in libnvdimm: Export max available extent libnvdimm: Use max contiguous area for namespace size MAINTAINERS: Add Jan Kara for filesystem DAX MAINTAINERS: update Ross Zwisler's email address tools/testing/nvdimm: Fix support for emulating controller temperature tools/testing/nvdimm: Make DSM failure code injection an override acpi, nfit: Prefer _DSM over _LSR for namespace label reads libnvdimm: Introduce locked DIMM capacity support
Diffstat (limited to 'tools')
-rw-r--r--tools/testing/nvdimm/pmem-dax.c12
-rw-r--r--tools/testing/nvdimm/test/nfit.c126
2 files changed, 87 insertions, 51 deletions
diff --git a/tools/testing/nvdimm/pmem-dax.c b/tools/testing/nvdimm/pmem-dax.c
index b53596ad601b..2e7fd8227969 100644
--- a/tools/testing/nvdimm/pmem-dax.c
+++ b/tools/testing/nvdimm/pmem-dax.c
@@ -31,17 +31,21 @@ long __pmem_direct_access(struct pmem_device *pmem, pgoff_t pgoff,
31 if (get_nfit_res(pmem->phys_addr + offset)) { 31 if (get_nfit_res(pmem->phys_addr + offset)) {
32 struct page *page; 32 struct page *page;
33 33
34 *kaddr = pmem->virt_addr + offset; 34 if (kaddr)
35 *kaddr = pmem->virt_addr + offset;
35 page = vmalloc_to_page(pmem->virt_addr + offset); 36 page = vmalloc_to_page(pmem->virt_addr + offset);
36 *pfn = page_to_pfn_t(page); 37 if (pfn)
38 *pfn = page_to_pfn_t(page);
37 pr_debug_ratelimited("%s: pmem: %p pgoff: %#lx pfn: %#lx\n", 39 pr_debug_ratelimited("%s: pmem: %p pgoff: %#lx pfn: %#lx\n",
38 __func__, pmem, pgoff, page_to_pfn(page)); 40 __func__, pmem, pgoff, page_to_pfn(page));
39 41
40 return 1; 42 return 1;
41 } 43 }
42 44
43 *kaddr = pmem->virt_addr + offset; 45 if (kaddr)
44 *pfn = phys_to_pfn_t(pmem->phys_addr + offset, pmem->pfn_flags); 46 *kaddr = pmem->virt_addr + offset;
47 if (pfn)
48 *pfn = phys_to_pfn_t(pmem->phys_addr + offset, pmem->pfn_flags);
45 49
46 /* 50 /*
47 * If badblocks are present, limit known good range to the 51 * If badblocks are present, limit known good range to the
diff --git a/tools/testing/nvdimm/test/nfit.c b/tools/testing/nvdimm/test/nfit.c
index e2926f72a821..cffc2c5a778d 100644
--- a/tools/testing/nvdimm/test/nfit.c
+++ b/tools/testing/nvdimm/test/nfit.c
@@ -142,6 +142,28 @@ static u32 handle[] = {
142static unsigned long dimm_fail_cmd_flags[NUM_DCR]; 142static unsigned long dimm_fail_cmd_flags[NUM_DCR];
143static int dimm_fail_cmd_code[NUM_DCR]; 143static int dimm_fail_cmd_code[NUM_DCR];
144 144
145static const struct nd_intel_smart smart_def = {
146 .flags = ND_INTEL_SMART_HEALTH_VALID
147 | ND_INTEL_SMART_SPARES_VALID
148 | ND_INTEL_SMART_ALARM_VALID
149 | ND_INTEL_SMART_USED_VALID
150 | ND_INTEL_SMART_SHUTDOWN_VALID
151 | ND_INTEL_SMART_MTEMP_VALID
152 | ND_INTEL_SMART_CTEMP_VALID,
153 .health = ND_INTEL_SMART_NON_CRITICAL_HEALTH,
154 .media_temperature = 23 * 16,
155 .ctrl_temperature = 25 * 16,
156 .pmic_temperature = 40 * 16,
157 .spares = 75,
158 .alarm_flags = ND_INTEL_SMART_SPARE_TRIP
159 | ND_INTEL_SMART_TEMP_TRIP,
160 .ait_status = 1,
161 .life_used = 5,
162 .shutdown_state = 0,
163 .vendor_size = 0,
164 .shutdown_count = 100,
165};
166
145struct nfit_test_fw { 167struct nfit_test_fw {
146 enum intel_fw_update_state state; 168 enum intel_fw_update_state state;
147 u32 context; 169 u32 context;
@@ -752,15 +774,30 @@ static int nfit_test_cmd_smart_inject(
752 if (buf_len != sizeof(*inj)) 774 if (buf_len != sizeof(*inj))
753 return -EINVAL; 775 return -EINVAL;
754 776
755 if (inj->mtemp_enable) 777 if (inj->flags & ND_INTEL_SMART_INJECT_MTEMP) {
756 smart->media_temperature = inj->media_temperature; 778 if (inj->mtemp_enable)
757 if (inj->spare_enable) 779 smart->media_temperature = inj->media_temperature;
758 smart->spares = inj->spares; 780 else
759 if (inj->fatal_enable) 781 smart->media_temperature = smart_def.media_temperature;
760 smart->health = ND_INTEL_SMART_FATAL_HEALTH; 782 }
761 if (inj->unsafe_shutdown_enable) { 783 if (inj->flags & ND_INTEL_SMART_INJECT_SPARE) {
762 smart->shutdown_state = 1; 784 if (inj->spare_enable)
763 smart->shutdown_count++; 785 smart->spares = inj->spares;
786 else
787 smart->spares = smart_def.spares;
788 }
789 if (inj->flags & ND_INTEL_SMART_INJECT_FATAL) {
790 if (inj->fatal_enable)
791 smart->health = ND_INTEL_SMART_FATAL_HEALTH;
792 else
793 smart->health = ND_INTEL_SMART_NON_CRITICAL_HEALTH;
794 }
795 if (inj->flags & ND_INTEL_SMART_INJECT_SHUTDOWN) {
796 if (inj->unsafe_shutdown_enable) {
797 smart->shutdown_state = 1;
798 smart->shutdown_count++;
799 } else
800 smart->shutdown_state = 0;
764 } 801 }
765 inj->status = 0; 802 inj->status = 0;
766 smart_notify(bus_dev, dimm_dev, smart, thresh); 803 smart_notify(bus_dev, dimm_dev, smart, thresh);
@@ -884,6 +921,16 @@ static int nd_intel_test_cmd_set_lss_status(struct nfit_test *t,
884 return 0; 921 return 0;
885} 922}
886 923
924static int override_return_code(int dimm, unsigned int func, int rc)
925{
926 if ((1 << func) & dimm_fail_cmd_flags[dimm]) {
927 if (dimm_fail_cmd_code[dimm])
928 return dimm_fail_cmd_code[dimm];
929 return -EIO;
930 }
931 return rc;
932}
933
887static int get_dimm(struct nfit_mem *nfit_mem, unsigned int func) 934static int get_dimm(struct nfit_mem *nfit_mem, unsigned int func)
888{ 935{
889 int i; 936 int i;
@@ -894,13 +941,6 @@ static int get_dimm(struct nfit_mem *nfit_mem, unsigned int func)
894 break; 941 break;
895 if (i >= ARRAY_SIZE(handle)) 942 if (i >= ARRAY_SIZE(handle))
896 return -ENXIO; 943 return -ENXIO;
897
898 if ((1 << func) & dimm_fail_cmd_flags[i]) {
899 if (dimm_fail_cmd_code[i])
900 return dimm_fail_cmd_code[i];
901 return -EIO;
902 }
903
904 return i; 944 return i;
905} 945}
906 946
@@ -939,48 +979,59 @@ static int nfit_test_ctl(struct nvdimm_bus_descriptor *nd_desc,
939 979
940 switch (func) { 980 switch (func) {
941 case ND_INTEL_ENABLE_LSS_STATUS: 981 case ND_INTEL_ENABLE_LSS_STATUS:
942 return nd_intel_test_cmd_set_lss_status(t, 982 rc = nd_intel_test_cmd_set_lss_status(t,
943 buf, buf_len); 983 buf, buf_len);
984 break;
944 case ND_INTEL_FW_GET_INFO: 985 case ND_INTEL_FW_GET_INFO:
945 return nd_intel_test_get_fw_info(t, buf, 986 rc = nd_intel_test_get_fw_info(t, buf,
946 buf_len, i - t->dcr_idx); 987 buf_len, i - t->dcr_idx);
988 break;
947 case ND_INTEL_FW_START_UPDATE: 989 case ND_INTEL_FW_START_UPDATE:
948 return nd_intel_test_start_update(t, buf, 990 rc = nd_intel_test_start_update(t, buf,
949 buf_len, i - t->dcr_idx); 991 buf_len, i - t->dcr_idx);
992 break;
950 case ND_INTEL_FW_SEND_DATA: 993 case ND_INTEL_FW_SEND_DATA:
951 return nd_intel_test_send_data(t, buf, 994 rc = nd_intel_test_send_data(t, buf,
952 buf_len, i - t->dcr_idx); 995 buf_len, i - t->dcr_idx);
996 break;
953 case ND_INTEL_FW_FINISH_UPDATE: 997 case ND_INTEL_FW_FINISH_UPDATE:
954 return nd_intel_test_finish_fw(t, buf, 998 rc = nd_intel_test_finish_fw(t, buf,
955 buf_len, i - t->dcr_idx); 999 buf_len, i - t->dcr_idx);
1000 break;
956 case ND_INTEL_FW_FINISH_QUERY: 1001 case ND_INTEL_FW_FINISH_QUERY:
957 return nd_intel_test_finish_query(t, buf, 1002 rc = nd_intel_test_finish_query(t, buf,
958 buf_len, i - t->dcr_idx); 1003 buf_len, i - t->dcr_idx);
1004 break;
959 case ND_INTEL_SMART: 1005 case ND_INTEL_SMART:
960 return nfit_test_cmd_smart(buf, buf_len, 1006 rc = nfit_test_cmd_smart(buf, buf_len,
961 &t->smart[i - t->dcr_idx]); 1007 &t->smart[i - t->dcr_idx]);
1008 break;
962 case ND_INTEL_SMART_THRESHOLD: 1009 case ND_INTEL_SMART_THRESHOLD:
963 return nfit_test_cmd_smart_threshold(buf, 1010 rc = nfit_test_cmd_smart_threshold(buf,
964 buf_len, 1011 buf_len,
965 &t->smart_threshold[i - 1012 &t->smart_threshold[i -
966 t->dcr_idx]); 1013 t->dcr_idx]);
1014 break;
967 case ND_INTEL_SMART_SET_THRESHOLD: 1015 case ND_INTEL_SMART_SET_THRESHOLD:
968 return nfit_test_cmd_smart_set_threshold(buf, 1016 rc = nfit_test_cmd_smart_set_threshold(buf,
969 buf_len, 1017 buf_len,
970 &t->smart_threshold[i - 1018 &t->smart_threshold[i -
971 t->dcr_idx], 1019 t->dcr_idx],
972 &t->smart[i - t->dcr_idx], 1020 &t->smart[i - t->dcr_idx],
973 &t->pdev.dev, t->dimm_dev[i]); 1021 &t->pdev.dev, t->dimm_dev[i]);
1022 break;
974 case ND_INTEL_SMART_INJECT: 1023 case ND_INTEL_SMART_INJECT:
975 return nfit_test_cmd_smart_inject(buf, 1024 rc = nfit_test_cmd_smart_inject(buf,
976 buf_len, 1025 buf_len,
977 &t->smart_threshold[i - 1026 &t->smart_threshold[i -
978 t->dcr_idx], 1027 t->dcr_idx],
979 &t->smart[i - t->dcr_idx], 1028 &t->smart[i - t->dcr_idx],
980 &t->pdev.dev, t->dimm_dev[i]); 1029 &t->pdev.dev, t->dimm_dev[i]);
1030 break;
981 default: 1031 default:
982 return -ENOTTY; 1032 return -ENOTTY;
983 } 1033 }
1034 return override_return_code(i, func, rc);
984 } 1035 }
985 1036
986 if (!test_bit(cmd, &cmd_mask) 1037 if (!test_bit(cmd, &cmd_mask)
@@ -1006,6 +1057,7 @@ static int nfit_test_ctl(struct nvdimm_bus_descriptor *nd_desc,
1006 default: 1057 default:
1007 return -ENOTTY; 1058 return -ENOTTY;
1008 } 1059 }
1060 return override_return_code(i, func, rc);
1009 } else { 1061 } else {
1010 struct ars_state *ars_state = &t->ars_state; 1062 struct ars_state *ars_state = &t->ars_state;
1011 struct nd_cmd_pkg *call_pkg = buf; 1063 struct nd_cmd_pkg *call_pkg = buf;
@@ -1302,29 +1354,9 @@ static void smart_init(struct nfit_test *t)
1302 .ctrl_temperature = 30 * 16, 1354 .ctrl_temperature = 30 * 16,
1303 .spares = 5, 1355 .spares = 5,
1304 }; 1356 };
1305 const struct nd_intel_smart smart_data = {
1306 .flags = ND_INTEL_SMART_HEALTH_VALID
1307 | ND_INTEL_SMART_SPARES_VALID
1308 | ND_INTEL_SMART_ALARM_VALID
1309 | ND_INTEL_SMART_USED_VALID
1310 | ND_INTEL_SMART_SHUTDOWN_VALID
1311 | ND_INTEL_SMART_MTEMP_VALID,
1312 .health = ND_INTEL_SMART_NON_CRITICAL_HEALTH,
1313 .media_temperature = 23 * 16,
1314 .ctrl_temperature = 25 * 16,
1315 .pmic_temperature = 40 * 16,
1316 .spares = 75,
1317 .alarm_flags = ND_INTEL_SMART_SPARE_TRIP
1318 | ND_INTEL_SMART_TEMP_TRIP,
1319 .ait_status = 1,
1320 .life_used = 5,
1321 .shutdown_state = 0,
1322 .vendor_size = 0,
1323 .shutdown_count = 100,
1324 };
1325 1357
1326 for (i = 0; i < t->num_dcr; i++) { 1358 for (i = 0; i < t->num_dcr; i++) {
1327 memcpy(&t->smart[i], &smart_data, sizeof(smart_data)); 1359 memcpy(&t->smart[i], &smart_def, sizeof(smart_def));
1328 memcpy(&t->smart_threshold[i], &smart_t_data, 1360 memcpy(&t->smart_threshold[i], &smart_t_data,
1329 sizeof(smart_t_data)); 1361 sizeof(smart_t_data));
1330 } 1362 }