aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/nvdimm/namespace_devs.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2019-09-21 13:55:29 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2019-09-21 13:55:29 -0400
commit6cb2e9ee51b5f1539f027346a02904e282b87d4d (patch)
treebf940785b622e8792ae943af9b92f55c5202612e /drivers/nvdimm/namespace_devs.c
parent10fd71780f7d155f4e35fecfad0ebd4a725a244b (diff)
parent5b26db95fee3f1ce0d096b2de0ac6f3716171093 (diff)
Merge tag 'libnvdimm-for-5.4' of git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm
Pull libnvdimm updates from Dan Williams: "Some reworks to better support nvdimms on powerpc and an nvdimm security interface update: - Rework the nvdimm core to accommodate architectures with different page sizes and ones that can change supported huge page sizes at boot time rather than a compile time constant. - Introduce a distinct 'frozen' attribute for the nvdimm security state since it is independent of the locked state. - Miscellaneous fixups" * tag 'libnvdimm-for-5.4' of git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm: libnvdimm: Use PAGE_SIZE instead of SZ_4K for align check libnvdimm/label: Remove the dpa align check libnvdimm/pfn_dev: Add page size and struct page size to pfn superblock libnvdimm/pfn_dev: Add a build check to make sure we notice when struct page size change libnvdimm/pmem: Advance namespace seed for specific probe errors libnvdimm/region: Rewrite _probe_success() to _advance_seeds() libnvdimm/security: Consolidate 'security' operations libnvdimm/security: Tighten scope of nvdimm->busy vs security operations libnvdimm/security: Introduce a 'frozen' attribute libnvdimm, region: Use struct_size() in kzalloc() tools/testing/nvdimm: Fix fallthrough warning libnvdimm/of_pmem: Provide a unique name for bus provider
Diffstat (limited to 'drivers/nvdimm/namespace_devs.c')
-rw-r--r--drivers/nvdimm/namespace_devs.c40
1 files changed, 31 insertions, 9 deletions
diff --git a/drivers/nvdimm/namespace_devs.c b/drivers/nvdimm/namespace_devs.c
index a16e52251a30..43401325c874 100644
--- a/drivers/nvdimm/namespace_devs.c
+++ b/drivers/nvdimm/namespace_devs.c
@@ -1006,10 +1006,10 @@ static ssize_t __size_store(struct device *dev, unsigned long long val)
1006 return -ENXIO; 1006 return -ENXIO;
1007 } 1007 }
1008 1008
1009 div_u64_rem(val, SZ_4K * nd_region->ndr_mappings, &remainder); 1009 div_u64_rem(val, PAGE_SIZE * nd_region->ndr_mappings, &remainder);
1010 if (remainder) { 1010 if (remainder) {
1011 dev_dbg(dev, "%llu is not %dK aligned\n", val, 1011 dev_dbg(dev, "%llu is not %ldK aligned\n", val,
1012 (SZ_4K * nd_region->ndr_mappings) / SZ_1K); 1012 (PAGE_SIZE * nd_region->ndr_mappings) / SZ_1K);
1013 return -EINVAL; 1013 return -EINVAL;
1014 } 1014 }
1015 1015
@@ -2462,6 +2462,27 @@ static struct device **create_namespaces(struct nd_region *nd_region)
2462 return devs; 2462 return devs;
2463} 2463}
2464 2464
2465static void deactivate_labels(void *region)
2466{
2467 struct nd_region *nd_region = region;
2468 int i;
2469
2470 for (i = 0; i < nd_region->ndr_mappings; i++) {
2471 struct nd_mapping *nd_mapping = &nd_region->mapping[i];
2472 struct nvdimm_drvdata *ndd = nd_mapping->ndd;
2473 struct nvdimm *nvdimm = nd_mapping->nvdimm;
2474
2475 mutex_lock(&nd_mapping->lock);
2476 nd_mapping_free_labels(nd_mapping);
2477 mutex_unlock(&nd_mapping->lock);
2478
2479 put_ndd(ndd);
2480 nd_mapping->ndd = NULL;
2481 if (ndd)
2482 atomic_dec(&nvdimm->busy);
2483 }
2484}
2485
2465static int init_active_labels(struct nd_region *nd_region) 2486static int init_active_labels(struct nd_region *nd_region)
2466{ 2487{
2467 int i; 2488 int i;
@@ -2519,16 +2540,17 @@ static int init_active_labels(struct nd_region *nd_region)
2519 mutex_unlock(&nd_mapping->lock); 2540 mutex_unlock(&nd_mapping->lock);
2520 } 2541 }
2521 2542
2522 if (j >= count) 2543 if (j < count)
2523 continue; 2544 break;
2545 }
2524 2546
2525 mutex_lock(&nd_mapping->lock); 2547 if (i < nd_region->ndr_mappings) {
2526 nd_mapping_free_labels(nd_mapping); 2548 deactivate_labels(nd_region);
2527 mutex_unlock(&nd_mapping->lock);
2528 return -ENOMEM; 2549 return -ENOMEM;
2529 } 2550 }
2530 2551
2531 return 0; 2552 return devm_add_action_or_reset(&nd_region->dev, deactivate_labels,
2553 nd_region);
2532} 2554}
2533 2555
2534int nd_region_register_namespaces(struct nd_region *nd_region, int *err) 2556int nd_region_register_namespaces(struct nd_region *nd_region, int *err)