forked from Minki/linux
drm/msm: add msm_gem_get_and_pin_iova_range
This function allows pinning iova to a specific page range (for a6xx GMU). Signed-off-by: Jonathan Marek <jonathan@marek.ca> Reviewed-by: Jordan Crouse <jcrouse@codeaurora.org> Signed-off-by: Rob Clark <robdclark@chromium.org>
This commit is contained in:
parent
eadf79286a
commit
d3b8877e57
@ -237,7 +237,8 @@ int msm_crtc_enable_vblank(struct drm_crtc *crtc);
|
||||
void msm_crtc_disable_vblank(struct drm_crtc *crtc);
|
||||
|
||||
int msm_gem_init_vma(struct msm_gem_address_space *aspace,
|
||||
struct msm_gem_vma *vma, int npages);
|
||||
struct msm_gem_vma *vma, int npages,
|
||||
u64 range_start, u64 range_end);
|
||||
void msm_gem_purge_vma(struct msm_gem_address_space *aspace,
|
||||
struct msm_gem_vma *vma);
|
||||
void msm_gem_unmap_vma(struct msm_gem_address_space *aspace,
|
||||
@ -277,6 +278,9 @@ vm_fault_t msm_gem_fault(struct vm_fault *vmf);
|
||||
uint64_t msm_gem_mmap_offset(struct drm_gem_object *obj);
|
||||
int msm_gem_get_iova(struct drm_gem_object *obj,
|
||||
struct msm_gem_address_space *aspace, uint64_t *iova);
|
||||
int msm_gem_get_and_pin_iova_range(struct drm_gem_object *obj,
|
||||
struct msm_gem_address_space *aspace, uint64_t *iova,
|
||||
u64 range_start, u64 range_end);
|
||||
int msm_gem_get_and_pin_iova(struct drm_gem_object *obj,
|
||||
struct msm_gem_address_space *aspace, uint64_t *iova);
|
||||
uint64_t msm_gem_iova(struct drm_gem_object *obj,
|
||||
|
@ -389,7 +389,8 @@ put_iova(struct drm_gem_object *obj)
|
||||
}
|
||||
|
||||
static int msm_gem_get_iova_locked(struct drm_gem_object *obj,
|
||||
struct msm_gem_address_space *aspace, uint64_t *iova)
|
||||
struct msm_gem_address_space *aspace, uint64_t *iova,
|
||||
u64 range_start, u64 range_end)
|
||||
{
|
||||
struct msm_gem_object *msm_obj = to_msm_bo(obj);
|
||||
struct msm_gem_vma *vma;
|
||||
@ -404,7 +405,8 @@ static int msm_gem_get_iova_locked(struct drm_gem_object *obj,
|
||||
if (IS_ERR(vma))
|
||||
return PTR_ERR(vma);
|
||||
|
||||
ret = msm_gem_init_vma(aspace, vma, obj->size >> PAGE_SHIFT);
|
||||
ret = msm_gem_init_vma(aspace, vma, obj->size >> PAGE_SHIFT,
|
||||
range_start, range_end);
|
||||
if (ret) {
|
||||
del_vma(vma);
|
||||
return ret;
|
||||
@ -443,9 +445,13 @@ static int msm_gem_pin_iova(struct drm_gem_object *obj,
|
||||
msm_obj->sgt, obj->size >> PAGE_SHIFT);
|
||||
}
|
||||
|
||||
/* get iova and pin it. Should have a matching put */
|
||||
int msm_gem_get_and_pin_iova(struct drm_gem_object *obj,
|
||||
struct msm_gem_address_space *aspace, uint64_t *iova)
|
||||
/*
|
||||
* get iova and pin it. Should have a matching put
|
||||
* limits iova to specified range (in pages)
|
||||
*/
|
||||
int msm_gem_get_and_pin_iova_range(struct drm_gem_object *obj,
|
||||
struct msm_gem_address_space *aspace, uint64_t *iova,
|
||||
u64 range_start, u64 range_end)
|
||||
{
|
||||
struct msm_gem_object *msm_obj = to_msm_bo(obj);
|
||||
u64 local;
|
||||
@ -453,7 +459,8 @@ int msm_gem_get_and_pin_iova(struct drm_gem_object *obj,
|
||||
|
||||
mutex_lock(&msm_obj->lock);
|
||||
|
||||
ret = msm_gem_get_iova_locked(obj, aspace, &local);
|
||||
ret = msm_gem_get_iova_locked(obj, aspace, &local,
|
||||
range_start, range_end);
|
||||
|
||||
if (!ret)
|
||||
ret = msm_gem_pin_iova(obj, aspace);
|
||||
@ -465,6 +472,13 @@ int msm_gem_get_and_pin_iova(struct drm_gem_object *obj,
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* get iova and pin it. Should have a matching put */
|
||||
int msm_gem_get_and_pin_iova(struct drm_gem_object *obj,
|
||||
struct msm_gem_address_space *aspace, uint64_t *iova)
|
||||
{
|
||||
return msm_gem_get_and_pin_iova_range(obj, aspace, iova, 0, U64_MAX);
|
||||
}
|
||||
|
||||
/*
|
||||
* Get an iova but don't pin it. Doesn't need a put because iovas are currently
|
||||
* valid for the life of the object
|
||||
@ -476,7 +490,7 @@ int msm_gem_get_iova(struct drm_gem_object *obj,
|
||||
int ret;
|
||||
|
||||
mutex_lock(&msm_obj->lock);
|
||||
ret = msm_gem_get_iova_locked(obj, aspace, iova);
|
||||
ret = msm_gem_get_iova_locked(obj, aspace, iova, 0, U64_MAX);
|
||||
mutex_unlock(&msm_obj->lock);
|
||||
|
||||
return ret;
|
||||
|
@ -103,7 +103,8 @@ void msm_gem_close_vma(struct msm_gem_address_space *aspace,
|
||||
|
||||
/* Initialize a new vma and allocate an iova for it */
|
||||
int msm_gem_init_vma(struct msm_gem_address_space *aspace,
|
||||
struct msm_gem_vma *vma, int npages)
|
||||
struct msm_gem_vma *vma, int npages,
|
||||
u64 range_start, u64 range_end)
|
||||
{
|
||||
int ret;
|
||||
|
||||
@ -111,7 +112,8 @@ int msm_gem_init_vma(struct msm_gem_address_space *aspace,
|
||||
return -EBUSY;
|
||||
|
||||
spin_lock(&aspace->lock);
|
||||
ret = drm_mm_insert_node(&aspace->mm, &vma->node, npages);
|
||||
ret = drm_mm_insert_node_in_range(&aspace->mm, &vma->node, npages, 0,
|
||||
0, range_start, range_end, 0);
|
||||
spin_unlock(&aspace->lock);
|
||||
|
||||
if (ret)
|
||||
|
Loading…
Reference in New Issue
Block a user