From: Jani Nikula <jani.nikula@linux.intel.com>
To: David Herrmann <dh.herrmann@gmail.com>,
Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: "linux-fbdev@vger.kernel.org" <linux-fbdev@vger.kernel.org>,
Tomi Valkeinen <tomi.valkeinen@ti.com>,
Jean-Christophe Plagniol-Villard <plagnioj@jcrosoft.com>,
Intel Graphics Development <intel-gfx@lists.freedesktop.org>,
DRI Development <dri-devel@lists.freedesktop.org>
Subject: Re: [PATCH] drm/i915: Kick out vga console
Date: Wed, 04 Jun 2014 12:20:09 +0000 [thread overview]
Message-ID: <87sinkeuiu.fsf@intel.com> (raw)
In-Reply-To: <CANq1E4Qxpu7UecPHxdu_VzU=kADR_hijFXxd48ag_rbx7jo8mg@mail.gmail.com>
On Wed, 04 Jun 2014, David Herrmann <dh.herrmann@gmail.com> wrote:
> Hi
>
> On Wed, Jun 4, 2014 at 12:57 AM, Daniel Vetter <daniel.vetter@ffwll.ch> wrote:
>> From: Chris Wilson <chris@chris-wilson.co.uk>
>>
>> Touching the VGA resources on an IVB EFI machine causes hard hangs when
>> we then kick out the efifb. Ouch.
>>
>> Apparently this also prevents unclaimed register errors on hsw and
>> hard machine hangs on my i855gm when trying to unbind fbcon.
>>
>> Also, we want this to make I915_FBDEV=n safe.
>>
>> v2: Rebase and pimp commit message.
>>
>> v3: We also need to unregister the vga console, otherwise the unbind
>> of the fb console before module unload might resurrect it again.
>>
>> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?idg813
>> Cc: David Herrmann <dh.herrmann@gmail.com>
>> Cc: Jean-Christophe Plagniol-Villard <plagnioj@jcrosoft.com>
>> Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
>> Cc: linux-fbdev@vger.kernel.org
>> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> (v1)
>> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
>> ---
>> drivers/gpu/drm/i915/i915_dma.c | 34 +++++++++++++++++++++++++++++++++-
>> drivers/video/console/dummycon.c | 1 +
>> drivers/video/console/vgacon.c | 1 +
>> 3 files changed, 35 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
>> index b9159ade5e85..a4df80740b37 100644
>> --- a/drivers/gpu/drm/i915/i915_dma.c
>> +++ b/drivers/gpu/drm/i915/i915_dma.c
>> @@ -36,6 +36,8 @@
>> #include "i915_drv.h"
>> #include "i915_trace.h"
>> #include <linux/pci.h>
>> +#include <linux/console.h>
>> +#include <linux/vt.h>
>> #include <linux/vgaarb.h>
>> #include <linux/acpi.h>
>> #include <linux/pnp.h>
>> @@ -1450,6 +1452,29 @@ static void i915_kick_out_firmware_fb(struct drm_i915_private *dev_priv)
>> }
>> #endif
>>
>> +static int i915_kick_out_vgacon(struct drm_i915_private *dev_priv)
>> +{
>> +#if !defined(CONFIG_VGA_CONSOLE)
>> + return 0;
>> +#else
>> + int ret;
>> +
>> +#if !defined(CONFIG_DUMMY_CONSOLE)
>> + return -ENODEV;
>> +#endif
>> +
>> + DRM_INFO("Replacing VGA console driver\n");
>> +
>> + console_lock();
>> + ret = do_take_over_console(&dummy_con, 0, MAX_NR_CONSOLES - 1, 1);
>
> You rely on compiler-optimizations here. "dummy_con" is not available
> if !CONFIG_DUMMY_CONSOLE, but you use it. This causes linker-failure
> if dead-code elimination is not done (-O0).
Nested #ifs too. How about
#if !defined(CONFIG_VGA_CONSOLE)
static inline int i915_kick_out_vgacon(struct drm_i915_private *dev_priv)
{
return 0;
}
#elif !defined(CONFIG_DUMMY_CONSOLE)
static inline 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)
{
/* ... */
}
#endif
in proper kernel style?
BR,
Jani.
>
> Thanks
> David
>
>> + if (ret = 0)
>> + ret = do_unregister_con_driver(&vga_con);
>> + console_unlock();
>> +
>> + return ret;
>> +#endif
>> +}
>> +
>> static void i915_dump_device_info(struct drm_i915_private *dev_priv)
>> {
>> const struct intel_device_info *info = &dev_priv->info;
>> @@ -1623,8 +1648,15 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags)
>> if (ret)
>> goto out_regs;
>>
>> - if (drm_core_check_feature(dev, DRIVER_MODESET))
>> + if (drm_core_check_feature(dev, DRIVER_MODESET)) {
>> + ret = i915_kick_out_vgacon(dev_priv);
>> + if (ret) {
>> + DRM_ERROR("failed to remove conflicting VGA console\n");
>> + goto out_gtt;
>> + }
>> +
>> i915_kick_out_firmware_fb(dev_priv);
>> + }
>>
>> pci_set_master(dev->pdev);
>>
>> diff --git a/drivers/video/console/dummycon.c b/drivers/video/console/dummycon.c
>> index b63860f7beab..40bec8d64b0a 100644
>> --- a/drivers/video/console/dummycon.c
>> +++ b/drivers/video/console/dummycon.c
>> @@ -77,3 +77,4 @@ const struct consw dummy_con = {
>> .con_set_palette = DUMMY,
>> .con_scrolldelta = DUMMY,
>> };
>> +EXPORT_SYMBOL_GPL(dummy_con);
>> diff --git a/drivers/video/console/vgacon.c b/drivers/video/console/vgacon.c
>> index 9d8feac67637..84acd6223dc5 100644
>> --- a/drivers/video/console/vgacon.c
>> +++ b/drivers/video/console/vgacon.c
>> @@ -1440,5 +1440,6 @@ const struct consw vga_con = {
>> .con_build_attr = vgacon_build_attr,
>> .con_invert_region = vgacon_invert_region,
>> };
>> +EXPORT_SYMBOL(vga_con);
>>
>> MODULE_LICENSE("GPL");
>> --
>> 1.8.1.4
>>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel
--
Jani Nikula, Intel Open Source Technology Center
WARNING: multiple messages have this Message-ID (diff)
From: Jani Nikula <jani.nikula@linux.intel.com>
To: David Herrmann <dh.herrmann@gmail.com>,
Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: "linux-fbdev@vger.kernel.org" <linux-fbdev@vger.kernel.org>,
Tomi Valkeinen <tomi.valkeinen@ti.com>,
Jean-Christophe Plagniol-Villard <plagnioj@jcrosoft.com>,
Intel Graphics Development <intel-gfx@lists.freedesktop.org>,
DRI Development <dri-devel@lists.freedesktop.org>
Subject: Re: [PATCH] drm/i915: Kick out vga console
Date: Wed, 04 Jun 2014 15:20:09 +0300 [thread overview]
Message-ID: <87sinkeuiu.fsf@intel.com> (raw)
In-Reply-To: <CANq1E4Qxpu7UecPHxdu_VzU=kADR_hijFXxd48ag_rbx7jo8mg@mail.gmail.com>
On Wed, 04 Jun 2014, David Herrmann <dh.herrmann@gmail.com> wrote:
> Hi
>
> On Wed, Jun 4, 2014 at 12:57 AM, Daniel Vetter <daniel.vetter@ffwll.ch> wrote:
>> From: Chris Wilson <chris@chris-wilson.co.uk>
>>
>> Touching the VGA resources on an IVB EFI machine causes hard hangs when
>> we then kick out the efifb. Ouch.
>>
>> Apparently this also prevents unclaimed register errors on hsw and
>> hard machine hangs on my i855gm when trying to unbind fbcon.
>>
>> Also, we want this to make I915_FBDEV=n safe.
>>
>> v2: Rebase and pimp commit message.
>>
>> v3: We also need to unregister the vga console, otherwise the unbind
>> of the fb console before module unload might resurrect it again.
>>
>> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=67813
>> Cc: David Herrmann <dh.herrmann@gmail.com>
>> Cc: Jean-Christophe Plagniol-Villard <plagnioj@jcrosoft.com>
>> Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
>> Cc: linux-fbdev@vger.kernel.org
>> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> (v1)
>> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
>> ---
>> drivers/gpu/drm/i915/i915_dma.c | 34 +++++++++++++++++++++++++++++++++-
>> drivers/video/console/dummycon.c | 1 +
>> drivers/video/console/vgacon.c | 1 +
>> 3 files changed, 35 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
>> index b9159ade5e85..a4df80740b37 100644
>> --- a/drivers/gpu/drm/i915/i915_dma.c
>> +++ b/drivers/gpu/drm/i915/i915_dma.c
>> @@ -36,6 +36,8 @@
>> #include "i915_drv.h"
>> #include "i915_trace.h"
>> #include <linux/pci.h>
>> +#include <linux/console.h>
>> +#include <linux/vt.h>
>> #include <linux/vgaarb.h>
>> #include <linux/acpi.h>
>> #include <linux/pnp.h>
>> @@ -1450,6 +1452,29 @@ static void i915_kick_out_firmware_fb(struct drm_i915_private *dev_priv)
>> }
>> #endif
>>
>> +static int i915_kick_out_vgacon(struct drm_i915_private *dev_priv)
>> +{
>> +#if !defined(CONFIG_VGA_CONSOLE)
>> + return 0;
>> +#else
>> + int ret;
>> +
>> +#if !defined(CONFIG_DUMMY_CONSOLE)
>> + return -ENODEV;
>> +#endif
>> +
>> + DRM_INFO("Replacing VGA console driver\n");
>> +
>> + console_lock();
>> + ret = do_take_over_console(&dummy_con, 0, MAX_NR_CONSOLES - 1, 1);
>
> You rely on compiler-optimizations here. "dummy_con" is not available
> if !CONFIG_DUMMY_CONSOLE, but you use it. This causes linker-failure
> if dead-code elimination is not done (-O0).
Nested #ifs too. How about
#if !defined(CONFIG_VGA_CONSOLE)
static inline int i915_kick_out_vgacon(struct drm_i915_private *dev_priv)
{
return 0;
}
#elif !defined(CONFIG_DUMMY_CONSOLE)
static inline 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)
{
/* ... */
}
#endif
in proper kernel style?
BR,
Jani.
>
> Thanks
> David
>
>> + if (ret == 0)
>> + ret = do_unregister_con_driver(&vga_con);
>> + console_unlock();
>> +
>> + return ret;
>> +#endif
>> +}
>> +
>> static void i915_dump_device_info(struct drm_i915_private *dev_priv)
>> {
>> const struct intel_device_info *info = &dev_priv->info;
>> @@ -1623,8 +1648,15 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags)
>> if (ret)
>> goto out_regs;
>>
>> - if (drm_core_check_feature(dev, DRIVER_MODESET))
>> + if (drm_core_check_feature(dev, DRIVER_MODESET)) {
>> + ret = i915_kick_out_vgacon(dev_priv);
>> + if (ret) {
>> + DRM_ERROR("failed to remove conflicting VGA console\n");
>> + goto out_gtt;
>> + }
>> +
>> i915_kick_out_firmware_fb(dev_priv);
>> + }
>>
>> pci_set_master(dev->pdev);
>>
>> diff --git a/drivers/video/console/dummycon.c b/drivers/video/console/dummycon.c
>> index b63860f7beab..40bec8d64b0a 100644
>> --- a/drivers/video/console/dummycon.c
>> +++ b/drivers/video/console/dummycon.c
>> @@ -77,3 +77,4 @@ const struct consw dummy_con = {
>> .con_set_palette = DUMMY,
>> .con_scrolldelta = DUMMY,
>> };
>> +EXPORT_SYMBOL_GPL(dummy_con);
>> diff --git a/drivers/video/console/vgacon.c b/drivers/video/console/vgacon.c
>> index 9d8feac67637..84acd6223dc5 100644
>> --- a/drivers/video/console/vgacon.c
>> +++ b/drivers/video/console/vgacon.c
>> @@ -1440,5 +1440,6 @@ const struct consw vga_con = {
>> .con_build_attr = vgacon_build_attr,
>> .con_invert_region = vgacon_invert_region,
>> };
>> +EXPORT_SYMBOL(vga_con);
>>
>> MODULE_LICENSE("GPL");
>> --
>> 1.8.1.4
>>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel
--
Jani Nikula, Intel Open Source Technology Center
next prev parent reply other threads:[~2014-06-04 12:20 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-03 22:57 [PATCH] drm/i915: Kick out vga console Daniel Vetter
2014-06-03 22:57 ` Daniel Vetter
2014-06-04 9:38 ` David Herrmann
2014-06-04 9:38 ` David Herrmann
2014-06-04 12:20 ` Jani Nikula [this message]
2014-06-04 12:20 ` Jani Nikula
2014-06-04 13:18 ` David Herrmann
2014-06-04 13:18 ` David Herrmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87sinkeuiu.fsf@intel.com \
--to=jani.nikula@linux.intel.com \
--cc=daniel.vetter@ffwll.ch \
--cc=dh.herrmann@gmail.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=linux-fbdev@vger.kernel.org \
--cc=plagnioj@jcrosoft.com \
--cc=tomi.valkeinen@ti.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.