Lines Matching refs:gmap

502 	struct gntdev_gmap *gmap, *gmap_tmp, *gmap_previous;  in gmap_list_dtor()  local
510 STAILQ_FOREACH_SAFE(gmap, &tmp_gmaps, gmap_next.list, gmap_tmp) { in gmap_list_dtor()
511 if (gmap->map == NULL) { in gmap_list_dtor()
518 if (gmap->notify) in gmap_list_dtor()
519 free(gmap->notify, M_GNTDEV); in gmap_list_dtor()
520 free(gmap->grant_map_ops, M_GNTDEV); in gmap_list_dtor()
521 free(gmap, M_GNTDEV); in gmap_list_dtor()
524 gmap_previous = gmap; in gmap_list_dtor()
542 struct gntdev_gmap find_gmap, *gmap; in gntdev_find_gmap() local
547 gmap = RB_FIND(gmap_tree_head, &priv_user->gmap_tree, &find_gmap); in gntdev_find_gmap()
550 if (gmap != NULL && gmap->count == count) in gntdev_find_gmap()
551 return (gmap); in gntdev_find_gmap()
562 notify_unmap_cleanup(struct gntdev_gmap *gmap) in notify_unmap_cleanup() argument
568 unmap_ops = malloc(sizeof(struct gnttab_unmap_grant_ref) * gmap->count, in notify_unmap_cleanup()
573 for (i = 0; i < gmap->count; i++) { in notify_unmap_cleanup()
574 if (gmap->grant_map_ops[i].handle != -1) { in notify_unmap_cleanup()
575 unmap_ops[count].handle = gmap->grant_map_ops[i].handle; in notify_unmap_cleanup()
577 gmap->grant_map_ops[i].host_addr; in notify_unmap_cleanup()
584 if (count > 0 && gmap->notify) { in notify_unmap_cleanup()
588 page_offset = gmap->notify->index - gmap->file_index; in notify_unmap_cleanup()
589 page = PHYS_TO_VM_PAGE(gmap->map->phys_base_addr + page_offset); in notify_unmap_cleanup()
590 notify(gmap->notify, page); in notify_unmap_cleanup()
594 cdev_mgtdev_pager_free_pages(gmap->map->mem); in notify_unmap_cleanup()
600 for (i = 0; i < gmap->count; i++) { in notify_unmap_cleanup()
601 gmap->grant_map_ops[i].handle = -1; in notify_unmap_cleanup()
602 gmap->grant_map_ops[i].host_addr = 0; in notify_unmap_cleanup()
605 if (gmap->map) { in notify_unmap_cleanup()
606 error = xenmem_free(gntdev_dev, gmap->map->pseudo_phys_res_id, in notify_unmap_cleanup()
607 gmap->map->pseudo_phys_res); in notify_unmap_cleanup()
611 free(gmap->map, M_GNTDEV); in notify_unmap_cleanup()
612 gmap->map = NULL; in notify_unmap_cleanup()
631 struct gntdev_gmap *gmap; in gntdev_map_grant_ref() local
638 gmap = malloc(sizeof(*gmap), M_GNTDEV, M_WAITOK | M_ZERO); in gntdev_map_grant_ref()
639 gmap->count = arg->count; in gntdev_map_grant_ref()
640 gmap->grant_map_ops = in gntdev_map_grant_ref()
649 free(gmap->grant_map_ops, M_GNTDEV); in gntdev_map_grant_ref()
650 free(gmap, M_GNTDEV); in gntdev_map_grant_ref()
653 gmap->grant_map_ops[i].dom = ref.domid; in gntdev_map_grant_ref()
654 gmap->grant_map_ops[i].ref = ref.ref; in gntdev_map_grant_ref()
655 gmap->grant_map_ops[i].handle = -1; in gntdev_map_grant_ref()
656 gmap->grant_map_ops[i].flags = GNTMAP_host_map; in gntdev_map_grant_ref()
659 error = get_file_offset(priv_user, arg->count, &gmap->file_index); in gntdev_map_grant_ref()
661 free(gmap->grant_map_ops, M_GNTDEV); in gntdev_map_grant_ref()
662 free(gmap, M_GNTDEV); in gntdev_map_grant_ref()
667 RB_INSERT(gmap_tree_head, &priv_user->gmap_tree, gmap); in gntdev_map_grant_ref()
670 arg->index = gmap->file_index; in gntdev_map_grant_ref()
686 struct gntdev_gmap *gmap; in gntdev_unmap_grant_ref() local
693 gmap = gntdev_find_gmap(priv_user, arg->index, arg->count); in gntdev_unmap_grant_ref()
694 if (gmap == NULL) { in gntdev_unmap_grant_ref()
701 RB_REMOVE(gmap_tree_head, &priv_user->gmap_tree, gmap); in gntdev_unmap_grant_ref()
702 STAILQ_INSERT_TAIL(&cleanup_data.to_kill_gmaps, gmap, gmap_next.list); in gntdev_unmap_grant_ref()
706 if (gmap->map) in gntdev_unmap_grant_ref()
707 vm_object_deallocate(gmap->map->mem); in gntdev_unmap_grant_ref()
736 struct gntdev_gmap *gmap; in gntdev_get_offset_for_vaddr() local
751 gmap = mem->handle; in gntdev_get_offset_for_vaddr()
752 if (gmap == NULL || in gntdev_get_offset_for_vaddr()
753 (entry->end - entry->start) != (gmap->count * PAGE_SIZE)) { in gntdev_get_offset_for_vaddr()
758 arg->count = gmap->count; in gntdev_get_offset_for_vaddr()
759 arg->offset = gmap->file_index; in gntdev_get_offset_for_vaddr()
788 struct gntdev_gmap *gmap = object->handle; in gntdev_gmap_pg_fault() local
793 if (gmap->map == NULL) in gntdev_gmap_pg_fault()
796 relative_offset = offset - gmap->file_index; in gntdev_gmap_pg_fault()
800 if (ridx >= gmap->count || in gntdev_gmap_pg_fault()
801 gmap->grant_map_ops[ridx].status != GNTST_okay) in gntdev_gmap_pg_fault()
804 page = PHYS_TO_VM_PAGE(gmap->map->phys_base_addr + relative_offset); in gntdev_gmap_pg_fault()
887 struct gntdev_gmap *gmap; in gntdev_set_unmap_notify() local
907 RB_FOREACH(gmap, gmap_tree_head, &priv_user->gmap_tree) { in gntdev_set_unmap_notify()
908 if (arg->index >= gmap->file_index && in gntdev_set_unmap_notify()
909 arg->index < gmap->file_index + gmap->count * PAGE_SIZE) { in gntdev_set_unmap_notify()
910 if (gmap->notify == NULL) in gntdev_set_unmap_notify()
911 gmap->notify = malloc(sizeof(*arg), M_GNTDEV, in gntdev_set_unmap_notify()
913 error = copy_notify_helper(gmap->notify, arg); in gntdev_set_unmap_notify()
936 struct gntdev_gmap *gmap, *gmap_tmp; in per_user_data_dtor() local
953 RB_FOREACH_SAFE(gmap, gmap_tree_head, &priv_user->gmap_tree, gmap_tmp) { in per_user_data_dtor()
954 RB_REMOVE(gmap_tree_head, &priv_user->gmap_tree, gmap); in per_user_data_dtor()
955 STAILQ_INSERT_TAIL(&cleanup_data.to_kill_gmaps, gmap, in per_user_data_dtor()
957 if (gmap->map) in per_user_data_dtor()
958 vm_object_deallocate(gmap->map->mem); in per_user_data_dtor()