Skip to contentSkip to conversation

modesetting: re-set the crtc's mode when link-status goes BAD

RFC PATCH In review Martin Peres 9 participants 36 messages Jan 26, 2017 – Apr 6, 2017 11 messages not in the archive

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 modesetting: re-set the crtc's mode when link-status goes BAD

Despite all the careful planing 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.

When available, we should use the link-status information to reset the wanted mode.

---

WARNING: The patches have not been merged in the kernel yet, so this patch is merely an RFC.

This patch is the result of discussions happening mostly in DRI-devel and Intel-GFX on how to handle link training failures. I would advise reading the thread [0] first and then this thread [1] which explain in great length why this is needed and why the selected approach seems to be the best.

The relevant kernel patches + this patch are enough to pass the relevant DisplayPort compliance tests, provided that the Desktop Environment or another program ([2]?) provides the initial modesetting on hotplug.

Would this patch be acceptable to you? Any comments or suggestions?

[0] https://lists.freedesktop.org/archives/dri-devel/2016-November/123366.html
[1] https://lists.freedesktop.org/archives/dri-devel/2016-November/124736.html
[2] https://cgit.freedesktop.org/~mperes/auto-randr/

 hw/xfree86/drivers/modesetting/drmmode_display.c | 51 ++++++++++++++++++++++++
 1 file changed, 51 insertions(+)
hw/xfree86/drivers/modesetting/drmmode_display.c +51 -0
index 6e755e9482..3144620c67 100644
@@ -2262,6 +2262,10 @@ drmmode_setup_colormap(ScreenPtr pScreen, ScrnInfoPtr pScrn)
 }
 
 #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)
 {
@@ -2281,6 +2285,49 @@ drmmode_handle_uevents(int fd, void *closure)
     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
+     * 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(drmmode->fd, con_id);
+        for (j = 0; koutput && j < koutput->count_props; j++) {
+            drmModePropertyPtr props;
+            props = drmModeGetProperty(drmmode->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"
+                           "with a black screen if this fails...\n", con_id);
+            }
+            drmModeFreeProperty(props);
+        }
+        drmModeFreeConnector(koutput);
+    }
+
     mode_res = drmModeGetResources(drmmode->fd);
     if (!mode_res)
         goto out;
@@ -2345,6 +2392,10 @@ out_free_res:
 out:
     RRGetInfo(xf86ScrnToScreen(scrn), TRUE);
 }
+
+#undef DRM_MODE_LINK_STATUS_BAD
+#undef DRM_MODE_LINK_STATUS_GOOD
+
 #endif
 
 void
Signature · 6 lines
2.11.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#1 lore raw
Quoted 7 lines · Martin Peres

Despite all the careful planing 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.

Quoted 8 lines

When available, we should use the link-status information to reset the wanted mode.

---

WARNING: The patches have not been merged in the kernel yet, so this patch is merely an RFC.

That's how it's supposed to happen, before we can merge the kernel side, we need acceptance (=reviewed) by the userspace side. Which is why this patch here.
-Daniel

Quoted 103 lines

This patch is the result of discussions happening mostly in DRI-devel and Intel-GFX on how to handle link training failures. I would advise reading the thread [0] first and then this thread [1] which explain in great length why this is needed and why the selected approach seems to be the best.

The relevant kernel patches + this patch are enough to pass the relevant DisplayPort compliance tests, provided that the Desktop Environment or another program ([2]?) provides the initial modesetting on hotplug.

Would this patch be acceptable to you? Any comments or suggestions?

[0] https://lists.freedesktop.org/archives/dri-devel/2016-November/123366.html
[1] https://lists.freedesktop.org/archives/dri-devel/2016-November/124736.html
[2] https://cgit.freedesktop.org/~mperes/auto-randr/

 hw/xfree86/drivers/modesetting/drmmode_display.c | 51 ++++++++++++++++++++++++
 1 file changed, 51 insertions(+)
hw/xfree86/drivers/modesetting/drmmode_display.c +51 -0
index 6e755e9482..3144620c67 100644
@@ -2262,6 +2262,10 @@ drmmode_setup_colormap(ScreenPtr pScreen, ScrnInfoPtr pScrn)
 }
 
 #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)
 {
@@ -2281,6 +2285,49 @@ drmmode_handle_uevents(int fd, void *closure)
     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
+     * 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(drmmode->fd, con_id);
+        for (j = 0; koutput && j < koutput->count_props; j++) {
+            drmModePropertyPtr props;
+            props = drmModeGetProperty(drmmode->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"
+                           "with a black screen if this fails...\n", con_id);
+            }
+            drmModeFreeProperty(props);
+        }
+        drmModeFreeConnector(koutput);
+    }
+
     mode_res = drmModeGetResources(drmmode->fd);
     if (!mode_res)
         goto out;
@@ -2345,6 +2392,10 @@ out_free_res:
 out:
     RRGetInfo(xf86ScrnToScreen(scrn), TRUE);
 }
+
+#undef DRM_MODE_LINK_STATUS_BAD
+#undef DRM_MODE_LINK_STATUS_GOOD
+
 #endif
 
 void
Signature · 6 lines
2.11.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

A message that is not in the archive (sent off-list or not yet received): 20170126172120.iflf5b5l4m4wsuus-dv86pmgwkMBes7Z6vYuT8azUEOm+Xw19@public.gmane.org

#3 lore raw
Quoted 14 lines · Daniel Vetter
Quoted 13 lines · Martin Peres

Despite all the careful planing 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.

When available, we should use the link-status information to reset the wanted mode.

---

Quoted 8 lines
Quoted 2 lines

WARNING: The patches have not been merged in the kernel yet, so this patch is merely an RFC.

That's how it's supposed to happen, before we can merge the kernel side, we need acceptance (=reviewed) by the userspace side. Which is why this patch here.
-Daniel

This has been validated with a compliance device inducing a forced link failure during modeset, after which the kernel sets the link-status to BAD and sends a hotplug to userspace. The -modesetting driver then resets the configuration by forcing another mdoeset and retraining the link at lower link rate/lane count. This has been proven to pass DP compliance. It has been also verified that this avoids the black screens in case of such mode failures due to link training failure.

Regards
Manasi

Quoted 95 lines
Quoted 95 lines

This patch is the result of discussions happening mostly in DRI-devel and Intel-GFX on how to handle link training failures. I would advise reading the thread [0] first and then this thread [1] which explain in great length why this is needed and why the selected approach seems to be the best.

The relevant kernel patches + this patch are enough to pass the relevant DisplayPort compliance tests, provided that the Desktop Environment or another program ([2]?) provides the initial modesetting on hotplug.

Would this patch be acceptable to you? Any comments or suggestions?

[0] https://lists.freedesktop.org/archives/dri-devel/2016-November/123366.html
[1] https://lists.freedesktop.org/archives/dri-devel/2016-November/124736.html
[2] https://cgit.freedesktop.org/~mperes/auto-randr/

 hw/xfree86/drivers/modesetting/drmmode_display.c | 51 ++++++++++++++++++++++++
 1 file changed, 51 insertions(+)
hw/xfree86/drivers/modesetting/drmmode_display.c +51 -0
index 6e755e9482..3144620c67 100644
@@ -2262,6 +2262,10 @@ drmmode_setup_colormap(ScreenPtr pScreen, ScrnInfoPtr pScrn)
 }
 
 #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)
 {
@@ -2281,6 +2285,49 @@ drmmode_handle_uevents(int fd, void *closure)
     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
+     * 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(drmmode->fd, con_id);
+        for (j = 0; koutput && j < koutput->count_props; j++) {
+            drmModePropertyPtr props;
+            props = drmModeGetProperty(drmmode->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"
+                           "with a black screen if this fails...\n", con_id);
+            }
+            drmModeFreeProperty(props);
+        }
+        drmModeFreeConnector(koutput);
+    }
+
     mode_res = drmModeGetResources(drmmode->fd);
     if (!mode_res)
         goto out;
@@ -2345,6 +2392,10 @@ out_free_res:
 out:
     RRGetInfo(xf86ScrnToScreen(scrn), TRUE);
 }
+
+#undef DRM_MODE_LINK_STATUS_BAD
+#undef DRM_MODE_LINK_STATUS_GOOD
+
 #endif
 
Quoted 13 lines
Quoted 8 lines
hw/xfree86/drivers/modesetting/drmmode_display.c +0 -0
 void
Signature · 6 lines
2.11.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

_______________________________________________
[email protected]: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

#4 lore raw
Quoted 24 lines · Manasi Navare
Quoted 14 lines · Daniel Vetter
Quoted 13 lines · Martin Peres

Despite all the careful planing 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.

When available, we should use the link-status information to reset the wanted mode.

---

Quoted 8 lines
Quoted 2 lines

WARNING: The patches have not been merged in the kernel yet, so this patch is merely an RFC.

That's how it's supposed to happen, before we can merge the kernel side, we need acceptance (=reviewed) by the userspace side. Which is why this patch here.
-Daniel

Quoted 7 lines

This has been validated with a compliance device inducing a forced link failure during modeset, after which the kernel sets the link-status to BAD and sends a hotplug to userspace. The -modesetting driver then resets the configuration by forcing another mdoeset and retraining the link at lower link rate/lane count. This has been proven to pass DP compliance. It has been also verified that this avoids the black screens in case of such mode failures due to link training failure.

Validation is great, but review is what is required and we're after!

BR,
Jani.

Signature · 5 lines
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#5 lore raw
In reply to Martin Peres
Quoted 11 lines · Martin Peres

Despite all the careful planing 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.

When available, we should use the link-status information to reset the wanted mode.

If I understand this right, there are two failure modes being handled:

1) A mode that won't actually work because the link isn't good enough.

2) A mode that should work, but link parameters were too optimistic and if we just ask the kernel to set the mode again it'll use more conservative parameters that work.

This patch seems good for 2). For 1), the drmmode_set_mode_major is going to set our old mode back. Won't the modeset then fail to link train again, and bring us back into this loop? The only escape that I see would be some other userspace responding to the advertised mode list changing, and then asking X to modeset to something new.

To avoid that failure busy loop, should we re-fetching modes at this point, and only re-setting if our mode still exists?

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#6 lore raw
Quoted 22 lines · Eric Anholt
Quoted 11 lines · Martin Peres

Despite all the careful planing 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.

When available, we should use the link-status information to reset the wanted mode.

If I understand this right, there are two failure modes being handled:

1) A mode that won't actually work because the link isn't good enough.

2) A mode that should work, but link parameters were too optimistic and if we just ask the kernel to set the mode again it'll use more conservative parameters that work.

Quoted 8 lines

This patch seems good for 2). For 1), the drmmode_set_mode_major is going to set our old mode back. Won't the modeset then fail to link train again, and bring us back into this loop? The only escape that I see would be some other userspace responding to the advertised mode list changing, and then asking X to modeset to something new.

To avoid that failure busy loop, should we re-fetching modes at this point, and only re-setting if our mode still exists?

Disclaimer: I don't know anything about the internals of the modesetting driver.

Perhaps we can identify the two cases now, but I'd put this more
generally: if the link status has gone bad, it's an indicator to userspace that the circumstances may have changed, and userspace should query the kernel for the list of available modes again. It should no longer trust information obtained prior to getting the bad link status, including the current mode.

But specifically, I think you're right, and AFAICT asking for the list of modes again is the only way for the userspace to distinguish between the two cases. I don't think there's a shortcut for deciding the current mode is still valid.

BR,
Jani.

Signature · 5 lines
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#7 lore raw
Quoted 42 lines · Jani Nikula
Quoted 22 lines · Eric Anholt
Quoted 11 lines · Martin Peres

Despite all the careful planing 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.

When available, we should use the link-status information to reset the wanted mode.

If I understand this right, there are two failure modes being handled:

1) A mode that won't actually work because the link isn't good enough.

2) A mode that should work, but link parameters were too optimistic and if we just ask the kernel to set the mode again it'll use more conservative parameters that work.

Quoted 8 lines

This patch seems good for 2). For 1), the drmmode_set_mode_major is going to set our old mode back. Won't the modeset then fail to link train again, and bring us back into this loop? The only escape that I see would be some other userspace responding to the advertised mode list changing, and then asking X to modeset to something new.

To avoid that failure busy loop, should we re-fetching modes at this point, and only re-setting if our mode still exists?

Disclaimer: I don't know anything about the internals of the modesetting driver.

Perhaps we can identify the two cases now, but I'd put this more
generally: if the link status has gone bad, it's an indicator to userspace that the circumstances may have changed, and userspace should query the kernel for the list of available modes again. It should no longer trust information obtained prior to getting the bad link status, including the current mode.

Quoted 4 lines

But specifically, I think you're right, and AFAICT asking for the list of modes again is the only way for the userspace to distinguish between the two cases. I don't think there's a shortcut for deciding the current mode is still valid.

To avoid the busy-loop problem, I think I'd like this patch to re-query the kernel to ask about the current mode list, and only try to re-set the mode if our mode is still there.

If the mode isn't there, then it's up to the DE to take action in response to the notification of new modes. If you don't have a DE to take appropriate action, you're kind of out of luck.

As far as the ABI goes, this seems fine to me. The only concern I had about ABI was having to walk all the connectors on every uevent to see if any had gone bad -- couldn't we have a flag of some sort about what the uevent indicates? But uevents should be super rare, so I'd say the kernel could go ahead with the current plan.

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#8 lore raw
Quoted 57 lines · Eric Anholt
Quoted 42 lines · Jani Nikula
Quoted 22 lines · Eric Anholt
Quoted 11 lines · Martin Peres

Despite all the careful planing 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.

When available, we should use the link-status information to reset the wanted mode.

If I understand this right, there are two failure modes being handled:

1) A mode that won't actually work because the link isn't good enough.

2) A mode that should work, but link parameters were too optimistic and if we just ask the kernel to set the mode again it'll use more conservative parameters that work.

Quoted 8 lines

This patch seems good for 2). For 1), the drmmode_set_mode_major is going to set our old mode back. Won't the modeset then fail to link train again, and bring us back into this loop? The only escape that I see would be some other userspace responding to the advertised mode list changing, and then asking X to modeset to something new.

To avoid that failure busy loop, should we re-fetching modes at this point, and only re-setting if our mode still exists?

Disclaimer: I don't know anything about the internals of the modesetting driver.

Perhaps we can identify the two cases now, but I'd put this more
generally: if the link status has gone bad, it's an indicator to userspace that the circumstances may have changed, and userspace should query the kernel for the list of available modes again. It should no longer trust information obtained prior to getting the bad link status, including the current mode.

Quoted 4 lines

But specifically, I think you're right, and AFAICT asking for the list of modes again is the only way for the userspace to distinguish between the two cases. I don't think there's a shortcut for deciding the current mode is still valid.

To avoid the busy-loop problem, I think I'd like this patch to re-query the kernel to ask about the current mode list, and only try to re-set the mode if our mode is still there.

If the mode isn't there, then it's up to the DE to take action in response to the notification of new modes. If you don't have a DE to take appropriate action, you're kind of out of luck.

Quoted 5 lines

As far as the ABI goes, this seems fine to me. The only concern I had about ABI was having to walk all the connectors on every uevent to see if any had gone bad -- couldn't we have a flag of some sort about what the uevent indicates? But uevents should be super rare, so I'd say the kernel could go ahead with the current plan.

Yes I agree. The kernel sets the link status BAD as soona s link training fails but does not prune the modes until a new modelist is requested by the userspace. So this patch should re query the mode list as soon as it sees the link status BAD in order for the kernel to validate the modes again based on new link paarmeters and send a new mode list back.
Remember that it could still not prune any mode if the same mode is valid with lower bpp, it will still keep the mode list same and when the userspace retries the same mode, it will do a modeset at lower bpp (say 18bpp) and still succeed. (Same mode at lower bpp still better than dropping the resolution)

Regards
Manasi

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

A message that is not in the archive (sent off-list or not yet received): [email protected]

#10 lore raw
Quoted 60 lines · Manasi Navare
Quoted 54 lines · Eric Anholt
Quoted 40 lines · Jani Nikula
Quoted 21 lines · Eric Anholt
Quoted 11 lines · Martin Peres

Despite all the careful planing 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.

When available, we should use the link-status information to reset the wanted mode.

If I understand this right, there are two failure modes being handled:

1) A mode that won't actually work because the link isn't good enough.

2) A mode that should work, but link parameters were too optimistic and if we just ask the kernel to set the mode again it'll use more conservative parameters that work.

Quoted 8 lines

This patch seems good for 2). For 1), the drmmode_set_mode_major is going to set our old mode back. Won't the modeset then fail to link train again, and bring us back into this loop? The only escape that I see would be some other userspace responding to the advertised mode list changing, and then asking X to modeset to something new.

To avoid that failure busy loop, should we re-fetching modes at this point, and only re-setting if our mode still exists?

Disclaimer: I don't know anything about the internals of the modesetting driver.

Perhaps we can identify the two cases now, but I'd put this more
generally: if the link status has gone bad, it's an indicator to userspace that the circumstances may have changed, and userspace should query the kernel for the list of available modes again. It should no longer trust information obtained prior to getting the bad link status, including the current mode.

Quoted 4 lines

But specifically, I think you're right, and AFAICT asking for the list of modes again is the only way for the userspace to distinguish between the two cases. I don't think there's a shortcut for deciding the current mode is still valid.

To avoid the busy-loop problem, I think I'd like this patch to re-query the kernel to ask about the current mode list, and only try to re-set the mode if our mode is still there.

If the mode isn't there, then it's up to the DE to take action in response to the notification of new modes. If you don't have a DE to take appropriate action, you're kind of out of luck.

Quoted 5 lines

As far as the ABI goes, this seems fine to me. The only concern I had about ABI was having to walk all the connectors on every uevent to see if any had gone bad -- couldn't we have a flag of some sort about what the uevent indicates? But uevents should be super rare, so I'd say the kernel could go ahead with the current plan.

Quoted 5 lines

Yes I agree. The kernel sets the link status BAD as soona s link training fails but does not prune the modes until a new modelist is requested by the userspace. So this patch should re query the mode list as soon as it sees the link status BAD in order for the kernel to validate the modes again based on new link paarmeters and send a new mode list back.

Seems like a bad behaviour from the kernel, isn't it? It should return immediatly if the mode is gonna be pruned :s

With the behaviour you are talking about, I should see 2 uevents when injecting one BAD link-state (first uevent generates a new modeset that will then generate a BAD state and another uevent, but this time the mode will have been pruned so when -modesetting tries to set the mode, it will fail immediatly). During my testing, I do not remember seeing such behaviour, so the kernel seemed to be doing the right thing from my PoV (failing a modeset to a mode that is known not to be achievable). I can verify tommorow, but it would be nice to make sure it is part of the ABI.

As for re-fetching the modes, this is something the DE will do anyway when asking for them via randr. So, really, that will generate double probing in the common case for what seems to be a workaround. Given that probing can be a super expensive operation (request EDID from all monitors, potentially first starting up powered-down GPUs such as NVIDIA or AMD), I would say that probing should not be taken lightly.

Isn't it possible to just return an error from the kernel if the mode should disapear? As far as my testing goes, this was already what seemed to be happening... but I may be wrong, especially since my DP monitor was fine with no link training whatsoever. What is the current ABI for the userspace requesting a mode from a previous monitor to a new one, because it did not reprobe?

In any case, this is a good discussion to have!

Quoted 4 lines

Remember that it could still not prune any mode if the same mode is valid with lower bpp, it will still keep the mode list same and when the userspace retries the same mode, it will do a modeset at lower bpp (say 18bpp) and still succeed. (Same mode at lower bpp still better than dropping the resolution)

Yes, this is the reason why I am doing the re-set of the mode ;) Otherwise, we would not need to do anything in there ;)

Martin

_______________________________________________
[email protected]: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

A message that is not in the archive (sent off-list or not yet received): 32b846ee-69c5-1dea-eed4-1bc41bb2958f-GANU6spQydw@public.gmane.org

#12 lore raw
Quoted 67 lines · Martin Peres
Quoted 60 lines · Manasi Navare
Quoted 54 lines · Eric Anholt
Quoted 40 lines · Jani Nikula
Quoted 21 lines · Eric Anholt
Quoted 11 lines · Martin Peres

Despite all the careful planing 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.

When available, we should use the link-status information to reset the wanted mode.

If I understand this right, there are two failure modes being handled:

1) A mode that won't actually work because the link isn't good enough.

2) A mode that should work, but link parameters were too optimistic and if we just ask the kernel to set the mode again it'll use more conservative parameters that work.

Quoted 8 lines

This patch seems good for 2). For 1), the drmmode_set_mode_major is going to set our old mode back. Won't the modeset then fail to link train again, and bring us back into this loop? The only escape that I see would be some other userspace responding to the advertised mode list changing, and then asking X to modeset to something new.

To avoid that failure busy loop, should we re-fetching modes at this point, and only re-setting if our mode still exists?

Disclaimer: I don't know anything about the internals of the modesetting driver.

Perhaps we can identify the two cases now, but I'd put this more
generally: if the link status has gone bad, it's an indicator to userspace that the circumstances may have changed, and userspace should query the kernel for the list of available modes again. It should no longer trust information obtained prior to getting the bad link status, including the current mode.

Quoted 4 lines

But specifically, I think you're right, and AFAICT asking for the list of modes again is the only way for the userspace to distinguish between the two cases. I don't think there's a shortcut for deciding the current mode is still valid.

To avoid the busy-loop problem, I think I'd like this patch to re-query the kernel to ask about the current mode list, and only try to re-set the mode if our mode is still there.

If the mode isn't there, then it's up to the DE to take action in response to the notification of new modes. If you don't have a DE to take appropriate action, you're kind of out of luck.

Quoted 5 lines

As far as the ABI goes, this seems fine to me. The only concern I had about ABI was having to walk all the connectors on every uevent to see if any had gone bad -- couldn't we have a flag of some sort about what the uevent indicates? But uevents should be super rare, so I'd say the kernel could go ahead with the current plan.

Quoted 5 lines

Yes I agree. The kernel sets the link status BAD as soona s link training fails but does not prune the modes until a new modelist is requested by the userspace. So this patch should re query the mode list as soon as it sees the link status BAD in order for the kernel to validate the modes again based on new link paarmeters and send a new mode list back.

Quoted 3 lines

Seems like a bad behaviour from the kernel, isn't it? It should return immediatly
if the mode is gonna be pruned :s

The kernel only knows that the link was bad because link training failed
so it sets the link status as BAD and sends a uevent expecting userspace
to take action. It will not prune the modes unless drm_helper_probe_single_connector_modes is called by the userspace which would happen only when drmModeGetConnector call is initiated by userspace.

So in your function too to read the link status
you should do a drmModeGetConnector() that will probe the connector modes and validate and prune necessary modes, then if the link status is BAD handle it by two ways:

1. Modeset on the existing mode which will fail if the current mode was pruned already
2. If step 1 fails, then fetch the modes and this will be an updated mode list and modeset on the first mode in the list.

This is how SNA driver implements this.

Danvet/Jani, please correct me if I am wrong and suggest if pruning should be done by kernel instead before sending a uevent on link status BAD.

Regards
Manasi

Quoted 42 lines

With the behaviour you are talking about, I should see 2 uevents when injecting one
BAD link-state (first uevent generates a new modeset that will then generate a BAD
state and another uevent, but this time the mode will have been pruned so when
-modesetting tries to set the mode, it will fail immediatly). During my testing, I do
not remember seeing such behaviour, so the kernel seemed to be doing the right thing
from my PoV (failing a modeset to a mode that is known not to be achievable). I can
verify tommorow, but it would be nice to make sure it is part of the ABI.

As for re-fetching the modes, this is something the DE will do anyway when asking
for them via randr. So, really, that will generate double probing in the common
case for what seems to be a workaround. Given that probing can be a super expensive
operation (request EDID from all monitors, potentially first starting up powered-down
GPUs such as NVIDIA or AMD), I would say that probing should not be taken lightly.

Isn't it possible to just return an error from the kernel if the mode should disapear?
As far as my testing goes, this was already what seemed to be happening... but I may be
wrong, especially since my DP monitor was fine with no link training whatsoever. What
is the current ABI for the userspace requesting a mode from a previous monitor to a new
one, because it did not reprobe?

In any case, this is a good discussion to have!

Quoted 4 lines

Remember that it could still not prune any mode if the same mode is valid with lower bpp, it will still keep the mode list same and when the userspace retries the same mode, it will do a modeset at lower bpp (say 18bpp) and still succeed. (Same mode at lower bpp still better than dropping the resolution)

Quoted 6 lines

Yes, this is the reason why I am doing the re-set of the mode ;) Otherwise, we would not
need to do anything in there ;)

Martin

_______________________________________________
[email protected]: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

#13 lore raw
In reply to Martin Peres
Quoted 67 lines · Martin Peres
Quoted 60 lines · Manasi Navare
Quoted 54 lines · Eric Anholt
Quoted 40 lines · Jani Nikula
Quoted 21 lines · Eric Anholt
Quoted 11 lines · Martin Peres

Despite all the careful planing 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.

When available, we should use the link-status information to reset the wanted mode.

If I understand this right, there are two failure modes being handled:

1) A mode that won't actually work because the link isn't good enough.

2) A mode that should work, but link parameters were too optimistic and if we just ask the kernel to set the mode again it'll use more conservative parameters that work.

Quoted 8 lines

This patch seems good for 2). For 1), the drmmode_set_mode_major is going to set our old mode back. Won't the modeset then fail to link train again, and bring us back into this loop? The only escape that I see would be some other userspace responding to the advertised mode list changing, and then asking X to modeset to something new.

To avoid that failure busy loop, should we re-fetching modes at this point, and only re-setting if our mode still exists?

Disclaimer: I don't know anything about the internals of the modesetting driver.

Perhaps we can identify the two cases now, but I'd put this more
generally: if the link status has gone bad, it's an indicator to userspace that the circumstances may have changed, and userspace should query the kernel for the list of available modes again. It should no longer trust information obtained prior to getting the bad link status, including the current mode.

Quoted 4 lines

But specifically, I think you're right, and AFAICT asking for the list of modes again is the only way for the userspace to distinguish between the two cases. I don't think there's a shortcut for deciding the current mode is still valid.

To avoid the busy-loop problem, I think I'd like this patch to re-query the kernel to ask about the current mode list, and only try to re-set the mode if our mode is still there.

If the mode isn't there, then it's up to the DE to take action in response to the notification of new modes. If you don't have a DE to take appropriate action, you're kind of out of luck.

Quoted 5 lines

As far as the ABI goes, this seems fine to me. The only concern I had about ABI was having to walk all the connectors on every uevent to see if any had gone bad -- couldn't we have a flag of some sort about what the uevent indicates? But uevents should be super rare, so I'd say the kernel could go ahead with the current plan.

Quoted 5 lines

Yes I agree. The kernel sets the link status BAD as soona s link training fails but does not prune the modes until a new modelist is requested by the userspace. So this patch should re query the mode list as soon as it sees the link status BAD in order for the kernel to validate the modes again based on new link paarmeters and send a new mode list back.

Quoted 3 lines

Seems like a bad behaviour from the kernel, isn't it? It should return immediatly
if the mode is gonna be pruned :s

The mode list pruning isn't relevant for modeesets, the kernel doesn't validate requested modes against that. The mode list is purely for userspace's information. Which means updating it only when userspace asks for it is fine.

I also thought some more about the loop when we're stuck on BAD, and I think it shouldn't happen: When the link goes BAD we update the link parameter values to the new limits, and the kernel will reject any mode that won't fit anymore. Of course you might be unlucky, and the new link limits are also not working, but eventually you're stuck at the "you're link is broken, sry" stage, where the kernel rejects everything :-)

So I think the busy-loop has strictly a limited amount of time until it runs out of steam.
-Daniel

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

A message that is not in the archive (sent off-list or not yet received): 20170203080451.vrbmoaioqjyd3hhc-dv86pmgwkMBes7Z6vYuT8azUEOm+Xw19@public.gmane.org

#15 lore raw
Quoted 67 lines · Daniel Vetter
Quoted 66 lines · Martin Peres
Quoted 65 lines · Manasi Navare
Quoted 54 lines · Eric Anholt
Quoted 40 lines · Jani Nikula
Quoted 21 lines · Eric Anholt
Quoted 11 lines · Martin Peres

Despite all the careful planing 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.

When available, we should use the link-status information to reset the wanted mode.

If I understand this right, there are two failure modes being handled:

1) A mode that won't actually work because the link isn't good enough.

2) A mode that should work, but link parameters were too optimistic and if we just ask the kernel to set the mode again it'll use more conservative parameters that work.

Quoted 8 lines

This patch seems good for 2). For 1), the drmmode_set_mode_major is going to set our old mode back. Won't the modeset then fail to link train again, and bring us back into this loop? The only escape that I see would be some other userspace responding to the advertised mode list changing, and then asking X to modeset to something new.

To avoid that failure busy loop, should we re-fetching modes at this point, and only re-setting if our mode still exists?

Disclaimer: I don't know anything about the internals of the modesetting driver.

Perhaps we can identify the two cases now, but I'd put this more
generally: if the link status has gone bad, it's an indicator to userspace that the circumstances may have changed, and userspace should query the kernel for the list of available modes again. It should no longer trust information obtained prior to getting the bad link status, including the current mode.

Quoted 4 lines

But specifically, I think you're right, and AFAICT asking for the list of modes again is the only way for the userspace to distinguish between the two cases. I don't think there's a shortcut for deciding the current mode is still valid.

To avoid the busy-loop problem, I think I'd like this patch to re-query the kernel to ask about the current mode list, and only try to re-set the mode if our mode is still there.

If the mode isn't there, then it's up to the DE to take action in response to the notification of new modes. If you don't have a DE to take appropriate action, you're kind of out of luck.

Quoted 5 lines

As far as the ABI goes, this seems fine to me. The only concern I had about ABI was having to walk all the connectors on every uevent to see if any had gone bad -- couldn't we have a flag of some sort about what the uevent indicates? But uevents should be super rare, so I'd say the kernel could go ahead with the current plan.

Yes I agree. The kernel sets the link status BAD as soona s link training fails but does not prune the modes until a new modelist is requested by the userspace. So this patch should re query the mode list as soon as it sees the link status BAD in order for the kernel to validate the modes again based on new link paarmeters and send a new mode list back.

Quoted 7 lines
Quoted 3 lines

Seems like a bad behaviour from the kernel, isn't it? It should return immediatly
if the mode is gonna be pruned :s

The mode list pruning isn't relevant for modeesets, the kernel doesn't validate requested modes against that. The mode list is purely for userspace's information. Which means updating it only when userspace asks for it is fine.

Hmm, ok. Fair enough!

Quoted 9 lines

I also thought some more about the loop when we're stuck on BAD, and I think it shouldn't happen: When the link goes BAD we update the link parameter values to the new limits, and the kernel will reject any mode that won't fit anymore. Of course you might be unlucky, and the new link limits are also not working, but eventually you're stuck at the "you're link is broken, sry" stage, where the kernel rejects everything :-)

So I think the busy-loop has strictly a limited amount of time until it runs out of steam.

OK, I have given it more thoughts and discussed with Ville and Chris IRL or on IRC.

My current proposal is based on the idea that the kernel should reject a mode it knows it cannot set. This is already largely tested in real life: Try setting 4K@60Hz on an HDMI 1.x monitor, it should immediately fail on prepare(). For this proposal to work, we would need to put in the ABI that a driver that sets the link-status to BAD should also make sure that whatever the userspace does, no infinite loop should be created (by changing the maximum link characteristics before setting the link-status property).

Re-probing the list of modes and checking if the mode is still in there is inherently racy, as a new screen may be plugged between the moment the list is sent to the userspace and the moment when we try setting the mode. Or the DE may also have changed the mode in the mean time and the kernel would have reduced the limits even more. So, the userspace cannot be expected to always do the right thing here :s.

From this point of view, I really do not like the idea of re-probing, since it increases the delay before the DE can handle the change and it does not bring any guarantee of working properly.

Did I miss anything? Any opinions?

Cheers,
Martin
_______________________________________________
[email protected]: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

A message that is not in the archive (sent off-list or not yet received): 4f8317ff-53e8-4c2d-effa-d074b11b15e6-GANU6spQydw@public.gmane.org

#17 lore raw
Quoted 127 lines · Martin Peres
Quoted 85 lines · Daniel Vetter
Quoted 84 lines · Martin Peres
Quoted 83 lines · Manasi Navare
Quoted 67 lines · Eric Anholt
Quoted 49 lines · Jani Nikula
Quoted 33 lines · Eric Anholt
Quoted 8 lines · Martin Peres

Despite all the careful planing 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.

Quoted 4 lines

When available, we should use the link-status information to reset the wanted mode.

If I understand this right, there are two failure modes being handled:

1) A mode that won't actually work because the link isn't good enough.

2) A mode that should work, but link parameters were too optimistic and
if we just ask the kernel to set the mode again it'll use more conservative parameters that work.

This patch seems good for 2). For 1), the drmmode_set_mode_major is going to set our old mode back. Won't the modeset then fail to link train again, and bring us back into this loop? The only escape that I
see would be some other userspace responding to the advertised mode list
changing, and then asking X to modeset to something new.

Quoted 2 lines

To avoid that failure busy loop, should we re-fetching modes at this point, and only re-setting if our mode still exists?

Disclaimer: I don't know anything about the internals of the modesetting
driver.

Perhaps we can identify the two cases now, but I'd put this more
generally: if the link status has gone bad, it's an indicator to userspace that the circumstances may have changed, and userspace should
query the kernel for the list of available modes again. It should no longer trust information obtained prior to getting the bad link status,
including the current mode.

Quoted 7 lines

But specifically, I think you're right, and AFAICT asking for the list
of modes again is the only way for the userspace to distinguish between
the two cases. I don't think there's a shortcut for deciding the current
mode is still valid.

To avoid the busy-loop problem, I think I'd like this patch to re-query
the kernel to ask about the current mode list, and only try to re-set the mode if our mode is still there.

If the mode isn't there, then it's up to the DE to take action in response to the notification of new modes. If you don't have a DE to take appropriate action, you're kind of out of luck.

Quoted 6 lines

As far as the ABI goes, this seems fine to me. The only concern I had about ABI was having to walk all the connectors on every uevent to see if any had gone bad -- couldn't we have a flag of some sort about what the uevent indicates? But uevents should be super rare, so I'd say the
kernel could go ahead with the current plan.

Yes I agree. The kernel sets the link status BAD as soona s link training fails
but does not prune the modes until a new modelist is requested by the userspace.
So this patch should re query the mode list as soon as it sees the link status
BAD in order for the kernel to validate the modes again based on new link
paarmeters and send a new mode list back.

Quoted 7 lines
Quoted 3 lines

Seems like a bad behaviour from the kernel, isn't it? It should return immediatly
if the mode is gonna be pruned :s

The mode list pruning isn't relevant for modeesets, the kernel doesn't validate requested modes against that. The mode list is purely for userspace's information. Which means updating it only when userspace asks for it is fine.

Hmm, ok. Fair enough!

Quoted 9 lines

I also thought some more about the loop when we're stuck on BAD, and I think it shouldn't happen: When the link goes BAD we update the link parameter values to the new limits, and the kernel will reject any mode that won't fit anymore. Of course you might be unlucky, and the new link limits are also not working, but eventually you're stuck at the "you're link is broken, sry" stage, where the kernel rejects everything :-)

So I think the busy-loop has strictly a limited amount of time until it runs out of steam.

OK, I have given it more thoughts and discussed with Ville and Chris IRL or on IRC.

My current proposal is based on the idea that the kernel should reject a mode
it knows it cannot set. This is already largely tested in real life: Try setting 4K@60Hz on an HDMI 1.x monitor, it should immediately fail on prepare(). For this proposal to work, we would need to put in the ABI that a
driver that sets the link-status to BAD should also make sure that whatever the userspace does, no infinite loop should be created (by changing the maximum link characteristics before setting the link-status property).

Re-probing the list of modes and checking if the mode is still in there is inherently racy, as a new screen may be plugged between the moment the list is sent to the userspace and the moment when we try setting the mode. Or the
DE may also have changed the mode in the mean time and the kernel would have reduced the limits even more. So, the userspace cannot be expected to always do the right thing here :s.

Quoted 5 lines

From this point of view, I really do not like the idea of re-probing, since it increases the delay before the DE can handle the change and it does not bring any guarantee of working properly.

Did I miss anything? Any opinions?

Any comments on this, Eric? Does it sound logical to you or did I miss something?

The kernel patches are stuck until this patch gets in. So far, you look like the only person who would be willing to review this patch (Ajax acked the patch, but that's the extent he was willing to go).

Feel free to suggest more potential reviewers if you don't want to commit to a R-b.

Cheers,
Martin

_______________________________________________
[email protected]: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

A message that is not in the archive (sent off-list or not yet received): 069473c6-d75e-48eb-e75d-4e65e201b4fb-VuQAYsv1563Yd54FQh9/[email protected]

#19 lore raw
Quoted 132 lines · Martin Peres
Quoted 131 lines · Martin Peres
Quoted 85 lines · Daniel Vetter
Quoted 84 lines · Martin Peres
Quoted 83 lines · Manasi Navare
Quoted 67 lines · Eric Anholt
Quoted 49 lines · Jani Nikula
Quoted 33 lines · Eric Anholt
Quoted 8 lines · Martin Peres

Despite all the careful planing 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.

Quoted 4 lines

When available, we should use the link-status information to reset the wanted mode.

If I understand this right, there are two failure modes being handled:

1) A mode that won't actually work because the link isn't good enough.

2) A mode that should work, but link parameters were too optimistic and
if we just ask the kernel to set the mode again it'll use more conservative parameters that work.

This patch seems good for 2). For 1), the drmmode_set_mode_major is going to set our old mode back. Won't the modeset then fail to link train again, and bring us back into this loop? The only escape that I
see would be some other userspace responding to the advertised mode list
changing, and then asking X to modeset to something new.

Quoted 2 lines

To avoid that failure busy loop, should we re-fetching modes at this point, and only re-setting if our mode still exists?

Disclaimer: I don't know anything about the internals of the modesetting
driver.

Perhaps we can identify the two cases now, but I'd put this more
generally: if the link status has gone bad, it's an indicator to userspace that the circumstances may have changed, and userspace should
query the kernel for the list of available modes again. It should no longer trust information obtained prior to getting the bad link status,
including the current mode.

Quoted 7 lines

But specifically, I think you're right, and AFAICT asking for the list
of modes again is the only way for the userspace to distinguish between
the two cases. I don't think there's a shortcut for deciding the current
mode is still valid.

To avoid the busy-loop problem, I think I'd like this patch to re-query
the kernel to ask about the current mode list, and only try to re-set the mode if our mode is still there.

If the mode isn't there, then it's up to the DE to take action in response to the notification of new modes. If you don't have a DE to take appropriate action, you're kind of out of luck.

Quoted 6 lines

As far as the ABI goes, this seems fine to me. The only concern I had about ABI was having to walk all the connectors on every uevent to see if any had gone bad -- couldn't we have a flag of some sort about what the uevent indicates? But uevents should be super rare, so I'd say the
kernel could go ahead with the current plan.

Yes I agree. The kernel sets the link status BAD as soona s link training fails
but does not prune the modes until a new modelist is requested by the userspace.
So this patch should re query the mode list as soon as it sees the link status
BAD in order for the kernel to validate the modes again based on new link
paarmeters and send a new mode list back.

Quoted 7 lines
Quoted 3 lines

Seems like a bad behaviour from the kernel, isn't it? It should return immediatly
if the mode is gonna be pruned :s

The mode list pruning isn't relevant for modeesets, the kernel doesn't validate requested modes against that. The mode list is purely for userspace's information. Which means updating it only when userspace asks for it is fine.

Hmm, ok. Fair enough!

Quoted 9 lines

I also thought some more about the loop when we're stuck on BAD, and I think it shouldn't happen: When the link goes BAD we update the link parameter values to the new limits, and the kernel will reject any mode that won't fit anymore. Of course you might be unlucky, and the new link limits are also not working, but eventually you're stuck at the "you're link is broken, sry" stage, where the kernel rejects everything :-)

So I think the busy-loop has strictly a limited amount of time until it runs out of steam.

OK, I have given it more thoughts and discussed with Ville and Chris IRL or on IRC.

My current proposal is based on the idea that the kernel should reject a mode
it knows it cannot set. This is already largely tested in real life: Try setting 4K@60Hz on an HDMI 1.x monitor, it should immediately fail on prepare(). For this proposal to work, we would need to put in the ABI that a
driver that sets the link-status to BAD should also make sure that whatever the userspace does, no infinite loop should be created (by changing the maximum link characteristics before setting the link-status property).

Re-probing the list of modes and checking if the mode is still in there is inherently racy, as a new screen may be plugged between the moment the list is sent to the userspace and the moment when we try setting the mode. Or the
DE may also have changed the mode in the mean time and the kernel would have reduced the limits even more. So, the userspace cannot be expected to always do the right thing here :s.

From this point of view, I really do not like the idea of re-probing, since it increases the delay before the DE can handle the change and it does not bring any guarantee of working properly.

Quoted 8 lines
Quoted 1 line

Did I miss anything? Any opinions?

Any comments on this, Eric? Does it sound logical to you or did I miss something?

The kernel patches are stuck until this patch gets in. So far, you look like the only person who would be willing to review this patch (Ajax acked the patch, but that's the extent he was willing to go).

I was just trying to provide review to get the kernel unstuck. The kernel should not be blocked until the patch gets lands (this obviously isn't the case with ioctls, which *don't* land in userspace until kernel does), you just need userspace published and generally agreed that the ABI works.

_______________________________________________
[email protected]: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

#20 lore raw
Quoted 143 lines · Eric Anholt
Quoted 132 lines · Martin Peres
Quoted 131 lines · Martin Peres
Quoted 85 lines · Daniel Vetter
Quoted 84 lines · Martin Peres
Quoted 83 lines · Manasi Navare
Quoted 67 lines · Eric Anholt
Quoted 49 lines · Jani Nikula
Quoted 33 lines · Eric Anholt
Quoted 8 lines · Martin Peres

Despite all the careful planing 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.

Quoted 4 lines

When available, we should use the link-status information to reset the wanted mode.

If I understand this right, there are two failure modes being handled:

1) A mode that won't actually work because the link isn't good enough.

2) A mode that should work, but link parameters were too optimistic and
if we just ask the kernel to set the mode again it'll use more conservative parameters that work.

This patch seems good for 2). For 1), the drmmode_set_mode_major is going to set our old mode back. Won't the modeset then fail to link train again, and bring us back into this loop? The only escape that I
see would be some other userspace responding to the advertised mode list
changing, and then asking X to modeset to something new.

Quoted 2 lines

To avoid that failure busy loop, should we re-fetching modes at this point, and only re-setting if our mode still exists?

Disclaimer: I don't know anything about the internals of the modesetting
driver.

Perhaps we can identify the two cases now, but I'd put this more
generally: if the link status has gone bad, it's an indicator to userspace that the circumstances may have changed, and userspace should
query the kernel for the list of available modes again. It should no longer trust information obtained prior to getting the bad link status,
including the current mode.

Quoted 7 lines

But specifically, I think you're right, and AFAICT asking for the list
of modes again is the only way for the userspace to distinguish between
the two cases. I don't think there's a shortcut for deciding the current
mode is still valid.

To avoid the busy-loop problem, I think I'd like this patch to re-query
the kernel to ask about the current mode list, and only try to re-set the mode if our mode is still there.

If the mode isn't there, then it's up to the DE to take action in response to the notification of new modes. If you don't have a DE to take appropriate action, you're kind of out of luck.

Quoted 6 lines

As far as the ABI goes, this seems fine to me. The only concern I had about ABI was having to walk all the connectors on every uevent to see if any had gone bad -- couldn't we have a flag of some sort about what the uevent indicates? But uevents should be super rare, so I'd say the
kernel could go ahead with the current plan.

Yes I agree. The kernel sets the link status BAD as soona s link training fails
but does not prune the modes until a new modelist is requested by the userspace.
So this patch should re query the mode list as soon as it sees the link status
BAD in order for the kernel to validate the modes again based on new link
paarmeters and send a new mode list back.

Quoted 7 lines
Quoted 3 lines

Seems like a bad behaviour from the kernel, isn't it? It should return immediatly
if the mode is gonna be pruned :s

The mode list pruning isn't relevant for modeesets, the kernel doesn't validate requested modes against that. The mode list is purely for userspace's information. Which means updating it only when userspace asks for it is fine.

Hmm, ok. Fair enough!

Quoted 9 lines

I also thought some more about the loop when we're stuck on BAD, and I think it shouldn't happen: When the link goes BAD we update the link parameter values to the new limits, and the kernel will reject any mode that won't fit anymore. Of course you might be unlucky, and the new link limits are also not working, but eventually you're stuck at the "you're link is broken, sry" stage, where the kernel rejects everything :-)

So I think the busy-loop has strictly a limited amount of time until it runs out of steam.

OK, I have given it more thoughts and discussed with Ville and Chris IRL or on IRC.

My current proposal is based on the idea that the kernel should reject a mode
it knows it cannot set. This is already largely tested in real life: Try setting 4K@60Hz on an HDMI 1.x monitor, it should immediately fail on prepare(). For this proposal to work, we would need to put in the ABI that a
driver that sets the link-status to BAD should also make sure that whatever the userspace does, no infinite loop should be created (by changing the maximum link characteristics before setting the link-status property).

Re-probing the list of modes and checking if the mode is still in there is inherently racy, as a new screen may be plugged between the moment the list is sent to the userspace and the moment when we try setting the mode. Or the
DE may also have changed the mode in the mean time and the kernel would have reduced the limits even more. So, the userspace cannot be expected to always do the right thing here :s.

From this point of view, I really do not like the idea of re-probing, since it increases the delay before the DE can handle the change and it does not bring any guarantee of working properly.

Quoted 8 lines
Quoted 1 line

Did I miss anything? Any opinions?

Any comments on this, Eric? Does it sound logical to you or did I miss something?

The kernel patches are stuck until this patch gets in. So far, you look like the only person who would be willing to review this patch (Ajax acked the patch, but that's the extent he was willing to go).

Quoted 5 lines

I was just trying to provide review to get the kernel unstuck. The kernel should not be blocked until the patch gets lands (this obviously isn't the case with ioctls, which *don't* land in userspace until kernel does), you just need userspace published and generally agreed that the ABI works.

Thanks Eric. I agree so if we have a consensus from you and Ajax on this design, can we move forward with getting the kernel patches merged?

We already have consensus from kernel folks as well as Ajax, Do we have your ACK on this?

Regards
Manasi
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

A message that is not in the archive (sent off-list or not yet received): 87k28tkdiq.fsf-omZaPlIz5HhaEpDpdNBo/[email protected]

#22 lore raw
Quoted 6 lines · Eric Anholt

I was just trying to provide review to get the kernel unstuck. The kernel should not be blocked until the patch gets lands (this obviously isn't the case with ioctls, which *don't* land in userspace until kernel does), you just need userspace published and generally agreed that the ABI works.

Yeah, I found it a bit odd too that we would get such requirement.

Anyway, thanks for taking the time, we will take this as an ACK from your side, which should be enough to merge the patch in the kernel.

Thanks!
Martin
_______________________________________________
[email protected]: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

#23 lore raw
In reply to Eric Anholt

Hi Daniel,

We have ACKs on the userspace design from both Adams and Eric. Is this enough to merge the kernel patches?

I spoke to Eric briefly about this and he gave me a verbal r-b as well. He said the userspace patches cant get merged unless DRM patches are merged.

So what should be some of our next steps here?

Regards
Manasi

Quoted 143 lines · Eric Anholt
Quoted 132 lines · Martin Peres
Quoted 131 lines · Martin Peres
Quoted 85 lines · Daniel Vetter
Quoted 84 lines · Martin Peres
Quoted 83 lines · Manasi Navare
Quoted 67 lines · Eric Anholt
Quoted 49 lines · Jani Nikula
Quoted 33 lines · Eric Anholt
Quoted 8 lines · Martin Peres

Despite all the careful planing 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.

Quoted 4 lines

When available, we should use the link-status information to reset the wanted mode.

If I understand this right, there are two failure modes being handled:

1) A mode that won't actually work because the link isn't good enough.

2) A mode that should work, but link parameters were too optimistic and
if we just ask the kernel to set the mode again it'll use more conservative parameters that work.

This patch seems good for 2). For 1), the drmmode_set_mode_major is going to set our old mode back. Won't the modeset then fail to link train again, and bring us back into this loop? The only escape that I
see would be some other userspace responding to the advertised mode list
changing, and then asking X to modeset to something new.

Quoted 2 lines

To avoid that failure busy loop, should we re-fetching modes at this point, and only re-setting if our mode still exists?

Disclaimer: I don't know anything about the internals of the modesetting
driver.

Perhaps we can identify the two cases now, but I'd put this more
generally: if the link status has gone bad, it's an indicator to userspace that the circumstances may have changed, and userspace should
query the kernel for the list of available modes again. It should no longer trust information obtained prior to getting the bad link status,
including the current mode.

Quoted 7 lines

But specifically, I think you're right, and AFAICT asking for the list
of modes again is the only way for the userspace to distinguish between
the two cases. I don't think there's a shortcut for deciding the current
mode is still valid.

To avoid the busy-loop problem, I think I'd like this patch to re-query
the kernel to ask about the current mode list, and only try to re-set the mode if our mode is still there.

If the mode isn't there, then it's up to the DE to take action in response to the notification of new modes. If you don't have a DE to take appropriate action, you're kind of out of luck.

Quoted 6 lines

As far as the ABI goes, this seems fine to me. The only concern I had about ABI was having to walk all the connectors on every uevent to see if any had gone bad -- couldn't we have a flag of some sort about what the uevent indicates? But uevents should be super rare, so I'd say the
kernel could go ahead with the current plan.

Yes I agree. The kernel sets the link status BAD as soona s link training fails
but does not prune the modes until a new modelist is requested by the userspace.
So this patch should re query the mode list as soon as it sees the link status
BAD in order for the kernel to validate the modes again based on new link
paarmeters and send a new mode list back.

Quoted 7 lines
Quoted 3 lines

Seems like a bad behaviour from the kernel, isn't it? It should return immediatly
if the mode is gonna be pruned :s

The mode list pruning isn't relevant for modeesets, the kernel doesn't validate requested modes against that. The mode list is purely for userspace's information. Which means updating it only when userspace asks for it is fine.

Hmm, ok. Fair enough!

Quoted 9 lines

I also thought some more about the loop when we're stuck on BAD, and I think it shouldn't happen: When the link goes BAD we update the link parameter values to the new limits, and the kernel will reject any mode that won't fit anymore. Of course you might be unlucky, and the new link limits are also not working, but eventually you're stuck at the "you're link is broken, sry" stage, where the kernel rejects everything :-)

So I think the busy-loop has strictly a limited amount of time until it runs out of steam.

OK, I have given it more thoughts and discussed with Ville and Chris IRL or on IRC.

My current proposal is based on the idea that the kernel should reject a mode
it knows it cannot set. This is already largely tested in real life: Try setting 4K@60Hz on an HDMI 1.x monitor, it should immediately fail on prepare(). For this proposal to work, we would need to put in the ABI that a
driver that sets the link-status to BAD should also make sure that whatever the userspace does, no infinite loop should be created (by changing the maximum link characteristics before setting the link-status property).

Re-probing the list of modes and checking if the mode is still in there is inherently racy, as a new screen may be plugged between the moment the list is sent to the userspace and the moment when we try setting the mode. Or the
DE may also have changed the mode in the mean time and the kernel would have reduced the limits even more. So, the userspace cannot be expected to always do the right thing here :s.

From this point of view, I really do not like the idea of re-probing, since it increases the delay before the DE can handle the change and it does not bring any guarantee of working properly.

Quoted 8 lines
Quoted 1 line

Did I miss anything? Any opinions?

Any comments on this, Eric? Does it sound logical to you or did I miss something?

The kernel patches are stuck until this patch gets in. So far, you look like the only person who would be willing to review this patch (Ajax acked the patch, but that's the extent he was willing to go).

Quoted 5 lines

I was just trying to provide review to get the kernel unstuck. The kernel should not be blocked until the patch gets lands (this obviously isn't the case with ioctls, which *don't* land in userspace until kernel does), you just need userspace published and generally agreed that the ABI works.

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#24 lore raw
Quoted 9 lines · Manasi Navare

Hi Daniel,

We have ACKs on the userspace design from both Adams and Eric. Is this enough to merge the kernel patches?

I spoke to Eric briefly about this and he gave me a verbal r-b as well. He said the userspace patches cant get merged unless DRM patches are merged.

So what should be some of our next steps here?

Still needs review on the kernel patches themselves, iirc Jani still had some opens on that. But I was out of the loop for 2 weeks :-) -Daniel

Quoted 156 lines

Regards
Manasi

Quoted 148 lines · Eric Anholt
Quoted 132 lines · Martin Peres
Quoted 131 lines · Martin Peres
Quoted 85 lines · Daniel Vetter
Quoted 84 lines · Martin Peres
Quoted 83 lines · Manasi Navare
Quoted 67 lines · Eric Anholt
Quoted 49 lines · Jani Nikula
Quoted 33 lines · Eric Anholt
Quoted 8 lines · Martin Peres

Despite all the careful planing 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.

Quoted 4 lines

When available, we should use the link-status information to reset the wanted mode.

If I understand this right, there are two failure modes being handled:

1) A mode that won't actually work because the link isn't good enough.

2) A mode that should work, but link parameters were too optimistic and
if we just ask the kernel to set the mode again it'll use more conservative parameters that work.

This patch seems good for 2). For 1), the drmmode_set_mode_major is going to set our old mode back. Won't the modeset then fail to link train again, and bring us back into this loop? The only escape that I
see would be some other userspace responding to the advertised mode list
changing, and then asking X to modeset to something new.

Quoted 2 lines

To avoid that failure busy loop, should we re-fetching modes at this point, and only re-setting if our mode still exists?

Disclaimer: I don't know anything about the internals of the modesetting
driver.

Perhaps we can identify the two cases now, but I'd put this more
generally: if the link status has gone bad, it's an indicator to userspace that the circumstances may have changed, and userspace should
query the kernel for the list of available modes again. It should no longer trust information obtained prior to getting the bad link status,
including the current mode.

Quoted 7 lines

But specifically, I think you're right, and AFAICT asking for the list
of modes again is the only way for the userspace to distinguish between
the two cases. I don't think there's a shortcut for deciding the current
mode is still valid.

To avoid the busy-loop problem, I think I'd like this patch to re-query
the kernel to ask about the current mode list, and only try to re-set the mode if our mode is still there.

If the mode isn't there, then it's up to the DE to take action in response to the notification of new modes. If you don't have a DE to take appropriate action, you're kind of out of luck.

Quoted 6 lines

As far as the ABI goes, this seems fine to me. The only concern I had about ABI was having to walk all the connectors on every uevent to see if any had gone bad -- couldn't we have a flag of some sort about what the uevent indicates? But uevents should be super rare, so I'd say the
kernel could go ahead with the current plan.

Yes I agree. The kernel sets the link status BAD as soona s link training fails
but does not prune the modes until a new modelist is requested by the userspace.
So this patch should re query the mode list as soon as it sees the link status
BAD in order for the kernel to validate the modes again based on new link
paarmeters and send a new mode list back.

Quoted 7 lines
Quoted 3 lines

Seems like a bad behaviour from the kernel, isn't it? It should return immediatly
if the mode is gonna be pruned :s

The mode list pruning isn't relevant for modeesets, the kernel doesn't validate requested modes against that. The mode list is purely for userspace's information. Which means updating it only when userspace asks for it is fine.

Hmm, ok. Fair enough!

Quoted 9 lines

I also thought some more about the loop when we're stuck on BAD, and I think it shouldn't happen: When the link goes BAD we update the link parameter values to the new limits, and the kernel will reject any mode that won't fit anymore. Of course you might be unlucky, and the new link limits are also not working, but eventually you're stuck at the "you're link is broken, sry" stage, where the kernel rejects everything :-)

So I think the busy-loop has strictly a limited amount of time until it runs out of steam.

OK, I have given it more thoughts and discussed with Ville and Chris IRL or on IRC.

My current proposal is based on the idea that the kernel should reject a mode
it knows it cannot set. This is already largely tested in real life: Try setting 4K@60Hz on an HDMI 1.x monitor, it should immediately fail on prepare(). For this proposal to work, we would need to put in the ABI that a
driver that sets the link-status to BAD should also make sure that whatever the userspace does, no infinite loop should be created (by changing the maximum link characteristics before setting the link-status property).

Re-probing the list of modes and checking if the mode is still in there is inherently racy, as a new screen may be plugged between the moment the list is sent to the userspace and the moment when we try setting the mode. Or the
DE may also have changed the mode in the mean time and the kernel would have reduced the limits even more. So, the userspace cannot be expected to always do the right thing here :s.

From this point of view, I really do not like the idea of re-probing, since it increases the delay before the DE can handle the change and it does not bring any guarantee of working properly.

Quoted 8 lines
Quoted 1 line

Did I miss anything? Any opinions?

Any comments on this, Eric? Does it sound logical to you or did I miss something?

The kernel patches are stuck until this patch gets in. So far, you look like the only person who would be willing to review this patch (Ajax acked the patch, but that's the extent he was willing to go).

I was just trying to provide review to get the kernel unstuck. The kernel should not be blocked until the patch gets lands (this obviously isn't the case with ioctls, which *don't* land in userspace until kernel does), you just need userspace published and generally agreed that the ABI works.

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#25 lore raw
Quoted 9 lines · Manasi Navare

Hi Daniel,

We have ACKs on the userspace design from both Adams and Eric. Is this enough to merge the kernel patches?

I spoke to Eric briefly about this and he gave me a verbal r-b as well. He said the userspace patches cant get merged unless DRM patches are merged.

So what should be some of our next steps here?

Still needs review on the kernel patches themselves, iirc Jani still had some opens on that. But I was out of the loop for 2 weeks :-) -Daniel

Thanks for merging the 1st patch in the kernel series. Are there any opens on the 2nd patch (the i915 patch)?
I wanted to actually respin the 2nd patch to add reset for intel_dp->lane_count on the link training failure so that it doesn't accidently retrain the link with the stale/failed values.

Regards
Manasi

Quoted 154 lines

Regards
Manasi

Quoted 146 lines · Eric Anholt
Quoted 130 lines · Martin Peres
Quoted 129 lines · Martin Peres
Quoted 83 lines · Daniel Vetter
Quoted 82 lines · Martin Peres
Quoted 81 lines · Manasi Navare
Quoted 65 lines · Eric Anholt
Quoted 48 lines · Jani Nikula
Quoted 33 lines · Eric Anholt
Quoted 8 lines · Martin Peres

Despite all the careful planing 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.

Quoted 4 lines

When available, we should use the link-status information to reset the wanted mode.

If I understand this right, there are two failure modes being
handled:

1) A mode that won't actually work because the link isn't good enough.

2) A mode that should work, but link parameters were too optimistic and if we just ask the kernel to set the mode again it'll use more conservative parameters that work.

This patch seems good for 2). For 1), the drmmode_set_mode_major is going to set our old mode back. Won't the modeset then fail to link train again, and bring us back into this loop? The only escape that I see would be some other userspace responding to the advertised mode list changing, and then asking X to modeset to something new.

Quoted 2 lines

To avoid that failure busy loop, should we re-fetching modes at this point, and only re-setting if our mode still exists?

Disclaimer: I don't know anything about the internals of the modesetting driver.

Perhaps we can identify the two cases now, but I'd put this more
generally: if the link status has gone bad, it's an indicator to userspace that the circumstances may have changed, and userspace should query the kernel for the list of available modes again. It should no longer trust information obtained prior to getting the bad link status, including the current mode.

Quoted 5 lines

But specifically, I think you're right, and AFAICT asking for the list of modes again is the only way for the userspace to distinguish between the two cases. I don't think there's a shortcut for deciding the current mode is still valid.

To avoid the busy-loop problem, I think I'd like this patch to
re-query
the kernel to ask about the current mode list, and only try to re-set the mode if our mode is still there.

If the mode isn't there, then it's up to the DE to take action in response to the notification of new modes. If you don't have a DE to take appropriate action, you're kind of out of luck.

Quoted 6 lines

As far as the ABI goes, this seems fine to me. The only concern I had about ABI was having to walk all the connectors on every uevent to see if any had gone bad -- couldn't we have a flag of some sort about what the uevent indicates? But uevents should be super rare, so I'd say the
kernel could go ahead with the current plan.

Yes I agree. The kernel sets the link status BAD as soona s link training fails
but does not prune the modes until a new modelist is requested by the userspace.
So this patch should re query the mode list as soon as it sees the link status
BAD in order for the kernel to validate the modes again based on new link
paarmeters and send a new mode list back.

Quoted 7 lines
Quoted 3 lines

Seems like a bad behaviour from the kernel, isn't it? It should return immediatly
if the mode is gonna be pruned :s

The mode list pruning isn't relevant for modeesets, the kernel doesn't validate requested modes against that. The mode list is purely for userspace's information. Which means updating it only when userspace asks for it is fine.

Hmm, ok. Fair enough!

Quoted 9 lines

I also thought some more about the loop when we're stuck on BAD, and I think it shouldn't happen: When the link goes BAD we update the link parameter values to the new limits, and the kernel will reject any mode that won't fit anymore. Of course you might be unlucky, and the new link limits are also not working, but eventually you're stuck at the "you're link is broken, sry" stage, where the kernel rejects everything :-)

So I think the busy-loop has strictly a limited amount of time until it runs out of steam.

OK, I have given it more thoughts and discussed with Ville and Chris IRL or on IRC.

My current proposal is based on the idea that the kernel should reject a mode
it knows it cannot set. This is already largely tested in real life: Try setting 4K@60Hz on an HDMI 1.x monitor, it should immediately fail on prepare(). For this proposal to work, we would need to put in the ABI that a
driver that sets the link-status to BAD should also make sure that whatever the userspace does, no infinite loop should be created (by changing the maximum link characteristics before setting the link-status property).

Re-probing the list of modes and checking if the mode is still in there is inherently racy, as a new screen may be plugged between the moment the list is sent to the userspace and the moment when we try setting the mode. Or the
DE may also have changed the mode in the mean time and the kernel would have reduced the limits even more. So, the userspace cannot be expected to always do the right thing here :s.

From this point of view, I really do not like the idea of re-probing, since it increases the delay before the DE can handle the change and it does not bring any guarantee of working properly.

Quoted 8 lines
Quoted 1 line

Did I miss anything? Any opinions?

Any comments on this, Eric? Does it sound logical to you or did I miss something?

The kernel patches are stuck until this patch gets in. So far, you look like the only person who would be willing to review this patch (Ajax acked the patch, but that's the extent he was willing to go).

I was just trying to provide review to get the kernel unstuck. The kernel should not be blocked until the patch gets lands (this obviously isn't the case with ioctls, which *don't* land in userspace until kernel does), you just need userspace published and generally agreed that the ABI works.

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#26 lore raw
Quoted 10 lines · Manasi D
Quoted 8 lines · Manasi Navare

Hi Daniel,

We have ACKs on the userspace design from both Adams and Eric. Is this enough to merge the kernel patches?

I spoke to Eric briefly about this and he gave me a verbal r-b as well. He said the userspace patches cant get merged unless DRM patches are merged.

Quoted 6 lines
Quoted 1 line

So what should be some of our next steps here?

Still needs review on the kernel patches themselves, iirc Jani still had some opens on that. But I was out of the loop for 2 weeks :-) -Daniel

Thanks for merging the 1st patch in the kernel series. Are there any opens on the 2nd patch (the i915 patch)?
I wanted to actually respin the 2nd patch to add reset for intel_dp->lane_count on the link training failure so that it doesn't accidently retrain the link with the stale/failed values.

Didn't look like that, and we can do this as a follow-up. I only asked where we should merge it for best results. Let's continue that discussion in the other thread.
-Daniel

Quoted 163 lines

Regards
Manasi

Quoted 154 lines

Regards
Manasi

Quoted 146 lines · Eric Anholt
Quoted 130 lines · Martin Peres
Quoted 129 lines · Martin Peres
Quoted 83 lines · Daniel Vetter
Quoted 82 lines · Martin Peres
Quoted 81 lines · Manasi Navare
Quoted 65 lines · Eric Anholt
Quoted 48 lines · Jani Nikula
Quoted 33 lines · Eric Anholt
Quoted 8 lines · Martin Peres

Despite all the careful planing 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.

Quoted 4 lines

When available, we should use the link-status information to reset the wanted mode.

If I understand this right, there are two failure modes being
handled:

1) A mode that won't actually work because the link isn't good enough.

2) A mode that should work, but link parameters were too optimistic and if we just ask the kernel to set the mode again it'll use more conservative parameters that work.

This patch seems good for 2). For 1), the drmmode_set_mode_major is going to set our old mode back. Won't the modeset then fail to link train again, and bring us back into this loop? The only escape that I see would be some other userspace responding to the advertised mode list changing, and then asking X to modeset to something new.

Quoted 2 lines

To avoid that failure busy loop, should we re-fetching modes at this point, and only re-setting if our mode still exists?

Disclaimer: I don't know anything about the internals of the modesetting driver.

Perhaps we can identify the two cases now, but I'd put this more
generally: if the link status has gone bad, it's an indicator to userspace that the circumstances may have changed, and userspace should query the kernel for the list of available modes again. It should no longer trust information obtained prior to getting the bad link status, including the current mode.

Quoted 5 lines

But specifically, I think you're right, and AFAICT asking for the list of modes again is the only way for the userspace to distinguish between the two cases. I don't think there's a shortcut for deciding the current mode is still valid.

To avoid the busy-loop problem, I think I'd like this patch to
re-query
the kernel to ask about the current mode list, and only try to re-set the mode if our mode is still there.

If the mode isn't there, then it's up to the DE to take action in response to the notification of new modes. If you don't have a DE to take appropriate action, you're kind of out of luck.

Quoted 6 lines

As far as the ABI goes, this seems fine to me. The only concern I had about ABI was having to walk all the connectors on every uevent to see if any had gone bad -- couldn't we have a flag of some sort about what the uevent indicates? But uevents should be super rare, so I'd say the
kernel could go ahead with the current plan.

Yes I agree. The kernel sets the link status BAD as soona s link training fails
but does not prune the modes until a new modelist is requested by the userspace.
So this patch should re query the mode list as soon as it sees the link status
BAD in order for the kernel to validate the modes again based on new link
paarmeters and send a new mode list back.

Quoted 7 lines
Quoted 3 lines

Seems like a bad behaviour from the kernel, isn't it? It should return immediatly
if the mode is gonna be pruned :s

The mode list pruning isn't relevant for modeesets, the kernel doesn't validate requested modes against that. The mode list is purely for userspace's information. Which means updating it only when userspace asks for it is fine.

Hmm, ok. Fair enough!

Quoted 9 lines

I also thought some more about the loop when we're stuck on BAD, and I think it shouldn't happen: When the link goes BAD we update the link parameter values to the new limits, and the kernel will reject any mode that won't fit anymore. Of course you might be unlucky, and the new link limits are also not working, but eventually you're stuck at the "you're link is broken, sry" stage, where the kernel rejects everything :-)

So I think the busy-loop has strictly a limited amount of time until it runs out of steam.

OK, I have given it more thoughts and discussed with Ville and Chris IRL or on IRC.

My current proposal is based on the idea that the kernel should reject a mode
it knows it cannot set. This is already largely tested in real life: Try setting 4K@60Hz on an HDMI 1.x monitor, it should immediately fail on prepare(). For this proposal to work, we would need to put in the ABI that a
driver that sets the link-status to BAD should also make sure that whatever the userspace does, no infinite loop should be created (by changing the maximum link characteristics before setting the link-status property).

Re-probing the list of modes and checking if the mode is still in there is inherently racy, as a new screen may be plugged between the moment the list is sent to the userspace and the moment when we try setting the mode. Or the
DE may also have changed the mode in the mean time and the kernel would have reduced the limits even more. So, the userspace cannot be expected to always do the right thing here :s.

From this point of view, I really do not like the idea of re-probing, since it increases the delay before the DE can handle the change and it does not bring any guarantee of working properly.

Quoted 8 lines
Quoted 1 line

Did I miss anything? Any opinions?

Any comments on this, Eric? Does it sound logical to you or did I miss something?

The kernel patches are stuck until this patch gets in. So far, you look like the only person who would be willing to review this patch (Ajax acked the patch, but that's the extent he was willing to go).

I was just trying to provide review to get the kernel unstuck. The kernel should not be blocked until the patch gets lands (this obviously isn't the case with ioctls, which *don't* land in userspace until kernel does), you just need userspace published and generally agreed that the ABI works.

Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#27 lore raw
In reply to Eric Anholt
Quoted 44 lines · Eric Anholt
Quoted 42 lines · Jani Nikula
Quoted 22 lines · Eric Anholt
Quoted 11 lines · Martin Peres

Despite all the careful planing 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.

When available, we should use the link-status information to reset the wanted mode.

If I understand this right, there are two failure modes being handled:

1) A mode that won't actually work because the link isn't good enough.

2) A mode that should work, but link parameters were too optimistic and if we just ask the kernel to set the mode again it'll use more conservative parameters that work.

Quoted 8 lines

This patch seems good for 2). For 1), the drmmode_set_mode_major is going to set our old mode back. Won't the modeset then fail to link train again, and bring us back into this loop? The only escape that I see would be some other userspace responding to the advertised mode list changing, and then asking X to modeset to something new.

To avoid that failure busy loop, should we re-fetching modes at this point, and only re-setting if our mode still exists?

Disclaimer: I don't know anything about the internals of the modesetting driver.

Perhaps we can identify the two cases now, but I'd put this more
generally: if the link status has gone bad, it's an indicator to userspace that the circumstances may have changed, and userspace should query the kernel for the list of available modes again. It should no longer trust information obtained prior to getting the bad link status, including the current mode.

Quoted 8 lines
Quoted 4 lines

But specifically, I think you're right, and AFAICT asking for the list of modes again is the only way for the userspace to distinguish between the two cases. I don't think there's a shortcut for deciding the current mode is still valid.

To avoid the busy-loop problem, I think I'd like this patch to re-query the kernel to ask about the current mode list, and only try to re-set the mode if our mode is still there.

Yeah, I guess that sounds like a reasonable heuristics. More integrated compositors (aka the wayland ones) might be able to make more useful decisions, but for -modesetting that's probably the best we can do.

Quoted 9 lines

If the mode isn't there, then it's up to the DE to take action in response to the notification of new modes. If you don't have a DE to take appropriate action, you're kind of out of luck.

As far as the ABI goes, this seems fine to me. The only concern I had about ABI was having to walk all the connectors on every uevent to see if any had gone bad -- couldn't we have a flag of some sort about what the uevent indicates? But uevents should be super rare, so I'd say the kernel could go ahead with the current plan.

We've discussed finer-grained uevent singalling a few times, and I'd like that to be an orthogonal abi extension. Right now we just don't have the required tracking even within the kernel to know which connector changed (and the tracking we do have missed a few things, too). My idea is to push the tracking into the leaves of the callchains with a function that increases some per-connector epoch counter. Then we'd just have to expose that somehow cheaply to userspace (could probably just send it along in the uevent). Plus expose it as a read-only property so that userspace can re-synchronize.

But again, that should be an orthogonal thing imo. -Daniel

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#28 lore raw
Quoted 78 lines · Daniel Vetter
Quoted 44 lines · Eric Anholt
Quoted 42 lines · Jani Nikula
Quoted 22 lines · Eric Anholt
Quoted 11 lines · Martin Peres

Despite all the careful planing 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.

When available, we should use the link-status information to reset the wanted mode.

If I understand this right, there are two failure modes being handled:

1) A mode that won't actually work because the link isn't good enough.

2) A mode that should work, but link parameters were too optimistic and if we just ask the kernel to set the mode again it'll use more conservative parameters that work.

Quoted 8 lines

This patch seems good for 2). For 1), the drmmode_set_mode_major is going to set our old mode back. Won't the modeset then fail to link train again, and bring us back into this loop? The only escape that I see would be some other userspace responding to the advertised mode list changing, and then asking X to modeset to something new.

To avoid that failure busy loop, should we re-fetching modes at this point, and only re-setting if our mode still exists?

Disclaimer: I don't know anything about the internals of the modesetting driver.

Perhaps we can identify the two cases now, but I'd put this more
generally: if the link status has gone bad, it's an indicator to userspace that the circumstances may have changed, and userspace should query the kernel for the list of available modes again. It should no longer trust information obtained prior to getting the bad link status, including the current mode.

Quoted 8 lines
Quoted 4 lines

But specifically, I think you're right, and AFAICT asking for the list of modes again is the only way for the userspace to distinguish between the two cases. I don't think there's a shortcut for deciding the current mode is still valid.

To avoid the busy-loop problem, I think I'd like this patch to re-query the kernel to ask about the current mode list, and only try to re-set the mode if our mode is still there.

Yeah, I guess that sounds like a reasonable heuristics. More integrated compositors (aka the wayland ones) might be able to make more useful decisions, but for -modesetting that's probably the best we can do.

Quoted 9 lines

If the mode isn't there, then it's up to the DE to take action in response to the notification of new modes. If you don't have a DE to take appropriate action, you're kind of out of luck.

As far as the ABI goes, this seems fine to me. The only concern I had about ABI was having to walk all the connectors on every uevent to see if any had gone bad -- couldn't we have a flag of some sort about what the uevent indicates? But uevents should be super rare, so I'd say the kernel could go ahead with the current plan.

We've discussed finer-grained uevent singalling a few times, and I'd like that to be an orthogonal abi extension. Right now we just don't have the required tracking even within the kernel to know which connector changed (and the tracking we do have missed a few things, too). My idea is to push the tracking into the leaves of the callchains with a function that increases some per-connector epoch counter. Then we'd just have to expose that somehow cheaply to userspace (could probably just send it along in the uevent). Plus expose it as a read-only property so that userspace can re-synchronize.

Quoted 1 line

But again, that should be an orthogonal thing imo.

Yeah, that was roughly my thought process, too.

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#29 lore raw
Quoted 80 lines · Eric Anholt
Quoted 78 lines · Daniel Vetter
Quoted 44 lines · Eric Anholt
Quoted 42 lines · Jani Nikula
Quoted 22 lines · Eric Anholt
Quoted 11 lines · Martin Peres

Despite all the careful planing 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.

When available, we should use the link-status information to reset the wanted mode.

If I understand this right, there are two failure modes being handled:

1) A mode that won't actually work because the link isn't good enough.

2) A mode that should work, but link parameters were too optimistic and if we just ask the kernel to set the mode again it'll use more conservative parameters that work.

Quoted 8 lines

This patch seems good for 2). For 1), the drmmode_set_mode_major is going to set our old mode back. Won't the modeset then fail to link train again, and bring us back into this loop? The only escape that I see would be some other userspace responding to the advertised mode list changing, and then asking X to modeset to something new.

To avoid that failure busy loop, should we re-fetching modes at this point, and only re-setting if our mode still exists?

Disclaimer: I don't know anything about the internals of the modesetting driver.

Perhaps we can identify the two cases now, but I'd put this more
generally: if the link status has gone bad, it's an indicator to userspace that the circumstances may have changed, and userspace should query the kernel for the list of available modes again. It should no longer trust information obtained prior to getting the bad link status, including the current mode.

Quoted 8 lines
Quoted 4 lines

But specifically, I think you're right, and AFAICT asking for the list of modes again is the only way for the userspace to distinguish between the two cases. I don't think there's a shortcut for deciding the current mode is still valid.

To avoid the busy-loop problem, I think I'd like this patch to re-query the kernel to ask about the current mode list, and only try to re-set the mode if our mode is still there.

Yeah, I guess that sounds like a reasonable heuristics. More integrated compositors (aka the wayland ones) might be able to make more useful decisions, but for -modesetting that's probably the best we can do.

Quoted 9 lines

If the mode isn't there, then it's up to the DE to take action in response to the notification of new modes. If you don't have a DE to take appropriate action, you're kind of out of luck.

As far as the ABI goes, this seems fine to me. The only concern I had about ABI was having to walk all the connectors on every uevent to see if any had gone bad -- couldn't we have a flag of some sort about what the uevent indicates? But uevents should be super rare, so I'd say the kernel could go ahead with the current plan.

We've discussed finer-grained uevent singalling a few times, and I'd like that to be an orthogonal abi extension. Right now we just don't have the required tracking even within the kernel to know which connector changed (and the tracking we do have missed a few things, too). My idea is to push the tracking into the leaves of the callchains with a function that increases some per-connector epoch counter. Then we'd just have to expose that somehow cheaply to userspace (could probably just send it along in the uevent). Plus expose it as a read-only property so that userspace can re-synchronize.

Quoted 3 lines
Quoted 1 line

But again, that should be an orthogonal thing imo.

Yeah, that was roughly my thought process, too.

I merged the kernel side of this new uapi:

commit 40ee6fbef75fe6452dc9e69e6f9f1a2c7808ed67

Author: Manasi Navare <[email protected]>
Date:   Fri Dec 16 12:29:06 2016 +0200

drm: Add a new connector atomic property for link status

Feel free to go ahead with the userspace side merging. (Yes the i915 side isn't merged yet, but purely for "in which branch should I put it?" technicality).

Cheers, Daniel

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#30 lore raw
In reply to Martin Peres
Quoted 51 lines · Martin Peres

Despite all the careful planing 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.

When available, we should use the link-status information to reset the wanted mode.

---

WARNING: The patches have not been merged in the kernel yet, so this patch is merely an RFC.

This patch is the result of discussions happening mostly in DRI-devel and Intel-GFX on how to handle link training failures. I would advise reading the thread [0] first and then this thread [1] which explain in great length why this is needed and why the selected approach seems to be the best.

The relevant kernel patches + this patch are enough to pass the relevant DisplayPort compliance tests, provided that the Desktop Environment or another program ([2]?) provides the initial modesetting on hotplug.

Would this patch be acceptable to you? Any comments or suggestions?

[0] https://lists.freedesktop.org/archives/dri-devel/2016-November/123366.html
[1] https://lists.freedesktop.org/archives/dri-devel/2016-November/124736.html
[2] https://cgit.freedesktop.org/~mperes/auto-randr/

 hw/xfree86/drivers/modesetting/drmmode_display.c | 51 ++++++++++++++++++++++++
 1 file changed, 51 insertions(+)
hw/xfree86/drivers/modesetting/drmmode_display.c +4 -0
index 6e755e9482..3144620c67 100644
@@ -2262,6 +2262,10 @@ drmmode_setup_colormap(ScreenPtr pScreen, ScrnInfoPtr pScrn)
 }
 
 #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)
 {

hw/xfree86/drivers/modesetting/drmmode_display.c drmmode_handle_uevents(int fd, void *closure) · line 2291

Quoted 7 lines
hw/xfree86/drivers/modesetting/drmmode_display.c +4 -0
@@ -2281,6 +2285,49 @@ drmmode_handle_uevents(int fd, void *closure)
     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
+     * mode is not achievable anymore, it should have pruned the mode before

The kernel does not prune the mode before sending a hotplug event. This happens when userspace tries to do a mdoeset on the current mode after which kernel will validate it agianst the new degraded link parameters and prune it if its not supported anymore in which case the userspace driver will need to request a modeset on the next lower mode.

Manasi

Quoted 24 lines
hw/xfree86/drivers/modesetting/drmmode_display.c +24 -0
+     * 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(drmmode->fd, con_id);
+        for (j = 0; koutput && j < koutput->count_props; j++) {
+            drmModePropertyPtr props;
+            props = drmModeGetProperty(drmmode->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;

hw/xfree86/drivers/modesetting/drmmode_display.c drmmode_handle_uevents(int fd, void *closure) · line 2325

Quoted 10 lines
hw/xfree86/drivers/modesetting/drmmode_display.c +10 -0
+
+                /* 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"
+                           "with a black screen if this fails...\n", con_id);
+            }

What happens incase this mdoe is pruned? In this case the kernel will fail the atomic_check() and return an error early on.
How does the driver request a new list of supported modes and request a lower resolution mode?

Regards
Manasi

Quoted 22 lines
hw/xfree86/drivers/modesetting/drmmode_display.c +9 -0
+            drmModeFreeProperty(props);
+        }
+        drmModeFreeConnector(koutput);
+    }
+
     mode_res = drmModeGetResources(drmmode->fd);
     if (!mode_res)
         goto out;
@@ -2345,6 +2392,10 @@ out_free_res:
 out:
     RRGetInfo(xf86ScrnToScreen(scrn), TRUE);
 }
+
+#undef DRM_MODE_LINK_STATUS_BAD
+#undef DRM_MODE_LINK_STATUS_GOOD
+
 #endif
 
 void
Signature · 1 line
2.11.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

A message that is not in the archive (sent off-list or not yet received): 20170126123728.5680-1-martin.peres-VuQAYsv1563Yd54FQh9/[email protected]

#32 lore raw
Quoted 11 lines · Martin Peres

Despite all the careful planing 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.

When available, we should use the link-status information to reset the wanted mode.

The relevant kernel patches have landed in drm-tip about a month ago.

Eric, would you mind providing feedback on or merging this patch?

Thanks,
Martin
_______________________________________________
[email protected]: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

#33 lore raw
Quoted 8 lines · Martin Peres
Quoted 7 lines · Martin Peres

Despite all the careful planing 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.

Quoted 8 lines
Quoted 4 lines

When available, we should use the link-status information to reset the wanted mode.

The relevant kernel patches have landed in drm-tip about a month ago.

Eric, would you mind providing feedback on or merging this patch?

The later discussion has sounded like the kernel will (always) prune the mode when we re-query, meaning that it doesn't make any sense to try to re-set to the old mode. Is this not the case?

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#34 lore raw
Quoted 15 lines · Eric Anholt
Quoted 13 lines · Martin Peres
Quoted 11 lines · Martin Peres

Despite all the careful planing 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.

When available, we should use the link-status information to reset the wanted mode.

Quoted 7 lines
Quoted 3 lines

The relevant kernel patches have landed in drm-tip about a month ago.

Eric, would you mind providing feedback on or merging this patch?

The later discussion has sounded like the kernel will (always) prune the mode when we re-query, meaning that it doesn't make any sense to try to re-set to the old mode. Is this not the case?

No the kernel will simply send a hotplug with link status as bad and then after that point its userspace driver's responsibility to check if link status is BAD, retry the same mode and if it fails then re probe.

Regards
Manasi
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#35 lore raw
Quoted 25 lines · Manasi Navare
Quoted 15 lines · Eric Anholt
Quoted 13 lines · Martin Peres
Quoted 11 lines · Martin Peres

Despite all the careful planing 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.

When available, we should use the link-status information to reset the wanted mode.

Quoted 7 lines
Quoted 3 lines

The relevant kernel patches have landed in drm-tip about a month ago.

Eric, would you mind providing feedback on or merging this patch?

The later discussion has sounded like the kernel will (always) prune the mode when we re-query, meaning that it doesn't make any sense to try to re-set to the old mode. Is this not the case?

Quoted 4 lines

No the kernel will simply send a hotplug with link status as bad and then after that point its userspace driver's responsibility to check if link status is BAD, retry the same mode and if it fails then re probe.

So the kernel will sometimes allow the same mode to be re-set with the same bpp?

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

A message that is not in the archive (sent off-list or not yet received): 87d1cxw6nq.fsf-omZaPlIz5HhaEpDpdNBo/[email protected]

#37 lore raw
Quoted 27 lines · Eric Anholt
Quoted 25 lines · Manasi Navare
Quoted 22 lines · Eric Anholt
Quoted 8 lines · Martin Peres
Quoted 7 lines · Martin Peres

Despite all the careful planing 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.

Quoted 8 lines
Quoted 4 lines

When available, we should use the link-status information to reset the wanted mode.

The relevant kernel patches have landed in drm-tip about a month ago.

Eric, would you mind providing feedback on or merging this patch?

The later discussion has sounded like the kernel will (always) prune the mode when we re-query, meaning that it doesn't make any sense to try to re-set to the old mode. Is this not the case?

Quoted 7 lines
Quoted 4 lines

No the kernel will simply send a hotplug with link status as bad and then after that point its userspace driver's responsibility to check if link status is BAD, retry the same mode and if it fails then re probe.

So the kernel will sometimes allow the same mode to be re-set with the same bpp?

So when userspace driver re-sets the same mode, the kernel will call the mode valid function where it will see it can allow the sam mode perhaps at a lower bpp now since the link parameters are lowered.
So the mode which failed at 30 bpp, might still work at 18bpp and is better going to a lower resolution.

Regards
Manasi

_______________________________________________
[email protected]: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

#38 lore raw
Quoted 33 lines · Manasi Navare
Quoted 32 lines · Eric Anholt
Quoted 29 lines · Manasi Navare
Quoted 15 lines · Eric Anholt
Quoted 13 lines · Martin Peres
Quoted 11 lines · Martin Peres

Despite all the careful planing 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.

When available, we should use the link-status information to reset the wanted mode.

Quoted 7 lines
Quoted 3 lines

The relevant kernel patches have landed in drm-tip about a month ago.

Eric, would you mind providing feedback on or merging this patch?

The later discussion has sounded like the kernel will (always) prune the mode when we re-query, meaning that it doesn't make any sense to try to re-set to the old mode. Is this not the case?

No the kernel will simply send a hotplug with link status as bad and then after that point its userspace driver's responsibility to check if link status is BAD, retry the same mode and if it fails then re probe.

Quoted 8 lines
Quoted 2 lines

So the kernel will sometimes allow the same mode to be re-set with the same bpp?

So when userspace driver re-sets the same mode, the kernel will call the mode valid function where it will see it can allow the sam mode perhaps at a lower bpp now since the link parameters are lowered.
So the mode which failed at 30 bpp, might still work at 18bpp and is better going to a lower resolution.

The question was whether the kernel will ever allow the same mode at the same bpp, since that's what this patch tries to do.

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#39 lore raw
Quoted 38 lines · Eric Anholt
Quoted 36 lines · Manasi Navare
Quoted 34 lines · Eric Anholt
Quoted 25 lines · Manasi Navare
Quoted 15 lines · Eric Anholt
Quoted 13 lines · Martin Peres
Quoted 11 lines · Martin Peres

Despite all the careful planing 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.

When available, we should use the link-status information to reset the wanted mode.

Quoted 7 lines
Quoted 3 lines

The relevant kernel patches have landed in drm-tip about a month ago.

Eric, would you mind providing feedback on or merging this patch?

The later discussion has sounded like the kernel will (always) prune the mode when we re-query, meaning that it doesn't make any sense to try to re-set to the old mode. Is this not the case?

Quoted 4 lines

No the kernel will simply send a hotplug with link status as bad and then after that point its userspace driver's responsibility to check if link status is BAD, retry the same mode and if it fails then re probe.

So the kernel will sometimes allow the same mode to be re-set with the same bpp?

Quoted 8 lines
Quoted 5 lines

So when userspace driver re-sets the same mode, the kernel will call the mode valid function where it will see it can allow the sam mode perhaps at a lower bpp now since the link parameters are lowered.
So the mode which failed at 30 bpp, might still work at 18bpp and is better going to a lower resolution.

The question was whether the kernel will ever allow the same mode at the same bpp, since that's what this patch tries to do.

Yes, this can happen. Doing a full modeset with recomputing clocks and everything behind userspace's back might not be something the kernel driver can pull of with a reasonable amount of effort, hence why we punt to userspace. The interface spec makes this a CAN, not WILL, to allow less unreasonable hw to handle these cases directly in the kernel driver. E.g. plain link-retraining is handled in i915.ko still.
-Daniel

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

A message that is not in the archive (sent off-list or not yet received): 20170402122809.trh7oxzz25oao4bu-dv86pmgwkMBes7Z6vYuT8azUEOm+Xw19@public.gmane.org

#41 lore raw
Quoted 48 lines · Daniel Vetter
Quoted 38 lines · Eric Anholt
Quoted 36 lines · Manasi Navare
Quoted 34 lines · Eric Anholt
Quoted 25 lines · Manasi Navare
Quoted 15 lines · Eric Anholt
Quoted 13 lines · Martin Peres
Quoted 11 lines · Martin Peres

Despite all the careful planing 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.

When available, we should use the link-status information to reset the wanted mode.

Quoted 7 lines
Quoted 3 lines

The relevant kernel patches have landed in drm-tip about a month ago.

Eric, would you mind providing feedback on or merging this patch?

The later discussion has sounded like the kernel will (always) prune the mode when we re-query, meaning that it doesn't make any sense to try to re-set to the old mode. Is this not the case?

Quoted 4 lines

No the kernel will simply send a hotplug with link status as bad and then after that point its userspace driver's responsibility to check if link status is BAD, retry the same mode and if it fails then re probe.

So the kernel will sometimes allow the same mode to be re-set with the same bpp?

Quoted 8 lines
Quoted 5 lines

So when userspace driver re-sets the same mode, the kernel will call the mode valid function where it will see it can allow the sam mode perhaps at a lower bpp now since the link parameters are lowered.
So the mode which failed at 30 bpp, might still work at 18bpp and is better going to a lower resolution.

The question was whether the kernel will ever allow the same mode at the same bpp, since that's what this patch tries to do.

Quoted 6 lines

Yes, this can happen. Doing a full modeset with recomputing clocks and everything behind userspace's back might not be something the kernel driver can pull of with a reasonable amount of effort, hence why we punt to userspace. The interface spec makes this a CAN, not WILL, to allow less unreasonable hw to handle these cases directly in the kernel driver. E.g. plain link-retraining is handled in i915.ko still.

So in that case you do need userspace to re-request the same mode at the same bpp?

_______________________________________________
[email protected]: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

A message that is not in the archive (sent off-list or not yet received): 87efxamdt6.fsf-omZaPlIz5HhaEpDpdNBo/[email protected]

#43 lore raw
Quoted 57 lines · Eric Anholt
Quoted 48 lines · Daniel Vetter
Quoted 38 lines · Eric Anholt
Quoted 36 lines · Manasi Navare
Quoted 34 lines · Eric Anholt
Quoted 25 lines · Manasi Navare
Quoted 15 lines · Eric Anholt
Quoted 13 lines · Martin Peres
Quoted 11 lines · Martin Peres

Despite all the careful planing 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.

When available, we should use the link-status information to reset the wanted mode.

Quoted 7 lines
Quoted 3 lines

The relevant kernel patches have landed in drm-tip about a month ago.

Eric, would you mind providing feedback on or merging this patch?

The later discussion has sounded like the kernel will (always) prune the mode when we re-query, meaning that it doesn't make any sense to try to re-set to the old mode. Is this not the case?

Quoted 4 lines

No the kernel will simply send a hotplug with link status as bad and then after that point its userspace driver's responsibility to check if link status is BAD, retry the same mode and if it fails then re probe.

So the kernel will sometimes allow the same mode to be re-set with the same bpp?

Quoted 8 lines
Quoted 5 lines

So when userspace driver re-sets the same mode, the kernel will call the mode valid function where it will see it can allow the sam mode perhaps at a lower bpp now since the link parameters are lowered.
So the mode which failed at 30 bpp, might still work at 18bpp and is better going to a lower resolution.

The question was whether the kernel will ever allow the same mode at the same bpp, since that's what this patch tries to do.

Quoted 6 lines

Yes, this can happen. Doing a full modeset with recomputing clocks and everything behind userspace's back might not be something the kernel driver can pull of with a reasonable amount of effort, hence why we punt to userspace. The interface spec makes this a CAN, not WILL, to allow less unreasonable hw to handle these cases directly in the kernel driver. E.g. plain link-retraining is handled in i915.ko still.

Quoted 2 lines

So in that case you do need userspace to re-request the same mode at the same bpp?

So yes because when userspace requests the same mode at same bpp, kernel will still call intel_dp->mod_valid which validates the mode against 18bpp so if the requested mode can be displayed at the lowest of 18bpp, then the kernel will try to do the modeset for that mode at lower bpp. What I am trying to say is irrespective of what bpp userspace requests, kernel will check if it can display that at the lowest of 18bpp.

Regards
Manasi

Quoted 4 lines

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

_______________________________________________
[email protected]: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

#44 lore raw
Quoted 9 lines · Manasi Navare
Quoted 2 lines

So in that case you do need userspace to re-request the same mode at the same bpp?

So yes because when userspace requests the same mode at same bpp, kernel will still call intel_dp->mod_valid which validates the mode against 18bpp so if the requested mode can be displayed at the lowest of 18bpp, then the kernel will try to do the modeset for that mode at lower bpp. What I am trying to say is irrespective of what bpp userspace requests, kernel will check if it can display that at the lowest of 18bpp.

You're talking about two different bpp here I think. Eric talks about the pixel format of the framebuffer, Manasi here about the bpp we send over the wire. The kernel will auto-dither if the wire bpp is lower than the stuff we scan out. Same with 6bpc panels really.

Right now userspace can't request a specific bpp for the sink/pipe, that's fully under the kernel's control. It only gets to set the pixel format of fbs.
-Daniel

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#45 lore raw
Quoted 16 lines · Daniel Vetter
Quoted 9 lines · Manasi Navare
Quoted 2 lines

So in that case you do need userspace to re-request the same mode at the same bpp?

So yes because when userspace requests the same mode at same bpp, kernel will still call intel_dp->mod_valid which validates the mode against 18bpp so if the requested mode can be displayed at the lowest of 18bpp, then the kernel will try to do the modeset for that mode at lower bpp. What I am trying to say is irrespective of what bpp userspace requests, kernel will check if it can display that at the lowest of 18bpp.

You're talking about two different bpp here I think. Eric talks about the pixel format of the framebuffer, Manasi here about the bpp we send over the wire. The kernel will auto-dither if the wire bpp is lower than the stuff we scan out. Same with 6bpc panels really.

Quoted 5 lines

Right now userspace can't request a specific bpp for the sink/pipe, that's fully under the kernel's control. It only gets to set the pixel format of fbs.
-Daniel

Yes so in that case, Eric we do need userspace to re-request the same mode at the same bpp or the same pixel format.
And if this also fails, then we need Gnome or KDE to be re triggering a complete re probe.

Regards
Manasi

Quoted 3 lines

Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#46 lore raw
In reply to a message not in the archive
Quoted 57 lines · Eric Anholt
Quoted 48 lines · Daniel Vetter
Quoted 38 lines · Eric Anholt
Quoted 36 lines · Manasi Navare
Quoted 34 lines · Eric Anholt
Quoted 25 lines · Manasi Navare
Quoted 15 lines · Eric Anholt
Quoted 13 lines · Martin Peres
Quoted 11 lines · Martin Peres

Despite all the careful planing 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.

When available, we should use the link-status information to reset the wanted mode.

Quoted 7 lines
Quoted 3 lines

The relevant kernel patches have landed in drm-tip about a month ago.

Eric, would you mind providing feedback on or merging this patch?

The later discussion has sounded like the kernel will (always) prune the mode when we re-query, meaning that it doesn't make any sense to try to re-set to the old mode. Is this not the case?

Quoted 4 lines

No the kernel will simply send a hotplug with link status as bad and then after that point its userspace driver's responsibility to check if link status is BAD, retry the same mode and if it fails then re probe.

So the kernel will sometimes allow the same mode to be re-set with the same bpp?

Quoted 8 lines
Quoted 5 lines

So when userspace driver re-sets the same mode, the kernel will call the mode valid function where it will see it can allow the sam mode perhaps at a lower bpp now since the link parameters are lowered.
So the mode which failed at 30 bpp, might still work at 18bpp and is better going to a lower resolution.

The question was whether the kernel will ever allow the same mode at the same bpp, since that's what this patch tries to do.

Quoted 6 lines

Yes, this can happen. Doing a full modeset with recomputing clocks and everything behind userspace's back might not be something the kernel driver can pull of with a reasonable amount of effort, hence why we punt to userspace. The interface spec makes this a CAN, not WILL, to allow less unreasonable hw to handle these cases directly in the kernel driver. E.g. plain link-retraining is handled in i915.ko still.

Quoted 2 lines

So in that case you do need userspace to re-request the same mode at the same bpp?

Hi Eric,

Yes so we do need userspace to re-request the same mode at the same bpp/pixel rate. Kernel will try that at that bpp or lower it. Its fully in kernel's control. If it fails then the atomic_check phase will return a failure and in that case the Gnome/KDE will have to do a full reprobe.

Eric, do you have any more concerns about this patch or can this be pushed to Xserver?

Its critical for thsi patch to be pushed to Xserver so that the entire Gfx stack can handle link failures and we can see some of the bugs going away.

Regards
Manasi

Quoted 4 lines

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

_______________________________________________
[email protected]: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel