drm/msm: Fix spelling "purgable" -> "purgeable"
[linux-2.6-microblaze.git] / drivers / gpu / drm / msm / msm_gem.h
index b3a0a88..13ebecd 100644 (file)
@@ -50,18 +50,30 @@ struct msm_gem_object {
         */
        uint8_t madv;
 
+       /**
+        * Is object on inactive_dontneed list (ie. counted in priv->shrinkable_count)?
+        */
+       bool dontneed : 1;
+
        /**
         * count of active vmap'ing
         */
        uint8_t vmap_count;
 
-       /* And object is either:
-        *  inactive - on priv->inactive_list
+       /**
+        * Node in list of all objects (mainly for debugfs, protected by
+        * priv->obj_lock
+        */
+       struct list_head node;
+
+       /**
+        * An object is either:
+        *  inactive - on priv->inactive_dontneed or priv->inactive_willneed
+        *     (depending on purgability 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
         *     block on submit if a bo is already on other ring
-        *
         */
        struct list_head mm_list;
 
@@ -78,8 +90,6 @@ struct msm_gem_object {
 
        struct list_head vmas;    /* list of msm_gem_vma */
 
-       struct llist_node freed;
-
        /* For physically contiguous buffers.  Used when we don't have
         * an IOMMU.  Also used for stolen/splashscreen buffer.
         */
@@ -148,7 +158,16 @@ struct drm_gem_object *msm_gem_import(struct drm_device *dev,
 __printf(2, 3)
 void msm_gem_object_set_name(struct drm_gem_object *bo, const char *fmt, ...);
 #ifdef CONFIG_DEBUG_FS
-void msm_gem_describe(struct drm_gem_object *obj, struct seq_file *m);
+
+struct msm_gem_stats {
+       struct {
+               unsigned count;
+               size_t size;
+       } all, active, purgeable, purged;
+};
+
+void msm_gem_describe(struct drm_gem_object *obj, struct seq_file *m,
+               struct msm_gem_stats *stats);
 void msm_gem_describe_objects(struct list_head *list, struct seq_file *m);
 #endif
 
@@ -188,10 +207,16 @@ static inline bool is_active(struct msm_gem_object *msm_obj)
        return msm_obj->active_count;
 }
 
+/* imported/exported objects are not purgeable: */
+static inline bool is_unpurgeable(struct msm_gem_object *msm_obj)
+{
+       return msm_obj->base.dma_buf && msm_obj->base.import_attach;
+}
+
 static inline bool is_purgeable(struct msm_gem_object *msm_obj)
 {
        return (msm_obj->madv == MSM_MADV_DONTNEED) && msm_obj->sgt &&
-                       !msm_obj->base.dma_buf && !msm_obj->base.import_attach;
+                       !is_unpurgeable(msm_obj);
 }
 
 static inline bool is_vunmapable(struct msm_gem_object *msm_obj)
@@ -200,6 +225,39 @@ static inline bool is_vunmapable(struct msm_gem_object *msm_obj)
        return (msm_obj->vmap_count == 0) && msm_obj->vaddr;
 }
 
+static inline void mark_purgeable(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_unpurgeable(msm_obj))
+               return;
+
+       if (WARN_ON(msm_obj->dontneed))
+               return;
+
+       priv->shrinkable_count += msm_obj->base.size >> PAGE_SHIFT;
+       msm_obj->dontneed = true;
+}
+
+static inline void mark_unpurgeable(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_unpurgeable(msm_obj))
+               return;
+
+       if (WARN_ON(!msm_obj->dontneed))
+               return;
+
+       priv->shrinkable_count -= msm_obj->base.size >> PAGE_SHIFT;
+       WARN_ON(priv->shrinkable_count < 0);
+       msm_obj->dontneed = false;
+}
+
 void msm_gem_purge(struct drm_gem_object *obj);
 void msm_gem_vunmap(struct drm_gem_object *obj);