Lines Matching refs:gref
105 struct gntalloc_gref *gref; member
110 static void __del_gref(struct gntalloc_gref *gref);
114 struct gntalloc_gref *gref, *n; in do_cleanup() local
115 list_for_each_entry_safe(gref, n, &gref_list, next_gref) { in do_cleanup()
116 if (!gref->users) in do_cleanup()
117 __del_gref(gref); in do_cleanup()
127 struct gntalloc_gref *gref, *next; in add_grefs() local
131 gref = kzalloc(sizeof(*gref), GFP_KERNEL); in add_grefs()
132 if (!gref) { in add_grefs()
136 list_add_tail(&gref->next_gref, &queue_gref); in add_grefs()
137 list_add_tail(&gref->next_file, &queue_file); in add_grefs()
138 gref->users = 1; in add_grefs()
139 gref->file_index = op->index + i * PAGE_SIZE; in add_grefs()
140 gref->page = alloc_page(GFP_KERNEL|__GFP_ZERO); in add_grefs()
141 if (!gref->page) { in add_grefs()
148 xen_page_to_gfn(gref->page), in add_grefs()
152 gref_ids[i] = gref->gref_id = rc; in add_grefs()
167 list_for_each_entry_safe(gref, next, &queue_file, next_file) { in add_grefs()
168 list_del(&gref->next_file); in add_grefs()
169 __del_gref(gref); in add_grefs()
184 static void __del_gref(struct gntalloc_gref *gref) in __del_gref() argument
186 if (gref->notify.flags & UNMAP_NOTIFY_CLEAR_BYTE) { in __del_gref()
187 uint8_t *tmp = kmap(gref->page); in __del_gref()
188 tmp[gref->notify.pgoff] = 0; in __del_gref()
189 kunmap(gref->page); in __del_gref()
191 if (gref->notify.flags & UNMAP_NOTIFY_SEND_EVENT) { in __del_gref()
192 notify_remote_via_evtchn(gref->notify.event); in __del_gref()
193 evtchn_put(gref->notify.event); in __del_gref()
196 gref->notify.flags = 0; in __del_gref()
198 if (gref->gref_id) { in __del_gref()
199 if (gnttab_query_foreign_access(gref->gref_id)) in __del_gref()
202 if (!gnttab_end_foreign_access_ref(gref->gref_id, 0)) in __del_gref()
205 gnttab_free_grant_reference(gref->gref_id); in __del_gref()
209 list_del(&gref->next_gref); in __del_gref()
211 if (gref->page) in __del_gref()
212 __free_page(gref->page); in __del_gref()
214 kfree(gref); in __del_gref()
221 struct gntalloc_gref *rv = NULL, *gref; in find_grefs() local
222 list_for_each_entry(gref, &priv->list, next_file) { in find_grefs()
223 if (gref->file_index == index && !rv) in find_grefs()
224 rv = gref; in find_grefs()
226 if (gref->file_index != index) in find_grefs()
264 struct gntalloc_gref *gref; in gntalloc_release() local
270 gref = list_entry(priv->list.next, in gntalloc_release()
272 list_del(&gref->next_file); in gntalloc_release()
273 gref->users--; in gntalloc_release()
274 if (gref->users == 0) in gntalloc_release()
275 __del_gref(gref); in gntalloc_release()
351 struct gntalloc_gref *gref, *n; in gntalloc_ioctl_dealloc() local
361 gref = find_grefs(priv, op.index, op.count); in gntalloc_ioctl_dealloc()
362 if (gref) { in gntalloc_ioctl_dealloc()
368 n = list_entry(gref->next_file.next, in gntalloc_ioctl_dealloc()
370 list_del(&gref->next_file); in gntalloc_ioctl_dealloc()
371 gref->users--; in gntalloc_ioctl_dealloc()
372 gref = n; in gntalloc_ioctl_dealloc()
389 struct gntalloc_gref *gref; in gntalloc_ioctl_unmap_notify() local
402 gref = find_grefs(priv, index, 1); in gntalloc_ioctl_unmap_notify()
403 if (!gref) { in gntalloc_ioctl_unmap_notify()
427 if (gref->notify.flags & UNMAP_NOTIFY_SEND_EVENT) in gntalloc_ioctl_unmap_notify()
428 evtchn_put(gref->notify.event); in gntalloc_ioctl_unmap_notify()
430 gref->notify.flags = op.action; in gntalloc_ioctl_unmap_notify()
431 gref->notify.pgoff = pgoff; in gntalloc_ioctl_unmap_notify()
432 gref->notify.event = op.event_channel_port; in gntalloc_ioctl_unmap_notify()
477 struct gntalloc_gref *gref, *next; in gntalloc_vma_close() local
486 gref = priv->gref; in gntalloc_vma_close()
488 gref->users--; in gntalloc_vma_close()
489 next = list_entry(gref->next_gref.next, in gntalloc_vma_close()
491 if (gref->users == 0) in gntalloc_vma_close()
492 __del_gref(gref); in gntalloc_vma_close()
493 gref = next; in gntalloc_vma_close()
509 struct gntalloc_gref *gref; in gntalloc_mmap() local
527 gref = find_grefs(priv, vma->vm_pgoff << PAGE_SHIFT, count); in gntalloc_mmap()
528 if (gref == NULL) { in gntalloc_mmap()
536 vm_priv->gref = gref; in gntalloc_mmap()
547 gref->users++; in gntalloc_mmap()
549 gref->page); in gntalloc_mmap()
553 gref = list_entry(gref->next_file.next, in gntalloc_mmap()