Lines Matching refs:nvdimm_bus
55 struct nvdimm_bus *nvdimm_bus = walk_to_nvdimm_bus(dev); in to_bus_provider() local
57 return nvdimm_bus->nd_desc->module; in to_bus_provider()
62 static void nvdimm_bus_probe_start(struct nvdimm_bus *nvdimm_bus) in nvdimm_bus_probe_start() argument
64 nvdimm_bus_lock(&nvdimm_bus->dev); in nvdimm_bus_probe_start()
65 nvdimm_bus->probe_active++; in nvdimm_bus_probe_start()
66 nvdimm_bus_unlock(&nvdimm_bus->dev); in nvdimm_bus_probe_start()
69 static void nvdimm_bus_probe_end(struct nvdimm_bus *nvdimm_bus) in nvdimm_bus_probe_end() argument
71 nvdimm_bus_lock(&nvdimm_bus->dev); in nvdimm_bus_probe_end()
72 if (--nvdimm_bus->probe_active == 0) in nvdimm_bus_probe_end()
73 wake_up(&nvdimm_bus->wait); in nvdimm_bus_probe_end()
74 nvdimm_bus_unlock(&nvdimm_bus->dev); in nvdimm_bus_probe_end()
81 struct nvdimm_bus *nvdimm_bus = walk_to_nvdimm_bus(dev); in nvdimm_bus_probe() local
87 dev_dbg(&nvdimm_bus->dev, "START: %s.probe(%s)\n", in nvdimm_bus_probe()
90 nvdimm_bus_probe_start(nvdimm_bus); in nvdimm_bus_probe()
95 nvdimm_bus_probe_end(nvdimm_bus); in nvdimm_bus_probe()
97 dev_dbg(&nvdimm_bus->dev, "END: %s.probe(%s) = %d\n", dev->driver->name, in nvdimm_bus_probe()
109 struct nvdimm_bus *nvdimm_bus = walk_to_nvdimm_bus(dev); in nvdimm_bus_remove() local
114 dev_dbg(&nvdimm_bus->dev, "%s.remove(%s)\n", dev->driver->name, in nvdimm_bus_remove()
121 struct nvdimm_bus *nvdimm_bus = walk_to_nvdimm_bus(dev); in nvdimm_bus_shutdown() local
129 dev_dbg(&nvdimm_bus->dev, "%s.shutdown(%s)\n", in nvdimm_bus_shutdown()
150 struct nvdimm_bus *nvdimm_bus = walk_to_nvdimm_bus(&nd_region->dev); in nvdimm_region_notify() local
152 if (!nvdimm_bus) in nvdimm_region_notify()
192 static void nvdimm_clear_badblocks_regions(struct nvdimm_bus *nvdimm_bus, in nvdimm_clear_badblocks_regions() argument
200 device_for_each_child(&nvdimm_bus->dev, &ctx, in nvdimm_clear_badblocks_regions()
204 static void nvdimm_account_cleared_poison(struct nvdimm_bus *nvdimm_bus, in nvdimm_account_cleared_poison() argument
208 badrange_forget(&nvdimm_bus->badrange, phys, cleared); in nvdimm_account_cleared_poison()
211 nvdimm_clear_badblocks_regions(nvdimm_bus, phys, cleared); in nvdimm_account_cleared_poison()
217 struct nvdimm_bus *nvdimm_bus = walk_to_nvdimm_bus(dev); in nvdimm_clear_poison() local
225 if (!nvdimm_bus) in nvdimm_clear_poison()
228 nd_desc = nvdimm_bus->nd_desc; in nvdimm_clear_poison()
266 nvdimm_account_cleared_poison(nvdimm_bus, phys, clear_err.cleared); in nvdimm_clear_poison()
285 struct nvdimm_bus *nvdimm_bus; in nvdimm_bus_release() local
287 nvdimm_bus = container_of(dev, struct nvdimm_bus, dev); in nvdimm_bus_release()
288 ida_simple_remove(&nd_ida, nvdimm_bus->id); in nvdimm_bus_release()
289 kfree(nvdimm_bus); in nvdimm_bus_release()
302 struct nvdimm_bus *walk_to_nvdimm_bus(struct device *nd_dev) in walk_to_nvdimm_bus()
315 struct nvdimm_bus *to_nvdimm_bus(struct device *dev) in to_nvdimm_bus()
317 struct nvdimm_bus *nvdimm_bus; in to_nvdimm_bus() local
319 nvdimm_bus = container_of(dev, struct nvdimm_bus, dev); in to_nvdimm_bus()
321 return nvdimm_bus; in to_nvdimm_bus()
325 struct nvdimm_bus *nvdimm_to_bus(struct nvdimm *nvdimm) in nvdimm_to_bus()
333 struct nvdimm_bus *nvdimm_bus_register(struct device *parent, in nvdimm_bus_register()
336 struct nvdimm_bus *nvdimm_bus; in nvdimm_bus_register() local
339 nvdimm_bus = kzalloc(sizeof(*nvdimm_bus), GFP_KERNEL); in nvdimm_bus_register()
340 if (!nvdimm_bus) in nvdimm_bus_register()
342 INIT_LIST_HEAD(&nvdimm_bus->list); in nvdimm_bus_register()
343 INIT_LIST_HEAD(&nvdimm_bus->mapping_list); in nvdimm_bus_register()
344 init_waitqueue_head(&nvdimm_bus->wait); in nvdimm_bus_register()
345 nvdimm_bus->id = ida_simple_get(&nd_ida, 0, 0, GFP_KERNEL); in nvdimm_bus_register()
346 if (nvdimm_bus->id < 0) { in nvdimm_bus_register()
347 kfree(nvdimm_bus); in nvdimm_bus_register()
350 mutex_init(&nvdimm_bus->reconfig_mutex); in nvdimm_bus_register()
351 badrange_init(&nvdimm_bus->badrange); in nvdimm_bus_register()
352 nvdimm_bus->nd_desc = nd_desc; in nvdimm_bus_register()
353 nvdimm_bus->dev.parent = parent; in nvdimm_bus_register()
354 nvdimm_bus->dev.type = &nvdimm_bus_dev_type; in nvdimm_bus_register()
355 nvdimm_bus->dev.groups = nd_desc->attr_groups; in nvdimm_bus_register()
356 nvdimm_bus->dev.bus = &nvdimm_bus_type; in nvdimm_bus_register()
357 nvdimm_bus->dev.of_node = nd_desc->of_node; in nvdimm_bus_register()
358 device_initialize(&nvdimm_bus->dev); in nvdimm_bus_register()
359 lockdep_set_class(&nvdimm_bus->dev.mutex, &nvdimm_bus_key); in nvdimm_bus_register()
360 device_set_pm_not_required(&nvdimm_bus->dev); in nvdimm_bus_register()
361 rc = dev_set_name(&nvdimm_bus->dev, "ndbus%d", nvdimm_bus->id); in nvdimm_bus_register()
365 rc = device_add(&nvdimm_bus->dev); in nvdimm_bus_register()
367 dev_dbg(&nvdimm_bus->dev, "registration failed: %d\n", rc); in nvdimm_bus_register()
371 return nvdimm_bus; in nvdimm_bus_register()
373 put_device(&nvdimm_bus->dev); in nvdimm_bus_register()
378 void nvdimm_bus_unregister(struct nvdimm_bus *nvdimm_bus) in nvdimm_bus_unregister() argument
380 if (!nvdimm_bus) in nvdimm_bus_unregister()
382 device_unregister(&nvdimm_bus->dev); in nvdimm_bus_unregister()
418 struct nvdimm_bus *nvdimm_bus = to_nvdimm_bus(dev); in nd_bus_remove() local
421 list_del_init(&nvdimm_bus->list); in nd_bus_remove()
424 wait_event(nvdimm_bus->wait, in nd_bus_remove()
425 atomic_read(&nvdimm_bus->ioctl_active) == 0); in nd_bus_remove()
428 device_for_each_child(&nvdimm_bus->dev, NULL, child_unregister); in nd_bus_remove()
430 spin_lock(&nvdimm_bus->badrange.lock); in nd_bus_remove()
431 free_badrange_list(&nvdimm_bus->badrange.list); in nd_bus_remove()
432 spin_unlock(&nvdimm_bus->badrange.lock); in nd_bus_remove()
434 nvdimm_bus_destroy_ndctl(nvdimm_bus); in nd_bus_remove()
439 struct nvdimm_bus *nvdimm_bus = to_nvdimm_bus(dev); in nd_bus_probe() local
442 rc = nvdimm_bus_create_ndctl(nvdimm_bus); in nd_bus_probe()
447 list_add_tail(&nvdimm_bus->list, &nvdimm_bus_list); in nd_bus_probe()
451 dev_set_drvdata(dev, nvdimm_bus->nd_desc); in nd_bus_probe()
720 int nvdimm_bus_create_ndctl(struct nvdimm_bus *nvdimm_bus) in nvdimm_bus_create_ndctl() argument
722 dev_t devt = MKDEV(nvdimm_bus_major, nvdimm_bus->id); in nvdimm_bus_create_ndctl()
733 dev->parent = &nvdimm_bus->dev; in nvdimm_bus_create_ndctl()
736 rc = dev_set_name(dev, "ndctl%d", nvdimm_bus->id); in nvdimm_bus_create_ndctl()
742 dev_dbg(&nvdimm_bus->dev, "failed to register ndctl%d: %d\n", in nvdimm_bus_create_ndctl()
743 nvdimm_bus->id, rc); in nvdimm_bus_create_ndctl()
753 void nvdimm_bus_destroy_ndctl(struct nvdimm_bus *nvdimm_bus) in nvdimm_bus_destroy_ndctl() argument
755 device_destroy(nd_class, MKDEV(nvdimm_bus_major, nvdimm_bus->id)); in nvdimm_bus_destroy_ndctl()
921 struct nvdimm_bus *nvdimm_bus = walk_to_nvdimm_bus(dev); in wait_nvdimm_bus_probe_idle() local
924 if (nvdimm_bus->probe_active == 0) in wait_nvdimm_bus_probe_idle()
928 wait_event(nvdimm_bus->wait, in wait_nvdimm_bus_probe_idle()
929 nvdimm_bus->probe_active == 0); in wait_nvdimm_bus_probe_idle()
982 static int nd_cmd_clear_to_send(struct nvdimm_bus *nvdimm_bus, in nd_cmd_clear_to_send() argument
985 struct nvdimm_bus_descriptor *nd_desc = nvdimm_bus->nd_desc; in nd_cmd_clear_to_send()
997 return device_for_each_child(&nvdimm_bus->dev, data, in nd_cmd_clear_to_send()
1004 wait_nvdimm_bus_probe_idle(&nvdimm_bus->dev); in nd_cmd_clear_to_send()
1010 static int __nd_ioctl(struct nvdimm_bus *nvdimm_bus, struct nvdimm *nvdimm, in __nd_ioctl() argument
1013 struct nvdimm_bus_descriptor *nd_desc = nvdimm_bus->nd_desc; in __nd_ioctl()
1016 struct device *dev = &nvdimm_bus->dev; in __nd_ioctl()
1166 rc = nd_cmd_clear_to_send(nvdimm_bus, nvdimm, func, buf); in __nd_ioctl()
1177 nvdimm_account_cleared_poison(nvdimm_bus, clear_err->address, in __nd_ioctl()
1216 struct nvdimm_bus *nvdimm_bus, *found = NULL; in nd_ioctl() local
1223 list_for_each_entry(nvdimm_bus, &nvdimm_bus_list, list) { in nd_ioctl()
1227 dev = device_find_child(&nvdimm_bus->dev, in nd_ioctl()
1232 found = nvdimm_bus; in nd_ioctl()
1233 } else if (nvdimm_bus->id == id) { in nd_ioctl()
1234 found = nvdimm_bus; in nd_ioctl()
1238 atomic_inc(&nvdimm_bus->ioctl_active); in nd_ioctl()
1247 nvdimm_bus = found; in nd_ioctl()
1248 rc = __nd_ioctl(nvdimm_bus, nvdimm, ro, cmd, arg); in nd_ioctl()
1252 if (atomic_dec_and_test(&nvdimm_bus->ioctl_active)) in nd_ioctl()
1253 wake_up(&nvdimm_bus->wait); in nd_ioctl()