All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Hellstrom <thellstrom@vmware.com>
To: dri-devel@lists.freedesktop.org
Cc: Thomas Hellstrom <thellstrom@vmware.com>,
	linux-graphics-maintainer@vmware.com
Subject: [PATCH -next 05/15] drm/vmwgfx: Fix atomic mode set check
Date: Tue,  3 Jul 2018 21:14:50 +0200	[thread overview]
Message-ID: <20180703191500.2374-6-thellstrom@vmware.com> (raw)
In-Reply-To: <20180703191500.2374-1-thellstrom@vmware.com>

From: Sinclair Yeh <syeh@vmware.com>

vmw_kms_atomic_check_modeset() is currently checking config using the
legacy state, which is updated after a commit has happened.

This means vmw_kms_atomic_check_modeset() will reject an invalid config
on the next update rather than the current one.

Fix this by using the new states for config checking

Signed-off-by: Sinclair Yeh <syeh@vmware.com>
Reviewed-by: Deepak Rawat <drawat@vmware.com>
Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
---
 drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 40 +++++++++++++++++++----------
 1 file changed, 26 insertions(+), 14 deletions(-)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
index e7a7a2e73bbf..6b8541f9215d 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
@@ -1526,33 +1526,45 @@ static int
 vmw_kms_atomic_check_modeset(struct drm_device *dev,
 			     struct drm_atomic_state *state)
 {
-	struct drm_crtc_state *crtc_state;
+	struct drm_crtc_state *new_crtc_state;
+	struct drm_plane_state *new_plane_state;
+	struct drm_plane *plane;
 	struct drm_crtc *crtc;
 	struct vmw_private *dev_priv = vmw_priv(dev);
-	int i;
+	int i, ret, cpp = 0;
 
-	for_each_new_crtc_in_state(state, crtc, crtc_state, i) {
-		unsigned long requested_bb_mem = 0;
+	ret = drm_atomic_helper_check(dev, state);
 
-		if (dev_priv->active_display_unit == vmw_du_screen_target) {
-			struct drm_plane *plane = crtc->primary;
-			struct drm_plane_state *plane_state;
+	/* If this is not a STDU, then no more checking is necessary */
+	if (ret || dev_priv->active_display_unit != vmw_du_screen_target)
+		return ret;
 
-			plane_state = drm_atomic_get_new_plane_state(state, plane);
+	for_each_new_plane_in_state(state, plane, new_plane_state, i) {
+		if (new_plane_state->fb) {
+			int current_cpp = new_plane_state->fb->pitches[0] /
+					  new_plane_state->fb->width;
 
-			if (plane_state && plane_state->fb) {
-				int cpp = plane_state->fb->format->cpp[0];
+			if (cpp == 0)
+				cpp = current_cpp;
+			else if (current_cpp != cpp)
+				return -EINVAL;
+		}
+	}
 
-				requested_bb_mem += crtc->mode.hdisplay * cpp *
-						    crtc->mode.vdisplay;
-			}
+	for_each_new_crtc_in_state(state, crtc, new_crtc_state, i) {
+		unsigned long requested_bb_mem = 0;
+
+		if (drm_atomic_crtc_needs_modeset(new_crtc_state)) {
+			requested_bb_mem += new_crtc_state->mode.hdisplay *
+					    new_crtc_state->mode.vdisplay *
+					    cpp;
 
 			if (requested_bb_mem > dev_priv->prim_bb_mem)
 				return -EINVAL;
 		}
 	}
 
-	return drm_atomic_helper_check(dev, state);
+	return ret;
 }
 
 static const struct drm_mode_config_funcs vmw_kms_funcs = {
-- 
2.18.0.rc1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  parent reply	other threads:[~2018-07-03 19:16 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-03 19:14 [PATCH -next 00/15] vmwgfx cleanups and modesetting changes Thomas Hellstrom
2018-07-03 19:14 ` [PATCH -next 01/15] drm/vmwgfx: Replace vmw_dma_buffer with vmw_buffer_object Thomas Hellstrom
2018-07-03 19:14 ` [PATCH -next 02/15] drm/vmwgfx: Move buffer object related code to vmwgfx_bo.c Thomas Hellstrom
2018-07-03 19:14 ` [PATCH -next 03/15] drm/vmwgfx: Optimize the buffer object swap_notify callback somewhat Thomas Hellstrom
2018-07-03 19:14 ` [PATCH -next 04/15] drm/vmwgfx: Use blocking buffer object reserves when evicting resources Thomas Hellstrom
2018-07-03 19:14 ` Thomas Hellstrom [this message]
2018-07-04  8:35   ` [PATCH -next 05/15] drm/vmwgfx: Fix atomic mode set check Daniel Vetter
2018-07-04  9:35     ` Thomas Hellstrom
2018-07-03 19:14 ` [PATCH -next 06/15] drm/vmwgfx: Perform topology validation during atomic modeset Thomas Hellstrom
2018-07-03 19:14 ` [PATCH -next 07/15] drm/vmwgfx: Use modeset display memory validation for layout ioctl Thomas Hellstrom
2018-07-03 19:14 ` [PATCH -next 08/15] drm/vmwgfx: Perform memory validations only when need full modeset Thomas Hellstrom
2018-07-03 19:14 ` [PATCH -next 09/15] drm/vmwgfx: Remove primary memory validation against mode while creating fb Thomas Hellstrom
2018-07-03 19:14 ` [PATCH -next 10/15] drm/vmwgfx: Use a mutex to protect gui positioning in vmw_display_unit Thomas Hellstrom
2018-07-03 19:14 ` [PATCH -next 11/15] drm/vmwgfx: Add gui_x/y to vmw_connector_state Thomas Hellstrom
2018-07-03 19:14 ` [PATCH -next 12/15] drm/vmwgfx: Improve on host message error messages Thomas Hellstrom
2018-07-03 19:14 ` [PATCH -next 13/15] drm/vmwgfx: Reorganize the fence wait loop Thomas Hellstrom
2018-07-03 19:14 ` [PATCH -next 14/15] drm/vmwgfx: Fix host message module function declarations Thomas Hellstrom
2018-07-03 19:15 ` [PATCH -next 15/15] drm/vmwgfx: Remove an obsolete __le32 conversion Thomas Hellstrom

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180703191500.2374-6-thellstrom@vmware.com \
    --to=thellstrom@vmware.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-graphics-maintainer@vmware.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.