mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2025-01-23 02:49:44 +07:00
drm: Add reservation_object to drm_gem_object
Many users of drm_gem_object embed a struct reservation_object into their subclassed struct, so let's add one to struct drm_gem_object. This will allow removing the reservation object from the subclasses and removing the ->gem_prime_res_obj callback. With the addition, add a drm_gem_reservation_object_wait() helper function for drivers to use in wait ioctls. Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com> Cc: Maxime Ripard <maxime.ripard@bootlin.com> Cc: Sean Paul <sean@poorly.run> Cc: David Airlie <airlied@linux.ie> Cc: Daniel Vetter <daniel@ffwll.ch> Signed-off-by: Rob Herring <robh@kernel.org> Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch> Reviewed-by: Eric Anholt <eric@anholt.net> Reviewed-by: Christian Gmeiner <christian.gmeiner@gmail.com> Link: https://patchwork.freedesktop.org/patch/msgid/20190202154158.10443-2-robh@kernel.org Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com>
This commit is contained in:
parent
1c1a7aa366
commit
1ba627148e
@ -215,12 +215,12 @@ Might be good to also have some igt testcases for this.
|
|||||||
|
|
||||||
Contact: Daniel Vetter, Noralf Tronnes
|
Contact: Daniel Vetter, Noralf Tronnes
|
||||||
|
|
||||||
Put a reservation_object into drm_gem_object
|
Remove the ->gem_prime_res_obj callback
|
||||||
--------------------------------------------
|
--------------------------------------------
|
||||||
|
|
||||||
This would remove the need for the ->gem_prime_res_obj callback. It would also
|
The ->gem_prime_res_obj callback can be removed from drivers by using the
|
||||||
allow us to implement generic helpers for waiting for a bo, allowing for quite a
|
reservation_object in the drm_gem_object. It may also be possible to use the
|
||||||
bit of refactoring in the various wait ioctl implementations.
|
generic drm_gem_reservation_object_wait helper for waiting for a bo.
|
||||||
|
|
||||||
Contact: Daniel Vetter
|
Contact: Daniel Vetter
|
||||||
|
|
||||||
|
@ -171,6 +171,10 @@ void drm_gem_private_object_init(struct drm_device *dev,
|
|||||||
kref_init(&obj->refcount);
|
kref_init(&obj->refcount);
|
||||||
obj->handle_count = 0;
|
obj->handle_count = 0;
|
||||||
obj->size = size;
|
obj->size = size;
|
||||||
|
reservation_object_init(&obj->_resv);
|
||||||
|
if (!obj->resv)
|
||||||
|
obj->resv = &obj->_resv;
|
||||||
|
|
||||||
drm_vma_node_reset(&obj->vma_node);
|
drm_vma_node_reset(&obj->vma_node);
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(drm_gem_private_object_init);
|
EXPORT_SYMBOL(drm_gem_private_object_init);
|
||||||
@ -687,6 +691,44 @@ drm_gem_object_lookup(struct drm_file *filp, u32 handle)
|
|||||||
}
|
}
|
||||||
EXPORT_SYMBOL(drm_gem_object_lookup);
|
EXPORT_SYMBOL(drm_gem_object_lookup);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* drm_gem_reservation_object_wait - Wait on GEM object's reservation's objects
|
||||||
|
* shared and/or exclusive fences.
|
||||||
|
* @filep: DRM file private date
|
||||||
|
* @handle: userspace handle
|
||||||
|
* @wait_all: if true, wait on all fences, else wait on just exclusive fence
|
||||||
|
* @timeout: timeout value in jiffies or zero to return immediately
|
||||||
|
*
|
||||||
|
* Returns:
|
||||||
|
*
|
||||||
|
* Returns -ERESTARTSYS if interrupted, 0 if the wait timed out, or
|
||||||
|
* greater than 0 on success.
|
||||||
|
*/
|
||||||
|
long drm_gem_reservation_object_wait(struct drm_file *filep, u32 handle,
|
||||||
|
bool wait_all, unsigned long timeout)
|
||||||
|
{
|
||||||
|
long ret;
|
||||||
|
struct drm_gem_object *obj;
|
||||||
|
|
||||||
|
obj = drm_gem_object_lookup(filep, handle);
|
||||||
|
if (!obj) {
|
||||||
|
DRM_DEBUG("Failed to look up GEM BO %d\n", handle);
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = reservation_object_wait_timeout_rcu(obj->resv, wait_all,
|
||||||
|
true, timeout);
|
||||||
|
if (ret == 0)
|
||||||
|
ret = -ETIME;
|
||||||
|
else if (ret > 0)
|
||||||
|
ret = 0;
|
||||||
|
|
||||||
|
drm_gem_object_put_unlocked(obj);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL(drm_gem_reservation_object_wait);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* drm_gem_close_ioctl - implementation of the GEM_CLOSE ioctl
|
* drm_gem_close_ioctl - implementation of the GEM_CLOSE ioctl
|
||||||
* @dev: drm_device
|
* @dev: drm_device
|
||||||
@ -851,6 +893,7 @@ drm_gem_object_release(struct drm_gem_object *obj)
|
|||||||
if (obj->filp)
|
if (obj->filp)
|
||||||
fput(obj->filp);
|
fput(obj->filp);
|
||||||
|
|
||||||
|
reservation_object_fini(&obj->_resv);
|
||||||
drm_gem_free_mmap_offset(obj);
|
drm_gem_free_mmap_offset(obj);
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(drm_gem_object_release);
|
EXPORT_SYMBOL(drm_gem_object_release);
|
||||||
|
@ -504,6 +504,7 @@ struct dma_buf *drm_gem_prime_export(struct drm_device *dev,
|
|||||||
.size = obj->size,
|
.size = obj->size,
|
||||||
.flags = flags,
|
.flags = flags,
|
||||||
.priv = obj,
|
.priv = obj,
|
||||||
|
.resv = obj->resv,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (dev->driver->gem_prime_res_obj)
|
if (dev->driver->gem_prime_res_obj)
|
||||||
|
@ -35,6 +35,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <linux/kref.h>
|
#include <linux/kref.h>
|
||||||
|
#include <linux/reservation.h>
|
||||||
|
|
||||||
#include <drm/drm_vma_manager.h>
|
#include <drm/drm_vma_manager.h>
|
||||||
|
|
||||||
@ -262,6 +263,24 @@ struct drm_gem_object {
|
|||||||
*/
|
*/
|
||||||
struct dma_buf_attachment *import_attach;
|
struct dma_buf_attachment *import_attach;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @resv:
|
||||||
|
*
|
||||||
|
* Pointer to reservation object associated with the this GEM object.
|
||||||
|
*
|
||||||
|
* Normally (@resv == &@_resv) except for imported GEM objects.
|
||||||
|
*/
|
||||||
|
struct reservation_object *resv;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @_resv:
|
||||||
|
*
|
||||||
|
* A reservation object for this GEM object.
|
||||||
|
*
|
||||||
|
* This is unused for imported GEM objects.
|
||||||
|
*/
|
||||||
|
struct reservation_object _resv;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @funcs:
|
* @funcs:
|
||||||
*
|
*
|
||||||
@ -363,6 +382,8 @@ void drm_gem_put_pages(struct drm_gem_object *obj, struct page **pages,
|
|||||||
bool dirty, bool accessed);
|
bool dirty, bool accessed);
|
||||||
|
|
||||||
struct drm_gem_object *drm_gem_object_lookup(struct drm_file *filp, u32 handle);
|
struct drm_gem_object *drm_gem_object_lookup(struct drm_file *filp, u32 handle);
|
||||||
|
long drm_gem_reservation_object_wait(struct drm_file *filep, u32 handle,
|
||||||
|
bool wait_all, unsigned long timeout);
|
||||||
int drm_gem_dumb_map_offset(struct drm_file *file, struct drm_device *dev,
|
int drm_gem_dumb_map_offset(struct drm_file *file, struct drm_device *dev,
|
||||||
u32 handle, u64 *offset);
|
u32 handle, u64 *offset);
|
||||||
int drm_gem_dumb_destroy(struct drm_file *file,
|
int drm_gem_dumb_destroy(struct drm_file *file,
|
||||||
|
Loading…
Reference in New Issue
Block a user