Skip to contentSkip to conversation

drm: Fix broken VT switch with video=1366x768 option

PATCH In review Takashi Iwai 3 participants 7 messages Jan 9, 2017 – Jan 11, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm: Fix broken VT switch with video=1366x768 option

I noticed that the VT switch doesn't work any longer with a Dell laptop with 1366x768 eDP when the machine is connected with a DP monitor. It behaves as if VT were switched, but the graphics remain frozen. Actually the keyboard works, so I could switch back to VT7 again.

I tried to track down the problem, and encountered a long story until we reach to this error:

- The machine is booted with video=1366x768 option (the distro installer seems to add it as default).
- Recently, drm_helper_probe_single_connector_modes() deals with cmdline modes, and it tries to create a new mode when no matching mode is found.
- The drm_mode_create_from_cmdline_mode() creates a mode based on either CVT of GFT according to the given cmdline mode; in our case, it's 1366x768.
- Since both CVT and GFT can't express the width 1366 due to alignment, the resultant mode becomes 1368x768, slightly larger than the given size.
- Later on, the atomic commit is performed, and in drm_atomic_check_only(), the size of each plane is checked.
- The size check of 1366x768 fails due to the above, and eventually the whole VT switch fails.

Back in the history, we've had a manual fix-up of 1368x768 in various places via c09dedb7a50e ("drm/edid: Add a workaround for 1366x768 HD panel"), but they have been all in drm_edid.c at probing the modes from EDID. For addressing the problem above, we need a similar hack to the mode newly created from cmdline, manually adjusting the width when the expected size is 1366 while we get 1368 instead.

Fixes eaf99c749d43 ("drm: Perform cmdline mode parsing during...")
---
 drivers/gpu/drm/drm_modes.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/gpu/drm/drm_modes.c +7 -0
index ac6a35212501..e6b19bc9021a 100644
@@ -1460,6 +1460,13 @@ drm_mode_create_from_cmdline_mode(struct drm_device *dev,
 		return NULL;
 
 	mode->type |= DRM_MODE_TYPE_USERDEF;
+	/* fix up 1368x768: GFT/CVT can't express 1366 width due to alignment */
+	if (cmd->xres == 1366 && mode->hdisplay == 1368) {
+		mode->hdisplay = 1366;
+		mode->hsync_start--;
+		mode->hsync_end--;
+		drm_mode_set_name(mode);
+	}
 	drm_mode_set_crtcinfo(mode, CRTC_INTERLACE_HALVE_V);
 	return mode;
 }
Signature · 6 lines
2.11.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Reviewed-by on v1 1/1
#1 lore raw
Quoted 44 lines · Takashi Iwai

I noticed that the VT switch doesn't work any longer with a Dell laptop with 1366x768 eDP when the machine is connected with a DP monitor. It behaves as if VT were switched, but the graphics remain frozen. Actually the keyboard works, so I could switch back to VT7 again.

I tried to track down the problem, and encountered a long story until we reach to this error:

- The machine is booted with video=1366x768 option (the distro installer seems to add it as default).
- Recently, drm_helper_probe_single_connector_modes() deals with cmdline modes, and it tries to create a new mode when no matching mode is found.
- The drm_mode_create_from_cmdline_mode() creates a mode based on either CVT of GFT according to the given cmdline mode; in our case, it's 1366x768.
- Since both CVT and GFT can't express the width 1366 due to alignment, the resultant mode becomes 1368x768, slightly larger than the given size.
- Later on, the atomic commit is performed, and in drm_atomic_check_only(), the size of each plane is checked.
- The size check of 1366x768 fails due to the above, and eventually the whole VT switch fails.

Back in the history, we've had a manual fix-up of 1368x768 in various places via c09dedb7a50e ("drm/edid: Add a workaround for 1366x768 HD panel"), but they have been all in drm_edid.c at probing the modes from EDID. For addressing the problem above, we need a similar hack to the mode newly created from cmdline, manually adjusting the width when the expected size is 1366 while we get 1368 instead.

Fixes eaf99c749d43 ("drm: Perform cmdline mode parsing during...")
---
 drivers/gpu/drm/drm_modes.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/gpu/drm/drm_modes.c +0 -0
index ac6a35212501..e6b19bc9021a 100644

drivers/gpu/drm/drm_modes.c drm_mode_create_from_cmdline_mode(struct drm_device *dev, · line 1469

Quoted 10 lines
drivers/gpu/drm/drm_modes.c +7 -0
@@ -1460,6 +1460,13 @@ drm_mode_create_from_cmdline_mode(struct drm_device *dev,
 		return NULL;
 
 	mode->type |= DRM_MODE_TYPE_USERDEF;
+	/* fix up 1368x768: GFT/CVT can't express 1366 width due to alignment */
+	if (cmd->xres == 1366 && mode->hdisplay == 1368) {
+		mode->hdisplay = 1366;
+		mode->hsync_start--;
+		mode->hsync_end--;
+		drm_mode_set_name(mode);
+	}

Maybe give fixup_mode_1366x768() a drm_ prefix and make in non-static to avoid duplicating the code? And I guess move it to drm_modes.c?

Otherwise lgtm:

Quoted 5 lines
drivers/gpu/drm/drm_modes.c +0 -0
 	drm_mode_set_crtcinfo(mode, CRTC_INTERLACE_HALVE_V);
 	return mode;
 }
Signature · 1 line
2.11.0
Signature · 2 lines
Ville Syrjälä
Intel OTC
#2 lore raw
Quoted 48 lines · Ville Syrjälä
Quoted 46 lines · Takashi Iwai

I noticed that the VT switch doesn't work any longer with a Dell laptop with 1366x768 eDP when the machine is connected with a DP monitor. It behaves as if VT were switched, but the graphics remain frozen. Actually the keyboard works, so I could switch back to VT7 again.

I tried to track down the problem, and encountered a long story until we reach to this error:

- The machine is booted with video=1366x768 option (the distro installer seems to add it as default).
- Recently, drm_helper_probe_single_connector_modes() deals with cmdline modes, and it tries to create a new mode when no matching mode is found.
- The drm_mode_create_from_cmdline_mode() creates a mode based on either CVT of GFT according to the given cmdline mode; in our case, it's 1366x768.
- Since both CVT and GFT can't express the width 1366 due to alignment, the resultant mode becomes 1368x768, slightly larger than the given size.
- Later on, the atomic commit is performed, and in drm_atomic_check_only(), the size of each plane is checked.
- The size check of 1366x768 fails due to the above, and eventually the whole VT switch fails.

Back in the history, we've had a manual fix-up of 1368x768 in various places via c09dedb7a50e ("drm/edid: Add a workaround for 1366x768 HD panel"), but they have been all in drm_edid.c at probing the modes from EDID. For addressing the problem above, we need a similar hack to the mode newly created from cmdline, manually adjusting the width when the expected size is 1366 while we get 1368 instead.

Fixes eaf99c749d43 ("drm: Perform cmdline mode parsing during...")
---
 drivers/gpu/drm/drm_modes.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/gpu/drm/drm_modes.c +0 -0
index ac6a35212501..e6b19bc9021a 100644
@@ -1460,6 +1460,13 @@ drm_mode_create_from_cmdline_mode(struct drm_device *dev,
 		return NULL;
 
Quoted 11 lines

drivers/gpu/drm/drm_modes.c drm_mode_create_from_cmdline_mode(struct drm_device *dev, · line 1469

Quoted 8 lines
drivers/gpu/drm/drm_modes.c +7 -0
 	mode->type |= DRM_MODE_TYPE_USERDEF;
+	/* fix up 1368x768: GFT/CVT can't express 1366 width due to alignment */
+	if (cmd->xres == 1366 && mode->hdisplay == 1368) {
+		mode->hdisplay = 1366;
+		mode->hsync_start--;
+		mode->hsync_end--;
+		drm_mode_set_name(mode);
+	}

Maybe give fixup_mode_1366x768() a drm_ prefix and make in non-static to avoid duplicating the code? And I guess move it to drm_modes.c?

Yes, that'll be a good cleanup. I was afraid of symbol export, but both are in the same module, so far. I can post a follow-up once when this one gets accepted.

Quoted 3 lines

Otherwise lgtm:

Thanks!

Takashi

Quoted 10 lines
Quoted 5 lines
drivers/gpu/drm/drm_modes.c +0 -0
 	drm_mode_set_crtcinfo(mode, CRTC_INTERLACE_HALVE_V);
 	return mode;
 }
Signature · 1 line
2.11.0
Signature · 2 lines
Ville Syrjälä
Intel OTC
#3 lore raw
Quoted 62 lines · Takashi Iwai
Quoted 48 lines · Ville Syrjälä
Quoted 46 lines · Takashi Iwai

I noticed that the VT switch doesn't work any longer with a Dell laptop with 1366x768 eDP when the machine is connected with a DP monitor. It behaves as if VT were switched, but the graphics remain frozen. Actually the keyboard works, so I could switch back to VT7 again.

I tried to track down the problem, and encountered a long story until we reach to this error:

- The machine is booted with video=1366x768 option (the distro installer seems to add it as default).
- Recently, drm_helper_probe_single_connector_modes() deals with cmdline modes, and it tries to create a new mode when no matching mode is found.
- The drm_mode_create_from_cmdline_mode() creates a mode based on either CVT of GFT according to the given cmdline mode; in our case, it's 1366x768.
- Since both CVT and GFT can't express the width 1366 due to alignment, the resultant mode becomes 1368x768, slightly larger than the given size.
- Later on, the atomic commit is performed, and in drm_atomic_check_only(), the size of each plane is checked.
- The size check of 1366x768 fails due to the above, and eventually the whole VT switch fails.

Back in the history, we've had a manual fix-up of 1368x768 in various places via c09dedb7a50e ("drm/edid: Add a workaround for 1366x768 HD panel"), but they have been all in drm_edid.c at probing the modes from EDID. For addressing the problem above, we need a similar hack to the mode newly created from cmdline, manually adjusting the width when the expected size is 1366 while we get 1368 instead.

Fixes eaf99c749d43 ("drm: Perform cmdline mode parsing during...")
---
 drivers/gpu/drm/drm_modes.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/gpu/drm/drm_modes.c +0 -0
index ac6a35212501..e6b19bc9021a 100644
@@ -1460,6 +1460,13 @@ drm_mode_create_from_cmdline_mode(struct drm_device *dev,
 		return NULL;
 
Quoted 11 lines

drivers/gpu/drm/drm_modes.c drm_mode_create_from_cmdline_mode(struct drm_device *dev, · line 1469

Quoted 8 lines
drivers/gpu/drm/drm_modes.c +7 -0
 	mode->type |= DRM_MODE_TYPE_USERDEF;
+	/* fix up 1368x768: GFT/CVT can't express 1366 width due to alignment */
+	if (cmd->xres == 1366 && mode->hdisplay == 1368) {
+		mode->hdisplay = 1366;
+		mode->hsync_start--;
+		mode->hsync_end--;
+		drm_mode_set_name(mode);
+	}

Maybe give fixup_mode_1366x768() a drm_ prefix and make in non-static to avoid duplicating the code? And I guess move it to drm_modes.c?

Quoted 3 lines

Yes, that'll be a good cleanup. I was afraid of symbol export, but both are in the same module, so far. I can post a follow-up once when this one gets accepted.

For the follow up, pls put the decl into drm_crtc_internal.h, so that drivers aren't tempted to use it. That header is for module-internal shared code only.

Quoted 4 lines
Quoted 2 lines

Otherwise lgtm:

Thanks!

Ville, can you pls also apply this one to drm-misc-fixes? -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
#4 lore raw
Quoted 64 lines · Daniel Vetter
Quoted 62 lines · Takashi Iwai
Quoted 59 lines · Ville Syrjälä
Quoted 44 lines · Takashi Iwai

I noticed that the VT switch doesn't work any longer with a Dell laptop with 1366x768 eDP when the machine is connected with a DP monitor. It behaves as if VT were switched, but the graphics remain frozen. Actually the keyboard works, so I could switch back to VT7 again.

I tried to track down the problem, and encountered a long story until we reach to this error:

- The machine is booted with video=1366x768 option (the distro installer seems to add it as default).
- Recently, drm_helper_probe_single_connector_modes() deals with cmdline modes, and it tries to create a new mode when no matching mode is found.
- The drm_mode_create_from_cmdline_mode() creates a mode based on either CVT of GFT according to the given cmdline mode; in our case, it's 1366x768.
- Since both CVT and GFT can't express the width 1366 due to alignment, the resultant mode becomes 1368x768, slightly larger than the given size.
- Later on, the atomic commit is performed, and in drm_atomic_check_only(), the size of each plane is checked.
- The size check of 1366x768 fails due to the above, and eventually the whole VT switch fails.

Back in the history, we've had a manual fix-up of 1368x768 in various places via c09dedb7a50e ("drm/edid: Add a workaround for 1366x768 HD panel"), but they have been all in drm_edid.c at probing the modes from EDID. For addressing the problem above, we need a similar hack to the mode newly created from cmdline, manually adjusting the width when the expected size is 1366 while we get 1368 instead.

Fixes eaf99c749d43 ("drm: Perform cmdline mode parsing during...")
---
 drivers/gpu/drm/drm_modes.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/gpu/drm/drm_modes.c +0 -0
index ac6a35212501..e6b19bc9021a 100644

drivers/gpu/drm/drm_modes.c drm_mode_create_from_cmdline_mode(struct drm_device *dev, · line 1469

Quoted 10 lines
drivers/gpu/drm/drm_modes.c +7 -0
@@ -1460,6 +1460,13 @@ drm_mode_create_from_cmdline_mode(struct drm_device *dev,
 		return NULL;
 
 	mode->type |= DRM_MODE_TYPE_USERDEF;
+	/* fix up 1368x768: GFT/CVT can't express 1366 width due to alignment */
+	if (cmd->xres == 1366 && mode->hdisplay == 1368) {
+		mode->hdisplay = 1366;
+		mode->hsync_start--;
+		mode->hsync_end--;
+		drm_mode_set_name(mode);
+	}

Maybe give fixup_mode_1366x768() a drm_ prefix and make in non-static to avoid duplicating the code? And I guess move it to drm_modes.c?

Quoted 7 lines
Quoted 3 lines

Yes, that'll be a good cleanup. I was afraid of symbol export, but both are in the same module, so far. I can post a follow-up once when this one gets accepted.

For the follow up, pls put the decl into drm_crtc_internal.h, so that drivers aren't tempted to use it. That header is for module-internal shared code only.

Alright, thanks for information.

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

#5 lore raw
In reply to Daniel Vetter
Quoted 71 lines · Daniel Vetter
Quoted 62 lines · Takashi Iwai
Quoted 48 lines · Ville Syrjälä
Quoted 46 lines · Takashi Iwai

I noticed that the VT switch doesn't work any longer with a Dell laptop with 1366x768 eDP when the machine is connected with a DP monitor. It behaves as if VT were switched, but the graphics remain frozen. Actually the keyboard works, so I could switch back to VT7 again.

I tried to track down the problem, and encountered a long story until we reach to this error:

- The machine is booted with video=1366x768 option (the distro installer seems to add it as default).
- Recently, drm_helper_probe_single_connector_modes() deals with cmdline modes, and it tries to create a new mode when no matching mode is found.
- The drm_mode_create_from_cmdline_mode() creates a mode based on either CVT of GFT according to the given cmdline mode; in our case, it's 1366x768.
- Since both CVT and GFT can't express the width 1366 due to alignment, the resultant mode becomes 1368x768, slightly larger than the given size.
- Later on, the atomic commit is performed, and in drm_atomic_check_only(), the size of each plane is checked.
- The size check of 1366x768 fails due to the above, and eventually the whole VT switch fails.

Back in the history, we've had a manual fix-up of 1368x768 in various places via c09dedb7a50e ("drm/edid: Add a workaround for 1366x768 HD panel"), but they have been all in drm_edid.c at probing the modes from EDID. For addressing the problem above, we need a similar hack to the mode newly created from cmdline, manually adjusting the width when the expected size is 1366 while we get 1368 instead.

Fixes eaf99c749d43 ("drm: Perform cmdline mode parsing during...")
---
 drivers/gpu/drm/drm_modes.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/gpu/drm/drm_modes.c +0 -0
index ac6a35212501..e6b19bc9021a 100644
@@ -1460,6 +1460,13 @@ drm_mode_create_from_cmdline_mode(struct drm_device *dev,
 		return NULL;
 
Quoted 11 lines

drivers/gpu/drm/drm_modes.c drm_mode_create_from_cmdline_mode(struct drm_device *dev, · line 1469

Quoted 8 lines
drivers/gpu/drm/drm_modes.c +7 -0
 	mode->type |= DRM_MODE_TYPE_USERDEF;
+	/* fix up 1368x768: GFT/CVT can't express 1366 width due to alignment */
+	if (cmd->xres == 1366 && mode->hdisplay == 1368) {
+		mode->hdisplay = 1366;
+		mode->hsync_start--;
+		mode->hsync_end--;
+		drm_mode_set_name(mode);
+	}

Maybe give fixup_mode_1366x768() a drm_ prefix and make in non-static to avoid duplicating the code? And I guess move it to drm_modes.c?

Quoted 3 lines

Yes, that'll be a good cleanup. I was afraid of symbol export, but both are in the same module, so far. I can post a follow-up once when this one gets accepted.

For the follow up, pls put the decl into drm_crtc_internal.h, so that drivers aren't tempted to use it. That header is for module-internal shared code only.

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

Otherwise lgtm:

Thanks!

Ville, can you pls also apply this one to drm-misc-fixes?

Pushed. Thanks for the patch.

Signature · 2 lines
Ville Syrjälä
Intel OTC
#6 lore raw
Quoted 73 lines · Ville Syrjälä
Quoted 71 lines · Daniel Vetter
Quoted 62 lines · Takashi Iwai
Quoted 48 lines · Ville Syrjälä
Quoted 46 lines · Takashi Iwai

I noticed that the VT switch doesn't work any longer with a Dell laptop with 1366x768 eDP when the machine is connected with a DP monitor. It behaves as if VT were switched, but the graphics remain frozen. Actually the keyboard works, so I could switch back to VT7 again.

I tried to track down the problem, and encountered a long story until we reach to this error:

- The machine is booted with video=1366x768 option (the distro installer seems to add it as default).
- Recently, drm_helper_probe_single_connector_modes() deals with cmdline modes, and it tries to create a new mode when no matching mode is found.
- The drm_mode_create_from_cmdline_mode() creates a mode based on either CVT of GFT according to the given cmdline mode; in our case, it's 1366x768.
- Since both CVT and GFT can't express the width 1366 due to alignment, the resultant mode becomes 1368x768, slightly larger than the given size.
- Later on, the atomic commit is performed, and in drm_atomic_check_only(), the size of each plane is checked.
- The size check of 1366x768 fails due to the above, and eventually the whole VT switch fails.

Back in the history, we've had a manual fix-up of 1368x768 in various places via c09dedb7a50e ("drm/edid: Add a workaround for 1366x768 HD panel"), but they have been all in drm_edid.c at probing the modes from EDID. For addressing the problem above, we need a similar hack to the mode newly created from cmdline, manually adjusting the width when the expected size is 1366 while we get 1368 instead.

Fixes eaf99c749d43 ("drm: Perform cmdline mode parsing during...")
---
 drivers/gpu/drm/drm_modes.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/gpu/drm/drm_modes.c +0 -0
index ac6a35212501..e6b19bc9021a 100644
@@ -1460,6 +1460,13 @@ drm_mode_create_from_cmdline_mode(struct drm_device *dev,
 		return NULL;
 
Quoted 11 lines

drivers/gpu/drm/drm_modes.c drm_mode_create_from_cmdline_mode(struct drm_device *dev, · line 1469

Quoted 8 lines
drivers/gpu/drm/drm_modes.c +7 -0
 	mode->type |= DRM_MODE_TYPE_USERDEF;
+	/* fix up 1368x768: GFT/CVT can't express 1366 width due to alignment */
+	if (cmd->xres == 1366 && mode->hdisplay == 1368) {
+		mode->hdisplay = 1366;
+		mode->hsync_start--;
+		mode->hsync_end--;
+		drm_mode_set_name(mode);
+	}

Maybe give fixup_mode_1366x768() a drm_ prefix and make in non-static to avoid duplicating the code? And I guess move it to drm_modes.c?

Quoted 3 lines

Yes, that'll be a good cleanup. I was afraid of symbol export, but both are in the same module, so far. I can post a follow-up once when this one gets accepted.

For the follow up, pls put the decl into drm_crtc_internal.h, so that drivers aren't tempted to use it. That header is for module-internal shared code only.

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

Otherwise lgtm:

Thanks!

Ville, can you pls also apply this one to drm-misc-fixes?

Pushed. Thanks for the patch.

Thanks!

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