Skip to content

Commit 19d17ab

Browse files
committed
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()
2 parents b7270c6 + 305a72e commit 19d17ab

File tree

5 files changed

+18
-28
lines changed

5 files changed

+18
-28
lines changed

drivers/dax/hmem/device.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ void hmem_register_device(int target_nid, struct resource *r)
4848
rc = platform_device_add_data(pdev, &info, sizeof(info));
4949
if (rc < 0) {
5050
pr_err("hmem memregion_info allocation failure for %pr\n", &res);
51-
goto out_pdev;
51+
goto out_resource;
5252
}
5353

5454
rc = platform_device_add_resources(pdev, &res, 1);
@@ -66,7 +66,7 @@ void hmem_register_device(int target_nid, struct resource *r)
6666
return;
6767

6868
out_resource:
69-
put_device(&pdev->dev);
69+
platform_device_put(pdev);
7070
out_pdev:
7171
memregion_free(id);
7272
}

drivers/dax/super.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ static void dax_free_inode(struct inode *inode)
363363
{
364364
struct dax_device *dax_dev = to_dax_dev(inode);
365365
if (inode->i_rdev)
366-
ida_simple_remove(&dax_minor_ida, iminor(inode));
366+
ida_free(&dax_minor_ida, iminor(inode));
367367
kmem_cache_free(dax_cache, dax_dev);
368368
}
369369

@@ -445,7 +445,7 @@ struct dax_device *alloc_dax(void *private, const struct dax_operations *ops)
445445
if (WARN_ON_ONCE(ops && !ops->zero_page_range))
446446
return ERR_PTR(-EINVAL);
447447

448-
minor = ida_simple_get(&dax_minor_ida, 0, MINORMASK+1, GFP_KERNEL);
448+
minor = ida_alloc_max(&dax_minor_ida, MINORMASK, GFP_KERNEL);
449449
if (minor < 0)
450450
return ERR_PTR(-ENOMEM);
451451

@@ -459,7 +459,7 @@ struct dax_device *alloc_dax(void *private, const struct dax_operations *ops)
459459
return dax_dev;
460460

461461
err_dev:
462-
ida_simple_remove(&dax_minor_ida, minor);
462+
ida_free(&dax_minor_ida, minor);
463463
return ERR_PTR(-ENOMEM);
464464
}
465465
EXPORT_SYMBOL_GPL(alloc_dax);

drivers/nvdimm/namespace_devs.c

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -170,15 +170,12 @@ EXPORT_SYMBOL(nvdimm_namespace_disk_name);
170170

171171
const uuid_t *nd_dev_to_uuid(struct device *dev)
172172
{
173-
if (!dev)
174-
return &uuid_null;
175-
176-
if (is_namespace_pmem(dev)) {
173+
if (dev && is_namespace_pmem(dev)) {
177174
struct nd_namespace_pmem *nspm = to_nd_namespace_pmem(dev);
178175

179176
return nspm->uuid;
180-
} else
181-
return &uuid_null;
177+
}
178+
return &uuid_null;
182179
}
183180
EXPORT_SYMBOL(nd_dev_to_uuid);
184181

@@ -388,7 +385,7 @@ static resource_size_t init_dpa_allocation(struct nd_label_id *label_id,
388385
*
389386
* BLK-space is valid as long as it does not precede a PMEM
390387
* allocation in a given region. PMEM-space must be contiguous
391-
* and adjacent to an existing existing allocation (if one
388+
* and adjacent to an existing allocation (if one
392389
* exists). If reserving PMEM any space is valid.
393390
*/
394391
static void space_valid(struct nd_region *nd_region, struct nvdimm_drvdata *ndd,
@@ -839,7 +836,6 @@ static ssize_t size_store(struct device *dev,
839836
{
840837
struct nd_region *nd_region = to_nd_region(dev->parent);
841838
unsigned long long val;
842-
uuid_t **uuid = NULL;
843839
int rc;
844840

845841
rc = kstrtoull(buf, 0, &val);
@@ -853,16 +849,12 @@ static ssize_t size_store(struct device *dev,
853849
if (rc >= 0)
854850
rc = nd_namespace_label_update(nd_region, dev);
855851

856-
if (is_namespace_pmem(dev)) {
852+
/* setting size zero == 'delete namespace' */
853+
if (rc == 0 && val == 0 && is_namespace_pmem(dev)) {
857854
struct nd_namespace_pmem *nspm = to_nd_namespace_pmem(dev);
858855

859-
uuid = &nspm->uuid;
860-
}
861-
862-
if (rc == 0 && val == 0 && uuid) {
863-
/* setting size zero == 'delete namespace' */
864-
kfree(*uuid);
865-
*uuid = NULL;
856+
kfree(nspm->uuid);
857+
nspm->uuid = NULL;
866858
}
867859

868860
dev_dbg(dev, "%llx %s (%d)\n", val, rc < 0 ? "fail" : "success", rc);

drivers/nvdimm/region_devs.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -509,24 +509,22 @@ static ssize_t align_store(struct device *dev,
509509
{
510510
struct nd_region *nd_region = to_nd_region(dev);
511511
unsigned long val, dpa;
512-
u32 remainder;
512+
u32 mappings, remainder;
513513
int rc;
514514

515515
rc = kstrtoul(buf, 0, &val);
516516
if (rc)
517517
return rc;
518518

519-
if (!nd_region->ndr_mappings)
520-
return -ENXIO;
521-
522519
/*
523520
* Ensure space-align is evenly divisible by the region
524521
* interleave-width because the kernel typically has no facility
525522
* to determine which DIMM(s), dimm-physical-addresses, would
526523
* contribute to the tail capacity in system-physical-address
527524
* space for the namespace.
528525
*/
529-
dpa = div_u64_rem(val, nd_region->ndr_mappings, &remainder);
526+
mappings = max_t(u32, 1, nd_region->ndr_mappings);
527+
dpa = div_u64_rem(val, mappings, &remainder);
530528
if (!is_power_of_2(dpa) || dpa < PAGE_SIZE
531529
|| val > region_size(nd_region) || remainder)
532530
return -EINVAL;
@@ -1096,7 +1094,7 @@ int nvdimm_flush(struct nd_region *nd_region, struct bio *bio)
10961094
return rc;
10971095
}
10981096
/**
1099-
* nvdimm_flush - flush any posted write queues between the cpu and pmem media
1097+
* generic_nvdimm_flush() - flush any posted write queues between the cpu and pmem media
11001098
* @nd_region: interleaved pmem region
11011099
*/
11021100
int generic_nvdimm_flush(struct nd_region *nd_region)

drivers/nvdimm/security.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ static int security_overwrite(struct nvdimm *nvdimm, unsigned int keyid)
408408
return rc;
409409
}
410410

411-
void __nvdimm_security_overwrite_query(struct nvdimm *nvdimm)
411+
static void __nvdimm_security_overwrite_query(struct nvdimm *nvdimm)
412412
{
413413
struct nvdimm_bus *nvdimm_bus = walk_to_nvdimm_bus(&nvdimm->dev);
414414
int rc;

0 commit comments

Comments
 (0)