diff mbox series

[v2,2/2] drm/qxl: kick out vgacon

Message ID 20190221113534.20764-3-kraxel@redhat.com (mailing list archive)
State New, archived
Headers show
Series drm/qxl: kick out vgacon | expand

Commit Message

Gerd Hoffmann Feb. 21, 2019, 11:35 a.m. UTC
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 <kraxel@redhat.com>
---
 drivers/gpu/drm/qxl/qxl_drv.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Daniel Vetter Feb. 21, 2019, 12:20 p.m. UTC | #1
On Thu, Feb 21, 2019 at 12:35:34PM +0100, Gerd Hoffmann wrote:
> 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 <kraxel@redhat.com>
> ---
>  drivers/gpu/drm/qxl/qxl_drv.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/gpu/drm/qxl/qxl_drv.c b/drivers/gpu/drm/qxl/qxl_drv.c
> index bb81e310eb..08446561aa 100644
> --- a/drivers/gpu/drm/qxl/qxl_drv.c
> +++ b/drivers/gpu/drm/qxl/qxl_drv.c
> @@ -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

>  	drm_fbdev_generic_setup(&qdev->ddev, 32);
>  	return 0;
>  
> -- 
> 2.9.3
>
Gerd Hoffmann Feb. 21, 2019, 1:06 p.m. UTC | #2
On Thu, Feb 21, 2019 at 01:20:11PM +0100, Daniel Vetter wrote:
> On Thu, Feb 21, 2019 at 12:35:34PM +0100, Gerd Hoffmann wrote:
> > 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 <kraxel@redhat.com>
> > ---
> >  drivers/gpu/drm/qxl/qxl_drv.c | 1 +
> >  1 file changed, 1 insertion(+)
> > 
> > diff --git a/drivers/gpu/drm/qxl/qxl_drv.c b/drivers/gpu/drm/qxl/qxl_drv.c
> > index bb81e310eb..08446561aa 100644
> > --- a/drivers/gpu/drm/qxl/qxl_drv.c
> > +++ b/drivers/gpu/drm/qxl/qxl_drv.c
> > @@ -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?

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
Daniel Vetter Feb. 21, 2019, 2:24 p.m. UTC | #3
On Thu, Feb 21, 2019 at 02:06:23PM +0100, Gerd Hoffmann wrote:
> On Thu, Feb 21, 2019 at 01:20:11PM +0100, Daniel Vetter wrote:
> > On Thu, Feb 21, 2019 at 12:35:34PM +0100, Gerd Hoffmann wrote:
> > > 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 <kraxel@redhat.com>
> > > ---
> > >  drivers/gpu/drm/qxl/qxl_drv.c | 1 +
> > >  1 file changed, 1 insertion(+)
> > > 
> > > diff --git a/drivers/gpu/drm/qxl/qxl_drv.c b/drivers/gpu/drm/qxl/qxl_drv.c
> > > index bb81e310eb..08446561aa 100644
> > > --- a/drivers/gpu/drm/qxl/qxl_drv.c
> > > +++ b/drivers/gpu/drm/qxl/qxl_drv.c
> > > @@ -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?
> 
> 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


> 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
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
Gerd Hoffmann Feb. 21, 2019, 3:11 p.m. UTC | #4
Hi,

> 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
Daniel Vetter Feb. 21, 2019, 3:17 p.m. UTC | #5
On Thu, Feb 21, 2019 at 4:11 PM Gerd Hoffmann <kraxel@redhat.com> wrote:
>
>   Hi,
>
> > 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 ...

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
Gerd Hoffmann Feb. 22, 2019, 7:14 a.m. UTC | #6
Hi,

> 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).

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
diff mbox series

Patch

diff --git a/drivers/gpu/drm/qxl/qxl_drv.c b/drivers/gpu/drm/qxl/qxl_drv.c
index bb81e310eb..08446561aa 100644
--- a/drivers/gpu/drm/qxl/qxl_drv.c
+++ b/drivers/gpu/drm/qxl/qxl_drv.c
@@ -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;