/* Free all blocks associated with the releasing file_priv  */
void nouveau_mem_release(struct drm_file *file_priv, struct mem_block *heap)
/* Free all blocks associated with the releasing file_priv  */
void nouveau_mem_release(struct drm_file *file_priv, struct mem_block *heap)
{
	struct mem_block *p;
	if (!heap || !heap->next)
		return;
	list_for_each(p, heap) {
		if (p->file_priv == file_priv)
			p->file_priv = NULL;
	}
	list_for_each(p, heap) {
		while ((p->file_priv == NULL) &&
					(p->next->file_priv == NULL) &&
					(p->next != heap)) {
			struct mem_block *q = p->next;
			p->size += q->size;
			p->next = q->next;
			p->next->prev = p;
			kfree(q);
		}
	}
}