From: Richard Weinberger <richard@nod.at>
To: Jiri Slaby <jslaby@suse.cz>
Cc: gregkh@linuxfoundation.org, alan@linux.intel.com,
linux-kernel@vger.kernel.org, jirislaby@gmail.com,
Jeff Dike <jdike@addtoit.com>,
user-mode-linux-devel@lists.sourceforge.net
Subject: Re: [PATCH 13/24] TTY: um/line, use tty from tty_port
Date: Mon, 04 Jun 2012 14:01:42 +0200 [thread overview]
Message-ID: <4FCCA3A6.8080608@nod.at> (raw)
In-Reply-To: <1338809738-18967-14-git-send-email-jslaby@suse.cz>
[-- Attachment #1: Type: text/plain, Size: 4244 bytes --]
Jiri,
Thanks a lot for fixing this!
I have two questions:
1. Are these patches also usable on 3.4 and 3.3 or do they depend on 3.5's TTY changes?
2. Why didn't you use tty_port_open()/close()/etc. as Alan suggested my in [1]?
Thanks,
//richard
[1] http://lkml.indiana.edu/hypermail/linux/kernel/1201.3/01705.html
Am 04.06.2012 13:35, schrieb Jiri Slaby:
> This means switching to the tty refcounted model so that we will not
> race with interrupts.
>
> Signed-off-by: Jiri Slaby <jslaby@suse.cz>
> Cc: Jeff Dike <jdike@addtoit.com>
> Cc: Richard Weinberger <richard@nod.at>
> Cc: user-mode-linux-devel@lists.sourceforge.net
> ---
> arch/um/drivers/chan_kern.c | 4 +++-
> arch/um/drivers/line.c | 25 ++++++++++++++++++-------
> arch/um/drivers/line.h | 1 -
> 3 files changed, 21 insertions(+), 9 deletions(-)
>
> diff --git a/arch/um/drivers/chan_kern.c b/arch/um/drivers/chan_kern.c
> index 45e248c..87eebfe 100644
> --- a/arch/um/drivers/chan_kern.c
> +++ b/arch/um/drivers/chan_kern.c
> @@ -150,9 +150,11 @@ void chan_enable_winch(struct chan *chan, struct tty_struct *tty)
> static void line_timer_cb(struct work_struct *work)
> {
> struct line *line = container_of(work, struct line, task.work);
> + struct tty_struct *tty = tty_port_tty_get(&line->port);
>
> if (!line->throttled)
> - chan_interrupt(line, line->tty, line->driver->read_irq);
> + chan_interrupt(line, tty, line->driver->read_irq);
> + tty_kref_put(tty);
> }
>
> int enable_chan(struct line *line)
> diff --git a/arch/um/drivers/line.c b/arch/um/drivers/line.c
> index 482a7bd..fb6e4ea 100644
> --- a/arch/um/drivers/line.c
> +++ b/arch/um/drivers/line.c
> @@ -19,9 +19,11 @@ static irqreturn_t line_interrupt(int irq, void *data)
> {
> struct chan *chan = data;
> struct line *line = chan->line;
> + struct tty_struct *tty = tty_port_tty_get(&line->port);
>
> if (line)
> - chan_interrupt(line, line->tty, irq);
> + chan_interrupt(line, tty, irq);
> + tty_kref_put(tty);
> return IRQ_HANDLED;
> }
>
> @@ -333,7 +335,7 @@ static irqreturn_t line_write_interrupt(int irq, void *data)
> {
> struct chan *chan = data;
> struct line *line = chan->line;
> - struct tty_struct *tty = line->tty;
> + struct tty_struct *tty;
> int err;
>
> /*
> @@ -352,10 +354,13 @@ static irqreturn_t line_write_interrupt(int irq, void *data)
> }
> spin_unlock(&line->lock);
>
> + tty = tty_port_tty_get(&line->port);
> if (tty == NULL)
> return IRQ_NONE;
>
> tty_wakeup(tty);
> + tty_kref_put(tty);
> +
> return IRQ_HANDLED;
> }
>
> @@ -409,7 +414,7 @@ int line_open(struct line *lines, struct tty_struct *tty)
>
> BUG_ON(tty->driver_data);
> tty->driver_data = line;
> - line->tty = tty;
> + tty_port_tty_set(&line->port, tty);
>
> err = enable_chan(line);
> if (err) /* line_close() will be called by our caller */
> @@ -449,7 +454,7 @@ void line_close(struct tty_struct *tty, struct file * filp)
> if (--line->port.count)
> goto out_unlock;
>
> - line->tty = NULL;
> + tty_port_tty_set(&line->port, NULL);
> tty->driver_data = NULL;
>
> if (line->sigio) {
> @@ -610,9 +615,15 @@ int line_get_config(char *name, struct line *lines, unsigned int num, char *str,
> mutex_lock(&line->count_lock);
> if (!line->valid)
> CONFIG_CHUNK(str, size, n, "none", 1);
> - else if (line->tty == NULL)
> - CONFIG_CHUNK(str, size, n, line->init_str, 1);
> - else n = chan_config_string(line, str, size, error_out);
> + else {
> + struct tty_struct *tty = tty_port_tty_get(&line->port);
> + if (tty == NULL) {
> + CONFIG_CHUNK(str, size, n, line->init_str, 1);
> + } else {
> + n = chan_config_string(line, str, size, error_out);
> + tty_kref_put(tty);
> + }
> + }
> mutex_unlock(&line->count_lock);
>
> return n;
> diff --git a/arch/um/drivers/line.h b/arch/um/drivers/line.h
> index 0e06a1f..5b3d4fb 100644
> --- a/arch/um/drivers/line.h
> +++ b/arch/um/drivers/line.h
> @@ -33,7 +33,6 @@ struct line_driver {
>
> struct line {
> struct tty_port port;
> - struct tty_struct *tty;
> struct mutex count_lock;
> int valid;
>
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 490 bytes --]
next prev parent reply other threads:[~2012-06-04 12:01 UTC|newest]
Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-04 11:35 [PATCH 00/25] TTY buffer in tty_port -- prep no. 3 Jiri Slaby
2012-06-04 11:35 ` [PATCH 01/24] TTY: cyclades, add local pointer for card Jiri Slaby
2012-06-04 11:35 ` [PATCH 02/24] TTY: ircomm, add tty_port Jiri Slaby
2012-06-04 11:35 ` [PATCH 03/24] TTY: ircomm, use close times from tty_port Jiri Slaby
2012-06-04 11:35 ` [PATCH 04/24] TTY: ircomm, use open counts " Jiri Slaby
2012-06-04 16:36 ` Alan Cox
2012-06-04 11:35 ` [PATCH 05/24] TTY: ircomm, use flags " Jiri Slaby
2012-06-04 11:35 ` [PATCH 06/24] TTY: ircomm, revamp locking Jiri Slaby
2012-06-04 16:57 ` Alan Cox
2012-06-04 11:35 ` [PATCH 07/24] TTY: ircomm, use tty from tty_port Jiri Slaby
2012-06-04 11:35 ` [PATCH 08/24] TTY: ircomm, define local tty_port Jiri Slaby
2012-06-04 11:35 ` [PATCH 09/24] TTY: ircomm, define carrier routines Jiri Slaby
2012-06-04 11:35 ` [PATCH 10/24] TTY: ircomm, use tty_port_close_end helper Jiri Slaby
2012-06-04 11:35 ` [PATCH 11/24] TTY: ircomm, use tty_port_close_start helper Jiri Slaby
2012-06-04 11:35 ` [PATCH 12/24] TTY: um/line, add tty_port Jiri Slaby
2012-06-04 11:35 ` [PATCH 13/24] TTY: um/line, use tty from tty_port Jiri Slaby
2012-06-04 12:01 ` Richard Weinberger [this message]
2012-06-04 15:20 ` Jiri Slaby
2012-06-04 15:29 ` Richard Weinberger
2012-06-04 15:41 ` Jiri Slaby
2012-06-04 15:42 ` Richard Weinberger
2012-06-04 16:27 ` [uml-devel] " Boaz Harrosh
2012-06-04 16:27 ` Boaz Harrosh
2012-06-04 16:29 ` Richard Weinberger
2012-06-04 16:37 ` Boaz Harrosh
2012-06-04 16:37 ` Boaz Harrosh
2012-06-04 16:55 ` Boaz Harrosh
2012-06-04 16:55 ` Boaz Harrosh
2012-06-04 17:05 ` Richard Weinberger
2012-06-04 17:14 ` Boaz Harrosh
2012-06-04 17:14 ` Boaz Harrosh
2012-06-04 15:58 ` Alan Cox
2012-06-04 15:58 ` Alan Cox
2012-06-04 11:35 ` [PATCH 14/24] PTY: remove one empty ops->remove Jiri Slaby
2012-06-04 11:35 ` [PATCH 15/24] PTY: merge pty_install implementations Jiri Slaby
2012-06-04 11:35 ` [PATCH 16/24] PTY: add tty_port Jiri Slaby
2012-06-12 22:55 ` Greg KH
2012-06-14 0:29 ` Greg KH
2012-06-14 0:31 ` Greg KH
2012-06-04 11:35 ` [PATCH 17/24] TTY: vt, remove con_schedule_flip Jiri Slaby
2012-06-04 11:35 ` [PATCH 18/24] TTY: provide drivers with tty_port_install Jiri Slaby
2012-06-04 11:35 ` [PATCH 19/24] TTY: vt, add ->install Jiri Slaby
2012-06-04 11:35 ` [PATCH 20/24] TTY: usb-serial, use tty_port_install Jiri Slaby
2012-06-04 11:35 ` [PATCH 21/24] TTY: centralize fail paths in tty_register_driver Jiri Slaby
2012-06-04 11:35 ` [PATCH 22/24] TTY: add ports array to tty_driver Jiri Slaby
2012-06-04 11:35 ` [PATCH 23/24] TTY: add tty_port_register_device helper Jiri Slaby
2012-06-04 11:35 ` [PATCH 24/24] TTY: use tty_port_register_device Jiri Slaby
2012-06-04 17:00 ` Alan Cox
2012-06-09 14:58 ` Jiri Slaby
2012-06-09 17:27 ` Greg KH
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=4FCCA3A6.8080608@nod.at \
--to=richard@nod.at \
--cc=alan@linux.intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=jdike@addtoit.com \
--cc=jirislaby@gmail.com \
--cc=jslaby@suse.cz \
--cc=linux-kernel@vger.kernel.org \
--cc=user-mode-linux-devel@lists.sourceforge.net \
/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.