Lines Matching refs:cxl_rr
141 struct cxl_region_ref *cxl_rr; in cxl_region_decode_reset() local
144 cxl_rr = cxl_rr_load(iter, cxlr); in cxl_region_decode_reset()
145 cxld = cxl_rr->decoder; in cxl_region_decode_reset()
167 struct cxl_region_ref *cxl_rr; in cxl_region_decode_commit() local
175 cxl_rr = cxl_rr_load(iter, cxlr); in cxl_region_decode_commit()
176 cxld = cxl_rr->decoder; in cxl_region_decode_commit()
187 cxl_rr = cxl_rr_load(iter, cxlr); in cxl_region_decode_commit()
188 cxld = cxl_rr->decoder; in cxl_region_decode_commit()
654 struct cxl_region_ref *cxl_rr, *iter; in alloc_region_ref() local
673 cxl_rr = kzalloc(sizeof(*cxl_rr), GFP_KERNEL); in alloc_region_ref()
674 if (!cxl_rr) in alloc_region_ref()
676 cxl_rr->port = port; in alloc_region_ref()
677 cxl_rr->region = cxlr; in alloc_region_ref()
678 cxl_rr->nr_targets = 1; in alloc_region_ref()
679 xa_init(&cxl_rr->endpoints); in alloc_region_ref()
681 rc = xa_insert(&port->regions, (unsigned long)cxlr, cxl_rr, GFP_KERNEL); in alloc_region_ref()
686 kfree(cxl_rr); in alloc_region_ref()
690 return cxl_rr; in alloc_region_ref()
693 static void cxl_rr_free_decoder(struct cxl_region_ref *cxl_rr) in cxl_rr_free_decoder() argument
695 struct cxl_region *cxlr = cxl_rr->region; in cxl_rr_free_decoder()
696 struct cxl_decoder *cxld = cxl_rr->decoder; in cxl_rr_free_decoder()
708 static void free_region_ref(struct cxl_region_ref *cxl_rr) in free_region_ref() argument
710 struct cxl_port *port = cxl_rr->port; in free_region_ref()
711 struct cxl_region *cxlr = cxl_rr->region; in free_region_ref()
713 cxl_rr_free_decoder(cxl_rr); in free_region_ref()
715 xa_destroy(&cxl_rr->endpoints); in free_region_ref()
716 kfree(cxl_rr); in free_region_ref()
719 static int cxl_rr_ep_add(struct cxl_region_ref *cxl_rr, in cxl_rr_ep_add() argument
723 struct cxl_port *port = cxl_rr->port; in cxl_rr_ep_add()
724 struct cxl_region *cxlr = cxl_rr->region; in cxl_rr_ep_add()
725 struct cxl_decoder *cxld = cxl_rr->decoder; in cxl_rr_ep_add()
729 rc = xa_insert(&cxl_rr->endpoints, (unsigned long)cxled, ep, in cxl_rr_ep_add()
734 cxl_rr->nr_eps++; in cxl_rr_ep_add()
746 struct cxl_region_ref *cxl_rr) in cxl_rr_alloc_decoder() argument
767 cxl_rr->decoder = cxld; in cxl_rr_alloc_decoder()
801 struct cxl_region_ref *cxl_rr; in cxl_port_attach_region() local
809 cxl_rr = cxl_rr_load(port, cxlr); in cxl_port_attach_region()
810 if (cxl_rr) { in cxl_port_attach_region()
820 xa_for_each(&cxl_rr->endpoints, index, ep_iter) { in cxl_port_attach_region()
834 cxl_rr->nr_targets++; in cxl_port_attach_region()
838 cxl_rr = alloc_region_ref(port, cxlr); in cxl_port_attach_region()
839 if (IS_ERR(cxl_rr)) { in cxl_port_attach_region()
843 return PTR_ERR(cxl_rr); in cxl_port_attach_region()
847 rc = cxl_rr_alloc_decoder(port, cxlr, cxled, cxl_rr); in cxl_port_attach_region()
851 cxld = cxl_rr->decoder; in cxl_port_attach_region()
853 rc = cxl_rr_ep_add(cxl_rr, cxled); in cxl_port_attach_region()
870 cxl_rr->nr_eps, cxl_rr->nr_targets); in cxl_port_attach_region()
875 cxl_rr->nr_targets--; in cxl_port_attach_region()
876 if (cxl_rr->nr_eps == 0) in cxl_port_attach_region()
877 free_region_ref(cxl_rr); in cxl_port_attach_region()
885 struct cxl_region_ref *cxl_rr; in cxl_port_detach_region() local
890 cxl_rr = cxl_rr_load(port, cxlr); in cxl_port_detach_region()
891 if (!cxl_rr) in cxl_port_detach_region()
898 if (cxl_rr->decoder == &cxled->cxld) in cxl_port_detach_region()
899 cxl_rr->nr_eps--; in cxl_port_detach_region()
901 ep = xa_erase(&cxl_rr->endpoints, (unsigned long)cxled); in cxl_port_detach_region()
907 cxl_rr->nr_eps--; in cxl_port_detach_region()
908 xa_for_each(&cxl_rr->endpoints, index, ep_iter) { in cxl_port_detach_region()
915 cxl_rr->nr_targets--; in cxl_port_detach_region()
918 if (cxl_rr->nr_eps == 0) in cxl_port_detach_region()
919 free_region_ref(cxl_rr); in cxl_port_detach_region()
923 struct cxl_ep *ep, struct cxl_region_ref *cxl_rr, in check_last_peer() argument
927 struct cxl_region *cxlr = cxl_rr->region; in check_last_peer()
930 struct cxl_port *port = cxl_rr->port; in check_last_peer()
969 struct cxl_region_ref *cxl_rr = cxl_rr_load(port, cxlr); in cxl_port_setup_targets() local
973 struct cxl_decoder *cxld = cxl_rr->decoder; in cxl_port_setup_targets()
982 if (!is_power_of_2(cxl_rr->nr_targets)) { in cxl_port_setup_targets()
985 cxl_rr->nr_targets); in cxl_port_setup_targets()
990 if (cxl_rr->nr_targets_set) { in cxl_port_setup_targets()
1000 distance = p->nr_targets / cxl_rr->nr_targets; in cxl_port_setup_targets()
1001 for (i = 0; i < cxl_rr->nr_targets_set; i++) in cxl_port_setup_targets()
1003 rc = check_last_peer(cxled, ep, cxl_rr, in cxl_port_setup_targets()
1047 iw = cxl_rr->nr_targets; in cxl_port_setup_targets()
1059 if (parent_iw > 1 && cxl_rr->nr_targets > 1) { in cxl_port_setup_targets()
1085 if (cxl_rr->nr_targets_set == cxl_rr->nr_targets) { in cxl_port_setup_targets()
1092 cxlsd->target[cxl_rr->nr_targets_set] = ep->dport; in cxl_port_setup_targets()
1095 cxl_rr->nr_targets_set += inc; in cxl_port_setup_targets()
1098 cxl_rr->nr_targets_set - 1, dev_name(ep->dport->dport), in cxl_port_setup_targets()
1107 struct cxl_region_ref *cxl_rr = cxl_rr_load(port, cxlr); in cxl_port_reset_targets() local
1114 if (!cxl_rr) in cxl_port_reset_targets()
1116 cxl_rr->nr_targets_set = 0; in cxl_port_reset_targets()
1118 cxld = cxl_rr->decoder; in cxl_port_reset_targets()