Lines Matching full:resource
32 return hash_32(handle.resource, VMCI_RESOURCE_HASH_BITS); in vmci_resource_hash()
36 * Gets a resource (if one exists) matching given handle from the hash table.
41 struct vmci_resource *r, *resource = NULL; in vmci_resource_lookup() local
48 u32 rid = r->handle.resource; in vmci_resource_lookup()
51 rid == handle.resource && in vmci_resource_lookup()
54 resource = r; in vmci_resource_lookup()
60 return resource; in vmci_resource_lookup()
64 * Find an unused resource ID and return it. The first
67 * Returns VMCI resource id on success, VMCI_INVALID_ID on failure.
77 * Generate a unique resource ID. Keep on trying until we wrap around in vmci_resource_find_id()
99 int vmci_resource_add(struct vmci_resource *resource, in vmci_resource_add() argument
109 if (handle.resource == VMCI_INVALID_ID) { in vmci_resource_add()
110 handle.resource = vmci_resource_find_id(handle.context, in vmci_resource_add()
112 if (handle.resource == VMCI_INVALID_ID) { in vmci_resource_add()
121 resource->handle = handle; in vmci_resource_add()
122 resource->type = resource_type; in vmci_resource_add()
123 INIT_HLIST_NODE(&resource->node); in vmci_resource_add()
124 kref_init(&resource->kref); in vmci_resource_add()
125 init_completion(&resource->done); in vmci_resource_add()
127 idx = vmci_resource_hash(resource->handle); in vmci_resource_add()
128 hlist_add_head_rcu(&resource->node, &vmci_resource_table.entries[idx]); in vmci_resource_add()
137 void vmci_resource_remove(struct vmci_resource *resource) in vmci_resource_remove() argument
139 struct vmci_handle handle = resource->handle; in vmci_resource_remove()
143 /* Remove resource from hash table. */ in vmci_resource_remove()
147 if (vmci_handle_is_equal(r->handle, resource->handle) && in vmci_resource_remove()
148 resource->type == r->type) { in vmci_resource_remove()
157 vmci_resource_put(resource); in vmci_resource_remove()
158 wait_for_completion(&resource->done); in vmci_resource_remove()
165 struct vmci_resource *r, *resource = NULL; in vmci_resource_by_handle() local
173 resource = vmci_resource_get(r); in vmci_resource_by_handle()
178 return resource; in vmci_resource_by_handle()
182 * Get a reference to given resource.
184 struct vmci_resource *vmci_resource_get(struct vmci_resource *resource) in vmci_resource_get() argument
186 kref_get(&resource->kref); in vmci_resource_get()
188 return resource; in vmci_resource_get()
193 struct vmci_resource *resource = in vmci_release_resource() local
196 /* Verify the resource has been unlinked from hash table */ in vmci_release_resource()
197 WARN_ON(!hlist_unhashed(&resource->node)); in vmci_release_resource()
199 /* Signal that container of this resource can now be destroyed */ in vmci_release_resource()
200 complete(&resource->done); in vmci_release_resource()
204 * Resource's release function will get called if last reference.
206 * can increment the count again (it's gone from the resource hash
209 int vmci_resource_put(struct vmci_resource *resource) in vmci_resource_put() argument
215 return kref_put(&resource->kref, vmci_release_resource) ? in vmci_resource_put()
219 struct vmci_handle vmci_resource_handle(struct vmci_resource *resource) in vmci_resource_handle() argument
221 return resource->handle; in vmci_resource_handle()