2019-02-21 14:13:30

by Noralf Trønnes

[permalink] [raw]
Subject: Re: [PATCH v2 1/2] drm: move i915_kick_out_vgacon to drm_fb_helper



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 <[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(-)
>
> 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;
>


2019-02-21 15:10:09

by Gerd Hoffmann

[permalink] [raw]
Subject: Re: [PATCH v2 1/2] drm: move i915_kick_out_vgacon to drm_fb_helper

> > +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


2019-02-21 15:52:37

by Daniel Vetter

[permalink] [raw]
Subject: Re: [PATCH v2 1/2] drm: move i915_kick_out_vgacon to drm_fb_helper

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