freedreno/drm: Close bo handle after bo->destroy()

For userspace allocated iova, we want to give the backend a chance to
release the iova before the handle is closed.

Signed-off-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16086>
This commit is contained in:
Rob Clark 2022-03-25 09:29:41 -07:00 committed by Marge Bot
parent 4ed346c6fb
commit d52455a962

View file

@ -350,6 +350,9 @@ cleanup_fences(struct fd_bo *bo, bool expired)
void
bo_del(struct fd_bo *bo)
{
struct fd_device *dev = bo->dev;
uint32_t handle = bo->handle;
VG_BO_FREE(bo);
simple_mtx_assert_locked(&table_lock);
@ -361,21 +364,20 @@ bo_del(struct fd_bo *bo)
if (bo->map)
os_munmap(bo->map, bo->size);
/* TODO probably bo's in bucket list get removed from
* handle table??
*/
if (bo->handle) {
struct drm_gem_close req = {
.handle = bo->handle,
};
_mesa_hash_table_remove_key(bo->dev->handle_table, &bo->handle);
if (handle) {
_mesa_hash_table_remove_key(dev->handle_table, &handle);
if (bo->name)
_mesa_hash_table_remove_key(bo->dev->name_table, &bo->name);
drmIoctl(bo->dev->fd, DRM_IOCTL_GEM_CLOSE, &req);
_mesa_hash_table_remove_key(dev->name_table, &bo->name);
}
bo->funcs->destroy(bo);
if (handle) {
struct drm_gem_close req = {
.handle = handle,
};
drmIoctl(dev->fd, DRM_IOCTL_GEM_CLOSE, &req);
}
}
static void