Skip to contentSkip to conversation

drm/vmwgfx: Assign eviction priorities to resources

PATCH In review Thomas Hellström (VMware) 3 participants 11 messages Jun 18, 2019

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/4 drm/vmwgfx: Assign eviction priorities to resources

From: Thomas Hellstrom <[email protected]>

TTM provides a means to assign eviction priorities to buffer object. This means that all buffer objects with a lower priority will be evicted first on memory pressure.
Use this to make sure surfaces and in particular non-dirty surfaces are evicted first. Evicting in particular shaders, cotables and contexts imply a significant performance hit on vmwgfx, so make sure these resources are evicted last.
Some buffer objects are sub-allocated in user-space which means we can have many resources attached to a single buffer object or resource. In that case the buffer object is given the highest priority of the attached resources.

---
 drivers/gpu/drm/vmwgfx/vmwgfx_bo.c            |  2 +
 drivers/gpu/drm/vmwgfx/vmwgfx_context.c       |  4 ++
 drivers/gpu/drm/vmwgfx/vmwgfx_cotable.c       | 13 ++--
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.h           | 72 +++++++++++++++++++
 drivers/gpu/drm/vmwgfx/vmwgfx_resource.c      | 56 +++++++++++----
 drivers/gpu/drm/vmwgfx/vmwgfx_resource_priv.h |  2 +
 drivers/gpu/drm/vmwgfx/vmwgfx_shader.c        |  8 ++-
 drivers/gpu/drm/vmwgfx/vmwgfx_surface.c       |  4 ++
 8 files changed, 141 insertions(+), 20 deletions(-)
drivers/gpu/drm/vmwgfx/vmwgfx_bo.c +2 -0
index 5d5c2bce01f3..c0829d50eecc 100644
@@ -510,6 +510,8 @@ int vmw_bo_init(struct vmw_private *dev_priv,
 
 	acc_size = vmw_bo_acc_size(dev_priv, size, user);
 	memset(vmw_bo, 0, sizeof(*vmw_bo));
+	BUILD_BUG_ON(TTM_MAX_BO_PRIORITY <= 3);
+	vmw_bo->base.priority = 3;
 
 	INIT_LIST_HEAD(&vmw_bo->res_list);
 
drivers/gpu/drm/vmwgfx/vmwgfx_context.c +4 -0
index 63f111068a44..a56c9d802382 100644
@@ -88,6 +88,8 @@ static const struct vmw_res_func vmw_gb_context_func = {
 	.res_type = vmw_res_context,
 	.needs_backup = true,
 	.may_evict = true,
+	.prio = 3,
+	.dirty_prio = 3,
 	.type_name = "guest backed contexts",
 	.backup_placement = &vmw_mob_placement,
 	.create = vmw_gb_context_create,
@@ -100,6 +102,8 @@ static const struct vmw_res_func vmw_dx_context_func = {
 	.res_type = vmw_res_dx_context,
 	.needs_backup = true,
 	.may_evict = true,
+	.prio = 3,
+	.dirty_prio = 3,
 	.type_name = "dx contexts",
 	.backup_placement = &vmw_mob_placement,
 	.create = vmw_dx_context_create,
drivers/gpu/drm/vmwgfx/vmwgfx_cotable.c +8 -5
index b4f6e1217c9d..8c699cb2565b 100644
@@ -116,6 +116,8 @@ static const struct vmw_res_func vmw_cotable_func = {
 	.res_type = vmw_res_cotable,
 	.needs_backup = true,
 	.may_evict = true,
+	.prio = 3,
+	.dirty_prio = 3,
 	.type_name = "context guest backed object tables",
 	.backup_placement = &vmw_mob_placement,
 	.create = vmw_cotable_create,
@@ -307,7 +309,7 @@ static int vmw_cotable_unbind(struct vmw_resource *res,
 	struct ttm_buffer_object *bo = val_buf->bo;
 	struct vmw_fence_obj *fence;
 
-	if (list_empty(&res->mob_head))
+	if (!vmw_resource_mob_attached(res))
 		return 0;
 
 	WARN_ON_ONCE(bo->mem.mem_type != VMW_PL_MOB);
@@ -453,6 +455,7 @@ static int vmw_cotable_resize(struct vmw_resource *res, size_t new_size)
 		goto out_wait;
 	}
 
+	vmw_resource_mob_detach(res);
 	res->backup = buf;
 	res->backup_size = new_size;
 	vcotbl->size_read_back = cur_size_read_back;
@@ -467,12 +470,12 @@ static int vmw_cotable_resize(struct vmw_resource *res, size_t new_size)
 		res->backup = old_buf;
 		res->backup_size = old_size;
 		vcotbl->size_read_back = old_size_read_back;
+		vmw_resource_mob_attach(res);
 		goto out_wait;
 	}
 
+	vmw_resource_mob_attach(res);
 	/* Let go of the old mob. */
-	list_del(&res->mob_head);
-	list_add_tail(&res->mob_head, &buf->res_list);
 	vmw_bo_unreference(&old_buf);
 	res->id = vcotbl->type;
 
@@ -496,7 +499,7 @@ static int vmw_cotable_resize(struct vmw_resource *res, size_t new_size)
  * is called before bind() in the validation sequence is instead used for two
  * things.
  * 1) Unscrub the cotable if it is scrubbed and still attached to a backup
- *    buffer, that is, if @res->mob_head is non-empty.
+ *    buffer.
  * 2) Resize the cotable if needed.
  */
 static int vmw_cotable_create(struct vmw_resource *res)
@@ -512,7 +515,7 @@ static int vmw_cotable_create(struct vmw_resource *res)
 		new_size *= 2;
 
 	if (likely(new_size <= res->backup_size)) {
-		if (vcotbl->scrubbed && !list_empty(&res->mob_head)) {
+		if (vcotbl->scrubbed && vmw_resource_mob_attached(res)) {
 			ret = vmw_cotable_unscrub(res);
 			if (ret)
 				return ret;
drivers/gpu/drm/vmwgfx/vmwgfx_drv.h +72 -0

102 lines not on this page · raw message

drivers/gpu/drm/vmwgfx/vmwgfx_resource.c +43 -13

130 lines not on this page · raw message

drivers/gpu/drm/vmwgfx/vmwgfx_resource_priv.h +2 -0
index 7e19eba0b0b8..984e588c62ca 100644
@@ -78,6 +78,8 @@ struct vmw_res_func {
 	const char *type_name;
 	struct ttm_placement *backup_placement;
 	bool may_evict;
+	u32 prio;
+	u32 dirty_prio;
 
 	int (*create) (struct vmw_resource *res);
 	int (*destroy) (struct vmw_resource *res);
drivers/gpu/drm/vmwgfx/vmwgfx_shader.c +6 -2
index d310d21f0d54..e139fdfd1635 100644
@@ -95,6 +95,8 @@ static const struct vmw_res_func vmw_gb_shader_func = {
 	.res_type = vmw_res_shader,
 	.needs_backup = true,
 	.may_evict = true,
+	.prio = 3,
+	.dirty_prio = 3,
 	.type_name = "guest backed shaders",
 	.backup_placement = &vmw_mob_placement,
 	.create = vmw_gb_shader_create,
@@ -106,7 +108,9 @@ static const struct vmw_res_func vmw_gb_shader_func = {
 static const struct vmw_res_func vmw_dx_shader_func = {
 	.res_type = vmw_res_shader,
 	.needs_backup = true,
-	.may_evict = false,
+	.may_evict = true,
+	.prio = 3,
+	.dirty_prio = 3,
 	.type_name = "dx shaders",
 	.backup_placement = &vmw_mob_placement,
 	.create = vmw_dx_shader_create,
@@ -423,7 +427,7 @@ static int vmw_dx_shader_create(struct vmw_resource *res)
 
 	WARN_ON_ONCE(!shader->committed);
 
-	if (!list_empty(&res->mob_head)) {
+	if (vmw_resource_mob_attached(res)) {
 		mutex_lock(&dev_priv->binding_mutex);
 		ret = vmw_dx_shader_unscrub(res);
 		mutex_unlock(&dev_priv->binding_mutex);
drivers/gpu/drm/vmwgfx/vmwgfx_surface.c +4 -0
index 219471903bc1..c40d44f4d9af 100644
@@ -112,6 +112,8 @@ static const struct vmw_res_func vmw_legacy_surface_func = {
 	.res_type = vmw_res_surface,
 	.needs_backup = false,
 	.may_evict = true,
+	.prio = 1,
+	.dirty_prio = 1,
 	.type_name = "legacy surfaces",
 	.backup_placement = &vmw_srf_placement,
 	.create = &vmw_legacy_srf_create,
@@ -124,6 +126,8 @@ static const struct vmw_res_func vmw_gb_surface_func = {
 	.res_type = vmw_res_surface,
 	.needs_backup = true,
 	.may_evict = true,
+	.prio = 1,
+	.dirty_prio = 2,
 	.type_name = "guest backed surfaces",
 	.backup_placement = &vmw_mob_placement,
 	.create = vmw_gb_surface_create,
Signature · 6 lines
2.20.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#1 lore raw

PATCH 2/4 drm/vmwgfx: Add debug message for layout change ioctl

From: Deepak Rawat <[email protected]>

Add debug code to check user-space layout change request.

---
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.h | 8 ++++++++
 drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 8 ++++++++
 2 files changed, 16 insertions(+)
drivers/gpu/drm/vmwgfx/vmwgfx_drv.h +8 -0
index 5971c0d47507..b4c8817dc267 100644
@@ -1424,6 +1424,14 @@ int vmw_host_log(const char *log);
 #define VMW_DEBUG_USER(fmt, ...)                                              \
 	DRM_DEBUG_DRIVER(fmt, ##__VA_ARGS__)
 
+/**
+ * VMW_DEBUG_KMS - Debug output for kernel mode-setting
+ *
+ * This macro is for debugging vmwgfx mode-setting code.
+ */
+#define VMW_DEBUG_KMS(fmt, ...)                                               \
+	DRM_DEBUG_DRIVER(fmt, ##__VA_ARGS__)
+
 /* Resource dirtying - vmwgfx_page_dirty.c */
 void vmw_bo_dirty_scan(struct vmw_buffer_object *vbo);
 int vmw_bo_dirty_add(struct vmw_buffer_object *vbo);
drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +8 -0
index b97bc8e5944b..7f9264a72e1d 100644
@@ -2347,6 +2347,9 @@ int vmw_kms_update_layout_ioctl(struct drm_device *dev, void *data,
 
 	if (!arg->num_outputs) {
 		struct drm_rect def_rect = {0, 0, 800, 600};
+		VMW_DEBUG_KMS("Default layout x1 = %d y1 = %d x2 = %d y2 = %d\n",
+			      def_rect.x1, def_rect.y1,
+			      def_rect.x2, def_rect.y2);
 		vmw_du_update_layout(dev_priv, 1, &def_rect);
 		return 0;
 	}
@@ -2367,6 +2370,7 @@ int vmw_kms_update_layout_ioctl(struct drm_device *dev, void *data,
 
 	drm_rects = (struct drm_rect *)rects;
 
+	VMW_DEBUG_KMS("Layout count = %u\n", arg->num_outputs);
 	for (i = 0; i < arg->num_outputs; i++) {
 		struct drm_vmw_rect curr_rect;
 
@@ -2383,6 +2387,10 @@ int vmw_kms_update_layout_ioctl(struct drm_device *dev, void *data,
 		drm_rects[i].x2 = curr_rect.x + curr_rect.w;
 		drm_rects[i].y2 = curr_rect.y + curr_rect.h;
 
+		VMW_DEBUG_KMS("  x1 = %d y1 = %d x2 = %d y2 = %d\n",
+			      drm_rects[i].x1, drm_rects[i].y1,
+			      drm_rects[i].x2, drm_rects[i].y2);
+
 		/*
 		 * Currently this check is limiting the topology within
 		 * mode_config->max (which actually is max texture size
Signature · 6 lines
2.20.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#2 lore raw

PATCH 3/4 drm/vmwgfx: Use VMW_DEBUG_KMS for vmwgfx mode-setting user errors

In reply to Thomas Hellström (VMware)

From: Deepak Rawat <[email protected]>

For errors during layout change ioctl use VMW_DEBUG_KMS instead of DRM_ERROR.

---
 drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)
drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +10 -5
index 7f9264a72e1d..e7222fa2cfdf 100644
@@ -1462,7 +1462,7 @@ static int vmw_kms_check_display_memory(struct drm_device *dev,
 		if (dev_priv->active_display_unit == vmw_du_screen_target &&
 		    (drm_rect_width(&rects[i]) > dev_priv->stdu_max_width ||
 		     drm_rect_height(&rects[i]) > dev_priv->stdu_max_height)) {
-			DRM_ERROR("Screen size not supported.\n");
+			VMW_DEBUG_KMS("Screen size not supported.\n");
 			return -EINVAL;
 		}
 
@@ -1486,7 +1486,7 @@ static int vmw_kms_check_display_memory(struct drm_device *dev,
 	 * limit on primary bounding box
 	 */
 	if (pixel_mem > dev_priv->prim_bb_mem) {
-		DRM_ERROR("Combined output size too large.\n");
+		VMW_DEBUG_KMS("Combined output size too large.\n");
 		return -EINVAL;
 	}
 
@@ -1496,7 +1496,7 @@ static int vmw_kms_check_display_memory(struct drm_device *dev,
 		bb_mem = (u64) bounding_box.x2 * bounding_box.y2 * 4;
 
 		if (bb_mem > dev_priv->prim_bb_mem) {
-			DRM_ERROR("Topology is beyond supported limits.\n");
+			VMW_DEBUG_KMS("Topology is beyond supported limits.\n");
 			return -EINVAL;
 		}
 	}
@@ -1645,6 +1645,7 @@ static int vmw_kms_check_topology(struct drm_device *dev,
 		struct vmw_connector_state *vmw_conn_state;
 
 		if (!du->pref_active && new_crtc_state->enable) {
+			VMW_DEBUG_KMS("Enabling a disabled display unit\n");
 			ret = -EINVAL;
 			goto clean;
 		}
@@ -1701,8 +1702,10 @@ vmw_kms_atomic_check_modeset(struct drm_device *dev,
 		return ret;
 
 	ret = vmw_kms_check_implicit(dev, state);
-	if (ret)
+	if (ret) {
+		VMW_DEBUG_KMS("Invalid implicit state\n");
 		return ret;
+	}
 
 	if (!state->allow_modeset)
 		return ret;
@@ -2401,7 +2404,9 @@ int vmw_kms_update_layout_ioctl(struct drm_device *dev, void *data,
 		if (drm_rects[i].x1 < 0 ||  drm_rects[i].y1 < 0 ||
 		    drm_rects[i].x2 > mode_config->max_width ||
 		    drm_rects[i].y2 > mode_config->max_height) {
-			DRM_ERROR("Invalid GUI layout.\n");
+			VMW_DEBUG_KMS("Invalid layout %d %d %d %d\n",
+				      drm_rects[i].x1, drm_rects[i].y1,
+				      drm_rects[i].x2, drm_rects[i].y2);
 			ret = -EINVAL;
 			goto out_free;
 		}
Signature · 6 lines
2.20.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#3 lore raw

PATCH 4/4 drm/vmwgfx: Kill unneeded legacy security features

In reply to Thomas Hellström (VMware)

From: Thomas Hellstrom <[email protected]>

At one point, the GPU command verifier and user-space handle manager couldn't properly protect GPU clients from accessing each other's data. Instead there was an elaborate mechanism to make sure only the active master's primary clients could render. The other clients were either put to sleep or even killed (if the master had exited). VRAM was evicted on master switch. With the advent of render-node functionality, we relaxed the VRAM eviction, but the other mechanisms stayed in place.

Now that the GPU command verifier and ttm object manager properly isolates primary clients from different master realms we can remove the master switch related code and drop those legacy features.

---
 drivers/gpu/drm/vmwgfx/ttm_lock.c       | 100 ---------------
 drivers/gpu/drm/vmwgfx/ttm_lock.h       |  30 -----
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.c     | 162 +-----------------------
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.h     |  16 +--
 drivers/gpu/drm/vmwgfx/vmwgfx_surface.c |   6 -
 5 files changed, 3 insertions(+), 311 deletions(-)
drivers/gpu/drm/vmwgfx/ttm_lock.c +0 -100
index 16b2083cb9d4..5971c72e6d10 100644
@@ -29,7 +29,6 @@
  * Authors: Thomas Hellstrom <thellstrom-at-vmware-dot-com>
  */
 
-#include <drm/ttm/ttm_module.h>
 #include <linux/atomic.h>
 #include <linux/errno.h>
 #include <linux/wait.h>
@@ -49,8 +48,6 @@ void ttm_lock_init(struct ttm_lock *lock)
 	init_waitqueue_head(&lock->queue);
 	lock->rw = 0;
 	lock->flags = 0;
-	lock->kill_takers = false;
-	lock->signal = SIGKILL;
 }
 
 void ttm_read_unlock(struct ttm_lock *lock)
@@ -66,11 +63,6 @@ static bool __ttm_read_lock(struct ttm_lock *lock)
 	bool locked = false;
 
 	spin_lock(&lock->lock);
-	if (unlikely(lock->kill_takers)) {
-		send_sig(lock->signal, current, 0);
-		spin_unlock(&lock->lock);
-		return false;
-	}
 	if (lock->rw >= 0 && lock->flags == 0) {
 		++lock->rw;
 		locked = true;
@@ -98,11 +90,6 @@ static bool __ttm_read_trylock(struct ttm_lock *lock, bool *locked)
 	*locked = false;
 
 	spin_lock(&lock->lock);
-	if (unlikely(lock->kill_takers)) {
-		send_sig(lock->signal, current, 0);
-		spin_unlock(&lock->lock);
-		return false;
-	}
 	if (lock->rw >= 0 && lock->flags == 0) {
 		++lock->rw;
 		block = false;
@@ -147,11 +134,6 @@ static bool __ttm_write_lock(struct ttm_lock *lock)
 	bool locked = false;
 
 	spin_lock(&lock->lock);
-	if (unlikely(lock->kill_takers)) {
-		send_sig(lock->signal, current, 0);
-		spin_unlock(&lock->lock);
-		return false;
-	}
 	if (lock->rw == 0 && ((lock->flags & ~TTM_WRITE_LOCK_PENDING) == 0)) {
 		lock->rw = -1;
 		lock->flags &= ~TTM_WRITE_LOCK_PENDING;
@@ -182,88 +164,6 @@ int ttm_write_lock(struct ttm_lock *lock, bool interruptible)
 	return ret;
 }
 
-static int __ttm_vt_unlock(struct ttm_lock *lock)
-{
-	int ret = 0;
-
-	spin_lock(&lock->lock);
-	if (unlikely(!(lock->flags & TTM_VT_LOCK)))
-		ret = -EINVAL;
-	lock->flags &= ~TTM_VT_LOCK;
-	wake_up_all(&lock->queue);
-	spin_unlock(&lock->lock);
-
-	return ret;
-}
-
-static void ttm_vt_lock_remove(struct ttm_base_object **p_base)
-{
-	struct ttm_base_object *base = *p_base;
-	struct ttm_lock *lock = container_of(base, struct ttm_lock, base);
-	int ret;
-
-	*p_base = NULL;
-	ret = __ttm_vt_unlock(lock);
-	BUG_ON(ret != 0);
-}
-
-static bool __ttm_vt_lock(struct ttm_lock *lock)
-{
-	bool locked = false;
-
-	spin_lock(&lock->lock);
-	if (lock->rw == 0) {
-		lock->flags &= ~TTM_VT_LOCK_PENDING;
-		lock->flags |= TTM_VT_LOCK;
-		locked = true;
-	} else {
-		lock->flags |= TTM_VT_LOCK_PENDING;
-	}
-	spin_unlock(&lock->lock);
-	return locked;
-}
-
-int ttm_vt_lock(struct ttm_lock *lock,
-		bool interruptible,
-		struct ttm_object_file *tfile)
-{
-	int ret = 0;
-
-	if (interruptible) {
-		ret = wait_event_interruptible(lock->queue,
-					       __ttm_vt_lock(lock));
-		if (unlikely(ret != 0)) {
-			spin_lock(&lock->lock);
-			lock->flags &= ~TTM_VT_LOCK_PENDING;
-			wake_up_all(&lock->queue);
-			spin_unlock(&lock->lock);
-			return ret;
-		}
-	} else
-		wait_event(lock->queue, __ttm_vt_lock(lock));
-
-	/*
-	 * Add a base-object, the destructor of which will
-	 * make sure the lock is released if the client dies
-	 * while holding it.
-	 */
-
-	ret = ttm_base_object_init(tfile, &lock->base, false,
-				   ttm_lock_type, &ttm_vt_lock_remove, NULL);
-	if (ret)
-		(void)__ttm_vt_unlock(lock);
-	else
-		lock->vt_holder = tfile;
-
-	return ret;
-}
-
-int ttm_vt_unlock(struct ttm_lock *lock)
-{
-	return ttm_ref_object_base_unref(lock->vt_holder,
-					 lock->base.handle, TTM_REF_USAGE);
-}
-
 void ttm_suspend_unlock(struct ttm_lock *lock)
 {
 	spin_lock(&lock->lock);
drivers/gpu/drm/vmwgfx/ttm_lock.h +0 -30
index 0c3af9836863..3d454e8b491f 100644
@@ -63,8 +63,6 @@
  * @lock: Spinlock protecting some lock members.
  * @rw: Read-write lock counter. Protected by @lock.
  * @flags: Lock state. Protected by @lock.
- * @kill_takers: Boolean whether to kill takers of the lock.
- * @signal: Signal to send when kill_takers is true.
  */
 
 struct ttm_lock {
@@ -73,9 +71,6 @@ struct ttm_lock {
 	spinlock_t lock;
 	int32_t rw;
 	uint32_t flags;
-	bool kill_takers;
-	int signal;
-	struct ttm_object_file *vt_holder;
 };
 
 
@@ -220,29 +215,4 @@ extern void ttm_write_unlock(struct ttm_lock *lock);
  */
 extern int ttm_write_lock(struct ttm_lock *lock, bool interruptible);
 
-/**
- * ttm_lock_set_kill
- *
- * @lock: Pointer to a struct ttm_lock
- * @val: Boolean whether to kill processes taking the lock.
- * @signal: Signal to send to the process taking the lock.
- *
- * The kill-when-taking-lock functionality is used to kill processes that keep
- * on using the TTM functionality when its resources has been taken down, for
- * example when the X server exits. A typical sequence would look like this:
- * - X server takes lock in write mode.
- * - ttm_lock_set_kill() is called with @val set to true.
- * - As part of X server exit, TTM resources are taken down.
- * - X server releases the lock on file release.
- * - Another dri client wants to render, takes the lock and is killed.
- *
- */
-static inline void ttm_lock_set_kill(struct ttm_lock *lock, bool val,
-				     int signal)
-{
-	lock->kill_takers = val;
-	if (val)
-		lock->signal = signal;
-}
-
 #endif
drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +2 -160

224 lines not on this page · raw message

drivers/gpu/drm/vmwgfx/vmwgfx_drv.h +1 -15
index b4c8817dc267..3a358a5495e4 100644
@@ -81,7 +81,6 @@
 #define VMW_RES_SHADER ttm_driver_type4
 
 struct vmw_fpriv {
-	struct drm_master *locked_master;
 	struct ttm_object_file *tfile;
 	bool gb_aware; /* user-space is guest-backed aware */
 };
@@ -393,10 +392,6 @@ struct vmw_sw_context{
 struct vmw_legacy_display;
 struct vmw_overlay;
 
-struct vmw_master {
-	struct ttm_lock lock;
-};
-
 struct vmw_vga_topology_state {
 	uint32_t width;
 	uint32_t height;
@@ -559,11 +554,8 @@ struct vmw_private {
 	spinlock_t svga_lock;
 
 	/**
-	 * Master management.
+	 * PM management.
 	 */
-
-	struct vmw_master *active_master;
-	struct vmw_master fbdev_master;
 	struct notifier_block pm_nb;
 	bool refuse_hibernation;
 	bool suspend_locked;
@@ -632,11 +624,6 @@ static inline struct vmw_fpriv *vmw_fpriv(struct drm_file *file_priv)
 	return (struct vmw_fpriv *)file_priv->driver_priv;
 }
 
-static inline struct vmw_master *vmw_master(struct drm_master *master)
-{
-	return (struct vmw_master *) master->driver_priv;
-}
-
 /*
  * The locking here is fine-grained, so that it is performed once
  * for every read- and write operation. This is of course costly, but we
@@ -1102,7 +1089,6 @@ void vmw_kms_cursor_snoop(struct vmw_surface *srf,
 int vmw_kms_write_svga(struct vmw_private *vmw_priv,
 		       unsigned width, unsigned height, unsigned pitch,
 		       unsigned bpp, unsigned depth);
-void vmw_kms_idle_workqueues(struct vmw_master *vmaster);
 bool vmw_kms_validate_mode_vram(struct vmw_private *dev_priv,
 				uint32_t pitch,
 				uint32_t height);
drivers/gpu/drm/vmwgfx/vmwgfx_surface.c +0 -6
index 637043f1befa..862ca44680ca 100644
@@ -946,12 +946,6 @@ vmw_surface_handle_reference(struct vmw_private *dev_priv,
 		if (unlikely(drm_is_render_client(file_priv)))
 			require_exist = true;
 
-		if (READ_ONCE(vmw_fpriv(file_priv)->locked_master)) {
-			DRM_ERROR("Locked master refused legacy "
-				  "surface reference.\n");
-			return -EACCES;
-		}
-
 		handle = u_handle;
 	}
 
Signature · 6 lines
2.20.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Reviewed-by Acked-by on v1 1/4
#4 lore raw
In reply to Thomas Hellström (VMware)

Hi Thomas,

Quoted 13 lines · Thomas Hellström (VMware)

From: Thomas Hellstrom <[email protected]>

TTM provides a means to assign eviction priorities to buffer object. This means that all buffer objects with a lower priority will be evicted first on memory pressure.
Use this to make sure surfaces and in particular non-dirty surfaces are evicted first. Evicting in particular shaders, cotables and contexts imply a significant performance hit on vmwgfx, so make sure these resources are evicted last.
Some buffer objects are sub-allocated in user-space which means we can have many resources attached to a single buffer object or resource. In that case the buffer object is given the highest priority of the attached resources.

Quoted 2 lines

Fwiw patches 1-3 are:

Patch 4 is:

Huge thanks for sorting this out.
Emil
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#5 lore raw
Quoted 18 lines · Emil Velikov

Hi Thomas,

Quoted 13 lines · Thomas Hellström (VMware)

From: Thomas Hellstrom <[email protected]>

TTM provides a means to assign eviction priorities to buffer object. This means that all buffer objects with a lower priority will be evicted first on memory pressure.
Use this to make sure surfaces and in particular non-dirty surfaces are evicted first. Evicting in particular shaders, cotables and contexts imply a significant performance hit on vmwgfx, so make sure these resources are evicted last.
Some buffer objects are sub-allocated in user-space which means we can have many resources attached to a single buffer object or resource. In that case the buffer object is given the highest priority of the attached resources.

Quoted 2 lines
Quoted 7 lines

Fwiw patches 1-3 are:

Patch 4 is:

Huge thanks for sorting this out.

Oh, does this mean we can remove the varios master* callbacks from drm_driver now? Iirc vmwgfx was the only user, and those callbacks seem very tempting to various folks for implementing questionable driver hacks ... Happy to type the patches, but maybe simpler if you do that since all this gets merged through the vmwgfx tree.

Cheers, Daniel

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#6 lore raw
Quoted 25 lines · Daniel Vetter
Quoted 24 lines · Emil Velikov

Hi Thomas,

Quoted 13 lines · Thomas Hellström (VMware)

From: Thomas Hellstrom <[email protected]>

TTM provides a means to assign eviction priorities to buffer object. This means that all buffer objects with a lower priority will be evicted first on memory pressure.
Use this to make sure surfaces and in particular non-dirty surfaces are evicted first. Evicting in particular shaders, cotables and contexts imply a significant performance hit on vmwgfx, so make sure these resources are evicted last.
Some buffer objects are sub-allocated in user-space which means we can have many resources attached to a single buffer object or resource. In that case the buffer object is given the highest priority of the attached resources.

Quoted 2 lines

Fwiw patches 1-3 are:

Patch 4 is:

Quoted 8 lines
Quoted 1 line

Huge thanks for sorting this out.

Oh, does this mean we can remove the varios master* callbacks from drm_driver now? Iirc vmwgfx was the only user, and those callbacks seem very tempting to various folks for implementing questionable driver hacks ... Happy to type the patches, but maybe simpler if you do that since all this gets merged through the vmwgfx tree.

Cheers, Daniel

In case someone follow this, I'll paste in the commit message of 4/4 which is the relevant one here..

8<--------------------------------------------

At one point, the GPU command verifier and user-space handle manager couldn't properly protect GPU clients from accessing each other's data. Instead there was an elaborate mechanism to make sure only the active master's primary clients could render. The other clients were either put to sleep or even killed (if the master had exited). VRAM was evicted on master switch. With the advent of render-node functionality, we relaxed the VRAM eviction, but the other mechanisms stayed in place.

Now that the GPU command verifier and ttm object manager properly isolates primary clients from different master realms we can remove the master switch related code and drop those legacy features.

8<-------------------------------------------

I think we can at least take a look. I'm out on a fairly long vacation soon so in any case it won't be before August or so.

One use we still have for master_set() is that if a master is switched away, and then the mode list changes, and then the master is switched back, it will typically not remember to act on the sysfs event received while switched out, and come back in an incorrect mode. Since mode-list changes happen quite frequently with virtual display adapters that's bad.

But perhaps we can consider moving that to core, if that's what needed to get rid of the master switch callbacks.

/Thomas

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#7 lore raw
Quoted 48 lines · Thomas Hellstrom
Quoted 25 lines · Daniel Vetter
Quoted 24 lines · Emil Velikov

Hi Thomas,

Quoted 13 lines · Thomas Hellström (VMware)

From: Thomas Hellstrom <[email protected]>

TTM provides a means to assign eviction priorities to buffer object. This means that all buffer objects with a lower priority will be evicted first on memory pressure.
Use this to make sure surfaces and in particular non-dirty surfaces are evicted first. Evicting in particular shaders, cotables and contexts imply a significant performance hit on vmwgfx, so make sure these resources are evicted last.
Some buffer objects are sub-allocated in user-space which means we can have many resources attached to a single buffer object or resource. In that case the buffer object is given the highest priority of the attached resources.

Quoted 2 lines

Fwiw patches 1-3 are:

Patch 4 is:

Quoted 8 lines
Quoted 1 line

Huge thanks for sorting this out.

Oh, does this mean we can remove the varios master* callbacks from drm_driver now? Iirc vmwgfx was the only user, and those callbacks seem very tempting to various folks for implementing questionable driver hacks ... Happy to type the patches, but maybe simpler if you do that since all this gets merged through the vmwgfx tree.

Cheers, Daniel

In case someone follow this, I'll paste in the commit message of 4/4 which is the relevant one here..

8<--------------------------------------------

At one point, the GPU command verifier and user-space handle manager couldn't properly protect GPU clients from accessing each other's data. Instead there was an elaborate mechanism to make sure only the active master's primary clients could render. The other clients were either put to sleep or even killed (if the master had exited). VRAM was evicted on master switch. With the advent of render-node functionality, we relaxed the VRAM eviction, but the other mechanisms stayed in place.

Quoted 8 lines

Now that the GPU command verifier and ttm object manager properly isolates primary clients from different master realms we can remove the master switch related code and drop those legacy features.

8<-------------------------------------------

I think we can at least take a look. I'm out on a fairly long vacation soon so in any case it won't be before August or so.

Ah don't worry, if this all lands in the 5.3 merge window I can take a look in a few weeks.

Quoted 8 lines

One use we still have for master_set() is that if a master is switched away, and then the mode list changes, and then the master is switched back, it will typically not remember to act on the sysfs event received while switched out, and come back in an incorrect mode. Since mode-list changes happen quite frequently with virtual display adapters that's bad.

But perhaps we can consider moving that to core, if that's what needed to get rid of the master switch callbacks.

Hm, this sounds a bit like papering over userspace bugs, at least if you're referring to drm_sysfs_hotplug_event(). Userspace is supposed to either keep listening or to re-acquire all the kms output state and do the hotplugg processing in one go when becoming active again.

Ofc it exists, so we can't just remove it. I wouldn't want to make this part of the uapi though, feels like duct-taping around sloppy userspace. Maybe we could work on a gradual plan to deprecate this, with limiting it only to older vmwgfx versions as a start?

These kind of tiny but important differences in how drivers implement kms is why I'd much, much prefer it's not even possible to do stuff like this.

Thanks, Daniel

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#8 lore raw
Quoted 72 lines · Daniel Vetter
Quoted 47 lines · Thomas Hellstrom
Quoted 25 lines · Daniel Vetter
Quoted 24 lines · Emil Velikov

Hi Thomas,

Quoted 13 lines · Thomas Hellström (VMware)

From: Thomas Hellstrom <[email protected]>

TTM provides a means to assign eviction priorities to buffer object. This means that all buffer objects with a lower priority will be evicted first on memory pressure.
Use this to make sure surfaces and in particular non-dirty surfaces are evicted first. Evicting in particular shaders, cotables and contexts imply a significant performance hit on vmwgfx, so make sure these resources are evicted last.
Some buffer objects are sub-allocated in user-space which means we can have many resources attached to a single buffer object or resource. In that case the buffer object is given the highest priority of the attached resources.

Quoted 2 lines

Fwiw patches 1-3 are:

Patch 4 is:

Quoted 8 lines
Quoted 1 line

Huge thanks for sorting this out.

Oh, does this mean we can remove the varios master* callbacks from drm_driver now? Iirc vmwgfx was the only user, and those callbacks seem very tempting to various folks for implementing questionable driver hacks ... Happy to type the patches, but maybe simpler if you do that since all this gets merged through the vmwgfx tree.

Cheers, Daniel

In case someone follow this, I'll paste in the commit message of 4/4 which is the relevant one here..

8<--------------------------------------------

At one point, the GPU command verifier and user-space handle manager couldn't properly protect GPU clients from accessing each other's data. Instead there was an elaborate mechanism to make sure only the active master's primary clients could render. The other clients were either put to sleep or even killed (if the master had exited). VRAM was evicted on master switch. With the advent of render-node functionality, we relaxed the VRAM eviction, but the other mechanisms stayed in place.

Quoted 8 lines

Now that the GPU command verifier and ttm object manager properly isolates primary clients from different master realms we can remove the master switch related code and drop those legacy features.

8<-------------------------------------------

I think we can at least take a look. I'm out on a fairly long vacation soon so in any case it won't be before August or so.

Ah don't worry, if this all lands in the 5.3 merge window I can take a look in a few weeks.

Quoted 8 lines

One use we still have for master_set() is that if a master is switched away, and then the mode list changes, and then the master is switched back, it will typically not remember to act on the sysfs event received while switched out, and come back in an incorrect mode. Since mode-list changes happen quite frequently with virtual display adapters that's bad.

But perhaps we can consider moving that to core, if that's what needed to get rid of the master switch callbacks.

Hm, this sounds a bit like papering over userspace bugs, at least if you're referring to drm_sysfs_hotplug_event(). Userspace is supposed to either keep listening or to re-acquire all the kms output state and do the hotplugg processing in one go when becoming active again.

Quoted 4 lines

Ofc it exists, so we can't just remove it. I wouldn't want to make this part of the uapi though, feels like duct-taping around sloppy userspace. Maybe we could work on a gradual plan to deprecate this, with limiting it only to older vmwgfx versions as a start?

Sounds ok with me. First I guess I need to figure out what compositors / user-space drivers actually suffer from this. If there are many, it might be a pain trying to fix them all.

Thanks,

Thomas

Quoted 5 lines

These kind of tiny but important differences in how drivers implement kms is why I'd much, much prefer it's not even possible to do stuff like this.

Thanks, Daniel

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#9 lore raw
Quoted 73 lines · Thomas Hellstrom
Quoted 72 lines · Daniel Vetter
Quoted 47 lines · Thomas Hellstrom
Quoted 25 lines · Daniel Vetter
Quoted 24 lines · Emil Velikov

Hi Thomas,

Quoted 13 lines · Thomas Hellström (VMware)

From: Thomas Hellstrom <[email protected]>

TTM provides a means to assign eviction priorities to buffer object. This means that all buffer objects with a lower priority will be evicted first on memory pressure.
Use this to make sure surfaces and in particular non-dirty surfaces are evicted first. Evicting in particular shaders, cotables and contexts imply a significant performance hit on vmwgfx, so make sure these resources are evicted last.
Some buffer objects are sub-allocated in user-space which means we can have many resources attached to a single buffer object or resource. In that case the buffer object is given the highest priority of the attached resources.

Quoted 2 lines

Fwiw patches 1-3 are:

Patch 4 is:

Quoted 8 lines
Quoted 1 line

Huge thanks for sorting this out.

Oh, does this mean we can remove the varios master* callbacks from drm_driver now? Iirc vmwgfx was the only user, and those callbacks seem very tempting to various folks for implementing questionable driver hacks ... Happy to type the patches, but maybe simpler if you do that since all this gets merged through the vmwgfx tree.

Cheers, Daniel

In case someone follow this, I'll paste in the commit message of 4/4 which is the relevant one here..

8<--------------------------------------------

At one point, the GPU command verifier and user-space handle manager couldn't properly protect GPU clients from accessing each other's data. Instead there was an elaborate mechanism to make sure only the active master's primary clients could render. The other clients were either put to sleep or even killed (if the master had exited). VRAM was evicted on master switch. With the advent of render-node functionality, we relaxed the VRAM eviction, but the other mechanisms stayed in place.

Quoted 8 lines

Now that the GPU command verifier and ttm object manager properly isolates primary clients from different master realms we can remove the master switch related code and drop those legacy features.

8<-------------------------------------------

I think we can at least take a look. I'm out on a fairly long vacation soon so in any case it won't be before August or so.

Ah don't worry, if this all lands in the 5.3 merge window I can take a look in a few weeks.

Quoted 8 lines

One use we still have for master_set() is that if a master is switched away, and then the mode list changes, and then the master is switched back, it will typically not remember to act on the sysfs event received while switched out, and come back in an incorrect mode. Since mode-list changes happen quite frequently with virtual display adapters that's bad.

But perhaps we can consider moving that to core, if that's what needed to get rid of the master switch callbacks.

Hm, this sounds a bit like papering over userspace bugs, at least if you're referring to drm_sysfs_hotplug_event(). Userspace is supposed to either keep listening or to re-acquire all the kms output state and do the hotplugg processing in one go when becoming active again.

Quoted 8 lines
Quoted 4 lines

Ofc it exists, so we can't just remove it. I wouldn't want to make this part of the uapi though, feels like duct-taping around sloppy userspace. Maybe we could work on a gradual plan to deprecate this, with limiting it only to older vmwgfx versions as a start?

Sounds ok with me. First I guess I need to figure out what compositors / user-space drivers actually suffer from this. If there are many, it might be a pain trying to fix them all.

Yeah if this shipped already sailed for most compositors, then I guess we need to upgrade this to cross-driver behavior. If it's just some vmwgfx thing, then we should try to phase it out slowly somehow.

Either way I much prefer consistent behaviour for anything that is relevant for kms clients and compositors.

Anyway, great progress on the other master callbacks, thanks a lot for doing that!

Cheers, Daniel

Quoted 13 lines

Thanks,

Thomas

Quoted 5 lines

These kind of tiny but important differences in how drivers implement kms is why I'd much, much prefer it's not even possible to do stuff like this.

Thanks, Daniel

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#10 lore raw
In reply to Emil Velikov
Quoted 18 lines · Emil Velikov

Hi Thomas,

Quoted 13 lines · Thomas Hellström (VMware)

From: Thomas Hellstrom <[email protected]>

TTM provides a means to assign eviction priorities to buffer object. This means that all buffer objects with a lower priority will be evicted first on memory pressure.
Use this to make sure surfaces and in particular non-dirty surfaces are evicted first. Evicting in particular shaders, cotables and contexts imply a significant performance hit on vmwgfx, so make sure these resources are evicted last.
Some buffer objects are sub-allocated in user-space which means we can have many resources attached to a single buffer object or resource. In that case the buffer object is given the highest priority of the attached resources.

Quoted 2 lines
Quoted 8 lines

Fwiw patches 1-3 are:

Patch 4 is:

Huge thanks for sorting this out.
Emil

Thanks for reviewing, Emil.

/Thomas

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel