Skip to content

Commit 3b6c6c0

Browse files
committed
nvdimm/region: Delete nd_blk_region infrastructure
Now that the nd_namespace_blk infrastructure is removed, delete all the region machinery to coordinate provisioning aliased capacity between PMEM and BLK. Reviewed-by: Christoph Hellwig <hch@lst.de> Link: https://lore.kernel.org/r/164688418803.2879318.1302315202397235855.stgit@dwillia2-desk3.amr.corp.intel.com Signed-off-by: Dan Williams <dan.j.williams@intel.com>
1 parent a4b9604 commit 3b6c6c0

13 files changed

Lines changed: 66 additions & 604 deletions

File tree

drivers/acpi/nfit/core.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2036,10 +2036,6 @@ static int acpi_nfit_register_dimms(struct acpi_nfit_desc *acpi_desc)
20362036
cmd_mask |= nfit_mem->dsm_mask & NVDIMM_STANDARD_CMDMASK;
20372037
}
20382038

2039-
/* Quirk to ignore LOCAL for labels on HYPERV DIMMs */
2040-
if (nfit_mem->family == NVDIMM_FAMILY_HYPERV)
2041-
set_bit(NDD_NOBLK, &flags);
2042-
20432039
if (test_bit(NFIT_MEM_LSR, &nfit_mem->flags)) {
20442040
set_bit(ND_CMD_GET_CONFIG_SIZE, &cmd_mask);
20452041
set_bit(ND_CMD_GET_CONFIG_DATA, &cmd_mask);
@@ -2602,8 +2598,7 @@ static int acpi_nfit_register_region(struct acpi_nfit_desc *acpi_desc,
26022598
{
26032599
static struct nd_mapping_desc mappings[ND_MAX_MAPPINGS];
26042600
struct acpi_nfit_system_address *spa = nfit_spa->spa;
2605-
struct nd_blk_region_desc ndbr_desc;
2606-
struct nd_region_desc *ndr_desc;
2601+
struct nd_region_desc *ndr_desc, _ndr_desc;
26072602
struct nfit_memdev *nfit_memdev;
26082603
struct nvdimm_bus *nvdimm_bus;
26092604
struct resource res;
@@ -2619,10 +2614,10 @@ static int acpi_nfit_register_region(struct acpi_nfit_desc *acpi_desc,
26192614

26202615
memset(&res, 0, sizeof(res));
26212616
memset(&mappings, 0, sizeof(mappings));
2622-
memset(&ndbr_desc, 0, sizeof(ndbr_desc));
2617+
memset(&_ndr_desc, 0, sizeof(_ndr_desc));
26232618
res.start = spa->address;
26242619
res.end = res.start + spa->length - 1;
2625-
ndr_desc = &ndbr_desc.ndr_desc;
2620+
ndr_desc = &_ndr_desc;
26262621
ndr_desc->res = &res;
26272622
ndr_desc->provider_data = nfit_spa;
26282623
ndr_desc->attr_groups = acpi_nfit_region_attribute_groups;

drivers/nvdimm/bus.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ static int to_nd_device_type(struct device *dev)
3535
return ND_DEVICE_DIMM;
3636
else if (is_memory(dev))
3737
return ND_DEVICE_REGION_PMEM;
38-
else if (is_nd_blk(dev))
39-
return ND_DEVICE_REGION_BLK;
4038
else if (is_nd_dax(dev))
4139
return ND_DEVICE_DAX_PMEM;
4240
else if (is_nd_region(dev->parent))

drivers/nvdimm/dimm_devs.c

Lines changed: 14 additions & 190 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,6 @@
1818

1919
static DEFINE_IDA(dimm_ida);
2020

21-
static bool noblk;
22-
module_param(noblk, bool, 0444);
23-
MODULE_PARM_DESC(noblk, "force disable BLK / local alias support");
24-
2521
/*
2622
* Retrieve bus and dimm handle and return if this bus supports
2723
* get_config_data commands
@@ -211,22 +207,6 @@ struct nvdimm *to_nvdimm(struct device *dev)
211207
}
212208
EXPORT_SYMBOL_GPL(to_nvdimm);
213209

214-
struct nvdimm *nd_blk_region_to_dimm(struct nd_blk_region *ndbr)
215-
{
216-
struct nd_region *nd_region = &ndbr->nd_region;
217-
struct nd_mapping *nd_mapping = &nd_region->mapping[0];
218-
219-
return nd_mapping->nvdimm;
220-
}
221-
EXPORT_SYMBOL_GPL(nd_blk_region_to_dimm);
222-
223-
unsigned long nd_blk_memremap_flags(struct nd_blk_region *ndbr)
224-
{
225-
/* pmem mapping properties are private to libnvdimm */
226-
return ARCH_MEMREMAP_PMEM;
227-
}
228-
EXPORT_SYMBOL_GPL(nd_blk_memremap_flags);
229-
230210
struct nvdimm_drvdata *to_ndd(struct nd_mapping *nd_mapping)
231211
{
232212
struct nvdimm *nvdimm = nd_mapping->nvdimm;
@@ -312,8 +292,7 @@ static ssize_t flags_show(struct device *dev,
312292
{
313293
struct nvdimm *nvdimm = to_nvdimm(dev);
314294

315-
return sprintf(buf, "%s%s%s\n",
316-
test_bit(NDD_ALIASING, &nvdimm->flags) ? "alias " : "",
295+
return sprintf(buf, "%s%s\n",
317296
test_bit(NDD_LABELING, &nvdimm->flags) ? "label " : "",
318297
test_bit(NDD_LOCKED, &nvdimm->flags) ? "lock " : "");
319298
}
@@ -612,8 +591,6 @@ struct nvdimm *__nvdimm_create(struct nvdimm_bus *nvdimm_bus,
612591

613592
nvdimm->dimm_id = dimm_id;
614593
nvdimm->provider_data = provider_data;
615-
if (noblk)
616-
flags |= 1 << NDD_NOBLK;
617594
nvdimm->flags = flags;
618595
nvdimm->cmd_mask = cmd_mask;
619596
nvdimm->num_flush = num_flush;
@@ -726,133 +703,6 @@ static unsigned long dpa_align(struct nd_region *nd_region)
726703
return nd_region->align / nd_region->ndr_mappings;
727704
}
728705

729-
int alias_dpa_busy(struct device *dev, void *data)
730-
{
731-
resource_size_t map_end, blk_start, new;
732-
struct blk_alloc_info *info = data;
733-
struct nd_mapping *nd_mapping;
734-
struct nd_region *nd_region;
735-
struct nvdimm_drvdata *ndd;
736-
struct resource *res;
737-
unsigned long align;
738-
int i;
739-
740-
if (!is_memory(dev))
741-
return 0;
742-
743-
nd_region = to_nd_region(dev);
744-
for (i = 0; i < nd_region->ndr_mappings; i++) {
745-
nd_mapping = &nd_region->mapping[i];
746-
if (nd_mapping->nvdimm == info->nd_mapping->nvdimm)
747-
break;
748-
}
749-
750-
if (i >= nd_region->ndr_mappings)
751-
return 0;
752-
753-
ndd = to_ndd(nd_mapping);
754-
map_end = nd_mapping->start + nd_mapping->size - 1;
755-
blk_start = nd_mapping->start;
756-
757-
/*
758-
* In the allocation case ->res is set to free space that we are
759-
* looking to validate against PMEM aliasing collision rules
760-
* (i.e. BLK is allocated after all aliased PMEM).
761-
*/
762-
if (info->res) {
763-
if (info->res->start >= nd_mapping->start
764-
&& info->res->start < map_end)
765-
/* pass */;
766-
else
767-
return 0;
768-
}
769-
770-
retry:
771-
/*
772-
* Find the free dpa from the end of the last pmem allocation to
773-
* the end of the interleave-set mapping.
774-
*/
775-
align = dpa_align(nd_region);
776-
if (!align)
777-
return 0;
778-
779-
for_each_dpa_resource(ndd, res) {
780-
resource_size_t start, end;
781-
782-
if (strncmp(res->name, "pmem", 4) != 0)
783-
continue;
784-
785-
start = ALIGN_DOWN(res->start, align);
786-
end = ALIGN(res->end + 1, align) - 1;
787-
if ((start >= blk_start && start < map_end)
788-
|| (end >= blk_start && end <= map_end)) {
789-
new = max(blk_start, min(map_end, end) + 1);
790-
if (new != blk_start) {
791-
blk_start = new;
792-
goto retry;
793-
}
794-
}
795-
}
796-
797-
/* update the free space range with the probed blk_start */
798-
if (info->res && blk_start > info->res->start) {
799-
info->res->start = max(info->res->start, blk_start);
800-
if (info->res->start > info->res->end)
801-
info->res->end = info->res->start - 1;
802-
return 1;
803-
}
804-
805-
info->available -= blk_start - nd_mapping->start;
806-
807-
return 0;
808-
}
809-
810-
/**
811-
* nd_blk_available_dpa - account the unused dpa of BLK region
812-
* @nd_mapping: container of dpa-resource-root + labels
813-
*
814-
* Unlike PMEM, BLK namespaces can occupy discontiguous DPA ranges, but
815-
* we arrange for them to never start at an lower dpa than the last
816-
* PMEM allocation in an aliased region.
817-
*/
818-
resource_size_t nd_blk_available_dpa(struct nd_region *nd_region)
819-
{
820-
struct nvdimm_bus *nvdimm_bus = walk_to_nvdimm_bus(&nd_region->dev);
821-
struct nd_mapping *nd_mapping = &nd_region->mapping[0];
822-
struct nvdimm_drvdata *ndd = to_ndd(nd_mapping);
823-
struct blk_alloc_info info = {
824-
.nd_mapping = nd_mapping,
825-
.available = nd_mapping->size,
826-
.res = NULL,
827-
};
828-
struct resource *res;
829-
unsigned long align;
830-
831-
if (!ndd)
832-
return 0;
833-
834-
device_for_each_child(&nvdimm_bus->dev, &info, alias_dpa_busy);
835-
836-
/* now account for busy blk allocations in unaliased dpa */
837-
align = dpa_align(nd_region);
838-
if (!align)
839-
return 0;
840-
for_each_dpa_resource(ndd, res) {
841-
resource_size_t start, end, size;
842-
843-
if (strncmp(res->name, "blk", 3) != 0)
844-
continue;
845-
start = ALIGN_DOWN(res->start, align);
846-
end = ALIGN(res->end + 1, align) - 1;
847-
size = end - start + 1;
848-
if (size >= info.available)
849-
return 0;
850-
info.available -= size;
851-
}
852-
853-
return info.available;
854-
}
855-
856706
/**
857707
* nd_pmem_max_contiguous_dpa - For the given dimm+region, return the max
858708
* contiguous unallocated dpa range.
@@ -900,24 +750,16 @@ resource_size_t nd_pmem_max_contiguous_dpa(struct nd_region *nd_region,
900750
* nd_pmem_available_dpa - for the given dimm+region account unallocated dpa
901751
* @nd_mapping: container of dpa-resource-root + labels
902752
* @nd_region: constrain available space check to this reference region
903-
* @overlap: calculate available space assuming this level of overlap
904753
*
905754
* Validate that a PMEM label, if present, aligns with the start of an
906-
* interleave set and truncate the available size at the lowest BLK
907-
* overlap point.
908-
*
909-
* The expectation is that this routine is called multiple times as it
910-
* probes for the largest BLK encroachment for any single member DIMM of
911-
* the interleave set. Once that value is determined the PMEM-limit for
912-
* the set can be established.
755+
* interleave set.
913756
*/
914757
resource_size_t nd_pmem_available_dpa(struct nd_region *nd_region,
915-
struct nd_mapping *nd_mapping, resource_size_t *overlap)
758+
struct nd_mapping *nd_mapping)
916759
{
917-
resource_size_t map_start, map_end, busy = 0, available, blk_start;
918760
struct nvdimm_drvdata *ndd = to_ndd(nd_mapping);
761+
resource_size_t map_start, map_end, busy = 0;
919762
struct resource *res;
920-
const char *reason;
921763
unsigned long align;
922764

923765
if (!ndd)
@@ -929,46 +771,28 @@ resource_size_t nd_pmem_available_dpa(struct nd_region *nd_region,
929771

930772
map_start = nd_mapping->start;
931773
map_end = map_start + nd_mapping->size - 1;
932-
blk_start = max(map_start, map_end + 1 - *overlap);
933774
for_each_dpa_resource(ndd, res) {
934775
resource_size_t start, end;
935776

936777
start = ALIGN_DOWN(res->start, align);
937778
end = ALIGN(res->end + 1, align) - 1;
938779
if (start >= map_start && start < map_end) {
939-
if (strncmp(res->name, "blk", 3) == 0)
940-
blk_start = min(blk_start,
941-
max(map_start, start));
942-
else if (end > map_end) {
943-
reason = "misaligned to iset";
944-
goto err;
945-
} else
946-
busy += end - start + 1;
780+
if (end > map_end) {
781+
nd_dbg_dpa(nd_region, ndd, res,
782+
"misaligned to iset\n");
783+
return 0;
784+
}
785+
busy += end - start + 1;
947786
} else if (end >= map_start && end <= map_end) {
948-
if (strncmp(res->name, "blk", 3) == 0) {
949-
/*
950-
* If a BLK allocation overlaps the start of
951-
* PMEM the entire interleave set may now only
952-
* be used for BLK.
953-
*/
954-
blk_start = map_start;
955-
} else
956-
busy += end - start + 1;
787+
busy += end - start + 1;
957788
} else if (map_start > start && map_start < end) {
958789
/* total eclipse of the mapping */
959790
busy += nd_mapping->size;
960-
blk_start = map_start;
961791
}
962792
}
963793

964-
*overlap = map_end + 1 - blk_start;
965-
available = blk_start - map_start;
966-
if (busy < available)
967-
return ALIGN_DOWN(available - busy, align);
968-
return 0;
969-
970-
err:
971-
nd_dbg_dpa(nd_region, ndd, res, "%s\n", reason);
794+
if (busy < nd_mapping->size)
795+
return ALIGN_DOWN(nd_mapping->size - busy, align);
972796
return 0;
973797
}
974798

@@ -999,7 +823,7 @@ struct resource *nvdimm_allocate_dpa(struct nvdimm_drvdata *ndd,
999823
/**
1000824
* nvdimm_allocated_dpa - sum up the dpa currently allocated to this label_id
1001825
* @nvdimm: container of dpa-resource-root + labels
1002-
* @label_id: dpa resource name of the form {pmem|blk}-<human readable uuid>
826+
* @label_id: dpa resource name of the form pmem-<human readable uuid>
1003827
*/
1004828
resource_size_t nvdimm_allocated_dpa(struct nvdimm_drvdata *ndd,
1005829
struct nd_label_id *label_id)

drivers/nvdimm/label.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -334,8 +334,7 @@ char *nd_label_gen_id(struct nd_label_id *label_id, const uuid_t *uuid,
334334
{
335335
if (!label_id || !uuid)
336336
return NULL;
337-
snprintf(label_id->id, ND_LABEL_ID_SIZE, "%s-%pUb",
338-
flags & NSLABEL_FLAG_LOCAL ? "blk" : "pmem", uuid);
337+
snprintf(label_id->id, ND_LABEL_ID_SIZE, "pmem-%pUb", uuid);
339338
return label_id->id;
340339
}
341340

@@ -406,7 +405,6 @@ int nd_label_reserve_dpa(struct nvdimm_drvdata *ndd)
406405
return 0; /* no label, nothing to reserve */
407406

408407
for_each_clear_bit_le(slot, free, nslot) {
409-
struct nvdimm *nvdimm = to_nvdimm(ndd->dev);
410408
struct nd_namespace_label *nd_label;
411409
struct nd_region *nd_region = NULL;
412410
struct nd_label_id label_id;
@@ -421,8 +419,6 @@ int nd_label_reserve_dpa(struct nvdimm_drvdata *ndd)
421419

422420
nsl_get_uuid(ndd, nd_label, &label_uuid);
423421
flags = nsl_get_flags(ndd, nd_label);
424-
if (test_bit(NDD_NOBLK, &nvdimm->flags))
425-
flags &= ~NSLABEL_FLAG_LOCAL;
426422
nd_label_gen_id(&label_id, &label_uuid, flags);
427423
res = nvdimm_allocate_dpa(ndd, &label_id,
428424
nsl_get_dpa(ndd, nd_label),

drivers/nvdimm/label.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ struct nd_namespace_label {
193193

194194
/**
195195
* struct nd_label_id - identifier string for dpa allocation
196-
* @id: "{blk|pmem}-<namespace uuid>"
196+
* @id: "pmem-<namespace uuid>"
197197
*/
198198
struct nd_label_id {
199199
char id[ND_LABEL_ID_SIZE];

0 commit comments

Comments
 (0)