Commit d413e6f9 authored by Rob Clark's avatar Rob Clark

drm/msm: Drop msm_gem_iova()

There was only a single user, which could just as easily stash the iova
when pinning.

v2: fix prepare->prepare->cleanup->cleanup sequences
Signed-off-by: default avatarRob Clark <robdclark@chromium.org>
Reviewed-by: default avatarDmitry Baryshkov <dmitry.baryshkov@linaro.org>
Link: https://lore.kernel.org/r/20220411215849.297838-7-robdclark@gmail.comSigned-off-by: default avatarRob Clark <robdclark@chromium.org>
parent 2ee4b5d2
...@@ -21,6 +21,10 @@ struct msm_framebuffer { ...@@ -21,6 +21,10 @@ struct msm_framebuffer {
/* Count of # of attached planes which need dirtyfb: */ /* Count of # of attached planes which need dirtyfb: */
refcount_t dirtyfb; refcount_t dirtyfb;
/* Framebuffer per-plane address, if pinned, else zero: */
uint64_t iova[DRM_FORMAT_MAX_PLANES];
atomic_t prepare_count;
}; };
#define to_msm_framebuffer(x) container_of(x, struct msm_framebuffer, base) #define to_msm_framebuffer(x) container_of(x, struct msm_framebuffer, base)
...@@ -76,14 +80,16 @@ int msm_framebuffer_prepare(struct drm_framebuffer *fb, ...@@ -76,14 +80,16 @@ int msm_framebuffer_prepare(struct drm_framebuffer *fb,
{ {
struct msm_framebuffer *msm_fb = to_msm_framebuffer(fb); struct msm_framebuffer *msm_fb = to_msm_framebuffer(fb);
int ret, i, n = fb->format->num_planes; int ret, i, n = fb->format->num_planes;
uint64_t iova;
if (needs_dirtyfb) if (needs_dirtyfb)
refcount_inc(&msm_fb->dirtyfb); refcount_inc(&msm_fb->dirtyfb);
atomic_inc(&msm_fb->prepare_count);
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
ret = msm_gem_get_and_pin_iova(fb->obj[i], aspace, &iova); ret = msm_gem_get_and_pin_iova(fb->obj[i], aspace, &msm_fb->iova[i]);
drm_dbg_state(fb->dev, "FB[%u]: iova[%d]: %08llx (%d)", fb->base.id, i, iova, ret); drm_dbg_state(fb->dev, "FB[%u]: iova[%d]: %08llx (%d)",
fb->base.id, i, msm_fb->iova[i], ret);
if (ret) if (ret)
return ret; return ret;
} }
...@@ -103,14 +109,16 @@ void msm_framebuffer_cleanup(struct drm_framebuffer *fb, ...@@ -103,14 +109,16 @@ void msm_framebuffer_cleanup(struct drm_framebuffer *fb,
for (i = 0; i < n; i++) for (i = 0; i < n; i++)
msm_gem_unpin_iova(fb->obj[i], aspace); msm_gem_unpin_iova(fb->obj[i], aspace);
if (!atomic_dec_return(&msm_fb->prepare_count))
memset(msm_fb->iova, 0, sizeof(msm_fb->iova));
} }
uint32_t msm_framebuffer_iova(struct drm_framebuffer *fb, uint32_t msm_framebuffer_iova(struct drm_framebuffer *fb,
struct msm_gem_address_space *aspace, int plane) struct msm_gem_address_space *aspace, int plane)
{ {
if (!fb->obj[plane]) struct msm_framebuffer *msm_fb = to_msm_framebuffer(fb);
return 0; return msm_fb->iova[plane];
return msm_gem_iova(fb->obj[plane], aspace) + fb->offsets[plane];
} }
struct drm_gem_object *msm_framebuffer_bo(struct drm_framebuffer *fb, int plane) struct drm_gem_object *msm_framebuffer_bo(struct drm_framebuffer *fb, int plane)
......
...@@ -509,22 +509,6 @@ int msm_gem_get_iova(struct drm_gem_object *obj, ...@@ -509,22 +509,6 @@ int msm_gem_get_iova(struct drm_gem_object *obj,
return ret; return ret;
} }
/* get iova without taking a reference, used in places where you have
* already done a 'msm_gem_get_and_pin_iova' or 'msm_gem_get_iova'
*/
uint64_t msm_gem_iova(struct drm_gem_object *obj,
struct msm_gem_address_space *aspace)
{
struct msm_gem_vma *vma;
msm_gem_lock(obj);
vma = lookup_vma(obj, aspace);
msm_gem_unlock(obj);
GEM_WARN_ON(!vma);
return vma ? vma->iova : 0;
}
/* /*
* Locked variant of msm_gem_unpin_iova() * Locked variant of msm_gem_unpin_iova()
*/ */
......
...@@ -142,8 +142,6 @@ int msm_gem_get_and_pin_iova_locked(struct drm_gem_object *obj, ...@@ -142,8 +142,6 @@ int msm_gem_get_and_pin_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);
int msm_gem_get_and_pin_iova(struct drm_gem_object *obj, int msm_gem_get_and_pin_iova(struct drm_gem_object *obj,
struct msm_gem_address_space *aspace, uint64_t *iova); struct msm_gem_address_space *aspace, uint64_t *iova);
uint64_t msm_gem_iova(struct drm_gem_object *obj,
struct msm_gem_address_space *aspace);
void msm_gem_unpin_iova_locked(struct drm_gem_object *obj, void msm_gem_unpin_iova_locked(struct drm_gem_object *obj,
struct msm_gem_address_space *aspace); struct msm_gem_address_space *aspace);
void msm_gem_unpin_iova(struct drm_gem_object *obj, void msm_gem_unpin_iova(struct drm_gem_object *obj,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment