Lines Matching refs:cxl_rr
176 struct cxl_region_ref *cxl_rr; in cxl_region_decode_reset() local
179 cxl_rr = cxl_rr_load(iter, cxlr); in cxl_region_decode_reset()
180 cxld = cxl_rr->decoder; in cxl_region_decode_reset()
225 struct cxl_region_ref *cxl_rr; in cxl_region_decode_commit() local
233 cxl_rr = cxl_rr_load(iter, cxlr); in cxl_region_decode_commit()
234 cxld = cxl_rr->decoder; in cxl_region_decode_commit()
244 cxl_rr = cxl_rr_load(iter, cxlr); in cxl_region_decode_commit()
245 cxld = cxl_rr->decoder; in cxl_region_decode_commit()
765 struct cxl_region_ref *cxl_rr, *iter; in alloc_region_ref() local
784 cxl_rr = kzalloc(sizeof(*cxl_rr), GFP_KERNEL); in alloc_region_ref()
785 if (!cxl_rr) in alloc_region_ref()
787 cxl_rr->port = port; in alloc_region_ref()
788 cxl_rr->region = cxlr; in alloc_region_ref()
789 cxl_rr->nr_targets = 1; in alloc_region_ref()
790 xa_init(&cxl_rr->endpoints); in alloc_region_ref()
792 rc = xa_insert(&port->regions, (unsigned long)cxlr, cxl_rr, GFP_KERNEL); in alloc_region_ref()
797 kfree(cxl_rr); in alloc_region_ref()
801 return cxl_rr; in alloc_region_ref()
804 static void cxl_rr_free_decoder(struct cxl_region_ref *cxl_rr) in cxl_rr_free_decoder() argument
806 struct cxl_region *cxlr = cxl_rr->region; in cxl_rr_free_decoder()
807 struct cxl_decoder *cxld = cxl_rr->decoder; in cxl_rr_free_decoder()
819 static void free_region_ref(struct cxl_region_ref *cxl_rr) in free_region_ref() argument
821 struct cxl_port *port = cxl_rr->port; in free_region_ref()
822 struct cxl_region *cxlr = cxl_rr->region; in free_region_ref()
824 cxl_rr_free_decoder(cxl_rr); in free_region_ref()
826 xa_destroy(&cxl_rr->endpoints); in free_region_ref()
827 kfree(cxl_rr); in free_region_ref()
830 static int cxl_rr_ep_add(struct cxl_region_ref *cxl_rr, in cxl_rr_ep_add() argument
834 struct cxl_port *port = cxl_rr->port; in cxl_rr_ep_add()
835 struct cxl_region *cxlr = cxl_rr->region; in cxl_rr_ep_add()
836 struct cxl_decoder *cxld = cxl_rr->decoder; in cxl_rr_ep_add()
840 rc = xa_insert(&cxl_rr->endpoints, (unsigned long)cxled, ep, in cxl_rr_ep_add()
845 cxl_rr->nr_eps++; in cxl_rr_ep_add()
857 struct cxl_region_ref *cxl_rr) in cxl_rr_alloc_decoder() argument
890 cxl_rr->decoder = cxld; in cxl_rr_alloc_decoder()
924 struct cxl_region_ref *cxl_rr; in cxl_port_attach_region() local
932 cxl_rr = cxl_rr_load(port, cxlr); in cxl_port_attach_region()
933 if (cxl_rr) { in cxl_port_attach_region()
943 xa_for_each(&cxl_rr->endpoints, index, ep_iter) { in cxl_port_attach_region()
957 cxl_rr->nr_targets++; in cxl_port_attach_region()
961 cxl_rr = alloc_region_ref(port, cxlr); in cxl_port_attach_region()
962 if (IS_ERR(cxl_rr)) { in cxl_port_attach_region()
966 return PTR_ERR(cxl_rr); in cxl_port_attach_region()
970 rc = cxl_rr_alloc_decoder(port, cxlr, cxled, cxl_rr); in cxl_port_attach_region()
974 cxld = cxl_rr->decoder; in cxl_port_attach_region()
976 rc = cxl_rr_ep_add(cxl_rr, cxled); in cxl_port_attach_region()
993 cxl_rr->nr_eps, cxl_rr->nr_targets); in cxl_port_attach_region()
998 cxl_rr->nr_targets--; in cxl_port_attach_region()
999 if (cxl_rr->nr_eps == 0) in cxl_port_attach_region()
1000 free_region_ref(cxl_rr); in cxl_port_attach_region()
1008 struct cxl_region_ref *cxl_rr; in cxl_port_detach_region() local
1013 cxl_rr = cxl_rr_load(port, cxlr); in cxl_port_detach_region()
1014 if (!cxl_rr) in cxl_port_detach_region()
1021 if (cxl_rr->decoder == &cxled->cxld) in cxl_port_detach_region()
1022 cxl_rr->nr_eps--; in cxl_port_detach_region()
1024 ep = xa_erase(&cxl_rr->endpoints, (unsigned long)cxled); in cxl_port_detach_region()
1030 cxl_rr->nr_eps--; in cxl_port_detach_region()
1031 xa_for_each(&cxl_rr->endpoints, index, ep_iter) { in cxl_port_detach_region()
1038 cxl_rr->nr_targets--; in cxl_port_detach_region()
1041 if (cxl_rr->nr_eps == 0) in cxl_port_detach_region()
1042 free_region_ref(cxl_rr); in cxl_port_detach_region()
1046 struct cxl_ep *ep, struct cxl_region_ref *cxl_rr, in check_last_peer() argument
1050 struct cxl_region *cxlr = cxl_rr->region; in check_last_peer()
1053 struct cxl_port *port = cxl_rr->port; in check_last_peer()
1092 struct cxl_region_ref *cxl_rr = cxl_rr_load(port, cxlr); in cxl_port_setup_targets() local
1096 struct cxl_decoder *cxld = cxl_rr->decoder; in cxl_port_setup_targets()
1105 if (!is_power_of_2(cxl_rr->nr_targets)) { in cxl_port_setup_targets()
1108 cxl_rr->nr_targets); in cxl_port_setup_targets()
1113 if (cxl_rr->nr_targets_set) { in cxl_port_setup_targets()
1120 if (cxl_rr->nr_targets == 1) in cxl_port_setup_targets()
1123 distance = p->nr_targets / cxl_rr->nr_targets; in cxl_port_setup_targets()
1124 for (i = 0; i < cxl_rr->nr_targets_set; i++) in cxl_port_setup_targets()
1126 rc = check_last_peer(cxled, ep, cxl_rr, in cxl_port_setup_targets()
1170 iw = cxl_rr->nr_targets; in cxl_port_setup_targets()
1230 if (cxl_rr->nr_targets_set == cxl_rr->nr_targets) { in cxl_port_setup_targets()
1238 if (cxlsd->target[cxl_rr->nr_targets_set] != ep->dport) { in cxl_port_setup_targets()
1243 cxl_rr->nr_targets_set); in cxl_port_setup_targets()
1247 cxlsd->target[cxl_rr->nr_targets_set] = ep->dport; in cxl_port_setup_targets()
1250 cxl_rr->nr_targets_set += inc; in cxl_port_setup_targets()
1253 cxl_rr->nr_targets_set - 1, dev_name(ep->dport->dport_dev), in cxl_port_setup_targets()
1262 struct cxl_region_ref *cxl_rr = cxl_rr_load(port, cxlr); in cxl_port_reset_targets() local
1269 if (!cxl_rr) in cxl_port_reset_targets()
1271 cxl_rr->nr_targets_set = 0; in cxl_port_reset_targets()
1273 cxld = cxl_rr->decoder; in cxl_port_reset_targets()