Lines Matching refs:cxlr

41 	struct cxl_region *cxlr = to_cxl_region(dev);  in uuid_show()  local
42 struct cxl_region_params *p = &cxlr->params; in uuid_show()
57 struct cxl_region *cxlr; in is_dup() local
64 cxlr = to_cxl_region(match); in is_dup()
65 p = &cxlr->params; in is_dup()
78 struct cxl_region *cxlr = to_cxl_region(dev); in uuid_store() local
79 struct cxl_region_params *p = &cxlr->params; in uuid_store()
119 struct cxl_region *cxlr) in cxl_rr_load() argument
121 return xa_load(&port->regions, (unsigned long)cxlr); in cxl_rr_load()
124 static int cxl_region_decode_reset(struct cxl_region *cxlr, int count) in cxl_region_decode_reset() argument
126 struct cxl_region_params *p = &cxlr->params; in cxl_region_decode_reset()
144 cxl_rr = cxl_rr_load(iter, cxlr); in cxl_region_decode_reset()
159 static int cxl_region_decode_commit(struct cxl_region *cxlr) in cxl_region_decode_commit() argument
161 struct cxl_region_params *p = &cxlr->params; in cxl_region_decode_commit()
175 cxl_rr = cxl_rr_load(iter, cxlr); in cxl_region_decode_commit()
187 cxl_rr = cxl_rr_load(iter, cxlr); in cxl_region_decode_commit()
201 cxl_region_decode_reset(cxlr, i); in cxl_region_decode_commit()
208 struct cxl_region *cxlr = to_cxl_region(dev); in commit_store() local
209 struct cxl_region_params *p = &cxlr->params; in commit_store()
234 rc = cxl_region_decode_commit(cxlr); in commit_store()
238 device_release_driver(&cxlr->dev); in commit_store()
246 rc = cxl_region_decode_reset(cxlr, p->interleave_ways); in commit_store()
268 struct cxl_region *cxlr = to_cxl_region(dev); in commit_show() local
269 struct cxl_region_params *p = &cxlr->params; in commit_show()
286 struct cxl_region *cxlr = to_cxl_region(dev); in cxl_region_visible() local
288 if (a == &dev_attr_uuid.attr && cxlr->mode != CXL_DECODER_PMEM) in cxl_region_visible()
296 struct cxl_region *cxlr = to_cxl_region(dev); in interleave_ways_show() local
297 struct cxl_region_params *p = &cxlr->params; in interleave_ways_show()
317 struct cxl_region *cxlr = to_cxl_region(dev); in interleave_ways_store() local
318 struct cxl_region_params *p = &cxlr->params; in interleave_ways_store()
337 dev_dbg(&cxlr->dev, "invalid interleave: %d\n", val); in interleave_ways_store()
351 rc = sysfs_update_group(&cxlr->dev.kobj, get_cxl_region_target_group()); in interleave_ways_store()
366 struct cxl_region *cxlr = to_cxl_region(dev); in interleave_granularity_show() local
367 struct cxl_region_params *p = &cxlr->params; in interleave_granularity_show()
385 struct cxl_region *cxlr = to_cxl_region(dev); in interleave_granularity_store() local
386 struct cxl_region_params *p = &cxlr->params; in interleave_granularity_store()
429 struct cxl_region *cxlr = to_cxl_region(dev); in resource_show() local
430 struct cxl_region_params *p = &cxlr->params; in resource_show()
446 static int alloc_hpa(struct cxl_region *cxlr, resource_size_t size) in alloc_hpa() argument
448 struct cxl_root_decoder *cxlrd = to_cxl_root_decoder(cxlr->dev.parent); in alloc_hpa()
449 struct cxl_region_params *p = &cxlr->params; in alloc_hpa()
468 (cxlr->mode == CXL_DECODER_PMEM && uuid_is_null(&p->uuid))) in alloc_hpa()
476 dev_name(&cxlr->dev)); in alloc_hpa()
478 dev_dbg(&cxlr->dev, "failed to allocate HPA: %ld\n", in alloc_hpa()
489 static void cxl_region_iomem_release(struct cxl_region *cxlr) in cxl_region_iomem_release() argument
491 struct cxl_region_params *p = &cxlr->params; in cxl_region_iomem_release()
493 if (device_is_registered(&cxlr->dev)) in cxl_region_iomem_release()
502 static int free_hpa(struct cxl_region *cxlr) in free_hpa() argument
504 struct cxl_region_params *p = &cxlr->params; in free_hpa()
514 cxl_region_iomem_release(cxlr); in free_hpa()
522 struct cxl_region *cxlr = to_cxl_region(dev); in size_store() local
535 rc = alloc_hpa(cxlr, val); in size_store()
537 rc = free_hpa(cxlr); in size_store()
549 struct cxl_region *cxlr = to_cxl_region(dev); in size_show() local
550 struct cxl_region_params *p = &cxlr->params; in size_show()
581 static size_t show_targetN(struct cxl_region *cxlr, char *buf, int pos) in show_targetN() argument
583 struct cxl_region_params *p = &cxlr->params; in show_targetN()
592 dev_dbg(&cxlr->dev, "position %d out of range %d\n", pos, in show_targetN()
632 struct cxl_region *cxlr) in cxl_region_find_decoder() argument
651 struct cxl_region *cxlr) in alloc_region_ref() argument
653 struct cxl_region_params *p = &cxlr->params; in alloc_region_ref()
665 dev_dbg(&cxlr->dev, in alloc_region_ref()
677 cxl_rr->region = cxlr; in alloc_region_ref()
681 rc = xa_insert(&port->regions, (unsigned long)cxlr, cxl_rr, GFP_KERNEL); in alloc_region_ref()
683 dev_dbg(&cxlr->dev, in alloc_region_ref()
695 struct cxl_region *cxlr = cxl_rr->region; in cxl_rr_free_decoder() local
701 dev_WARN_ONCE(&cxlr->dev, cxld->region != cxlr, "region mismatch\n"); in cxl_rr_free_decoder()
702 if (cxld->region == cxlr) { in cxl_rr_free_decoder()
704 put_device(&cxlr->dev); in cxl_rr_free_decoder()
711 struct cxl_region *cxlr = cxl_rr->region; in free_region_ref() local
714 xa_erase(&port->regions, (unsigned long)cxlr); in free_region_ref()
724 struct cxl_region *cxlr = cxl_rr->region; in cxl_rr_ep_add() local
737 cxld->region = cxlr; in cxl_rr_ep_add()
738 get_device(&cxlr->dev); in cxl_rr_ep_add()
744 static int cxl_rr_alloc_decoder(struct cxl_port *port, struct cxl_region *cxlr, in cxl_rr_alloc_decoder() argument
753 cxld = cxl_region_find_decoder(port, cxlr); in cxl_rr_alloc_decoder()
755 dev_dbg(&cxlr->dev, "%s: no decoder available\n", in cxl_rr_alloc_decoder()
761 dev_dbg(&cxlr->dev, "%s: %s already attached to %s\n", in cxl_rr_alloc_decoder()
796 struct cxl_region *cxlr, in cxl_port_attach_region() argument
809 cxl_rr = cxl_rr_load(port, cxlr); in cxl_port_attach_region()
838 cxl_rr = alloc_region_ref(port, cxlr); in cxl_port_attach_region()
840 dev_dbg(&cxlr->dev, in cxl_port_attach_region()
847 rc = cxl_rr_alloc_decoder(port, cxlr, cxled, cxl_rr); in cxl_port_attach_region()
855 dev_dbg(&cxlr->dev, in cxl_port_attach_region()
862 dev_dbg(&cxlr->dev, in cxl_port_attach_region()
882 struct cxl_region *cxlr, in cxl_port_detach_region() argument
890 cxl_rr = cxl_rr_load(port, cxlr); in cxl_port_detach_region()
927 struct cxl_region *cxlr = cxl_rr->region; in check_last_peer() local
928 struct cxl_region_params *p = &cxlr->params; in check_last_peer()
941 dev_dbg(&cxlr->dev, "%s:%s: cannot host %s:%s at %d\n", in check_last_peer()
950 dev_dbg(&cxlr->dev, in check_last_peer()
963 struct cxl_region *cxlr, in cxl_port_setup_targets() argument
966 struct cxl_root_decoder *cxlrd = to_cxl_root_decoder(cxlr->dev.parent); in cxl_port_setup_targets()
969 struct cxl_region_ref *cxl_rr = cxl_rr_load(port, cxlr); in cxl_port_setup_targets()
972 struct cxl_region_params *p = &cxlr->params; in cxl_port_setup_targets()
983 dev_dbg(&cxlr->dev, "%s:%s: invalid target count %d\n", in cxl_port_setup_targets()
1025 parent_rr = cxl_rr_load(parent_port, cxlr); in cxl_port_setup_targets()
1033 dev_dbg(&cxlr->dev, "%s:%s: invalid parent granularity: %d\n", in cxl_port_setup_targets()
1041 dev_dbg(&cxlr->dev, "%s:%s: invalid parent interleave: %d\n", in cxl_port_setup_targets()
1050 dev_dbg(&cxlr->dev, "%s:%s: invalid port interleave: %d\n", in cxl_port_setup_targets()
1070 dev_dbg(&cxlr->dev, "%s:%s: invalid interleave: %d\n", in cxl_port_setup_targets()
1082 dev_dbg(&cxlr->dev, "%s:%s iw: %d ig: %d\n", dev_name(port->uport), in cxl_port_setup_targets()
1086 dev_dbg(&cxlr->dev, in cxl_port_setup_targets()
1096 dev_dbg(&cxlr->dev, "%s:%s target[%d] = %s for %s:%s @ %d\n", in cxl_port_setup_targets()
1105 struct cxl_region *cxlr) in cxl_port_reset_targets() argument
1107 struct cxl_region_ref *cxl_rr = cxl_rr_load(port, cxlr); in cxl_port_reset_targets()
1125 static void cxl_region_teardown_targets(struct cxl_region *cxlr) in cxl_region_teardown_targets() argument
1127 struct cxl_region_params *p = &cxlr->params; in cxl_region_teardown_targets()
1144 cxl_port_reset_targets(iter, cxlr); in cxl_region_teardown_targets()
1148 static int cxl_region_setup_targets(struct cxl_region *cxlr) in cxl_region_setup_targets() argument
1150 struct cxl_region_params *p = &cxlr->params; in cxl_region_setup_targets()
1171 rc = cxl_port_setup_targets(iter, cxlr, cxled); in cxl_region_setup_targets()
1173 cxl_region_teardown_targets(cxlr); in cxl_region_setup_targets()
1182 static int cxl_region_attach(struct cxl_region *cxlr, in cxl_region_attach() argument
1185 struct cxl_root_decoder *cxlrd = to_cxl_root_decoder(cxlr->dev.parent); in cxl_region_attach()
1188 struct cxl_region_params *p = &cxlr->params; in cxl_region_attach()
1193 dev_dbg(&cxlr->dev, "%s dead\n", dev_name(&cxled->cxld.dev)); in cxl_region_attach()
1199 dev_dbg(&cxlr->dev, "region already active\n"); in cxl_region_attach()
1202 dev_dbg(&cxlr->dev, "interleave config missing\n"); in cxl_region_attach()
1207 dev_dbg(&cxlr->dev, "position %d out of range %d\n", pos, in cxl_region_attach()
1219 dev_dbg(&cxlr->dev, "position %d already assigned to %s:%s\n", in cxl_region_attach()
1235 dev_dbg(&cxlr->dev, in cxl_region_attach()
1247 dev_dbg(&cxlr->dev, "%s:%s invalid target for %s\n", in cxl_region_attach()
1249 dev_name(cxlr->dev.parent)); in cxl_region_attach()
1254 dev_dbg(&cxlr->dev, "%s:%s invalid target position for %s\n", in cxl_region_attach()
1260 if (cxled->cxld.target_type != cxlr->type) { in cxl_region_attach()
1261 dev_dbg(&cxlr->dev, "%s:%s type mismatch: %d vs %d\n", in cxl_region_attach()
1263 cxled->cxld.target_type, cxlr->type); in cxl_region_attach()
1268 dev_dbg(&cxlr->dev, "%s:%s: missing DPA allocation.\n", in cxl_region_attach()
1275 dev_dbg(&cxlr->dev, in cxl_region_attach()
1285 rc = cxl_port_attach_region(iter, cxlr, cxled, pos); in cxl_region_attach()
1295 rc = cxl_region_setup_targets(cxlr); in cxl_region_attach()
1315 cxl_port_detach_region(iter, cxlr, cxled); in cxl_region_attach()
1322 struct cxl_region *cxlr = cxled->cxld.region; in cxl_region_detach() local
1328 if (!cxlr) in cxl_region_detach()
1331 p = &cxlr->params; in cxl_region_detach()
1332 get_device(&cxlr->dev); in cxl_region_detach()
1339 rc = cxl_region_decode_reset(cxlr, p->interleave_ways); in cxl_region_detach()
1347 cxl_port_detach_region(iter, cxlr, cxled); in cxl_region_detach()
1353 dev_WARN_ONCE(&cxlr->dev, 1, "expected %s:%s at position %d\n", in cxl_region_detach()
1361 cxl_region_teardown_targets(cxlr); in cxl_region_detach()
1372 device_release_driver(&cxlr->dev); in cxl_region_detach()
1375 put_device(&cxlr->dev); in cxl_region_detach()
1387 static int attach_target(struct cxl_region *cxlr, const char *decoder, int pos) in attach_target() argument
1405 rc = cxl_region_attach(cxlr, to_cxl_endpoint_decoder(dev), pos); in attach_target()
1413 static int detach_target(struct cxl_region *cxlr, int pos) in detach_target() argument
1415 struct cxl_region_params *p = &cxlr->params; in detach_target()
1423 dev_dbg(&cxlr->dev, "position %d out of range %d\n", pos, in detach_target()
1440 static size_t store_targetN(struct cxl_region *cxlr, const char *buf, int pos, in store_targetN() argument
1446 rc = detach_target(cxlr, pos); in store_targetN()
1448 rc = attach_target(cxlr, buf, pos); in store_targetN()
1510 struct cxl_region *cxlr = to_cxl_region(dev); in cxl_region_target_visible() local
1511 struct cxl_region_params *p = &cxlr->params; in cxl_region_target_visible()
1538 struct cxl_region *cxlr = to_cxl_region(dev); in cxl_region_release() local
1546 if (cxlr->id < id) in cxl_region_release()
1547 if (atomic_try_cmpxchg(&cxlrd->region_id, &id, cxlr->id)) { in cxl_region_release()
1552 memregion_free(cxlr->id); in cxl_region_release()
1555 kfree(cxlr); in cxl_region_release()
1581 struct cxl_region *cxlr = to_cxl_region(dev); in unregister_region() local
1582 struct cxl_region_params *p = &cxlr->params; in unregister_region()
1593 detach_target(cxlr, i); in unregister_region()
1595 cxl_region_iomem_release(cxlr); in unregister_region()
1603 struct cxl_region *cxlr; in cxl_region_alloc() local
1606 cxlr = kzalloc(sizeof(*cxlr), GFP_KERNEL); in cxl_region_alloc()
1607 if (!cxlr) { in cxl_region_alloc()
1612 dev = &cxlr->dev; in cxl_region_alloc()
1624 cxlr->id = id; in cxl_region_alloc()
1626 return cxlr; in cxl_region_alloc()
1648 struct cxl_region *cxlr; in devm_cxl_add_region() local
1652 cxlr = cxl_region_alloc(cxlrd, id); in devm_cxl_add_region()
1653 if (IS_ERR(cxlr)) in devm_cxl_add_region()
1654 return cxlr; in devm_cxl_add_region()
1655 cxlr->mode = mode; in devm_cxl_add_region()
1656 cxlr->type = type; in devm_cxl_add_region()
1658 dev = &cxlr->dev; in devm_cxl_add_region()
1667 rc = devm_add_action_or_reset(port->uport, unregister_region, cxlr); in devm_cxl_add_region()
1673 return cxlr; in devm_cxl_add_region()
1693 struct cxl_region *cxlr; in create_pmem_region_store() local
1709 cxlr = devm_cxl_add_region(cxlrd, id, CXL_DECODER_PMEM, in create_pmem_region_store()
1711 if (IS_ERR(cxlr)) in create_pmem_region_store()
1712 return PTR_ERR(cxlr); in create_pmem_region_store()
1757 struct cxl_region *cxlr; in delete_region_store() local
1759 cxlr = cxl_find_region_by_name(cxlrd, buf); in delete_region_store()
1760 if (IS_ERR(cxlr)) in delete_region_store()
1761 return PTR_ERR(cxlr); in delete_region_store()
1763 devm_release_action(port->uport, unregister_region, cxlr); in delete_region_store()
1764 put_device(&cxlr->dev); in delete_region_store()
1812 static struct cxl_pmem_region *cxl_pmem_region_alloc(struct cxl_region *cxlr) in cxl_pmem_region_alloc() argument
1814 struct cxl_region_params *p = &cxlr->params; in cxl_pmem_region_alloc()
1850 cxlr_pmem->cxlr = cxlr; in cxl_pmem_region_alloc()
1854 dev->parent = &cxlr->dev; in cxl_pmem_region_alloc()
1874 static int devm_cxl_add_pmem_region(struct cxl_region *cxlr) in devm_cxl_add_pmem_region() argument
1880 cxlr_pmem = cxl_pmem_region_alloc(cxlr); in devm_cxl_add_pmem_region()
1885 rc = dev_set_name(dev, "pmem_region%d", cxlr->id); in devm_cxl_add_pmem_region()
1893 dev_dbg(&cxlr->dev, "%s: register %s\n", dev_name(dev->parent), in devm_cxl_add_pmem_region()
1896 return devm_add_action_or_reset(&cxlr->dev, cxlr_pmem_unregister, dev); in devm_cxl_add_pmem_region()
1905 struct cxl_region *cxlr = to_cxl_region(dev); in cxl_region_probe() local
1906 struct cxl_region_params *p = &cxlr->params; in cxl_region_probe()
1911 dev_dbg(&cxlr->dev, "probe interrupted\n"); in cxl_region_probe()
1916 dev_dbg(&cxlr->dev, "config state: %d\n", p->state); in cxl_region_probe()
1926 switch (cxlr->mode) { in cxl_region_probe()
1928 return devm_cxl_add_pmem_region(cxlr); in cxl_region_probe()
1930 dev_dbg(&cxlr->dev, "unsupported region mode: %d\n", in cxl_region_probe()
1931 cxlr->mode); in cxl_region_probe()