Lines Matching refs:gmap

503 	struct gntdev_gmap *gmap, *gmap_tmp, *gmap_previous;  in gmap_list_dtor()  local
511 STAILQ_FOREACH_SAFE(gmap, &tmp_gmaps, gmap_next.list, gmap_tmp) { in gmap_list_dtor()
512 if (gmap->map == NULL) { in gmap_list_dtor()
519 if (gmap->notify) in gmap_list_dtor()
520 free(gmap->notify, M_GNTDEV); in gmap_list_dtor()
521 free(gmap->grant_map_ops, M_GNTDEV); in gmap_list_dtor()
522 free(gmap, M_GNTDEV); in gmap_list_dtor()
525 gmap_previous = gmap; in gmap_list_dtor()
543 struct gntdev_gmap find_gmap, *gmap; in gntdev_find_gmap() local
548 gmap = RB_FIND(gmap_tree_head, &priv_user->gmap_tree, &find_gmap); in gntdev_find_gmap()
551 if (gmap != NULL && gmap->count == count) in gntdev_find_gmap()
552 return (gmap); in gntdev_find_gmap()
563 notify_unmap_cleanup(struct gntdev_gmap *gmap) in notify_unmap_cleanup() argument
570 unmap_ops = malloc(sizeof(struct gnttab_unmap_grant_ref) * gmap->count, in notify_unmap_cleanup()
575 for (i = 0; i < gmap->count; i++) { in notify_unmap_cleanup()
576 if (gmap->grant_map_ops[i].handle != -1) { in notify_unmap_cleanup()
577 unmap_ops[count].handle = gmap->grant_map_ops[i].handle; in notify_unmap_cleanup()
579 gmap->grant_map_ops[i].host_addr; in notify_unmap_cleanup()
586 if (count > 0 && gmap->notify) { in notify_unmap_cleanup()
590 page_offset = gmap->notify->index - gmap->file_index; in notify_unmap_cleanup()
591 page = PHYS_TO_VM_PAGE(gmap->map->phys_base_addr + page_offset); in notify_unmap_cleanup()
592 notify(gmap->notify, page); in notify_unmap_cleanup()
596 VM_OBJECT_WLOCK(gmap->map->mem); in notify_unmap_cleanup()
598 for (i = 0; i < gmap->count; i++) { in notify_unmap_cleanup()
599 m = vm_page_lookup(gmap->map->mem, i); in notify_unmap_cleanup()
604 cdev_pager_free_page(gmap->map->mem, m); in notify_unmap_cleanup()
606 VM_OBJECT_WUNLOCK(gmap->map->mem); in notify_unmap_cleanup()
612 for (i = 0; i < gmap->count; i++) { in notify_unmap_cleanup()
613 gmap->grant_map_ops[i].handle = -1; in notify_unmap_cleanup()
614 gmap->grant_map_ops[i].host_addr = 0; in notify_unmap_cleanup()
617 if (gmap->map) { in notify_unmap_cleanup()
618 error = xenmem_free(gntdev_dev, gmap->map->pseudo_phys_res_id, in notify_unmap_cleanup()
619 gmap->map->pseudo_phys_res); in notify_unmap_cleanup()
623 free(gmap->map, M_GNTDEV); in notify_unmap_cleanup()
624 gmap->map = NULL; in notify_unmap_cleanup()
643 struct gntdev_gmap *gmap; in gntdev_map_grant_ref() local
650 gmap = malloc(sizeof(*gmap), M_GNTDEV, M_WAITOK | M_ZERO); in gntdev_map_grant_ref()
651 gmap->count = arg->count; in gntdev_map_grant_ref()
652 gmap->grant_map_ops = 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()
665 gmap->grant_map_ops[i].dom = ref.domid; in gntdev_map_grant_ref()
666 gmap->grant_map_ops[i].ref = ref.ref; in gntdev_map_grant_ref()
667 gmap->grant_map_ops[i].handle = -1; in gntdev_map_grant_ref()
668 gmap->grant_map_ops[i].flags = GNTMAP_host_map; in gntdev_map_grant_ref()
671 error = get_file_offset(priv_user, arg->count, &gmap->file_index); in gntdev_map_grant_ref()
673 free(gmap->grant_map_ops, M_GNTDEV); in gntdev_map_grant_ref()
674 free(gmap, M_GNTDEV); in gntdev_map_grant_ref()
679 RB_INSERT(gmap_tree_head, &priv_user->gmap_tree, gmap); in gntdev_map_grant_ref()
682 arg->index = gmap->file_index; in gntdev_map_grant_ref()
698 struct gntdev_gmap *gmap; in gntdev_unmap_grant_ref() local
705 gmap = gntdev_find_gmap(priv_user, arg->index, arg->count); in gntdev_unmap_grant_ref()
706 if (gmap == NULL) { in gntdev_unmap_grant_ref()
713 RB_REMOVE(gmap_tree_head, &priv_user->gmap_tree, gmap); in gntdev_unmap_grant_ref()
714 STAILQ_INSERT_TAIL(&cleanup_data.to_kill_gmaps, gmap, gmap_next.list); in gntdev_unmap_grant_ref()
718 if (gmap->map) in gntdev_unmap_grant_ref()
719 vm_object_deallocate(gmap->map->mem); in gntdev_unmap_grant_ref()
748 struct gntdev_gmap *gmap; in gntdev_get_offset_for_vaddr() local
763 gmap = mem->handle; in gntdev_get_offset_for_vaddr()
764 if (gmap == NULL || in gntdev_get_offset_for_vaddr()
765 (entry->end - entry->start) != (gmap->count * PAGE_SIZE)) { in gntdev_get_offset_for_vaddr()
770 arg->count = gmap->count; in gntdev_get_offset_for_vaddr()
771 arg->offset = gmap->file_index; in gntdev_get_offset_for_vaddr()
800 struct gntdev_gmap *gmap = object->handle; in gntdev_gmap_pg_fault() local
805 if (gmap->map == NULL) in gntdev_gmap_pg_fault()
808 relative_offset = offset - gmap->file_index; in gntdev_gmap_pg_fault()
812 if (ridx >= gmap->count || in gntdev_gmap_pg_fault()
813 gmap->grant_map_ops[ridx].status != GNTST_okay) in gntdev_gmap_pg_fault()
816 page = PHYS_TO_VM_PAGE(gmap->map->phys_base_addr + relative_offset); in gntdev_gmap_pg_fault()
899 struct gntdev_gmap *gmap; in gntdev_set_unmap_notify() local
919 RB_FOREACH(gmap, gmap_tree_head, &priv_user->gmap_tree) { in gntdev_set_unmap_notify()
920 if (arg->index >= gmap->file_index && in gntdev_set_unmap_notify()
921 arg->index < gmap->file_index + gmap->count * PAGE_SIZE) { in gntdev_set_unmap_notify()
922 if (gmap->notify == NULL) in gntdev_set_unmap_notify()
923 gmap->notify = malloc(sizeof(*arg), M_GNTDEV, in gntdev_set_unmap_notify()
925 error = copy_notify_helper(gmap->notify, arg); in gntdev_set_unmap_notify()
948 struct gntdev_gmap *gmap, *gmap_tmp; in per_user_data_dtor() local
965 RB_FOREACH_SAFE(gmap, gmap_tree_head, &priv_user->gmap_tree, gmap_tmp) { in per_user_data_dtor()
966 RB_REMOVE(gmap_tree_head, &priv_user->gmap_tree, gmap); in per_user_data_dtor()
967 STAILQ_INSERT_TAIL(&cleanup_data.to_kill_gmaps, gmap, in per_user_data_dtor()
969 if (gmap->map) in per_user_data_dtor()
970 vm_object_deallocate(gmap->map->mem); in per_user_data_dtor()