mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-18 11:16:42 +07:00
drm/vma_manage: Drop has_offset
It's racy, creating mmap offsets is a slowpath, so better to remove it to avoid drivers doing broken things. The only user is i915, and it's ok there because everything (well almost) is protected by dev->struct_mutex in i915-gem. While at it add a note in the create_mmap_offset kerneldoc that drivers must release it again. And then I also noticed that drm_gem_object_release entirely lacks kerneldoc. Cc: David Herrmann <dh.herrmann@gmail.com> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com> Link: http://patchwork.freedesktop.org/patch/msgid/1459330852-27668-14-git-send-email-daniel.vetter@ffwll.ch
This commit is contained in:
parent
0797ac6181
commit
f74418a400
@ -422,6 +422,10 @@ EXPORT_SYMBOL(drm_gem_handle_create);
|
||||
* @obj: obj in question
|
||||
*
|
||||
* This routine frees fake offsets allocated by drm_gem_create_mmap_offset().
|
||||
*
|
||||
* Note that drm_gem_object_release() already calls this function, so drivers
|
||||
* don't have to take care of releasing the mmap offset themselves when freeing
|
||||
* the GEM object.
|
||||
*/
|
||||
void
|
||||
drm_gem_free_mmap_offset(struct drm_gem_object *obj)
|
||||
@ -445,6 +449,9 @@ EXPORT_SYMBOL(drm_gem_free_mmap_offset);
|
||||
* This routine allocates and attaches a fake offset for @obj, in cases where
|
||||
* the virtual size differs from the physical size (ie. obj->size). Otherwise
|
||||
* just use drm_gem_create_mmap_offset().
|
||||
*
|
||||
* This function is idempotent and handles an already allocated mmap offset
|
||||
* transparently. Drivers do not need to check for this case.
|
||||
*/
|
||||
int
|
||||
drm_gem_create_mmap_offset_size(struct drm_gem_object *obj, size_t size)
|
||||
@ -466,6 +473,9 @@ EXPORT_SYMBOL(drm_gem_create_mmap_offset_size);
|
||||
* structures.
|
||||
*
|
||||
* This routine allocates and attaches a fake offset for @obj.
|
||||
*
|
||||
* Drivers can call drm_gem_free_mmap_offset() before freeing @obj to release
|
||||
* the fake offset again.
|
||||
*/
|
||||
int drm_gem_create_mmap_offset(struct drm_gem_object *obj)
|
||||
{
|
||||
@ -759,6 +769,13 @@ drm_gem_release(struct drm_device *dev, struct drm_file *file_private)
|
||||
idr_destroy(&file_private->object_idr);
|
||||
}
|
||||
|
||||
/**
|
||||
* drm_gem_object_release - release GEM buffer object resources
|
||||
* @obj: GEM buffer object
|
||||
*
|
||||
* This releases any structures and resources used by @obj and is the invers of
|
||||
* drm_gem_object_init().
|
||||
*/
|
||||
void
|
||||
drm_gem_object_release(struct drm_gem_object *obj)
|
||||
{
|
||||
|
@ -2031,9 +2031,6 @@ static int i915_gem_object_create_mmap_offset(struct drm_i915_gem_object *obj)
|
||||
struct drm_i915_private *dev_priv = obj->base.dev->dev_private;
|
||||
int ret;
|
||||
|
||||
if (drm_vma_node_has_offset(&obj->base.vma_node))
|
||||
return 0;
|
||||
|
||||
dev_priv->mm.shrinker_no_lock_stealing = true;
|
||||
|
||||
ret = drm_gem_create_mmap_offset(&obj->base);
|
||||
|
@ -175,19 +175,6 @@ static inline unsigned long drm_vma_node_size(struct drm_vma_offset_node *node)
|
||||
return node->vm_node.size;
|
||||
}
|
||||
|
||||
/**
|
||||
* drm_vma_node_has_offset() - Check whether node is added to offset manager
|
||||
* @node: Node to be checked
|
||||
*
|
||||
* RETURNS:
|
||||
* true iff the node was previously allocated an offset and added to
|
||||
* an vma offset manager.
|
||||
*/
|
||||
static inline bool drm_vma_node_has_offset(struct drm_vma_offset_node *node)
|
||||
{
|
||||
return drm_mm_node_allocated(&node->vm_node);
|
||||
}
|
||||
|
||||
/**
|
||||
* drm_vma_node_offset_addr() - Return sanitized offset for user-space mmaps
|
||||
* @node: Linked offset node
|
||||
@ -220,7 +207,7 @@ static inline __u64 drm_vma_node_offset_addr(struct drm_vma_offset_node *node)
|
||||
static inline void drm_vma_node_unmap(struct drm_vma_offset_node *node,
|
||||
struct address_space *file_mapping)
|
||||
{
|
||||
if (drm_vma_node_has_offset(node))
|
||||
if (drm_mm_node_allocated(&node->vm_node))
|
||||
unmap_mapping_range(file_mapping,
|
||||
drm_vma_node_offset_addr(node),
|
||||
drm_vma_node_size(node) << PAGE_SHIFT, 1);
|
||||
|
Loading…
Reference in New Issue
Block a user