drm/qxl: kick out vgacon
Subsystems (5)
Gerd Hoffmann
maintainerPATCH v2 1/2 drm: move i915_kick_out_vgacon to drm_fb_helper
In reply to Gerd HoffmannIt'll be useful for other drivers too, so move it to drm_fb_helper.c (and rename it of course). Also add docs.
--- include/drm/drm_fb_helper.h | 2 ++ drivers/gpu/drm/drm_fb_helper.c | 39 +++++++++++++++++++++++++++++++++++++++ drivers/gpu/drm/i915/i915_drv.c | 35 +---------------------------------- 3 files changed, 42 insertions(+), 34 deletions(-)
include/drm/drm_fb_helper.h +2 -0
@@ -649,4 +649,6 @@ drm_fb_helper_remove_conflicting_pci_framebuffers(struct pci_dev *pdev, #endif } +int drm_fb_helper_kick_out_vgacon (void ); +#endif
drivers/gpu/drm/drm_fb_helper.c +39 -0
@@ -35,6 +35,7 @@#include <linux/sysrq.h> #include <linux/slab.h> #include <linux/module.h> +#include <linux/vt_kern.h> #include <drm/drmP.h> #include <drm/drm_crtc.h> #include <drm/drm_fb_helper.h>
@@ -3353,3 +3354,41 @@ int __init drm_fb_helper_modinit(void)return 0 ; }EXPORT_SYMBOL (drm_fb_helper_modinit); + +/** +* drm_fb_helper_kick_out_vgacon - deactivate vgacon driver. +* +* Deactivate vgacon driver so it stops accessing vga io ports. +* Should be called after +* drm_fb_helper_remove_conflicting_pci_framebuffers(). +* +* Returns: +* Zero on success or negative error code on failure. +*/ +int drm_fb_helper_kick_out_vgacon (void ) +{ +#if !defined(CONFIG_VGA_CONSOLE ) +return 0 ; +#elif !defined(CONFIG_DUMMY_CONSOLE ) +return -ENODEV ; +#else +int ret =0 ; + +DRM_INFO ("Replacing VGA console driver\n" ); + +console_lock (); +if (con_is_bound (&vga_con)) + ret =do_take_over_console (&dummy_con,0 ,MAX_NR_CONSOLES -1 ,1 ); +if (ret ==0 ) { + ret =do_unregister_con_driver (&vga_con); + +/* Ignore "already unregistered". */ +if (ret == -ENODEV ) + ret =0 ; + } +console_unlock (); + +return ret; +#endif +} +EXPORT_SYMBOL (drm_fb_helper_kick_out_vgacon);
drivers/gpu/drm/i915/i915_drv.c +1 -34
@@ -757,39 +757,6 @@ static int i915_kick_out_firmware_fb(struct drm_i915_private *dev_priv)return ret; } -#if !defined(CONFIG_VGA_CONSOLE ) -static int i915_kick_out_vgacon (struct drm_i915_private *dev_priv) -{ -return 0 ; -} -#elif !defined(CONFIG_DUMMY_CONSOLE ) -static int i915_kick_out_vgacon (struct drm_i915_private *dev_priv) -{ -return -ENODEV ; -} -#else -static int i915_kick_out_vgacon (struct drm_i915_private *dev_priv) -{ -int ret =0 ; - -DRM_INFO ("Replacing VGA console driver\n" ); - -console_lock (); -if (con_is_bound (&vga_con)) - ret =do_take_over_console (&dummy_con,0 ,MAX_NR_CONSOLES -1 ,1 ); -if (ret ==0 ) { - ret =do_unregister_con_driver (&vga_con); - -/* Ignore "already unregistered". */ -if (ret == -ENODEV ) - ret =0 ; - } -console_unlock (); - -return ret; -} -#endif -static void intel_init_dpio (struct drm_i915_private *dev_priv) {/*
@@ -1420,7 +1387,7 @@ static int i915_driver_init_hw(struct drm_i915_private *dev_priv) goto err_ggtt; } - ret =i915_kick_out_vgacon (dev_priv); + ret =drm_fb_helper_kick_out_vgacon ();if (ret) {DRM_ERROR ("failed to remove conflicting VGA console\n" ); goto err_ggtt;
Signature · 6 lines
2.9.3 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Gerd Hoffmann
maintainerPATCH v2 2/2 drm/qxl: kick out vgacon
In reply to Gerd HoffmannProblem: qxl switches from native mode back into vga compatibility mode when it notices someone is accessing vga registers. And vgacon does exactly that before fbcon takes over. So make sure we kick out vgacon early enough that it wouldn't disturb us.
--- drivers/gpu/drm/qxl/qxl_drv.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/qxl/qxl_drv.c +1 -0
@@ -95,6 +95,7 @@ qxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) goto modeset_cleanup;drm_fb_helper_remove_conflicting_pci_framebuffers (pdev,0 ,"qxl" ); +drm_fb_helper_kick_out_vgacon ();drm_fbdev_generic_setup (&qdev->ddev,32 );return 0 ;
Signature · 1 line
2.9.3
Gerd Hoffmann
maintainerPATCH v2 2/2 drm/qxl: kick out vgacon
In reply to Gerd HoffmannProblem: qxl switches from native mode back into vga compatibility mode when it notices someone is accessing vga registers. And vgacon does exactly that before fbcon takes over. So make sure we kick out vgacon early enough that it wouldn't disturb us.
--- drivers/gpu/drm/qxl/qxl_drv.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/qxl/qxl_drv.c +1 -0
@@ -95,6 +95,7 @@ qxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) goto modeset_cleanup;drm_fb_helper_remove_conflicting_pci_framebuffers (pdev,0 ,"qxl" ); +drm_fb_helper_kick_out_vgacon ();drm_fbdev_generic_setup (&qdev->ddev,32 );return 0 ;
Signature · 1 line
2.9.3
Gerd Hoffmann
maintainerv2 cover drm/qxl: kick out vgacon
v2: move the i915 code to drm_fb_helper and use that instead of reinventing the wheel.
Gerd Hoffmann (2):
drm: move i915_kick_out_vgacon to drm_fb_helper
drm/qxl: kick out vgacon
include/drm/drm_fb_helper.h | 2 ++ drivers/gpu/drm/drm_fb_helper.c | 39 +++++++++++++++++++++++++++++++++++++++ drivers/gpu/drm/i915/i915_drv.c | 35 +---------------------------------- drivers/gpu/drm/qxl/qxl_drv.c | 1 + 4 files changed, 43 insertions(+), 34 deletions(-)
Signature · 6 lines
2.9.3 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v2 1/2] drm: move i915_kick_out_vgacon to drm_fb_helper
In reply to Gerd HoffmannQuoted 34 lines · Gerd Hoffmann
It'll be useful for other drivers too, so move it to
drm_fb_helper.c(and rename it of course). Also add docs.Signed-off-by Gerd Hoffmann <[email protected]>--- include/drm/drm_fb_helper.h | 2 ++ drivers/gpu/drm/drm_fb_helper.c | 39 +++++++++++++++++++++++++++++++++++++++ drivers/gpu/drm/i915/i915_drv.c | 35 +---------------------------------- 3 files changed, 42 insertions(+), 34 deletions(-)include/drm/drm_fb_helper.h +2
-0@@ -649,4 +649,6 @@ drm_fb_helper_remove_conflicting_pci_framebuffers(struct pci_dev *pdev, #endif } +int drm_fb_helper_kick_out_vgacon (void ); +#endif drivers/gpu/drm/drm_fb_helper.c +1
-0@@ -35,6 +35,7 @@#include <linux/sysrq.h> #include <linux/slab.h> #include <linux/module.h> +#include <linux/vt_kern.h> #include <drm/drmP.h> #include <drm/drm_crtc.h> #include <drm/drm_fb_helper.h>
drivers/gpu/drm/drm_fb_helper.c int __init drm_fb_helper_modinit(void) · line 3363
Quoted 10 lines
drivers/gpu/drm/drm_fb_helper.c +7
-0@@ -3353,3 +3354,41 @@ int __init drm_fb_helper_modinit(void)return 0 ; }EXPORT_SYMBOL (drm_fb_helper_modinit); + +/** +* drm_fb_helper_kick_out_vgacon - deactivate vgacon driver. +* +* Deactivate vgacon driver so it stops accessing vga io ports. +* Should be called after +* drm_fb_helper_remove_conflicting_pci_framebuffers().
Why after? i915 calls this before kicking out the fbdev drivers ...
Otherwise lgtm.
-Daniel
Quoted 87 lines
drivers/gpu/drm/drm_fb_helper.c +31
-0+* +* Returns: +* Zero on success or negative error code on failure. +*/ +int drm_fb_helper_kick_out_vgacon (void ) +{ +#if !defined(CONFIG_VGA_CONSOLE ) +return 0 ; +#elif !defined(CONFIG_DUMMY_CONSOLE ) +return -ENODEV ; +#else +int ret =0 ; + +DRM_INFO ("Replacing VGA console driver\n" ); + +console_lock (); +if (con_is_bound (&vga_con)) + ret =do_take_over_console (&dummy_con,0 ,MAX_NR_CONSOLES -1 ,1 ); +if (ret ==0 ) { + ret =do_unregister_con_driver (&vga_con); + +/* Ignore "already unregistered". */ +if (ret == -ENODEV ) + ret =0 ; + } +console_unlock (); + +return ret; +#endif +} +EXPORT_SYMBOL (drm_fb_helper_kick_out_vgacon);drivers/gpu/drm/i915/i915_drv.c +1
-34@@ -757,39 +757,6 @@ static int i915_kick_out_firmware_fb(struct drm_i915_private *dev_priv)return ret; } -#if !defined(CONFIG_VGA_CONSOLE ) -static int i915_kick_out_vgacon (struct drm_i915_private *dev_priv) -{ -return 0 ; -} -#elif !defined(CONFIG_DUMMY_CONSOLE ) -static int i915_kick_out_vgacon (struct drm_i915_private *dev_priv) -{ -return -ENODEV ; -} -#else -static int i915_kick_out_vgacon (struct drm_i915_private *dev_priv) -{ -int ret =0 ; - -DRM_INFO ("Replacing VGA console driver\n" ); - -console_lock (); -if (con_is_bound (&vga_con)) - ret =do_take_over_console (&dummy_con,0 ,MAX_NR_CONSOLES -1 ,1 ); -if (ret ==0 ) { - ret =do_unregister_con_driver (&vga_con); - -/* Ignore "already unregistered". */ -if (ret == -ENODEV ) - ret =0 ; - } -console_unlock (); - -return ret; -} -#endif -static void intel_init_dpio (struct drm_i915_private *dev_priv) {/* @@ -1420,7 +1387,7 @@ static int i915_driver_init_hw(struct drm_i915_private *dev_priv) goto err_ggtt; } - ret =i915_kick_out_vgacon (dev_priv); + ret =drm_fb_helper_kick_out_vgacon ();if (ret) {DRM_ERROR ("failed to remove conflicting VGA console\n" ); goto err_ggtt;Signature · 1 line
2.9.3
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
Quoted 15 lines · Gerd Hoffmann
Problem: qxl switches from native mode back into vga compatibility mode when it notices someone is accessing vga registers. And vgacon does exactly that before fbcon takes over. So make sure we kick out vgacon early enough that it wouldn't disturb us.
Signed-off-by Gerd Hoffmann <[email protected]>--- drivers/gpu/drm/qxl/qxl_drv.c | 1 + 1 file changed, 1 insertion(+)drivers/gpu/drm/qxl/qxl_drv.c +0
-0
drivers/gpu/drm/qxl/qxl_drv.c qxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) · line 98
Quoted 4 lines
drivers/gpu/drm/qxl/qxl_drv.c +1
-0@@ -95,6 +95,7 @@ qxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) goto modeset_cleanup;drm_fb_helper_remove_conflicting_pci_framebuffers (pdev,0 ,"qxl" ); +drm_fb_helper_kick_out_vgacon ();
I was thinking of checking whether pdev is a VGA class device and whether it decodes vga access, and in that case automatically calling kick_out_vgacon from remove_conflicting_pci_framebuffer. Since that's what drivers want anyway, and those who don't can open code it.
Or is there an issue with that?
-Daniel
Quoted 6 lines
drivers/gpu/drm/qxl/qxl_drv.c +0
-0drm_fbdev_generic_setup (&qdev->ddev,32 );return 0 ;Signature · 1 line
2.9.3
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Spice-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/spice-devel
Quoted 15 lines · Gerd Hoffmann
Problem: qxl switches from native mode back into vga compatibility mode when it notices someone is accessing vga registers. And vgacon does exactly that before fbcon takes over. So make sure we kick out vgacon early enough that it wouldn't disturb us.
Signed-off-by Gerd Hoffmann <[email protected]>--- drivers/gpu/drm/qxl/qxl_drv.c | 1 + 1 file changed, 1 insertion(+)drivers/gpu/drm/qxl/qxl_drv.c +0
-0
drivers/gpu/drm/qxl/qxl_drv.c qxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) · line 98
Quoted 4 lines
drivers/gpu/drm/qxl/qxl_drv.c +1
-0@@ -95,6 +95,7 @@ qxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) goto modeset_cleanup;drm_fb_helper_remove_conflicting_pci_framebuffers (pdev,0 ,"qxl" ); +drm_fb_helper_kick_out_vgacon ();
I was thinking of checking whether pdev is a VGA class device and whether it decodes vga access, and in that case automatically calling kick_out_vgacon from remove_conflicting_pci_framebuffer. Since that's what drivers want anyway, and those who don't can open code it.
Or is there an issue with that?
-Daniel
Quoted 6 lines
drivers/gpu/drm/qxl/qxl_drv.c +0
-0drm_fbdev_generic_setup (&qdev->ddev,32 );return 0 ;Signature · 1 line
2.9.3
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch
Gerd Hoffmann
maintainerRe: [PATCH v2 1/2] drm: move i915_kick_out_vgacon to drm_fb_helper
In reply to Daniel VetterQuoted 8 lines
Quoted 6 lines
+/**
+ *drm_fb_helper_kick_out_vgacon- deactivate vgacon driver.
+ *
+ * Deactivate vgacon driver so it stops accessing vga io ports.
+ * Should be called after
+ *drm_fb_helper_remove_conflicting_pci_framebuffers().Why after? i915 calls this before kicking out the fbdev drivers ...
No, it doesn't:
<quote>
/*
* WARNING: Apparently we must kick fbdev drivers before vgacon,
* otherwise the vga fbdev driver falls over.
*/
ret = i915_kick_out_firmware_fb(dev_priv);
if (ret) {
DRM_ERROR("failed to remove conflicting framebuffer drivers\n");
goto err_ggtt;
}
ret = i915_kick_out_vgacon(dev_priv);
if (ret) {
DRM_ERROR("failed to remove conflicting VGA console\n");
goto err_ggtt;
}</quote>
cheers,
Gerd
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Gerd Hoffmann
maintainerQuoted 26 lines · Daniel Vetter
Quoted 15 lines · Gerd Hoffmann
Problem: qxl switches from native mode back into vga compatibility mode when it notices someone is accessing vga registers. And vgacon does exactly that before fbcon takes over. So make sure we kick out vgacon early enough that it wouldn't disturb us.
Signed-off-by Gerd Hoffmann <[email protected]>--- drivers/gpu/drm/qxl/qxl_drv.c | 1 + 1 file changed, 1 insertion(+)drivers/gpu/drm/qxl/qxl_drv.c +0
-0drivers/gpu/drm/qxl/qxl_drv.c qxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) · line 98
Quoted 4 lines
drivers/gpu/drm/qxl/qxl_drv.c +1
-0@@ -95,6 +95,7 @@ qxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) goto modeset_cleanup;drm_fb_helper_remove_conflicting_pci_framebuffers (pdev,0 ,"qxl" ); +drm_fb_helper_kick_out_vgacon ();I was thinking of checking whether pdev is a VGA class device and whether it decodes vga access, and in that case automatically calling
kick_out_vgaconfromremove_conflicting_pci_framebuffer. Since that's what drivers want anyway, and those who don't can open code it.
Quoted 1 line
Or is there an issue with that?
It'll need more careful testing to make sure we don't have unwanted side effects when just doing it for everyone. And I guess most drivers don't care much because their hardware ignores vga port writes once they are switched out of vga text mode.
Dunno why i915 needs this.
In case of qxl it is more a historical leftover. The very first qxl device revision had no explicit qxl command to switch from qxl native mode back to vga compatibility mode, vga port access was used for that instead. It's long fixed, but the qxl device still has that quirk for compatibility with very old guest drivers.
cheers,
Gerd
_______________________________________________
Spice-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/spice-devel
Gerd Hoffmann
maintainerQuoted 26 lines · Daniel Vetter
Quoted 15 lines · Gerd Hoffmann
Problem: qxl switches from native mode back into vga compatibility mode when it notices someone is accessing vga registers. And vgacon does exactly that before fbcon takes over. So make sure we kick out vgacon early enough that it wouldn't disturb us.
Signed-off-by Gerd Hoffmann <[email protected]>--- drivers/gpu/drm/qxl/qxl_drv.c | 1 + 1 file changed, 1 insertion(+)drivers/gpu/drm/qxl/qxl_drv.c +0
-0drivers/gpu/drm/qxl/qxl_drv.c qxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) · line 98
Quoted 4 lines
drivers/gpu/drm/qxl/qxl_drv.c +1
-0@@ -95,6 +95,7 @@ qxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) goto modeset_cleanup;drm_fb_helper_remove_conflicting_pci_framebuffers (pdev,0 ,"qxl" ); +drm_fb_helper_kick_out_vgacon ();I was thinking of checking whether pdev is a VGA class device and whether it decodes vga access, and in that case automatically calling
kick_out_vgaconfromremove_conflicting_pci_framebuffer. Since that's what drivers want anyway, and those who don't can open code it.
Quoted 1 line
Or is there an issue with that?
It'll need more careful testing to make sure we don't have unwanted side effects when just doing it for everyone. And I guess most drivers don't care much because their hardware ignores vga port writes once they are switched out of vga text mode.
Dunno why i915 needs this.
In case of qxl it is more a historical leftover. The very first qxl device revision had no explicit qxl command to switch from qxl native mode back to vga compatibility mode, vga port access was used for that instead. It's long fixed, but the qxl device still has that quirk for compatibility with very old guest drivers.
cheers,
Gerd
Jani Nikula
maintainerRe: [PATCH v2 1/2] drm: move i915_kick_out_vgacon to drm_fb_helper
In reply to Gerd HoffmannQuoted 45 lines · Gerd Hoffmann
It'll be useful for other drivers too, so move it to
drm_fb_helper.c(and rename it of course). Also add docs.Signed-off-by Gerd Hoffmann <[email protected]>--- include/drm/drm_fb_helper.h | 2 ++ drivers/gpu/drm/drm_fb_helper.c | 39 +++++++++++++++++++++++++++++++++++++++ drivers/gpu/drm/i915/i915_drv.c | 35 +---------------------------------- 3 files changed, 42 insertions(+), 34 deletions(-)include/drm/drm_fb_helper.h +2
-0@@ -649,4 +649,6 @@ drm_fb_helper_remove_conflicting_pci_framebuffers(struct pci_dev *pdev, #endif } +int drm_fb_helper_kick_out_vgacon (void ); +#endif drivers/gpu/drm/drm_fb_helper.c +9
-0@@ -35,6 +35,7 @@#include <linux/sysrq.h> #include <linux/slab.h> #include <linux/module.h> +#include <linux/vt_kern.h> #include <drm/drmP.h> #include <drm/drm_crtc.h> #include <drm/drm_fb_helper.h> @@ -3353,3 +3354,41 @@ int __init drm_fb_helper_modinit(void)return 0 ; }EXPORT_SYMBOL (drm_fb_helper_modinit); + +/** +* drm_fb_helper_kick_out_vgacon - deactivate vgacon driver. +* +* Deactivate vgacon driver so it stops accessing vga io ports. +* Should be called after +* drm_fb_helper_remove_conflicting_pci_framebuffers(). +*
drivers/gpu/drm/drm_fb_helper.c int __init drm_fb_helper_modinit(void) · line 3374
Quoted 10 lines
drivers/gpu/drm/drm_fb_helper.c +10
-0+* Returns: +* Zero on success or negative error code on failure. +*/ +int drm_fb_helper_kick_out_vgacon (void ) +{ +#if !defined(CONFIG_VGA_CONSOLE ) +return 0 ; +#elif !defined(CONFIG_DUMMY_CONSOLE ) +return -ENODEV ; +#else
Please retain the original way of keeping conditional compilation outside of functions.
BR,
Jani.
Quoted 73 lines
drivers/gpu/drm/drm_fb_helper.c +20
-0+int ret =0 ; + +DRM_INFO ("Replacing VGA console driver\n" ); + +console_lock (); +if (con_is_bound (&vga_con)) + ret =do_take_over_console (&dummy_con,0 ,MAX_NR_CONSOLES -1 ,1 ); +if (ret ==0 ) { + ret =do_unregister_con_driver (&vga_con); + +/* Ignore "already unregistered". */ +if (ret == -ENODEV ) + ret =0 ; + } +console_unlock (); + +return ret; +#endif +} +EXPORT_SYMBOL (drm_fb_helper_kick_out_vgacon);drivers/gpu/drm/i915/i915_drv.c +1
-34@@ -757,39 +757,6 @@ static int i915_kick_out_firmware_fb(struct drm_i915_private *dev_priv)return ret; } -#if !defined(CONFIG_VGA_CONSOLE ) -static int i915_kick_out_vgacon (struct drm_i915_private *dev_priv) -{ -return 0 ; -} -#elif !defined(CONFIG_DUMMY_CONSOLE ) -static int i915_kick_out_vgacon (struct drm_i915_private *dev_priv) -{ -return -ENODEV ; -} -#else -static int i915_kick_out_vgacon (struct drm_i915_private *dev_priv) -{ -int ret =0 ; - -DRM_INFO ("Replacing VGA console driver\n" ); - -console_lock (); -if (con_is_bound (&vga_con)) - ret =do_take_over_console (&dummy_con,0 ,MAX_NR_CONSOLES -1 ,1 ); -if (ret ==0 ) { - ret =do_unregister_con_driver (&vga_con); - -/* Ignore "already unregistered". */ -if (ret == -ENODEV ) - ret =0 ; - } -console_unlock (); - -return ret; -} -#endif -static void intel_init_dpio (struct drm_i915_private *dev_priv) {/* @@ -1420,7 +1387,7 @@ static int i915_driver_init_hw(struct drm_i915_private *dev_priv) goto err_ggtt; } - ret =i915_kick_out_vgacon (dev_priv); + ret =drm_fb_helper_kick_out_vgacon ();if (ret) {DRM_ERROR ("failed to remove conflicting VGA console\n" ); goto err_ggtt;
Signature · 1 line
Jani Nikula, Intel Open Source Graphics Center
Gerd Hoffmann
maintainerRe: [PATCH v2 1/2] drm: move i915_kick_out_vgacon to drm_fb_helper
Quoted 51 lines · Jani Nikula
Quoted 50 lines · Gerd Hoffmann
It'll be useful for other drivers too, so move it to
drm_fb_helper.c(and rename it of course). Also add docs.Signed-off-by Gerd Hoffmann <[email protected]>--- include/drm/drm_fb_helper.h | 2 ++ drivers/gpu/drm/drm_fb_helper.c | 39 +++++++++++++++++++++++++++++++++++++++ drivers/gpu/drm/i915/i915_drv.c | 35 +---------------------------------- 3 files changed, 42 insertions(+), 34 deletions(-)include/drm/drm_fb_helper.h +2
-0@@ -649,4 +649,6 @@ drm_fb_helper_remove_conflicting_pci_framebuffers(struct pci_dev *pdev, #endif } +int drm_fb_helper_kick_out_vgacon (void ); +#endif drivers/gpu/drm/drm_fb_helper.c +14
-0@@ -35,6 +35,7 @@#include <linux/sysrq.h> #include <linux/slab.h> #include <linux/module.h> +#include <linux/vt_kern.h> #include <drm/drmP.h> #include <drm/drm_crtc.h> #include <drm/drm_fb_helper.h> @@ -3353,3 +3354,41 @@ int __init drm_fb_helper_modinit(void)return 0 ; }EXPORT_SYMBOL (drm_fb_helper_modinit); + +/** +* drm_fb_helper_kick_out_vgacon - deactivate vgacon driver. +* +* Deactivate vgacon driver so it stops accessing vga io ports. +* Should be called after +* drm_fb_helper_remove_conflicting_pci_framebuffers(). +* +* Returns: +* Zero on success or negative error code on failure. +*/ +int drm_fb_helper_kick_out_vgacon (void ) +{
Quoted 8 lines
drivers/gpu/drm/drm_fb_helper.c int __init drm_fb_helper_modinit(void) · line 3374
Quoted 5 lines
drivers/gpu/drm/drm_fb_helper.c +5
-0+#if !defined(CONFIG_VGA_CONSOLE ) +return 0 ; +#elif !defined(CONFIG_DUMMY_CONSOLE ) +return -ENODEV ; +#else Please retain the original way of keeping conditional compilation outside of functions.
Care to explain why that is better?
thanks,
Gerd
Re: [PATCH v2 1/2] drm: move i915_kick_out_vgacon to drm_fb_helper
In reply to Gerd HoffmannDen 21.02.2019 12.35, skrev Gerd Hoffmann:
Quoted 15 lines
It'll be useful for other drivers too, so move it to
drm_fb_helper.c(and rename it of course). Also add docs.Signed-off-by Gerd Hoffmann <[email protected]>--- include/drm/drm_fb_helper.h | 2 ++ drivers/gpu/drm/drm_fb_helper.c | 39 +++++++++++++++++++++++++++++++++++++++ drivers/gpu/drm/i915/i915_drv.c | 35 +---------------------------------- 3 files changed, 42 insertions(+), 34 deletions(-)include/drm/drm_fb_helper.h +0
-0
include/drm/drm_fb_helper.h drm_fb_helper_remove_conflicting_pci_framebuffers(struct pci_dev *pdev, · line 653
Quoted 5 lines
include/drm/drm_fb_helper.h +2
-0@@ -649,4 +649,6 @@ drm_fb_helper_remove_conflicting_pci_framebuffers(struct pci_dev *pdev,#endif } +int drm_fb_helper_kick_out_vgacon (void ); +
Don't you need a dummy version as well for this one, like how it's done for the other functions, to cover the case when DRM_FBDEV_EMULATION is not selected?
Noralf.
Quoted 101 lines
include/drm/drm_fb_helper.h +0
-0#endif drivers/gpu/drm/drm_fb_helper.c +39
-0@@ -35,6 +35,7 @@#include <linux/sysrq.h> #include <linux/slab.h> #include <linux/module.h> +#include <linux/vt_kern.h> #include <drm/drmP.h> #include <drm/drm_crtc.h> #include <drm/drm_fb_helper.h> @@ -3353,3 +3354,41 @@ int __init drm_fb_helper_modinit(void)return 0 ; }EXPORT_SYMBOL (drm_fb_helper_modinit); + +/** +* drm_fb_helper_kick_out_vgacon - deactivate vgacon driver. +* +* Deactivate vgacon driver so it stops accessing vga io ports. +* Should be called after +* drm_fb_helper_remove_conflicting_pci_framebuffers(). +* +* Returns: +* Zero on success or negative error code on failure. +*/ +int drm_fb_helper_kick_out_vgacon (void ) +{ +#if !defined(CONFIG_VGA_CONSOLE ) +return 0 ; +#elif !defined(CONFIG_DUMMY_CONSOLE ) +return -ENODEV ; +#else +int ret =0 ; + +DRM_INFO ("Replacing VGA console driver\n" ); + +console_lock (); +if (con_is_bound (&vga_con)) + ret =do_take_over_console (&dummy_con,0 ,MAX_NR_CONSOLES -1 ,1 ); +if (ret ==0 ) { + ret =do_unregister_con_driver (&vga_con); + +/* Ignore "already unregistered". */ +if (ret == -ENODEV ) + ret =0 ; + } +console_unlock (); + +return ret; +#endif +} +EXPORT_SYMBOL (drm_fb_helper_kick_out_vgacon);drivers/gpu/drm/i915/i915_drv.c +0
-33@@ -757,39 +757,6 @@ static int i915_kick_out_firmware_fb(struct drm_i915_private *dev_priv)return ret; } -#if !defined(CONFIG_VGA_CONSOLE ) -static int i915_kick_out_vgacon (struct drm_i915_private *dev_priv) -{ -return 0 ; -} -#elif !defined(CONFIG_DUMMY_CONSOLE ) -static int i915_kick_out_vgacon (struct drm_i915_private *dev_priv) -{ -return -ENODEV ; -} -#else -static int i915_kick_out_vgacon (struct drm_i915_private *dev_priv) -{ -int ret =0 ; - -DRM_INFO ("Replacing VGA console driver\n" ); - -console_lock (); -if (con_is_bound (&vga_con)) - ret =do_take_over_console (&dummy_con,0 ,MAX_NR_CONSOLES -1 ,1 ); -if (ret ==0 ) { - ret =do_unregister_con_driver (&vga_con); - -/* Ignore "already unregistered". */ -if (ret == -ENODEV ) - ret =0 ; - } -console_unlock (); - -return ret; -} -#endif -static void intel_init_dpio (struct drm_i915_private *dev_priv) {/*
drivers/gpu/drm/i915/i915_drv.c static int i915_driver_init_hw(struct drm_i915_private *dev_priv) · line 1393
Quoted 8 lines
drivers/gpu/drm/i915/i915_drv.c +1
-1@@ -1420,7 +1387,7 @@ static int i915_driver_init_hw(struct drm_i915_private *dev_priv) goto err_ggtt; } - ret =i915_kick_out_vgacon (dev_priv); + ret =drm_fb_helper_kick_out_vgacon ();if (ret) {DRM_ERROR ("failed to remove conflicting VGA console\n" ); goto err_ggtt;
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Daniel Vetter
Acked-by Chris WilsonRe: [PATCH v2 1/2] drm: move i915_kick_out_vgacon to drm_fb_helper
In reply to Gerd HoffmannQuoted 27 lines · Gerd Hoffmann
Quoted 8 lines
Quoted 6 lines
+/**
+ *drm_fb_helper_kick_out_vgacon- deactivate vgacon driver.
+ *
+ * Deactivate vgacon driver so it stops accessing vga io ports.
+ * Should be called after
+ *drm_fb_helper_remove_conflicting_pci_framebuffers().Why after? i915 calls this before kicking out the fbdev drivers ...
No, it doesn't:
<quote>
/* * WARNING: Apparently we must kick fbdev drivers before vgacon, * otherwise the vga fbdev driver falls over. */ ret = i915_kick_out_firmware_fb(dev_priv); if (ret) { DRM_ERROR("failed to remove conflicting framebuffer drivers\n"); goto err_ggtt; } ret = i915_kick_out_vgacon(dev_priv); if (ret) { DRM_ERROR("failed to remove conflicting VGA console\n"); goto err_ggtt; }
Quoted 1 line
</quote>
/me collects special prize for failing to remove blinders before replying
And indeed this has reasons:
commit 0485c9dc24ec0939b42ca5104c0373297506b555 (tag: drm-intel-fixes-2014-11-19)
Author: Daniel Vetter <[email protected]> Date: Fri Nov 14 10:09:49 2014 +0100
drm/i915: Kick fbdev before vgacon
It's magic, but it seems to work.
This fixes a regression introduced in
commit 1bb9e632a0aeee1121e652ee4dc80e5e6f14bcd2
Author: Daniel Vetter <[email protected]>
Date: Tue Jul 8 10:02:43 2014 +0200
drm/i915: Only unbind vgacon, not other console drivers
My best guess is that the vga fbdev driver falls over if we rip out parts of vgacon. Hooray.
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=82439
I think given that even more reasons that the pci helper should automatically kick out all the things, in the right order. And perhaps cite the above commit in the commit message somewhere. -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
Quoted 27 lines · Gerd Hoffmann
Quoted 26 lines · Daniel Vetter
Quoted 15 lines · Gerd Hoffmann
Problem: qxl switches from native mode back into vga compatibility mode when it notices someone is accessing vga registers. And vgacon does exactly that before fbcon takes over. So make sure we kick out vgacon early enough that it wouldn't disturb us.
Signed-off-by Gerd Hoffmann <[email protected]>--- drivers/gpu/drm/qxl/qxl_drv.c | 1 + 1 file changed, 1 insertion(+)drivers/gpu/drm/qxl/qxl_drv.c +0
-0drivers/gpu/drm/qxl/qxl_drv.c qxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) · line 98
Quoted 4 lines
drivers/gpu/drm/qxl/qxl_drv.c +1
-0@@ -95,6 +95,7 @@ qxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) goto modeset_cleanup;drm_fb_helper_remove_conflicting_pci_framebuffers (pdev,0 ,"qxl" ); +drm_fb_helper_kick_out_vgacon ();I was thinking of checking whether pdev is a VGA class device and whether it decodes vga access, and in that case automatically calling
kick_out_vgaconfromremove_conflicting_pci_framebuffer. Since that's what drivers want anyway, and those who don't can open code it.
Quoted 8 lines
Quoted 1 line
Or is there an issue with that?
It'll need more careful testing to make sure we don't have unwanted side effects when just doing it for everyone. And I guess most drivers don't care much because their hardware ignores vga port writes once they are switched out of vga text mode.
Dunno why i915 needs this.
The problem isn't loading, it's unloading again. If you boot with vgacon, but no fbdev driver (which iirc also has magic code to throw out the vga console), then when you unload your kms driver vgacon kicks back in. And a pile of things go really sideways when that happens.
I have no idea whether it's just intel hw or maybe pci decoding or something else, but seems like good practice to kick out all existing drivers, to make sure they can never get at the hw again.
So don't think it'll hurt to do this for everyone. But yeah maybe we can do that as a follow-up (and convert i915 over), dunno. -Daniel
Quoted 13 lines
In case of qxl it is more a historical leftover. The very first qxl device revision had no explicit qxl command to switch from qxl native mode back to vga compatibility mode, vga port access was used for that instead. It's long fixed, but the qxl device still has that quirk for compatibility with very old guest drivers.
cheers,
Gerd_______________________________________________
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
Quoted 27 lines · Gerd Hoffmann
Quoted 26 lines · Daniel Vetter
Quoted 15 lines · Gerd Hoffmann
Problem: qxl switches from native mode back into vga compatibility mode when it notices someone is accessing vga registers. And vgacon does exactly that before fbcon takes over. So make sure we kick out vgacon early enough that it wouldn't disturb us.
Signed-off-by Gerd Hoffmann <[email protected]>--- drivers/gpu/drm/qxl/qxl_drv.c | 1 + 1 file changed, 1 insertion(+)drivers/gpu/drm/qxl/qxl_drv.c +0
-0drivers/gpu/drm/qxl/qxl_drv.c qxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) · line 98
Quoted 4 lines
drivers/gpu/drm/qxl/qxl_drv.c +1
-0@@ -95,6 +95,7 @@ qxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) goto modeset_cleanup;drm_fb_helper_remove_conflicting_pci_framebuffers (pdev,0 ,"qxl" ); +drm_fb_helper_kick_out_vgacon ();I was thinking of checking whether pdev is a VGA class device and whether it decodes vga access, and in that case automatically calling
kick_out_vgaconfromremove_conflicting_pci_framebuffer. Since that's what drivers want anyway, and those who don't can open code it.
Quoted 8 lines
Quoted 1 line
Or is there an issue with that?
It'll need more careful testing to make sure we don't have unwanted side effects when just doing it for everyone. And I guess most drivers don't care much because their hardware ignores vga port writes once they are switched out of vga text mode.
Dunno why i915 needs this.
The problem isn't loading, it's unloading again. If you boot with vgacon, but no fbdev driver (which iirc also has magic code to throw out the vga console), then when you unload your kms driver vgacon kicks back in. And a pile of things go really sideways when that happens.
I have no idea whether it's just intel hw or maybe pci decoding or something else, but seems like good practice to kick out all existing drivers, to make sure they can never get at the hw again.
So don't think it'll hurt to do this for everyone. But yeah maybe we can do that as a follow-up (and convert i915 over), dunno. -Daniel
Quoted 13 lines
In case of qxl it is more a historical leftover. The very first qxl device revision had no explicit qxl command to switch from qxl native mode back to vga compatibility mode, vga port access was used for that instead. It's long fixed, but the qxl device still has that quirk for compatibility with very old guest drivers.
cheers,
Gerd_______________________________________________
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
Jani Nikula
maintainerRe: [PATCH v2 1/2] drm: move i915_kick_out_vgacon to drm_fb_helper
In reply to Gerd HoffmannQuoted 61 lines · Gerd Hoffmann
Quoted 51 lines · Jani Nikula
Quoted 50 lines · Gerd Hoffmann
It'll be useful for other drivers too, so move it to
drm_fb_helper.c(and rename it of course). Also add docs.Signed-off-by Gerd Hoffmann <[email protected]>--- include/drm/drm_fb_helper.h | 2 ++ drivers/gpu/drm/drm_fb_helper.c | 39 +++++++++++++++++++++++++++++++++++++++ drivers/gpu/drm/i915/i915_drv.c | 35 +---------------------------------- 3 files changed, 42 insertions(+), 34 deletions(-)include/drm/drm_fb_helper.h +2
-0@@ -649,4 +649,6 @@ drm_fb_helper_remove_conflicting_pci_framebuffers(struct pci_dev *pdev, #endif } +int drm_fb_helper_kick_out_vgacon (void ); +#endif drivers/gpu/drm/drm_fb_helper.c +14
-0@@ -35,6 +35,7 @@#include <linux/sysrq.h> #include <linux/slab.h> #include <linux/module.h> +#include <linux/vt_kern.h> #include <drm/drmP.h> #include <drm/drm_crtc.h> #include <drm/drm_fb_helper.h> @@ -3353,3 +3354,41 @@ int __init drm_fb_helper_modinit(void)return 0 ; }EXPORT_SYMBOL (drm_fb_helper_modinit); + +/** +* drm_fb_helper_kick_out_vgacon - deactivate vgacon driver. +* +* Deactivate vgacon driver so it stops accessing vga io ports. +* Should be called after +* drm_fb_helper_remove_conflicting_pci_framebuffers(). +* +* Returns: +* Zero on success or negative error code on failure. +*/ +int drm_fb_helper_kick_out_vgacon (void ) +{Quoted 8 lines
drivers/gpu/drm/drm_fb_helper.c int __init drm_fb_helper_modinit(void) · line 3374
Quoted 5 lines
drivers/gpu/drm/drm_fb_helper.c +5
-0+#if !defined(CONFIG_VGA_CONSOLE ) +return 0 ; +#elif !defined(CONFIG_DUMMY_CONSOLE ) +return -ENODEV ; +#else Please retain the original way of keeping conditional compilation outside of functions.
Quoted 1 line
Care to explain why that is better?
Prevalent and documented [1] kernel coding style. It's easier to see what happens in each branch, and the compiler throws the alternatives away anyway.
Patches that do code movement should focus on code movement. Any additional changes should be separate, and justified separately. The function rename and documentation are of course okay, and they're mentioned in the commit message as they should.
BR,
Jani.
[1] Documentation/process/coding-style.rst
Signature · 1 line
Jani Nikula, Intel Open Source Graphics Center
Gerd Hoffmann
maintainerRe: [PATCH v2 1/2] drm: move i915_kick_out_vgacon to drm_fb_helper
In reply to Noralf TrønnesQuoted 6 lines
include/drm/drm_fb_helper.h drm_fb_helper_remove_conflicting_pci_framebuffers(struct pci_dev *pdev, · line 653
Quoted 2 lines
include/drm/drm_fb_helper.h +2
-0+int drm_fb_helper_kick_out_vgacon (void ); +Don't you need a dummy version as well for this one, like how it's done for the other functions, to cover the case when
DRM_FBDEV_EMULATIONis not selected?
Good question.
I guess it makes sense to kick out vgacon even with CONFIG_FB=n.
But when integrating this into drm_fb_helper_remove_conflicting_pci_framebuffers() as suggested by Daniel this isn't going to fly ...
cheers,
Gerd
Gerd Hoffmann
maintainerHi,
Quoted 2 lines
I was thinking of checking whether pdev is a VGA class device and whether it decodes vga access, and in that case automatically calling
How can I figure that? Ok, class is easy, but decode? pci.h offers functions to set vga decode but not to get that info ...
thanks,
Gerd
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Gerd Hoffmann
maintainerHi,
Quoted 2 lines
I was thinking of checking whether pdev is a VGA class device and whether it decodes vga access, and in that case automatically calling
How can I figure that? Ok, class is easy, but decode? pci.h offers functions to set vga decode but not to get that info ...
thanks,
Gerd
Quoted 8 lines · Gerd Hoffmann
Hi,
Quoted 2 lines
I was thinking of checking whether pdev is a VGA class device and whether it decodes vga access, and in that case automatically calling
How can I figure that? Ok, class is easy, but decode?
pci.hoffers functions to set vga decode but not to get that info ...
PCI_COMMAND_MEM and PCI_COMMAND_IO. There doesn't seem to be any separate bits really. That's at least what I've gleaned from vgaarb.c. The magic legacy vga decode bits only seem to exist on bridges, maybe we can extract that logic from vgaarb.c (yes this is all a bit spiralling out of control).
-Daniel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
Quoted 8 lines · Gerd Hoffmann
Hi,
Quoted 2 lines
I was thinking of checking whether pdev is a VGA class device and whether it decodes vga access, and in that case automatically calling
How can I figure that? Ok, class is easy, but decode?
pci.hoffers functions to set vga decode but not to get that info ...
PCI_COMMAND_MEM and PCI_COMMAND_IO. There doesn't seem to be any separate bits really. That's at least what I've gleaned from vgaarb.c. The magic legacy vga decode bits only seem to exist on bridges, maybe we can extract that logic from vgaarb.c (yes this is all a bit spiralling out of control).
-Daniel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
Re: [PATCH v2 1/2] drm: move i915_kick_out_vgacon to drm_fb_helper
In reply to Gerd HoffmannQuoted 7 lines · Gerd Hoffmann
Quoted 6 lines
include/drm/drm_fb_helper.h drm_fb_helper_remove_conflicting_pci_framebuffers(struct pci_dev *pdev, · line 653
Quoted 2 lines
include/drm/drm_fb_helper.h +2
-0+int drm_fb_helper_kick_out_vgacon (void ); +Don't you need a dummy version as well for this one, like how it's done for the other functions, to cover the case when
DRM_FBDEV_EMULATIONis not selected?
Quoted 7 lines
Good question.
I guess it makes sense to kick out vgacon even with
CONFIG_FB=n.But when integrating this into
drm_fb_helper_remove_conflicting_pci_framebuffers()as suggested by Daniel this isn't going to fly ...
We need to put it into both versions of that function, or pull that function out of the #ifdef.
-Daniel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Gerd Hoffmann
maintainerHi,
Quoted 5 lines
PCI_COMMAND_MEMandPCI_COMMAND_IO. There doesn't seem to be any separate bits really. That's at least what I've gleaned fromvgaarb.c. The magic legacy vga decode bits only seem to exist on bridges, maybe we can extract that logic fromvgaarb.c(yes this is all a bit spiralling out of control).
Also makes me wonder whenever vgaarb is the better place (compared to drm_fb_helper). Tried that, doesn't look too bad, should continue working with CONFIG_FB=n. Will send patches in a moment.
cheers,
Gerd
Gerd Hoffmann
maintainerHi,
Quoted 5 lines
PCI_COMMAND_MEMandPCI_COMMAND_IO. There doesn't seem to be any separate bits really. That's at least what I've gleaned fromvgaarb.c. The magic legacy vga decode bits only seem to exist on bridges, maybe we can extract that logic fromvgaarb.c(yes this is all a bit spiralling out of control).
Also makes me wonder whenever vgaarb is the better place (compared to drm_fb_helper). Tried that, doesn't look too bad, should continue working with CONFIG_FB=n. Will send patches in a moment.
cheers,
Gerd