Merge tag 'libnvdimm-for-6.1' of git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm

Pull nvdimm updates from Dan Williams:
"Some small cleanups and fixes in and around the nvdimm subsystem. The
most significant change is a regression fix for nvdimm namespace
(volume) creation when the namespace size is smaller than 2MB/

Summary:

- Fix nvdimm namespace creation on platforms that do not publish
associated 'DIMM' metadata for a persistent memory region.

- Miscellaneous fixes and cleanups"

* tag 'libnvdimm-for-6.1' of git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm:
ACPI: HMAT: Release platform device in case of platform_device_add_data() fails
dax: Remove usage of the deprecated ida_simple_xxx API
libnvdimm/region: Allow setting align attribute on regions without mappings
nvdimm/namespace: Fix comment typo
nvdimm: make __nvdimm_security_overwrite_query static
nvdimm/region: Fix kernel-doc
nvdimm/namespace: drop unneeded temporary variable in size_store()
nvdimm/namespace: return uuid_null only once in nd_dev_to_uuid()

+18 -28
+2 -2
drivers/dax/hmem/device.c
··· 48 48 rc = platform_device_add_data(pdev, &info, sizeof(info)); 49 49 if (rc < 0) { 50 50 pr_err("hmem memregion_info allocation failure for %pr\n", &res); 51 - goto out_pdev; 51 + goto out_resource; 52 52 } 53 53 54 54 rc = platform_device_add_resources(pdev, &res, 1); ··· 66 66 return; 67 67 68 68 out_resource: 69 - put_device(&pdev->dev); 69 + platform_device_put(pdev); 70 70 out_pdev: 71 71 memregion_free(id); 72 72 }
+3 -3
drivers/dax/super.c
··· 363 363 { 364 364 struct dax_device *dax_dev = to_dax_dev(inode); 365 365 if (inode->i_rdev) 366 - ida_simple_remove(&dax_minor_ida, iminor(inode)); 366 + ida_free(&dax_minor_ida, iminor(inode)); 367 367 kmem_cache_free(dax_cache, dax_dev); 368 368 } 369 369 ··· 445 445 if (WARN_ON_ONCE(ops && !ops->zero_page_range)) 446 446 return ERR_PTR(-EINVAL); 447 447 448 - minor = ida_simple_get(&dax_minor_ida, 0, MINORMASK+1, GFP_KERNEL); 448 + minor = ida_alloc_max(&dax_minor_ida, MINORMASK, GFP_KERNEL); 449 449 if (minor < 0) 450 450 return ERR_PTR(-ENOMEM); 451 451 ··· 459 459 return dax_dev; 460 460 461 461 err_dev: 462 - ida_simple_remove(&dax_minor_ida, minor); 462 + ida_free(&dax_minor_ida, minor); 463 463 return ERR_PTR(-ENOMEM); 464 464 } 465 465 EXPORT_SYMBOL_GPL(alloc_dax);
+8 -16
drivers/nvdimm/namespace_devs.c
··· 170 170 171 171 const uuid_t *nd_dev_to_uuid(struct device *dev) 172 172 { 173 - if (!dev) 174 - return &uuid_null; 175 - 176 - if (is_namespace_pmem(dev)) { 173 + if (dev && is_namespace_pmem(dev)) { 177 174 struct nd_namespace_pmem *nspm = to_nd_namespace_pmem(dev); 178 175 179 176 return nspm->uuid; 180 - } else 181 - return &uuid_null; 177 + } 178 + return &uuid_null; 182 179 } 183 180 EXPORT_SYMBOL(nd_dev_to_uuid); 184 181 ··· 385 388 * 386 389 * BLK-space is valid as long as it does not precede a PMEM 387 390 * allocation in a given region. PMEM-space must be contiguous 388 - * and adjacent to an existing existing allocation (if one 391 + * and adjacent to an existing allocation (if one 389 392 * exists). If reserving PMEM any space is valid. 390 393 */ 391 394 static void space_valid(struct nd_region *nd_region, struct nvdimm_drvdata *ndd, ··· 836 839 { 837 840 struct nd_region *nd_region = to_nd_region(dev->parent); 838 841 unsigned long long val; 839 - uuid_t **uuid = NULL; 840 842 int rc; 841 843 842 844 rc = kstrtoull(buf, 0, &val); ··· 849 853 if (rc >= 0) 850 854 rc = nd_namespace_label_update(nd_region, dev); 851 855 852 - if (is_namespace_pmem(dev)) { 856 + /* setting size zero == 'delete namespace' */ 857 + if (rc == 0 && val == 0 && is_namespace_pmem(dev)) { 853 858 struct nd_namespace_pmem *nspm = to_nd_namespace_pmem(dev); 854 859 855 - uuid = &nspm->uuid; 856 - } 857 - 858 - if (rc == 0 && val == 0 && uuid) { 859 - /* setting size zero == 'delete namespace' */ 860 - kfree(*uuid); 861 - *uuid = NULL; 860 + kfree(nspm->uuid); 861 + nspm->uuid = NULL; 862 862 } 863 863 864 864 dev_dbg(dev, "%llx %s (%d)\n", val, rc < 0 ? "fail" : "success", rc);
+4 -6
drivers/nvdimm/region_devs.c
··· 509 509 { 510 510 struct nd_region *nd_region = to_nd_region(dev); 511 511 unsigned long val, dpa; 512 - u32 remainder; 512 + u32 mappings, remainder; 513 513 int rc; 514 514 515 515 rc = kstrtoul(buf, 0, &val); 516 516 if (rc) 517 517 return rc; 518 - 519 - if (!nd_region->ndr_mappings) 520 - return -ENXIO; 521 518 522 519 /* 523 520 * Ensure space-align is evenly divisible by the region ··· 523 526 * contribute to the tail capacity in system-physical-address 524 527 * space for the namespace. 525 528 */ 526 - dpa = div_u64_rem(val, nd_region->ndr_mappings, &remainder); 529 + mappings = max_t(u32, 1, nd_region->ndr_mappings); 530 + dpa = div_u64_rem(val, mappings, &remainder); 527 531 if (!is_power_of_2(dpa) || dpa < PAGE_SIZE 528 532 || val > region_size(nd_region) || remainder) 529 533 return -EINVAL; ··· 1094 1096 return rc; 1095 1097 } 1096 1098 /** 1097 - * nvdimm_flush - flush any posted write queues between the cpu and pmem media 1099 + * generic_nvdimm_flush() - flush any posted write queues between the cpu and pmem media 1098 1100 * @nd_region: interleaved pmem region 1099 1101 */ 1100 1102 int generic_nvdimm_flush(struct nd_region *nd_region)
+1 -1
drivers/nvdimm/security.c
··· 408 408 return rc; 409 409 } 410 410 411 - void __nvdimm_security_overwrite_query(struct nvdimm *nvdimm) 411 + static void __nvdimm_security_overwrite_query(struct nvdimm *nvdimm) 412 412 { 413 413 struct nvdimm_bus *nvdimm_bus = walk_to_nvdimm_bus(&nvdimm->dev); 414 414 int rc;