Lines Matching full:attach

305 	struct iommufd_attach *attach;  in iommufd_group_device_num()  local
312 attach = xa_load(&igroup->pasid_attach, pasid); in iommufd_group_device_num()
313 if (attach) in iommufd_group_device_num()
314 xa_for_each(&attach->device_array, index, idev) in iommufd_group_device_num()
388 /* The device attach/detach/replace helpers for attach_handle */
393 struct iommufd_attach *attach; in iommufd_device_is_attached() local
395 attach = xa_load(&idev->igroup->pasid_attach, pasid); in iommufd_device_is_attached()
396 return xa_load(&attach->device_array, idev->obj.id); in iommufd_device_is_attached()
415 struct iommufd_attach *attach; in iommufd_hwpt_pasid_compat() local
420 attach = xa_load(&igroup->pasid_attach, IOMMU_NO_PASID); in iommufd_hwpt_pasid_compat()
421 if (attach && attach->hwpt && !attach->hwpt->pasid_compat) in iommufd_hwpt_pasid_compat()
560 struct iommufd_attach *attach; in iommufd_hw_pagetable_attach() local
565 attach = xa_cmpxchg(&igroup->pasid_attach, pasid, NULL, in iommufd_hw_pagetable_attach()
567 if (xa_is_err(attach)) { in iommufd_hw_pagetable_attach()
568 rc = xa_err(attach); in iommufd_hw_pagetable_attach()
572 if (!attach) { in iommufd_hw_pagetable_attach()
573 attach = kzalloc(sizeof(*attach), GFP_KERNEL); in iommufd_hw_pagetable_attach()
574 if (!attach) { in iommufd_hw_pagetable_attach()
578 xa_init(&attach->device_array); in iommufd_hw_pagetable_attach()
581 old_hwpt = attach->hwpt; in iommufd_hw_pagetable_attach()
583 rc = xa_insert(&attach->device_array, idev->obj.id, XA_ZERO_ENTRY, in iommufd_hw_pagetable_attach()
602 * Only attach to the group once for the first device that is in the in iommufd_hw_pagetable_attach()
604 * should attach every device individually to the hwpt as the per-device in iommufd_hw_pagetable_attach()
612 attach->hwpt = hwpt; in iommufd_hw_pagetable_attach()
613 WARN_ON(xa_is_err(xa_store(&igroup->pasid_attach, pasid, attach, in iommufd_hw_pagetable_attach()
617 WARN_ON(xa_is_err(xa_store(&attach->device_array, idev->obj.id, in iommufd_hw_pagetable_attach()
625 xa_release(&attach->device_array, idev->obj.id); in iommufd_hw_pagetable_attach()
628 kfree(attach); in iommufd_hw_pagetable_attach()
643 struct iommufd_attach *attach; in iommufd_hw_pagetable_detach() local
646 attach = xa_load(&igroup->pasid_attach, pasid); in iommufd_hw_pagetable_detach()
647 if (!attach) { in iommufd_hw_pagetable_detach()
652 hwpt = attach->hwpt; in iommufd_hw_pagetable_detach()
655 xa_erase(&attach->device_array, idev->obj.id); in iommufd_hw_pagetable_detach()
656 if (xa_empty(&attach->device_array)) { in iommufd_hw_pagetable_detach()
659 kfree(attach); in iommufd_hw_pagetable_detach()
685 struct iommufd_attach *attach; in iommufd_group_remove_reserved_iova() local
691 attach = xa_load(&igroup->pasid_attach, IOMMU_NO_PASID); in iommufd_group_remove_reserved_iova()
692 xa_for_each(&attach->device_array, index, cur) in iommufd_group_remove_reserved_iova()
701 struct iommufd_attach *attach; in iommufd_group_do_replace_reserved_iova() local
708 attach = xa_load(&igroup->pasid_attach, IOMMU_NO_PASID); in iommufd_group_do_replace_reserved_iova()
709 old_hwpt_paging = find_hwpt_paging(attach->hwpt); in iommufd_group_do_replace_reserved_iova()
711 xa_for_each(&attach->device_array, index, cur) { in iommufd_group_do_replace_reserved_iova()
738 struct iommufd_attach *attach; in iommufd_device_do_replace() local
744 attach = xa_load(&igroup->pasid_attach, pasid); in iommufd_device_do_replace()
745 if (!attach) { in iommufd_device_do_replace()
750 old_hwpt = attach->hwpt; in iommufd_device_do_replace()
752 WARN_ON(!old_hwpt || xa_empty(&attach->device_array)); in iommufd_device_do_replace()
779 attach->hwpt = hwpt; in iommufd_device_do_replace()
830 * that is willing to attach to the device is interchangeable with any in iommufd_device_auto_get_domain()
939 * @idev: device to attach
940 * @pasid: pasid to attach
946 * @pasid. @pasid is IOMMU_NO_PASID if this attach is for no pasid usage.