Lines Matching refs:nd_region

40 	struct nd_region *nd_region = to_nd_region(dev->parent);  in namespace_blk_release()  local
43 ida_simple_remove(&nd_region->ns_ida, nsblk->id); in namespace_blk_release()
135 struct nd_region *nd_region = to_nd_region(dev->parent); in pmem_should_map_pages() local
140 if (!test_bit(ND_REGION_PAGEMAP, &nd_region->flags)) in pmem_should_map_pages()
157 struct nd_region *nd_region = to_nd_region(ndns->dev.parent); in nvdimm_namespace_disk_name() local
174 sprintf(name, "pmem%d%s", nd_region->id, suffix ? suffix : ""); in nvdimm_namespace_disk_name()
179 sprintf(name, "ndblk%d.%d%s", nd_region->id, nsblk->id, in nvdimm_namespace_disk_name()
212 struct nd_region *nd_region = to_nd_region(dev->parent); in nstype_show() local
214 return sprintf(buf, "%d\n", nd_region_to_nstype(nd_region)); in nstype_show()
266 struct nd_region *nd_region = to_nd_region(nsblk->common.dev.parent); in nd_namespace_blk_size() local
267 struct nd_mapping *nd_mapping = &nd_region->mapping[0]; in nd_namespace_blk_size()
284 struct nd_region *nd_region = to_nd_region(nsblk->common.dev.parent); in __nd_namespace_blk_validate() local
285 struct nd_mapping *nd_mapping = &nd_region->mapping[0]; in __nd_namespace_blk_validate()
341 static int nd_namespace_label_update(struct nd_region *nd_region, in nd_namespace_label_update() argument
362 return nd_pmem_namespace_label_update(nd_region, nspm, size); in nd_namespace_label_update()
372 return nd_blk_namespace_label_update(nd_region, nsblk, size); in nd_namespace_label_update()
380 struct nd_region *nd_region = to_nd_region(dev->parent); in alt_name_store() local
388 rc = nd_namespace_label_update(nd_region, dev); in alt_name_store()
416 static int scan_free(struct nd_region *nd_region, in scan_free() argument
438 nd_dbg_dpa(nd_region, ndd, res, "delete %d\n", rc); in scan_free()
456 nd_dbg_dpa(nd_region, ndd, res, "shrink %d\n", rc); in scan_free()
474 static int shrink_dpa_allocation(struct nd_region *nd_region, in shrink_dpa_allocation() argument
479 for (i = 0; i < nd_region->ndr_mappings; i++) { in shrink_dpa_allocation()
480 struct nd_mapping *nd_mapping = &nd_region->mapping[i]; in shrink_dpa_allocation()
483 rc = scan_free(nd_region, nd_mapping, label_id, n); in shrink_dpa_allocation()
492 struct nd_region *nd_region, struct nd_mapping *nd_mapping, in init_dpa_allocation() argument
512 nd_dbg_dpa(nd_region, ndd, res, "init %d\n", rc); in init_dpa_allocation()
535 static resource_size_t scan_allocate(struct nd_region *nd_region, in scan_allocate() argument
654 nd_dbg_dpa(nd_region, ndd, new_res, "%s(%d) %d\n", in scan_allocate()
680 return init_dpa_allocation(label_id, nd_region, nd_mapping, n); in scan_allocate()
684 static int merge_dpa(struct nd_region *nd_region, in merge_dpa() argument
705 nd_dbg_dpa(nd_region, ndd, res, "merge %d\n", rc); in merge_dpa()
718 struct nd_region *nd_region; in __reserve_free_pmem() local
725 nd_region = to_nd_region(dev); in __reserve_free_pmem()
726 if (nd_region->ndr_mappings == 0) in __reserve_free_pmem()
731 for (i = 0; i < nd_region->ndr_mappings; i++) { in __reserve_free_pmem()
732 struct nd_mapping *nd_mapping = &nd_region->mapping[i]; in __reserve_free_pmem()
738 n = nd_pmem_available_dpa(nd_region, nd_mapping, &rem); in __reserve_free_pmem()
741 rem = scan_allocate(nd_region, nd_mapping, &label_id, n); in __reserve_free_pmem()
742 dev_WARN_ONCE(&nd_region->dev, rem, in __reserve_free_pmem()
789 static int grow_dpa_allocation(struct nd_region *nd_region, in grow_dpa_allocation() argument
792 struct nvdimm_bus *nvdimm_bus = walk_to_nvdimm_bus(&nd_region->dev); in grow_dpa_allocation()
796 for (i = 0; i < nd_region->ndr_mappings; i++) { in grow_dpa_allocation()
797 struct nd_mapping *nd_mapping = &nd_region->mapping[i]; in grow_dpa_allocation()
813 rem = scan_allocate(nd_region, nd_mapping, in grow_dpa_allocation()
823 dev_WARN_ONCE(&nd_region->dev, rem, in grow_dpa_allocation()
830 rc = merge_dpa(nd_region, nd_mapping, label_id); in grow_dpa_allocation()
838 static void nd_namespace_pmem_set_size(struct nd_region *nd_region, in nd_namespace_pmem_set_size() argument
843 res->start = nd_region->ndr_start; in nd_namespace_pmem_set_size()
844 res->end = nd_region->ndr_start + size - 1; in nd_namespace_pmem_set_size()
850 struct nd_region *nd_region = to_nd_region(dev->parent); in __size_store() local
876 if (!uuid || nd_region->ndr_mappings == 0) in __size_store()
879 div_u64_rem(val, SZ_4K * nd_region->ndr_mappings, &remainder); in __size_store()
882 (SZ_4K * nd_region->ndr_mappings) / SZ_1K); in __size_store()
887 for (i = 0; i < nd_region->ndr_mappings; i++) { in __size_store()
888 nd_mapping = &nd_region->mapping[i]; in __size_store()
900 available = nd_region_available_dpa(nd_region); in __size_store()
908 val = div_u64(val, nd_region->ndr_mappings); in __size_store()
909 allocated = div_u64(allocated, nd_region->ndr_mappings); in __size_store()
911 rc = shrink_dpa_allocation(nd_region, &label_id, in __size_store()
914 rc = grow_dpa_allocation(nd_region, &label_id, val - allocated); in __size_store()
922 nd_namespace_pmem_set_size(nd_region, nspm, in __size_store()
923 val * nd_region->ndr_mappings); in __size_store()
933 if (val == 0 && nd_region->ns_seed != dev in __size_store()
944 struct nd_region *nd_region = to_nd_region(dev->parent); in size_store() local
958 rc = nd_namespace_label_update(nd_region, dev); in size_store()
1052 static int namespace_update_uuid(struct nd_region *nd_region, in namespace_update_uuid() argument
1072 for (i = 0; i < nd_region->ndr_mappings; i++) { in namespace_update_uuid()
1073 struct nd_mapping *nd_mapping = &nd_region->mapping[i]; in namespace_update_uuid()
1088 for (i = 0; i < nd_region->ndr_mappings; i++) { in namespace_update_uuid()
1089 struct nd_mapping *nd_mapping = &nd_region->mapping[i]; in namespace_update_uuid()
1107 struct nd_region *nd_region = to_nd_region(dev->parent); in uuid_store() local
1131 rc = namespace_update_uuid(nd_region, dev, uuid, ns_uuid); in uuid_store()
1133 rc = nd_namespace_label_update(nd_region, dev); in uuid_store()
1186 struct nd_region *nd_region = to_nd_region(dev->parent); in sector_size_store() local
1200 rc = nd_namespace_label_update(nd_region, dev); in sector_size_store()
1214 struct nd_region *nd_region = to_nd_region(dev->parent); in dpa_extents_show() local
1237 for (i = 0; i < nd_region->ndr_mappings; i++) { in dpa_extents_show()
1238 struct nd_mapping *nd_mapping = &nd_region->mapping[i]; in dpa_extents_show()
1415 static struct device **create_namespace_io(struct nd_region *nd_region) in create_namespace_io() argument
1433 dev->parent = &nd_region->dev; in create_namespace_io()
1435 res->name = dev_name(&nd_region->dev); in create_namespace_io()
1437 res->start = nd_region->ndr_start; in create_namespace_io()
1438 res->end = res->start + nd_region->ndr_size - 1; in create_namespace_io()
1444 static bool has_uuid_at_pos(struct nd_region *nd_region, u8 *uuid, in has_uuid_at_pos() argument
1450 for (i = 0; i < nd_region->ndr_mappings; i++) { in has_uuid_at_pos()
1451 struct nd_mapping *nd_mapping = &nd_region->mapping[i]; in has_uuid_at_pos()
1474 if (nlabel != nd_region->ndr_mappings) in has_uuid_at_pos()
1487 static int select_pmem_id(struct nd_region *nd_region, u8 *pmem_id) in select_pmem_id() argument
1495 for (i = 0; i < nd_region->ndr_mappings; i++) { in select_pmem_id()
1496 struct nd_mapping *nd_mapping = &nd_region->mapping[i]; in select_pmem_id()
1534 static int find_pmem_label_set(struct nd_region *nd_region, in find_pmem_label_set() argument
1537 u64 cookie = nd_region_interleave_set_cookie(nd_region); in find_pmem_label_set()
1552 for_each_label(l, nd_label, nd_region->mapping[0].labels) { in find_pmem_label_set()
1558 for (i = 0; nd_region->ndr_mappings; i++) in find_pmem_label_set()
1559 if (!has_uuid_at_pos(nd_region, nd_label->uuid, in find_pmem_label_set()
1562 if (i < nd_region->ndr_mappings) { in find_pmem_label_set()
1591 rc = select_pmem_id(nd_region, pmem_id); in find_pmem_label_set()
1596 for (i = 0; i < nd_region->ndr_mappings; i++) { in find_pmem_label_set()
1597 struct nd_mapping *nd_mapping = &nd_region->mapping[i]; in find_pmem_label_set()
1615 nd_namespace_pmem_set_size(nd_region, nspm, size); in find_pmem_label_set()
1621 dev_dbg(&nd_region->dev, "%s: invalid label(s)\n", __func__); in find_pmem_label_set()
1624 dev_dbg(&nd_region->dev, "%s: label not found\n", __func__); in find_pmem_label_set()
1627 dev_dbg(&nd_region->dev, "%s: unexpected err: %d\n", in find_pmem_label_set()
1634 static struct device **create_namespace_pmem(struct nd_region *nd_region) in create_namespace_pmem() argument
1647 dev->parent = &nd_region->dev; in create_namespace_pmem()
1649 res->name = dev_name(&nd_region->dev); in create_namespace_pmem()
1651 rc = find_pmem_label_set(nd_region, nspm); in create_namespace_pmem()
1656 for (i = 0; i < nd_region->ndr_mappings; i++) { in create_namespace_pmem()
1657 struct nd_mapping *nd_mapping = &nd_region->mapping[i]; in create_namespace_pmem()
1664 nd_namespace_pmem_set_size(nd_region, nspm, 0); in create_namespace_pmem()
1682 struct resource *nsblk_add_resource(struct nd_region *nd_region, in nsblk_add_resource() argument
1705 static struct device *nd_namespace_blk_create(struct nd_region *nd_region) in nd_namespace_blk_create() argument
1710 if (!is_nd_blk(&nd_region->dev)) in nd_namespace_blk_create()
1719 nsblk->id = ida_simple_get(&nd_region->ns_ida, 0, 0, GFP_KERNEL); in nd_namespace_blk_create()
1724 dev_set_name(dev, "namespace%d.%d", nd_region->id, nsblk->id); in nd_namespace_blk_create()
1725 dev->parent = &nd_region->dev; in nd_namespace_blk_create()
1731 void nd_region_create_blk_seed(struct nd_region *nd_region) in nd_region_create_blk_seed() argument
1733 WARN_ON(!is_nvdimm_bus_locked(&nd_region->dev)); in nd_region_create_blk_seed()
1734 nd_region->ns_seed = nd_namespace_blk_create(nd_region); in nd_region_create_blk_seed()
1739 if (!nd_region->ns_seed) in nd_region_create_blk_seed()
1740 dev_err(&nd_region->dev, "failed to create blk namespace\n"); in nd_region_create_blk_seed()
1742 nd_device_register(nd_region->ns_seed); in nd_region_create_blk_seed()
1745 void nd_region_create_btt_seed(struct nd_region *nd_region) in nd_region_create_btt_seed() argument
1747 WARN_ON(!is_nvdimm_bus_locked(&nd_region->dev)); in nd_region_create_btt_seed()
1748 nd_region->btt_seed = nd_btt_create(nd_region); in nd_region_create_btt_seed()
1753 if (!nd_region->btt_seed) in nd_region_create_btt_seed()
1754 dev_err(&nd_region->dev, "failed to create btt namespace\n"); in nd_region_create_btt_seed()
1757 static struct device **create_namespace_blk(struct nd_region *nd_region) in create_namespace_blk() argument
1759 struct nd_mapping *nd_mapping = &nd_region->mapping[0]; in create_namespace_blk()
1767 if (nd_region->ndr_mappings == 0) in create_namespace_blk()
1785 res = nsblk_add_resource(nd_region, ndd, nsblk, in create_namespace_blk()
1789 nd_dbg_dpa(nd_region, ndd, res, "%s assign\n", in create_namespace_blk()
1808 dev->parent = &nd_region->dev; in create_namespace_blk()
1809 dev_set_name(dev, "namespace%d.%d", nd_region->id, count); in create_namespace_blk()
1821 res = nsblk_add_resource(nd_region, ndd, nsblk, in create_namespace_blk()
1825 nd_dbg_dpa(nd_region, ndd, res, "%s assign\n", in create_namespace_blk()
1829 dev_dbg(&nd_region->dev, "%s: discovered %d blk namespace%s\n", in create_namespace_blk()
1834 for (i = 0; i < nd_region->ndr_mappings; i++) { in create_namespace_blk()
1835 struct nd_mapping *nd_mapping = &nd_region->mapping[i]; in create_namespace_blk()
1849 dev->parent = &nd_region->dev; in create_namespace_blk()
1864 static int init_active_labels(struct nd_region *nd_region) in init_active_labels() argument
1868 for (i = 0; i < nd_region->ndr_mappings; i++) { in init_active_labels()
1869 struct nd_mapping *nd_mapping = &nd_region->mapping[i]; in init_active_labels()
1881 dev_dbg(&nd_region->dev, "%s: is disabled, failing probe\n", in init_active_labels()
1908 int nd_region_register_namespaces(struct nd_region *nd_region, int *err) in nd_region_register_namespaces() argument
1914 nvdimm_bus_lock(&nd_region->dev); in nd_region_register_namespaces()
1915 rc = init_active_labels(nd_region); in nd_region_register_namespaces()
1917 nvdimm_bus_unlock(&nd_region->dev); in nd_region_register_namespaces()
1921 type = nd_region_to_nstype(nd_region); in nd_region_register_namespaces()
1924 devs = create_namespace_io(nd_region); in nd_region_register_namespaces()
1927 devs = create_namespace_pmem(nd_region); in nd_region_register_namespaces()
1930 devs = create_namespace_blk(nd_region); in nd_region_register_namespaces()
1935 nvdimm_bus_unlock(&nd_region->dev); in nd_region_register_namespaces()
1948 id = ida_simple_get(&nd_region->ns_ida, 0, 0, in nd_region_register_namespaces()
1956 dev_set_name(dev, "namespace%d.%d", nd_region->id, id); in nd_region_register_namespaces()
1961 nd_region->ns_seed = devs[0]; in nd_region_register_namespaces()