From: Thomas Zimmermann <tzimmermann@suse.de>
To: airlied@redhat.com, daniel@ffwll.ch, sam@ravnborg.org,
kraxel@redhat.com, emil.l.velikov@gmail.com
Cc: dri-devel@lists.freedesktop.org,
Thomas Zimmermann <tzimmermann@suse.de>,
Daniel Vetter <daniel.vetter@ffwll.ch>,
"Y.C. Chen" <yc_chen@aspeedtech.com>,
stable@vger.kernel.org
Subject: [PATCH 1/3] drm/ast: Do full modeset if the primary plane's format changes
Date: Mon, 27 Jul 2020 09:37:05 +0200 [thread overview]
Message-ID: <20200727073707.21097-2-tzimmermann@suse.de> (raw)
In-Reply-To: <20200727073707.21097-1-tzimmermann@suse.de>
The atomic modesetting code tried to distinguish format changes from
full modesetting operations. In practice, this was buggy and the format
registers were often updated even for simple pageflips.
Instead do a full modeset if the primary plane changes formats. It's
just as rare as an actual mode change, so there will be no performance
penalty.
The patch also replaces a reference to drm_crtc_state.allow_modeset with
the correct call to drm_atomic_crtc_needs_modeset().
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Fixes: 4961eb60f145 ("drm/ast: Enable atomic modesetting")
Cc: Thomas Zimmermann <tzimmermann@suse.de>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Dave Airlie <airlied@redhat.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Sam Ravnborg <sam@ravnborg.org>
Cc: Emil Velikov <emil.l.velikov@gmail.com>
Cc: "Y.C. Chen" <yc_chen@aspeedtech.com>
Cc: <stable@vger.kernel.org> # v5.6+
---
drivers/gpu/drm/ast/ast_mode.c | 23 ++++++++++++++++-------
1 file changed, 16 insertions(+), 7 deletions(-)
diff --git a/drivers/gpu/drm/ast/ast_mode.c b/drivers/gpu/drm/ast/ast_mode.c
index 154cd877d9d1..3680a000b812 100644
--- a/drivers/gpu/drm/ast/ast_mode.c
+++ b/drivers/gpu/drm/ast/ast_mode.c
@@ -527,8 +527,8 @@ static const uint32_t ast_primary_plane_formats[] = {
static int ast_primary_plane_helper_atomic_check(struct drm_plane *plane,
struct drm_plane_state *state)
{
- struct drm_crtc_state *crtc_state;
- struct ast_crtc_state *ast_crtc_state;
+ struct drm_crtc_state *crtc_state, *old_crtc_state;
+ struct ast_crtc_state *ast_crtc_state, *old_ast_crtc_state;
int ret;
if (!state->crtc)
@@ -550,6 +550,15 @@ static int ast_primary_plane_helper_atomic_check(struct drm_plane *plane,
ast_crtc_state->format = state->fb->format;
+ old_crtc_state = drm_atomic_get_old_crtc_state(state->state, state->crtc);
+ if (!old_crtc_state)
+ return 0;
+ old_ast_crtc_state = to_ast_crtc_state(old_crtc_state);
+ if (!old_ast_crtc_state)
+ return 0;
+ if (ast_crtc_state->format != old_ast_crtc_state->format)
+ crtc_state->mode_changed = true;
+
return 0;
}
@@ -775,18 +784,18 @@ static void ast_crtc_helper_atomic_flush(struct drm_crtc *crtc,
ast_state = to_ast_crtc_state(crtc->state);
- format = ast_state->format;
- if (!format)
+ if (!drm_atomic_crtc_needs_modeset(crtc->state))
return;
+ format = ast_state->format;
+ if (drm_WARN_ON_ONCE(dev, !format))
+ return; /* BUG: We didn't set format in primary check(). */
+
vbios_mode_info = &ast_state->vbios_mode_info;
ast_set_color_reg(ast, format);
ast_set_vbios_color_reg(ast, format, vbios_mode_info);
- if (!crtc->state->mode_changed)
- return;
-
adjusted_mode = &crtc->state->adjusted_mode;
ast_set_vbios_mode_reg(ast, adjusted_mode, vbios_mode_info);
--
2.27.0
next parent reply other threads:[~2020-07-27 7:37 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20200727073707.21097-1-tzimmermann@suse.de>
2020-07-27 7:37 ` Thomas Zimmermann [this message]
2020-07-27 10:40 ` [PATCH 1/3] drm/ast: Do full modeset if the primary plane's format changes daniel
2020-07-27 11:24 ` Thomas Zimmermann
2020-07-27 18:31 ` Daniel Vetter
2020-07-27 7:37 ` [PATCH 2/3] drm/ast: Store image size in HW cursor info Thomas Zimmermann
2020-07-27 10:42 ` daniel
2020-07-27 11:37 ` Thomas Zimmermann
2020-07-27 18:32 ` Daniel Vetter
2020-07-27 7:37 ` [PATCH 3/3] drm/ast: Disable cursor while switching display modes Thomas Zimmermann
2020-07-27 10:46 ` daniel
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=20200727073707.21097-2-tzimmermann@suse.de \
--to=tzimmermann@suse.de \
--cc=airlied@redhat.com \
--cc=daniel.vetter@ffwll.ch \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=emil.l.velikov@gmail.com \
--cc=kraxel@redhat.com \
--cc=sam@ravnborg.org \
--cc=stable@vger.kernel.org \
--cc=yc_chen@aspeedtech.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox