Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1641938 > unrolled thread

[patch v2 6/6] staging: speakup: flush tty buffers and ensure hardware flow control

Started byOkash Khawaja <okash.khawaja@gmail.com>
First post2017-05-15 20:00 +0200
Last post2017-05-16 15:00 +0200
Articles 5 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [patch v2 6/6] staging: speakup: flush tty buffers and ensure hardware flow control Okash Khawaja <okash.khawaja@gmail.com> - 2017-05-15 20:00 +0200
    Re: [patch v2 6/6] staging: speakup: flush tty buffers and ensure  hardware flow control Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-05-16 14:10 +0200
      Re: [patch v2 6/6] staging: speakup: flush tty buffers and ensure  hardware flow control Okash Khawaja <okash.khawaja@gmail.com> - 2017-05-16 14:20 +0200
        Re: [patch v2 6/6] staging: speakup: flush tty buffers and ensure  hardware flow control Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-05-16 14:30 +0200
          Re: [patch v2 6/6] staging: speakup: flush tty buffers and ensure hardware flow control Okash Khawaja <okash.khawaja@gmail.com> - 2017-05-16 15:00 +0200

#1641938 — [patch v2 6/6] staging: speakup: flush tty buffers and ensure hardware flow control

FromOkash Khawaja <okash.khawaja@gmail.com>
Date2017-05-15 20:00 +0200
Subject[patch v2 6/6] staging: speakup: flush tty buffers and ensure hardware flow control
Message-ID<tHsrL-2Pf-7@gated-at.bofh.it>
This patch fixes the issue where TTY-migrated synths would take a while to shut up after hitting numpad enter key. When calling synth_flush, even though XOFF character is sent as high priority, data buffered in TTY layer is still sent to the synth. This patch flushes that buffered data when synth_flush is called.

It also tries to ensure that hardware flow control is enabled, by setting CRTSCTS using tty's termios.

Reported-by: John Covici <covici@ccs.covici.com>
Signed-off-by: Okash Khawaja <okash.khawaja@gmail.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>

Index: linux-staging/drivers/staging/speakup/serialio.c
===================================================================
--- linux-staging.orig/drivers/staging/speakup/serialio.c
+++ linux-staging/drivers/staging/speakup/serialio.c
@@ -30,6 +30,7 @@
 static void spk_serial_tiocmset(unsigned int set, unsigned int clear);
 static unsigned char spk_serial_in(void);
 static unsigned char spk_serial_in_nowait(void);
+static void spk_serial_flush_buffer(void);
 
 struct spk_io_ops spk_serial_io_ops = {
 	.synth_out = spk_serial_out,
@@ -37,6 +38,7 @@
 	.tiocmset = spk_serial_tiocmset,
 	.synth_in = spk_serial_in,
 	.synth_in_nowait = spk_serial_in_nowait,
+	.flush_buffer = spk_serial_flush_buffer,
 };
 EXPORT_SYMBOL_GPL(spk_serial_io_ops);
 
@@ -268,6 +270,11 @@
 	return inb_p(speakup_info.port_tts + UART_RX);
 }
 
+static void spk_serial_flush_buffer(void)
+{
+	/* TODO: flush the UART 16550 buffer */
+}
+
 static int spk_serial_out(struct spk_synth *in_synth, const char ch)
 {
 	if (in_synth->alive && spk_wait_for_xmitr(in_synth)) {
Index: linux-staging/drivers/staging/speakup/spk_ttyio.c
===================================================================
--- linux-staging.orig/drivers/staging/speakup/spk_ttyio.c
+++ linux-staging/drivers/staging/speakup/spk_ttyio.c
@@ -85,6 +85,7 @@
 static void spk_ttyio_tiocmset(unsigned int set, unsigned int clear);
 static unsigned char spk_ttyio_in(void);
 static unsigned char spk_ttyio_in_nowait(void);
+static void spk_ttyio_flush_buffer(void);
 
 struct spk_io_ops spk_ttyio_ops = {
 	.synth_out = spk_ttyio_out,
@@ -92,13 +93,22 @@
 	.tiocmset = spk_ttyio_tiocmset,
 	.synth_in = spk_ttyio_in,
 	.synth_in_nowait = spk_ttyio_in_nowait,
+	.flush_buffer = spk_ttyio_flush_buffer,
 };
 EXPORT_SYMBOL_GPL(spk_ttyio_ops);
 
+static inline void get_termios(struct tty_struct *tty, struct ktermios *out_termios)
+{
+	down_read(&tty->termios_rwsem);
+	*out_termios = tty->termios;
+	up_read(&tty->termios_rwsem);
+}
+
 static int spk_ttyio_initialise_ldisc(int ser)
 {
 	int ret = 0;
 	struct tty_struct *tty;
+	struct ktermios tmp_termios;
 
 	ret = tty_register_ldisc(N_SPEAKUP, &spk_ttyio_ldisc_ops);
 	if (ret) {
@@ -127,6 +137,20 @@
 	}
 
 	clear_bit(TTY_HUPPED, &tty->flags);
+	/* ensure hardware flow control is enabled */
+	get_termios(tty, &tmp_termios);
+	if (!(tmp_termios.c_cflag & CRTSCTS)) {
+		tmp_termios.c_cflag |= CRTSCTS;
+		tty_set_termios(tty, &tmp_termios);
+		/*
+		 * check c_cflag to see if it's updated as tty_set_termios may not return
+		 * error even when no tty bits are changed by the request.
+		 */
+		get_termios(tty, &tmp_termios);
+		if (!(tmp_termios.c_cflag & CRTSCTS))
+			pr_warn("speakup: Failed to set hardware flow control\n");
+	}
+
 	tty_unlock(tty);
 
 	ret = tty_set_ldisc(tty, N_SPEAKUP);
@@ -201,6 +225,11 @@
 	return (rv == 0xff) ? 0 : rv;
 }
 
+static void spk_ttyio_flush_buffer(void)
+{
+	speakup_tty->ops->flush_buffer(speakup_tty);
+}
+
 int spk_ttyio_synth_probe(struct spk_synth *synth)
 {
 	int rv = spk_ttyio_initialise_ldisc(synth->ser);
Index: linux-staging/drivers/staging/speakup/spk_types.h
===================================================================
--- linux-staging.orig/drivers/staging/speakup/spk_types.h
+++ linux-staging/drivers/staging/speakup/spk_types.h
@@ -154,6 +154,7 @@
 	void (*tiocmset)(unsigned int set, unsigned int clear);
 	unsigned char (*synth_in)(void);
 	unsigned char (*synth_in_nowait)(void);
+	void (*flush_buffer)(void);
 };
 
 struct spk_synth {
Index: linux-staging/drivers/staging/speakup/speakup_audptr.c
===================================================================
--- linux-staging.orig/drivers/staging/speakup/speakup_audptr.c
+++ linux-staging/drivers/staging/speakup/speakup_audptr.c
@@ -127,6 +127,7 @@
 
 static void synth_flush(struct spk_synth *synth)
 {
+	synth->io_ops->flush_buffer();
 	synth->io_ops->send_xchar(SYNTH_CLEAR);
 	synth->io_ops->synth_out(synth, PROCSPEECH);
 }
Index: linux-staging/drivers/staging/speakup/speakup_decext.c
===================================================================
--- linux-staging.orig/drivers/staging/speakup/speakup_decext.c
+++ linux-staging/drivers/staging/speakup/speakup_decext.c
@@ -221,6 +221,7 @@
 static void synth_flush(struct spk_synth *synth)
 {
 	in_escape = 0;
+	synth->io_ops->flush_buffer();
 	synth->synth_immediate(synth, "\033P;10z\033\\");
 }
 
Index: linux-staging/drivers/staging/speakup/speakup_dectlk.c
===================================================================
--- linux-staging.orig/drivers/staging/speakup/speakup_dectlk.c
+++ linux-staging/drivers/staging/speakup/speakup_dectlk.c
@@ -293,6 +293,7 @@
 		synth->io_ops->synth_out(synth, ']');
 	in_escape = 0;
 	is_flushing = 1;
+	synth->io_ops->flush_buffer();
 	synth->io_ops->synth_out(synth, SYNTH_CLEAR);
 }
 
Index: linux-staging/drivers/staging/speakup/speakup_spkout.c
===================================================================
--- linux-staging.orig/drivers/staging/speakup/speakup_spkout.c
+++ linux-staging/drivers/staging/speakup/speakup_spkout.c
@@ -125,6 +125,7 @@
 
 static void synth_flush(struct spk_synth *synth)
 {
+	synth->io_ops->flush_buffer();
 	synth->io_ops->send_xchar(SYNTH_CLEAR);
 }
 
Index: linux-staging/drivers/staging/speakup/synth.c
===================================================================
--- linux-staging.orig/drivers/staging/speakup/synth.c
+++ linux-staging/drivers/staging/speakup/synth.c
@@ -120,6 +120,7 @@
 
 void spk_synth_flush(struct spk_synth *synth)
 {
+	synth->io_ops->flush_buffer();
 	synth->io_ops->synth_out(synth, synth->clear);
 }
 EXPORT_SYMBOL_GPL(spk_synth_flush);

[toc] | [next] | [standalone]


#1642472 — Re: [patch v2 6/6] staging: speakup: flush tty buffers and ensure hardware flow control

FromGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Date2017-05-16 14:10 +0200
SubjectRe: [patch v2 6/6] staging: speakup: flush tty buffers and ensure hardware flow control
Message-ID<tHJsC-5rS-23@gated-at.bofh.it>
In reply to#1641938
On Mon, May 15, 2017 at 06:45:37PM +0100, Okash Khawaja wrote:
> This patch fixes the issue where TTY-migrated synths would take a while to shut up after hitting numpad enter key. When calling synth_flush, even though XOFF character is sent as high priority, data buffered in TTY layer is still sent to the synth. This patch flushes that buffered data when synth_flush is called.

Minor nit, please line-wrap your changelog text at 72 columns so that I
don't have to do it "by hand".

> 
> It also tries to ensure that hardware flow control is enabled, by setting CRTSCTS using tty's termios.
> 
> Reported-by: John Covici <covici@ccs.covici.com>
> Signed-off-by: Okash Khawaja <okash.khawaja@gmail.com>
> Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
> 
> Index: linux-staging/drivers/staging/speakup/serialio.c
> ===================================================================

Are you using git?  These lines are odd...

thanks,

greg k-h

[toc] | [prev] | [next] | [standalone]


#1642485 — Re: [patch v2 6/6] staging: speakup: flush tty buffers and ensure hardware flow control

FromOkash Khawaja <okash.khawaja@gmail.com>
Date2017-05-16 14:20 +0200
SubjectRe: [patch v2 6/6] staging: speakup: flush tty buffers and ensure hardware flow control
Message-ID<tHJCi-5vb-35@gated-at.bofh.it>
In reply to#1642472
Hi,

On Tue, May 16, 2017 at 1:00 PM, Greg Kroah-Hartman
<gregkh@linuxfoundation.org> wrote:
> On Mon, May 15, 2017 at 06:45:37PM +0100, Okash Khawaja wrote:
>> This patch fixes the issue where TTY-migrated synths would take a while to shut up after hitting numpad enter key. When calling synth_flush, even though XOFF character is sent as high priority, data buffered in TTY layer is still sent to the synth. This patch flushes that buffered data when synth_flush is called.
>
> Minor nit, please line-wrap your changelog text at 72 columns so that I
> don't have to do it "by hand".
Sure, will do.

>
>>
>> It also tries to ensure that hardware flow control is enabled, by setting CRTSCTS using tty's termios.
>>
>> Reported-by: John Covici <covici@ccs.covici.com>
>> Signed-off-by: Okash Khawaja <okash.khawaja@gmail.com>
>> Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
>>
>> Index: linux-staging/drivers/staging/speakup/serialio.c
>> ===================================================================
>
> Are you using git?  These lines are odd...
They come from quilt. Haven't checked yet if there is an option to
turn them off.

Thanks,
Okash

[toc] | [prev] | [next] | [standalone]


#1642492 — Re: [patch v2 6/6] staging: speakup: flush tty buffers and ensure hardware flow control

FromGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Date2017-05-16 14:30 +0200
SubjectRe: [patch v2 6/6] staging: speakup: flush tty buffers and ensure hardware flow control
Message-ID<tHJLY-5yL-11@gated-at.bofh.it>
In reply to#1642485
On Tue, May 16, 2017 at 01:19:10PM +0100, Okash Khawaja wrote:
> Hi,
> 
> On Tue, May 16, 2017 at 1:00 PM, Greg Kroah-Hartman
> <gregkh@linuxfoundation.org> wrote:
> > On Mon, May 15, 2017 at 06:45:37PM +0100, Okash Khawaja wrote:
> >> This patch fixes the issue where TTY-migrated synths would take a while to shut up after hitting numpad enter key. When calling synth_flush, even though XOFF character is sent as high priority, data buffered in TTY layer is still sent to the synth. This patch flushes that buffered data when synth_flush is called.
> >
> > Minor nit, please line-wrap your changelog text at 72 columns so that I
> > don't have to do it "by hand".
> Sure, will do.
> 
> >
> >>
> >> It also tries to ensure that hardware flow control is enabled, by setting CRTSCTS using tty's termios.
> >>
> >> Reported-by: John Covici <covici@ccs.covici.com>
> >> Signed-off-by: Okash Khawaja <okash.khawaja@gmail.com>
> >> Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
> >>
> >> Index: linux-staging/drivers/staging/speakup/serialio.c
> >> ===================================================================
> >
> > Are you using git?  These lines are odd...
> They come from quilt. Haven't checked yet if there is an option to
> turn them off.

There is, here's what is in my .quiltrc:

QUILT_REFRESH_ARGS="--diffstat --strip-trailing-whitespace --no-timestamps --no-index --sort -p1 -p ab"
QUILT_DIFF_ARGS="--no-timestamps --no-index --sort --color=auto -p ab"
QUILT_DIFF_OPTS="-p"

That will give you the diffstat in the patch as well, which is always
helpful to reviewers.

thanks,

greg k-h

[toc] | [prev] | [next] | [standalone]


#1642547

FromOkash Khawaja <okash.khawaja@gmail.com>
Date2017-05-16 15:00 +0200
Message-ID<tHKf0-5Iw-15@gated-at.bofh.it>
In reply to#1642492
> On 16 May 2017, at 13:28, Greg Kroah-Hartman <gregkh@linuxfoundation.org> wrote:
> 
>> On Tue, May 16, 2017 at 01:19:10PM +0100, Okash Khawaja wrote:
>> Hi,
>> 
>> On Tue, May 16, 2017 at 1:00 PM, Greg Kroah-Hartman
>> <gregkh@linuxfoundation.org> wrote:
>>> On Mon, May 15, 2017 at 06:45:37PM +0100, Okash Khawaja wrote:
>>>> This patch fixes the issue where TTY-migrated synths would take a while to shut up after hitting numpad enter key. When calling synth_flush, even though XOFF character is sent as high priority, data buffered in TTY layer is still sent to the synth. This patch flushes that buffered data when synth_flush is called.
>>> 
>>> Minor nit, please line-wrap your changelog text at 72 columns so that I
>>> don't have to do it "by hand".
>> Sure, will do.
>> 
>>> 
>>>> 
>>>> It also tries to ensure that hardware flow control is enabled, by setting CRTSCTS using tty's termios.
>>>> 
>>>> Reported-by: John Covici <covici@ccs.covici.com>
>>>> Signed-off-by: Okash Khawaja <okash.khawaja@gmail.com>
>>>> Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
>>>> 
>>>> Index: linux-staging/drivers/staging/speakup/serialio.c
>>>> ===================================================================
>>> 
>>> Are you using git?  These lines are odd...
>> They come from quilt. Haven't checked yet if there is an option to
>> turn them off.
> 
> There is, here's what is in my .quiltrc:
> 
> QUILT_REFRESH_ARGS="--diffstat --strip-trailing-whitespace --no-timestamps --no-index --sort -p1 -p ab"
> QUILT_DIFF_ARGS="--no-timestamps --no-index --sort --color=auto -p ab"
> QUILT_DIFF_OPTS="-p"
> 
> That will give you the diffstat in the patch as well, which is always
> helpful to reviewers.

Thanks very much. Will update mine. 

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web