summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/msm/msm_gem.h
diff options
context:
space:
mode:
authorRob Clark <robdclark@chromium.org>2021-04-05 10:45:29 -0700
committerRob Clark <robdclark@chromium.org>2021-04-07 11:05:47 -0700
commit64fcbde772c72af81e96189d748a4bc8950b08d3 (patch)
tree187b7eca148b40daa4d8959c930ccd31b8c89f73 /drivers/gpu/drm/msm/msm_gem.h
parentf48f356330f7124671b28ddc93a28c492ef05b9f (diff)
downloadlinux-64fcbde772c72af81e96189d748a4bc8950b08d3.tar.bz2
drm/msm: Track potentially evictable objects
Objects that are potential for swapping out are (1) willneed (ie. if they are purgable/MADV_WONTNEED we can just free the pages without them having to land in swap), (2) not on an active list, (3) not dma-buf imported or exported, and (4) not vmap'd. This repurposes the purged list for objects that do not have backing pages (either because they have not been pinned for the first time yet, or in a later patch because they have been unpinned/evicted. Signed-off-by: Rob Clark <robdclark@chromium.org> Link: https://lore.kernel.org/r/20210405174532.1441497-7-robdclark@gmail.com Signed-off-by: Rob Clark <robdclark@chromium.org>
Diffstat (limited to 'drivers/gpu/drm/msm/msm_gem.h')
-rw-r--r--drivers/gpu/drm/msm/msm_gem.h47
1 files changed, 46 insertions, 1 deletions
diff --git a/drivers/gpu/drm/msm/msm_gem.h b/drivers/gpu/drm/msm/msm_gem.h
index 4ac0062312d4..a6480d2c81b2 100644
--- a/drivers/gpu/drm/msm/msm_gem.h
+++ b/drivers/gpu/drm/msm/msm_gem.h
@@ -61,6 +61,11 @@ struct msm_gem_object {
bool dontneed : 1;
/**
+ * Is object evictable (ie. counted in priv->evictable_count)?
+ */
+ bool evictable : 1;
+
+ /**
* count of active vmap'ing
*/
uint8_t vmap_count;
@@ -74,7 +79,7 @@ struct msm_gem_object {
/**
* An object is either:
* inactive - on priv->inactive_dontneed or priv->inactive_willneed
- * (depending on purgability status)
+ * (depending on purgeability status)
* active - on one one of the gpu's active_list.. well, at
* least for now we don't have (I don't think) hw sync between
* 2d and 3d one devices which have both, meaning we need to
@@ -103,6 +108,7 @@ struct msm_gem_object {
char name[32]; /* Identifier to print for the debugfs files */
int active_count;
+ int pin_count;
};
#define to_msm_bo(x) container_of(x, struct msm_gem_object, base)
@@ -263,7 +269,46 @@ static inline void mark_unpurgeable(struct msm_gem_object *msm_obj)
msm_obj->dontneed = false;
}
+static inline bool is_unevictable(struct msm_gem_object *msm_obj)
+{
+ return is_unpurgeable(msm_obj) || msm_obj->pin_count || msm_obj->vaddr;
+}
+
+static inline void mark_evictable(struct msm_gem_object *msm_obj)
+{
+ struct msm_drm_private *priv = msm_obj->base.dev->dev_private;
+
+ WARN_ON(!mutex_is_locked(&priv->mm_lock));
+
+ if (is_unevictable(msm_obj))
+ return;
+
+ if (WARN_ON(msm_obj->evictable))
+ return;
+
+ priv->evictable_count += msm_obj->base.size >> PAGE_SHIFT;
+ msm_obj->evictable = true;
+}
+
+static inline void mark_unevictable(struct msm_gem_object *msm_obj)
+{
+ struct msm_drm_private *priv = msm_obj->base.dev->dev_private;
+
+ WARN_ON(!mutex_is_locked(&priv->mm_lock));
+
+ if (is_unevictable(msm_obj))
+ return;
+
+ if (WARN_ON(!msm_obj->evictable))
+ return;
+
+ priv->evictable_count -= msm_obj->base.size >> PAGE_SHIFT;
+ WARN_ON(priv->evictable_count < 0);
+ msm_obj->evictable = false;
+}
+
void msm_gem_purge(struct drm_gem_object *obj);
+void msm_gem_evict(struct drm_gem_object *obj);
void msm_gem_vunmap(struct drm_gem_object *obj);
/* Created per submit-ioctl, to track bo's and cmdstream bufs, etc,