mirror of
https://github.com/brl/mutter.git
synced 2024-11-30 12:00:44 -05:00
kms-impl-simple: Handle mode set race conditions gracefully
If we end up trying to do a mode set on a DRM state that has already
changed behind our back without us yet having seen the hotplug event we
may fail with `EINVAL`. Since the renderer layer doesn't handle mode set
failure, it'll still try to page flip later on, which will then also
fail. When failing, it'll try to look up the cached mode set in order to
retry the mode set later on, as is needed to handle other error
conditions. However, if the mode set prior to the page flip failed, we
won't cache the mode set, and the page flip error handling code will get
confused.
Instead of asserting that a page flip always has a valid cached mode set
ready to look up, handle it being missing more gracefully by failing to
mode set. It is expected that things will correct themself as there
should be a hotplug event waiting around the the corner, to reconfigure
the monitor configuration setting new modes.
Fixes: https://gitlab.gnome.org/GNOME/mutter/issues/917
https://gitlab.gnome.org/GNOME/mutter/merge_requests/1007
(cherry picked from commit ce3409b2b7
)
This commit is contained in:
parent
be777dbd79
commit
01d93f2819
@ -324,6 +324,13 @@ retry_page_flip_data_free (RetryPageFlipData *retry_page_flip_data)
|
||||
g_free (retry_page_flip_data);
|
||||
}
|
||||
|
||||
static CachedModeSet *
|
||||
get_cached_mode_set (MetaKmsImplSimple *impl_simple,
|
||||
MetaKmsCrtc *crtc)
|
||||
{
|
||||
return g_hash_table_lookup (impl_simple->cached_mode_sets, crtc);
|
||||
}
|
||||
|
||||
static float
|
||||
get_cached_crtc_refresh_rate (MetaKmsImplSimple *impl_simple,
|
||||
MetaKmsCrtc *crtc)
|
||||
@ -645,14 +652,30 @@ process_page_flip (MetaKmsImpl *impl,
|
||||
|
||||
if (ret == -EBUSY)
|
||||
{
|
||||
float refresh_rate;
|
||||
CachedModeSet *cached_mode_set;
|
||||
|
||||
refresh_rate = get_cached_crtc_refresh_rate (impl_simple, crtc);
|
||||
schedule_retry_page_flip (impl_simple,
|
||||
crtc,
|
||||
plane_assignment->fb_id,
|
||||
refresh_rate,
|
||||
page_flip_data);
|
||||
cached_mode_set = get_cached_mode_set (impl_simple, crtc);
|
||||
if (cached_mode_set)
|
||||
{
|
||||
drmModeModeInfo *drm_mode;
|
||||
float refresh_rate;
|
||||
|
||||
drm_mode = cached_mode_set->drm_mode;
|
||||
refresh_rate = meta_calculate_drm_mode_refresh_rate (drm_mode);
|
||||
schedule_retry_page_flip (impl_simple,
|
||||
crtc,
|
||||
plane_assignment->fb_id,
|
||||
refresh_rate,
|
||||
page_flip_data);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
||||
"Page flip of %u failed, and no mode set available",
|
||||
meta_kms_crtc_get_id (crtc));
|
||||
meta_kms_page_flip_data_unref (page_flip_data);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
else if (ret == -EINVAL)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user