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
132 gref = kzalloc(sizeof(*gref), GFP_KERNEL); in add_grefs()
133 if (!gref) in add_grefs()
135 list_add_tail(&gref->next_gref, &queue_gref); in add_grefs()
136 list_add_tail(&gref->next_file, &queue_file); in add_grefs()
137 gref->users = 1; in add_grefs()
138 gref->file_index = op->index + i * PAGE_SIZE; in add_grefs()
139 gref->page = alloc_page(GFP_KERNEL|__GFP_ZERO); in add_grefs()
140 if (!gref->page) in add_grefs()
145 pfn_to_mfn(page_to_pfn(gref->page)), readonly); in add_grefs()
148 gref_ids[i] = gref->gref_id = rc; in add_grefs()
163 list_for_each_entry_safe(gref, next, &queue_file, next_file) { in add_grefs()
164 list_del(&gref->next_file); in add_grefs()
165 __del_gref(gref); in add_grefs()
180 static void __del_gref(struct gntalloc_gref *gref) in __del_gref() argument
182 if (gref->notify.flags & UNMAP_NOTIFY_CLEAR_BYTE) { in __del_gref()
183 uint8_t *tmp = kmap(gref->page); in __del_gref()
184 tmp[gref->notify.pgoff] = 0; in __del_gref()
185 kunmap(gref->page); in __del_gref()
187 if (gref->notify.flags & UNMAP_NOTIFY_SEND_EVENT) { in __del_gref()
188 notify_remote_via_evtchn(gref->notify.event); in __del_gref()
189 evtchn_put(gref->notify.event); in __del_gref()
192 gref->notify.flags = 0; in __del_gref()
194 if (gref->gref_id) { in __del_gref()
195 if (gnttab_query_foreign_access(gref->gref_id)) in __del_gref()
198 if (!gnttab_end_foreign_access_ref(gref->gref_id, 0)) in __del_gref()
201 gnttab_free_grant_reference(gref->gref_id); in __del_gref()
205 list_del(&gref->next_gref); in __del_gref()
207 if (gref->page) in __del_gref()
208 __free_page(gref->page); in __del_gref()
210 kfree(gref); in __del_gref()
217 struct gntalloc_gref *rv = NULL, *gref; in find_grefs() local
218 list_for_each_entry(gref, &priv->list, next_file) { in find_grefs()
219 if (gref->file_index == index && !rv) in find_grefs()
220 rv = gref; in find_grefs()
222 if (gref->file_index != index) in find_grefs()
260 struct gntalloc_gref *gref; in gntalloc_release() local
266 gref = list_entry(priv->list.next, in gntalloc_release()
268 list_del(&gref->next_file); in gntalloc_release()
269 gref->users--; in gntalloc_release()
270 if (gref->users == 0) in gntalloc_release()
271 __del_gref(gref); in gntalloc_release()
347 struct gntalloc_gref *gref, *n; in gntalloc_ioctl_dealloc() local
357 gref = find_grefs(priv, op.index, op.count); in gntalloc_ioctl_dealloc()
358 if (gref) { in gntalloc_ioctl_dealloc()
364 n = list_entry(gref->next_file.next, in gntalloc_ioctl_dealloc()
366 list_del(&gref->next_file); in gntalloc_ioctl_dealloc()
367 gref->users--; in gntalloc_ioctl_dealloc()
368 gref = n; in gntalloc_ioctl_dealloc()
385 struct gntalloc_gref *gref; in gntalloc_ioctl_unmap_notify() local
398 gref = find_grefs(priv, index, 1); in gntalloc_ioctl_unmap_notify()
399 if (!gref) { in gntalloc_ioctl_unmap_notify()
423 if (gref->notify.flags & UNMAP_NOTIFY_SEND_EVENT) in gntalloc_ioctl_unmap_notify()
424 evtchn_put(gref->notify.event); in gntalloc_ioctl_unmap_notify()
426 gref->notify.flags = op.action; in gntalloc_ioctl_unmap_notify()
427 gref->notify.pgoff = pgoff; in gntalloc_ioctl_unmap_notify()
428 gref->notify.event = op.event_channel_port; in gntalloc_ioctl_unmap_notify()
473 struct gntalloc_gref *gref, *next; in gntalloc_vma_close() local
482 gref = priv->gref; in gntalloc_vma_close()
484 gref->users--; in gntalloc_vma_close()
485 next = list_entry(gref->next_gref.next, in gntalloc_vma_close()
487 if (gref->users == 0) in gntalloc_vma_close()
488 __del_gref(gref); in gntalloc_vma_close()
489 gref = next; in gntalloc_vma_close()
505 struct gntalloc_gref *gref; in gntalloc_mmap() local
523 gref = find_grefs(priv, vma->vm_pgoff << PAGE_SHIFT, count); in gntalloc_mmap()
524 if (gref == NULL) { in gntalloc_mmap()
532 vm_priv->gref = gref; in gntalloc_mmap()
543 gref->users++; in gntalloc_mmap()
545 gref->page); in gntalloc_mmap()
549 gref = list_entry(gref->next_file.next, in gntalloc_mmap()