modesetting: re-set the crtc's mode when link-status goes BAD
PATCH 1/1 modesetting: re-set the crtc's mode when link-status goes BAD
From: Martin Peres <[email protected]>
Despite all the careful planning of the kernel, a link may become insufficient to handle the currently-set mode. At this point, the kernel should mark this particular configuration as being broken and potentially prune the mode before setting the offending connector's link-status to BAD and send the userspace a hotplug event. This may happen right after a modeset or later on.
Upon receiving a hot-plug event, we iterate through the connectors to re-apply the currently-set mode on all the connectors that have a link-status property set to BAD. The kernel may be able to get the link to work by dropping to using a lower link bpp (with the same display bpp). However, the modeset may fail if the kernel has pruned the mode, so to make users aware of this problem a warning is outputed in the logs to warn about having a potentially-black display.
This patch does not modify the current behaviour of always propagating the events to the randr clients. This allows desktop environments to re-probe the connectors and select a new resolution based on the new (currated) mode list if a mode disapeared. This behaviour is expected in order to pass the Display Port compliance tests.
(Ported from xserver commit bcee1b76aa0db8525b491485e90b8740763d7de6)
[ Michel: Bump libdrm dependency to >= 2.4.78 for
DRM_MODE_LINK_STATUS_BAD ]
(Ported from radeon commit 0472a605e0ec8fec1892bbc3a84698b7ef9c5296)
--- configure.ac | 2 +- src/drmmode_display.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 1 deletion(-)
configure.ac +1 -1
@@ -70,7 +70,7 @@ XORG_DRIVER_CHECK_EXT(XV, videoproto) XORG_DRIVER_CHECK_EXT(DPMSExtension, xextproto) # Checks for libraries. -PKG_CHECK_MODULES(LIBDRM, [libdrm >= 2.4.72]) +PKG_CHECK_MODULES(LIBDRM, [libdrm >= 2.4.78]) PKG_CHECK_MODULES(LIBDRM_AMDGPU, [libdrm_amdgpu >= 2.4.72]) PKG_CHECK_MODULES(GBM, [gbm])
src/drmmode_display.c +43 -0
49 lines not on this page · raw message
Signature · 6 lines
2.14.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 20170822094819.8006-1-michel-otUistvHUpPR7s880joybQ@public.gmane.org
Harry Wentland
Acked-byQuoted 23 lines · Michel Dänzer
From: Martin Peres <[email protected]>
Despite all the careful planning of the kernel, a link may become insufficient to handle the currently-set mode. At this point, the kernel should mark this particular configuration as being broken and potentially prune the mode before setting the offending connector's link-status to BAD and send the userspace a hotplug event. This may happen right after a modeset or later on.
Upon receiving a hot-plug event, we iterate through the connectors to re-apply the currently-set mode on all the connectors that have a link-status property set to BAD. The kernel may be able to get the link to work by dropping to using a lower link bpp (with the same display bpp). However, the modeset may fail if the kernel has pruned the mode, so to make users aware of this problem a warning is outputed in the logs to warn about having a potentially-black display.
This patch does not modify the current behaviour of always propagating the events to the randr clients. This allows desktop environments to re-probe the connectors and select a new resolution based on the new (currated) mode list if a mode disapeared. This behaviour is expected in order to pass the Display Port compliance tests.
Quoted 7 lines
(Ported from xserver commit
bcee1b76aa0db8525b491485e90b8740763d7de6)[ Michel: Bump libdrm dependency to >= 2.4.78 for
DRM_MODE_LINK_STATUS_BAD]
(Ported from radeon commit0472a605e0ec8fec1892bbc3a84698b7ef9c5296)Signed-off-by Michel Dänzer <[email protected]>
Thanks, and
I'll send an amd/display kernel patch soon to set link-status to bad.
Harry
Quoted 63 lines
--- configure.ac | 2 +- src/drmmode_display.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 1 deletion(-)configure.ac +1
-1@@ -70,7 +70,7 @@ XORG_DRIVER_CHECK_EXT(XV, videoproto) XORG_DRIVER_CHECK_EXT(DPMSExtension, xextproto) # Checks for libraries. -PKG_CHECK_MODULES(LIBDRM, [libdrm >= 2.4.72]) +PKG_CHECK_MODULES(LIBDRM, [libdrm >= 2.4.78]) PKG_CHECK_MODULES(LIBDRM_AMDGPU, [libdrm_amdgpu >= 2.4.72]) PKG_CHECK_MODULES(GBM, [gbm])src/drmmode_display.c +36
-0@@ -2627,6 +2627,49 @@ amdgpu_mode_hotplug(ScrnInfoPtr scrn, drmmode_ptr drmmode)Bool changed = FALSE;int num_dvi =0 , num_hdmi =0 ; +/* 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 +* mode is not achievable anymore, it should have pruned the mode before +* sending the hotplug event. Try to re-set the currently-set mode to keep +* the display alive, this will fail if the mode has been pruned. +* In any case, we will send randr events for the Desktop Environment to +* deal with it, if it wants to. +*/ +for (i =0 ; i < config->num_output; i++) { +xf86OutputPtr output = config->output[i]; +drmmode_output_private_ptr drmmode_output = output->driver_private; +uint32_t con_id = drmmode_output->mode_output->connector_id; +drmModeConnectorPtr koutput; + +/* Get an updated view of the properties for the current connector and +* look for the link-status property +*/ + koutput =drmModeGetConnectorCurrent (pAMDGPUEnt->fd, con_id); +for (j =0 ; koutput && j < koutput->count_props; j++) { +drmModePropertyPtr props; + props =drmModeGetProperty (pAMDGPUEnt->fd, koutput->props[j]); +if (props && props->flags &DRM_MODE_PROP_ENUM && + !strcmp (props->name,"link-status" ) && + koutput->prop_values[j] ==DRM_MODE_LINK_STATUS_BAD ) { +xf86CrtcPtr crtc = output->crtc; +if (!crtc) +continue ; + +/* the connector got a link failure, re-set the current mode */ +drmmode_set_mode_major (crtc, &crtc->mode, crtc->rotation, + crtc->x, crtc->y); + +xf86DrvMsg (scrn->scrnIndex,X_WARNING , +"hotplug event: connector %u's link-state is BAD, " + "tried resetting the current mode. You may be left "
src/drmmode_display.c amdgpu_mode_hotplug(ScrnInfoPtr scrn, drmmode_ptr drmmode) · line 2675
Quoted 10 lines
src/drmmode_display.c +7
-0+ "with a black screen if this fails...\n", con_id); + } +drmModeFreeProperty (props); + } +drmModeFreeConnector (koutput); + } + mode_res =drmModeGetResources (pAMDGPUEnt->fd);if (!mode_res) goto out;
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Deucher, Alexander
Reviewed-by Alex DeucherQuoted 31 lines
-----Original Message-----
From: amd-gfx [mailto:[email protected]] On Behalf Of Michel Dänzer
Sent: Tuesday, August 22, 2017 5:48 AM
To: [email protected]
Subject: [PATCH xf86-video-amdgpu] modesetting: re-set the crtc's mode when link-status goes BADFrom: Martin Peres <[email protected]>
Despite all the careful planning of the kernel, a link may become insufficient to handle the currently-set mode. At this point, the kernel should mark this particular configuration as being broken and potentially prune the mode before setting the offending connector's link-status to BAD and send the userspace a hotplug event. This may happen right after a modeset or later on.
Upon receiving a hot-plug event, we iterate through the connectors to re-apply the currently-set mode on all the connectors that have a link-status property set to BAD. The kernel may be able to get the link to work by dropping to using a lower link bpp (with the same display bpp). However, the modeset may fail if the kernel has pruned the mode, so to make users aware of this problem a warning is outputed in the logs to warn about having a potentially-black display.
This patch does not modify the current behaviour of always propagating the events to the randr clients. This allows desktop environments to re-probe the connectors and select a new resolution based on the new (currated) mode list if a mode disapeared. This behaviour is expected in order to pass the Display Port compliance tests.
Quoted 8 lines
(Ported from xserver commit
bcee1b76aa0db8525b491485e90b8740763d7de6)[ Michel: Bump libdrm dependency to >= 2.4.78 for
DRM_MODE_LINK_STATUS_BAD]
(Ported from radeon commit0472a605e0ec8fec1892bbc3a84698b7ef9c5296)Signed-off-by Michel Dänzer <[email protected]>
Quoted 94 lines
--- configure.ac | 2 +- src/drmmode_display.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 1 deletion(-)configure.ac +1
-1@@ -70,7 +70,7 @@ XORG_DRIVER_CHECK_EXT(XV, videoproto) XORG_DRIVER_CHECK_EXT(DPMSExtension, xextproto) # Checks for libraries. -PKG_CHECK_MODULES(LIBDRM, [libdrm >= 2.4.72]) +PKG_CHECK_MODULES(LIBDRM, [libdrm >= 2.4.78]) PKG_CHECK_MODULES(LIBDRM_AMDGPU, [libdrm_amdgpu >= 2.4.72]) PKG_CHECK_MODULES(GBM, [gbm])src/drmmode_display.c +2
-0@@ -2627,6 +2627,49 @@ amdgpu_mode_hotplug(ScrnInfoPtr scrn, drmmode_ptr drmmode) Bool changed = FALSE;int num_dvi =0 , num_hdmi =0 ; +/* 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
src/drmmode_display.c +1
-0+* different link-training parameters. If the kernel found that the current
src/drmmode_display.c +1
-0+* mode is not achievable anymore, it should have pruned the mode before
src/drmmode_display.c +1
-0+* sending the hotplug event. Try to re-set the currently-set mode to keep
src/drmmode_display.c +2
-0+* the display alive, this will fail if the mode has been pruned. +* In any case, we will send randr events for the Desktop Environment to
src/drmmode_display.c +5
-0+* deal with it, if it wants to. +*/ +for (i =0 ; i < config->num_output; i++) { +xf86OutputPtr output = config->output[i]; + drmmode_output_private_ptr drmmode_output = output-Quoted 1 line
driver_private;src/drmmode_display.c +1
-0+ uint32_t con_id = drmmode_output->mode_output-Quoted 1 line
connector_id;src/drmmode_display.c +3
-0+drmModeConnectorPtr koutput; + +/* Get an updated view of the properties for the current connector and
src/drmmode_display.c +3
-0+* look for the link-status property +*/ + koutput = drmModeGetConnectorCurrent(pAMDGPUEnt-Quoted 1 line
fd,
con_id);src/drmmode_display.c +3
-0+for (j =0 ; koutput && j < koutput->count_props; j++) { +drmModePropertyPtr props; + props = drmModeGetProperty(pAMDGPUEnt->fd,koutput->props[j]);
src/drmmode_display.c +1
-0+ if (props && props->flags &
DRM_MODE_PROP_ENUM&&src/drmmode_display.c +2
-0+ !strcmp (props->name,"link-status" ) && + koutput->prop_values[j] ==
DRM_MODE_LINK_STATUS_BAD) {src/drmmode_display.c +5
-0+xf86CrtcPtr crtc = output->crtc; +if (!crtc) +continue ; + +/* the connector got a link failure, re-set the current mode */
src/drmmode_display.c +1
-0+ drmmode_set_mode_major(crtc, &crtc-Quoted 1 line
mode,
crtc->rotation,src/drmmode_display.c +4
-0+ crtc->x, crtc->y); + + xf86DrvMsg(scrn->scrnIndex, X_WARNING, + "hotplug event: connector %u's link-state is BAD, "
src/drmmode_display.c +1
-0+ "tried resetting the current mode.You may be left "
src/drmmode_display.c +1
-0+ "with a black screen if this fails...\n",
con_id);src/drmmode_display.c +6
-1+ } +drmModeFreeProperty (props); + } +drmModeFreeConnector (koutput); + } + mode_res =drmModeGetResources (pAMDGPUEnt->fd);if (!mode_res) goto out; --2.14.1
Quoted 4 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx