Lines Matching refs:dax_region
148 static bool is_static(struct dax_region *dax_region) in is_static() argument
150 return (dax_region->res.flags & IORESOURCE_DAX_STATIC) != 0; in is_static()
176 struct dax_region *dax_region = dev_dax->region; in dax_bus_probe() local
184 if (rc || is_static(dax_region)) in dax_bus_probe()
191 if (dax_region->seed == dev) in dax_bus_probe()
192 dax_region->seed = NULL; in dax_bus_probe()
237 struct dax_region *dax_region = dev_get_drvdata(dev); in id_show() local
239 return sprintf(buf, "%d\n", dax_region->id); in id_show()
246 struct dax_region *dax_region = dev_get_drvdata(dev); in region_size_show() local
249 resource_size(&dax_region->res)); in region_size_show()
257 struct dax_region *dax_region = dev_get_drvdata(dev); in region_align_show() local
259 return sprintf(buf, "%u\n", dax_region->align); in region_align_show()
264 #define for_each_dax_region_resource(dax_region, res) \ argument
265 for (res = (dax_region)->res.child; res; res = res->sibling)
267 static unsigned long long dax_region_avail_size(struct dax_region *dax_region) in dax_region_avail_size() argument
269 resource_size_t size = resource_size(&dax_region->res); in dax_region_avail_size()
272 device_lock_assert(dax_region->dev); in dax_region_avail_size()
274 for_each_dax_region_resource(dax_region, res) in dax_region_avail_size()
282 struct dax_region *dax_region = dev_get_drvdata(dev); in available_size_show() local
286 size = dax_region_avail_size(dax_region); in available_size_show()
296 struct dax_region *dax_region = dev_get_drvdata(dev); in seed_show() local
300 if (is_static(dax_region)) in seed_show()
304 seed = dax_region->seed; in seed_show()
315 struct dax_region *dax_region = dev_get_drvdata(dev); in create_show() local
319 if (is_static(dax_region)) in create_show()
323 youngest = dax_region->youngest; in create_show()
333 struct dax_region *dax_region = dev_get_drvdata(dev); in create_store() local
338 if (is_static(dax_region)) in create_store()
348 avail = dax_region_avail_size(dax_region); in create_store()
353 .dax_region = dax_region, in create_store()
369 if (!dax_region->seed) in create_store()
370 dax_region->seed = &dev_dax->dev; in create_store()
371 dax_region->youngest = &dev_dax->dev; in create_store()
403 struct dax_region *dax_region = dev_dax->region; in trim_dev_dax_range() local
405 device_lock_assert(dax_region->dev); in trim_dev_dax_range()
410 __release_region(&dax_region->res, range->start, range_len(range)); in trim_dev_dax_range()
438 struct dax_region *dax_region = dev_dax->region; in __free_dev_dax_id() local
444 if (is_static(dax_region) || dev_dax->id < 0) in __free_dev_dax_id()
446 ida_free(&dax_region->ida, dev_dax->id); in __free_dev_dax_id()
465 struct dax_region *dax_region = dev_get_drvdata(dev); in delete_store() local
471 if (is_static(dax_region)) in delete_store()
474 victim = device_find_child_by_name(dax_region->dev, buf); in delete_store()
493 if (dax_region->seed == victim) in delete_store()
494 dax_region->seed = NULL; in delete_store()
495 if (dax_region->youngest == victim) in delete_store()
496 dax_region->youngest = NULL; in delete_store()
516 struct dax_region *dax_region = dev_get_drvdata(dev); in dax_region_visible() local
518 if (is_static(dax_region)) in dax_region_visible()
551 struct dax_region *dax_region; in dax_region_free() local
553 dax_region = container_of(kref, struct dax_region, kref); in dax_region_free()
554 kfree(dax_region); in dax_region_free()
557 void dax_region_put(struct dax_region *dax_region) in dax_region_put() argument
559 kref_put(&dax_region->kref, dax_region_free); in dax_region_put()
565 struct dax_region *dax_region = region; in dax_region_unregister() local
567 sysfs_remove_groups(&dax_region->dev->kobj, in dax_region_unregister()
569 dax_region_put(dax_region); in dax_region_unregister()
572 struct dax_region *alloc_dax_region(struct device *parent, int region_id, in alloc_dax_region()
576 struct dax_region *dax_region; in alloc_dax_region() local
592 dax_region = kzalloc(sizeof(*dax_region), GFP_KERNEL); in alloc_dax_region()
593 if (!dax_region) in alloc_dax_region()
596 dev_set_drvdata(parent, dax_region); in alloc_dax_region()
597 kref_init(&dax_region->kref); in alloc_dax_region()
598 dax_region->id = region_id; in alloc_dax_region()
599 dax_region->align = align; in alloc_dax_region()
600 dax_region->dev = parent; in alloc_dax_region()
601 dax_region->target_node = target_node; in alloc_dax_region()
602 ida_init(&dax_region->ida); in alloc_dax_region()
603 dax_region->res = (struct resource) { in alloc_dax_region()
610 kfree(dax_region); in alloc_dax_region()
614 kref_get(&dax_region->kref); in alloc_dax_region()
615 if (devm_add_action_or_reset(parent, dax_region_unregister, dax_region)) in alloc_dax_region()
617 return dax_region; in alloc_dax_region()
635 struct dax_region *dax_region = dev_dax->region; in unregister_dax_mapping() local
639 device_lock_assert(dax_region->dev); in unregister_dax_mapping()
652 struct dax_region *dax_region = dev_dax->region; in get_dax_range() local
654 device_lock(dax_region->dev); in get_dax_range()
656 device_unlock(dax_region->dev); in get_dax_range()
667 struct dax_region *dax_region = dev_dax->region; in put_dax_range() local
669 device_unlock(dax_region->dev); in put_dax_range()
743 struct dax_region *dax_region = dev_dax->region; in devm_register_dax_mapping() local
748 device_lock_assert(dax_region->dev); in devm_register_dax_mapping()
750 if (dev_WARN_ONCE(&dev_dax->dev, !dax_region->dev->driver, in devm_register_dax_mapping()
775 rc = devm_add_action_or_reset(dax_region->dev, unregister_dax_mapping, in devm_register_dax_mapping()
785 struct dax_region *dax_region = dev_dax->region; in alloc_dev_dax_range() local
786 struct resource *res = &dax_region->res; in alloc_dev_dax_range()
793 device_lock_assert(dax_region->dev); in alloc_dev_dax_range()
847 struct dax_region *dax_region = dev_dax->region; in adjust_dev_dax_range() local
853 device_lock_assert(dax_region->dev); in adjust_dev_dax_range()
899 struct dax_region *dax_region = dev_dax->region; in dev_dax_shrink() local
911 devm_release_action(dax_region->dev, in dev_dax_shrink()
920 for_each_dax_region_resource(dax_region, res) in dev_dax_shrink()
962 static ssize_t dev_dax_resize(struct dax_region *dax_region, in dev_dax_resize() argument
965 resource_size_t avail = dax_region_avail_size(dax_region), to_alloc; in dev_dax_resize()
967 struct resource *region_res = &dax_region->res; in dev_dax_resize()
995 return alloc_dev_dax_range(dev_dax, dax_region->res.start, to_alloc); in dev_dax_resize()
1002 if (res == first && res->start > dax_region->res.start) { in dev_dax_resize()
1003 alloc = min(res->start - dax_region->res.start, to_alloc); in dev_dax_resize()
1004 rc = alloc_dev_dax_range(dev_dax, dax_region->res.start, alloc); in dev_dax_resize()
1041 struct dax_region *dax_region = dev_dax->region; in size_store() local
1052 device_lock(dax_region->dev); in size_store()
1053 if (!dax_region->dev->driver) { in size_store()
1054 device_unlock(dax_region->dev); in size_store()
1058 rc = dev_dax_resize(dax_region, dev_dax, val); in size_store()
1060 device_unlock(dax_region->dev); in size_store()
1100 struct dax_region *dax_region = dev_dax->region; in mapping_store() local
1110 device_lock(dax_region->dev); in mapping_store()
1111 if (!dax_region->dev->driver) { in mapping_store()
1112 device_unlock(dax_region->dev); in mapping_store()
1121 device_unlock(dax_region->dev); in mapping_store()
1157 struct dax_region *dax_region = dev_dax->region; in align_store() local
1168 device_lock(dax_region->dev); in align_store()
1169 if (!dax_region->dev->driver) { in align_store()
1170 device_unlock(dax_region->dev); in align_store()
1187 device_unlock(dax_region->dev); in align_store()
1194 struct dax_region *dax_region = dev_dax->region; in dev_dax_target_node() local
1196 return dax_region->target_node; in dev_dax_target_node()
1212 struct dax_region *dax_region = dev_dax->region; in resource_show() local
1216 start = dax_region->res.start; in resource_show()
1246 struct dax_region *dax_region = dev_dax->region; in dev_dax_visible() local
1252 if (a == &dev_attr_mapping.attr && is_static(dax_region)) in dev_dax_visible()
1255 a == &dev_attr_size.attr) && is_static(dax_region)) in dev_dax_visible()
1284 struct dax_region *dax_region = dev_dax->region; in dev_dax_release() local
1289 dax_region_put(dax_region); in dev_dax_release()
1301 struct dax_region *dax_region = data->dax_region; in devm_create_dev_dax() local
1302 struct device *parent = dax_region->dev; in devm_create_dev_dax()
1313 if (is_static(dax_region)) { in devm_create_dev_dax()
1328 rc = ida_alloc(&dax_region->ida, GFP_KERNEL); in devm_create_dev_dax()
1334 dev_dax->region = dax_region; in devm_create_dev_dax()
1337 dev_set_name(dev, "dax%d.%d", dax_region->id, dev_dax->id); in devm_create_dev_dax()
1339 rc = alloc_dev_dax_range(dev_dax, dax_region->res.start, data->size); in devm_create_dev_dax()
1344 dev_WARN_ONCE(parent, !is_static(dax_region), in devm_create_dev_dax()
1372 dev_dax->target_node = dax_region->target_node; in devm_create_dev_dax()
1373 dev_dax->align = dax_region->align; in devm_create_dev_dax()
1375 kref_get(&dax_region->kref); in devm_create_dev_dax()
1390 rc = devm_add_action_or_reset(dax_region->dev, unregister_dev_dax, dev); in devm_create_dev_dax()