diff mbox

[3/5] tty/vt: add con_bind and con_unbind functions

Message ID 1380236762-1698-4-git-send-email-przanoni@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Paulo Zanoni Sept. 26, 2013, 11:06 p.m. UTC
From: Paulo Zanoni <paulo.r.zanoni@intel.com>

The consoles who need to do something when unbinding or binding can
optionally implement these functions.

The current problem I'm trying to solve is that when i915+fbcon is
loaded on Haswell, if we disable the power well (to save power) the
VGA interface gets completely disabled, so when we unbind fbcon we
need to restore the VGA interface to allow vgacon to work.

Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
---
 drivers/tty/vt/vt.c     | 6 ++++++
 include/linux/console.h | 2 ++
 2 files changed, 8 insertions(+)

Comments

Ville Syrjälä Oct. 1, 2013, 1:50 p.m. UTC | #1
On Thu, Sep 26, 2013 at 08:06:00PM -0300, Paulo Zanoni wrote:
> From: Paulo Zanoni <paulo.r.zanoni@intel.com>
> 
> The consoles who need to do something when unbinding or binding can
> optionally implement these functions.
> 
> The current problem I'm trying to solve is that when i915+fbcon is
> loaded on Haswell, if we disable the power well (to save power) the
> VGA interface gets completely disabled, so when we unbind fbcon we
> need to restore the VGA interface to allow vgacon to work.

We don't need to make it work. No one else does, and in the general case
it's even impossible since on some hardware that would definitely
corrupt the state that the real driver is attempting to use. The only
case where it might be nice to restore vgacon is on i915 unload, but no
one else does that either AFAIK, so I would not waste any cycles on
attempting that.

> 
> Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
> ---
>  drivers/tty/vt/vt.c     | 6 ++++++
>  include/linux/console.h | 2 ++
>  2 files changed, 8 insertions(+)
> 
> diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
> index 9a8e8c5..beb5986 100644
> --- a/drivers/tty/vt/vt.c
> +++ b/drivers/tty/vt/vt.c
> @@ -3014,6 +3014,9 @@ static int do_bind_con_driver(const struct consw *csw, int first, int last,
>  	if (retval)
>  		goto err;
>  
> +	if (csw->con_bind)
> +		csw->con_bind();
> +
>  	if (!(con_driver->flag & CON_DRIVER_FLAG_INIT)) {
>  		csw->con_startup();
>  		con_driver->flag |= CON_DRIVER_FLAG_INIT;
> @@ -3152,6 +3155,9 @@ int do_unbind_con_driver(const struct consw *csw, int first, int last, int deflt
>  	if (!con_is_bound(csw))
>  		goto err;
>  
> +	if (csw->con_unbind)
> +		csw->con_unbind();
> +
>  	first = max(first, con_driver->first);
>  	last = min(last, con_driver->last);
>  
> diff --git a/include/linux/console.h b/include/linux/console.h
> index 7571a16..5cd2c35 100644
> --- a/include/linux/console.h
> +++ b/include/linux/console.h
> @@ -65,6 +65,8 @@ struct consw {
>  	 * Restore the console to its pre-debug state as closely as possible.
>  	 */
>  	int	(*con_debug_leave)(struct vc_data *);
> +	void	(*con_bind)(void);
> +	void	(*con_unbind)(void);
>  };
>  
>  extern const struct consw *conswitchp;
> -- 
> 1.8.3.1
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel
Paulo Zanoni Oct. 8, 2013, 9:12 p.m. UTC | #2
2013/10/1 Ville Syrjälä <ville.syrjala@linux.intel.com>:
> On Thu, Sep 26, 2013 at 08:06:00PM -0300, Paulo Zanoni wrote:
>> From: Paulo Zanoni <paulo.r.zanoni@intel.com>
>>
>> The consoles who need to do something when unbinding or binding can
>> optionally implement these functions.
>>
>> The current problem I'm trying to solve is that when i915+fbcon is
>> loaded on Haswell, if we disable the power well (to save power) the
>> VGA interface gets completely disabled, so when we unbind fbcon we
>> need to restore the VGA interface to allow vgacon to work.
>
> We don't need to make it work. No one else does, and in the general case
> it's even impossible since on some hardware that would definitely
> corrupt the state that the real driver is attempting to use. The only
> case where it might be nice to restore vgacon is on i915 unload, but no
> one else does that either AFAIK, so I would not waste any cycles on
> attempting that.

I don't understand your point. Without patches 3-4-5, module_reload
doesn't work at all if the power well is disabled: we need these
patches to fix it. The plan is not to restore everything to make
vgacon actually work, the plan is just to prevent it from breaking
module_reload.


>
>>
>> Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
>> ---
>>  drivers/tty/vt/vt.c     | 6 ++++++
>>  include/linux/console.h | 2 ++
>>  2 files changed, 8 insertions(+)
>>
>> diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
>> index 9a8e8c5..beb5986 100644
>> --- a/drivers/tty/vt/vt.c
>> +++ b/drivers/tty/vt/vt.c
>> @@ -3014,6 +3014,9 @@ static int do_bind_con_driver(const struct consw *csw, int first, int last,
>>       if (retval)
>>               goto err;
>>
>> +     if (csw->con_bind)
>> +             csw->con_bind();
>> +
>>       if (!(con_driver->flag & CON_DRIVER_FLAG_INIT)) {
>>               csw->con_startup();
>>               con_driver->flag |= CON_DRIVER_FLAG_INIT;
>> @@ -3152,6 +3155,9 @@ int do_unbind_con_driver(const struct consw *csw, int first, int last, int deflt
>>       if (!con_is_bound(csw))
>>               goto err;
>>
>> +     if (csw->con_unbind)
>> +             csw->con_unbind();
>> +
>>       first = max(first, con_driver->first);
>>       last = min(last, con_driver->last);
>>
>> diff --git a/include/linux/console.h b/include/linux/console.h
>> index 7571a16..5cd2c35 100644
>> --- a/include/linux/console.h
>> +++ b/include/linux/console.h
>> @@ -65,6 +65,8 @@ struct consw {
>>        * Restore the console to its pre-debug state as closely as possible.
>>        */
>>       int     (*con_debug_leave)(struct vc_data *);
>> +     void    (*con_bind)(void);
>> +     void    (*con_unbind)(void);
>>  };
>>
>>  extern const struct consw *conswitchp;
>> --
>> 1.8.3.1
>>
>> _______________________________________________
>> dri-devel mailing list
>> dri-devel@lists.freedesktop.org
>> http://lists.freedesktop.org/mailman/listinfo/dri-devel
>
> --
> Ville Syrjälä
> Intel OTC
Ville Syrjälä Oct. 9, 2013, 8:10 a.m. UTC | #3
On Tue, Oct 08, 2013 at 06:12:15PM -0300, Paulo Zanoni wrote:
> 2013/10/1 Ville Syrjälä <ville.syrjala@linux.intel.com>:
> > On Thu, Sep 26, 2013 at 08:06:00PM -0300, Paulo Zanoni wrote:
> >> From: Paulo Zanoni <paulo.r.zanoni@intel.com>
> >>
> >> The consoles who need to do something when unbinding or binding can
> >> optionally implement these functions.
> >>
> >> The current problem I'm trying to solve is that when i915+fbcon is
> >> loaded on Haswell, if we disable the power well (to save power) the
> >> VGA interface gets completely disabled, so when we unbind fbcon we
> >> need to restore the VGA interface to allow vgacon to work.
> >
> > We don't need to make it work. No one else does, and in the general case
> > it's even impossible since on some hardware that would definitely
> > corrupt the state that the real driver is attempting to use. The only
> > case where it might be nice to restore vgacon is on i915 unload, but no
> > one else does that either AFAIK, so I would not waste any cycles on
> > attempting that.
> 
> I don't understand your point. Without patches 3-4-5, module_reload
> doesn't work at all if the power well is disabled: we need these
> patches to fix it. The plan is not to restore everything to make
> vgacon actually work, the plan is just to prevent it from breaking
> module_reload.

How does the power well vs. vgacon break module_reload?

BTW module_reload seems to be busted on ILK and IVB too currently.
diff mbox

Patch

diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
index 9a8e8c5..beb5986 100644
--- a/drivers/tty/vt/vt.c
+++ b/drivers/tty/vt/vt.c
@@ -3014,6 +3014,9 @@  static int do_bind_con_driver(const struct consw *csw, int first, int last,
 	if (retval)
 		goto err;
 
+	if (csw->con_bind)
+		csw->con_bind();
+
 	if (!(con_driver->flag & CON_DRIVER_FLAG_INIT)) {
 		csw->con_startup();
 		con_driver->flag |= CON_DRIVER_FLAG_INIT;
@@ -3152,6 +3155,9 @@  int do_unbind_con_driver(const struct consw *csw, int first, int last, int deflt
 	if (!con_is_bound(csw))
 		goto err;
 
+	if (csw->con_unbind)
+		csw->con_unbind();
+
 	first = max(first, con_driver->first);
 	last = min(last, con_driver->last);
 
diff --git a/include/linux/console.h b/include/linux/console.h
index 7571a16..5cd2c35 100644
--- a/include/linux/console.h
+++ b/include/linux/console.h
@@ -65,6 +65,8 @@  struct consw {
 	 * Restore the console to its pre-debug state as closely as possible.
 	 */
 	int	(*con_debug_leave)(struct vc_data *);
+	void	(*con_bind)(void);
+	void	(*con_unbind)(void);
 };
 
 extern const struct consw *conswitchp;