Lines Matching refs:gmap
510 struct gntdev_gmap *gmap, *gmap_tmp, *gmap_previous; in gmap_list_dtor() local
518 STAILQ_FOREACH_SAFE(gmap, &tmp_gmaps, gmap_next.list, gmap_tmp) { in gmap_list_dtor()
519 if (gmap->map == NULL) { in gmap_list_dtor()
526 if (gmap->notify) in gmap_list_dtor()
527 free(gmap->notify, M_GNTDEV); in gmap_list_dtor()
528 free(gmap->grant_map_ops, M_GNTDEV); in gmap_list_dtor()
529 free(gmap, M_GNTDEV); in gmap_list_dtor()
532 gmap_previous = gmap; in gmap_list_dtor()
550 struct gntdev_gmap find_gmap, *gmap; in gntdev_find_gmap() local
555 gmap = RB_FIND(gmap_tree_head, &priv_user->gmap_tree, &find_gmap); in gntdev_find_gmap()
558 if (gmap != NULL && gmap->count == count) in gntdev_find_gmap()
559 return (gmap); in gntdev_find_gmap()
570 notify_unmap_cleanup(struct gntdev_gmap *gmap) in notify_unmap_cleanup() argument
577 unmap_ops = malloc(sizeof(struct gnttab_unmap_grant_ref) * gmap->count, in notify_unmap_cleanup()
582 for (i = 0; i < gmap->count; i++) { in notify_unmap_cleanup()
583 if (gmap->grant_map_ops[i].handle != -1) { in notify_unmap_cleanup()
584 unmap_ops[count].handle = gmap->grant_map_ops[i].handle; in notify_unmap_cleanup()
586 gmap->grant_map_ops[i].host_addr; in notify_unmap_cleanup()
593 if (count > 0 && gmap->notify) { in notify_unmap_cleanup()
597 page_offset = gmap->notify->index - gmap->file_index; in notify_unmap_cleanup()
598 page = PHYS_TO_VM_PAGE(gmap->map->phys_base_addr + page_offset); in notify_unmap_cleanup()
599 notify(gmap->notify, page); in notify_unmap_cleanup()
603 VM_OBJECT_WLOCK(gmap->map->mem); in notify_unmap_cleanup()
605 for (i = 0; i < gmap->count; i++) { in notify_unmap_cleanup()
606 m = vm_page_lookup(gmap->map->mem, i); in notify_unmap_cleanup()
611 cdev_pager_free_page(gmap->map->mem, m); in notify_unmap_cleanup()
613 VM_OBJECT_WUNLOCK(gmap->map->mem); in notify_unmap_cleanup()
619 for (i = 0; i < gmap->count; i++) { in notify_unmap_cleanup()
620 gmap->grant_map_ops[i].handle = -1; in notify_unmap_cleanup()
621 gmap->grant_map_ops[i].host_addr = 0; in notify_unmap_cleanup()
624 if (gmap->map) { in notify_unmap_cleanup()
625 error = xenmem_free(gntdev_dev, gmap->map->pseudo_phys_res_id, in notify_unmap_cleanup()
626 gmap->map->pseudo_phys_res); in notify_unmap_cleanup()
630 free(gmap->map, M_GNTDEV); in notify_unmap_cleanup()
631 gmap->map = NULL; in notify_unmap_cleanup()
650 struct gntdev_gmap *gmap; in gntdev_map_grant_ref() local
657 gmap = malloc(sizeof(*gmap), M_GNTDEV, M_WAITOK | M_ZERO); in gntdev_map_grant_ref()
658 gmap->count = arg->count; in gntdev_map_grant_ref()
659 gmap->grant_map_ops = in gntdev_map_grant_ref()
668 free(gmap->grant_map_ops, M_GNTDEV); in gntdev_map_grant_ref()
669 free(gmap, M_GNTDEV); in gntdev_map_grant_ref()
672 gmap->grant_map_ops[i].dom = ref.domid; in gntdev_map_grant_ref()
673 gmap->grant_map_ops[i].ref = ref.ref; in gntdev_map_grant_ref()
674 gmap->grant_map_ops[i].handle = -1; in gntdev_map_grant_ref()
675 gmap->grant_map_ops[i].flags = GNTMAP_host_map; in gntdev_map_grant_ref()
678 error = get_file_offset(priv_user, arg->count, &gmap->file_index); in gntdev_map_grant_ref()
680 free(gmap->grant_map_ops, M_GNTDEV); in gntdev_map_grant_ref()
681 free(gmap, M_GNTDEV); in gntdev_map_grant_ref()
686 RB_INSERT(gmap_tree_head, &priv_user->gmap_tree, gmap); in gntdev_map_grant_ref()
689 arg->index = gmap->file_index; in gntdev_map_grant_ref()
705 struct gntdev_gmap *gmap; in gntdev_unmap_grant_ref() local
712 gmap = gntdev_find_gmap(priv_user, arg->index, arg->count); in gntdev_unmap_grant_ref()
713 if (gmap == NULL) { in gntdev_unmap_grant_ref()
720 RB_REMOVE(gmap_tree_head, &priv_user->gmap_tree, gmap); in gntdev_unmap_grant_ref()
721 STAILQ_INSERT_TAIL(&cleanup_data.to_kill_gmaps, gmap, gmap_next.list); in gntdev_unmap_grant_ref()
725 if (gmap->map) in gntdev_unmap_grant_ref()
726 vm_object_deallocate(gmap->map->mem); in gntdev_unmap_grant_ref()
755 struct gntdev_gmap *gmap; in gntdev_get_offset_for_vaddr() local
770 gmap = mem->handle; in gntdev_get_offset_for_vaddr()
771 if (gmap == NULL || in gntdev_get_offset_for_vaddr()
772 (entry->end - entry->start) != (gmap->count * PAGE_SIZE)) { in gntdev_get_offset_for_vaddr()
777 arg->count = gmap->count; in gntdev_get_offset_for_vaddr()
778 arg->offset = gmap->file_index; in gntdev_get_offset_for_vaddr()
807 struct gntdev_gmap *gmap = object->handle; in gntdev_gmap_pg_fault() local
812 if (gmap->map == NULL) in gntdev_gmap_pg_fault()
815 relative_offset = offset - gmap->file_index; in gntdev_gmap_pg_fault()
819 if (ridx >= gmap->count || in gntdev_gmap_pg_fault()
820 gmap->grant_map_ops[ridx].status != GNTST_okay) in gntdev_gmap_pg_fault()
823 page = PHYS_TO_VM_PAGE(gmap->map->phys_base_addr + relative_offset); in gntdev_gmap_pg_fault()
911 struct gntdev_gmap *gmap; in gntdev_set_unmap_notify() local
931 RB_FOREACH(gmap, gmap_tree_head, &priv_user->gmap_tree) { in gntdev_set_unmap_notify()
932 if (arg->index >= gmap->file_index && in gntdev_set_unmap_notify()
933 arg->index < gmap->file_index + gmap->count * PAGE_SIZE) { in gntdev_set_unmap_notify()
934 if (gmap->notify == NULL) in gntdev_set_unmap_notify()
935 gmap->notify = malloc(sizeof(*arg), M_GNTDEV, in gntdev_set_unmap_notify()
937 error = copy_notify_helper(gmap->notify, arg); in gntdev_set_unmap_notify()
960 struct gntdev_gmap *gmap, *gmap_tmp; in per_user_data_dtor() local
977 RB_FOREACH_SAFE(gmap, gmap_tree_head, &priv_user->gmap_tree, gmap_tmp) { in per_user_data_dtor()
978 RB_REMOVE(gmap_tree_head, &priv_user->gmap_tree, gmap); in per_user_data_dtor()
979 STAILQ_INSERT_TAIL(&cleanup_data.to_kill_gmaps, gmap, in per_user_data_dtor()
981 if (gmap->map) in per_user_data_dtor()
982 vm_object_deallocate(gmap->map->mem); in per_user_data_dtor()