From: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
To: Sean Paul <seanpaul@chromium.org>
Cc: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 3/3] drm/atomic: Try to preserve the crtc enabled state in drm_atomic_remove_fb.
Date: Mon, 27 Feb 2017 13:01:17 +0100 [thread overview]
Message-ID: <e043345f-280e-6c1e-fb13-389612133d31@linux.intel.com> (raw)
In-Reply-To: <20170223152430.GC17822@art_vandelay>
Op 23-02-17 om 16:24 schreef Sean Paul:
> On Tue, Feb 21, 2017 at 02:51:42PM +0100, Maarten Lankhorst wrote:
>> This introduces a slight behavioral change to rmfb. Instead of
>> disabling a crtc when the primary plane is disabled, we try to
>> preserve it.
>>
>> Apart from old versions of the vmwgfx xorg driver, there is
>> nothing depending on rmfb disabling a crtc. Since vmwgfx is
>> a legacy driver we can safely only disable the plane with atomic.
>> In the conversion to atomic the driver will reject the config
>> without primary plane.
>>
>> If this commit is rejected by the driver then we will still fall
>> back to the old behavior and turn off the crtc.
>>
>> Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
>> ---
>> drivers/gpu/drm/drm_atomic.c | 22 ++++++++++++++++++++--
>> 1 file changed, 20 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
>> index 285e1c23e8c9..0d5b0065208e 100644
>> --- a/drivers/gpu/drm/drm_atomic.c
>> +++ b/drivers/gpu/drm/drm_atomic.c
>> @@ -2070,7 +2070,7 @@ int drm_atomic_remove_fb(struct drm_framebuffer *fb)
>> struct drm_connector *conn;
>> struct drm_connector_state *conn_state;
>> int i, ret = 0;
>> - unsigned plane_mask;
>> + unsigned plane_mask, disable_crtcs = false;
>>
>> state = drm_atomic_state_alloc(dev);
>> if (!state)
>> @@ -2097,7 +2097,13 @@ int drm_atomic_remove_fb(struct drm_framebuffer *fb)
>> goto unlock;
>> }
>>
>> - if (plane_state->crtc->primary == plane) {
>> + /*
>> + * Some drivers do not support keeping crtc active with the
>> + * primary plane disabled. If we fail to commit with -EINVAL
>> + * then we will try to perform the same commit but with all
>> + * crtc's disabled for primary planes as well.
>> + */
>> + if (disable_crtcs && plane_state->crtc->primary == plane) {
>> struct drm_crtc_state *crtc_state;
>>
>> crtc_state = drm_atomic_get_existing_crtc_state(state, plane_state->crtc);
>> @@ -2122,6 +2128,7 @@ int drm_atomic_remove_fb(struct drm_framebuffer *fb)
>> plane->old_fb = plane->fb;
>> }
>>
>> + /* This list is only not empty when disable_crtcs is set. */
>> for_each_connector_in_state(state, conn, conn_state, i) {
>> ret = drm_atomic_set_crtc_for_connector(conn_state, NULL);
>>
>> @@ -2143,6 +2150,17 @@ int drm_atomic_remove_fb(struct drm_framebuffer *fb)
>>
>> drm_atomic_state_put(state);
>>
>> + if (ret == -EINVAL && !disable_crtcs) {
>> + disable_crtcs = true;
>> +
>> + state = drm_atomic_state_alloc(dev);
>> + if (state) {
>> + state->acquire_ctx = &ctx;
>> + goto retry;
> Re-using the retry label is a little fishy here. You need to re-allocate state,
> but we don't drop the locks, which makes things a little unbalanced (I realize
> modeset_lock will s/EALREADY/0/).
drm_modeset_lock can be called any arbitrary numer of times. I'm not worried about it. :)
> Perhaps something like this above would be more clear:
>
> + drm_modeset_acquire_init(&ctx, 0);
> +retry:
> + plane_mask = 0;
> + ret = drm_modeset_lock_all_ctx(dev, &ctx);
> + if (ret)
> + goto unlock;
> +
> +retry_disable:
> + state = drm_atomic_state_alloc(dev);
> + if (!state)
> + return -ENOMEM;
> + state->acquire_ctx = &ctx;
> +
>
> Then you can do:
>
>
> + if (ret == -EINVAL && !disable_crtcs) {
> + disable_crtcs = true;
> + goto retry_disable;
> + }
>
> (you would also need to ensure you moved the state_put above the EDEADLK
> handling).
>
> Thoughts?
In general we try to call drm_atomic_state_clear instead of drm_atomic_state_put, this would be a source of confusion for being different from other users of atomic.
~Maarten
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2017-02-27 12:01 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-21 13:51 [PATCH 0/3] drm/atomic: Make drm_framebuffer_remove atomic, again Maarten Lankhorst
[not found] ` <1487685102-31991-1-git-send-email-maarten.lankhorst-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2017-02-21 13:51 ` [PATCH 1/3] drm/atomic: Make disable_all helper fully disable the crtc Maarten Lankhorst
2017-02-23 15:03 ` Sean Paul
2017-02-23 20:10 ` Maarten Lankhorst
2017-02-21 13:51 ` [PATCH 2/3] drm: Convert drm_framebuffer_remove to atomic, v4 Maarten Lankhorst
2017-02-23 15:09 ` Sean Paul
2017-02-28 12:03 ` Daniel Vetter
2017-02-21 13:51 ` [PATCH 3/3] drm/atomic: Try to preserve the crtc enabled state in drm_atomic_remove_fb Maarten Lankhorst
2017-02-23 15:24 ` Sean Paul
2017-02-27 12:01 ` Maarten Lankhorst [this message]
[not found] ` <20170221152344.24239.80784@emeril.freedesktop.org>
2017-02-22 11:48 ` ✗ Fi.CI.BAT: failure for drm/atomic: Make drm_framebuffer_remove atomic, again Maarten Lankhorst
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=e043345f-280e-6c1e-fb13-389612133d31@linux.intel.com \
--to=maarten.lankhorst@linux.intel.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=seanpaul@chromium.org \
/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