mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-08 09:08:10 +02:00
iris/bufmgr: Move iris_bo_reference into hash_find_bo, rename it
Everybody importing an external buffer was looking it up in the hash table, then referencing it. We can just do that in the helper instead, which also gives us a convenient spot to stash extra code shortly.
This commit is contained in:
parent
4f75ea57c2
commit
48e5a99d86
1 changed files with 16 additions and 14 deletions
|
|
@ -173,10 +173,18 @@ key_uint_equal(const void *a, const void *b)
|
|||
}
|
||||
|
||||
static struct iris_bo *
|
||||
hash_find_bo(struct hash_table *ht, unsigned int key)
|
||||
find_and_ref_external_bo(struct hash_table *ht, unsigned int key)
|
||||
{
|
||||
struct hash_entry *entry = _mesa_hash_table_search(ht, &key);
|
||||
return entry ? (struct iris_bo *) entry->data : NULL;
|
||||
struct iris_bo *bo = entry ? entry->data : NULL;
|
||||
|
||||
if (bo) {
|
||||
assert(bo->external);
|
||||
|
||||
iris_bo_reference(bo);
|
||||
}
|
||||
|
||||
return bo;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -628,11 +636,9 @@ iris_bo_gem_create_from_name(struct iris_bufmgr *bufmgr,
|
|||
* provides a sufficiently fast match.
|
||||
*/
|
||||
mtx_lock(&bufmgr->lock);
|
||||
bo = hash_find_bo(bufmgr->name_table, handle);
|
||||
if (bo) {
|
||||
iris_bo_reference(bo);
|
||||
bo = find_and_ref_external_bo(bufmgr->name_table, handle);
|
||||
if (bo)
|
||||
goto out;
|
||||
}
|
||||
|
||||
struct drm_gem_open open_arg = { .name = handle };
|
||||
int ret = gen_ioctl(bufmgr->fd, DRM_IOCTL_GEM_OPEN, &open_arg);
|
||||
|
|
@ -646,11 +652,9 @@ iris_bo_gem_create_from_name(struct iris_bufmgr *bufmgr,
|
|||
* object from the kernel before by looking through the list
|
||||
* again for a matching gem_handle
|
||||
*/
|
||||
bo = hash_find_bo(bufmgr->handle_table, open_arg.handle);
|
||||
if (bo) {
|
||||
iris_bo_reference(bo);
|
||||
bo = find_and_ref_external_bo(bufmgr->handle_table, open_arg.handle);
|
||||
if (bo)
|
||||
goto out;
|
||||
}
|
||||
|
||||
bo = bo_calloc();
|
||||
if (!bo)
|
||||
|
|
@ -1275,11 +1279,9 @@ iris_bo_import_dmabuf(struct iris_bufmgr *bufmgr, int prime_fd)
|
|||
* for named buffers, we must not create two bo's pointing at the same
|
||||
* kernel object
|
||||
*/
|
||||
bo = hash_find_bo(bufmgr->handle_table, handle);
|
||||
if (bo) {
|
||||
iris_bo_reference(bo);
|
||||
bo = find_and_ref_external_bo(bufmgr->handle_table, handle);
|
||||
if (bo)
|
||||
goto out;
|
||||
}
|
||||
|
||||
bo = bo_calloc();
|
||||
if (!bo)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue