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()
176 static void __del_gref(struct gntalloc_gref *gref) in __del_gref() argument
180 if (gref->notify.flags & UNMAP_NOTIFY_CLEAR_BYTE) { in __del_gref()
181 uint8_t *tmp = kmap(gref->page); in __del_gref()
182 tmp[gref->notify.pgoff] = 0; in __del_gref()
183 kunmap(gref->page); in __del_gref()
185 if (gref->notify.flags & UNMAP_NOTIFY_SEND_EVENT) { in __del_gref()
186 notify_remote_via_evtchn(gref->notify.event); in __del_gref()
187 evtchn_put(gref->notify.event); in __del_gref()
190 gref->notify.flags = 0; in __del_gref()
192 if (gref->gref_id) { in __del_gref()
193 if (gref->page) { in __del_gref()
194 addr = (unsigned long)page_to_virt(gref->page); in __del_gref()
195 gnttab_end_foreign_access(gref->gref_id, 0, addr); in __del_gref()
197 gnttab_free_grant_reference(gref->gref_id); in __del_gref()
201 list_del(&gref->next_gref); in __del_gref()
203 kfree(gref); in __del_gref()
210 struct gntalloc_gref *rv = NULL, *gref; in find_grefs() local
211 list_for_each_entry(gref, &priv->list, next_file) { in find_grefs()
212 if (gref->file_index == index && !rv) in find_grefs()
213 rv = gref; in find_grefs()
215 if (gref->file_index != index) in find_grefs()
253 struct gntalloc_gref *gref; in gntalloc_release() local
259 gref = list_entry(priv->list.next, in gntalloc_release()
261 list_del(&gref->next_file); in gntalloc_release()
262 gref->users--; in gntalloc_release()
263 if (gref->users == 0) in gntalloc_release()
264 __del_gref(gref); in gntalloc_release()
340 struct gntalloc_gref *gref, *n; in gntalloc_ioctl_dealloc() local
350 gref = find_grefs(priv, op.index, op.count); in gntalloc_ioctl_dealloc()
351 if (gref) { in gntalloc_ioctl_dealloc()
357 n = list_entry(gref->next_file.next, in gntalloc_ioctl_dealloc()
359 list_del(&gref->next_file); in gntalloc_ioctl_dealloc()
360 gref->users--; in gntalloc_ioctl_dealloc()
361 gref = n; in gntalloc_ioctl_dealloc()
378 struct gntalloc_gref *gref; in gntalloc_ioctl_unmap_notify() local
391 gref = find_grefs(priv, index, 1); in gntalloc_ioctl_unmap_notify()
392 if (!gref) { in gntalloc_ioctl_unmap_notify()
416 if (gref->notify.flags & UNMAP_NOTIFY_SEND_EVENT) in gntalloc_ioctl_unmap_notify()
417 evtchn_put(gref->notify.event); in gntalloc_ioctl_unmap_notify()
419 gref->notify.flags = op.action; in gntalloc_ioctl_unmap_notify()
420 gref->notify.pgoff = pgoff; in gntalloc_ioctl_unmap_notify()
421 gref->notify.event = op.event_channel_port; in gntalloc_ioctl_unmap_notify()
466 struct gntalloc_gref *gref, *next; in gntalloc_vma_close() local
475 gref = priv->gref; in gntalloc_vma_close()
477 gref->users--; in gntalloc_vma_close()
478 next = list_entry(gref->next_gref.next, in gntalloc_vma_close()
480 if (gref->users == 0) in gntalloc_vma_close()
481 __del_gref(gref); in gntalloc_vma_close()
482 gref = next; in gntalloc_vma_close()
498 struct gntalloc_gref *gref; in gntalloc_mmap() local
516 gref = find_grefs(priv, vma->vm_pgoff << PAGE_SHIFT, count); in gntalloc_mmap()
517 if (gref == NULL) { in gntalloc_mmap()
525 vm_priv->gref = gref; in gntalloc_mmap()
536 gref->users++; in gntalloc_mmap()
538 gref->page); in gntalloc_mmap()
542 gref = list_entry(gref->next_file.next, in gntalloc_mmap()