Re: [PATCH v2 15/20] s390: perf/events: advertise PMU exclusion capability

2018-11-27 Thread Hendrik Brueckner
On Mon, Nov 26, 2018 at 11:12:31AM +, Andrew Murray wrote:
> The s390 cpum_cf and cpum_sf PMUs have the capability to exclude
> events based on context. Let's advertise that we support the
> PERF_PMU_CAP_EXCLUDE capability to ensure that perf doesn't
> prevent us from handling events where any exclusion flags are set.
> 
> Signed-off-by: Andrew Murray 
> ---
>  arch/s390/kernel/perf_cpum_cf.c | 1 +
>  arch/s390/kernel/perf_cpum_sf.c | 2 ++
>  2 files changed, 3 insertions(+)

Reviewed-by: Hendrik Brueckner 



Re: [PATCH 1/2] tty/hvc_console: Add DTR/RTS callback to handle HUPCL control

2013-10-17 Thread Hendrik Brueckner
On Wed, Oct 16, 2013 at 06:21:12PM -0500, Benjamin Herrenschmidt wrote:
> On Wed, 2013-10-16 at 11:04 +0200, Hendrik Brueckner wrote:
> > Indeed, two callbacks change the DTR line.  The main difference is that
> > tiocmget/tiocmset can be called from user space by ioctl.  That's not the 
> > case
> > for the dtr_cts callback.  Also, tiocmget/tiocmset provide more flags that 
> > can
> > be changed (ST, SR, CTS, CD, RNG, RI,  ...)
> > 
> > Assume we would like to unify them have a single callback to change DTR, 
> > then
> > we have to take care of these differences.  So the question to you now is
> > whether you plan for a) other modem flags to be changed and b) if changing 
> > the
> > DTR line (or other control flags) through an ioctl?
> > 
> > Depending on your results, I could work on sth that helps us both and 
> > reduces
> > the callbacks.
> 
> Can we not just have the users of dtr_cts just call the backend's tiocmset ?

That's possible.  The only concern is that the tiocmset() callback could be
triggered from within the hvc_console() layer as well as from user space via
ioctl.  For the hvc_iucv driver, I do not want to introduce this ioctl.

One option would be to add parameter to the hvc_callbacks that indicate the
origin so that a backend could filter.

> If they need to filter or clamp bits, we could handle all that in hvc_console
> by caching the user intended value and passing a cooked value down to the 
> backend..

Sure the hvc_console layer could do as much as possible.

> 
> None of that is urgent or anything, it's just odd and would be nice to 
> cleanup.

Thanks and kind regards,
  Hendrik

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [PATCH 1/2] tty/hvc_console: Add DTR/RTS callback to handle HUPCL control

2013-10-16 Thread Hendrik Brueckner
On Tue, Oct 15, 2013 at 03:47:50PM -0500, Benjamin Herrenschmidt wrote:
> On Tue, 2013-10-15 at 17:36 +0200, Hendrik Brueckner wrote:
> > On Sat, Oct 12, 2013 at 07:43:24AM +1100, Benjamin Herrenschmidt wrote:
> > > On Fri, 2013-10-11 at 14:47 +0200, Hendrik Brueckner wrote:
> > > > The tiocmget/tiocmset callbacks are used to set and get modem status and
> > > > triggered through an tty ioctl.
> > > > 
> > > > The dtr_rts() callback is different and it is used for DTS/RTS 
> > > > handshaking
> > > > between the hvc_console (or any other tty_port) and the tty layer.  The 
> > > > tty
> > > > port layer uses this callback to signal the hvc_console whether to 
> > > > raise or
> > > > lower the DTR/RTS lines.  This is different than the ioctl interface to
> > > > controls the modem status.
> > > 
> > > Well, DTR at least is the same via both callbacks... Also normal 
> > > handshaking
> > > is normally RTS/CTS, only some HW setups "hijacks" DTR for RTS (old Macs 
> > > come
> > > to mind).
> > 
> > Yep. DTR is changed in both callbacks but from different layers.  The
> > tiocmget/tiocmset are triggered through the ioctl.  The dtr_rts() callback 
> > is
> > called in hvc_close() to properly handle HUPCL to lower modem control lines
> > after last process closes the device (hang up).
> > 
> > This is also done in the hvsilib_close() in hvsi_lib.c:
> > 
> > /* Clear our own DTR */
> > if (!pv->tty || (pv->tty->termios.c_cflag & HUPCL))
> > hvsilib_write_mctrl(pv, 0); 
> > 
> > This is actually what the dtr_rts() callback should trigger and I wonder
> > whether it would be worth to introduce the dtr_rts() callback to encapsulate
> > the "hvsilib_write_mctrl(pv, 0);" call from above.
> > 
> > On the other hand, the dtr_rts() callback is a good encapsulation to not
> > directly access the hp->tty to potentially prevent a layering violation. At
> > least for the hvc_iucv() I do not want to deal with the "underlying" tty 
> > layer
> > and introduce additional reference accounting.
> > 
> > I hope this helps you to understand my rational for introducing the 
> > dtr_rts()
> > callback.
> 
> I'm not sure :) We still end up basically with 2 callbacks to do the
> same thing ... change the DTR line. It's odd at best, I still don't
> quite see why hvc_console couldn't just use mctrl...
> 
Indeed, two callbacks change the DTR line.  The main difference is that
tiocmget/tiocmset can be called from user space by ioctl.  That's not the case
for the dtr_cts callback.  Also, tiocmget/tiocmset provide more flags that can
be changed (ST, SR, CTS, CD, RNG, RI,  ...)

Assume we would like to unify them have a single callback to change DTR, then
we have to take care of these differences.  So the question to you now is
whether you plan for a) other modem flags to be changed and b) if changing the
DTR line (or other control flags) through an ioctl?

Depending on your results, I could work on sth that helps us both and reduces
the callbacks.

Thanks and kind regards,
  Hendrik

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [PATCH 1/2] tty/hvc_console: Add DTR/RTS callback to handle HUPCL control

2013-10-15 Thread Hendrik Brueckner
Hi Benjamin,

On Sat, Oct 12, 2013 at 07:43:24AM +1100, Benjamin Herrenschmidt wrote:
> On Fri, 2013-10-11 at 14:47 +0200, Hendrik Brueckner wrote:
> > The tiocmget/tiocmset callbacks are used to set and get modem status and
> > triggered through an tty ioctl.
> > 
> > The dtr_rts() callback is different and it is used for DTS/RTS handshaking
> > between the hvc_console (or any other tty_port) and the tty layer.  The tty
> > port layer uses this callback to signal the hvc_console whether to raise or
> > lower the DTR/RTS lines.  This is different than the ioctl interface to
> > controls the modem status.
> 
> Well, DTR at least is the same via both callbacks... Also normal handshaking
> is normally RTS/CTS, only some HW setups "hijacks" DTR for RTS (old Macs come
> to mind).

Yep. DTR is changed in both callbacks but from different layers.  The
tiocmget/tiocmset are triggered through the ioctl.  The dtr_rts() callback is
called in hvc_close() to properly handle HUPCL to lower modem control lines
after last process closes the device (hang up).

This is also done in the hvsilib_close() in hvsi_lib.c:

/* Clear our own DTR */
if (!pv->tty || (pv->tty->termios.c_cflag & HUPCL))
hvsilib_write_mctrl(pv, 0); 

This is actually what the dtr_rts() callback should trigger and I wonder
whether it would be worth to introduce the dtr_rts() callback to encapsulate
the "hvsilib_write_mctrl(pv, 0);" call from above.

On the other hand, the dtr_rts() callback is a good encapsulation to not
directly access the hp->tty to potentially prevent a layering violation. At
least for the hvc_iucv() I do not want to deal with the "underlying" tty layer
and introduce additional reference accounting.

I hope this helps you to understand my rational for introducing the dtr_rts()
callback.

Thanks and kind regards,
  Hendrik

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [PATCH 1/2] tty/hvc_console: Add DTR/RTS callback to handle HUPCL control

2013-10-11 Thread Hendrik Brueckner
Hi Benjamin,

On Fri, Oct 11, 2013 at 06:15:11PM +1100, Benjamin Herrenschmidt wrote:
> On Tue, 2013-07-02 at 17:07 +0200, Hendrik Brueckner wrote:
> > Introduce a new callback to explicitly handle the HUPCL termios control 
> > flag.
> > This prepares for a follow-up commit for the hvc_iucv device driver to
> > improve handling when to drop an established network connection.
> > 
> > The callback naming is based on the recently added tty_port interface to
> > facilitate a potential refactoring of the hvc_console to use tty_port
> > functions.
> 
> I only just noticed that ... oops. Why add those dtr_rts() calls ? We
> already have tiocmset in there which is used to set DTR on HVSI consoles
> such as hvc_opal when using hvsi_lib...
> 
> Any reason why a separate callback was needed ?

The tiocmget/tiocmset callbacks are used to set and get modem status and
triggered through an tty ioctl.

The dtr_rts() callback is different and it is used for DTS/RTS handshaking
between the hvc_console (or any other tty_port) and the tty layer.  The tty
port layer uses this callback to signal the hvc_console whether to raise or
lower the DTR/RTS lines.  This is different than the ioctl interface to
controls the modem status.

Thanks and kind regards,
  Hendrik

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


[PATCH 2/2] tty/hvc_iucv: Disconnect IUCV connection when lowering DTR

2013-07-02 Thread Hendrik Brueckner
Implement the dtr_rts() hvc console callback to improve control when to
disconnect the IUCV connection.  Previously, the IUCV connection was
disconnected during the notifier_del() callback, i.e., when the last file
descriptor to the hvc terminal device was closed.

Recent changes in login programs caused undesired disconnects during the
login phase.  To prevent these kind of disconnects, implement the dtr_rts
callback to implicitly handle the HUPCL termios control via the hvc_console
driver.

Signed-off-by: Hendrik Brueckner 
---
 drivers/tty/hvc/hvc_iucv.c |   64 +++-
 1 files changed, 51 insertions(+), 13 deletions(-)

diff --git a/drivers/tty/hvc/hvc_iucv.c b/drivers/tty/hvc/hvc_iucv.c
index b6f7d52..bb08676 100644
--- a/drivers/tty/hvc/hvc_iucv.c
+++ b/drivers/tty/hvc/hvc_iucv.c
@@ -656,21 +656,64 @@ static void hvc_iucv_notifier_hangup(struct hvc_struct 
*hp, int id)
 }
 
 /**
+ * hvc_iucv_dtr_rts() - HVC notifier for handling DTR/RTS
+ * @hp:Pointer the HVC device (struct hvc_struct)
+ * @raise: Non-zero to raise or zero to lower DTR/RTS lines
+ *
+ * This routine notifies the HVC back-end to raise or lower DTR/RTS
+ * lines.  Raising DTR/RTS is ignored.  Lowering DTR/RTS indicates to
+ * drop the IUCV connection (similar to hang up the modem).
+ */
+static void hvc_iucv_dtr_rts(struct hvc_struct *hp, int raise)
+{
+   struct hvc_iucv_private *priv;
+   struct iucv_path*path;
+
+   /* Raising the DTR/RTS is ignored as IUCV connections can be
+* established at any times.
+*/
+   if (raise)
+   return;
+
+   priv = hvc_iucv_get_private(hp->vtermno);
+   if (!priv)
+   return;
+
+   /* Lowering the DTR/RTS lines disconnects an established IUCV
+* connection.
+*/
+   flush_sndbuf_sync(priv);
+
+   spin_lock_bh(&priv->lock);
+   path = priv->path;  /* save reference to IUCV path */
+   priv->path = NULL;
+   priv->iucv_state = IUCV_DISCONN;
+   spin_unlock_bh(&priv->lock);
+
+   /* Sever IUCV path outside of priv->lock due to lock ordering of:
+* priv->lock <--> iucv_table_lock */
+   if (path) {
+   iucv_path_sever(path, NULL);
+   iucv_path_free(path);
+   }
+}
+
+/**
  * hvc_iucv_notifier_del() - HVC notifier for closing a TTY for the last time.
  * @hp:Pointer to the HVC device (struct hvc_struct)
  * @id:Additional data (originally passed to hvc_alloc):
  * the index of an struct hvc_iucv_private instance.
  *
  * This routine notifies the HVC back-end that the last tty device fd has been
- * closed.  The function calls hvc_iucv_cleanup() to clean up the struct
- * hvc_iucv_private instance.
+ * closed.  The function cleans up tty resources.  The clean-up of the IUCV
+ * connection is done in hvc_iucv_dtr_rts() and depends on the HUPCL termios
+ * control setting.
  *
  * Locking:struct hvc_iucv_private->lock
  */
 static void hvc_iucv_notifier_del(struct hvc_struct *hp, int id)
 {
struct hvc_iucv_private *priv;
-   struct iucv_path*path;
 
priv = hvc_iucv_get_private(id);
if (!priv)
@@ -679,17 +722,11 @@ static void hvc_iucv_notifier_del(struct hvc_struct *hp, 
int id)
flush_sndbuf_sync(priv);
 
spin_lock_bh(&priv->lock);
-   path = priv->path;  /* save reference to IUCV path */
-   priv->path = NULL;
-   hvc_iucv_cleanup(priv);
+   destroy_tty_buffer_list(&priv->tty_outqueue);
+   destroy_tty_buffer_list(&priv->tty_inqueue);
+   priv->tty_state = TTY_CLOSED;
+   priv->sndbuf_len = 0;
spin_unlock_bh(&priv->lock);
-
-   /* sever IUCV path outside of priv->lock due to lock ordering of:
-* priv->lock <--> iucv_table_lock */
-   if (path) {
-   iucv_path_sever(path, NULL);
-   iucv_path_free(path);
-   }
 }
 
 /**
@@ -931,6 +968,7 @@ static const struct hv_ops hvc_iucv_ops = {
.notifier_add = hvc_iucv_notifier_add,
.notifier_del = hvc_iucv_notifier_del,
.notifier_hangup = hvc_iucv_notifier_hangup,
+   .dtr_rts = hvc_iucv_dtr_rts,
 };
 
 /* Suspend / resume device operations */
-- 
1.7.5.4

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


[PATCH 1/2] tty/hvc_console: Add DTR/RTS callback to handle HUPCL control

2013-07-02 Thread Hendrik Brueckner
Introduce a new callback to explicitly handle the HUPCL termios control flag.
This prepares for a follow-up commit for the hvc_iucv device driver to
improve handling when to drop an established network connection.

The callback naming is based on the recently added tty_port interface to
facilitate a potential refactoring of the hvc_console to use tty_port
functions.

Signed-off-by: Hendrik Brueckner 
---
 drivers/tty/hvc/hvc_console.c |   11 ++-
 drivers/tty/hvc/hvc_console.h |3 +++
 2 files changed, 13 insertions(+), 1 deletions(-)

diff --git a/drivers/tty/hvc/hvc_console.c b/drivers/tty/hvc/hvc_console.c
index eb255e8..9eba119 100644
--- a/drivers/tty/hvc/hvc_console.c
+++ b/drivers/tty/hvc/hvc_console.c
@@ -361,7 +361,12 @@ static int hvc_open(struct tty_struct *tty, struct file * 
filp)
tty->driver_data = NULL;
tty_port_put(&hp->port);
printk(KERN_ERR "hvc_open: request_irq failed with rc %d.\n", 
rc);
-   }
+   } else
+   /* We are ready... raise DTR/RTS */
+   if (C_BAUD(tty))
+   if (hp->ops->dtr_rts)
+   hp->ops->dtr_rts(hp, 1);
+
/* Force wakeup of the polling thread */
hvc_kick();
 
@@ -393,6 +398,10 @@ static void hvc_close(struct tty_struct *tty, struct file 
* filp)
/* We are done with the tty pointer now. */
tty_port_tty_set(&hp->port, NULL);
 
+   if (C_HUPCL(tty))
+   if (hp->ops->dtr_rts)
+   hp->ops->dtr_rts(hp, 0);
+
if (hp->ops->notifier_del)
hp->ops->notifier_del(hp, hp->data);
 
diff --git a/drivers/tty/hvc/hvc_console.h b/drivers/tty/hvc/hvc_console.h
index 674d23c..9131019 100644
--- a/drivers/tty/hvc/hvc_console.h
+++ b/drivers/tty/hvc/hvc_console.h
@@ -75,6 +75,9 @@ struct hv_ops {
/* tiocmget/set implementation */
int (*tiocmget)(struct hvc_struct *hp);
int (*tiocmset)(struct hvc_struct *hp, unsigned int set, unsigned int 
clear);
+
+   /* Callbacks to handle tty ports */
+   void (*dtr_rts)(struct hvc_struct *hp, int raise);
 };
 
 /* Register a vterm and a slot index for use as a console (console_init) */
-- 
1.7.5.4

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


[PATCH 0/2] hvc_console: Add DTR/RTS callbacks to handle HUPCL conditions

2013-07-02 Thread Hendrik Brueckner
Hi folks,

this series resolves an issue for hvc back-ends that transfer
terminal data over an established communication path.

The current implementation of the hvc_console layer notifies its
back-ends for tty open, close, and hangups.  However, there are
conditions where the hangup-on-close (HUPCL) termios flag must be
considered, for example, when doing a vhangup().

For the hvc_iucv back-end, users perceives disconnects at their
login which are triggered by a modified vhangup() invocation as
described in https://lkml.org/lkml/2012/6/5/145.
(The kernel change implied also a change in the login program).

However, this also necessitates to inform back-ends about changes
in the DTR/RTS control lines which actually depend on the setting
of the HUPCL termios flag.  Like in the old days for modems,
network-based back-ends need to know when to hang-up and drop off
an established communication path.  Without this new notification,
back-ends can only use the tty open, close, hangup notifiers to
decide whether to disconnect.  This is not sufficient because the
HUPCL flag can be cleared (i.e. not to hang-up a connection) when
last tty file descriptor is closed.

This series adds the dtr_rts() callback to the hvc_console layer
and modifies the hvc_iucv device driver to disconnect an established
IUCV connection only when the DTR/RTS is lowered.


Feedback is very welcome.  Thanks in advance!

Kind regards,
  Hendrik

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


[RFC] [PATCH] hvc_console: improve tty/console put_chars handling

2011-07-05 Thread Hendrik Brueckner
Hi folks,

On Tue, Jul 05, 2011 at 04:22:43PM +1000, Benjamin Herrenschmidt wrote:
> On Tue, 2011-07-05 at 04:17 +, Tabi Timur-B04825 wrote:
> > On Mon, Jul 4, 2011 at 9:24 AM, Hendrik Brueckner
> >  wrote:
> > 
> > I started that thread.  After much soul searching, we came to the
> > conclusion that HVC is not compatible with hypervisors that return
> > BUSY on writes. 
> 
> That is a fun conclusion considering that hvc has been written for the
> pseries hypervisor which ... can return BUSY on writes :-)
> 
> We just need to fix HVC properly.

So I took initiative and looked again into this issue.  Below you can
find a patch that is based on Ben's -EAGAIN idea.  The hvc console layer
takes care of retrying depending on the backend's return code.

However, the main issue is that from a backend perspective, there is no
difference between tty and console output.  Because consoles, especially
the preferred console, behave different than a simple tty.  Blocked write
to a preferred console can stop the system.

So with the patch below, the backend can now indirectly control the way
console output is handled for it.  I still have to think if this solution
is ok or if it is better to introduce a new callback to console output only
(and might provide a default implemenatation similar to the patch below).

NOTE: I did not yet test this patch but will do.. I just want to share it
  early to get feedback from you.

-->8-

Currently, the hvc_console_print() function drops console output if the
hvc backend's put_chars() returns 0.  This patch changes this behavior
to allow a retry through returning -EAGAIN.

This change also affects the hvc_push() function.  Both functions are
changed to handle -EAGAIN and to retry the put_chars() operation.

If a hvc backend returns -EAGAIN, the retry handling differs:

  - hvc_console_print() spins to write the complete console output.
  - hvc_push() behaves the same way as for returning 0.

Now hvc backends can indirectly control the way how console output is
handled through the hvc console layer.

Signed-off-by: Hendrik Brueckner 
---
 drivers/tty/hvc/hvc_console.c |8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

--- a/drivers/tty/hvc/hvc_console.c
+++ b/drivers/tty/hvc/hvc_console.c
@@ -163,8 +163,10 @@ static void hvc_console_print(struct con
} else {
r = cons_ops[index]->put_chars(vtermnos[index], c, i);
if (r <= 0) {
-   /* throw away chars on error */
-   i = 0;
+   /* throw away characters on error
+* but spin in case of -EAGAIN */
+   if (r != -EAGAIN)
+   i = 0;
} else if (r > 0) {
i -= r;
if (i > 0)
@@ -448,7 +450,7 @@ static int hvc_push(struct hvc_struct *h
 
n = hp->ops->put_chars(hp->vtermno, hp->outbuf, hp->n_outbuf);
if (n <= 0) {
-   if (n == 0) {
+   if (n == 0 || n == -EAGAIN) {
hp->do_wakeup = 1;
return 0;
}
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: hvc_console change results in corrupt oops output

2011-07-04 Thread Hendrik Brueckner
On Mon, Jul 04, 2011 at 11:56:27PM +1000, Benjamin Herrenschmidt wrote:
> On Mon, 2011-07-04 at 20:57 +1000, Anton Blanchard wrote:
> 
>  .../...
> 
> > The hypervisor gives us a busy return, so we could retry a number of
> > times instead of dropping it on the floor. We'd need to do it in the
> > hvc_console driver - the tty drivers share the same backend
> > functions so we can't hide it in the pseries put_chars function.
> 
> For kernel console, I don't see why not wait forever ... If the
> underlying backend really lost the connection it can always return a
> negative error no ?
> 
> Or we could have "well defined" return codes for "wait forever" vs.
> "drop this" ... maybe return -EAGAIN.

I will check this again for my hvc_iucv back-end.  Meanwhile a found
an old thread discussing the same issue.  It covers some differences
between console and ttys which actually does not matter for hvc-backend
because of the shared put_chars() routine.

You can read the thread on lkml.org: http://lkml.org/lkml/2009/10/15/149


Kind regards,
  Hendrik
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [PATCH] hvc_console: returning 0 from put_chars is not an error

2009-10-16 Thread Hendrik Brueckner
On Thu, Oct 15, 2009 at 02:32:54PM -0500, Scott Wood wrote:
> Christian Borntraeger wrote:
>> About the backends, there are some that spin until the text is 
>> delivered (e.g. virtio) , others can drop (e.g. iucv is a connection 
>> oriented protocol and it will (and has to) drop if there is no 
>> connection). 
>
> Sure, dropping due to not having a connection makes sense.  That's  
> different from merely being busy.  Can the iucv code tell the difference  
> between those two states?

The states are handled by the hvc_iucv itself:
If the hvc_iucv code has a connection established, terminal or console data
are queued and sent to the peer. If the state is disconnected, terminal and
console data is discarded internally.

- Hendrik
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


[PATCH] hvc_console: provide (un)locked version for hvc_resize()

2009-08-27 Thread Hendrik Brueckner
On Thu, Aug 27, 2009 at 07:27:23PM +1000, Benjamin Herrenschmidt wrote:
> On Thu, 2009-08-27 at 10:08 +0100, Alan Cox wrote:
> So at this stage, I think the reasonably thing to do is to stick to the
> spinlock, but we can try to make it a bit smarter, and we can definitely
> attempt to fix the case Amit pointed out where we call resize without a
> lock while it seems to expect it (though we also need to be careful
> about re-entrancy I believe).

I have worked on a patch for providing a locked hvc_resize() function.
Since only two back-ends (virtio_console and hvc_iucv) use the function,
I decided to update my hvc_iucv back-end through renaming the function
call as follows:

Rename the locking free hvc_resize() function to __hvc_resize() and
provide an inline function that locks the hvc_struct and calls
__hvc_resize().

The rationale for this patch is that virtio_console calls the hvc_resize()
function without locking the hvc_struct.
According to naming rules, the unlocked version is renamed and
prefixed with "__".
References to unlocked function calls in hvc back-ends has been updated.

Signed-off-by: Hendrik Brueckner 
Acked-by: Christian Borntraeger 
---
 drivers/char/hvc_console.c |6 +++---
 drivers/char/hvc_console.h |   12 +++-
 drivers/char/hvc_iucv.c|4 +++-
 3 files changed, 17 insertions(+), 5 deletions(-)

--- a/drivers/char/hvc_console.c
+++ b/drivers/char/hvc_console.c
@@ -680,7 +680,7 @@ int hvc_poll(struct hvc_struct *hp)
 EXPORT_SYMBOL_GPL(hvc_poll);
 
 /**
- * hvc_resize() - Update terminal window size information.
+ * __hvc_resize() - Update terminal window size information.
  * @hp:HVC console pointer
  * @ws:Terminal window size structure
  *
@@ -689,12 +689,12 @@ EXPORT_SYMBOL_GPL(hvc_poll);
  *
  * Locking:Locking free; the function MUST be called holding hp->lock
  */
-void hvc_resize(struct hvc_struct *hp, struct winsize ws)
+void __hvc_resize(struct hvc_struct *hp, struct winsize ws)
 {
hp->ws = ws;
schedule_work(&hp->tty_resize);
 }
-EXPORT_SYMBOL_GPL(hvc_resize);
+EXPORT_SYMBOL_GPL(__hvc_resize);
 
 /*
  * This kthread is either polling or interrupt driven.  This is determined by
--- a/drivers/char/hvc_console.h
+++ b/drivers/char/hvc_console.h
@@ -28,6 +28,7 @@
 #define HVC_CONSOLE_H
 #include 
 #include 
+#include 
 
 /*
  * This is the max number of console adapters that can/will be found as
@@ -88,7 +89,16 @@ int hvc_poll(struct hvc_struct *hp);
 void hvc_kick(void);
 
 /* Resize hvc tty terminal window */
-extern void hvc_resize(struct hvc_struct *hp, struct winsize ws);
+extern void __hvc_resize(struct hvc_struct *hp, struct winsize ws);
+
+static inline void hvc_resize(struct hvc_struct *hp, struct winsize ws)
+{
+   unsigned long flags;
+
+   spin_lock_irqsave(&hp->lock, flags);
+   __hvc_resize(hp, ws);
+   spin_unlock_irqrestore(&hp->lock, flags);
+}
 
 /* default notifier for irq based notification */
 extern int notifier_add_irq(struct hvc_struct *hp, int data);
--- a/drivers/char/hvc_iucv.c
+++ b/drivers/char/hvc_iucv.c
@@ -273,7 +273,9 @@ static int hvc_iucv_write(struct hvc_iuc
case MSG_TYPE_WINSIZE:
if (rb->mbuf->datalen != sizeof(struct winsize))
break;
-   hvc_resize(priv->hvc, *((struct winsize *) rb->mbuf->data));
+   /* The caller must ensure that the hvc is locked, which
+* is the case when called from hvc_iucv_get_chars() */
+   __hvc_resize(priv->hvc, *((struct winsize *) rb->mbuf->data));
break;
 
case MSG_TYPE_ERROR:/* ignored ... */
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [PATCH 1/4 v2] hvc_console: remove tty->low_latency

2009-01-15 Thread Hendrik Brueckner
On Wed, Jan 14, 2009 at 08:04:04AM +1100, Benjamin Herrenschmidt wrote:
> > So the simplest is to never set it.
> 
> I already applied your previous patch. Please send an incremental fix.
Here is the incremental patch for your powerpc tree along with a summary
as patch description.

Regards,
Hendrik

--
This patch removes the tty->low_latency setting.

For irq based hvc_console backends the tty->low_latency must be set to 0,
because the tty_flip_buffer_push() function must not be called from IRQ context
(see drivers/char/tty_buffer.c).

For polled backends, the low_latency setting causes the bug trace below, because
tty_flip_buffer_push() is called within an atomic context and subsequent calls
might sleep due to mutex_lock.

BUG: sleeping function called from invalid context at 
/root/cvs/linux-2.6.git/kernel/mutex.c:207
in_atomic(): 1, irqs_disabled(): 0, pid: 748, name: khvcd
1 lock held by khvcd/748:
 #0:  (hvc_structs_lock){--..}, at: [<002ceb50>] khvcd+0x58/0x12c
CPU: 0 Not tainted 2.6.29-rc1git #29
Process khvcd (pid: 748, task: 2fb9a480, ksp: 2f66bd78)
070a 2f66ba00 0002 (null) 
   2f66baa0 2f66ba18 2f66ba18 00104f08 
   c000 2f66bd78 (null) (null) 
   2f66ba00 000c 2f66ba00 2f66ba70 
   00466af8 00104f08 2f66ba00 2f66ba50 
Call Trace:
([<00104e7c>] show_trace+0x138/0x158)
 [<00104f62>] show_stack+0xc6/0xf8
 [<00105740>] dump_stack+0xb0/0xc0
 [<0013144a>] __might_sleep+0x14e/0x17c
 [<0045e226>] mutex_lock_nested+0x42/0x3b4
 [<002c443e>] echo_char_raw+0x3a/0x9c
 [<002c688c>] n_tty_receive_buf+0x1154/0x1208
 [<002ca0a2>] flush_to_ldisc+0x152/0x220
 [<002ca1da>] tty_flip_buffer_push+0x6a/0x90
 [<002cea74>] hvc_poll+0x244/0x2c8
 [<002ceb68>] khvcd+0x70/0x12c
 [<0015bbd0>] kthread+0x68/0xa0
 [<00109d5a>] kernel_thread_starter+0x6/0xc
 [<00109d54>] kernel_thread_starter+0x0/0xc
1 lock held by khvcd/748:
 #0:  (hvc_structs_lock){--..}, at: [<002ceb50>] khvcd+0x58/0x12c

Signed-off-by: Hendrik Brueckner 
---
 drivers/char/hvc_console.c |2 --
 1 file changed, 2 deletions(-)

--- a/drivers/char/hvc_console.c
+++ b/drivers/char/hvc_console.c
@@ -318,8 +318,6 @@ static int hvc_open(struct tty_struct *t
} /* else count == 0 */
 
tty->driver_data = hp;
-   if (!hp->irq_requested)
-   tty->low_latency = 1; /* Makes flushes to ldisc synchronous. */
 
hp->tty = tty;
 
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [PATCH 1/4] hvc_console: do not set low_latency

2009-01-13 Thread Hendrik Brueckner
Here is yet another bug trace related to the low_latency issue, that is
experienced using the hvc_iucv backend.  The hvc_iucv backend now also uses irq
notifiers.
The bug trace below appears if hvc_kick() is called.

On Tue, Jan 13, 2009 at 10:04:22AM +0100, Christian Borntraeger wrote:
> Am Donnerstag 08 Januar 2009 schrieb Milton Miller:
> > hvc_console is setting low_latency unconditionally, but some clients are
> > interrupt driven and will call hvc_poll from irq context.  This will cause
> > tty_flip_buffer_push to be called from irq context, and it very clearly
> > states it must not be called from IRQ when low_latency is specified.
It seems that if low_latency is set, tty_flip_buffer_push() should also not be
called within an atomic context, because echo_char_raw() and other echo* calls
might sleep.

Christian's patch solves this problem for irq driven backends.
However, there might be still a problem with polled backends since the khvcd()
thread calls hvc_poll() while hvc_structs_lock is held.

I think the hvc_udbg backend is based on polling.
David, could you check if you experience any problems with your hvc_udbg
backend on latest git.

BUG: sleeping function called from invalid context at 
/root/cvs/linux-2.6.git/kernel/mutex.c:207
in_atomic(): 1, irqs_disabled(): 0, pid: 748, name: khvcd
1 lock held by khvcd/748:
 #0:  (hvc_structs_lock){--..}, at: [<002ceb50>] khvcd+0x58/0x12c
CPU: 0 Not tainted 2.6.29-rc1git #29
Process khvcd (pid: 748, task: 2fb9a480, ksp: 2f66bd78)
070a 2f66ba00 0002 (null) 
   2f66baa0 2f66ba18 2f66ba18 00104f08 
   c000 2f66bd78 (null) (null) 
   2f66ba00 000c 2f66ba00 2f66ba70 
   00466af8 00104f08 2f66ba00 2f66ba50 
Call Trace:
([<00104e7c>] show_trace+0x138/0x158)
 [<00104f62>] show_stack+0xc6/0xf8
 [<00105740>] dump_stack+0xb0/0xc0
 [<0013144a>] __might_sleep+0x14e/0x17c
 [<0045e226>] mutex_lock_nested+0x42/0x3b4
 [<002c443e>] echo_char_raw+0x3a/0x9c
 [<002c688c>] n_tty_receive_buf+0x1154/0x1208
 [<002ca0a2>] flush_to_ldisc+0x152/0x220
 [<002ca1da>] tty_flip_buffer_push+0x6a/0x90
 [<002cea74>] hvc_poll+0x244/0x2c8
 [<002ceb68>] khvcd+0x70/0x12c
 [<0015bbd0>] kthread+0x68/0xa0
 [<00109d5a>] kernel_thread_starter+0x6/0xc
 [<00109d54>] kernel_thread_starter+0x0/0xc
1 lock held by khvcd/748:
 #0:  (hvc_structs_lock){--..}, at: [<002ceb50>] khvcd+0x58/0x12c

> This wont work, since the call to notifier_add is done later:
> What about:
> ---
>  drivers/char/hvc_console.c |5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> Index: linux-2.6/drivers/char/hvc_console.c
> ===
> --- linux-2.6.orig/drivers/char/hvc_console.c
> +++ linux-2.6/drivers/char/hvc_console.c
> @@ -318,8 +318,6 @@ static int hvc_open(struct tty_struct *t
>   } /* else count == 0 */
> 
>   tty->driver_data = hp;
> - tty->low_latency = 1; /* Makes flushes to ldisc synchronous. */
> -
>   hp->tty = tty;
> 
>   spin_unlock_irqrestore(&hp->lock, flags);
> @@ -327,6 +325,9 @@ static int hvc_open(struct tty_struct *t
>   if (hp->ops->notifier_add)
>   rc = hp->ops->notifier_add(hp, hp->data);
> 
> + if (!hp->irq_requested)
> + tty->low_latency = 1; /* Makes flushes to ldisc synchronous. */
> +
>   /*
>* If the notifier fails we return an error.  The tty layer
>* will call hvc_close() after a failed open but we don't want to clean

Acked-by: Hendrik Brueckner 
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [patch 1/1 v2] hvc_console: escape magic sysrq key

2008-12-16 Thread Hendrik Brueckner
Hello Andreas,

thanks for your comments.

On Tue, Dec 16, 2008 at 10:36:55AM +0100, Andreas Schwab wrote:
> > +   /* if ^0 is pressed again, reset
> > +* sysrq_pressed and flip ^0 char */
> The comment says ^0 twice when ^O is meant.
Correct. I have updated the comment.

> > +   sysrq_pressed = (sysrq_pressed) ? 0 : 1;
> sysrq_pressed = !sysrc_pressed;
Ok, it might look better.


[PATCH v2] hvc_console: escape magic sysrq key

From: Hendrik Brueckner 

The ctrl-o (^O) is a common control key used by several applications like vim.

To allow users to send ^O to the terminal, this patch introduces a check
if ^O is pressed again if the sysrq_pressed variable is already set.
In this case, clear sysrq_pressed state and flip the ^O character to the tty.
(The old behavior has always set "sysrq_pressed" if ^O has been entered, and it
has not flipped the ^O character to the tty.)

Signed-off-by: Hendrik Brueckner 
---
 drivers/char/hvc_console.c |7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

--- a/drivers/char/hvc_console.c
+++ b/drivers/char/hvc_console.c
@@ -642,8 +642,11 @@ int hvc_poll(struct hvc_struct *hp)
/* Handle the SysRq Hack */
/* XXX should support a sequence */
if (buf[i] == '\x0f') { /* ^O */
-   sysrq_pressed = 1;
-   continue;
+   /* if ^O is pressed again, reset
+* sysrq_pressed and flip ^O char */
+   sysrq_pressed = !sysrq_pressed;
+   if (sysrq_pressed)
+   continue;
} else if (sysrq_pressed) {
handle_sysrq(buf[i], tty);
sysrq_pressed = 0;
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


[patch 1/1] hvc_console: escape magic sysrq key

2008-12-16 Thread Hendrik Brueckner
From: Hendrik Brueckner 

The ctrl-o (^O) is a common control key used by several applications like vim.

To allow users to send ^O to the terminal, this patch introduces a check
if ^O is pressed again if the sysrq_pressed variable is already set.
In this case, clear sysrq_pressed state and flip the ^O character to the tty.
(The old behavior has always set "sysrq_pressed" if ^0 has been entered, and it
has not flipped the ^O character to the tty.)

Signed-off-by: Hendrik Brueckner 
---
 drivers/char/hvc_console.c |7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

--- a/drivers/char/hvc_console.c
+++ b/drivers/char/hvc_console.c
@@ -642,8 +642,11 @@ int hvc_poll(struct hvc_struct *hp)
/* Handle the SysRq Hack */
/* XXX should support a sequence */
if (buf[i] == '\x0f') { /* ^O */
-   sysrq_pressed = 1;
-   continue;
+   /* if ^0 is pressed again, reset
+* sysrq_pressed and flip ^0 char */
+   sysrq_pressed = (sysrq_pressed) ? 0 : 1;
+   if (sysrq_pressed)
+   continue;
} else if (sysrq_pressed) {
handle_sysrq(buf[i], tty);
sysrq_pressed = 0;

-- 
Hendrik Brueckner
D/3303 Linux on System z Development
eMail: brueck...@linux.vnet.ibm.com
IBM Deutschland Research & Development GmbH, Schoenaicher Str. 220, 71032 
Boeblingen

IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Martin Jetter
Geschaeftsfuehrung: Erich Baier
Sitz der Gesellschaft: Boeblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294

___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


[patch 0/1] hvc_console: send magic sysrq key to terminal

2008-12-16 Thread Hendrik Brueckner
Hello,

the patch allows to send the magic sysrq key to the terminal (if pressed twice),
so that it can be consumed by applications (e.g. ^0 is used by some editors...)


Ben, Paul, could you add the patch to your powerpc tree?

Thanks and regards, 
Hendrik

-- 
Hendrik Brueckner
D/3303 Linux on System z Development
eMail: brueck...@linux.vnet.ibm.com
IBM Deutschland Research & Development GmbH, Schoenaicher Str. 220, 71032 
Boeblingen

IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Martin Jetter
Geschaeftsfuehrung: Erich Baier
Sitz der Gesellschaft: Boeblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294

___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [patch 1/1] hvc_console: fix: hp->ws winsize check runs out-of-sync

2008-12-03 Thread Hendrik Brueckner
Hi Paul,

On Wed, Dec 03, 2008 at 08:17:13PM +1100, Paul Mackerras wrote:
> Looks OK.  Is this going to go in via the s390 tree, or should I put
> it in the powerpc tree?
The patch should go via the powerpc tree.

Thanks and regards,
Hendrik
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


[patch 1/1] hvc_console: fix: hp->ws winsize check runs out-of-sync

2008-11-18 Thread Hendrik Brueckner
From: Hendrik Brueckner <[EMAIL PROTECTED]>

The test to check for a new winsize runs out-of-sync with the underlying
tty. After a tty has been released and initialized again, the winsize might
differ between the tty and the hp struct. 
The solution is to simply remove the check and always schedule the resize work.

Signed-off-by: Hendrik Brueckner <[EMAIL PROTECTED]>
Acked-by: Christian Borntraeger <[EMAIL PROTECTED]>
---
 drivers/char/hvc_console.c |6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

--- a/drivers/char/hvc_console.c
+++ b/drivers/char/hvc_console.c
@@ -689,10 +689,8 @@ EXPORT_SYMBOL_GPL(hvc_poll);
  */
 void hvc_resize(struct hvc_struct *hp, struct winsize ws)
 {
-   if ((hp->ws.ws_row != ws.ws_row) || (hp->ws.ws_col != ws.ws_col)) {
-   hp->ws = ws;
-   schedule_work(&hp->tty_resize);
-   }
+   hp->ws = ws;
+   schedule_work(&hp->tty_resize);
 }
 
 /*

-- 
Hendrik Brueckner
D/3303 Linux on System z Development
Tel: +49 7031 16-1073
Fax: +49 7031 16-3456
eMail: [EMAIL PROTECTED]
IBM Deutschland Research & Development GmbH, Schoenaicher Str. 220, 71032 
Boeblingen

IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Martin Jetter
Geschaeftsfuehrung: Erich Baier
Sitz der Gesellschaft: Boeblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294

___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


[patch 0/1] hvc_console: fix: remove duplicate hp->ws winsize check

2008-11-18 Thread Hendrik Brueckner
Hello,

this patch fixes a hvc terminal resize problem by removing a duplicate
winsize comparison.

Ben, could you add this patch to your tree for 2.6.28-rc6 bug fixes?

Thanks and regards,
Hendrik

-- 
Hendrik Brueckner
D/3303 Linux on System z Development
eMail: [EMAIL PROTECTED]
IBM Deutschland Research & Development GmbH, Schoenaicher Str. 220, 71032 
Boeblingen

IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Martin Jetter
Geschaeftsfuehrung: Erich Baier
Sitz der Gesellschaft: Boeblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294

___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: linux-next: ttydev tree build failure

2008-10-23 Thread Hendrik Brueckner
On Thu, Oct 23, 2008 at 05:29:38PM +1100, Stephen Rothwell wrote:
> drivers/char/hvc_console.c: In function 'hvc_set_winsz':
> drivers/char/hvc_console.c:532: warning: passing argument 2 of 
> 'tty_do_resize' from incompatible pointer type
> drivers/char/hvc_console.c:532: error: too many arguments to function 
> 'tty_do_resize'
> 
> Caused by commit eb6ab2d361a49470ca9785c70482772c19e49bec
> ("pty-simplify-resize") from the ttydev tree interacting with commit
> febde3711992a64ea83a47a719f68a90c4b0927a ("hvc_console: Add support for
> tty window resizing").
> 
> The former added another call to the function that the latter changed.
In linux-next, the pty-simplify-resize patch has changed the
tty_do_resize() signature; and therefore the hvc patch did not compile.

> I applied the following patch.
The patch is correct.
Thanks.

Acked-by: Hendrik Brueckner <[EMAIL PROTECTED]>

-- 
Regards
Hendrik

IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Martin Jetter
Geschaeftsfuehrung: Erich Baier
Sitz der Gesellschaft: Boeblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294

___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [RFC PATCH 0/5] patches for a network-based hvc backend (s390)

2008-10-21 Thread Hendrik Brueckner
On Tue, Oct 21, 2008 at 10:23:37AM +1100, Benjamin Herrenschmidt wrote:
> What's the status with that patch serie ? Is this 2.6.28 material ?
It is 2.6.28 material.
> Alan, are you ok with those ? Hendrik, have there been any respin other
> than v2 of patch 4/5 ?
The other patches have not been changed.

fyi: patch 1/5 (hangup notifier) applies successfully with an offset
of 2 lines due to commit eef2622a9fcfa96407ea72c7c9cd20ad45e6
(hvc_console: Fix free_irq in spinlocked section).


> I can merge it via powerpc but it's getting late in the merge window...
Thanks... that would be really great!

Regards
Hendrik

-- 
Hendrik Brueckner
D/3303 Linux on System z Development
Tel: +49 7031 16-1073
Fax: +49 7031 16-3456
eMail: [EMAIL PROTECTED]
IBM Deutschland Research & Development GmbH, Schoenaicher Str. 220, 71032 
Boeblingen

IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Martin Jetter
Geschaeftsfuehrung: Erich Baier
Sitz der Gesellschaft: Boeblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294

___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [RFC PATCH 2/5] hvc_console: Add tty driver flag TTY_DRIVER_RESET_TERMIOS

2008-10-16 Thread Hendrik Brueckner
Hello,

for the sake of completion, here are few more details why I have suggest to
add the TTY_DRIVER_RESET_TERMIOS flag:

On Tue, Oct 14, 2008 at 10:40:25AM +0100, Alan Cox wrote:
> On Tue, 14 Oct 2008 11:12:49 +0200
> Hendrik Brueckner <[EMAIL PROTECTED]> wrote:
> 
> > After a tty hangup() or close() operation, processes might not reset the
> > termio settings to a sane state.
> That is the job of the getty task normally. pty is special as the reissue
> of the same pty is done as a new device (with new state).

During some testing, I have experienced that the bash alters few termios
settings before showing the bash prompt:
-
ioctl(0, TCGETS, {B38400 opost isig icanon echo ...}) = 0
ioctl(0, TCSETSW, {B38400 opost isig -icanon -echo ...}) = 0
write(2, "[EMAIL PROTECTED]:~# ", 17) = 17
-
If the tty gets a hangup, the bash gets terminated but the settings still
remains after init has respawned the getty process.
For my network-based hvc backend, a tty_hangup() is caused by a disconnect.

I looked into the tty_io.c source and found out that the termios settings
are stored in an array of the tty driver struct and they remains unchanged
if a tty device is released and initialized again.
At tty device initialization, the tty_init_termios() set tty->termios to the
tty->driver->termios[tty->index].

The idea is to ensure that when a tty is initialized it has the
default (initial) termio settings; and that is actually done if
TTY_DRIVER_RESET_TERMIOS is set.

Anyhow the other possibility might be to always set the initial termios
when the tty is initialized (see patch below).
But I am not sure if that case is the general behavior of ttys.
Please let me know if there is a reason not to re-initialize the termios
of a new tty.

Thanks.

Best regards
Hendrik

Signed-off-by: Hendrik Brueckner <[EMAIL PROTECTED]>
---
 drivers/char/tty_io.c |3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

--- a/drivers/char/tty_io.c 2008-10-16 09:48:00.0 +0200
+++ b/drivers/char/tty_io.c 2008-10-16 12:55:52.0 +0200
@@ -1243,10 +1243,9 @@ int tty_init_termios(struct tty_struct *
tp = kzalloc(sizeof(struct ktermios[2]), GFP_KERNEL);
if (tp == NULL)
return -ENOMEM;
-   memcpy(tp, &tty->driver->init_termios,
-   sizeof(struct ktermios));
tty->driver->termios[idx] = tp;
}
+   memcpy(tp, &tty->driver->init_termios, sizeof(struct ktermios));
    tty->termios = tp;
tty->termios_locked = tp + 1;
 
-- 
Hendrik Brueckner
D/3303 Linux on System z Development
Tel: +49 7031 16-1073
Fax: +49 7031 16-3456
eMail: [EMAIL PROTECTED]
IBM Deutschland Research & Development GmbH, Schoenaicher Str. 220, 71032 
Boeblingen

IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Martin Jetter
Geschaeftsfuehrung: Erich Baier
Sitz der Gesellschaft: Boeblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294

___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [RFC PATCH 4/5] hvc_console: Add tty window resizing

2008-10-14 Thread Hendrik Brueckner
On Tue, Oct 14, 2008 at 10:44:28AM +0100, Alan Cox wrote:
> > +   hp = container_of(work, struct hvc_struct, tty_resize);
> > +   if (!hp || !hp->tty)
> > +   return;
> What locks hp->tty here, it can go NULL after the test on a hangup it
> seems ?
You are right. Thanks.

> See tty_do_resize() for all of this stuff in the latest git. If you can't
> use tty_do_resize from your work queue then please let me know why as I'd
> like everyone to be using one abstraction.
I have looked at it  and I have corrected my patch to use tty_do_resize().
Since tty_do_resize() cannot be called holding the hp spinlock; the code uses
now tty_kref_get/put to keep track of the tty object. I am not sure if the
use of the kref's is correct here, so please let me know if there is a better
solution.

Thanks.

Regards,
Hendrik

[RFC PATCH 4/5 v2] hvc_console: Add tty window resizing using tty_do_resize()

From: Hendrik Brueckner <[EMAIL PROTECTED]>

The patch provides the hvc_resize() function to update the terminal
window dimensions (struct winsize) for a specified hvc console.
The function stores the new window size and schedules a function
that finally updates the tty winsize and signals the change to
user space (SIGWINCH).
Because the winsize update must acquire a mutex and might sleep,
the function is scheduled instead of being called from hvc_poll()
or khvcd.

This patch uses the tty_do_resize() routine from the tty layer.
A pending resize work is canceled in hvc_close() and hvc_hangup().

Signed-off-by: Hendrik Brueckner <[EMAIL PROTECTED]>
---
 drivers/char/hvc_console.c |   58 +
 drivers/char/hvc_console.h |6 
 2 files changed, 64 insertions(+)

--- a/drivers/char/hvc_console.c2008-10-14 16:13:12.0 +0200
+++ b/drivers/char/hvc_console.c2008-10-14 16:43:03.0 +0200
@@ -374,6 +374,9 @@ static void hvc_close(struct tty_struct 
hp->tty = NULL;
spin_unlock_irqrestore(&hp->lock, flags);
 
+   /* cancel pending tty resize work */
+   cancel_work_sync(&hp->tty_resize);
+
/*
 * Chain calls chars_in_buffer() and returns immediately if
 * there is no buffered data otherwise sleeps on a wait queue
@@ -399,6 +402,9 @@ static void hvc_hangup(struct tty_struct
if (!hp)
return;
 
+   /* cancel pending tty resize work */
+   cancel_work_sync(&hp->tty_resize);
+
spin_lock_irqsave(&hp->lock, flags);
 
/*
@@ -494,6 +500,39 @@ static int hvc_write(struct tty_struct *
return written;
 }
 
+/**
+ * hvc_set_winsz() - Resize the hvc tty terminal window.
+ * @work:  work structure.
+ *
+ * The routine shall not be called within an atomic context because it
+ * might sleep.
+ *
+ * Locking:hp->lock
+ */
+static void hvc_set_winsz(struct work_struct *work)
+{
+   struct hvc_struct *hp;
+   unsigned long hvc_flags;
+   struct tty_struct *tty;
+   struct winsize ws;
+
+   hp = container_of(work, struct hvc_struct, tty_resize);
+   if (!hp)
+   return;
+
+   spin_lock_irqsave(&hp->lock, hvc_flags);
+   if (!hp->tty) {
+   spin_unlock_irqrestore(&hp->lock, hvc_flags);
+   return;
+   }
+   ws  = hp->ws;
+   tty = tty_kref_get(hp->tty);
+   spin_unlock_irqrestore(&hp->lock, hvc_flags);
+
+   tty_do_resize(tty, tty, &ws);
+   tty_kref_put(tty);
+}
+
 /*
  * This is actually a contract between the driver and the tty layer outlining
  * how much write room the driver can guarantee will be sent OR BUFFERED.  This
@@ -638,6 +677,24 @@ int hvc_poll(struct hvc_struct *hp)
 }
 EXPORT_SYMBOL_GPL(hvc_poll);
 
+/**
+ * hvc_resize() - Update terminal window size information.
+ * @hp:HVC console pointer
+ * @ws:Terminal window size structure
+ *
+ * Stores the specified window size information in the hvc structure of @hp.
+ * The function schedule the tty resize update.
+ *
+ * Locking:Locking free; the function MUST be called holding hp->lock
+ */
+void hvc_resize(struct hvc_struct *hp, struct winsize ws)
+{
+   if ((hp->ws.ws_row != ws.ws_row) || (hp->ws.ws_col != ws.ws_col)) {
+   hp->ws = ws;
+   schedule_work(&hp->tty_resize);
+   }
+}
+
 /*
  * This kthread is either polling or interrupt driven.  This is determined by
  * calling hvc_poll() who determines whether a console adapter support
@@ -720,6 +777,7 @@ struct hvc_struct __devinit *hvc_alloc(u
 
kref_init(&hp->kref);
 
+   INIT_WORK(&hp->tty_resize, hvc_set_winsz);
spin_lock_init(&hp->lock);
spin_lock(&hvc_structs_lock);
 
--- a/drivers/char/hvc_console.h2008-10-14 16:13:1

[RFC PATCH 2/5] hvc_console: Add tty driver flag TTY_DRIVER_RESET_TERMIOS

2008-10-14 Thread Hendrik Brueckner
From: Hendrik Brueckner <[EMAIL PROTECTED]>

After a tty hangup() or close() operation, processes might not reset the
termio settings to a sane state. In order to reset the termios to its
default settings the tty driver flag TTY_DRIVER_RESET_TERMIOS has been added.

TTY driver flag description from include/linux/tty_driver.h:
TTY_DRIVER_RESET_TERMIOS --- requests the tty layer to reset the
  termios setting when the last process has closed the device.
  Used for PTY's, in particular.


Acked-by: Christian Borntraeger <[EMAIL PROTECTED]>
Signed-off-by: Hendrik Brueckner <[EMAIL PROTECTED]>
---
 drivers/char/hvc_console.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/drivers/char/hvc_console.c
+++ b/drivers/char/hvc_console.c
@@ -796,7 +796,7 @@ static int hvc_init(void)
drv->minor_start = HVC_MINOR;
drv->type = TTY_DRIVER_TYPE_SYSTEM;
drv->init_termios = tty_std_termios;
-   drv->flags = TTY_DRIVER_REAL_RAW;
+   drv->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_RESET_TERMIOS;
tty_set_operations(drv, &hvc_ops);
 
/* Always start the kthread because there can be hotplug vty adapters

-- 
Hendrik Brueckner
D/3303 Linux on System z Development
Tel: +49 7031 16-1073
Fax: +49 7031 16-3456
eMail: [EMAIL PROTECTED]
IBM Deutschland Research & Development GmbH, Schoenaicher Str. 220, 71032 
Boeblingen

IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Martin Jetter
Geschaeftsfuehrung: Erich Baier
Sitz der Gesellschaft: Boeblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294

___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


[RFC PATCH 4/5] hvc_console: Add tty window resizing

2008-10-14 Thread Hendrik Brueckner
From: Hendrik Brueckner <[EMAIL PROTECTED]>

The patch provides the hvc_resize() function to update the terminal
window dimensions (struct winsize) for a specified hvc console.
The function stores the new window size and schedules a function
that finally updates the tty winsize and signals the change to
user space (SIGWINCH).
Because the winsize update must acquire a mutex and might sleep,
the function is scheduled instead of being called from hvc_poll()
or khvcd.

Acked-by: Christian Borntraeger <[EMAIL PROTECTED]>
Signed-off-by: Hendrik Brueckner <[EMAIL PROTECTED]>
---
 drivers/char/hvc_console.c |   61 +
 drivers/char/hvc_console.h |6 
 2 files changed, 67 insertions(+)

--- a/drivers/char/hvc_console.c
+++ b/drivers/char/hvc_console.c
@@ -494,6 +494,48 @@ static int hvc_write(struct tty_struct *
return written;
 }
 
+/**
+ * hvc_set_winsz() - Resize the hvc tty terminal window.
+ * @work:  work structure.
+ *
+ * The routine shall not be called within an atomic context because it
+ * acquires the tty termios mutex and might sleep.
+ *
+ * Locking:hp->lock, tty->termios_mutex and tty->ctrl_lock
+ */
+static void hvc_set_winsz(struct work_struct *work)
+{
+   struct hvc_struct *hp;
+   struct pid *pgrp;
+   unsigned long hvc_flags;
+   unsigned long ctrl_flags;
+
+   hp = container_of(work, struct hvc_struct, tty_resize);
+   if (!hp || !hp->tty)
+   return;
+
+   mutex_lock(&hp->tty->termios_mutex);
+   spin_lock_irqsave(&hp->lock, hvc_flags);
+
+   if ((hp->ws.ws_row == hp->tty->winsize.ws_row) &&
+   (hp->ws.ws_col == hp->tty->winsize.ws_col))
+   goto out_mutex_unlock;
+
+   spin_lock_irqsave(&hp->tty->ctrl_lock, ctrl_flags);
+   pgrp = get_pid(hp->tty->pgrp);
+   spin_unlock_irqrestore(&hp->tty->ctrl_lock, ctrl_flags);
+
+   if (pgrp)
+   kill_pgrp(pgrp, SIGWINCH, 1);
+   put_pid(pgrp);
+
+   hp->tty->winsize = hp->ws;
+
+out_mutex_unlock:
+   spin_unlock_irqrestore(&hp->lock, hvc_flags);
+   mutex_unlock(&hp->tty->termios_mutex);
+}
+
 /*
  * This is actually a contract between the driver and the tty layer outlining
  * how much write room the driver can guarantee will be sent OR BUFFERED.  This
@@ -638,6 +680,24 @@ int hvc_poll(struct hvc_struct *hp)
 }
 EXPORT_SYMBOL_GPL(hvc_poll);
 
+/**
+ * hvc_resize() - Update terminal window size information.
+ * @hp:HVC console pointer
+ * @ws:Terminal window size structure
+ *
+ * Stores the specified window size information in the hvc structure of @hp.
+ * The function schedule the tty resize update.
+ *
+ * Locking:Locking free; the function MUST be called holding hp->lock
+ */
+void hvc_resize(struct hvc_struct *hp, struct winsize ws)
+{
+   if ((hp->ws.ws_row != ws.ws_row) || (hp->ws.ws_col != ws.ws_col)) {
+   hp->ws = ws;
+   schedule_work(&hp->tty_resize);
+   }
+}
+
 /*
  * This kthread is either polling or interrupt driven.  This is determined by
  * calling hvc_poll() who determines whether a console adapter support
@@ -720,6 +780,7 @@ struct hvc_struct __devinit *hvc_alloc(u
 
kref_init(&hp->kref);
 
+   INIT_WORK(&hp->tty_resize, hvc_set_winsz);
spin_lock_init(&hp->lock);
spin_lock(&hvc_structs_lock);
 
--- a/drivers/char/hvc_console.h
+++ b/drivers/char/hvc_console.h
@@ -27,6 +27,7 @@
 #ifndef HVC_CONSOLE_H
 #define HVC_CONSOLE_H
 #include 
+#include 
 
 /*
  * This is the max number of console adapters that can/will be found as
@@ -56,6 +57,8 @@ struct hvc_struct {
struct hv_ops *ops;
int irq_requested;
int data;
+   struct winsize ws;
+   struct work_struct tty_resize;
struct list_head next;
struct kref kref; /* ref count & hvc_struct lifetime */
 };
@@ -84,6 +87,9 @@ extern int __devexit hvc_remove(struct h
 int hvc_poll(struct hvc_struct *hp);
 void hvc_kick(void);
 
+/* Resize hvc tty terminal window */
+extern void hvc_resize(struct hvc_struct *hp, struct winsize ws);
+
 /* default notifier for irq based notification */
 extern int notifier_add_irq(struct hvc_struct *hp, int data);
 extern void notifier_del_irq(struct hvc_struct *hp, int data);

-- 
Hendrik Brueckner
D/3303 Linux on System z Development
Tel: +49 7031 16-1073
Fax: +49 7031 16-3456
eMail: [EMAIL PROTECTED]
IBM Deutschland Research & Development GmbH, Schoenaicher Str. 220, 71032 
Boeblingen

IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Martin Jetter
Geschaeftsfuehrung: Erich Baier
Sitz der Gesellschaft: Boeblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294

___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


[RFC PATCH 3/5] hvc_console: Fix loop if put_char() returns 0

2008-10-14 Thread Hendrik Brueckner
From: Hendrik Brueckner <[EMAIL PROTECTED]>

If put_char() routine of a hvc console backend returns 0, then the
hvc console starts looping in the following scenarios:

1. hvc_console_print()
If put_char() returns 0 then the while loop may loop forever.
I have added the missing check for 0 to throw away console messages.

2. khvcd may loop:
The thread calls hvc_poll() --> hvc_push()... if there are still
buffered data then the HVC_POLL_WRITE bit is set and causes the
khvcd thread to loop (if yield() returns immediately).

However, instead of looping, the khvcd thread could sleep for
MIN_TIMEOUT (doing the same as for get_chars()).
The MIN_TIMEOUT is set if hvc_push() was not able to write
data to the backend. If data has been written, the timeout is
set to 0 to immediately re-schedule hvc_poll().

Reviewed-by: Christian Borntraeger <[EMAIL PROTECTED]>
Tested-by: Christian Borntraeger <[EMAIL PROTECTED]> (virtio_console)
Signed-off-by: Hendrik Brueckner <[EMAIL PROTECTED]>
---
 drivers/char/hvc_console.c |   20 +++-
 1 file changed, 11 insertions(+), 9 deletions(-)

--- a/drivers/char/hvc_console.c
+++ b/drivers/char/hvc_console.c
@@ -161,7 +161,7 @@ static void hvc_console_print(struct con
}
} else {
r = cons_ops[index]->put_chars(vtermnos[index], c, i);
-   if (r < 0) {
+   if (r <= 0) {
/* throw away chars on error */
i = 0;
} else if (r > 0) {
@@ -431,7 +431,7 @@ static void hvc_hangup(struct tty_struct
  * Push buffered characters whether they were just recently buffered or waiting
  * on a blocked hypervisor.  Call this function with hp->lock held.
  */
-static void hvc_push(struct hvc_struct *hp)
+static int hvc_push(struct hvc_struct *hp)
 {
int n;
 
@@ -439,7 +439,7 @@ static void hvc_push(struct hvc_struct *
if (n <= 0) {
if (n == 0) {
hp->do_wakeup = 1;
-   return;
+   return 0;
}
/* throw away output on error; this happens when
   there is no session connected to the vterm. */
@@ -450,6 +450,8 @@ static void hvc_push(struct hvc_struct *
memmove(hp->outbuf, hp->outbuf + n, hp->n_outbuf);
else
hp->do_wakeup = 1;
+
+   return n;
 }
 
 static int hvc_write(struct tty_struct *tty, const unsigned char *buf, int 
count)
@@ -538,16 +540,20 @@ int hvc_poll(struct hvc_struct *hp)
char buf[N_INBUF] __ALIGNED__;
unsigned long flags;
int read_total = 0;
+   int written_total = 0;
 
spin_lock_irqsave(&hp->lock, flags);
 
/* Push pending writes */
if (hp->n_outbuf > 0)
-   hvc_push(hp);
+   written_total = hvc_push(hp);
 
/* Reschedule us if still some write pending */
-   if (hp->n_outbuf > 0)
+   if (hp->n_outbuf > 0) {
poll_mask |= HVC_POLL_WRITE;
+   /* If hvc_push() was not able to write, sleep a few msecs */
+   timeout = (written_total) ? 0 : MIN_TIMEOUT;
+   }
 
/* No tty attached, just skip */
tty = hp->tty;
@@ -659,10 +665,6 @@ static int khvcd(void *unused)
poll_mask |= HVC_POLL_READ;
if (hvc_kicked)
continue;
-   if (poll_mask & HVC_POLL_WRITE) {
-   yield();
-   continue;
-   }
set_current_state(TASK_INTERRUPTIBLE);
    if (!hvc_kicked) {
if (poll_mask == 0)

-- 
Hendrik Brueckner
D/3303 Linux on System z Development
Tel: +49 7031 16-1073
Fax: +49 7031 16-3456
eMail: [EMAIL PROTECTED]
IBM Deutschland Research & Development GmbH, Schoenaicher Str. 220, 71032 
Boeblingen

IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Martin Jetter
Geschaeftsfuehrung: Erich Baier
Sitz der Gesellschaft: Boeblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294

___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


[RFC PATCH 5/5] hvc_console: Remove __devexit annotation of hvc_remove()

2008-10-14 Thread Hendrik Brueckner
From: Hendrik Brueckner <[EMAIL PROTECTED]>

Removed __devexit annotation of hvc_remove() to avoid a section mismatch
if the backend initialization fails and hvc_remove() must be used to
clean up allocated hvc structs (called in section __init or __devinit).

Acked-by: Christian Borntraeger <[EMAIL PROTECTED]>
Signed-off-by: Hendrik Brueckner <[EMAIL PROTECTED]>
---
 drivers/char/hvc_console.c |2 +-
 drivers/char/hvc_console.h |2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

--- a/drivers/char/hvc_console.c
+++ b/drivers/char/hvc_console.c
@@ -806,7 +806,7 @@ struct hvc_struct __devinit *hvc_alloc(u
 }
 EXPORT_SYMBOL_GPL(hvc_alloc);
 
-int __devexit hvc_remove(struct hvc_struct *hp)
+int hvc_remove(struct hvc_struct *hp)
 {
unsigned long flags;
struct tty_struct *tty;
--- a/drivers/char/hvc_console.h
+++ b/drivers/char/hvc_console.h
@@ -81,7 +81,7 @@ extern int hvc_instantiate(uint32_t vter
 extern struct hvc_struct * __devinit hvc_alloc(uint32_t vtermno, int data,
struct hv_ops *ops, int outbuf_size);
 /* remove a vterm from hvc tty operation (module_exit or hotplug remove) */
-extern int __devexit hvc_remove(struct hvc_struct *hp);
+extern int hvc_remove(struct hvc_struct *hp);
 
 /* data available */
 int hvc_poll(struct hvc_struct *hp);

-- 
Hendrik Brueckner
D/3303 Linux on System z Development
Tel: +49 7031 16-1073
Fax: +49 7031 16-3456
eMail: [EMAIL PROTECTED]
IBM Deutschland Research & Development GmbH, Schoenaicher Str. 220, 71032 
Boeblingen

IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Martin Jetter
Geschaeftsfuehrung: Erich Baier
Sitz der Gesellschaft: Boeblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294

___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


[RFC PATCH 0/5] patches for a network-based hvc backend (s390)

2008-10-14 Thread Hendrik Brueckner
Hello,

I work on a network-based hvc console backend for s390 that allows
to get "full-screen" terminal access to z/VM guest machines.
The solution consists of a HVC backend that provides the terminal interface;
and a tool to connect to the terminal via a z/VM specific communication
protocol.

The network-based backend differs in a few aspects from the notifier-based
model of the HVC console; because it has to deal with (dis)connects and must
take care of virtual tty hangups. Therefore, I would like to introduce a third
notifier for hangups (see patch 1).

Further I found out that if put_char() returns 0 in particular cases, the hvc
console starts to loop. I tried to address this problem with patch 3 and I hope
that it will work for all backends.

Finally, I would like to add a function that allows to resize the terminal
window of a HVC terminal (patch 4).


Here is an overview about the complete patch series:
 Patch 1 adds a hangup notifier
 Patch 2 adds tty driver flag TTY_DRIVER_RESET_TERMIOS
 Patch 3 fixes a loop if put_char() returns 0
 Patch 4 adds a function to resize the tty window
 Patch 5 removes __devexit of hvc_remove() for use in __(dev)init sections


Any review feedback would be greatly appreciated.
Thank you in advance.

Regards,
Hendrik
-- 
Hendrik Brueckner
D/3303 Linux on System z Development
Tel: +49 7031 16-1073
Fax: +49 7031 16-3456
eMail: [EMAIL PROTECTED]
IBM Deutschland Research & Development GmbH, Schoenaicher Str. 220, 71032 
Boeblingen

IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Martin Jetter
Geschaeftsfuehrung: Erich Baier
Sitz der Gesellschaft: Boeblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294

___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


[RFC PATCH 1/5] hvc_console: Adding hangup notifier

2008-10-14 Thread Hendrik Brueckner
From: Hendrik Brueckner <[EMAIL PROTECTED]>

I have added a hangup notifier that can be used by hvc console
backends to handle a tty hangup. The default irq hangup notifier
calls the notifier_del_irq() for compatibility.

Acked-by: Christian Borntraeger <[EMAIL PROTECTED]>
Signed-off-by: Hendrik Brueckner <[EMAIL PROTECTED]>
---
 drivers/char/hvc_console.c|4 ++--
 drivers/char/hvc_console.h|4 +++-
 drivers/char/hvc_irq.c|5 +
 drivers/char/hvc_iseries.c|1 +
 drivers/char/hvc_vio.c|1 +
 drivers/char/hvc_xen.c|1 +
 drivers/char/virtio_console.c |1 +
 7 files changed, 14 insertions(+), 3 deletions(-)

--- a/drivers/char/hvc_console.c2008-10-08 16:08:40.0 +0200
+++ b/drivers/char/hvc_console.c2008-10-09 10:30:13.0 +0200
@@ -416,8 +416,8 @@ static void hvc_hangup(struct tty_struct
hp->n_outbuf = 0;
hp->tty = NULL;
 
-   if (hp->ops->notifier_del)
-   hp->ops->notifier_del(hp, hp->data);
+   if (hp->ops->notifier_hangup)
+   hp->ops->notifier_hangup(hp, hp->data);
 
spin_unlock_irqrestore(&hp->lock, flags);
 
--- a/drivers/char/hvc_console.h2008-10-08 16:08:40.0 +0200
+++ b/drivers/char/hvc_console.h2008-10-09 10:30:13.0 +0200
@@ -65,9 +65,10 @@ struct hv_ops {
int (*get_chars)(uint32_t vtermno, char *buf, int count);
int (*put_chars)(uint32_t vtermno, const char *buf, int count);
 
-   /* Callbacks for notification. Called in open and close */
+   /* Callbacks for notification. Called in open, close and hangup */
int (*notifier_add)(struct hvc_struct *hp, int irq);
void (*notifier_del)(struct hvc_struct *hp, int irq);
+   void (*notifier_hangup)(struct hvc_struct *hp, int irq);
 };
 
 /* Register a vterm and a slot index for use as a console (console_init) */
@@ -86,6 +87,7 @@ void hvc_kick(void);
 /* default notifier for irq based notification */
 extern int notifier_add_irq(struct hvc_struct *hp, int data);
 extern void notifier_del_irq(struct hvc_struct *hp, int data);
+extern void notifier_hangup_irq(struct hvc_struct *hp, int data);
 
 
 #if defined(CONFIG_XMON) && defined(CONFIG_SMP)
--- a/drivers/char/hvc_irq.c2008-10-08 16:08:40.0 +0200
+++ b/drivers/char/hvc_irq.c2008-10-09 10:30:13.0 +0200
@@ -42,3 +42,8 @@ void notifier_del_irq(struct hvc_struct 
free_irq(irq, hp);
hp->irq_requested = 0;
 }
+
+void notifier_hangup_irq(struct hvc_struct *hp, int irq)
+{
+   notifier_del_irq(hp, irq);
+}
--- a/drivers/char/hvc_iseries.c2008-10-08 16:08:40.0 +0200
+++ b/drivers/char/hvc_iseries.c2008-10-09 10:30:13.0 +0200
@@ -202,6 +202,7 @@ static struct hv_ops hvc_get_put_ops = {
.put_chars = put_chars,
.notifier_add = notifier_add_irq,
.notifier_del = notifier_del_irq,
+   .notifier_hangup = notifier_hangup_irq,
 };
 
 static int __devinit hvc_vio_probe(struct vio_dev *vdev,
--- a/drivers/char/hvc_xen.c2008-10-08 16:08:40.0 +0200
+++ b/drivers/char/hvc_xen.c2008-10-09 10:30:13.0 +0200
@@ -102,6 +102,7 @@ static struct hv_ops hvc_ops = {
.put_chars = write_console,
.notifier_add = notifier_add_irq,
.notifier_del = notifier_del_irq,
+   .notifier_hangup = notifier_hangup_irq,
 };
 
 static int __init xen_init(void)
--- a/drivers/char/hvc_vio.c2008-10-08 16:08:40.0 +0200
+++ b/drivers/char/hvc_vio.c2008-10-09 10:30:13.0 +0200
@@ -82,6 +82,7 @@ static struct hv_ops hvc_get_put_ops = {
.put_chars = hvc_put_chars,
.notifier_add = notifier_add_irq,
.notifier_del = notifier_del_irq,
+   .notifier_hangup = notifier_hangup_irq,
 };
 
 static int __devinit hvc_vio_probe(struct vio_dev *vdev,
--- a/drivers/char/virtio_console.c 2008-10-09 10:29:41.0 +0200
+++ b/drivers/char/virtio_console.c 2008-10-09 10:30:23.0 +0200
@@ -198,6 +198,7 @@ static int __devinit virtcons_probe(stru
virtio_cons.put_chars = put_chars;
virtio_cons.notifier_add = notifier_add_vio;
virtio_cons.notifier_del = notifier_del_vio;
+   virtio_cons.notifier_hangup = notifier_del_vio;
 
/* The first argument of hvc_alloc() is the virtual console number, so
     * we use zero.  The second argument is the parameter for the

-- 
Hendrik Brueckner
D/3303 Linux on System z Development
Tel: +49 7031 16-1073
Fax: +49 7031 16-3456
eMail: [EMAIL PROTECTED]
IBM Deutschland Research & Development GmbH, Schoenaicher Str. 220, 71032 
Boeblingen

IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Martin Jetter
Geschaeftsfuehrung: Erich Baier
Sitz der Gesellschaft: Boeblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294