Skip to content

Commit 10f7616

Browse files
committed
drm/msm: Do not unpin/evict exported dma-buf's
Our initial logic for excluding dma-bufs was not quite right. In particular we want msm_gem_get/put_pages() path used for exported dma-bufs to increment/decrement the pin-count. Also, in case the importer is vmap'ing the dma-buf, we need to be sure to update the object's status, because it is now no longer potentially evictable. Fixes: 63f17ef drm/msm: Support evicting GEM objects to swap Signed-off-by: Rob Clark <robdclark@chromium.org> Link: https://lore.kernel.org/r/20210426235326.1230125-1-robdclark@gmail.com Signed-off-by: Rob Clark <robdclark@chromium.org>
1 parent a29c8c0 commit 10f7616

2 files changed

Lines changed: 17 additions & 3 deletions

File tree

drivers/gpu/drm/msm/msm_gem.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,13 +190,25 @@ struct page **msm_gem_get_pages(struct drm_gem_object *obj)
190190
}
191191

192192
p = get_pages(obj);
193+
194+
if (!IS_ERR(p)) {
195+
msm_obj->pin_count++;
196+
update_inactive(msm_obj);
197+
}
198+
193199
msm_gem_unlock(obj);
194200
return p;
195201
}
196202

197203
void msm_gem_put_pages(struct drm_gem_object *obj)
198204
{
199-
/* when we start tracking the pin count, then do something here */
205+
struct msm_gem_object *msm_obj = to_msm_bo(obj);
206+
207+
msm_gem_lock(obj);
208+
msm_obj->pin_count--;
209+
GEM_WARN_ON(msm_obj->pin_count < 0);
210+
update_inactive(msm_obj);
211+
msm_gem_unlock(obj);
200212
}
201213

202214
int msm_gem_mmap_obj(struct drm_gem_object *obj,
@@ -646,6 +658,8 @@ static void *get_vaddr(struct drm_gem_object *obj, unsigned madv)
646658
ret = -ENOMEM;
647659
goto fail;
648660
}
661+
662+
update_inactive(msm_obj);
649663
}
650664

651665
return msm_obj->vaddr;

drivers/gpu/drm/msm/msm_gem.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ static inline bool is_active(struct msm_gem_object *msm_obj)
221221
/* imported/exported objects are not purgeable: */
222222
static inline bool is_unpurgeable(struct msm_gem_object *msm_obj)
223223
{
224-
return msm_obj->base.dma_buf && msm_obj->base.import_attach;
224+
return msm_obj->base.import_attach || msm_obj->pin_count;
225225
}
226226

227227
static inline bool is_purgeable(struct msm_gem_object *msm_obj)
@@ -271,7 +271,7 @@ static inline void mark_unpurgeable(struct msm_gem_object *msm_obj)
271271

272272
static inline bool is_unevictable(struct msm_gem_object *msm_obj)
273273
{
274-
return is_unpurgeable(msm_obj) || msm_obj->pin_count || msm_obj->vaddr;
274+
return is_unpurgeable(msm_obj) || msm_obj->vaddr;
275275
}
276276

277277
static inline void mark_evictable(struct msm_gem_object *msm_obj)

0 commit comments

Comments
 (0)