Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

libnvdimm/region: Introduce NDD_LABELING

The NDD_ALIASING flag is used to indicate where pmem capacity might
alias with blk capacity and require labeling. It is also used to
indicate whether the DIMM supports labeling. Separate this latter
capability into its own flag so that the NDD_ALIASING flag is scoped to
true aliased configurations.

To my knowledge aliased configurations only exist in the ACPI spec,
there are no known platforms that ship this support in production.

This clarity allows namespace-capacity alignment constraints around
interleave-ways to be relaxed.

Cc: Vishal Verma <vishal.l.verma@intel.com>
Cc: Oliver O'Halloran <oohall@gmail.com>
Reviewed-by: Jeff Moyer <jmoyer@redhat.com>
Reviewed-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
Link: https://lore.kernel.org/r/158041477856.3889308.4212605617834097674.stgit@dwillia2-desk3.amr.corp.intel.com
Signed-off-by: Dan Williams <dan.j.williams@intel.com>

+19 -14
+1 -1
arch/powerpc/platforms/pseries/papr_scm.c
··· 328 328 } 329 329 330 330 dimm_flags = 0; 331 - set_bit(NDD_ALIASING, &dimm_flags); 331 + set_bit(NDD_LABELING, &dimm_flags); 332 332 333 333 p->nvdimm = nvdimm_create(p->bus, p, NULL, dimm_flags, 334 334 PAPR_SCM_DIMM_CMD_MASK, 0, NULL);
+3 -1
drivers/acpi/nfit/core.c
··· 2026 2026 continue; 2027 2027 } 2028 2028 2029 - if (nfit_mem->bdw && nfit_mem->memdev_pmem) 2029 + if (nfit_mem->bdw && nfit_mem->memdev_pmem) { 2030 2030 set_bit(NDD_ALIASING, &flags); 2031 + set_bit(NDD_LABELING, &flags); 2032 + } 2031 2033 2032 2034 /* collate flags across all memdevs for this dimm */ 2033 2035 list_for_each_entry(nfit_memdev, &acpi_desc->memdevs, list) {
+1 -1
drivers/nvdimm/dimm.c
··· 99 99 if (ndd->ns_current >= 0) { 100 100 rc = nd_label_reserve_dpa(ndd); 101 101 if (rc == 0) 102 - nvdimm_set_aliasing(dev); 102 + nvdimm_set_labeling(dev); 103 103 } 104 104 nvdimm_bus_unlock(dev); 105 105
+5 -4
drivers/nvdimm/dimm_devs.c
··· 32 32 33 33 if (!nvdimm->cmd_mask || 34 34 !test_bit(ND_CMD_GET_CONFIG_DATA, &nvdimm->cmd_mask)) { 35 - if (test_bit(NDD_ALIASING, &nvdimm->flags)) 35 + if (test_bit(NDD_LABELING, &nvdimm->flags)) 36 36 return -ENXIO; 37 37 else 38 38 return -ENOTTY; ··· 173 173 return rc; 174 174 } 175 175 176 - void nvdimm_set_aliasing(struct device *dev) 176 + void nvdimm_set_labeling(struct device *dev) 177 177 { 178 178 struct nvdimm *nvdimm = to_nvdimm(dev); 179 179 180 - set_bit(NDD_ALIASING, &nvdimm->flags); 180 + set_bit(NDD_LABELING, &nvdimm->flags); 181 181 } 182 182 183 183 void nvdimm_set_locked(struct device *dev) ··· 312 312 { 313 313 struct nvdimm *nvdimm = to_nvdimm(dev); 314 314 315 - return sprintf(buf, "%s%s\n", 315 + return sprintf(buf, "%s%s%s\n", 316 316 test_bit(NDD_ALIASING, &nvdimm->flags) ? "alias " : "", 317 + test_bit(NDD_LABELING, &nvdimm->flags) ? "label " : "", 317 318 test_bit(NDD_LOCKED, &nvdimm->flags) ? "lock " : ""); 318 319 } 319 320 static DEVICE_ATTR_RO(flags);
+1 -1
drivers/nvdimm/namespace_devs.c
··· 2538 2538 if (!ndd) { 2539 2539 if (test_bit(NDD_LOCKED, &nvdimm->flags)) 2540 2540 /* fail, label data may be unreadable */; 2541 - else if (test_bit(NDD_ALIASING, &nvdimm->flags)) 2541 + else if (test_bit(NDD_LABELING, &nvdimm->flags)) 2542 2542 /* fail, labels needed to disambiguate dpa */; 2543 2543 else 2544 2544 return 0;
+1 -1
drivers/nvdimm/nd.h
··· 252 252 void *buf, size_t len); 253 253 long nvdimm_clear_poison(struct device *dev, phys_addr_t phys, 254 254 unsigned int len); 255 - void nvdimm_set_aliasing(struct device *dev); 255 + void nvdimm_set_labeling(struct device *dev); 256 256 void nvdimm_set_locked(struct device *dev); 257 257 void nvdimm_clear_locked(struct device *dev); 258 258 int nvdimm_security_setup_events(struct device *dev);
+5 -5
drivers/nvdimm/region_devs.c
··· 195 195 int nd_region_to_nstype(struct nd_region *nd_region) 196 196 { 197 197 if (is_memory(&nd_region->dev)) { 198 - u16 i, alias; 198 + u16 i, label; 199 199 200 - for (i = 0, alias = 0; i < nd_region->ndr_mappings; i++) { 200 + for (i = 0, label = 0; i < nd_region->ndr_mappings; i++) { 201 201 struct nd_mapping *nd_mapping = &nd_region->mapping[i]; 202 202 struct nvdimm *nvdimm = nd_mapping->nvdimm; 203 203 204 - if (test_bit(NDD_ALIASING, &nvdimm->flags)) 205 - alias++; 204 + if (test_bit(NDD_LABELING, &nvdimm->flags)) 205 + label++; 206 206 } 207 - if (alias) 207 + if (label) 208 208 return ND_DEVICE_NAMESPACE_PMEM; 209 209 else 210 210 return ND_DEVICE_NAMESPACE_IO;
+2
include/linux/libnvdimm.h
··· 37 37 NDD_WORK_PENDING = 4, 38 38 /* ignore / filter NSLABEL_FLAG_LOCAL for this DIMM, i.e. no aliasing */ 39 39 NDD_NOBLK = 5, 40 + /* dimm supports namespace labels */ 41 + NDD_LABELING = 6, 40 42 41 43 /* need to set a limit somewhere, but yes, this is likely overkill */ 42 44 ND_IOCTL_MAX_BUFLEN = SZ_4M,