From ae3737d8b2e98ff375d9595553d442bacaabed52 Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: Tue, 15 Dec 2020 11:06:50 -0500 Subject: [PATCH] import xorg-x11-server-1.20.8-6.1.el8_3 --- ...tting-check-the-kms-state-on-EnterVT.patch | 122 +++++++++++++ ...-going-if-a-modeset-fails-on-EnterVT.patch | 160 ++++++++++++++++++ SPECS/xorg-x11-server.spec | 8 +- 3 files changed, 289 insertions(+), 1 deletion(-) create mode 100644 SOURCES/0001-modesetting-check-the-kms-state-on-EnterVT.patch create mode 100644 SOURCES/0002-modesetting-keep-going-if-a-modeset-fails-on-EnterVT.patch diff --git a/SOURCES/0001-modesetting-check-the-kms-state-on-EnterVT.patch b/SOURCES/0001-modesetting-check-the-kms-state-on-EnterVT.patch new file mode 100644 index 0000000..07a38c2 --- /dev/null +++ b/SOURCES/0001-modesetting-check-the-kms-state-on-EnterVT.patch @@ -0,0 +1,122 @@ +From 41f85557a939d8037dc5e509e39316bf624fd186 Mon Sep 17 00:00:00 2001 +From: Martin Peres +Date: Fri, 24 Apr 2020 18:06:16 +0300 +Subject: [PATCH xserver 1/2] modesetting: check the kms state on EnterVT +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Normally, we would receive a uevent coming from Linux's DRM subsystem, +which would trigger the check for disappearing/appearing resources. +However, this event is not received when X is not master (another VT +is selected), and so the userspace / desktop environment would not be +notified about the changes that happened while X wasn't master. + +To fix the issue, this patch forces a refresh on EnterVT by splitting +the kms-checking code from the uevent handling into its own (exported) +function called drmmode_update_kms_state. This function is then called +from both the uevent-handling function, and on EnterVT right before +restoring the modes. + +Signed-off-by: Martin Peres +Reviewed-by: Daniel Vetter +Acked-by: Kishore Kadiyala +Tested-by: Kishore Kadiyala +Signed-off-by: Michel Dänzer +--- + hw/xfree86/drivers/modesetting/driver.c | 2 ++ + .../drivers/modesetting/drmmode_display.c | 34 ++++++++++++------- + .../drivers/modesetting/drmmode_display.h | 1 + + 3 files changed, 24 insertions(+), 13 deletions(-) + +diff --git a/hw/xfree86/drivers/modesetting/driver.c b/hw/xfree86/drivers/modesetting/driver.c +index 2aaea5f7d..a4d486a67 100644 +--- a/hw/xfree86/drivers/modesetting/driver.c ++++ b/hw/xfree86/drivers/modesetting/driver.c +@@ -1820,6 +1820,8 @@ EnterVT(ScrnInfoPtr pScrn) + + SetMaster(pScrn); + ++ drmmode_update_kms_state(&ms->drmmode); ++ + if (!drmmode_set_desired_modes(pScrn, &ms->drmmode, TRUE)) + return FALSE; + +diff --git a/hw/xfree86/drivers/modesetting/drmmode_display.c b/hw/xfree86/drivers/modesetting/drmmode_display.c +index 9dd8c5573..646bacecb 100644 +--- a/hw/xfree86/drivers/modesetting/drmmode_display.c ++++ b/hw/xfree86/drivers/modesetting/drmmode_display.c +@@ -3607,30 +3607,19 @@ drmmode_setup_colormap(ScreenPtr pScreen, ScrnInfoPtr pScrn) + return TRUE; + } + +-#ifdef CONFIG_UDEV_KMS +- + #define DRM_MODE_LINK_STATUS_GOOD 0 + #define DRM_MODE_LINK_STATUS_BAD 1 + +-static void +-drmmode_handle_uevents(int fd, void *closure) ++void ++drmmode_update_kms_state(drmmode_ptr drmmode) + { +- drmmode_ptr drmmode = closure; + ScrnInfoPtr scrn = drmmode->scrn; +- struct udev_device *dev; + drmModeResPtr mode_res; + xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn); + int i, j; + Bool found = FALSE; + Bool changed = FALSE; + +- while ((dev = udev_monitor_receive_device(drmmode->uevent_monitor))) { +- udev_device_unref(dev); +- found = TRUE; +- } +- if (!found) +- return; +- + /* Try to re-set the mode on all the connectors with a BAD link-state: + * This may happen if a link degrades and a new modeset is necessary, using + * different link-training parameters. If the kernel found that the current +@@ -3745,6 +3734,25 @@ out: + #undef DRM_MODE_LINK_STATUS_BAD + #undef DRM_MODE_LINK_STATUS_GOOD + ++#ifdef CONFIG_UDEV_KMS ++ ++static void ++drmmode_handle_uevents(int fd, void *closure) ++{ ++ drmmode_ptr drmmode = closure; ++ struct udev_device *dev; ++ Bool found = FALSE; ++ ++ while ((dev = udev_monitor_receive_device(drmmode->uevent_monitor))) { ++ udev_device_unref(dev); ++ found = TRUE; ++ } ++ if (!found) ++ return; ++ ++ drmmode_update_kms_state(drmmode); ++} ++ + #endif + + void +diff --git a/hw/xfree86/drivers/modesetting/drmmode_display.h b/hw/xfree86/drivers/modesetting/drmmode_display.h +index 4142607fb..6ef8ab9e4 100644 +--- a/hw/xfree86/drivers/modesetting/drmmode_display.h ++++ b/hw/xfree86/drivers/modesetting/drmmode_display.h +@@ -281,6 +281,7 @@ void drmmode_adjust_frame(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int x, int y); + extern Bool drmmode_set_desired_modes(ScrnInfoPtr pScrn, drmmode_ptr drmmode, Bool set_hw); + extern Bool drmmode_setup_colormap(ScreenPtr pScreen, ScrnInfoPtr pScrn); + ++extern void drmmode_update_kms_state(drmmode_ptr drmmode); + extern void drmmode_uevent_init(ScrnInfoPtr scrn, drmmode_ptr drmmode); + extern void drmmode_uevent_fini(ScrnInfoPtr scrn, drmmode_ptr drmmode); + +-- +2.28.0 + diff --git a/SOURCES/0002-modesetting-keep-going-if-a-modeset-fails-on-EnterVT.patch b/SOURCES/0002-modesetting-keep-going-if-a-modeset-fails-on-EnterVT.patch new file mode 100644 index 0000000..a34d0d3 --- /dev/null +++ b/SOURCES/0002-modesetting-keep-going-if-a-modeset-fails-on-EnterVT.patch @@ -0,0 +1,160 @@ +From 287a960c316ecae5cb87c9d23dcb25810d67a0d1 Mon Sep 17 00:00:00 2001 +From: Kishore Kadiyala +Date: Sat, 19 Sep 2020 01:28:14 +0530 +Subject: [PATCH xserver 2/2] modesetting: keep going if a modeset fails on + EnterVT +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +There was a time when setting a mode on a CRTC would not depend on the +associated connector's state. If a mode had been set successfully once, +it would mean it would work later on. + +This changed with the introduction of new connectors type that now +require a link training sequence (DP, HDMI 2.0), and that means that +some events may have happened while the X server was not master that +would then prevent the mode from successfully be restored to its +previous state. + +This patch relaxes the requirement that all modes should be restored on +EnterVT, or the entire X-Server would go down by allowing modesets to +fail (with some warnings). If a modeset fails, the CRTC will be +disabled, and a RandR event will be sent for the desktop environment to +fix the situation as well as possible. + +Additional patches might be needed to make sure that the user would +never be left with all screens black in some scenarios. + +v2 (Martin Peres): + - whitespace fixes + - remove the uevent handling (it is done in a previous patch) + - improve the commit message + - reduce the size of the patch by not changing lines needlessly + - return FALSE if one modeset fails in ignore mode + - add comments/todos to explain why we do things + - disable the CRTCs that failed the modeset + +Signed-off-by: Kishore Kadiyala +Signed-off-by: Martin Peres +Reviewed-by: Daniel Vetter +Tested-by: Kishore Kadiyala +Closes: #1010 +Signed-off-by: Michel Dänzer +--- + hw/xfree86/drivers/modesetting/driver.c | 23 +++++++++++++++---- + .../drivers/modesetting/drmmode_display.c | 19 +++++++++++---- + .../drivers/modesetting/drmmode_display.h | 3 ++- + 3 files changed, 36 insertions(+), 9 deletions(-) + +diff --git a/hw/xfree86/drivers/modesetting/driver.c b/hw/xfree86/drivers/modesetting/driver.c +index a4d486a67..ef4a3147d 100644 +--- a/hw/xfree86/drivers/modesetting/driver.c ++++ b/hw/xfree86/drivers/modesetting/driver.c +@@ -705,7 +705,7 @@ msBlockHandler_oneshot(ScreenPtr pScreen, void *pTimeout) + + msBlockHandler(pScreen, pTimeout); + +- drmmode_set_desired_modes(pScrn, &ms->drmmode, TRUE); ++ drmmode_set_desired_modes(pScrn, &ms->drmmode, TRUE, FALSE); + } + + static void +@@ -1348,7 +1348,7 @@ CreateScreenResources(ScreenPtr pScreen) + ret = pScreen->CreateScreenResources(pScreen); + pScreen->CreateScreenResources = CreateScreenResources; + +- if (!drmmode_set_desired_modes(pScrn, &ms->drmmode, pScrn->is_gpu)) ++ if (!drmmode_set_desired_modes(pScrn, &ms->drmmode, pScrn->is_gpu, FALSE)) + return FALSE; + + if (!drmmode_glamor_handle_new_screen_pixmap(&ms->drmmode)) +@@ -1822,8 +1822,23 @@ EnterVT(ScrnInfoPtr pScrn) + + drmmode_update_kms_state(&ms->drmmode); + +- if (!drmmode_set_desired_modes(pScrn, &ms->drmmode, TRUE)) +- return FALSE; ++ /* allow not all modes to be set successfully since some events might have ++ * happened while not being master that could prevent the previous ++ * configuration from being re-applied. ++ */ ++ if (!drmmode_set_desired_modes(pScrn, &ms->drmmode, TRUE, TRUE)) { ++ xf86DisableUnusedFunctions(pScrn); ++ ++ /* TODO: check that at least one screen is on, to allow the user to fix ++ * their setup if all modeset failed... ++ */ ++ ++ /* Tell the desktop environment that something changed, so that they ++ * can hopefully correct the situation ++ */ ++ RRSetChanged(xf86ScrnToScreen(pScrn)); ++ RRTellChanged(xf86ScrnToScreen(pScrn)); ++ } + + return TRUE; + } +diff --git a/hw/xfree86/drivers/modesetting/drmmode_display.c b/hw/xfree86/drivers/modesetting/drmmode_display.c +index 646bacecb..88992f521 100644 +--- a/hw/xfree86/drivers/modesetting/drmmode_display.c ++++ b/hw/xfree86/drivers/modesetting/drmmode_display.c +@@ -3457,9 +3457,11 @@ drmmode_adjust_frame(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int x, int y) + } + + Bool +-drmmode_set_desired_modes(ScrnInfoPtr pScrn, drmmode_ptr drmmode, Bool set_hw) ++drmmode_set_desired_modes(ScrnInfoPtr pScrn, drmmode_ptr drmmode, Bool set_hw, ++ Bool ign_err) + { + xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn); ++ Bool success = TRUE; + int c; + + for (c = 0; c < config->num_crtc; c++) { +@@ -3507,8 +3509,17 @@ drmmode_set_desired_modes(ScrnInfoPtr pScrn, drmmode_ptr drmmode, Bool set_hw) + if (set_hw) { + if (!crtc->funcs-> + set_mode_major(crtc, &crtc->desiredMode, crtc->desiredRotation, +- crtc->desiredX, crtc->desiredY)) +- return FALSE; ++ crtc->desiredX, crtc->desiredY)) { ++ if (!ign_err) ++ return FALSE; ++ else { ++ success = FALSE; ++ crtc->enabled = FALSE; ++ xf86DrvMsg(pScrn->scrnIndex, X_WARNING, ++ "Failed to set the desired mode on connector %s\n", ++ output->name); ++ } ++ } + } else { + crtc->mode = crtc->desiredMode; + crtc->rotation = crtc->desiredRotation; +@@ -3522,7 +3533,7 @@ drmmode_set_desired_modes(ScrnInfoPtr pScrn, drmmode_ptr drmmode, Bool set_hw) + /* Validate leases on VT re-entry */ + drmmode_validate_leases(pScrn); + +- return TRUE; ++ return success; + } + + static void +diff --git a/hw/xfree86/drivers/modesetting/drmmode_display.h b/hw/xfree86/drivers/modesetting/drmmode_display.h +index 6ef8ab9e4..59d79e9a0 100644 +--- a/hw/xfree86/drivers/modesetting/drmmode_display.h ++++ b/hw/xfree86/drivers/modesetting/drmmode_display.h +@@ -278,7 +278,8 @@ void drmmode_DisableSharedPixmapFlipping(xf86CrtcPtr crtc, drmmode_ptr drmmode); + extern Bool drmmode_pre_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int cpp); + extern Bool drmmode_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode); + void drmmode_adjust_frame(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int x, int y); +-extern Bool drmmode_set_desired_modes(ScrnInfoPtr pScrn, drmmode_ptr drmmode, Bool set_hw); ++extern Bool drmmode_set_desired_modes(ScrnInfoPtr pScrn, drmmode_ptr drmmode, ++ Bool set_hw, Bool ign_err); + extern Bool drmmode_setup_colormap(ScreenPtr pScreen, ScrnInfoPtr pScrn); + + extern void drmmode_update_kms_state(drmmode_ptr drmmode); +-- +2.28.0 + diff --git a/SPECS/xorg-x11-server.spec b/SPECS/xorg-x11-server.spec index 0c0d307..92250a2 100644 --- a/SPECS/xorg-x11-server.spec +++ b/SPECS/xorg-x11-server.spec @@ -46,7 +46,7 @@ Summary: X.Org X11 X server Name: xorg-x11-server Version: 1.20.8 -Release: 6%{?gitdate:.%{gitdate}}%{?dist} +Release: 6.1%{?gitdate:.%{gitdate}}%{?dist} URL: http://www.x.org License: MIT Group: User Interface/X @@ -118,6 +118,8 @@ Patch203: 0001-xfree86-Only-switch-to-original-VT-if-it-is-active.patch Patch204: 0001-xwayland-Hold-a-pixmap-reference-in-struct-xwl_prese.patch Patch205: 0001-glamor-Fix-glamor_poly_fill_rect_gl-xRectangle-width.patch Patch206: 0001-xfree86-add-drm-modes-on-non-GTF-panels.patch +Patch207: 0001-modesetting-check-the-kms-state-on-EnterVT.patch +Patch208: 0002-modesetting-keep-going-if-a-modeset-fails-on-EnterVT.patch BuildRequires: systemtap-sdt-devel BuildRequires: git @@ -561,6 +563,10 @@ find %{inst_srcdir}/hw/xfree86 -name \*.c -delete %changelog +* Tue Dec 1 2020 Michel Dänzer - 1.20.8-6.1 +- modesetting: keep going if a modeset fails on EnterVT + Resolves: #1883491 + * Thu Aug 20 2020 Michel Dänzer - 1.20.8-6 - xfree86: add drm modes on non-GTF panels Resolves: #1823461