/bsd-core/

pt">) { struct drm_reg *entry, *next_entry; int ret; *reg = NULL; /* * Search the unfenced list. */ list_for_each_entry(entry, &manager->unfenced, head) { if (manager->reg_reusable(entry, data)) { entry->new_fence_type |= fence_type; goto out; } } /* * Search the lru list. */ list_for_each_entry_safe(entry, next_entry, &manager->lru, head) { struct drm_fence_object *fence = entry->fence; if (fence->fence_class == fence_class && (entry->fence_type & fence_type) == entry->fence_type && manager->reg_reusable(entry, data)) { list_del(&entry->head); entry->new_fence_type = fence_type; list_add_tail(&entry->head, &manager->unfenced); goto out; } } /* * Search the free list. */ list_for_each_entry(entry, &manager->free, head) { list_del(&entry->head); entry->new_fence_type = fence_type; list_add_tail(&entry->head, &manager->unfenced); goto out; } if (no_wait) return -EBUSY; /* * Go back to the lru list and try to expire fences. */ list_for_each_entry_safe(entry, next_entry, &manager->lru, head) { BUG_ON(!entry->fence); ret = drm_fence_object_wait(entry->fence, 0, !interruptible, entry->fence_type); if (ret) return ret; drm_fence_usage_deref_unlocked(&entry->fence); list_del(&entry->head); entry->new_fence_type = fence_type; list_add_tail(&entry->head, &manager->unfenced); goto out; } /* * Oops. All registers are used up :(. */ return -EBUSY; out: *reg = entry; return 0; } EXPORT_SYMBOL(drm_regs_alloc); void drm_regs_fence(struct drm_reg_manager *manager, struct drm_fence_object *fence) { struct drm_reg *entry; struct drm_reg *next_entry; if (!fence) { /* * Old fence (if any) is still valid. * Put back on free and lru lists. */ list_for_each_entry_safe_reverse(entry, next_entry, &manager->unfenced, head) { list_del(&entry->head); list_add(&entry->head, (entry->fence) ? &manager->lru : &manager->free); } } else {