* [PATCH v2 2/2] drm/qxl: kick out vgacon [not found] <20190221113534.20764-1-kraxel@redhat.com> @ 2019-02-21 11:35 ` Gerd Hoffmann 2019-02-21 12:20 ` Daniel Vetter [not found] ` <20190221113534.20764-2-kraxel@redhat.com> 1 sibling, 1 reply; 13+ messages in thread From: Gerd Hoffmann @ 2019-02-21 11:35 UTC (permalink / raw) To: dri-devel Cc: daniel, Gerd Hoffmann, Dave Airlie, David Airlie, open list:DRM DRIVER FOR QXL VIRTUAL GPU, open list:DRM DRIVER FOR QXL VIRTUAL GPU, open list 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(); drm_fbdev_generic_setup(&qdev->ddev, 32); return 0; -- 2.9.3 ^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH v2 2/2] drm/qxl: kick out vgacon 2019-02-21 11:35 ` [PATCH v2 2/2] drm/qxl: kick out vgacon Gerd Hoffmann @ 2019-02-21 12:20 ` Daniel Vetter 2019-02-21 13:06 ` Gerd Hoffmann 2019-02-21 15:11 ` Gerd Hoffmann 0 siblings, 2 replies; 13+ messages in thread From: Daniel Vetter @ 2019-02-21 12:20 UTC (permalink / raw) To: Gerd Hoffmann Cc: dri-devel, daniel, Dave Airlie, David Airlie, open list:DRM DRIVER FOR QXL VIRTUAL GPU, open list:DRM DRIVER FOR QXL VIRTUAL GPU, open list 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 > -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2 2/2] drm/qxl: kick out vgacon 2019-02-21 12:20 ` Daniel Vetter @ 2019-02-21 13:06 ` Gerd Hoffmann 2019-02-21 14:24 ` Daniel Vetter 2019-02-21 15:11 ` Gerd Hoffmann 1 sibling, 1 reply; 13+ messages in thread From: Gerd Hoffmann @ 2019-02-21 13:06 UTC (permalink / raw) To: dri-devel, Dave Airlie, David Airlie, open list:DRM DRIVER FOR QXL VIRTUAL GPU, open list:DRM DRIVER FOR QXL VIRTUAL GPU, open list 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 ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2 2/2] drm/qxl: kick out vgacon 2019-02-21 13:06 ` Gerd Hoffmann @ 2019-02-21 14:24 ` Daniel Vetter 0 siblings, 0 replies; 13+ messages in thread From: Daniel Vetter @ 2019-02-21 14:24 UTC (permalink / raw) To: Gerd Hoffmann Cc: dri-devel, Dave Airlie, David Airlie, open list:DRM DRIVER FOR QXL VIRTUAL GPU, open list:DRM DRIVER FOR QXL VIRTUAL GPU, open list 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 -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2 2/2] drm/qxl: kick out vgacon 2019-02-21 12:20 ` Daniel Vetter 2019-02-21 13:06 ` Gerd Hoffmann @ 2019-02-21 15:11 ` Gerd Hoffmann 2019-02-21 15:17 ` Daniel Vetter 1 sibling, 1 reply; 13+ messages in thread From: Gerd Hoffmann @ 2019-02-21 15:11 UTC (permalink / raw) To: dri-devel, Dave Airlie, David Airlie, open list:DRM DRIVER FOR QXL VIRTUAL GPU, open list:DRM DRIVER FOR QXL VIRTUAL GPU, open list 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 ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2 2/2] drm/qxl: kick out vgacon 2019-02-21 15:11 ` Gerd Hoffmann @ 2019-02-21 15:17 ` Daniel Vetter 2019-02-22 7:14 ` Gerd Hoffmann 0 siblings, 1 reply; 13+ messages in thread From: Daniel Vetter @ 2019-02-21 15:17 UTC (permalink / raw) To: Gerd Hoffmann Cc: dri-devel, Dave Airlie, David Airlie, open list:DRM DRIVER FOR QXL VIRTUAL GPU, open list:DRM DRIVER FOR QXL VIRTUAL GPU, open list 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 -- Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2 2/2] drm/qxl: kick out vgacon 2019-02-21 15:17 ` Daniel Vetter @ 2019-02-22 7:14 ` Gerd Hoffmann 0 siblings, 0 replies; 13+ messages in thread From: Gerd Hoffmann @ 2019-02-22 7:14 UTC (permalink / raw) To: Daniel Vetter Cc: dri-devel, Dave Airlie, David Airlie, open list:DRM DRIVER FOR QXL VIRTUAL GPU, open list:DRM DRIVER FOR QXL VIRTUAL GPU, open list 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 ^ permalink raw reply [flat|nested] 13+ messages in thread
[parent not found: <20190221113534.20764-2-kraxel@redhat.com>]
* Re: [PATCH v2 1/2] drm: move i915_kick_out_vgacon to drm_fb_helper [not found] ` <20190221113534.20764-2-kraxel@redhat.com> @ 2019-02-21 13:08 ` Jani Nikula 2019-02-21 13:25 ` Gerd Hoffmann 2019-02-21 14:12 ` Noralf Trønnes 1 sibling, 1 reply; 13+ messages in thread From: Jani Nikula @ 2019-02-21 13:08 UTC (permalink / raw) To: Gerd Hoffmann, dri-devel Cc: daniel, Gerd Hoffmann, Maarten Lankhorst, Maxime Ripard, Sean Paul, David Airlie, Joonas Lahtinen, Rodrigo Vivi, open list, open list:INTEL DRM DRIVERS (excluding Poulsbo, Moorestow... On Thu, 21 Feb 2019, Gerd Hoffmann <kraxel@redhat.com> wrote: > 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 <kraxel@redhat.com> > --- > 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(-) > > diff --git a/include/drm/drm_fb_helper.h b/include/drm/drm_fb_helper.h > index bb9acea613..a401ba47ad 100644 > --- a/include/drm/drm_fb_helper.h > +++ b/include/drm/drm_fb_helper.h > @@ -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 > diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c > index 0e9349ff2d..a2d7e5bc51 100644 > --- a/drivers/gpu/drm/drm_fb_helper.c > +++ b/drivers/gpu/drm/drm_fb_helper.c > @@ -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 Please retain the original way of keeping conditional compilation outside of functions. BR, Jani. > + 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); > diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c > index 6630212f2f..3edd4d7d55 100644 > --- a/drivers/gpu/drm/i915/i915_drv.c > +++ b/drivers/gpu/drm/i915/i915_drv.c > @@ -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; -- Jani Nikula, Intel Open Source Graphics Center ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2 1/2] drm: move i915_kick_out_vgacon to drm_fb_helper 2019-02-21 13:08 ` [PATCH v2 1/2] drm: move i915_kick_out_vgacon to drm_fb_helper Jani Nikula @ 2019-02-21 13:25 ` Gerd Hoffmann 2019-02-21 14:41 ` Jani Nikula 0 siblings, 1 reply; 13+ messages in thread From: Gerd Hoffmann @ 2019-02-21 13:25 UTC (permalink / raw) To: Jani Nikula Cc: dri-devel, daniel, Maarten Lankhorst, Maxime Ripard, Sean Paul, David Airlie, Joonas Lahtinen, Rodrigo Vivi, open list, open list:INTEL DRM DRIVERS (excluding Poulsbo, Moorestow... On Thu, Feb 21, 2019 at 03:08:39PM +0200, Jani Nikula wrote: > On Thu, 21 Feb 2019, Gerd Hoffmann <kraxel@redhat.com> wrote: > > 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 <kraxel@redhat.com> > > --- > > 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(-) > > > > diff --git a/include/drm/drm_fb_helper.h b/include/drm/drm_fb_helper.h > > index bb9acea613..a401ba47ad 100644 > > --- a/include/drm/drm_fb_helper.h > > +++ b/include/drm/drm_fb_helper.h > > @@ -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 > > diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c > > index 0e9349ff2d..a2d7e5bc51 100644 > > --- a/drivers/gpu/drm/drm_fb_helper.c > > +++ b/drivers/gpu/drm/drm_fb_helper.c > > @@ -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 > > Please retain the original way of keeping conditional compilation > outside of functions. Care to explain why that is better? thanks, Gerd ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2 1/2] drm: move i915_kick_out_vgacon to drm_fb_helper 2019-02-21 13:25 ` Gerd Hoffmann @ 2019-02-21 14:41 ` Jani Nikula 0 siblings, 0 replies; 13+ messages in thread From: Jani Nikula @ 2019-02-21 14:41 UTC (permalink / raw) To: Gerd Hoffmann Cc: dri-devel, daniel, Maarten Lankhorst, Maxime Ripard, Sean Paul, David Airlie, Joonas Lahtinen, Rodrigo Vivi, open list, open list:INTEL DRM DRIVERS (excluding Poulsbo, Moorestow... On Thu, 21 Feb 2019, Gerd Hoffmann <kraxel@redhat.com> wrote: > On Thu, Feb 21, 2019 at 03:08:39PM +0200, Jani Nikula wrote: >> On Thu, 21 Feb 2019, Gerd Hoffmann <kraxel@redhat.com> wrote: >> > 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 <kraxel@redhat.com> >> > --- >> > 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(-) >> > >> > diff --git a/include/drm/drm_fb_helper.h b/include/drm/drm_fb_helper.h >> > index bb9acea613..a401ba47ad 100644 >> > --- a/include/drm/drm_fb_helper.h >> > +++ b/include/drm/drm_fb_helper.h >> > @@ -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 >> > diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c >> > index 0e9349ff2d..a2d7e5bc51 100644 >> > --- a/drivers/gpu/drm/drm_fb_helper.c >> > +++ b/drivers/gpu/drm/drm_fb_helper.c >> > @@ -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 >> >> Please retain the original way of keeping conditional compilation >> outside of functions. > > 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 -- Jani Nikula, Intel Open Source Graphics Center ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2 1/2] drm: move i915_kick_out_vgacon to drm_fb_helper [not found] ` <20190221113534.20764-2-kraxel@redhat.com> 2019-02-21 13:08 ` [PATCH v2 1/2] drm: move i915_kick_out_vgacon to drm_fb_helper Jani Nikula @ 2019-02-21 14:12 ` Noralf Trønnes 2019-02-21 15:09 ` Gerd Hoffmann 1 sibling, 1 reply; 13+ messages in thread From: Noralf Trønnes @ 2019-02-21 14:12 UTC (permalink / raw) To: Gerd Hoffmann, dri-devel Cc: Maxime Ripard, open list:INTEL DRM DRIVERS excluding Poulsbo, Moorestow..., open list, David Airlie, Rodrigo Vivi, Sean Paul Den 21.02.2019 12.35, skrev 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 <kraxel@redhat.com> > --- > 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(-) > > diff --git a/include/drm/drm_fb_helper.h b/include/drm/drm_fb_helper.h > index bb9acea613..a401ba47ad 100644 > --- a/include/drm/drm_fb_helper.h > +++ b/include/drm/drm_fb_helper.h > @@ -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. > #endif > diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c > index 0e9349ff2d..a2d7e5bc51 100644 > --- a/drivers/gpu/drm/drm_fb_helper.c > +++ b/drivers/gpu/drm/drm_fb_helper.c > @@ -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); > diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c > index 6630212f2f..3edd4d7d55 100644 > --- a/drivers/gpu/drm/i915/i915_drv.c > +++ b/drivers/gpu/drm/i915/i915_drv.c > @@ -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; > ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2 1/2] drm: move i915_kick_out_vgacon to drm_fb_helper 2019-02-21 14:12 ` Noralf Trønnes @ 2019-02-21 15:09 ` Gerd Hoffmann 2019-02-21 15:51 ` Daniel Vetter 0 siblings, 1 reply; 13+ messages in thread From: Gerd Hoffmann @ 2019-02-21 15:09 UTC (permalink / raw) To: Noralf Trønnes Cc: dri-devel, Maxime Ripard, open list:INTEL DRM DRIVERS excluding Poulsbo, Moorestow..., open list, David Airlie, Rodrigo Vivi, Sean Paul > > +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? 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 ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2 1/2] drm: move i915_kick_out_vgacon to drm_fb_helper 2019-02-21 15:09 ` Gerd Hoffmann @ 2019-02-21 15:51 ` Daniel Vetter 0 siblings, 0 replies; 13+ messages in thread From: Daniel Vetter @ 2019-02-21 15:51 UTC (permalink / raw) To: Gerd Hoffmann Cc: Noralf Trønnes, Maxime Ripard, open list:INTEL DRM DRIVERS excluding Poulsbo, Moorestow..., open list, dri-devel, David Airlie, Rodrigo Vivi, Sean Paul On Thu, Feb 21, 2019 at 04:09:12PM +0100, Gerd Hoffmann wrote: > > > +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? > > 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 -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch ^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2019-02-22 7:14 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20190221113534.20764-1-kraxel@redhat.com>
2019-02-21 11:35 ` [PATCH v2 2/2] drm/qxl: kick out vgacon Gerd Hoffmann
2019-02-21 12:20 ` Daniel Vetter
2019-02-21 13:06 ` Gerd Hoffmann
2019-02-21 14:24 ` Daniel Vetter
2019-02-21 15:11 ` Gerd Hoffmann
2019-02-21 15:17 ` Daniel Vetter
2019-02-22 7:14 ` Gerd Hoffmann
[not found] ` <20190221113534.20764-2-kraxel@redhat.com>
2019-02-21 13:08 ` [PATCH v2 1/2] drm: move i915_kick_out_vgacon to drm_fb_helper Jani Nikula
2019-02-21 13:25 ` Gerd Hoffmann
2019-02-21 14:41 ` Jani Nikula
2019-02-21 14:12 ` Noralf Trønnes
2019-02-21 15:09 ` Gerd Hoffmann
2019-02-21 15:51 ` Daniel Vetter
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox