Lines Matching full:access
738 * a valid cur_ioas (access->ioas). A caller passing in a valid new_ioas should
741 static int iommufd_access_change_ioas(struct iommufd_access *access, in iommufd_access_change_ioas() argument
744 u32 iopt_access_list_id = access->iopt_access_list_id; in iommufd_access_change_ioas()
745 struct iommufd_ioas *cur_ioas = access->ioas; in iommufd_access_change_ioas()
748 lockdep_assert_held(&access->ioas_lock); in iommufd_access_change_ioas()
751 if (cur_ioas != access->ioas_unpin) in iommufd_access_change_ioas()
759 * iommufd_access_unpin_pages() can continue using access->ioas_unpin. in iommufd_access_change_ioas()
761 access->ioas = NULL; in iommufd_access_change_ioas()
764 rc = iopt_add_access(&new_ioas->iopt, access); in iommufd_access_change_ioas()
766 access->ioas = cur_ioas; in iommufd_access_change_ioas()
773 if (access->ops->unmap) { in iommufd_access_change_ioas()
774 mutex_unlock(&access->ioas_lock); in iommufd_access_change_ioas()
775 access->ops->unmap(access->data, 0, ULONG_MAX); in iommufd_access_change_ioas()
776 mutex_lock(&access->ioas_lock); in iommufd_access_change_ioas()
778 iopt_remove_access(&cur_ioas->iopt, access, iopt_access_list_id); in iommufd_access_change_ioas()
782 access->ioas = new_ioas; in iommufd_access_change_ioas()
783 access->ioas_unpin = new_ioas; in iommufd_access_change_ioas()
788 static int iommufd_access_change_ioas_id(struct iommufd_access *access, u32 id) in iommufd_access_change_ioas_id() argument
790 struct iommufd_ioas *ioas = iommufd_get_ioas(access->ictx, id); in iommufd_access_change_ioas_id()
795 rc = iommufd_access_change_ioas(access, ioas); in iommufd_access_change_ioas_id()
796 iommufd_put_object(access->ictx, &ioas->obj); in iommufd_access_change_ioas_id()
802 struct iommufd_access *access = in iommufd_access_destroy_object() local
805 mutex_lock(&access->ioas_lock); in iommufd_access_destroy_object()
806 if (access->ioas) in iommufd_access_destroy_object()
807 WARN_ON(iommufd_access_change_ioas(access, NULL)); in iommufd_access_destroy_object()
808 mutex_unlock(&access->ioas_lock); in iommufd_access_destroy_object()
809 iommufd_ctx_put(access->ictx); in iommufd_access_destroy_object()
815 * @ops: Driver's ops to associate with the access
817 * @id: Output ID number to return to userspace for this access
829 struct iommufd_access *access; in iommufd_access_create() local
832 * There is no uAPI for the access object, but to keep things symmetric in iommufd_access_create()
835 access = iommufd_object_alloc(ictx, access, IOMMUFD_OBJ_ACCESS); in iommufd_access_create()
836 if (IS_ERR(access)) in iommufd_access_create()
837 return access; in iommufd_access_create()
839 access->data = data; in iommufd_access_create()
840 access->ops = ops; in iommufd_access_create()
843 access->iova_alignment = PAGE_SIZE; in iommufd_access_create()
845 access->iova_alignment = 1; in iommufd_access_create()
848 refcount_inc(&access->obj.users); in iommufd_access_create()
849 access->ictx = ictx; in iommufd_access_create()
851 iommufd_object_finalize(ictx, &access->obj); in iommufd_access_create()
852 *id = access->obj.id; in iommufd_access_create()
853 mutex_init(&access->ioas_lock); in iommufd_access_create()
854 return access; in iommufd_access_create()
860 * @access: The access to destroy
862 * The caller must stop using the access before destroying it.
864 void iommufd_access_destroy(struct iommufd_access *access) in iommufd_access_destroy() argument
866 iommufd_object_destroy_user(access->ictx, &access->obj); in iommufd_access_destroy()
870 void iommufd_access_detach(struct iommufd_access *access) in iommufd_access_detach() argument
872 mutex_lock(&access->ioas_lock); in iommufd_access_detach()
873 if (WARN_ON(!access->ioas)) { in iommufd_access_detach()
874 mutex_unlock(&access->ioas_lock); in iommufd_access_detach()
877 WARN_ON(iommufd_access_change_ioas(access, NULL)); in iommufd_access_detach()
878 mutex_unlock(&access->ioas_lock); in iommufd_access_detach()
882 int iommufd_access_attach(struct iommufd_access *access, u32 ioas_id) in iommufd_access_attach() argument
886 mutex_lock(&access->ioas_lock); in iommufd_access_attach()
887 if (WARN_ON(access->ioas)) { in iommufd_access_attach()
888 mutex_unlock(&access->ioas_lock); in iommufd_access_attach()
892 rc = iommufd_access_change_ioas_id(access, ioas_id); in iommufd_access_attach()
893 mutex_unlock(&access->ioas_lock); in iommufd_access_attach()
898 int iommufd_access_replace(struct iommufd_access *access, u32 ioas_id) in iommufd_access_replace() argument
902 mutex_lock(&access->ioas_lock); in iommufd_access_replace()
903 if (!access->ioas) { in iommufd_access_replace()
904 mutex_unlock(&access->ioas_lock); in iommufd_access_replace()
907 rc = iommufd_access_change_ioas_id(access, ioas_id); in iommufd_access_replace()
908 mutex_unlock(&access->ioas_lock); in iommufd_access_replace()
934 struct iommufd_access *access; in iommufd_access_notify_unmap() local
938 xa_for_each(&ioas->iopt.access_list, index, access) { in iommufd_access_notify_unmap()
939 if (!iommufd_lock_obj(&access->obj)) in iommufd_access_notify_unmap()
943 access->ops->unmap(access->data, iova, length); in iommufd_access_notify_unmap()
945 iommufd_put_object(access->ictx, &access->obj); in iommufd_access_notify_unmap()
953 * @access: IOAS access to act on
955 * @length: Number of bytes to access
960 void iommufd_access_unpin_pages(struct iommufd_access *access, in iommufd_access_unpin_pages() argument
972 mutex_lock(&access->ioas_lock); in iommufd_access_unpin_pages()
977 if (WARN_ON(!access->ioas_unpin)) { in iommufd_access_unpin_pages()
978 mutex_unlock(&access->ioas_lock); in iommufd_access_unpin_pages()
981 iopt = &access->ioas_unpin->iopt; in iommufd_access_unpin_pages()
992 mutex_unlock(&access->ioas_lock); in iommufd_access_unpin_pages()
1017 * @access: IOAS access to act on
1019 * @length: Number of bytes to access
1024 * These can be kmap'd by the caller for CPU access.
1034 int iommufd_access_pin_pages(struct iommufd_access *access, unsigned long iova, in iommufd_access_pin_pages() argument
1046 WARN_ON(access->iova_alignment != PAGE_SIZE || !access->ops->unmap)) in iommufd_access_pin_pages()
1054 mutex_lock(&access->ioas_lock); in iommufd_access_pin_pages()
1055 if (!access->ioas) { in iommufd_access_pin_pages()
1056 mutex_unlock(&access->ioas_lock); in iommufd_access_pin_pages()
1059 iopt = &access->ioas->iopt; in iommufd_access_pin_pages()
1091 mutex_unlock(&access->ioas_lock); in iommufd_access_pin_pages()
1106 mutex_unlock(&access->ioas_lock); in iommufd_access_pin_pages()
1113 * @access: IOAS access to act on
1116 * @length: Number of bytes to access
1123 int iommufd_access_rw(struct iommufd_access *access, unsigned long iova, in iommufd_access_rw() argument
1137 mutex_lock(&access->ioas_lock); in iommufd_access_rw()
1138 if (!access->ioas) { in iommufd_access_rw()
1139 mutex_unlock(&access->ioas_lock); in iommufd_access_rw()
1142 iopt = &access->ioas->iopt; in iommufd_access_rw()
1170 mutex_unlock(&access->ioas_lock); in iommufd_access_rw()