Lines Matching refs:dax_region
176 static bool is_static(struct dax_region *dax_region) in is_static() argument
178 return (dax_region->res.flags & IORESOURCE_DAX_STATIC) != 0; in is_static()
204 struct dax_region *dax_region = dev_dax->region; in dax_bus_probe() local
219 if (rc || is_static(dax_region)) in dax_bus_probe()
226 if (dax_region->seed == dev) in dax_bus_probe()
227 dax_region->seed = NULL; in dax_bus_probe()
267 struct dax_region *dax_region = dev_get_drvdata(dev); in id_show() local
269 return sysfs_emit(buf, "%d\n", dax_region->id); in id_show()
276 struct dax_region *dax_region = dev_get_drvdata(dev); in region_size_show() local
279 (unsigned long long)resource_size(&dax_region->res)); in region_size_show()
287 struct dax_region *dax_region = dev_get_drvdata(dev); in region_align_show() local
289 return sysfs_emit(buf, "%u\n", dax_region->align); in region_align_show()
294 #define for_each_dax_region_resource(dax_region, res) \ argument
295 for (res = (dax_region)->res.child; res; res = res->sibling)
297 static unsigned long long dax_region_avail_size(struct dax_region *dax_region) in dax_region_avail_size() argument
299 resource_size_t size = resource_size(&dax_region->res); in dax_region_avail_size()
304 for_each_dax_region_resource(dax_region, res) in dax_region_avail_size()
312 struct dax_region *dax_region = dev_get_drvdata(dev); in available_size_show() local
319 size = dax_region_avail_size(dax_region); in available_size_show()
329 struct dax_region *dax_region = dev_get_drvdata(dev); in seed_show() local
333 if (is_static(dax_region)) in seed_show()
339 seed = dax_region->seed; in seed_show()
350 struct dax_region *dax_region = dev_get_drvdata(dev); in create_show() local
354 if (is_static(dax_region)) in create_show()
360 youngest = dax_region->youngest; in create_show()
372 struct dax_region *dax_region = dev_get_drvdata(dev); in create_store() local
377 if (is_static(dax_region)) in create_store()
389 avail = dax_region_avail_size(dax_region); in create_store()
394 .dax_region = dax_region, in create_store()
411 if (!dax_region->seed) in create_store()
412 dax_region->seed = &dev_dax->dev; in create_store()
413 dax_region->youngest = &dev_dax->dev; in create_store()
445 struct dax_region *dax_region = dev_dax->region; in trim_dev_dax_range() local
452 __release_region(&dax_region->res, range->start, range_len(range)); in trim_dev_dax_range()
481 struct dax_region *dax_region; in dax_region_free() local
483 dax_region = container_of(kref, struct dax_region, kref); in dax_region_free()
484 kfree(dax_region); in dax_region_free()
487 static void dax_region_put(struct dax_region *dax_region) in dax_region_put() argument
489 kref_put(&dax_region->kref, dax_region_free); in dax_region_put()
495 struct dax_region *dax_region; in __free_dev_dax_id() local
502 dax_region = dev_dax->region; in __free_dev_dax_id()
503 ida_free(&dax_region->ida, dev_dax->id); in __free_dev_dax_id()
504 dax_region_put(dax_region); in __free_dev_dax_id()
523 struct dax_region *dax_region = dev_dax->region; in alloc_dev_dax_id() local
526 id = ida_alloc(&dax_region->ida, GFP_KERNEL); in alloc_dev_dax_id()
529 kref_get(&dax_region->kref); in alloc_dev_dax_id()
538 struct dax_region *dax_region = dev_get_drvdata(dev); in delete_store() local
544 if (is_static(dax_region)) in delete_store()
547 victim = device_find_child_by_name(dax_region->dev, buf); in delete_store()
567 if (dax_region->seed == victim) in delete_store()
568 dax_region->seed = NULL; in delete_store()
569 if (dax_region->youngest == victim) in delete_store()
570 dax_region->youngest = NULL; in delete_store()
591 struct dax_region *dax_region = dev_get_drvdata(dev); in dax_region_visible() local
593 if (is_static(dax_region)) in dax_region_visible()
626 struct dax_region *dax_region = region; in dax_region_unregister() local
628 sysfs_remove_groups(&dax_region->dev->kobj, in dax_region_unregister()
630 dax_region_put(dax_region); in dax_region_unregister()
633 struct dax_region *alloc_dax_region(struct device *parent, int region_id, in alloc_dax_region()
637 struct dax_region *dax_region; in alloc_dax_region() local
653 dax_region = kzalloc(sizeof(*dax_region), GFP_KERNEL); in alloc_dax_region()
654 if (!dax_region) in alloc_dax_region()
657 dev_set_drvdata(parent, dax_region); in alloc_dax_region()
658 kref_init(&dax_region->kref); in alloc_dax_region()
659 dax_region->id = region_id; in alloc_dax_region()
660 dax_region->align = align; in alloc_dax_region()
661 dax_region->dev = parent; in alloc_dax_region()
662 dax_region->target_node = target_node; in alloc_dax_region()
663 ida_init(&dax_region->ida); in alloc_dax_region()
664 dax_region->res = (struct resource) { in alloc_dax_region()
671 kfree(dax_region); in alloc_dax_region()
675 if (devm_add_action_or_reset(parent, dax_region_unregister, dax_region)) in alloc_dax_region()
677 return dax_region; in alloc_dax_region()
799 struct dax_region *dax_region = dev_dax->region; in devm_register_dax_mapping() local
806 if (dev_WARN_ONCE(&dev_dax->dev, !dax_region->dev->driver, in devm_register_dax_mapping()
832 rc = devm_add_action_or_reset(dax_region->dev, unregister_dax_mapping, in devm_register_dax_mapping()
842 struct dax_region *dax_region = dev_dax->region; in alloc_dev_dax_range() local
843 struct resource *res = &dax_region->res; in alloc_dev_dax_range()
958 struct dax_region *dax_region = dev_dax->region; in dev_dax_shrink() local
970 devm_release_action(dax_region->dev, in dev_dax_shrink()
979 for_each_dax_region_resource(dax_region, res) in dev_dax_shrink()
1021 static ssize_t dev_dax_resize(struct dax_region *dax_region, in dev_dax_resize() argument
1024 resource_size_t avail = dax_region_avail_size(dax_region), to_alloc; in dev_dax_resize()
1026 struct resource *region_res = &dax_region->res; in dev_dax_resize()
1054 return alloc_dev_dax_range(dev_dax, dax_region->res.start, to_alloc); in dev_dax_resize()
1061 if (res == first && res->start > dax_region->res.start) { in dev_dax_resize()
1062 alloc = min(res->start - dax_region->res.start, to_alloc); in dev_dax_resize()
1063 rc = alloc_dev_dax_range(dev_dax, dax_region->res.start, alloc); in dev_dax_resize()
1100 struct dax_region *dax_region = dev_dax->region; in size_store() local
1114 if (!dax_region->dev->driver) { in size_store()
1122 rc = dev_dax_resize(dax_region, dev_dax, val); in size_store()
1169 struct dax_region *dax_region = dev_dax->region; in mapping_store() local
1181 if (!dax_region->dev->driver) { in mapping_store()
1231 struct dax_region *dax_region = dev_dax->region; in align_store() local
1245 if (!dax_region->dev->driver) { in align_store()
1274 struct dax_region *dax_region = dev_dax->region; in dev_dax_target_node() local
1276 return dax_region->target_node; in dev_dax_target_node()
1292 struct dax_region *dax_region = dev_dax->region; in resource_show() local
1296 start = dax_region->res.start; in resource_show()
1368 struct dax_region *dax_region = dev_dax->region; in dev_dax_visible() local
1374 if (a == &dev_attr_mapping.attr && is_static(dax_region)) in dev_dax_visible()
1377 a == &dev_attr_size.attr) && is_static(dax_region)) in dev_dax_visible()
1422 struct dax_region *dax_region = data->dax_region; in __devm_create_dev_dax() local
1423 struct device *parent = dax_region->dev; in __devm_create_dev_dax()
1434 dev_dax->region = dax_region; in __devm_create_dev_dax()
1435 if (is_static(dax_region)) { in __devm_create_dev_dax()
1457 dev_set_name(dev, "dax%d.%d", dax_region->id, dev_dax->id); in __devm_create_dev_dax()
1459 rc = alloc_dev_dax_range(dev_dax, dax_region->res.start, data->size); in __devm_create_dev_dax()
1464 dev_WARN_ONCE(parent, !is_static(dax_region), in __devm_create_dev_dax()
1492 dev_dax->target_node = dax_region->target_node; in __devm_create_dev_dax()
1493 dev_dax->align = dax_region->align; in __devm_create_dev_dax()
1511 rc = devm_add_action_or_reset(dax_region->dev, unregister_dev_dax, dev); in __devm_create_dev_dax()