Lines Matching refs:matrix_mdev
99 static inline void get_update_locks_for_mdev(struct ap_matrix_mdev *matrix_mdev) in get_update_locks_for_mdev() argument
102 if (matrix_mdev && matrix_mdev->kvm) in get_update_locks_for_mdev()
103 mutex_lock(&matrix_mdev->kvm->lock); in get_update_locks_for_mdev()
122 static inline void release_update_locks_for_mdev(struct ap_matrix_mdev *matrix_mdev) in release_update_locks_for_mdev() argument
125 if (matrix_mdev && matrix_mdev->kvm) in release_update_locks_for_mdev()
126 mutex_unlock(&matrix_mdev->kvm->lock); in release_update_locks_for_mdev()
151 struct ap_matrix_mdev *matrix_mdev; in get_update_locks_by_apqn() local
155 list_for_each_entry(matrix_mdev, &matrix_dev->mdev_list, node) { in get_update_locks_by_apqn()
156 if (test_bit_inv(AP_QID_CARD(apqn), matrix_mdev->matrix.apm) && in get_update_locks_by_apqn()
157 test_bit_inv(AP_QID_QUEUE(apqn), matrix_mdev->matrix.aqm)) { in get_update_locks_by_apqn()
158 if (matrix_mdev->kvm) in get_update_locks_by_apqn()
159 mutex_lock(&matrix_mdev->kvm->lock); in get_update_locks_by_apqn()
163 return matrix_mdev; in get_update_locks_by_apqn()
191 if (q->matrix_mdev && q->matrix_mdev->kvm) in get_update_locks_for_queue()
192 mutex_lock(&q->matrix_mdev->kvm->lock); in get_update_locks_for_queue()
206 struct ap_matrix_mdev *matrix_mdev, in vfio_ap_mdev_get_queue() argument
211 hash_for_each_possible(matrix_mdev->qtable.queues, q, mdev_qnode, in vfio_ap_mdev_get_queue()
273 !WARN_ON(!(q->matrix_mdev && q->matrix_mdev->kvm))) { in vfio_ap_free_aqic_resources()
274 kvm_s390_gisc_unregister(q->matrix_mdev->kvm, q->saved_isc); in vfio_ap_free_aqic_resources()
277 if (q->saved_iova && !WARN_ON(!q->matrix_mdev)) { in vfio_ap_free_aqic_resources()
278 vfio_unpin_pages(&q->matrix_mdev->vdev, q->saved_iova, 1); in vfio_ap_free_aqic_resources()
427 ret = vfio_pin_pages(&q->matrix_mdev->vdev, nib, 1, in vfio_ap_irq_enable()
441 kvm = q->matrix_mdev->kvm; in vfio_ap_irq_enable()
450 vfio_unpin_pages(&q->matrix_mdev->vdev, nib, 1); in vfio_ap_irq_enable()
478 vfio_unpin_pages(&q->matrix_mdev->vdev, nib, 1); in vfio_ap_irq_enable()
572 struct ap_matrix_mdev *matrix_mdev; in handle_pqap() local
593 matrix_mdev = container_of(vcpu->kvm->arch.crypto.pqap_hook, in handle_pqap()
597 if (!matrix_mdev->kvm) { in handle_pqap()
598 vfio_ap_le_guid_to_be_uuid(&matrix_mdev->mdev->uuid, uuid); in handle_pqap()
605 q = vfio_ap_mdev_get_queue(matrix_mdev, apqn); in handle_pqap()
636 static void vfio_ap_mdev_update_guest_apcb(struct ap_matrix_mdev *matrix_mdev) in vfio_ap_mdev_update_guest_apcb() argument
638 if (matrix_mdev->kvm) in vfio_ap_mdev_update_guest_apcb()
639 kvm_arch_crypto_set_masks(matrix_mdev->kvm, in vfio_ap_mdev_update_guest_apcb()
640 matrix_mdev->shadow_apcb.apm, in vfio_ap_mdev_update_guest_apcb()
641 matrix_mdev->shadow_apcb.aqm, in vfio_ap_mdev_update_guest_apcb()
642 matrix_mdev->shadow_apcb.adm); in vfio_ap_mdev_update_guest_apcb()
645 static bool vfio_ap_mdev_filter_cdoms(struct ap_matrix_mdev *matrix_mdev) in vfio_ap_mdev_filter_cdoms() argument
649 bitmap_copy(prev_shadow_adm, matrix_mdev->shadow_apcb.adm, AP_DOMAINS); in vfio_ap_mdev_filter_cdoms()
650 bitmap_and(matrix_mdev->shadow_apcb.adm, matrix_mdev->matrix.adm, in vfio_ap_mdev_filter_cdoms()
653 return !bitmap_equal(prev_shadow_adm, matrix_mdev->shadow_apcb.adm, in vfio_ap_mdev_filter_cdoms()
674 struct ap_matrix_mdev *matrix_mdev) in vfio_ap_mdev_filter_matrix() argument
681 bitmap_copy(prev_shadow_apm, matrix_mdev->shadow_apcb.apm, AP_DEVICES); in vfio_ap_mdev_filter_matrix()
682 bitmap_copy(prev_shadow_aqm, matrix_mdev->shadow_apcb.aqm, AP_DOMAINS); in vfio_ap_mdev_filter_matrix()
683 vfio_ap_matrix_init(&matrix_dev->info, &matrix_mdev->shadow_apcb); in vfio_ap_mdev_filter_matrix()
690 bitmap_and(matrix_mdev->shadow_apcb.apm, matrix_mdev->matrix.apm, in vfio_ap_mdev_filter_matrix()
692 bitmap_and(matrix_mdev->shadow_apcb.aqm, matrix_mdev->matrix.aqm, in vfio_ap_mdev_filter_matrix()
706 q = vfio_ap_mdev_get_queue(matrix_mdev, apqn); in vfio_ap_mdev_filter_matrix()
709 matrix_mdev->shadow_apcb.apm); in vfio_ap_mdev_filter_matrix()
715 return !bitmap_equal(prev_shadow_apm, matrix_mdev->shadow_apcb.apm, in vfio_ap_mdev_filter_matrix()
717 !bitmap_equal(prev_shadow_aqm, matrix_mdev->shadow_apcb.aqm, in vfio_ap_mdev_filter_matrix()
723 struct ap_matrix_mdev *matrix_mdev = in vfio_ap_mdev_init_dev() local
726 matrix_mdev->mdev = to_mdev_device(vdev->dev); in vfio_ap_mdev_init_dev()
727 vfio_ap_matrix_init(&matrix_dev->info, &matrix_mdev->matrix); in vfio_ap_mdev_init_dev()
728 matrix_mdev->pqap_hook = handle_pqap; in vfio_ap_mdev_init_dev()
729 vfio_ap_matrix_init(&matrix_dev->info, &matrix_mdev->shadow_apcb); in vfio_ap_mdev_init_dev()
730 hash_init(matrix_mdev->qtable.queues); in vfio_ap_mdev_init_dev()
737 struct ap_matrix_mdev *matrix_mdev; in vfio_ap_mdev_probe() local
740 matrix_mdev = vfio_alloc_device(ap_matrix_mdev, vdev, &mdev->dev, in vfio_ap_mdev_probe()
742 if (IS_ERR(matrix_mdev)) in vfio_ap_mdev_probe()
743 return PTR_ERR(matrix_mdev); in vfio_ap_mdev_probe()
745 ret = vfio_register_emulated_iommu_dev(&matrix_mdev->vdev); in vfio_ap_mdev_probe()
748 matrix_mdev->req_trigger = NULL; in vfio_ap_mdev_probe()
749 dev_set_drvdata(&mdev->dev, matrix_mdev); in vfio_ap_mdev_probe()
751 list_add(&matrix_mdev->node, &matrix_dev->mdev_list); in vfio_ap_mdev_probe()
756 vfio_put_device(&matrix_mdev->vdev); in vfio_ap_mdev_probe()
760 static void vfio_ap_mdev_link_queue(struct ap_matrix_mdev *matrix_mdev, in vfio_ap_mdev_link_queue() argument
764 q->matrix_mdev = matrix_mdev; in vfio_ap_mdev_link_queue()
765 hash_add(matrix_mdev->qtable.queues, &q->mdev_qnode, q->apqn); in vfio_ap_mdev_link_queue()
769 static void vfio_ap_mdev_link_apqn(struct ap_matrix_mdev *matrix_mdev, int apqn) in vfio_ap_mdev_link_apqn() argument
774 vfio_ap_mdev_link_queue(matrix_mdev, q); in vfio_ap_mdev_link_apqn()
784 q->matrix_mdev = NULL; in vfio_ap_unlink_mdev_fr_queue()
787 static void vfio_ap_mdev_unlink_fr_queues(struct ap_matrix_mdev *matrix_mdev) in vfio_ap_mdev_unlink_fr_queues() argument
792 for_each_set_bit_inv(apid, matrix_mdev->matrix.apm, AP_DEVICES) { in vfio_ap_mdev_unlink_fr_queues()
793 for_each_set_bit_inv(apqi, matrix_mdev->matrix.aqm, in vfio_ap_mdev_unlink_fr_queues()
795 q = vfio_ap_mdev_get_queue(matrix_mdev, in vfio_ap_mdev_unlink_fr_queues()
798 q->matrix_mdev = NULL; in vfio_ap_mdev_unlink_fr_queues()
805 struct ap_matrix_mdev *matrix_mdev = dev_get_drvdata(&mdev->dev); in vfio_ap_mdev_remove() local
807 vfio_unregister_group_dev(&matrix_mdev->vdev); in vfio_ap_mdev_remove()
811 vfio_ap_mdev_reset_queues(&matrix_mdev->qtable); in vfio_ap_mdev_remove()
812 vfio_ap_mdev_unlink_fr_queues(matrix_mdev); in vfio_ap_mdev_remove()
813 list_del(&matrix_mdev->node); in vfio_ap_mdev_remove()
816 vfio_put_device(&matrix_mdev->vdev); in vfio_ap_mdev_remove()
822 static void vfio_ap_mdev_log_sharing_err(struct ap_matrix_mdev *matrix_mdev, in vfio_ap_mdev_log_sharing_err() argument
827 const struct device *dev = mdev_dev(matrix_mdev->mdev); in vfio_ap_mdev_log_sharing_err()
850 struct ap_matrix_mdev *matrix_mdev; in vfio_ap_mdev_verify_no_sharing() local
854 list_for_each_entry(matrix_mdev, &matrix_dev->mdev_list, node) { in vfio_ap_mdev_verify_no_sharing()
859 if (mdev_apm == matrix_mdev->matrix.apm && in vfio_ap_mdev_verify_no_sharing()
860 mdev_aqm == matrix_mdev->matrix.aqm) in vfio_ap_mdev_verify_no_sharing()
870 if (!bitmap_and(apm, mdev_apm, matrix_mdev->matrix.apm, in vfio_ap_mdev_verify_no_sharing()
874 if (!bitmap_and(aqm, mdev_aqm, matrix_mdev->matrix.aqm, in vfio_ap_mdev_verify_no_sharing()
878 vfio_ap_mdev_log_sharing_err(matrix_mdev, apm, aqm); in vfio_ap_mdev_verify_no_sharing()
901 static int vfio_ap_mdev_validate_masks(struct ap_matrix_mdev *matrix_mdev) in vfio_ap_mdev_validate_masks() argument
903 if (ap_apqn_in_matrix_owned_by_def_drv(matrix_mdev->matrix.apm, in vfio_ap_mdev_validate_masks()
904 matrix_mdev->matrix.aqm)) in vfio_ap_mdev_validate_masks()
907 return vfio_ap_mdev_verify_no_sharing(matrix_mdev->matrix.apm, in vfio_ap_mdev_validate_masks()
908 matrix_mdev->matrix.aqm); in vfio_ap_mdev_validate_masks()
911 static void vfio_ap_mdev_link_adapter(struct ap_matrix_mdev *matrix_mdev, in vfio_ap_mdev_link_adapter() argument
916 for_each_set_bit_inv(apqi, matrix_mdev->matrix.aqm, AP_DOMAINS) in vfio_ap_mdev_link_adapter()
917 vfio_ap_mdev_link_apqn(matrix_mdev, in vfio_ap_mdev_link_adapter()
962 struct ap_matrix_mdev *matrix_mdev = dev_get_drvdata(dev); in assign_adapter_store() local
965 get_update_locks_for_mdev(matrix_mdev); in assign_adapter_store()
971 if (apid > matrix_mdev->matrix.apm_max) { in assign_adapter_store()
976 if (test_bit_inv(apid, matrix_mdev->matrix.apm)) { in assign_adapter_store()
981 set_bit_inv(apid, matrix_mdev->matrix.apm); in assign_adapter_store()
983 ret = vfio_ap_mdev_validate_masks(matrix_mdev); in assign_adapter_store()
985 clear_bit_inv(apid, matrix_mdev->matrix.apm); in assign_adapter_store()
989 vfio_ap_mdev_link_adapter(matrix_mdev, apid); in assign_adapter_store()
994 matrix_mdev->matrix.aqm, matrix_mdev)) in assign_adapter_store()
995 vfio_ap_mdev_update_guest_apcb(matrix_mdev); in assign_adapter_store()
999 release_update_locks_for_mdev(matrix_mdev); in assign_adapter_store()
1007 *vfio_ap_unlink_apqn_fr_mdev(struct ap_matrix_mdev *matrix_mdev, in vfio_ap_unlink_apqn_fr_mdev() argument
1012 q = vfio_ap_mdev_get_queue(matrix_mdev, AP_MKQID(apid, apqi)); in vfio_ap_unlink_apqn_fr_mdev()
1028 static void vfio_ap_mdev_unlink_adapter(struct ap_matrix_mdev *matrix_mdev, in vfio_ap_mdev_unlink_adapter() argument
1035 for_each_set_bit_inv(apqi, matrix_mdev->matrix.aqm, AP_DOMAINS) { in vfio_ap_mdev_unlink_adapter()
1036 q = vfio_ap_unlink_apqn_fr_mdev(matrix_mdev, apid, apqi); in vfio_ap_mdev_unlink_adapter()
1039 if (test_bit_inv(apid, matrix_mdev->shadow_apcb.apm) && in vfio_ap_mdev_unlink_adapter()
1040 test_bit_inv(apqi, matrix_mdev->shadow_apcb.aqm)) in vfio_ap_mdev_unlink_adapter()
1047 static void vfio_ap_mdev_hot_unplug_adapter(struct ap_matrix_mdev *matrix_mdev, in vfio_ap_mdev_hot_unplug_adapter() argument
1055 vfio_ap_mdev_unlink_adapter(matrix_mdev, apid, qtable); in vfio_ap_mdev_hot_unplug_adapter()
1057 if (test_bit_inv(apid, matrix_mdev->shadow_apcb.apm)) { in vfio_ap_mdev_hot_unplug_adapter()
1058 clear_bit_inv(apid, matrix_mdev->shadow_apcb.apm); in vfio_ap_mdev_hot_unplug_adapter()
1059 vfio_ap_mdev_update_guest_apcb(matrix_mdev); in vfio_ap_mdev_hot_unplug_adapter()
1093 struct ap_matrix_mdev *matrix_mdev = dev_get_drvdata(dev); in unassign_adapter_store() local
1095 get_update_locks_for_mdev(matrix_mdev); in unassign_adapter_store()
1101 if (apid > matrix_mdev->matrix.apm_max) { in unassign_adapter_store()
1106 if (!test_bit_inv(apid, matrix_mdev->matrix.apm)) { in unassign_adapter_store()
1111 clear_bit_inv((unsigned long)apid, matrix_mdev->matrix.apm); in unassign_adapter_store()
1112 vfio_ap_mdev_hot_unplug_adapter(matrix_mdev, apid); in unassign_adapter_store()
1115 release_update_locks_for_mdev(matrix_mdev); in unassign_adapter_store()
1120 static void vfio_ap_mdev_link_domain(struct ap_matrix_mdev *matrix_mdev, in vfio_ap_mdev_link_domain() argument
1125 for_each_set_bit_inv(apid, matrix_mdev->matrix.apm, AP_DEVICES) in vfio_ap_mdev_link_domain()
1126 vfio_ap_mdev_link_apqn(matrix_mdev, in vfio_ap_mdev_link_domain()
1171 struct ap_matrix_mdev *matrix_mdev = dev_get_drvdata(dev); in assign_domain_store() local
1174 get_update_locks_for_mdev(matrix_mdev); in assign_domain_store()
1180 if (apqi > matrix_mdev->matrix.aqm_max) { in assign_domain_store()
1185 if (test_bit_inv(apqi, matrix_mdev->matrix.aqm)) { in assign_domain_store()
1190 set_bit_inv(apqi, matrix_mdev->matrix.aqm); in assign_domain_store()
1192 ret = vfio_ap_mdev_validate_masks(matrix_mdev); in assign_domain_store()
1194 clear_bit_inv(apqi, matrix_mdev->matrix.aqm); in assign_domain_store()
1198 vfio_ap_mdev_link_domain(matrix_mdev, apqi); in assign_domain_store()
1202 if (vfio_ap_mdev_filter_matrix(matrix_mdev->matrix.apm, aqm_delta, in assign_domain_store()
1203 matrix_mdev)) in assign_domain_store()
1204 vfio_ap_mdev_update_guest_apcb(matrix_mdev); in assign_domain_store()
1208 release_update_locks_for_mdev(matrix_mdev); in assign_domain_store()
1215 static void vfio_ap_mdev_unlink_domain(struct ap_matrix_mdev *matrix_mdev, in vfio_ap_mdev_unlink_domain() argument
1222 for_each_set_bit_inv(apid, matrix_mdev->matrix.apm, AP_DEVICES) { in vfio_ap_mdev_unlink_domain()
1223 q = vfio_ap_unlink_apqn_fr_mdev(matrix_mdev, apid, apqi); in vfio_ap_mdev_unlink_domain()
1226 if (test_bit_inv(apid, matrix_mdev->shadow_apcb.apm) && in vfio_ap_mdev_unlink_domain()
1227 test_bit_inv(apqi, matrix_mdev->shadow_apcb.aqm)) in vfio_ap_mdev_unlink_domain()
1234 static void vfio_ap_mdev_hot_unplug_domain(struct ap_matrix_mdev *matrix_mdev, in vfio_ap_mdev_hot_unplug_domain() argument
1242 vfio_ap_mdev_unlink_domain(matrix_mdev, apqi, qtable); in vfio_ap_mdev_hot_unplug_domain()
1244 if (test_bit_inv(apqi, matrix_mdev->shadow_apcb.aqm)) { in vfio_ap_mdev_hot_unplug_domain()
1245 clear_bit_inv(apqi, matrix_mdev->shadow_apcb.aqm); in vfio_ap_mdev_hot_unplug_domain()
1246 vfio_ap_mdev_update_guest_apcb(matrix_mdev); in vfio_ap_mdev_hot_unplug_domain()
1280 struct ap_matrix_mdev *matrix_mdev = dev_get_drvdata(dev); in unassign_domain_store() local
1282 get_update_locks_for_mdev(matrix_mdev); in unassign_domain_store()
1288 if (apqi > matrix_mdev->matrix.aqm_max) { in unassign_domain_store()
1293 if (!test_bit_inv(apqi, matrix_mdev->matrix.aqm)) { in unassign_domain_store()
1298 clear_bit_inv((unsigned long)apqi, matrix_mdev->matrix.aqm); in unassign_domain_store()
1299 vfio_ap_mdev_hot_unplug_domain(matrix_mdev, apqi); in unassign_domain_store()
1303 release_update_locks_for_mdev(matrix_mdev); in unassign_domain_store()
1328 struct ap_matrix_mdev *matrix_mdev = dev_get_drvdata(dev); in assign_control_domain_store() local
1330 get_update_locks_for_mdev(matrix_mdev); in assign_control_domain_store()
1336 if (id > matrix_mdev->matrix.adm_max) { in assign_control_domain_store()
1341 if (test_bit_inv(id, matrix_mdev->matrix.adm)) { in assign_control_domain_store()
1351 set_bit_inv(id, matrix_mdev->matrix.adm); in assign_control_domain_store()
1352 if (vfio_ap_mdev_filter_cdoms(matrix_mdev)) in assign_control_domain_store()
1353 vfio_ap_mdev_update_guest_apcb(matrix_mdev); in assign_control_domain_store()
1357 release_update_locks_for_mdev(matrix_mdev); in assign_control_domain_store()
1382 struct ap_matrix_mdev *matrix_mdev = dev_get_drvdata(dev); in unassign_control_domain_store() local
1384 get_update_locks_for_mdev(matrix_mdev); in unassign_control_domain_store()
1390 if (domid > matrix_mdev->matrix.adm_max) { in unassign_control_domain_store()
1395 if (!test_bit_inv(domid, matrix_mdev->matrix.adm)) { in unassign_control_domain_store()
1400 clear_bit_inv(domid, matrix_mdev->matrix.adm); in unassign_control_domain_store()
1402 if (test_bit_inv(domid, matrix_mdev->shadow_apcb.adm)) { in unassign_control_domain_store()
1403 clear_bit_inv(domid, matrix_mdev->shadow_apcb.adm); in unassign_control_domain_store()
1404 vfio_ap_mdev_update_guest_apcb(matrix_mdev); in unassign_control_domain_store()
1409 release_update_locks_for_mdev(matrix_mdev); in unassign_control_domain_store()
1422 struct ap_matrix_mdev *matrix_mdev = dev_get_drvdata(dev); in control_domains_show() local
1423 unsigned long max_domid = matrix_mdev->matrix.adm_max; in control_domains_show()
1426 for_each_set_bit_inv(id, matrix_mdev->matrix.adm, max_domid + 1) { in control_domains_show()
1483 struct ap_matrix_mdev *matrix_mdev = dev_get_drvdata(dev); in matrix_show() local
1486 nchars = vfio_ap_mdev_matrix_show(&matrix_mdev->matrix, buf); in matrix_show()
1497 struct ap_matrix_mdev *matrix_mdev = dev_get_drvdata(dev); in guest_matrix_show() local
1500 nchars = vfio_ap_mdev_matrix_show(&matrix_mdev->shadow_apcb, buf); in guest_matrix_show()
1539 static int vfio_ap_mdev_set_kvm(struct ap_matrix_mdev *matrix_mdev, in vfio_ap_mdev_set_kvm() argument
1546 kvm->arch.crypto.pqap_hook = &matrix_mdev->pqap_hook; in vfio_ap_mdev_set_kvm()
1552 if (m != matrix_mdev && m->kvm == kvm) { in vfio_ap_mdev_set_kvm()
1559 matrix_mdev->kvm = kvm; in vfio_ap_mdev_set_kvm()
1560 vfio_ap_mdev_update_guest_apcb(matrix_mdev); in vfio_ap_mdev_set_kvm()
1568 static void unmap_iova(struct ap_matrix_mdev *matrix_mdev, u64 iova, u64 length) in unmap_iova() argument
1570 struct ap_queue_table *qtable = &matrix_mdev->qtable; in unmap_iova()
1583 struct ap_matrix_mdev *matrix_mdev = in vfio_ap_mdev_dma_unmap() local
1588 unmap_iova(matrix_mdev, iova, length); in vfio_ap_mdev_dma_unmap()
1599 static void vfio_ap_mdev_unset_kvm(struct ap_matrix_mdev *matrix_mdev) in vfio_ap_mdev_unset_kvm() argument
1601 struct kvm *kvm = matrix_mdev->kvm; in vfio_ap_mdev_unset_kvm()
1611 vfio_ap_mdev_reset_queues(&matrix_mdev->qtable); in vfio_ap_mdev_unset_kvm()
1613 matrix_mdev->kvm = NULL; in vfio_ap_mdev_unset_kvm()
1767 struct ap_matrix_mdev *matrix_mdev = in vfio_ap_mdev_open_device() local
1773 return vfio_ap_mdev_set_kvm(matrix_mdev, vdev->kvm); in vfio_ap_mdev_open_device()
1778 struct ap_matrix_mdev *matrix_mdev = in vfio_ap_mdev_close_device() local
1781 vfio_ap_mdev_unset_kvm(matrix_mdev); in vfio_ap_mdev_close_device()
1787 struct ap_matrix_mdev *matrix_mdev; in vfio_ap_mdev_request() local
1789 matrix_mdev = container_of(vdev, struct ap_matrix_mdev, vdev); in vfio_ap_mdev_request()
1791 if (matrix_mdev->req_trigger) { in vfio_ap_mdev_request()
1797 eventfd_signal(matrix_mdev->req_trigger, 1); in vfio_ap_mdev_request()
1871 static int vfio_ap_set_request_irq(struct ap_matrix_mdev *matrix_mdev, in vfio_ap_set_request_irq() argument
1886 if (matrix_mdev->req_trigger) in vfio_ap_set_request_irq()
1887 eventfd_ctx_put(matrix_mdev->req_trigger); in vfio_ap_set_request_irq()
1888 matrix_mdev->req_trigger = NULL; in vfio_ap_set_request_irq()
1894 if (matrix_mdev->req_trigger) in vfio_ap_set_request_irq()
1895 eventfd_ctx_put(matrix_mdev->req_trigger); in vfio_ap_set_request_irq()
1897 matrix_mdev->req_trigger = req_trigger; in vfio_ap_set_request_irq()
1905 static int vfio_ap_set_irqs(struct ap_matrix_mdev *matrix_mdev, in vfio_ap_set_irqs() argument
1919 return vfio_ap_set_request_irq(matrix_mdev, arg); in vfio_ap_set_irqs()
1931 struct ap_matrix_mdev *matrix_mdev = in vfio_ap_mdev_ioctl() local
1941 ret = vfio_ap_mdev_reset_queues(&matrix_mdev->qtable); in vfio_ap_mdev_ioctl()
1947 ret = vfio_ap_set_irqs(matrix_mdev, arg); in vfio_ap_mdev_ioctl()
1960 struct ap_matrix_mdev *matrix_mdev; in vfio_ap_mdev_for_queue() local
1964 list_for_each_entry(matrix_mdev, &matrix_dev->mdev_list, node) { in vfio_ap_mdev_for_queue()
1965 if (test_bit_inv(apid, matrix_mdev->matrix.apm) && in vfio_ap_mdev_for_queue()
1966 test_bit_inv(apqi, matrix_mdev->matrix.aqm)) in vfio_ap_mdev_for_queue()
1967 return matrix_mdev; in vfio_ap_mdev_for_queue()
1979 struct ap_matrix_mdev *matrix_mdev; in status_show() local
1984 matrix_mdev = vfio_ap_mdev_for_queue(q); in status_show()
1986 if (matrix_mdev) { in status_show()
1987 if (matrix_mdev->kvm) in status_show()
2073 struct ap_matrix_mdev *matrix_mdev; in vfio_ap_mdev_probe_queue() local
2089 matrix_mdev = get_update_locks_by_apqn(q->apqn); in vfio_ap_mdev_probe_queue()
2091 if (matrix_mdev) { in vfio_ap_mdev_probe_queue()
2092 vfio_ap_mdev_link_queue(matrix_mdev, q); in vfio_ap_mdev_probe_queue()
2094 if (vfio_ap_mdev_filter_matrix(matrix_mdev->matrix.apm, in vfio_ap_mdev_probe_queue()
2095 matrix_mdev->matrix.aqm, in vfio_ap_mdev_probe_queue()
2096 matrix_mdev)) in vfio_ap_mdev_probe_queue()
2097 vfio_ap_mdev_update_guest_apcb(matrix_mdev); in vfio_ap_mdev_probe_queue()
2100 release_update_locks_for_mdev(matrix_mdev); in vfio_ap_mdev_probe_queue()
2113 struct ap_matrix_mdev *matrix_mdev; in vfio_ap_mdev_remove_queue() local
2118 matrix_mdev = q->matrix_mdev; in vfio_ap_mdev_remove_queue()
2120 if (matrix_mdev) { in vfio_ap_mdev_remove_queue()
2130 if (test_bit_inv(apid, matrix_mdev->shadow_apcb.apm) && in vfio_ap_mdev_remove_queue()
2131 test_bit_inv(apqi, matrix_mdev->shadow_apcb.aqm)) { in vfio_ap_mdev_remove_queue()
2132 clear_bit_inv(apid, matrix_mdev->shadow_apcb.apm); in vfio_ap_mdev_remove_queue()
2133 vfio_ap_mdev_update_guest_apcb(matrix_mdev); in vfio_ap_mdev_remove_queue()
2141 release_update_locks_for_mdev(matrix_mdev); in vfio_ap_mdev_remove_queue()
2182 static void vfio_ap_mdev_hot_unplug_cfg(struct ap_matrix_mdev *matrix_mdev, in vfio_ap_mdev_hot_unplug_cfg() argument
2190 do_hotplug |= bitmap_andnot(matrix_mdev->shadow_apcb.apm, in vfio_ap_mdev_hot_unplug_cfg()
2191 matrix_mdev->shadow_apcb.apm, in vfio_ap_mdev_hot_unplug_cfg()
2196 do_hotplug |= bitmap_andnot(matrix_mdev->shadow_apcb.aqm, in vfio_ap_mdev_hot_unplug_cfg()
2197 matrix_mdev->shadow_apcb.aqm, in vfio_ap_mdev_hot_unplug_cfg()
2202 do_hotplug |= bitmap_andnot(matrix_mdev->shadow_apcb.adm, in vfio_ap_mdev_hot_unplug_cfg()
2203 matrix_mdev->shadow_apcb.adm, in vfio_ap_mdev_hot_unplug_cfg()
2207 vfio_ap_mdev_update_guest_apcb(matrix_mdev); in vfio_ap_mdev_hot_unplug_cfg()
2227 struct ap_matrix_mdev *matrix_mdev; in vfio_ap_mdev_cfg_remove() local
2233 list_for_each_entry(matrix_mdev, &matrix_dev->mdev_list, node) { in vfio_ap_mdev_cfg_remove()
2234 mutex_lock(&matrix_mdev->kvm->lock); in vfio_ap_mdev_cfg_remove()
2238 matrix_mdev->matrix.apm, in vfio_ap_mdev_cfg_remove()
2241 matrix_mdev->matrix.aqm, in vfio_ap_mdev_cfg_remove()
2244 matrix_mdev->matrix.adm, in vfio_ap_mdev_cfg_remove()
2248 vfio_ap_mdev_hot_unplug_cfg(matrix_mdev, aprem, aqrem, in vfio_ap_mdev_cfg_remove()
2252 mutex_unlock(&matrix_mdev->kvm->lock); in vfio_ap_mdev_cfg_remove()
2369 struct ap_matrix_mdev *matrix_mdev; in vfio_ap_mdev_cfg_add() local
2376 list_for_each_entry(matrix_mdev, &matrix_dev->mdev_list, node) { in vfio_ap_mdev_cfg_add()
2377 bitmap_and(matrix_mdev->apm_add, in vfio_ap_mdev_cfg_add()
2378 matrix_mdev->matrix.apm, apm_add, AP_DEVICES); in vfio_ap_mdev_cfg_add()
2379 bitmap_and(matrix_mdev->aqm_add, in vfio_ap_mdev_cfg_add()
2380 matrix_mdev->matrix.aqm, aqm_add, AP_DOMAINS); in vfio_ap_mdev_cfg_add()
2381 bitmap_and(matrix_mdev->adm_add, in vfio_ap_mdev_cfg_add()
2382 matrix_mdev->matrix.adm, adm_add, AP_DEVICES); in vfio_ap_mdev_cfg_add()
2444 static void vfio_ap_mdev_hot_plug_cfg(struct ap_matrix_mdev *matrix_mdev) in vfio_ap_mdev_hot_plug_cfg() argument
2452 mutex_lock(&matrix_mdev->kvm->lock); in vfio_ap_mdev_hot_plug_cfg()
2455 filter_adapters = bitmap_and(apm, matrix_mdev->matrix.apm, in vfio_ap_mdev_hot_plug_cfg()
2456 matrix_mdev->apm_add, AP_DEVICES); in vfio_ap_mdev_hot_plug_cfg()
2457 filter_domains = bitmap_and(aqm, matrix_mdev->matrix.aqm, in vfio_ap_mdev_hot_plug_cfg()
2458 matrix_mdev->aqm_add, AP_DOMAINS); in vfio_ap_mdev_hot_plug_cfg()
2461 do_hotplug |= vfio_ap_mdev_filter_matrix(apm, aqm, matrix_mdev); in vfio_ap_mdev_hot_plug_cfg()
2465 matrix_mdev->shadow_apcb.aqm, in vfio_ap_mdev_hot_plug_cfg()
2466 matrix_mdev); in vfio_ap_mdev_hot_plug_cfg()
2469 vfio_ap_mdev_filter_matrix(matrix_mdev->shadow_apcb.apm, in vfio_ap_mdev_hot_plug_cfg()
2470 aqm, matrix_mdev); in vfio_ap_mdev_hot_plug_cfg()
2472 if (bitmap_intersects(matrix_mdev->matrix.adm, matrix_mdev->adm_add, in vfio_ap_mdev_hot_plug_cfg()
2474 do_hotplug |= vfio_ap_mdev_filter_cdoms(matrix_mdev); in vfio_ap_mdev_hot_plug_cfg()
2477 vfio_ap_mdev_update_guest_apcb(matrix_mdev); in vfio_ap_mdev_hot_plug_cfg()
2480 mutex_unlock(&matrix_mdev->kvm->lock); in vfio_ap_mdev_hot_plug_cfg()
2486 struct ap_matrix_mdev *matrix_mdev; in vfio_ap_on_scan_complete() local
2490 list_for_each_entry(matrix_mdev, &matrix_dev->mdev_list, node) { in vfio_ap_on_scan_complete()
2491 if (bitmap_empty(matrix_mdev->apm_add, AP_DEVICES) && in vfio_ap_on_scan_complete()
2492 bitmap_empty(matrix_mdev->aqm_add, AP_DOMAINS) && in vfio_ap_on_scan_complete()
2493 bitmap_empty(matrix_mdev->adm_add, AP_DOMAINS)) in vfio_ap_on_scan_complete()
2496 vfio_ap_mdev_hot_plug_cfg(matrix_mdev); in vfio_ap_on_scan_complete()
2497 bitmap_clear(matrix_mdev->apm_add, 0, AP_DEVICES); in vfio_ap_on_scan_complete()
2498 bitmap_clear(matrix_mdev->aqm_add, 0, AP_DOMAINS); in vfio_ap_on_scan_complete()
2499 bitmap_clear(matrix_mdev->adm_add, 0, AP_DOMAINS); in vfio_ap_on_scan_complete()