linux-serial.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* (unknown), 
@ 2012-03-04 17:59 Matthieu CASTET
  2012-03-04 17:59 ` [PATCH 1/9] tty: make receive_buf() return the amout of bytes received Matthieu CASTET
                   ` (8 more replies)
  0 siblings, 9 replies; 64+ messages in thread
From: Matthieu CASTET @ 2012-03-04 17:59 UTC (permalink / raw)
  To: Alan Cox, linux-serial, Felipe Balbi, Toby Gray, Stefan Bigler

Subject: [RFC] tty : make receive_room internal to N_TTY line discipline
In-Reply-To:

This patch try to solve issue exposed on https://lkml.org/lkml/2011/6/7/700

On Tue, Jun 07, 2011 at 07:44:48PM -0700, Linus Torvalds wrote
> I'd love to get rid of receive_room entirely - and just letting the
> tty line discipline handler say how much it actually received. in
> other words, having receive_buf() just tell us how much it used, and
> not looking at receive_room in the caller is absolutely the right
> thing.



^ permalink raw reply	[flat|nested] 64+ messages in thread

* [PATCH 1/9] tty: make receive_buf() return the amout of bytes received
  2012-03-04 17:59 (unknown), Matthieu CASTET
@ 2012-03-04 17:59 ` Matthieu CASTET
  2012-03-05 10:40   ` Alan Cox
  2012-03-04 17:59 ` [PATCH 2/9] tty : make n_tty_receive_buf return bytes received in raw mode Matthieu CASTET
                   ` (7 subsequent siblings)
  8 siblings, 1 reply; 64+ messages in thread
From: Matthieu CASTET @ 2012-03-04 17:59 UTC (permalink / raw)
  To: Alan Cox, linux-serial, Felipe Balbi, Toby Gray, Stefan Bigler
  Cc: Matthieu CASTET

it makes it simpler to keep track of the amount of bytes received.

For a first step, will always return that we received everything.
This make sure to we don't break anything when we will check receive_buf
return value.

Some code is based on b1c43f82c5aa265442f82dba31ce985ebb7aa71c reverted
commit.

Signed-off-by: Matthieu CASTET <castet.matthieu@free.fr>
---
 drivers/bluetooth/hci_ldisc.c      |   11 +++++++----
 drivers/input/serio/serport.c      |    9 +++++++--
 drivers/isdn/gigaset/ser-gigaset.c |    8 +++++---
 drivers/misc/ti-st/st_core.c       |    6 ++++--
 drivers/net/caif/caif_serial.c     |   10 ++++++----
 drivers/net/can/slcan.c            |    9 ++++++---
 drivers/net/hamradio/6pack.c       |   11 ++++++-----
 drivers/net/hamradio/mkiss.c       |   11 +++++++----
 drivers/net/irda/irtty-sir.c       |   16 +++++++++-------
 drivers/net/ppp/ppp_async.c        |    6 ++++--
 drivers/net/ppp/ppp_synctty.c      |    6 ++++--
 drivers/net/slip/slip.c            |    7 +++++--
 drivers/net/wan/x25_asy.c          |    9 ++++++---
 drivers/tty/n_gsm.c                |    6 ++++--
 drivers/tty/n_hdlc.c               |   18 ++++++++++--------
 drivers/tty/n_r3964.c              |   10 ++++++----
 drivers/tty/n_tracerouter.c        |    4 +++-
 drivers/tty/n_tty.c                |    6 ++++--
 include/linux/tty_ldisc.h          |    9 +++++----
 sound/soc/omap/ams-delta.c         |    7 ++++---
 20 files changed, 112 insertions(+), 67 deletions(-)

diff --git a/drivers/bluetooth/hci_ldisc.c b/drivers/bluetooth/hci_ldisc.c
index 0711448..47b97a8 100644
--- a/drivers/bluetooth/hci_ldisc.c
+++ b/drivers/bluetooth/hci_ldisc.c
@@ -355,17 +355,18 @@ static void hci_uart_tty_wakeup(struct tty_struct *tty)
  *             flags        pointer to flags for data
  *             count        count of received data in bytes
  *     
- * Return Value:    None
+ * Return Value:    bytes received.
  */
-static void hci_uart_tty_receive(struct tty_struct *tty, const u8 *data, char *flags, int count)
+static int hci_uart_tty_receive(struct tty_struct *tty,
+		const u8 *data, char *flags, int count)
 {
 	struct hci_uart *hu = (void *)tty->disc_data;
 
 	if (!hu || tty != hu->tty)
-		return;
+		return count;
 
 	if (!test_bit(HCI_UART_PROTO_SET, &hu->flags))
-		return;
+		return count;
 
 	spin_lock(&hu->rx_lock);
 	hu->proto->recv(hu, (void *) data, count);
@@ -373,6 +374,8 @@ static void hci_uart_tty_receive(struct tty_struct *tty, const u8 *data, char *f
 	spin_unlock(&hu->rx_lock);
 
 	tty_unthrottle(tty);
+
+	return count;
 }
 
 static int hci_uart_register_dev(struct hci_uart *hu)
diff --git a/drivers/input/serio/serport.c b/drivers/input/serio/serport.c
index 8755f5f..657043a 100644
--- a/drivers/input/serio/serport.c
+++ b/drivers/input/serio/serport.c
@@ -120,17 +120,20 @@ static void serport_ldisc_close(struct tty_struct *tty)
  * 'interrupt' routine.
  */
 
-static void serport_ldisc_receive(struct tty_struct *tty, const unsigned char *cp, char *fp, int count)
+static int serport_ldisc_receive(struct tty_struct *tty,
+		const unsigned char *cp, char *fp, int count)
 {
 	struct serport *serport = (struct serport*) tty->disc_data;
 	unsigned long flags;
 	unsigned int ch_flags;
+	int ret = 0;
 	int i;
 
 	spin_lock_irqsave(&serport->lock, flags);
 
-	if (!test_bit(SERPORT_ACTIVE, &serport->flags))
+	if (!test_bit(SERPORT_ACTIVE, &serport->flags)) {
 		goto out;
+	}
 
 	for (i = 0; i < count; i++) {
 		switch (fp[i]) {
@@ -152,6 +155,8 @@ static void serport_ldisc_receive(struct tty_struct *tty, const unsigned char *c
 
 out:
 	spin_unlock_irqrestore(&serport->lock, flags);
+
+	return count;
 }
 
 /*
diff --git a/drivers/isdn/gigaset/ser-gigaset.c b/drivers/isdn/gigaset/ser-gigaset.c
index 86a5c4f..569712a 100644
--- a/drivers/isdn/gigaset/ser-gigaset.c
+++ b/drivers/isdn/gigaset/ser-gigaset.c
@@ -674,7 +674,7 @@ gigaset_tty_ioctl(struct tty_struct *tty, struct file *file,
  *	cflags	buffer containing error flags for received characters (ignored)
  *	count	number of received characters
  */
-static void
+static int
 gigaset_tty_receive(struct tty_struct *tty, const unsigned char *buf,
 		    char *cflags, int count)
 {
@@ -683,12 +683,12 @@ gigaset_tty_receive(struct tty_struct *tty, const unsigned char *buf,
 	struct inbuf_t *inbuf;
 
 	if (!cs)
-		return;
+		return count;
 	inbuf = cs->inbuf;
 	if (!inbuf) {
 		dev_err(cs->dev, "%s: no inbuf\n", __func__);
 		cs_put(cs);
-		return;
+		return count;
 	}
 
 	tail = inbuf->tail;
@@ -725,6 +725,8 @@ gigaset_tty_receive(struct tty_struct *tty, const unsigned char *buf,
 	gig_dbg(DEBUG_INTR, "%s-->BH", __func__);
 	gigaset_schedule_event(cs);
 	cs_put(cs);
+
+	return count;
 }
 
 /*
diff --git a/drivers/misc/ti-st/st_core.c b/drivers/misc/ti-st/st_core.c
index 2b62232..bc3f61c 100644
--- a/drivers/misc/ti-st/st_core.c
+++ b/drivers/misc/ti-st/st_core.c
@@ -765,8 +765,8 @@ static void st_tty_close(struct tty_struct *tty)
 	pr_debug("%s: done ", __func__);
 }
 
-static void st_tty_receive(struct tty_struct *tty, const unsigned char *data,
-			   char *tty_flags, int count)
+static int st_tty_receive(struct tty_struct *tty,
+		const unsigned char *data, char *tty_flags, int count)
 {
 #ifdef VERBOSE
 	print_hex_dump(KERN_DEBUG, ">in>", DUMP_PREFIX_NONE,
@@ -779,6 +779,8 @@ static void st_tty_receive(struct tty_struct *tty, const unsigned char *data,
 	 */
 	st_recv(tty->disc_data, data, count);
 	pr_debug("done %s", __func__);
+
+	return count;
 }
 
 /* wake-up function called in from the TTY layer
diff --git a/drivers/net/caif/caif_serial.c b/drivers/net/caif/caif_serial.c
index 8a3054b..d801d6e 100644
--- a/drivers/net/caif/caif_serial.c
+++ b/drivers/net/caif/caif_serial.c
@@ -167,8 +167,8 @@ static inline void debugfs_tx(struct ser_device *ser, const u8 *data, int size)
 
 #endif
 
-static void ldisc_receive(struct tty_struct *tty, const u8 *data,
-			char *flags, int count)
+static int ldisc_receive(struct tty_struct *tty,
+		const u8 *data, char *flags, int count)
 {
 	struct sk_buff *skb = NULL;
 	struct ser_device *ser;
@@ -191,7 +191,7 @@ static void ldisc_receive(struct tty_struct *tty, const u8 *data,
 		dev_info(&ser->dev->dev,
 			"Bytes received before initial transmission -"
 			"bytes discarded.\n");
-		return;
+		return count;
 	}
 
 	BUG_ON(ser->dev == NULL);
@@ -199,7 +199,7 @@ static void ldisc_receive(struct tty_struct *tty, const u8 *data,
 	/* Get a suitable caif packet and copy in data. */
 	skb = netdev_alloc_skb(ser->dev, count+1);
 	if (skb == NULL)
-		return;
+		return count;
 	p = skb_put(skb, count);
 	memcpy(p, data, count);
 
@@ -215,6 +215,8 @@ static void ldisc_receive(struct tty_struct *tty, const u8 *data,
 	} else
 		++ser->dev->stats.rx_dropped;
 	update_tty_status(ser);
+
+	return count;
 }
 
 static int handle_tx(struct ser_device *ser)
diff --git a/drivers/net/can/slcan.c b/drivers/net/can/slcan.c
index 3f1ebcc..3229e30 100644
--- a/drivers/net/can/slcan.c
+++ b/drivers/net/can/slcan.c
@@ -403,16 +403,17 @@ static void slc_setup(struct net_device *dev)
  * in parallel
  */
 
-static void slcan_receive_buf(struct tty_struct *tty,
+static int slcan_receive_buf(struct tty_struct *tty,
 			      const unsigned char *cp, char *fp, int count)
 {
 	struct slcan *sl = (struct slcan *) tty->disc_data;
+	int bytes = count;
 
 	if (!sl || sl->magic != SLCAN_MAGIC || !netif_running(sl->dev))
-		return;
+		return count;
 
 	/* Read the characters out of the buffer */
-	while (count--) {
+	while (bytes--) {
 		if (fp && *fp++) {
 			if (!test_and_set_bit(SLF_ERROR, &sl->flags))
 				sl->dev->stats.rx_errors++;
@@ -421,6 +422,8 @@ static void slcan_receive_buf(struct tty_struct *tty,
 		}
 		slcan_unesc(sl, *cp++);
 	}
+
+	return count;
 }
 
 /************************************
diff --git a/drivers/net/hamradio/6pack.c b/drivers/net/hamradio/6pack.c
index 2a5a34d..39ad8fe 100644
--- a/drivers/net/hamradio/6pack.c
+++ b/drivers/net/hamradio/6pack.c
@@ -456,25 +456,24 @@ out:
  * a block of 6pack data has been received, which can now be decapsulated
  * and sent on to some IP layer for further processing.
  */
-static void sixpack_receive_buf(struct tty_struct *tty,
+static int sixpack_receive_buf(struct tty_struct *tty,
 	const unsigned char *cp, char *fp, int count)
 {
 	struct sixpack *sp;
 	unsigned char buf[512];
-	int count1;
+	int received = count;
 
 	if (!count)
-		return;
+		return 0;
 
 	sp = sp_get(tty);
 	if (!sp)
-		return;
+		return count;
 
 	memcpy(buf, cp, count < sizeof(buf) ? count : sizeof(buf));
 
 	/* Read the characters out of the buffer */
 
-	count1 = count;
 	while (count) {
 		count--;
 		if (fp && *fp++) {
@@ -487,6 +486,8 @@ static void sixpack_receive_buf(struct tty_struct *tty,
 
 	sp_put(sp);
 	tty_unthrottle(tty);
+
+	return received;
 }
 
 /*
diff --git a/drivers/net/hamradio/mkiss.c b/drivers/net/hamradio/mkiss.c
index bc02968..75173ca 100644
--- a/drivers/net/hamradio/mkiss.c
+++ b/drivers/net/hamradio/mkiss.c
@@ -923,13 +923,14 @@ static long mkiss_compat_ioctl(struct tty_struct *tty, struct file *file,
  * a block of data has been received, which can now be decapsulated
  * and sent on to the AX.25 layer for further processing.
  */
-static void mkiss_receive_buf(struct tty_struct *tty, const unsigned char *cp,
-	char *fp, int count)
+static int mkiss_receive_buf(struct tty_struct *tty,
+		const unsigned char *cp, char *fp, int count)
 {
 	struct mkiss *ax = mkiss_get(tty);
+	int bytes = count;
 
 	if (!ax)
-		return;
+		return count;
 
 	/*
 	 * Argh! mtu change time! - costs us the packet part received
@@ -939,7 +940,7 @@ static void mkiss_receive_buf(struct tty_struct *tty, const unsigned char *cp,
 		ax_changedmtu(ax);
 
 	/* Read the characters out of the buffer */
-	while (count--) {
+	while (bytes--) {
 		if (fp != NULL && *fp++) {
 			if (!test_and_set_bit(AXF_ERROR, &ax->flags))
 				ax->dev->stats.rx_errors++;
@@ -952,6 +953,8 @@ static void mkiss_receive_buf(struct tty_struct *tty, const unsigned char *cp,
 
 	mkiss_put(ax);
 	tty_unthrottle(tty);
+
+	return count;
 }
 
 /*
diff --git a/drivers/net/irda/irtty-sir.c b/drivers/net/irda/irtty-sir.c
index 3352b24..3166e91 100644
--- a/drivers/net/irda/irtty-sir.c
+++ b/drivers/net/irda/irtty-sir.c
@@ -216,23 +216,23 @@ static int irtty_do_write(struct sir_dev *dev, const unsigned char *ptr, size_t
  * usbserial:	urb-complete-interrupt / softint
  */
 
-static void irtty_receive_buf(struct tty_struct *tty, const unsigned char *cp,
-			      char *fp, int count) 
+static int irtty_receive_buf(struct tty_struct *tty,
+		const unsigned char *cp, char *fp, int count)
 {
 	struct sir_dev *dev;
 	struct sirtty_cb *priv = tty->disc_data;
 	int	i;
 
-	IRDA_ASSERT(priv != NULL, return;);
-	IRDA_ASSERT(priv->magic == IRTTY_MAGIC, return;);
+	IRDA_ASSERT(priv != NULL, return count;);
+	IRDA_ASSERT(priv->magic == IRTTY_MAGIC, return count;);
 
 	if (unlikely(count==0))		/* yes, this happens */
-		return;
+		return 0;
 
 	dev = priv->dev;
 	if (!dev) {
 		IRDA_WARNING("%s(), not ready yet!\n", __func__);
-		return;
+		return count;
 	}
 
 	for (i = 0; i < count; i++) {
@@ -242,11 +242,13 @@ static void irtty_receive_buf(struct tty_struct *tty, const unsigned char *cp,
  		if (fp && *fp++) { 
 			IRDA_DEBUG(0, "Framing or parity error!\n");
 			sirdev_receive(dev, NULL, 0);	/* notify sir_dev (updating stats) */
-			return;
+			return count;
  		}
 	}
 
 	sirdev_receive(dev, cp, count);
+
+	return count;
 }
 
 /*
diff --git a/drivers/net/ppp/ppp_async.c b/drivers/net/ppp/ppp_async.c
index c6ba643..aefd499 100644
--- a/drivers/net/ppp/ppp_async.c
+++ b/drivers/net/ppp/ppp_async.c
@@ -341,7 +341,7 @@ ppp_asynctty_poll(struct tty_struct *tty, struct file *file, poll_table *wait)
 }
 
 /* May sleep, don't call from interrupt level or with interrupts disabled */
-static void
+static int
 ppp_asynctty_receive(struct tty_struct *tty, const unsigned char *buf,
 		  char *cflags, int count)
 {
@@ -349,7 +349,7 @@ ppp_asynctty_receive(struct tty_struct *tty, const unsigned char *buf,
 	unsigned long flags;
 
 	if (!ap)
-		return;
+		return count;
 	spin_lock_irqsave(&ap->recv_lock, flags);
 	ppp_async_input(ap, buf, cflags, count);
 	spin_unlock_irqrestore(&ap->recv_lock, flags);
@@ -357,6 +357,8 @@ ppp_asynctty_receive(struct tty_struct *tty, const unsigned char *buf,
 		tasklet_schedule(&ap->tsk);
 	ap_put(ap);
 	tty_unthrottle(tty);
+
+	return count;
 }
 
 static void
diff --git a/drivers/net/ppp/ppp_synctty.c b/drivers/net/ppp/ppp_synctty.c
index 736a39e..248ece3 100644
--- a/drivers/net/ppp/ppp_synctty.c
+++ b/drivers/net/ppp/ppp_synctty.c
@@ -382,7 +382,7 @@ ppp_sync_poll(struct tty_struct *tty, struct file *file, poll_table *wait)
 }
 
 /* May sleep, don't call from interrupt level or with interrupts disabled */
-static void
+static int
 ppp_sync_receive(struct tty_struct *tty, const unsigned char *buf,
 		  char *cflags, int count)
 {
@@ -390,7 +390,7 @@ ppp_sync_receive(struct tty_struct *tty, const unsigned char *buf,
 	unsigned long flags;
 
 	if (!ap)
-		return;
+		return count;
 	spin_lock_irqsave(&ap->recv_lock, flags);
 	ppp_sync_input(ap, buf, cflags, count);
 	spin_unlock_irqrestore(&ap->recv_lock, flags);
@@ -398,6 +398,8 @@ ppp_sync_receive(struct tty_struct *tty, const unsigned char *buf,
 		tasklet_schedule(&ap->tsk);
 	sp_put(ap);
 	tty_unthrottle(tty);
+
+	return count;
 }
 
 static void
diff --git a/drivers/net/slip/slip.c b/drivers/net/slip/slip.c
index ba08341..b9e7156 100644
--- a/drivers/net/slip/slip.c
+++ b/drivers/net/slip/slip.c
@@ -668,13 +668,14 @@ static void sl_setup(struct net_device *dev)
  * in parallel
  */
 
-static void slip_receive_buf(struct tty_struct *tty, const unsigned char *cp,
+static int slip_receive_buf(struct tty_struct *tty, const unsigned char *cp,
 							char *fp, int count)
 {
 	struct slip *sl = tty->disc_data;
+	int received = count;
 
 	if (!sl || sl->magic != SLIP_MAGIC || !netif_running(sl->dev))
-		return;
+		return count;
 
 	/* Read the characters out of the buffer */
 	while (count--) {
@@ -691,6 +692,8 @@ static void slip_receive_buf(struct tty_struct *tty, const unsigned char *cp,
 #endif
 			slip_unesc(sl, *cp++);
 	}
+
+	return received;
 }
 
 /************************************
diff --git a/drivers/net/wan/x25_asy.c b/drivers/net/wan/x25_asy.c
index 8a10bb7..3b07835 100644
--- a/drivers/net/wan/x25_asy.c
+++ b/drivers/net/wan/x25_asy.c
@@ -516,17 +516,18 @@ static int x25_asy_close(struct net_device *dev)
  * and sent on to some IP layer for further processing.
  */
 
-static void x25_asy_receive_buf(struct tty_struct *tty,
+static int x25_asy_receive_buf(struct tty_struct *tty,
 				const unsigned char *cp, char *fp, int count)
 {
 	struct x25_asy *sl = tty->disc_data;
+	int bytes = count;
 
 	if (!sl || sl->magic != X25_ASY_MAGIC || !netif_running(sl->dev))
-		return;
+		return count;
 
 
 	/* Read the characters out of the buffer */
-	while (count--) {
+	while (bytes--) {
 		if (fp && *fp++) {
 			if (!test_and_set_bit(SLF_ERROR, &sl->flags))
 				sl->dev->stats.rx_errors++;
@@ -535,6 +536,8 @@ static void x25_asy_receive_buf(struct tty_struct *tty,
 		}
 		x25_asy_unesc(sl, *cp++);
 	}
+
+	return count;
 }
 
 /*
diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
index fc7bbba..f8133a4 100644
--- a/drivers/tty/n_gsm.c
+++ b/drivers/tty/n_gsm.c
@@ -2246,8 +2246,8 @@ static void gsmld_detach_gsm(struct tty_struct *tty, struct gsm_mux *gsm)
 	gsm->tty = NULL;
 }
 
-static void gsmld_receive_buf(struct tty_struct *tty, const unsigned char *cp,
-			      char *fp, int count)
+static int gsmld_receive_buf(struct tty_struct *tty,
+		const unsigned char *cp, char *fp, int count)
 {
 	struct gsm_mux *gsm = tty->disc_data;
 	const unsigned char *dp;
@@ -2280,6 +2280,8 @@ static void gsmld_receive_buf(struct tty_struct *tty, const unsigned char *cp,
 	}
 	/* FASYNC if needed ? */
 	/* If clogged call tty_throttle(tty); */
+
+	return count;
 }
 
 /**
diff --git a/drivers/tty/n_hdlc.c b/drivers/tty/n_hdlc.c
index a09ce3e..f74ef15 100644
--- a/drivers/tty/n_hdlc.c
+++ b/drivers/tty/n_hdlc.c
@@ -188,8 +188,8 @@ static unsigned int n_hdlc_tty_poll(struct tty_struct *tty, struct file *filp,
 				    poll_table *wait);
 static int n_hdlc_tty_open(struct tty_struct *tty);
 static void n_hdlc_tty_close(struct tty_struct *tty);
-static void n_hdlc_tty_receive(struct tty_struct *tty, const __u8 *cp,
-			       char *fp, int count);
+static int n_hdlc_tty_receive(struct tty_struct *tty,
+		const __u8 *cp, char *fp, int count);
 static void n_hdlc_tty_wakeup(struct tty_struct *tty);
 
 #define bset(p,b)	((p)[(b) >> 5] |= (1 << ((b) & 0x1f)))
@@ -509,8 +509,8 @@ static void n_hdlc_tty_wakeup(struct tty_struct *tty)
  * Called by tty low level driver when receive data is available. Data is
  * interpreted as one HDLC frame.
  */
-static void n_hdlc_tty_receive(struct tty_struct *tty, const __u8 *data,
-			       char *flags, int count)
+static int n_hdlc_tty_receive(struct tty_struct *tty,
+		const __u8 *data, char *flags, int count)
 {
 	register struct n_hdlc *n_hdlc = tty2n_hdlc (tty);
 	register struct n_hdlc_buf *buf;
@@ -521,20 +521,20 @@ static void n_hdlc_tty_receive(struct tty_struct *tty, const __u8 *data,
 		
 	/* This can happen if stuff comes in on the backup tty */
 	if (!n_hdlc || tty != n_hdlc->tty)
-		return;
+		return count;
 		
 	/* verify line is using HDLC discipline */
 	if (n_hdlc->magic != HDLC_MAGIC) {
 		printk("%s(%d) line not using HDLC discipline\n",
 			__FILE__,__LINE__);
-		return;
+		return count;
 	}
 	
 	if ( count>maxframe ) {
 		if (debuglevel >= DEBUG_LEVEL_INFO)	
 			printk("%s(%d) rx count>maxframesize, data discarded\n",
 			       __FILE__,__LINE__);
-		return;
+		return count;
 	}
 
 	/* get a free HDLC buffer */	
@@ -550,7 +550,7 @@ static void n_hdlc_tty_receive(struct tty_struct *tty, const __u8 *data,
 		if (debuglevel >= DEBUG_LEVEL_INFO)	
 			printk("%s(%d) no more rx buffers, data discarded\n",
 			       __FILE__,__LINE__);
-		return;
+		return count;
 	}
 		
 	/* copy received data to HDLC buffer */
@@ -565,6 +565,8 @@ static void n_hdlc_tty_receive(struct tty_struct *tty, const __u8 *data,
 	if (n_hdlc->tty->fasync != NULL)
 		kill_fasync (&n_hdlc->tty->fasync, SIGIO, POLL_IN);
 
+	return count;
+
 }	/* end of n_hdlc_tty_receive() */
 
 /**
diff --git a/drivers/tty/n_r3964.c b/drivers/tty/n_r3964.c
index 5c6c314..43384b3 100644
--- a/drivers/tty/n_r3964.c
+++ b/drivers/tty/n_r3964.c
@@ -139,8 +139,8 @@ static int r3964_ioctl(struct tty_struct *tty, struct file *file,
 static void r3964_set_termios(struct tty_struct *tty, struct ktermios *old);
 static unsigned int r3964_poll(struct tty_struct *tty, struct file *file,
 		struct poll_table_struct *wait);
-static void r3964_receive_buf(struct tty_struct *tty, const unsigned char *cp,
-		char *fp, int count);
+static int r3964_receive_buf(struct tty_struct *tty,
+		const unsigned char *cp, char *fp, int count);
 
 static struct tty_ldisc_ops tty_ldisc_N_R3964 = {
 	.owner = THIS_MODULE,
@@ -1239,8 +1239,8 @@ static unsigned int r3964_poll(struct tty_struct *tty, struct file *file,
 	return result;
 }
 
-static void r3964_receive_buf(struct tty_struct *tty, const unsigned char *cp,
-			char *fp, int count)
+static int r3964_receive_buf(struct tty_struct *tty,
+		const unsigned char *cp, char *fp, int count)
 {
 	struct r3964_info *pInfo = tty->disc_data;
 	const unsigned char *p;
@@ -1257,6 +1257,8 @@ static void r3964_receive_buf(struct tty_struct *tty, const unsigned char *cp,
 		}
 
 	}
+
+	return count;
 }
 
 MODULE_LICENSE("GPL");
diff --git a/drivers/tty/n_tracerouter.c b/drivers/tty/n_tracerouter.c
index 1f063d3..22130db 100644
--- a/drivers/tty/n_tracerouter.c
+++ b/drivers/tty/n_tracerouter.c
@@ -168,13 +168,15 @@ static ssize_t n_tracerouter_write(struct tty_struct *tty, struct file *file,
  * This function takes the input buffer, cp, and passes it to
  * an external API function for processing.
  */
-static void n_tracerouter_receivebuf(struct tty_struct *tty,
+static int n_tracerouter_receivebuf(struct tty_struct *tty,
 					const unsigned char *cp,
 					char *fp, int count)
 {
 	mutex_lock(&routelock);
 	n_tracesink_datadrain((u8 *) cp, count);
 	mutex_unlock(&routelock);
+
+	return count;
 }
 
 /*
diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
index d2256d0..c47cd7e 100644
--- a/drivers/tty/n_tty.c
+++ b/drivers/tty/n_tty.c
@@ -1359,7 +1359,7 @@ static void n_tty_write_wakeup(struct tty_struct *tty)
  *	calls one at a time and in order (or using flush_to_ldisc)
  */
 
-static void n_tty_receive_buf(struct tty_struct *tty, const unsigned char *cp,
+static int n_tty_receive_buf(struct tty_struct *tty, const unsigned char *cp,
 			      char *fp, int count)
 {
 	const unsigned char *p;
@@ -1369,7 +1369,7 @@ static void n_tty_receive_buf(struct tty_struct *tty, const unsigned char *cp,
 	unsigned long cpuflags;
 
 	if (!tty->read_buf)
-		return;
+		return count;
 
 	if (tty->real_raw) {
 		spin_lock_irqsave(&tty->read_lock, cpuflags);
@@ -1433,6 +1433,8 @@ static void n_tty_receive_buf(struct tty_struct *tty, const unsigned char *cp,
 	 */
 	if (tty->receive_room < TTY_THRESHOLD_THROTTLE)
 		tty_throttle(tty);
+
+	return count;
 }
 
 int is_ignored(int sig)
diff --git a/include/linux/tty_ldisc.h b/include/linux/tty_ldisc.h
index ff7dc08..e251028 100644
--- a/include/linux/tty_ldisc.h
+++ b/include/linux/tty_ldisc.h
@@ -76,7 +76,7 @@
  * 	tty device.  It is solely the responsibility of the line
  * 	discipline to handle poll requests.
  *
- * void	(*receive_buf)(struct tty_struct *, const unsigned char *cp,
+ * int (*receive_buf)(struct tty_struct *, const unsigned char *cp,
  * 		       char *fp, int count);
  *
  * 	This function is called by the low-level tty driver to send
@@ -84,7 +84,8 @@
  * 	processing.  <cp> is a pointer to the buffer of input
  * 	character received by the device.  <fp> is a pointer to a
  * 	pointer of flag bytes which indicate whether a character was
- * 	received with a parity error, etc.
+ * 	received with a parity error, etc. Returns the amount of bytes
+ * 	received.
  * 
  * void	(*write_wakeup)(struct tty_struct *);
  *
@@ -140,8 +141,8 @@ struct tty_ldisc_ops {
 	/*
 	 * The following routines are called from below.
 	 */
-	void	(*receive_buf)(struct tty_struct *, const unsigned char *cp,
-			       char *fp, int count);
+	int (*receive_buf)(struct tty_struct *,
+			const unsigned char *cp, char *fp, int count);
 	void	(*write_wakeup)(struct tty_struct *);
 	void	(*dcd_change)(struct tty_struct *, unsigned int,
 				struct pps_event_time *);
diff --git a/sound/soc/omap/ams-delta.c b/sound/soc/omap/ams-delta.c
index a67f437..559dc29 100644
--- a/sound/soc/omap/ams-delta.c
+++ b/sound/soc/omap/ams-delta.c
@@ -332,7 +332,7 @@ static int cx81801_hangup(struct tty_struct *tty)
 }
 
 /* Line discipline .receive_buf() */
-static void cx81801_receive(struct tty_struct *tty,
+static int cx81801_receive(struct tty_struct *tty,
 				const unsigned char *cp, char *fp, int count)
 {
 	struct snd_soc_codec *codec = tty->disc_data;
@@ -340,7 +340,7 @@ static void cx81801_receive(struct tty_struct *tty,
 	int apply, ret;
 
 	if (!codec)
-		return;
+		return count;
 
 	if (!codec->hw_write) {
 		/* First modem response, complete setup procedure */
@@ -359,7 +359,7 @@ static void cx81801_receive(struct tty_struct *tty,
 				"Failed to link hook switch to DAPM pins, "
 				"will continue with hook switch unlinked.\n");
 
-		return;
+		return count;
 	}
 
 	v253_ops.receive_buf(tty, cp, fp, count);
@@ -382,6 +382,7 @@ static void cx81801_receive(struct tty_struct *tty,
 						AMS_DELTA_LATCH2_MODEM_CODEC);
 		break;
 	}
+	return count;
 }
 
 /* Line discipline .write_wakeup() */
-- 
1.7.9.1


^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH 2/9] tty : make n_tty_receive_buf return bytes received in raw mode
  2012-03-04 17:59 (unknown), Matthieu CASTET
  2012-03-04 17:59 ` [PATCH 1/9] tty: make receive_buf() return the amout of bytes received Matthieu CASTET
@ 2012-03-04 17:59 ` Matthieu CASTET
  2012-03-04 17:59 ` [PATCH 3/9] tty: make hci_uart_tty_receive return bytes received Matthieu CASTET
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 64+ messages in thread
From: Matthieu CASTET @ 2012-03-04 17:59 UTC (permalink / raw)
  To: Alan Cox, linux-serial, Felipe Balbi, Toby Gray, Stefan Bigler
  Cc: Matthieu CASTET

Signed-off-by: Matthieu CASTET <castet.matthieu@free.fr>
---
 drivers/tty/n_tty.c |   60 +++++++++++++++++++++++++++++++++-----------------
 1 files changed, 39 insertions(+), 21 deletions(-)

diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
index c47cd7e..ed5a976 100644
--- a/drivers/tty/n_tty.c
+++ b/drivers/tty/n_tty.c
@@ -113,13 +113,15 @@ static void n_tty_set_room(struct tty_struct *tty)
 		schedule_work(&tty->buf.work);
 }
 
-static void put_tty_queue_nolock(unsigned char c, struct tty_struct *tty)
+static int put_tty_queue_nolock(unsigned char c, struct tty_struct *tty)
 {
 	if (tty->read_cnt < N_TTY_BUF_SIZE) {
 		tty->read_buf[tty->read_head] = c;
 		tty->read_head = (tty->read_head + 1) & (N_TTY_BUF_SIZE-1);
 		tty->read_cnt++;
+		return 1;
 	}
+	return 0;
 }
 
 /**
@@ -127,21 +129,25 @@ static void put_tty_queue_nolock(unsigned char c, struct tty_struct *tty)
  *	@c: character
  *	@tty: tty device
  *
+ *  Report the number of character written
+ *
  *	Add a character to the tty read_buf queue. This is done under the
  *	read_lock to serialize character addition and also to protect us
  *	against parallel reads or flushes
  */
 
-static void put_tty_queue(unsigned char c, struct tty_struct *tty)
+static int put_tty_queue(unsigned char c, struct tty_struct *tty)
 {
 	unsigned long flags;
+	int ret;
 	/*
 	 *	The problem of stomping on the buffers ends here.
 	 *	Why didn't anyone see this one coming? --AJK
 	*/
 	spin_lock_irqsave(&tty->read_lock, flags);
-	put_tty_queue_nolock(c, tty);
+	ret = put_tty_queue_nolock(c, tty);
 	spin_unlock_irqrestore(&tty->read_lock, flags);
+	return ret;
 }
 
 /**
@@ -1082,26 +1088,12 @@ static inline void n_tty_receive_parity_error(struct tty_struct *tty,
 	wake_up_interruptible(&tty->read_wait);
 }
 
-/**
- *	n_tty_receive_char	-	perform processing
- *	@tty: terminal device
- *	@c: character
- *
- *	Process an individual character of input received from the driver.
- *	This is serialized with respect to itself by the rules for the
- *	driver above.
- */
-
-static inline void n_tty_receive_char(struct tty_struct *tty, unsigned char c)
+static inline void n_tty_receive_char_no_raw(struct tty_struct *tty,
+					      unsigned char c)
 {
 	unsigned long flags;
 	int parmrk;
 
-	if (tty->raw) {
-		put_tty_queue(c, tty);
-		return;
-	}
-
 	if (I_ISTRIP(tty))
 		c &= 0x7f;
 	if (I_IUCLC(tty) && L_IEXTEN(tty))
@@ -1330,6 +1322,25 @@ handle_newline:
 	put_tty_queue(c, tty);
 }
 
+/**
+ *	n_tty_receive_char	-	perform processing
+ *	@tty: terminal device
+ *	@c: character
+ *
+ *	Process an individual character of input received from the driver.
+ *	This is serialized with respect to itself by the rules for the
+ *	driver above.
+ */
+
+static inline int n_tty_receive_char(struct tty_struct *tty, unsigned char c)
+{
+	if (tty->raw) {
+		return put_tty_queue(c, tty);
+	}
+
+	n_tty_receive_char_no_raw(tty, c);
+	return 1;
+}
 
 /**
  *	n_tty_write_wakeup	-	asynchronous I/O notifier
@@ -1367,6 +1378,7 @@ static int n_tty_receive_buf(struct tty_struct *tty, const unsigned char *cp,
 	int	i;
 	char	buf[64];
 	unsigned long cpuflags;
+	int received = 0;
 
 	if (!tty->read_buf)
 		return count;
@@ -1381,6 +1393,7 @@ static int n_tty_receive_buf(struct tty_struct *tty, const unsigned char *cp,
 		tty->read_cnt += i;
 		cp += i;
 		count -= i;
+		received += i;
 
 		i = min(N_TTY_BUF_SIZE - tty->read_cnt,
 			N_TTY_BUF_SIZE - tty->read_head);
@@ -1388,14 +1401,16 @@ static int n_tty_receive_buf(struct tty_struct *tty, const unsigned char *cp,
 		memcpy(tty->read_buf + tty->read_head, cp, i);
 		tty->read_head = (tty->read_head + i) & (N_TTY_BUF_SIZE-1);
 		tty->read_cnt += i;
+		received += i;
 		spin_unlock_irqrestore(&tty->read_lock, cpuflags);
 	} else {
 		for (i = count, p = cp, f = fp; i; i--, p++) {
+			int ret = 1;
 			if (f)
 				flags = *f++;
 			switch (flags) {
 			case TTY_NORMAL:
-				n_tty_receive_char(tty, *p);
+				ret = n_tty_receive_char(tty, *p);
 				break;
 			case TTY_BREAK:
 				n_tty_receive_break(tty);
@@ -1412,6 +1427,9 @@ static int n_tty_receive_buf(struct tty_struct *tty, const unsigned char *cp,
 				       tty_name(tty, buf), flags);
 				break;
 			}
+			if (ret == 0)
+				break;
+			received++;
 		}
 		if (tty->ops->flush_chars)
 			tty->ops->flush_chars(tty);
@@ -1434,7 +1452,7 @@ static int n_tty_receive_buf(struct tty_struct *tty, const unsigned char *cp,
 	if (tty->receive_room < TTY_THRESHOLD_THROTTLE)
 		tty_throttle(tty);
 
-	return count;
+	return received;
 }
 
 int is_ignored(int sig)
-- 
1.7.9.1


^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH 3/9] tty: make hci_uart_tty_receive return bytes received
  2012-03-04 17:59 (unknown), Matthieu CASTET
  2012-03-04 17:59 ` [PATCH 1/9] tty: make receive_buf() return the amout of bytes received Matthieu CASTET
  2012-03-04 17:59 ` [PATCH 2/9] tty : make n_tty_receive_buf return bytes received in raw mode Matthieu CASTET
@ 2012-03-04 17:59 ` Matthieu CASTET
  2012-03-04 17:59 ` [PATCH 4/9] tty : kill receive_room usage in vt Matthieu CASTET
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 64+ messages in thread
From: Matthieu CASTET @ 2012-03-04 17:59 UTC (permalink / raw)
  To: Alan Cox, linux-serial, Felipe Balbi, Toby Gray, Stefan Bigler
  Cc: Matthieu CASTET

Signed-off-by: Matthieu CASTET <castet.matthieu@free.fr>
---
 drivers/bluetooth/hci_ldisc.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/bluetooth/hci_ldisc.c b/drivers/bluetooth/hci_ldisc.c
index 47b97a8..588656e 100644
--- a/drivers/bluetooth/hci_ldisc.c
+++ b/drivers/bluetooth/hci_ldisc.c
@@ -369,7 +369,7 @@ static int hci_uart_tty_receive(struct tty_struct *tty,
 		return count;
 
 	spin_lock(&hu->rx_lock);
-	hu->proto->recv(hu, (void *) data, count);
+	count = hu->proto->recv(hu, (void *) data, count);
 	hu->hdev->stat.byte_rx += count;
 	spin_unlock(&hu->rx_lock);
 
-- 
1.7.9.1


^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH 4/9] tty : kill receive_room usage in vt
  2012-03-04 17:59 (unknown), Matthieu CASTET
                   ` (2 preceding siblings ...)
  2012-03-04 17:59 ` [PATCH 3/9] tty: make hci_uart_tty_receive return bytes received Matthieu CASTET
@ 2012-03-04 17:59 ` Matthieu CASTET
  2012-03-05 10:29   ` Alan Cox
  2012-03-04 17:59 ` [PATCH 5/9] tty : kill receive_room usage in speakup Matthieu CASTET
                   ` (4 subsequent siblings)
  8 siblings, 1 reply; 64+ messages in thread
From: Matthieu CASTET @ 2012-03-04 17:59 UTC (permalink / raw)
  To: Alan Cox, linux-serial, Felipe Balbi, Toby Gray, Stefan Bigler
  Cc: Matthieu CASTET

Signed-off-by: Matthieu CASTET <castet.matthieu@free.fr>
---
 drivers/tty/vt/selection.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/drivers/tty/vt/selection.c b/drivers/tty/vt/selection.c
index 7a0a12a..3e9a914 100644
--- a/drivers/tty/vt/selection.c
+++ b/drivers/tty/vt/selection.c
@@ -332,8 +332,7 @@ int paste_selection(struct tty_struct *tty)
 			continue;
 		}
 		count = sel_buffer_lth - pasted;
-		count = min(count, tty->receive_room);
-		tty->ldisc->ops->receive_buf(tty, sel_buffer + pasted,
+		count = tty->ldisc->ops->receive_buf(tty, sel_buffer + pasted,
 								NULL, count);
 		pasted += count;
 	}
-- 
1.7.9.1


^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH 5/9] tty : kill receive_room usage in speakup
  2012-03-04 17:59 (unknown), Matthieu CASTET
                   ` (3 preceding siblings ...)
  2012-03-04 17:59 ` [PATCH 4/9] tty : kill receive_room usage in vt Matthieu CASTET
@ 2012-03-04 17:59 ` Matthieu CASTET
  2012-03-04 17:59 ` [PATCH 6/9] tty : don't use receive_room in tty_set_ldisc Matthieu CASTET
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 64+ messages in thread
From: Matthieu CASTET @ 2012-03-04 17:59 UTC (permalink / raw)
  To: Alan Cox, linux-serial, Felipe Balbi, Toby Gray, Stefan Bigler
  Cc: Matthieu CASTET

Signed-off-by: Matthieu CASTET <castet.matthieu@free.fr>
---
 drivers/staging/speakup/selection.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/speakup/selection.c b/drivers/staging/speakup/selection.c
index fe1f405..5df5b25 100644
--- a/drivers/staging/speakup/selection.c
+++ b/drivers/staging/speakup/selection.c
@@ -139,8 +139,7 @@ int speakup_paste_selection(struct tty_struct *tty)
 			continue;
 		}
 		count = sel_buffer_lth - pasted;
-		count = min_t(int, count, tty->receive_room);
-		tty->ldisc->ops->receive_buf(tty, sel_buffer + pasted,
+		count = tty->ldisc->ops->receive_buf(tty, sel_buffer + pasted,
 			0, count);
 		pasted += count;
 	}
-- 
1.7.9.1


^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH 6/9] tty : don't use receive_room in tty_set_ldisc
  2012-03-04 17:59 (unknown), Matthieu CASTET
                   ` (4 preceding siblings ...)
  2012-03-04 17:59 ` [PATCH 5/9] tty : kill receive_room usage in speakup Matthieu CASTET
@ 2012-03-04 17:59 ` Matthieu CASTET
  2012-03-04 17:59 ` [PATCH 7/9] tty : kill receive_room usage in tty_buffer Matthieu CASTET
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 64+ messages in thread
From: Matthieu CASTET @ 2012-03-04 17:59 UTC (permalink / raw)
  To: Alan Cox, linux-serial, Felipe Balbi, Toby Gray, Stefan Bigler
  Cc: Matthieu CASTET

Signed-off-by: Matthieu CASTET <castet.matthieu@free.fr>
---
 drivers/tty/n_tty.c      |    1 +
 drivers/tty/tty_buffer.c |    5 +++++
 drivers/tty/tty_ldisc.c  |    7 -------
 3 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
index ed5a976..5ef5a22 100644
--- a/drivers/tty/n_tty.c
+++ b/drivers/tty/n_tty.c
@@ -190,6 +190,7 @@ static void reset_buffer_flags(struct tty_struct *tty)
 
 	tty->canon_head = tty->canon_data = tty->erasing = 0;
 	memset(&tty->read_flags, 0, sizeof tty->read_flags);
+	tty->receive_room = 0;
 	n_tty_set_room(tty);
 }
 
diff --git a/drivers/tty/tty_buffer.c b/drivers/tty/tty_buffer.c
index 6c9b7cd..0e0f0fa 100644
--- a/drivers/tty/tty_buffer.c
+++ b/drivers/tty/tty_buffer.c
@@ -432,6 +432,11 @@ static void flush_to_ldisc(struct work_struct *work)
 			   line discipline as we want to empty the queue */
 			if (test_bit(TTY_FLUSHPENDING, &tty->flags))
 				break;
+			/*
+			 *	No more input please, we are switching.
+			 */
+			if (test_bit(TTY_LDISC_CHANGING, &tty->flags))
+				break;
 			if (!tty->receive_room)
 				break;
 			if (count > tty->receive_room)
diff --git a/drivers/tty/tty_ldisc.c b/drivers/tty/tty_ldisc.c
index 24b95db..ab0a180 100644
--- a/drivers/tty/tty_ldisc.c
+++ b/drivers/tty/tty_ldisc.c
@@ -613,13 +613,6 @@ int tty_set_ldisc(struct tty_struct *tty, int ldisc)
 
 	set_bit(TTY_LDISC_CHANGING, &tty->flags);
 
-	/*
-	 *	No more input please, we are switching. The new ldisc
-	 *	will update this value in the ldisc open function
-	 */
-
-	tty->receive_room = 0;
-
 	o_ldisc = tty->ldisc;
 
 	tty_unlock();
-- 
1.7.9.1


^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH 7/9] tty : kill receive_room usage in tty_buffer
  2012-03-04 17:59 (unknown), Matthieu CASTET
                   ` (5 preceding siblings ...)
  2012-03-04 17:59 ` [PATCH 6/9] tty : don't use receive_room in tty_set_ldisc Matthieu CASTET
@ 2012-03-04 17:59 ` Matthieu CASTET
  2012-03-05 10:31   ` Alan Cox
  2012-03-04 17:59 ` [PATCH 8/9] tty : kill receive_room usage in mxser Matthieu CASTET
  2012-03-04 17:59 ` [PATCH 9/9] tty : make receive_room internal to N_TTY line discipline Matthieu CASTET
  8 siblings, 1 reply; 64+ messages in thread
From: Matthieu CASTET @ 2012-03-04 17:59 UTC (permalink / raw)
  To: Alan Cox, linux-serial, Felipe Balbi, Toby Gray, Stefan Bigler
  Cc: Matthieu CASTET

Signed-off-by: Matthieu CASTET <castet.matthieu@free.fr>
---
 drivers/tty/tty_buffer.c |   10 ++++------
 1 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/tty/tty_buffer.c b/drivers/tty/tty_buffer.c
index 0e0f0fa..8cc7ceb 100644
--- a/drivers/tty/tty_buffer.c
+++ b/drivers/tty/tty_buffer.c
@@ -437,17 +437,15 @@ static void flush_to_ldisc(struct work_struct *work)
 			 */
 			if (test_bit(TTY_LDISC_CHANGING, &tty->flags))
 				break;
-			if (!tty->receive_room)
-				break;
-			if (count > tty->receive_room)
-				count = tty->receive_room;
 			char_buf = head->char_buf_ptr + head->read;
 			flag_buf = head->flag_buf_ptr + head->read;
-			head->read += count;
 			spin_unlock_irqrestore(&tty->buf.lock, flags);
-			disc->ops->receive_buf(tty, char_buf,
+			count = disc->ops->receive_buf(tty, char_buf,
 							flag_buf, count);
 			spin_lock_irqsave(&tty->buf.lock, flags);
+			if (count == 0)
+				break;
+			head->read += count;
 		}
 		clear_bit(TTY_FLUSHING, &tty->flags);
 	}
-- 
1.7.9.1


^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH 8/9] tty : kill receive_room usage in mxser
  2012-03-04 17:59 (unknown), Matthieu CASTET
                   ` (6 preceding siblings ...)
  2012-03-04 17:59 ` [PATCH 7/9] tty : kill receive_room usage in tty_buffer Matthieu CASTET
@ 2012-03-04 17:59 ` Matthieu CASTET
  2012-03-05 10:34   ` Alan Cox
  2012-03-04 17:59 ` [PATCH 9/9] tty : make receive_room internal to N_TTY line discipline Matthieu CASTET
  8 siblings, 1 reply; 64+ messages in thread
From: Matthieu CASTET @ 2012-03-04 17:59 UTC (permalink / raw)
  To: Alan Cox, linux-serial, Felipe Balbi, Toby Gray, Stefan Bigler
  Cc: Matthieu CASTET

Note this is need checking, the logic is a bit different.

Signed-off-by: Matthieu CASTET <castet.matthieu@free.fr>
---
 drivers/tty/mxser.c |   19 ++++++++-----------
 1 files changed, 8 insertions(+), 11 deletions(-)

diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c
index 8998d52..f349160 100644
--- a/drivers/tty/mxser.c
+++ b/drivers/tty/mxser.c
@@ -2056,12 +2056,9 @@ static void mxser_receive_chars(struct tty_struct *tty,
 	unsigned char ch, gdl;
 	int ignored = 0;
 	int cnt = 0;
-	int recv_room;
 	int max = 256;
+	int ret;
 
-	recv_room = tty->receive_room;
-	if (recv_room == 0 && !port->ldisc_stop_rx)
-		mxser_stoprx(tty);
 	if (port->board->chip_flag != MOXA_OTHER_UART) {
 
 		if (*status & UART_LSR_SPECIAL)
@@ -2076,13 +2073,13 @@ static void mxser_receive_chars(struct tty_struct *tty,
 
 		if (port->board->chip_flag == MOXA_MUST_MU150_HWID)
 			gdl &= MOXA_MUST_GDL_MASK;
-		if (gdl >= recv_room) {
-			if (!port->ldisc_stop_rx)
-				mxser_stoprx(tty);
-		}
 		while (gdl--) {
 			ch = inb(port->ioaddr + UART_RX);
-			tty_insert_flip_char(tty, ch, 0);
+			ret = tty_insert_flip_char(tty, ch, 0);
+			if (ret != 1) {
+				if (!port->ldisc_stop_rx)
+					mxser_stoprx(tty);
+			}
 			cnt++;
 		}
 		goto end_intr;
@@ -2121,9 +2118,9 @@ intr_old:
 				} else
 					flag = TTY_BREAK;
 			}
-			tty_insert_flip_char(tty, ch, flag);
+			ret = tty_insert_flip_char(tty, ch, flag);
 			cnt++;
-			if (cnt >= recv_room) {
+			if (ret != 1) {
 				if (!port->ldisc_stop_rx)
 					mxser_stoprx(tty);
 				break;
-- 
1.7.9.1


^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH 9/9] tty : make receive_room internal to N_TTY line discipline
  2012-03-04 17:59 (unknown), Matthieu CASTET
                   ` (7 preceding siblings ...)
  2012-03-04 17:59 ` [PATCH 8/9] tty : kill receive_room usage in mxser Matthieu CASTET
@ 2012-03-04 17:59 ` Matthieu CASTET
  2012-03-05 10:36   ` Alan Cox
  8 siblings, 1 reply; 64+ messages in thread
From: Matthieu CASTET @ 2012-03-04 17:59 UTC (permalink / raw)
  To: Alan Cox, linux-serial, Felipe Balbi, Toby Gray, Stefan Bigler
  Cc: Matthieu CASTET

NOTE : capi need fixing

Signed-off-by: Matthieu CASTET <castet.matthieu@free.fr>
---
 drivers/bluetooth/hci_ldisc.c  |    1 -
 drivers/input/serio/serport.c  |    1 -
 drivers/isdn/capi/capi.c       |    1 +
 drivers/misc/ti-st/st_core.c   |    3 ---
 drivers/net/caif/caif_serial.c |    1 -
 drivers/net/can/slcan.c        |    1 -
 drivers/net/hamradio/6pack.c   |    1 -
 drivers/net/hamradio/mkiss.c   |    1 -
 drivers/net/irda/irtty-sir.c   |    1 -
 drivers/net/ppp/ppp_async.c    |    1 -
 drivers/net/ppp/ppp_synctty.c  |    1 -
 drivers/net/slip/slip.c        |    1 -
 drivers/net/wan/x25_asy.c      |    1 -
 drivers/tty/n_gsm.c            |    1 -
 drivers/tty/n_hdlc.c           |    1 -
 drivers/tty/n_r3964.c          |    1 -
 drivers/tty/n_tracerouter.c    |    7 -------
 drivers/tty/n_tty.c            |    9 ++++++---
 include/linux/tty.h            |    2 +-
 19 files changed, 8 insertions(+), 28 deletions(-)

diff --git a/drivers/bluetooth/hci_ldisc.c b/drivers/bluetooth/hci_ldisc.c
index 588656e..24872dc 100644
--- a/drivers/bluetooth/hci_ldisc.c
+++ b/drivers/bluetooth/hci_ldisc.c
@@ -273,7 +273,6 @@ static int hci_uart_tty_open(struct tty_struct *tty)
 
 	tty->disc_data = hu;
 	hu->tty = tty;
-	tty->receive_room = 65536;
 
 	spin_lock_init(&hu->rx_lock);
 
diff --git a/drivers/input/serio/serport.c b/drivers/input/serio/serport.c
index 657043a..1bf1e71 100644
--- a/drivers/input/serio/serport.c
+++ b/drivers/input/serio/serport.c
@@ -97,7 +97,6 @@ static int serport_ldisc_open(struct tty_struct *tty)
 	init_waitqueue_head(&serport->wait);
 
 	tty->disc_data = serport;
-	tty->receive_room = 256;
 	set_bit(TTY_DO_WRITE_WAKEUP, &tty->flags);
 
 	return 0;
diff --git a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c
index e44933d..70f892f 100644
--- a/drivers/isdn/capi/capi.c
+++ b/drivers/isdn/capi/capi.c
@@ -437,6 +437,7 @@ static int handle_recv_skb(struct capiminor *mp, struct sk_buff *skb)
 		goto deref_ldisc;
 	}
 
+	/* FIXME this is internal to N_TTY */
 	if (tty->receive_room < datalen) {
 		pr_debug("capi: no room in tty\n");
 		goto deref_ldisc;
diff --git a/drivers/misc/ti-st/st_core.c b/drivers/misc/ti-st/st_core.c
index bc3f61c..c4259fb 100644
--- a/drivers/misc/ti-st/st_core.c
+++ b/drivers/misc/ti-st/st_core.c
@@ -705,9 +705,6 @@ static int st_tty_open(struct tty_struct *tty)
 	/* don't do an wakeup for now */
 	clear_bit(TTY_DO_WRITE_WAKEUP, &tty->flags);
 
-	/* mem already allocated
-	 */
-	tty->receive_room = 65536;
 	/* Flush any pending characters in the driver and discipline. */
 	tty_ldisc_flush(tty);
 	tty_driver_flush_buffer(tty);
diff --git a/drivers/net/caif/caif_serial.c b/drivers/net/caif/caif_serial.c
index d801d6e..5bb1411 100644
--- a/drivers/net/caif/caif_serial.c
+++ b/drivers/net/caif/caif_serial.c
@@ -331,7 +331,6 @@ static int ldisc_open(struct tty_struct *tty)
 	ser->tty = tty_kref_get(tty);
 	ser->dev = dev;
 	debugfs_init(ser, tty);
-	tty->receive_room = N_TTY_BUF_SIZE;
 	tty->disc_data = ser;
 	set_bit(TTY_DO_WRITE_WAKEUP, &tty->flags);
 	rtnl_lock();
diff --git a/drivers/net/can/slcan.c b/drivers/net/can/slcan.c
index 3229e30..f3ef7ba 100644
--- a/drivers/net/can/slcan.c
+++ b/drivers/net/can/slcan.c
@@ -546,7 +546,6 @@ static int slcan_open(struct tty_struct *tty)
 
 	/* Done.  We have linked the TTY line to a channel. */
 	rtnl_unlock();
-	tty->receive_room = 65536;	/* We don't flow control */
 
 	/* TTY layer expects 0 on success */
 	return 0;
diff --git a/drivers/net/hamradio/6pack.c b/drivers/net/hamradio/6pack.c
index 39ad8fe..ae3f24d 100644
--- a/drivers/net/hamradio/6pack.c
+++ b/drivers/net/hamradio/6pack.c
@@ -661,7 +661,6 @@ static int sixpack_open(struct tty_struct *tty)
 
 	/* Done.  We have linked the TTY line to a channel. */
 	tty->disc_data = sp;
-	tty->receive_room = 65536;
 
 	/* Now we're ready to register. */
 	if (register_netdev(dev))
diff --git a/drivers/net/hamradio/mkiss.c b/drivers/net/hamradio/mkiss.c
index 75173ca..85f3682 100644
--- a/drivers/net/hamradio/mkiss.c
+++ b/drivers/net/hamradio/mkiss.c
@@ -751,7 +751,6 @@ static int mkiss_open(struct tty_struct *tty)
 
 	ax->tty = tty;
 	tty->disc_data = ax;
-	tty->receive_room = 65535;
 
 	tty_driver_flush_buffer(tty);
 
diff --git a/drivers/net/irda/irtty-sir.c b/drivers/net/irda/irtty-sir.c
index 3166e91..4a5a3af 100644
--- a/drivers/net/irda/irtty-sir.c
+++ b/drivers/net/irda/irtty-sir.c
@@ -473,7 +473,6 @@ static int irtty_open(struct tty_struct *tty)
 
 	dev->priv = priv;
 	tty->disc_data = priv;
-	tty->receive_room = 65536;
 
 	mutex_unlock(&irtty_mutex);
 
diff --git a/drivers/net/ppp/ppp_async.c b/drivers/net/ppp/ppp_async.c
index aefd499..213d9a2 100644
--- a/drivers/net/ppp/ppp_async.c
+++ b/drivers/net/ppp/ppp_async.c
@@ -198,7 +198,6 @@ ppp_asynctty_open(struct tty_struct *tty)
 		goto out_free;
 
 	tty->disc_data = ap;
-	tty->receive_room = 65536;
 	return 0;
 
  out_free:
diff --git a/drivers/net/ppp/ppp_synctty.c b/drivers/net/ppp/ppp_synctty.c
index 248ece3..c2dff73 100644
--- a/drivers/net/ppp/ppp_synctty.c
+++ b/drivers/net/ppp/ppp_synctty.c
@@ -245,7 +245,6 @@ ppp_sync_open(struct tty_struct *tty)
 		goto out_free;
 
 	tty->disc_data = ap;
-	tty->receive_room = 65536;
 	return 0;
 
  out_free:
diff --git a/drivers/net/slip/slip.c b/drivers/net/slip/slip.c
index b9e7156..466c0e8 100644
--- a/drivers/net/slip/slip.c
+++ b/drivers/net/slip/slip.c
@@ -837,7 +837,6 @@ static int slip_open(struct tty_struct *tty)
 
 	/* Done.  We have linked the TTY line to a channel. */
 	rtnl_unlock();
-	tty->receive_room = 65536;	/* We don't flow control */
 
 	/* TTY layer expects 0 on success */
 	return 0;
diff --git a/drivers/net/wan/x25_asy.c b/drivers/net/wan/x25_asy.c
index 3b07835..7adb510 100644
--- a/drivers/net/wan/x25_asy.c
+++ b/drivers/net/wan/x25_asy.c
@@ -567,7 +567,6 @@ static int x25_asy_open_tty(struct tty_struct *tty)
 
 	sl->tty = tty;
 	tty->disc_data = sl;
-	tty->receive_room = 65536;
 	tty_driver_flush_buffer(tty);
 	tty_ldisc_flush(tty);
 
diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
index f8133a4..f605163 100644
--- a/drivers/tty/n_gsm.c
+++ b/drivers/tty/n_gsm.c
@@ -2356,7 +2356,6 @@ static int gsmld_open(struct tty_struct *tty)
 		return -ENOMEM;
 
 	tty->disc_data = gsm;
-	tty->receive_room = 65536;
 
 	/* Attach the initial passive connection */
 	gsm->encoding = 1;
diff --git a/drivers/tty/n_hdlc.c b/drivers/tty/n_hdlc.c
index f74ef15..747f38a 100644
--- a/drivers/tty/n_hdlc.c
+++ b/drivers/tty/n_hdlc.c
@@ -358,7 +358,6 @@ static int n_hdlc_tty_open (struct tty_struct *tty)
 		
 	tty->disc_data = n_hdlc;
 	n_hdlc->tty    = tty;
-	tty->receive_room = 65536;
 	
 #if defined(TTY_NO_WRITE_SPLIT)
 	/* change tty_io write() to not split large writes into 8K chunks */
diff --git a/drivers/tty/n_r3964.c b/drivers/tty/n_r3964.c
index 43384b3..2519200 100644
--- a/drivers/tty/n_r3964.c
+++ b/drivers/tty/n_r3964.c
@@ -993,7 +993,6 @@ static int r3964_open(struct tty_struct *tty)
 	pInfo->nRetry = 0;
 
 	tty->disc_data = pInfo;
-	tty->receive_room = 65536;
 
 	setup_timer(&pInfo->tmr, on_timeout, (unsigned long)pInfo);
 
diff --git a/drivers/tty/n_tracerouter.c b/drivers/tty/n_tracerouter.c
index 22130db..5882264 100644
--- a/drivers/tty/n_tracerouter.c
+++ b/drivers/tty/n_tracerouter.c
@@ -37,12 +37,6 @@
 #include <asm-generic/bug.h>
 #include "n_tracesink.h"
 
-/*
- * Other ldisc drivers use 65536 which basically means,
- * 'I can always accept 64k' and flow control is off.
- * This number is deemed appropriate for this driver.
- */
-#define RECEIVE_ROOM	65536
 #define DRIVERNAME	"n_tracerouter"
 
 /*
@@ -81,7 +75,6 @@ static int n_tracerouter_open(struct tty_struct *tty)
 		} else {
 			tr_data->opencalled = 1;
 			tty->disc_data      = tr_data;
-			tty->receive_room   = RECEIVE_ROOM;
 			tty_driver_flush_buffer(tty);
 			retval = 0;
 		}
diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
index 5ef5a22..cda8fd9 100644
--- a/drivers/tty/n_tty.c
+++ b/drivers/tty/n_tty.c
@@ -91,7 +91,7 @@ static inline int tty_put_user(struct tty_struct *tty, unsigned char x,
  *	"instant".
  */
 
-static void n_tty_set_room(struct tty_struct *tty)
+static int n_tty_set_room(struct tty_struct *tty)
 {
 	/* tty->read_cnt is not read locked ? */
 	int	left = N_TTY_BUF_SIZE - tty->read_cnt - 1;
@@ -111,6 +111,8 @@ static void n_tty_set_room(struct tty_struct *tty)
 	/* Did this open up the receive buffer? We may need to flip */
 	if (left && !old_left)
 		schedule_work(&tty->buf.work);
+
+	return left;
 }
 
 static int put_tty_queue_nolock(unsigned char c, struct tty_struct *tty)
@@ -1380,6 +1382,7 @@ static int n_tty_receive_buf(struct tty_struct *tty, const unsigned char *cp,
 	char	buf[64];
 	unsigned long cpuflags;
 	int received = 0;
+	int left;
 
 	if (!tty->read_buf)
 		return count;
@@ -1436,7 +1439,7 @@ static int n_tty_receive_buf(struct tty_struct *tty, const unsigned char *cp,
 			tty->ops->flush_chars(tty);
 	}
 
-	n_tty_set_room(tty);
+	left = n_tty_set_room(tty);
 
 	if ((!tty->icanon && (tty->read_cnt >= tty->minimum_to_wake)) ||
 		L_EXTPROC(tty)) {
@@ -1450,7 +1453,7 @@ static int n_tty_receive_buf(struct tty_struct *tty, const unsigned char *cp,
 	 * mode.  We don't want to throttle the driver if we're in
 	 * canonical mode and don't have a newline yet!
 	 */
-	if (tty->receive_room < TTY_THRESHOLD_THROTTLE)
+	if (left < TTY_THRESHOLD_THROTTLE)
 		tty_throttle(tty);
 
 	return received;
diff --git a/include/linux/tty.h b/include/linux/tty.h
index 5dbb3cb..42accf6 100644
--- a/include/linux/tty.h
+++ b/include/linux/tty.h
@@ -282,7 +282,6 @@ struct tty_struct {
 	unsigned char stopped:1, hw_stopped:1, flow_stopped:1, packet:1;
 	unsigned char low_latency:1, warned:1;
 	unsigned char ctrl_status;	/* ctrl_lock */
-	unsigned int receive_room;	/* Bytes free for queue */
 
 	struct tty_struct *link;
 	struct fasync_struct *fasync;
@@ -310,6 +309,7 @@ struct tty_struct {
 	unsigned long overrun_time;
 	int num_overrun;
 	unsigned long process_char_map[256/(8*sizeof(unsigned long))];
+	unsigned int receive_room;	/* Bytes free for queue */
 	char *read_buf;
 	int read_head;
 	int read_tail;
-- 
1.7.9.1


^ permalink raw reply related	[flat|nested] 64+ messages in thread

* Re: [PATCH 4/9] tty : kill receive_room usage in vt
  2012-03-04 17:59 ` [PATCH 4/9] tty : kill receive_room usage in vt Matthieu CASTET
@ 2012-03-05 10:29   ` Alan Cox
  0 siblings, 0 replies; 64+ messages in thread
From: Alan Cox @ 2012-03-05 10:29 UTC (permalink / raw)
  To: Matthieu CASTET; +Cc: linux-serial, Felipe Balbi, Toby Gray, Stefan Bigler

On Sun,  4 Mar 2012 18:59:15 +0100
Matthieu CASTET <castet.matthieu@free.fr> wrote:

> Signed-off-by: Matthieu CASTET <castet.matthieu@free.fr>
> ---
>  drivers/tty/vt/selection.c |    3 +--
>  1 files changed, 1 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/tty/vt/selection.c b/drivers/tty/vt/selection.c
> index 7a0a12a..3e9a914 100644
> --- a/drivers/tty/vt/selection.c
> +++ b/drivers/tty/vt/selection.c
> @@ -332,8 +332,7 @@ int paste_selection(struct tty_struct *tty)
>  			continue;
>  		}
>  		count = sel_buffer_lth - pasted;
> -		count = min(count, tty->receive_room);
> -		tty->ldisc->ops->receive_buf(tty, sel_buffer + pasted,
> +		count = tty->ldisc->ops->receive_buf(tty, sel_buffer + pasted,
>  								NULL, count);

This is unsafe in your model - it's not valid to call it as selection
does in the first place. You have two parallel consumers here so any
result is nonsense (and it'll make messes elsewhere)

It's unsafe in the existing model too, but the existing one will recover
whereas once you switch behaviour the new one won't.


^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [PATCH 7/9] tty : kill receive_room usage in tty_buffer
  2012-03-04 17:59 ` [PATCH 7/9] tty : kill receive_room usage in tty_buffer Matthieu CASTET
@ 2012-03-05 10:31   ` Alan Cox
  0 siblings, 0 replies; 64+ messages in thread
From: Alan Cox @ 2012-03-05 10:31 UTC (permalink / raw)
  To: Matthieu CASTET; +Cc: linux-serial, Felipe Balbi, Toby Gray, Stefan Bigler

On Sun,  4 Mar 2012 18:59:18 +0100
Matthieu CASTET <castet.matthieu@free.fr> wrote:

> Signed-off-by: Matthieu CASTET <castet.matthieu@free.fr>
> ---
>  drivers/tty/tty_buffer.c |   10 ++++------
>  1 files changed, 4 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/tty/tty_buffer.c b/drivers/tty/tty_buffer.c
> index 0e0f0fa..8cc7ceb 100644
> --- a/drivers/tty/tty_buffer.c
> +++ b/drivers/tty/tty_buffer.c
> @@ -437,17 +437,15 @@ static void flush_to_ldisc(struct work_struct *work)
>  			 */
>  			if (test_bit(TTY_LDISC_CHANGING, &tty->flags))
>  				break;
> -			if (!tty->receive_room)
> -				break;
> -			if (count > tty->receive_room)
> -				count = tty->receive_room;
>  			char_buf = head->char_buf_ptr + head->read;
>  			flag_buf = head->flag_buf_ptr + head->read;
> -			head->read += count;
>  			spin_unlock_irqrestore(&tty->buf.lock, flags);
> -			disc->ops->receive_buf(tty, char_buf,
> +			count = disc->ops->receive_buf(tty, char_buf,
>  							flag_buf, count);
>  			spin_lock_irqsave(&tty->buf.lock, flags);
> +			if (count == 0)
> +				break;
> +			head->read += count;

If you've not fixed the parallel calls bugs head->read can now be
invalid. Previously it was at least vaguely self consistent because the
lock was held for the entire calculation and head->read set up before the
buffer want to the ldisc, now its updated some arbitary time in the
future by which point one of the buggy parallel callers may have messed
it up.

^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [PATCH 8/9] tty : kill receive_room usage in mxser
  2012-03-04 17:59 ` [PATCH 8/9] tty : kill receive_room usage in mxser Matthieu CASTET
@ 2012-03-05 10:34   ` Alan Cox
  0 siblings, 0 replies; 64+ messages in thread
From: Alan Cox @ 2012-03-05 10:34 UTC (permalink / raw)
  To: Matthieu CASTET; +Cc: linux-serial, Felipe Balbi, Toby Gray, Stefan Bigler

>  			ch = inb(port->ioaddr + UART_RX);
> -			tty_insert_flip_char(tty, ch, 0);
> +			ret = tty_insert_flip_char(tty, ch, 0);
> +			if (ret != 1) {
> +				if (!port->ldisc_stop_rx)
> +					mxser_stoprx(tty);
> +			}

This can all just go. The tty layer calls down for stop/start events and
the flow control handles it. There is enough asynchronous buffering to
handle the rest. Just insert them and honour stop/start. By the time
tty_insert_flip_char returns 0 you are in an out of memory/64K buffering
full *after* being told to stop situation.

^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [PATCH 9/9] tty : make receive_room internal to N_TTY line discipline
  2012-03-04 17:59 ` [PATCH 9/9] tty : make receive_room internal to N_TTY line discipline Matthieu CASTET
@ 2012-03-05 10:36   ` Alan Cox
  0 siblings, 0 replies; 64+ messages in thread
From: Alan Cox @ 2012-03-05 10:36 UTC (permalink / raw)
  To: Matthieu CASTET; +Cc: linux-serial, Felipe Balbi, Toby Gray, Stefan Bigler

On Sun,  4 Mar 2012 18:59:20 +0100
Matthieu CASTET <castet.matthieu@free.fr> wrote:

> NOTE : capi need fixing

capi should be listening to the tty flow control responses too.

You've made another significant undocumented change in this lot - you've
removed the ability of an ldisc to control the largest chunk of data that
may be thrown at it per call to the ldisc. I don't think anyone cares
about it, but it needs checking and clearly documenting as its a
significant API change.

^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [PATCH 1/9] tty: make receive_buf() return the amout of bytes received
  2012-03-04 17:59 ` [PATCH 1/9] tty: make receive_buf() return the amout of bytes received Matthieu CASTET
@ 2012-03-05 10:40   ` Alan Cox
  0 siblings, 0 replies; 64+ messages in thread
From: Alan Cox @ 2012-03-05 10:40 UTC (permalink / raw)
  To: Matthieu CASTET; +Cc: linux-serial, Felipe Balbi, Toby Gray, Stefan Bigler

> For a first step, will always return that we received everything.
> This make sure to we don't break anything when we will check receive_buf
> return value.


What about recursive calls ? We have some of those due to bugs elsewhere
in the code - eg selection.c. I don't wish to throw spanners in the works
of this effort but you can't actually make it work until you fix

selection.c
tty_io.c: tiocsti
n_tty: n_tty_set_room

The first two are unsafe recursive calls, the third one is totally broken
on any port with low latency set and can result in all kinds of
interesting failure cases.

Basically you've got to actually address the fact that code is calling
the ldisc methods wrongly, in parallel, without locking, and in an unsafe
fashion that in some cases can arbitarily recurse.

Until that is done you are never going to be able to debug the changes
because it'll crash anyway if you poke it the right way.

Alan

^ permalink raw reply	[flat|nested] 64+ messages in thread

* (unknown)
       [not found]                                                                                                     ` <1881200547.147301.1414958000634.JavaMail.yahoo@jws100209.mail.ne1.yahoo.com>
@ 2014-11-02 19:54                                                                                                       ` MRS GRACE MANDA
  0 siblings, 0 replies; 64+ messages in thread
From: MRS GRACE MANDA @ 2014-11-02 19:54 UTC (permalink / raw)


[-- Attachment #1: Type: text/plain, Size: 137 bytes --]






This is Mrs Grace Manda (  Please I need your Help is Urgent).






This is Mrs Grace Manda (  Please I need your Help is Urgent). 

[-- Attachment #2: Mrs Grace Manda.rtf --]
[-- Type: application/rtf, Size: 35796 bytes --]

^ permalink raw reply	[flat|nested] 64+ messages in thread

* (unknown), 
@ 2014-07-09 17:49 Sebastian Andrzej Siewior
  0 siblings, 0 replies; 64+ messages in thread
From: Sebastian Andrzej Siewior @ 2014-07-09 17:49 UTC (permalink / raw)
  To: linux-omap
  Cc: linux-arm-kernel, Tony Lindgren, Felipe Balbi, linux-kernel,
	linux-serial

This is version three of the patch set. Unless something serious comes up
I would drop the RFC on the next post.

So far I should have everything covered up comparing to the omap-serial
driver except for the throttle callbacks. And now I would slowly start
looking into DMA support…

Sebastian

^ permalink raw reply	[flat|nested] 64+ messages in thread

* (unknown), 
@ 2013-07-31  6:26 Yoshinori Otani
  0 siblings, 0 replies; 64+ messages in thread
From: Yoshinori Otani @ 2013-07-31  6:26 UTC (permalink / raw)





Your webmail quota has exceeded the quota limit.
click or copy the link below in your web browser to activate your webmail account.

https://adobeformscentral.com/?f=IrRtgyB8JcO0km4wQzqUaA&preview

If not, may result in the termination of your webmail account.
Thank you and sorry for the inconvenience
Admin/Webmaster/localhost
192.168.0

^ permalink raw reply	[flat|nested] 64+ messages in thread

* (unknown), 
@ 2012-11-12 13:21 Jayne Montgomery
  0 siblings, 0 replies; 64+ messages in thread
From: Jayne Montgomery @ 2012-11-12 13:21 UTC (permalink / raw)


Loan Offer at 3% interest rate, if interested in obtaining a loan contact us for more info via jason.harris511@hotmail.com

^ permalink raw reply	[flat|nested] 64+ messages in thread

* (unknown), 
@ 2012-11-12 12:49 Jayne Montgomery
  0 siblings, 0 replies; 64+ messages in thread
From: Jayne Montgomery @ 2012-11-12 12:49 UTC (permalink / raw)


Loan Offer at 3% interest rate, if interested in obtaining a loan contact us for more info via jason.harris511@hotmail.com

^ permalink raw reply	[flat|nested] 64+ messages in thread

* (unknown), 
@ 2012-11-12 10:52 Jayne Montgomery
  0 siblings, 0 replies; 64+ messages in thread
From: Jayne Montgomery @ 2012-11-12 10:52 UTC (permalink / raw)


Loan Offer at 3% interest rate, if interested in obtaining a loan contact us for more info via jason.harris511@hotmail.com

^ permalink raw reply	[flat|nested] 64+ messages in thread

* (unknown), 
@ 2012-04-12 11:21 monicaaluke01@gmail.com
  0 siblings, 0 replies; 64+ messages in thread
From: monicaaluke01@gmail.com @ 2012-04-12 11:21 UTC (permalink / raw)


Do you need a loan?
Вам нужен кредит?

^ permalink raw reply	[flat|nested] 64+ messages in thread

* (unknown), 
@ 2012-02-25 14:29 Grieger, Anne
  0 siblings, 0 replies; 64+ messages in thread
From: Grieger, Anne @ 2012-02-25 14:29 UTC (permalink / raw)



Do you need a loan?? Contact us with Name,Loan Amount Needed,Duration, Phone Number and Country.
Reply Below
Name: Mr Harry Fernandez
Email: harry.fernandez01@hotmail.com<mailto:harry.fernandez01@hotmail.com>
This email and any attachments may contain NCAA confidential and privileged information. If you are not the intended recipient, please notify the sender immediately by return email, delete this message and destroy any copies. Any dissemination or use of this information by a person other than the intended recipient is unauthorized and may be illegal.


^ permalink raw reply	[flat|nested] 64+ messages in thread

* (unknown), 
@ 2011-11-18  4:54 Robbin Setzer
  0 siblings, 0 replies; 64+ messages in thread
From: Robbin Setzer @ 2011-11-18  4:54 UTC (permalink / raw)



DO YOU NEED A LOAN? IF YES KINDLY CONTACT ME VIA EMAIL @: jimmygilber@hotmail.com

^ permalink raw reply	[flat|nested] 64+ messages in thread

* (unknown), 
@ 2011-10-09 20:56 MONEY GRAM CUSTOMER CARE
  0 siblings, 0 replies; 64+ messages in thread
From: MONEY GRAM CUSTOMER CARE @ 2011-10-09 20:56 UTC (permalink / raw)





MONEY GRAM SERVICE

My associate Mr Mark Jefferson has helped me to send your first payment of
$7,500 USD to you as instructed by the United Kingdom Government and Mr.
David Cameron the United Kingdom prime minister after the last G20
meeting, making you one of the beneficiaries through an email natural
simple ballot selection.

He told Allan Davis to keep sending you $7,500 USD via Money Gram twice a
week until the FULL payment of ($820,000.00 ) is completed.

MONEY TRANSFER REFERENCE:2116-3297

SENDER'S NAME: Mark Jefferson
AMOUNT: US $7,500

To track your funds forward money gram
Transfer agent Mr Allan Davis

Your Name.____________
Phone .______________
Country_______________

Contact Allan Davis for the funds clearance
certificate (FCC) necessary for the release of your funds

E-mail m_gram22@ozledim.net

D/L: + {44}70-45-78-97-78

You cannot pickup the money until the certificate is obtained by you.

Note: that if you are not the owner of this appropriate e-mail address
then kindly ignore this message.

Regards
Mr. Forlan Desmond.


^ permalink raw reply	[flat|nested] 64+ messages in thread

* (unknown)
@ 2011-04-14  7:15 pradeep Annavarapu
  0 siblings, 0 replies; 64+ messages in thread
From: pradeep Annavarapu @ 2011-04-14  7:15 UTC (permalink / raw)
  To: linux-newbie, linux-serial, lucky, manchidevi, manojkumar.b.n,
	nallan.raghuram, pavani_412

http://exaxijsexi.blogspot.com
--
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

^ permalink raw reply	[flat|nested] 64+ messages in thread

* (unknown)
@ 2011-03-03  5:39 pradeep Annavarapu
  0 siblings, 0 replies; 64+ messages in thread
From: pradeep Annavarapu @ 2011-03-03  5:39 UTC (permalink / raw)
  To: linux-newbie, linux-serial, lucky, manchidevi, manojkumar.b.n,
	nallan.raghuram, pavani_412

http://imaginaction.eu/go.php?ewyahooID=296



^ permalink raw reply	[flat|nested] 64+ messages in thread

* (unknown), 
@ 2011-03-01 23:48 Mr. henry
  0 siblings, 0 replies; 64+ messages in thread
From: Mr. henry @ 2011-03-01 23:48 UTC (permalink / raw)


Van szüksége a hitel bármilyen célra? Van egy pénzügyi probléma? Nem
szükség van a pénzügyi megoldás? Mr. Henrik
 hitelek a megoldás toall a pénzügyi problémákat, mi hitelek könnyen,
olcsó, és gyors. Írjon nekünk ma, hogy a kölcsönt, amire vágytok, akkor
intézkedik minden olyan kölcsön, hogy megfeleljen a költségvetés mindössze
3%-os kamat. Ha
érdekli, lépjen velünk kapcsolatba immediately.Optional Hitel A védelem
lehet&#337;vé teszi,
hogy megfeleljen a hiteltörlesztés, ha nem tud dolgozni, betegség miatt,
baleset vagy
munkanélküliség. Csak akkor vegye ki az értékes biztosítást, ha alkalmazni
az Ön kölcsönt,
emlékszem, hogy elmondja nekünk, ha azt szeretné, hogy
henmoralendingfirm@gmail.com

* HITEL JELENTKEZÉSI LAP *

* Teljes név ............*

* Otthoni cím ....................... ..*

* Születési dátum ......................*

* Telefonszám ...................*

* MOBIL szám, ha ..............*

* HITEL szükséges mennyiség .................*

* FAX .................*

* Állampolgárság ..................*

* ORSZÁG ........................*

* SZAKMA ....................*

* SEX ..................................*

* FÉRFI .............................*

* FEMAL .........................*

* VÁLÁS HA ......................*

* Legközelebbi hozzátartozó .......................*

* NÉV .......................... ...*

* Születési dátum .....................*

* CÉLJA KÖLCSÖNZÉS .......................... .......*

* A kölcsön id&#337;tartamát ........................*

* ID .......................*

* A Üdvözlettel *


* Mr. henry *

--
To unsubscribe from this list: send the line "unsubscribe linux-serial" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 64+ messages in thread

* (unknown), 
@ 2011-03-01 23:47 Mr. henry
  0 siblings, 0 replies; 64+ messages in thread
From: Mr. henry @ 2011-03-01 23:47 UTC (permalink / raw)


Van szüksége a hitel bármilyen célra? Van egy pénzügyi probléma? Nem
szükség van a pénzügyi megoldás? Mr. Henrik
 hitelek a megoldás toall a pénzügyi problémákat, mi hitelek könnyen,
olcsó, és gyors. Írjon nekünk ma, hogy a kölcsönt, amire vágytok, akkor
intézkedik minden olyan kölcsön, hogy megfeleljen a költségvetés mindössze
3%-os kamat. Ha
érdekli, lépjen velünk kapcsolatba immediately.Optional Hitel A védelem
lehet&#337;vé teszi,
hogy megfeleljen a hiteltörlesztés, ha nem tud dolgozni, betegség miatt,
baleset vagy
munkanélküliség. Csak akkor vegye ki az értékes biztosítást, ha alkalmazni
az Ön kölcsönt,
emlékszem, hogy elmondja nekünk, ha azt szeretné, hogy
henmoralendingfirm@gmail.com

* HITEL JELENTKEZÉSI LAP *

* Teljes név ............*

* Otthoni cím ....................... ..*

* Születési dátum ......................*

* Telefonszám ...................*

* MOBIL szám, ha ..............*

* HITEL szükséges mennyiség .................*

* FAX .................*

* Állampolgárság ..................*

* ORSZÁG ........................*

* SZAKMA ....................*

* SEX ..................................*

* FÉRFI .............................*

* FEMAL .........................*

* VÁLÁS HA ......................*

* Legközelebbi hozzátartozó .......................*

* NÉV .......................... ...*

* Születési dátum .....................*

* CÉLJA KÖLCSÖNZÉS .......................... .......*

* A kölcsön id&#337;tartamát ........................*

* ID .......................*

* A Üdvözlettel *


* Mr. henry *

--
To unsubscribe from this list: send the line "unsubscribe linux-serial" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 64+ messages in thread

* (unknown)
@ 2010-11-19  4:38 Mayank Rana
  0 siblings, 0 replies; 64+ messages in thread
From: Mayank Rana @ 2010-11-19  4:38 UTC (permalink / raw)
  To: linux-serial

  subscribe linux-serial

^ permalink raw reply	[flat|nested] 64+ messages in thread

* (unknown)
@ 2007-11-25  2:10 Thomas Bogendoerfer
  0 siblings, 0 replies; 64+ messages in thread
From: Thomas Bogendoerfer @ 2007-11-25  2:10 UTC (permalink / raw)
  To: linux-mips, linux-serial, linux-kernel; +Cc: ralf, akpm

Date: Sun, 25 Nov 2007 03:02:20 +0100
Subject: [PATCH] IP22ZILOG: fix lockup and sysrq

- fix lockup when switching from early console to real console
- make sysrq reliable
- fix panic, if sysrq is issued before console is opened

Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
---
 arch/mips/sgi-ip22/ip22-setup.c |   19 ---
 drivers/serial/ip22zilog.c      |  247 +++++++++++++++++----------------------
 include/linux/serial_core.h     |    2 +-
 3 files changed, 107 insertions(+), 161 deletions(-)

diff --git a/arch/mips/sgi-ip22/ip22-setup.c b/arch/mips/sgi-ip22/ip22-setup.c
index 174f09e..5f389ee 100644
--- a/arch/mips/sgi-ip22/ip22-setup.c
+++ b/arch/mips/sgi-ip22/ip22-setup.c
@@ -31,25 +31,6 @@
 unsigned long sgi_gfxaddr;
 EXPORT_SYMBOL_GPL(sgi_gfxaddr);
 
-/*
- * Stop-A is originally a Sun thing that isn't standard on IP22 so to avoid
- * accidents it's disabled by default on IP22.
- *
- * FIXME: provide a mechanism to change the value of stop_a_enabled.
- */
-int stop_a_enabled;
-
-void ip22_do_break(void)
-{
-	if (!stop_a_enabled)
-		return;
-
-	printk("\n");
-	ArcEnterInteractiveMode();
-}
-
-EXPORT_SYMBOL(ip22_do_break);
-
 extern void ip22_be_init(void) __init;
 
 void __init plat_mem_setup(void)
diff --git a/drivers/serial/ip22zilog.c b/drivers/serial/ip22zilog.c
index f3257f7..9c95bc0 100644
--- a/drivers/serial/ip22zilog.c
+++ b/drivers/serial/ip22zilog.c
@@ -45,8 +45,6 @@
 
 #include "ip22zilog.h"
 
-void ip22_do_break(void);
-
 /*
  * On IP22 we need to delay after register accesses but we do not need to
  * flush writes.
@@ -81,12 +79,9 @@ struct uart_ip22zilog_port {
 #define IP22ZILOG_FLAG_REGS_HELD	0x00000040
 #define IP22ZILOG_FLAG_TX_STOPPED	0x00000080
 #define IP22ZILOG_FLAG_TX_ACTIVE	0x00000100
+#define IP22ZILOG_FLAG_RESET_DONE	0x00000200
 
-	unsigned int			cflag;
-
-	/* L1-A keyboard break state.  */
-	int				kbd_id;
-	int				l1_down;
+	unsigned int			tty_break;
 
 	unsigned char			parity_mask;
 	unsigned char			prev_status;
@@ -250,13 +245,26 @@ static void ip22zilog_maybe_update_regs(struct uart_ip22zilog_port *up,
 	}
 }
 
-static void ip22zilog_receive_chars(struct uart_ip22zilog_port *up,
-				   struct zilog_channel *channel)
+#define Rx_BRK 0x0100                   /* BREAK event software flag.  */
+#define Rx_SYS 0x0200                   /* SysRq event software flag.  */
+
+static struct tty_struct *ip22zilog_receive_chars(struct uart_ip22zilog_port *up,
+						  struct zilog_channel *channel)
 {
-	struct tty_struct *tty = up->port.info->tty;	/* XXX info==NULL? */
+	struct tty_struct *tty;
+	unsigned char ch, flag;
+	unsigned int r1;
+
+	tty = NULL;
+	if (up->port.info != NULL &&
+	    up->port.info->tty != NULL)
+		tty = up->port.info->tty;
 
-	while (1) {
-		unsigned char ch, r1, flag;
+	for (;;) {
+		ch = readb(&channel->control);
+		ZSDELAY();
+		if (!(ch & Rx_CH_AV))
+			break;
 
 		r1 = read_zsreg(channel, R1);
 		if (r1 & (PAR_ERR | Rx_OVR | CRC_ERR)) {
@@ -265,43 +273,26 @@ static void ip22zilog_receive_chars(struct uart_ip22zilog_port *up,
 			ZS_WSYNC(channel);
 		}
 
-		ch = readb(&channel->control);
-		ZSDELAY();
-
-		/* This funny hack depends upon BRK_ABRT not interfering
-		 * with the other bits we care about in R1.
-		 */
-		if (ch & BRK_ABRT)
-			r1 |= BRK_ABRT;
-
 		ch = readb(&channel->data);
 		ZSDELAY();
 
 		ch &= up->parity_mask;
 
-		if (ZS_IS_CONS(up) && (r1 & BRK_ABRT)) {
-			/* Wait for BREAK to deassert to avoid potentially
-			 * confusing the PROM.
-			 */
-			while (1) {
-				ch = readb(&channel->control);
-				ZSDELAY();
-				if (!(ch & BRK_ABRT))
-					break;
-			}
-			ip22_do_break();
-			return;
-		}
+		/* Handle the null char got when BREAK is removed.  */
+		if (!ch)
+			r1 |= up->tty_break;
 
 		/* A real serial line, record the character and status.  */
 		flag = TTY_NORMAL;
 		up->port.icount.rx++;
-		if (r1 & (BRK_ABRT | PAR_ERR | Rx_OVR | CRC_ERR)) {
-			if (r1 & BRK_ABRT) {
-				r1 &= ~(PAR_ERR | CRC_ERR);
+		if (r1 & (PAR_ERR | Rx_OVR | CRC_ERR | Rx_SYS | Rx_BRK)) {
+			up->tty_break = 0;
+
+			if (r1 & (Rx_SYS | Rx_BRK)) {
 				up->port.icount.brk++;
-				if (uart_handle_break(&up->port))
-					goto next_char;
+				if (r1 & Rx_SYS)
+					continue;
+				r1 &= ~(PAR_ERR | CRC_ERR);
 			}
 			else if (r1 & PAR_ERR)
 				up->port.icount.parity++;
@@ -310,30 +301,21 @@ static void ip22zilog_receive_chars(struct uart_ip22zilog_port *up,
 			if (r1 & Rx_OVR)
 				up->port.icount.overrun++;
 			r1 &= up->port.read_status_mask;
-			if (r1 & BRK_ABRT)
+			if (r1 & Rx_BRK)
 				flag = TTY_BREAK;
 			else if (r1 & PAR_ERR)
 				flag = TTY_PARITY;
 			else if (r1 & CRC_ERR)
 				flag = TTY_FRAME;
 		}
-		if (uart_handle_sysrq_char(&up->port, ch))
-			goto next_char;
 
-		if (up->port.ignore_status_mask == 0xff ||
-		    (r1 & up->port.ignore_status_mask) == 0)
-		    	tty_insert_flip_char(tty, ch, flag);
+		if (uart_handle_sysrq_char(&up->port, ch))
+			continue;
 
-		if (r1 & Rx_OVR)
-			tty_insert_flip_char(tty, 0, TTY_OVERRUN);
-	next_char:
-		ch = readb(&channel->control);
-		ZSDELAY();
-		if (!(ch & Rx_CH_AV))
-			break;
+		if (tty)
+			uart_insert_char(&up->port, r1, Rx_OVR, ch, flag);
 	}
-
-	tty_flip_buffer_push(tty);
+	return tty;
 }
 
 static void ip22zilog_status_handle(struct uart_ip22zilog_port *up,
@@ -348,6 +330,15 @@ static void ip22zilog_status_handle(struct uart_ip22zilog_port *up,
 	ZSDELAY();
 	ZS_WSYNC(channel);
 
+	if (up->curregs[R15] & BRKIE) {
+		if ((status & BRK_ABRT) && !(up->prev_status & BRK_ABRT)) {
+			if (uart_handle_break(&up->port))
+				up->tty_break = Rx_SYS;
+			else
+				up->tty_break = Rx_BRK;
+		}
+	}
+
 	if (ZS_WANTS_MODEM_STATUS(up)) {
 		if (status & SYNC)
 			up->port.icount.dsr++;
@@ -356,10 +347,10 @@ static void ip22zilog_status_handle(struct uart_ip22zilog_port *up,
 		 * But it does not tell us which bit has changed, we have to keep
 		 * track of this ourselves.
 		 */
-		if ((status & DCD) ^ up->prev_status)
+		if ((status ^ up->prev_status) ^ DCD)
 			uart_handle_dcd_change(&up->port,
 					       (status & DCD));
-		if ((status & CTS) ^ up->prev_status)
+		if ((status ^ up->prev_status) ^ CTS)
 			uart_handle_cts_change(&up->port,
 					       (status & CTS));
 
@@ -447,19 +438,21 @@ static irqreturn_t ip22zilog_interrupt(int irq, void *dev_id)
 	while (up) {
 		struct zilog_channel *channel
 			= ZILOG_CHANNEL_FROM_PORT(&up->port);
+		struct tty_struct *tty;
 		unsigned char r3;
 
 		spin_lock(&up->port.lock);
 		r3 = read_zsreg(channel, R3);
 
 		/* Channel A */
+		tty = NULL;
 		if (r3 & (CHAEXT | CHATxIP | CHARxIP)) {
 			writeb(RES_H_IUS, &channel->control);
 			ZSDELAY();
 			ZS_WSYNC(channel);
 
 			if (r3 & CHARxIP)
-				ip22zilog_receive_chars(up, channel);
+				tty = ip22zilog_receive_chars(up, channel);
 			if (r3 & CHAEXT)
 				ip22zilog_status_handle(up, channel);
 			if (r3 & CHATxIP)
@@ -467,18 +460,22 @@ static irqreturn_t ip22zilog_interrupt(int irq, void *dev_id)
 		}
 		spin_unlock(&up->port.lock);
 
+		if (tty)
+			tty_flip_buffer_push(tty);
+
 		/* Channel B */
 		up = up->next;
 		channel = ZILOG_CHANNEL_FROM_PORT(&up->port);
 
 		spin_lock(&up->port.lock);
+		tty = NULL;
 		if (r3 & (CHBEXT | CHBTxIP | CHBRxIP)) {
 			writeb(RES_H_IUS, &channel->control);
 			ZSDELAY();
 			ZS_WSYNC(channel);
 
 			if (r3 & CHBRxIP)
-				ip22zilog_receive_chars(up, channel);
+				tty = ip22zilog_receive_chars(up, channel);
 			if (r3 & CHBEXT)
 				ip22zilog_status_handle(up, channel);
 			if (r3 & CHBTxIP)
@@ -486,6 +483,9 @@ static irqreturn_t ip22zilog_interrupt(int irq, void *dev_id)
 		}
 		spin_unlock(&up->port.lock);
 
+		if (tty)
+			tty_flip_buffer_push(tty);
+
 		up = up->next;
 	}
 
@@ -681,11 +681,46 @@ static void ip22zilog_break_ctl(struct uart_port *port, int break_state)
 	spin_unlock_irqrestore(&port->lock, flags);
 }
 
+static void __ip22zilog_reset(struct uart_ip22zilog_port *up)
+{
+	struct zilog_channel *channel;
+	int i;
+
+	if (up->flags & IP22ZILOG_FLAG_RESET_DONE)
+		return;
+
+	/* Let pending transmits finish.  */
+	channel = ZILOG_CHANNEL_FROM_PORT(&up->port);
+	for (i = 0; i < 1000; i++) {
+		unsigned char stat = read_zsreg(channel, R1);
+		if (stat & ALL_SNT)
+			break;
+		udelay(100);
+	}
+
+	if (!ZS_IS_CHANNEL_A(up)) {
+		up++;
+		channel = ZILOG_CHANNEL_FROM_PORT(&up->port);
+	}
+	write_zsreg(channel, R9, FHWRES);
+	ZSDELAY_LONG();
+	(void) read_zsreg(channel, R0);
+
+	up->flags |= IP22ZILOG_FLAG_RESET_DONE;
+	up->next->flags |= IP22ZILOG_FLAG_RESET_DONE;
+}
+
 static void __ip22zilog_startup(struct uart_ip22zilog_port *up)
 {
 	struct zilog_channel *channel;
 
 	channel = ZILOG_CHANNEL_FROM_PORT(&up->port);
+
+	__ip22zilog_reset(up);
+
+	__load_zsregs(channel, up->curregs);
+	/* set master interrupt enable */
+	write_zsreg(channel, R9, up->curregs[R9]);
 	up->prev_status = readb(&channel->control);
 
 	/* Enable receiver and transmitter.  */
@@ -859,8 +894,6 @@ ip22zilog_set_termios(struct uart_port *port, struct ktermios *termios,
 	else
 		up->flags &= ~IP22ZILOG_FLAG_MODEM_STATUS;
 
-	up->cflag = termios->c_cflag;
-
 	ip22zilog_maybe_update_regs(up, ZILOG_CHANNEL_FROM_PORT(port));
 	uart_update_timeout(port, termios->c_cflag, baud);
 
@@ -992,74 +1025,29 @@ ip22zilog_console_write(struct console *con, const char *s, unsigned int count)
 	spin_unlock_irqrestore(&up->port.lock, flags);
 }
 
-void
-ip22serial_console_termios(struct console *con, char *options)
-{
-	int baud = 9600, bits = 8, cflag;
-	int parity = 'n';
-	int flow = 'n';
-
-	if (options)
-		uart_parse_options(options, &baud, &parity, &bits, &flow);
-
-	cflag = CREAD | HUPCL | CLOCAL;
-
-	switch (baud) {
-		case 150: cflag |= B150; break;
-		case 300: cflag |= B300; break;
-		case 600: cflag |= B600; break;
-		case 1200: cflag |= B1200; break;
-		case 2400: cflag |= B2400; break;
-		case 4800: cflag |= B4800; break;
-		case 9600: cflag |= B9600; break;
-		case 19200: cflag |= B19200; break;
-		case 38400: cflag |= B38400; break;
-		default: baud = 9600; cflag |= B9600; break;
-	}
-
-	con->cflag = cflag | CS8;			/* 8N1 */
-
-	uart_update_timeout(&ip22zilog_port_table[con->index].port, cflag, baud);
-}
-
 static int __init ip22zilog_console_setup(struct console *con, char *options)
 {
 	struct uart_ip22zilog_port *up = &ip22zilog_port_table[con->index];
 	unsigned long flags;
-	int baud, brg;
-
-	printk("Console: ttyS%d (IP22-Zilog)\n", con->index);
+	int baud = 9600, bits = 8;
+	int parity = 'n';
+	int flow = 'n';
 
-	/* Get firmware console settings.  */
-	ip22serial_console_termios(con, options);
+	up->flags |= IP22ZILOG_FLAG_IS_CONS;
 
-	/* Firmware console speed is limited to 150-->38400 baud so
-	 * this hackish cflag thing is OK.
-	 */
-	switch (con->cflag & CBAUD) {
-	case B150: baud = 150; break;
-	case B300: baud = 300; break;
-	case B600: baud = 600; break;
-	case B1200: baud = 1200; break;
-	case B2400: baud = 2400; break;
-	case B4800: baud = 4800; break;
-	default: case B9600: baud = 9600; break;
-	case B19200: baud = 19200; break;
-	case B38400: baud = 38400; break;
-	};
-
-	brg = BPS_TO_BRG(baud, ZS_CLOCK / ZS_CLOCK_DIVISOR);
+	printk(KERN_INFO "Console: ttyS%d (IP22-Zilog)\n", con->index);
 
 	spin_lock_irqsave(&up->port.lock, flags);
 
-	up->curregs[R15] = BRKIE;
-	ip22zilog_convert_to_zs(up, con->cflag, 0, brg);
+	up->curregs[R15] |= BRKIE;
 
 	__ip22zilog_startup(up);
 
 	spin_unlock_irqrestore(&up->port.lock, flags);
 
-	return 0;
+	if (options)
+		uart_parse_options(options, &baud, &parity, &bits, &flow);
+	return uart_set_options(&up->port, con, baud, parity, bits, flow);
 }
 
 static struct uart_driver ip22zilog_reg;
@@ -1140,25 +1128,10 @@ static void __init ip22zilog_prepare(void)
 		up[(chip * 2) + 1].port.line = (chip * 2) + 1;
 		up[(chip * 2) + 1].flags |= IP22ZILOG_FLAG_IS_CHANNEL_A;
 	}
-}
-
-static void __init ip22zilog_init_hw(void)
-{
-	int i;
-
-	for (i = 0; i < NUM_CHANNELS; i++) {
-		struct uart_ip22zilog_port *up = &ip22zilog_port_table[i];
-		struct zilog_channel *channel = ZILOG_CHANNEL_FROM_PORT(&up->port);
-		unsigned long flags;
-		int baud, brg;
 
-		spin_lock_irqsave(&up->port.lock, flags);
-
-		if (ZS_IS_CHANNEL_A(up)) {
-			write_zsreg(channel, R9, FHWRES);
-			ZSDELAY_LONG();
-			(void) read_zsreg(channel, R0);
-		}
+	for (channel = 0; channel < NUM_CHANNELS; channel++) {
+		struct uart_ip22zilog_port *up = &ip22zilog_port_table[channel];
+		int brg;
 
 		/* Normal serial TTY. */
 		up->parity_mask = 0xff;
@@ -1169,16 +1142,10 @@ static void __init ip22zilog_init_hw(void)
 		up->curregs[R9] = NV | MIE;
 		up->curregs[R10] = NRZ;
 		up->curregs[R11] = TCBR | RCBR;
-		baud = 9600;
-		brg = BPS_TO_BRG(baud, ZS_CLOCK / ZS_CLOCK_DIVISOR);
+		brg = BPS_TO_BRG(9600, ZS_CLOCK / ZS_CLOCK_DIVISOR);
 		up->curregs[R12] = (brg & 0xff);
 		up->curregs[R13] = (brg >> 8) & 0xff;
 		up->curregs[R14] = BRENAB;
-		__load_zsregs(channel, up->curregs);
-	        /* set master interrupt enable */
-	        write_zsreg(channel, R9, up->curregs[R9]);
-
-		spin_unlock_irqrestore(&up->port.lock, flags);
 	}
 }
 
@@ -1195,8 +1162,6 @@ static int __init ip22zilog_ports_init(void)
 		panic("IP22-Zilog: Unable to register zs interrupt handler.\n");
 	}
 
-	ip22zilog_init_hw();
-
 	ret = uart_register_driver(&ip22zilog_reg);
 	if (ret == 0) {
 		int i;
diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
index 6a5203f..9963f81 100644
--- a/include/linux/serial_core.h
+++ b/include/linux/serial_core.h
@@ -437,7 +437,7 @@ uart_handle_sysrq_char(struct uart_port *port, unsigned int ch)
 #ifdef SUPPORT_SYSRQ
 	if (port->sysrq) {
 		if (ch && time_before(jiffies, port->sysrq)) {
-			handle_sysrq(ch, port->info->tty);
+			handle_sysrq(ch, port->info ? port->info->tty : NULL);
 			port->sysrq = 0;
 			return 1;
 		}
-- 
1.4.4.4

^ permalink raw reply related	[flat|nested] 64+ messages in thread

* (unknown)
@ 2007-04-30 22:06 Corey Minyard
  0 siblings, 0 replies; 64+ messages in thread
From: Corey Minyard @ 2007-04-30 22:06 UTC (permalink / raw)
  To: Linux Kernel, Russell King; +Cc: linux-serial

I think I've spotted a bug in the 8250 code, but I'm not really
sure.  I'm having a hard time understanding why the lsr_break_flag
is necessary.

Subject: Serial 8250: clear the lsr_break_flag at open

The lsr_break_flag in the 8250 driver is not cleared when the port is
opened.  This means that on a serial console, if a break has occurred
while the port is closed, the first call to receive_chars() will
result in a break being delivered at that point.  Clear the flag at
open to fix the problem.

Signed-off-by: Corey Minyard <minyard@acm.org>

Index: linux-2.6.21/drivers/serial/8250.c
===================================================================
--- linux-2.6.21.orig/drivers/serial/8250.c
+++ linux-2.6.21/drivers/serial/8250.c
@@ -1638,6 +1638,7 @@ static int serial8250_startup(struct uar
 
 	up->capabilities = uart_config[up->port.type].flags;
 	up->mcr = 0;
+	up->lsr_break_flag = 0;
 
 	if (up->port.type == PORT_16C950) {
 		/* Wake up and initialize UART */

^ permalink raw reply	[flat|nested] 64+ messages in thread

* (unknown), 
       [not found] <000601c7708e$f36a37c0$0200a8c0@7950gx2>
@ 2007-03-27 16:42 ` Chris Mawer
  0 siblings, 0 replies; 64+ messages in thread
From: Chris Mawer @ 2007-03-27 16:42 UTC (permalink / raw)
  To: linux-serial

Unsubscribe linux-kernel


^ permalink raw reply	[flat|nested] 64+ messages in thread

* (unknown)
@ 2006-10-15 14:20 upcajxhkb
  0 siblings, 0 replies; 64+ messages in thread
From: upcajxhkb @ 2006-10-15 14:20 UTC (permalink / raw)


\x01BOUNDARY_OUTLOOK

^ permalink raw reply	[flat|nested] 64+ messages in thread

* (unknown), 
@ 2006-08-07  2:46 colet aeneas
  0 siblings, 0 replies; 64+ messages in thread
From: colet aeneas @ 2006-08-07  2:46 UTC (permalink / raw)
  To: linux-serial

Hello, 
I'm Dave Johnson, and I want to share an opportunity www.realhighprofit.net which pays me everyday. Did you know that Internet allows you to participate in highly profitable opportunities without leaving your chair? 

Yes it's true! I found a program which pays me 5% profit every day. Unbelievable, yes? Jest check out this site -  www.realhighprofit.net
Dave.


wsnqgqsfjw

^ permalink raw reply	[flat|nested] 64+ messages in thread

* (unknown)
@ 2006-06-16 17:54 kueth
  0 siblings, 0 replies; 64+ messages in thread
From: kueth @ 2006-06-16 17:54 UTC (permalink / raw)




^ permalink raw reply	[flat|nested] 64+ messages in thread

* (unknown)
@ 2006-05-01  7:56 bec
  0 siblings, 0 replies; 64+ messages in thread
From: bec @ 2006-05-01  7:56 UTC (permalink / raw)




^ permalink raw reply	[flat|nested] 64+ messages in thread

* (unknown)
@ 2006-04-30 23:40 jungjackson
  0 siblings, 0 replies; 64+ messages in thread
From: jungjackson @ 2006-04-30 23:40 UTC (permalink / raw)




^ permalink raw reply	[flat|nested] 64+ messages in thread

* (unknown)
@ 2006-03-11 21:02 lwvxfb
  0 siblings, 0 replies; 64+ messages in thread
From: lwvxfb @ 2006-03-11 21:02 UTC (permalink / raw)




^ permalink raw reply	[flat|nested] 64+ messages in thread

* (unknown)
@ 2005-11-17 18:48 Stuart MacDonald
  0 siblings, 0 replies; 64+ messages in thread
From: Stuart MacDonald @ 2005-11-17 18:48 UTC (permalink / raw)
  To: linux-serial

subscribe


^ permalink raw reply	[flat|nested] 64+ messages in thread

* (unknown)
@ 2005-07-27 16:19 drlim
  0 siblings, 0 replies; 64+ messages in thread
From: drlim @ 2005-07-27 16:19 UTC (permalink / raw)




^ permalink raw reply	[flat|nested] 64+ messages in thread

* (unknown)
@ 2005-07-23  4:50 Mr.Derrick Tanner.
  0 siblings, 0 replies; 64+ messages in thread
From: Mr.Derrick Tanner. @ 2005-07-23  4:50 UTC (permalink / raw)




^ permalink raw reply	[flat|nested] 64+ messages in thread

* (unknown)
@ 2005-06-21 11:48 pliskie
  0 siblings, 0 replies; 64+ messages in thread
From: pliskie @ 2005-06-21 11:48 UTC (permalink / raw)




^ permalink raw reply	[flat|nested] 64+ messages in thread

* (unknown)
@ 2005-06-16 12:14 LeslieGolden
  0 siblings, 0 replies; 64+ messages in thread
From: LeslieGolden @ 2005-06-16 12:14 UTC (permalink / raw)




^ permalink raw reply	[flat|nested] 64+ messages in thread

* (unknown)
@ 2005-06-11  2:00 dtasman
  0 siblings, 0 replies; 64+ messages in thread
From: dtasman @ 2005-06-11  2:00 UTC (permalink / raw)




^ permalink raw reply	[flat|nested] 64+ messages in thread

* (unknown)
@ 2005-06-10  2:30 bewails
  0 siblings, 0 replies; 64+ messages in thread
From: bewails @ 2005-06-10  2:30 UTC (permalink / raw)




^ permalink raw reply	[flat|nested] 64+ messages in thread

* (unknown)
@ 2005-05-16  8:11 ucmjfspdc
  0 siblings, 0 replies; 64+ messages in thread
From: ucmjfspdc @ 2005-05-16  8:11 UTC (permalink / raw)




^ permalink raw reply	[flat|nested] 64+ messages in thread

* (unknown)
@ 2005-05-08  3:52 xiytw
  0 siblings, 0 replies; 64+ messages in thread
From: xiytw @ 2005-05-08  3:52 UTC (permalink / raw)




^ permalink raw reply	[flat|nested] 64+ messages in thread

* (unknown)
@ 2005-04-22  2:00 vyidqsw
  0 siblings, 0 replies; 64+ messages in thread
From: vyidqsw @ 2005-04-22  2:00 UTC (permalink / raw)




^ permalink raw reply	[flat|nested] 64+ messages in thread

* (unknown)
@ 2004-10-09 22:23 zzz
  0 siblings, 0 replies; 64+ messages in thread
From: zzz @ 2004-10-09 22:23 UTC (permalink / raw)
  To: linux-serial

subscribe

^ permalink raw reply	[flat|nested] 64+ messages in thread

* (unknown), 
@ 2004-09-02 14:27 Larry
  0 siblings, 0 replies; 64+ messages in thread
From: Larry @ 2004-09-02 14:27 UTC (permalink / raw)
  To: linux-kernel

Save up to 80% on popular meds!

*** GREAT SPECIALS ***

Check it out: http://www.oabwkdfbabdfj.com/?92

- No doctor visits or hassles
- Quick delivery to your front door

Visit us here: http://www.oabwkdfbabdfj.com/?92


On medication long term?  
Buy bulk through us and LITERALLY SAVE THOUSANDS!



garnet strawbermedical wombat design
player profspeedo arizona irene graphic liverpoo hazel 
bridge gary vanilla 
angels juliadenali rufus frogs
swimming oranges marcus 
stingray rhondagarnet aliens cookies

valentin t-bonehanna sweety scooby theatre cherry republic 


^ permalink raw reply	[flat|nested] 64+ messages in thread

* (unknown)
@ 2004-08-24  6:05 Francisco M. Marzoa Alonso
  0 siblings, 0 replies; 64+ messages in thread
From: Francisco M. Marzoa Alonso @ 2004-08-24  6:05 UTC (permalink / raw)
  To: linux-serial

>>       TOut.tv_sec = Wait / 1000;
>>       TOut.tv_usec = Wait % 1000;
>
>So "Wait" is in milli-seconds? That doesn't look correct, then:)
>
>        TOut.tv_sec = Wait / 1000;
>        TOut.tv_usec = (Wait % 1000) * 1000;

Sure you're right, but this is a thing that I do not understand. I made a 
function GetTickCount to emulate Window's one based on gettimeofday and see 
that milliseconds on timeval structure can have values up to 999999 when I 
expect to found a maximum value of 999 as there are only 1000 milliseconds in 
a second.

>>       if ( select ( FD_SETSIZE, &readfs, NULL, NULL, &TOut ) ) {

>That's most probably wrong. "FD_SETSIZE" should be "HND + 1". ...and the
>"if" should fire like "if (select (...) > 0)"

Ok, I've tried some different values, I'll use only HND+1 from now.

>This could hand because you didn't select() on HND *before* writing to
>it.

You're right. I've fixed this. 

>>       if ( ! select ( FD_SETSIZE, NULL, &writefs, NULL, &TOut ) ) {
>>               perror ( "Timeout waiting on CommWriteChar");
>>               return 0;
>>       }

>select() checks if the next access won't hand (but may return
>successfull or with an error instead). It doesn't make much sense to do
>that *after* having something written down there:)

>>       return ( bcount );
>> }

>Btw: return isn't a function. It's return value doesn't need an own pair
>of parentheses.

I usually forget this, but I think this makes no efective difference and the 
code generated by the compiler is the same and I feel more comfortable using 
them.

I've done this changes, that I've no doubt that are needed, but I continue 
having the same problems as described in my previous e-mail.

Thanks a lot.


-- 
Francisco M. Marzoa Alonso
Responsable de Software - Softrónica S.A.
http://www.softronica.org/
C/Herrerías, 14 - 28760 Tres Cantos (Madrid)
tfno. +34 918 038 600  fax. +34 918 032 297
-
To unsubscribe from this list: send the line "unsubscribe linux-serial" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 64+ messages in thread

* (unknown)
@ 2004-08-14  6:38 sky
  0 siblings, 0 replies; 64+ messages in thread
From: sky @ 2004-08-14  6:38 UTC (permalink / raw)




^ permalink raw reply	[flat|nested] 64+ messages in thread

* (unknown)
@ 2004-08-11  1:10 sky
  0 siblings, 0 replies; 64+ messages in thread
From: sky @ 2004-08-11  1:10 UTC (permalink / raw)




^ permalink raw reply	[flat|nested] 64+ messages in thread

* (unknown)
@ 2004-08-07  4:32 sky
  0 siblings, 0 replies; 64+ messages in thread
From: sky @ 2004-08-07  4:32 UTC (permalink / raw)




^ permalink raw reply	[flat|nested] 64+ messages in thread

* (unknown)
@ 2004-08-07  1:05 kkkkkkk
  0 siblings, 0 replies; 64+ messages in thread
From: kkkkkkk @ 2004-08-07  1:05 UTC (permalink / raw)




^ permalink raw reply	[flat|nested] 64+ messages in thread

* (unknown)
@ 2004-08-06  1:02 lowinterrest
  0 siblings, 0 replies; 64+ messages in thread
From: lowinterrest @ 2004-08-06  1:02 UTC (permalink / raw)




^ permalink raw reply	[flat|nested] 64+ messages in thread

* (unknown)
@ 2004-08-01 10:30 sky
  0 siblings, 0 replies; 64+ messages in thread
From: sky @ 2004-08-01 10:30 UTC (permalink / raw)




^ permalink raw reply	[flat|nested] 64+ messages in thread

* (unknown), 
@ 2004-03-16 22:48 Kumar Gala
  0 siblings, 0 replies; 64+ messages in thread
From: Kumar Gala @ 2004-03-16 22:48 UTC (permalink / raw)
  To: rmk+serial; +Cc: Dan Malek, Tom Rini, linux-serial

Russell,

I'm working on a new uart driver for the 82xx CPM that uses the 
serial_core.  I had a few questions about how things worked that were 
unclear to me.

1. how do tty's (in /dev/*) map to registered uart_driver(s)
2. what is the purpose of 'driver_name' and 'dev_name' in the 
uart_driver struct?
3. how are major/minor device id's being allocated for uart drivers?
4. how does uart_port line related to everything else?

thanks

- kumar


^ permalink raw reply	[flat|nested] 64+ messages in thread

* (unknown), 
@ 2004-03-15 22:13 Brice Blount
  0 siblings, 0 replies; 64+ messages in thread
From: Brice Blount @ 2004-03-15 22:13 UTC (permalink / raw)
  To: linux-scsi; +Cc: linux-serial

[-- Attachment #1: Type: text/plain, Size: 1041 bytes --]

Hello, 

This is Clarke Robbins President & CEO of
LoanSafe4AllNow1. Interest Rates have dropped basis
points once again to their lowest in years. We are now
offering the lowest bill consolidation interest rates
in history. Even if you just consolidated, we can save
you more $ now, faster! We can:

* Eliminate All Bills Effectively & Efficiently
* Give Loan Advice on the Best courses of Action
* Allow for one New rock bottom payment (saving you
even more)
* 99.9% of all Loans qualify & we do NO HISTORY, All
are approved in our program!

We hope to hear from you soon to earn your business &
trust. Click Below.

*Today's Low Rate is 2.47%

Sincerely,

Clarke Robbins
CEO & President
LoanSafe4AllNow

http://lowerrates4you.com/?partid=n278 

















The above gift or special offer was sent to you as a 
subscriber of Direct Media. We will continue to bring you 
valuable offers on products and services that interest you 
most. To modify your future preference with us: 
http://lowerrates4you.com/st.html 


self
2
%RND _TEXT


^ permalink raw reply	[flat|nested] 64+ messages in thread

* (unknown)
@ 2003-12-21 13:39 "Grigorii Rubtsov" 
  0 siblings, 0 replies; 64+ messages in thread
From: "Grigorii Rubtsov"  @ 2003-12-21 13:39 UTC (permalink / raw)
  To: rmk+serial; +Cc: linux-serial



  Dear Developers.

There is a misprint in linux-2.6.0/drivers/serial/Kconfig file concerning 8250 driver

/drivers/serial/Kconfig states

   config SERIAL_8250
             ........................
   	     To compile this driver as a module, choose M here: the
 	     module will be called serial.

But in real world the module is called 8250 (but not serial). This misprint can lead to confusion. (user will not find desired module)

Best regards,
Grigory Rubtsov.


^ permalink raw reply	[flat|nested] 64+ messages in thread

* (unknown)
@ 2003-12-18  7:37 achen1
  0 siblings, 0 replies; 64+ messages in thread
From: achen1 @ 2003-12-18  7:37 UTC (permalink / raw)




^ permalink raw reply	[flat|nested] 64+ messages in thread

* (unknown), 
@ 2003-11-18 13:26 Michael Kohne
  0 siblings, 0 replies; 64+ messages in thread
From: Michael Kohne @ 2003-11-18 13:26 UTC (permalink / raw)
  To: linux-serial; +Cc: tytso

Proposed modification to the low_latency flag in version 5.05c of the
linux 16550 driver (drivers/char/serial.c).

My ultimate goal is to get this change accepted into the kernel so that I
don't have to maintain it on our end forever.

Background:
My company (Gasboy LLC) builds fuel management systems. Among other things
our systems talk via RS-422/485 lines to a variety of devices. Our newest
product is linux based and uses an 8 port serial board based on Exar 16654
quad uarts. A single serial port may be used to talk to up 32 devices on a
422 or 485 loop. The linux system is the master and polls the devices for
status information. When we poll a device, we send a small message out
including the device's address and expect the device to respond. If the
device does not respond in X milliseconds, we go on to the next. It is
important to minimize the timeout (X) so that we can talk to as many
devices as possible in as short a time as possible (the devices are gas
pumps, card readers, etc). Minimizing X becomes especially important when
devices are disabled or the system is mis-configured to talk to more
devices than exist (we don't want to hold up operations on live devices
waiting for dead ones). Timeouts are thus specified in terms of when the
FIRST character (STX) comes back from the device. If the STX is not
received in time, the device is assumed to be not present. The timeouts
are VERY short (on the order of 20-30 milliseconds).

The problem:
The old system hardware had uarts with no FIFO. Therefore, getting the STX
immediately after it hit the uart was no problem. The new system has 64
byte fifos. Since the linux serial drivers set the fifo to 56 bytes (a
good choice for high-bandwidth communications), the response packet (22
bytes) fits entirely in the fifo without hitting the trigger. The uart
will wait for 4 empty character times before it triggers the interrupt. At
9600 baud (about 1 millisecond per character) that's about 26 milliseconds
after the STX came in before the application sees it. Since the remote
device DOES take some time to respond, adding 26 milliseconds to the
response time causes our system to believe the device is gone and try to
recover appropriately.

Attempted solutions:
I have played with our timeouts, but significantly extending them (to the
point that they cover the fifo latency) causes user-visible delays when
large numbers of devices are configured on the loop, but missing.
I tried forcing the system to treat the relevant uarts as 16450 instead of
16654, but then we start dropping characters on a regular basis
(especially when heavy ethernet or ppp traffic occurs), thus slowing the
loops down again.
I do have the low_latency flag set, but that of course only changes how
data moves around AFTER it's received from the uart. It does nothing to
speed data in from the uart.

The proposed solution:
An optimal solution to the problem seems (to me) to be reducing the FIFO
trigger levels whenever low_latency is set on the port. This minimizes the
amount of time from when a character is received to when the application
layer sees it (which I believe to be the point of the low_latency flag
already).

Problems with this solution:
1) By reducing the receive fifo trigger level, we significantly increase
the interrupt rate of the uart, and therefore the overhead in servicing
it. I'm OK with this because the low_latency flag already specifies that
you are trading CPU overhead for latency.

2) Conflating the trigger level changes with the established behaviour of
low_latency seems appropriate to me, but better-informed persons might
well disagree. The alternative (to maintain a seperate flag) seems worse.



Results:
On a kernel with this patch installed, I did some timing analysis. My test
code sends a packet out a 422 port and waits for an STX to come back. With
setserial <port> ^low_latency, my timings are about 34 milliseconds. With
setserial <port> low_latency, my timings are 17 milliseconds. (The 34
milliseconds matches the times I got with my old kernel).


Addendum:
In the process of internally reviewing this patch at our company, I found
another division that had made a similar modification for internal use. So
I am now convinced that this is a useful modification.



The proposed patch (in diff -u format):
This patch is against the standard serial.c distributed with the 2.4.22
kernel.
If folks think that this is reasonable for kernel inclusion, I'll port it
to 2.5/2.6 as well.

--- serial.2.4.22.c	Tue Nov 11 02:13:41 2003
+++ serial.c	Tue Nov 11 02:13:04 2003
@@ -62,6 +62,9 @@
  *        Robert Schwebel <robert@schwebel.de>,
  *        Juergen Beisert <jbeisert@eurodsn.de>,
  *        Theodore Ts'o <tytso@mit.edu>
+ *
+ * 11/03: Set minimum fifo trigger level when low_latency set.
+ *        Michael Kohne <mhkohne@discordia.org>
  */

 static char *serial_version = "5.05c";
@@ -1728,7 +1731,10 @@

 	/* Set up FIFO's */
 	if (uart_config[info->state->type].flags & UART_USE_FIFO) {
-		if ((info->state->baud_base / quot) < 2400)
+		/* minimize lag time on low baud or user request */
+		/* otherwise, use appropriate default for this uart */
+		if ( ((info->state->baud_base / quot) < 2400) ||
+			(info->tty->low_latency) )
 			fcr = UART_FCR_ENABLE_FIFO | UART_FCR_TRIGGER_1;
 #ifdef CONFIG_SERIAL_RSA
 		else if (info->state->type == PORT_RSA)




-- 
Michael Kohne        mhkohne@discordia.org
"You should be smarter than the equipment you are trying to operate." --
Matt Osborne



^ permalink raw reply	[flat|nested] 64+ messages in thread

* (unknown)
@ 2002-08-27  1:48 Alex Pavloff
  0 siblings, 0 replies; 64+ messages in thread
From: Alex Pavloff @ 2002-08-27  1:48 UTC (permalink / raw)
  To: 'linux-serial@vger.kernel.org'


Good (morning/afternoon/evening) folks,

I am writing Modbus RTU code for Linux 2.4.19.  While seeminly simple to do
in userspace, there's one big kicker that I can't handle there easily.
Modbus RTU is a binary serial protocol used in industrial automation.  First
used by the Modicon PLCs, it's found on a variety of devices from a variety
of manufacturers.

The specification is at www.modbus.org, under "Modbus Standard Library", and
its the Modbus Serial Protocol Reference Guide.

Here's the part that I don't think I can resolve in userspace:
-----
RTU Framing
In RTU mode, messages start with a silent interval of at least 3.5 character
times. This is most easily implemented as a multiple of character times at
the baud rate that is being used on the network (shown as T1-T2-T3-T4 in the
figure below). The first field then transmitted is the device address.

The allowable characters transmitted for all fields are hexadecimal 0-9,
A-F. Networked devices monitor the network bus continuously, including
during the 'silent' intervals. When the first field (the address field) is
received, each device decodes it to find out if it is the addressed device.

Following the last transmitted character, a similar interval of at least 3.5
character times marks the end of the message. A new message can begin after
this interval.

The entire message frame must be transmitted as a continuous stream. If a
silent interval of more than 1.5 character times occurs before completion of
the frame, the receiving device flushes the incomplete message and assumes
that the next byte will be the address field of a new message.
-----

3.5 character times at high baud rates is not something I can pull off with
termios.  To get the Modbus RTU frames without resorting to some really
strange code in userspace, should I write a line-discipline module whose
sole purpose is to deal with the character timing?

Any comments (yay/nay/huh?) appreciated.

Alex Pavloff
Software Engineer
Eason Technology
 



^ permalink raw reply	[flat|nested] 64+ messages in thread

end of thread, other threads:[~2014-11-02 20:01 UTC | newest]

Thread overview: 64+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-04 17:59 (unknown), Matthieu CASTET
2012-03-04 17:59 ` [PATCH 1/9] tty: make receive_buf() return the amout of bytes received Matthieu CASTET
2012-03-05 10:40   ` Alan Cox
2012-03-04 17:59 ` [PATCH 2/9] tty : make n_tty_receive_buf return bytes received in raw mode Matthieu CASTET
2012-03-04 17:59 ` [PATCH 3/9] tty: make hci_uart_tty_receive return bytes received Matthieu CASTET
2012-03-04 17:59 ` [PATCH 4/9] tty : kill receive_room usage in vt Matthieu CASTET
2012-03-05 10:29   ` Alan Cox
2012-03-04 17:59 ` [PATCH 5/9] tty : kill receive_room usage in speakup Matthieu CASTET
2012-03-04 17:59 ` [PATCH 6/9] tty : don't use receive_room in tty_set_ldisc Matthieu CASTET
2012-03-04 17:59 ` [PATCH 7/9] tty : kill receive_room usage in tty_buffer Matthieu CASTET
2012-03-05 10:31   ` Alan Cox
2012-03-04 17:59 ` [PATCH 8/9] tty : kill receive_room usage in mxser Matthieu CASTET
2012-03-05 10:34   ` Alan Cox
2012-03-04 17:59 ` [PATCH 9/9] tty : make receive_room internal to N_TTY line discipline Matthieu CASTET
2012-03-05 10:36   ` Alan Cox
     [not found] <1570038211.167595.1414613146892.JavaMail.yahoo@jws10056.mail.ne1.yahoo.com>
     [not found] ` <1835234304.171617.1414613165674.JavaMail.yahoo@jws10089.mail.ne1.yahoo.com>
     [not found]   ` <1938862685.172387.1414613200459.JavaMail.yahoo@jws100180.mail.ne1.yahoo.com>
     [not found]     ` <705402329.170339.1414613213653.JavaMail.yahoo@jws10087.mail.ne1.yahoo.com>
     [not found]       ` <760168749.169371.1414613227586.JavaMail.yahoo@jws10082.mail.ne1.yahoo.com>
     [not found]         ` <1233923671.167957.1414613439879.JavaMail.yahoo@jws10091.mail.ne1.yahoo.com>
     [not found]           ` <925985882.172122.1414613520734.JavaMail.yahoo@jws100207.mail.ne1.yahoo.com>
     [not found]             ` <1216694778.172990.1414613570775.JavaMail.yahoo@jws100152.mail.ne1.yahoo.com>
     [not found]               ` <1213035306.169838.1414613612716.JavaMail.yahoo@jws10097.mail.ne1.yahoo.com>
     [not found]                 ` <2058591563.172973.1414613668636.JavaMail.yahoo@jws10089.mail.ne1.yahoo.com>
     [not found]                   ` <1202030640.175493 .1414613712352.JavaMail.yahoo@jws10036.mail.ne1.yahoo.com>
     [not found]                     ` <1111049042.175610.1414613739099.JavaMail.yahoo@jws100165.mail.ne1.yahoo.com>
     [not found]                       ` <574125160.175950.1414613784216.JavaMail.yahoo@jws100158.mail.ne1.yahoo.com>
     [not found]                         ` <1726966600.175552.1414613846198.JavaMail.yahoo@jws100190.mail.ne1.yahoo.com>
     [not found]                           ` <976499752.219775.1414613888129.JavaMail.yahoo@jws100101.mail.ne1.yahoo.com>
     [not found]                             ` <1400960529.171566.1414613936238.JavaMail.yahoo@jws10059.mail.ne1.yahoo.com>
     [not found]                               ` <1333619289.175040.1414613999304.JavaMail.yahoo@jws100196.mail.ne1.yahoo.com>
     [not found]                                 ` <1038759122.176173.1414614054070.JavaMail.yahoo@jws100138.mail.ne1.yahoo.com>
     [not found]                                   ` <1109995533.176150.1414614101940.JavaMail.yahoo@jws100140.mail.ne1.yahoo.com>
     [not found]                                     ` <809474730.174920.1414614143971.JavaMail.yahoo@jws100154.mail.ne1.yahoo.com>
     [not found]                                       ` <1234226428.170349.1414614189490.JavaMail .yahoo@jws10056.mail.ne1.yahoo.com>
     [not found]                                         ` <1122464611.177103.1414614228916.JavaMail.yahoo@jws100161.mail.ne1.yahoo.com>
     [not found]                                           ` <1350859260.174219.1414614279095.JavaMail.yahoo@jws100176.mail.ne1.yahoo.com>
     [not found]                                             ` <1730751880.171557.1414614322033.JavaMail.yahoo@jws10060.mail.ne1.yahoo.com>
     [not found]                                               ` <642429550.177328.1414614367628.JavaMail.yahoo@jws100165.mail.ne1.yahoo.com>
     [not found]                                                 ` <1400780243.20511.1414614418178.JavaMail.yahoo@jws100162.mail.ne1.yahoo.com>
     [not found]                                                   ` <2025652090.173204.1414614462119.JavaMail.yahoo@jws10087.mail.ne1.yahoo.com>
     [not found]                                                     ` <859211720.180077.1414614521867.JavaMail.yahoo@jws100147.mail.ne1.yahoo.com>
     [not found]                                                       ` <258705675.173585.1414614563057.JavaMail.yahoo@jws10078.mail.ne1.yahoo.com>
     [not found]                                                         ` <1773234186.173687.1414614613736.JavaMail.yahoo@jws10078.mail.ne1.yahoo.com>
     [not found]                                                           ` <1132079010.173033.1414614645153.JavaMail.yahoo@jws10066.mail.ne1.ya hoo.com>
     [not found]                                                             ` <1972302405.176488.1414614708676.JavaMail.yahoo@jws100166.mail.ne1.yahoo.com>
     [not found]                                                               ` <1713123000.176308.1414614771694.JavaMail.yahoo@jws10045.mail.ne1.yahoo.com>
     [not found]                                                                 ` <299800233.173413.1414614817575.JavaMail.yahoo@jws10066.mail.ne1.yahoo.com>
     [not found]                                                                   ` <494469968.179875.1414614903152.JavaMail.yahoo@jws100144.mail.ne1.yahoo.com>
     [not found]                                                                     ` <2136945987.171995.1414614942776.JavaMail.yahoo@jws10091.mail.ne1.yahoo.com>
     [not found]                                                                       ` <257674219.177708.1414615022592.JavaMail.yahoo@jws100181.mail.ne1.yahoo.com>
     [not found]                                                                         ` <716927833.181664.1414615075308.JavaMail.yahoo@jws100145.mail.ne1.yahoo.com>
     [not found]                                                                           ` <874940984.178797.1414615132802.JavaMail.yahoo@jws100157.mail.ne1.yahoo.com>
     [not found]                                                                             ` <1283488887.176736.1414615187657.JavaMail.yahoo@jws100183.mail.ne1.yahoo.com>
     [not found]                                                                               ` <777665713.175887.1414615236293.JavaMail.yahoo@jws10083.mail.ne1.yahoo.com>
     [not found]                                                                                 ` <585395776.176325.1 414615298260.JavaMail.yahoo@jws10033.mail.ne1.yahoo.com>
     [not found]                                                                                   ` <178352191.221832.1414615355071.JavaMail.yahoo@jws100104.mail.ne1.yahoo.com>
     [not found]                                                                                     ` <108454213.176606.1414615522058.JavaMail.yahoo@jws10053.mail.ne1.yahoo.com>
     [not found]                                                                                       ` <1617229176.177502.1414615563724.JavaMail.yahoo@jws10030.mail.ne1.yahoo.com>
     [not found]                                                                                         ` <324334617.178254.1414615625247.JavaMail.yahoo@jws10089.mail.ne1.yahoo.com>
     [not found]                                                                                           ` <567135865.82376.1414615664442.JavaMail.yahoo@jws100136.mail.ne1.yahoo.com>
     [not found]                                                                                             ` <764758300.179669.1414615711821.JavaMail.yahoo@jws100107.mail.ne1.yahoo.com>
     [not found]                                                                                               ` <1072855470.183388.1414615775798.JavaMail.yahoo@jws100147.mail.ne1.yahoo.com>
     [not found]                                                                                                 ` <2134283632.173314.1414615831322.JavaMail.yahoo@jws10094.mail.ne1.yahoo.com>
     [not found]                                                                                                   ` <1454491902.178612.1414615875076.JavaMail.yahoo@jws100209.mail.ne1.yahoo.com>
     [not found]                                                                                                     ` <1881200547.147301.1414958000634.JavaMail.yahoo@jws100209.mail.ne1.yahoo.com>
2014-11-02 19:54                                                                                                       ` (unknown) MRS GRACE MANDA
  -- strict thread matches above, loose matches on Subject: below --
2014-07-09 17:49 (unknown), Sebastian Andrzej Siewior
2013-07-31  6:26 (unknown), Yoshinori Otani
2012-11-12 13:21 (unknown), Jayne Montgomery
2012-11-12 12:49 (unknown), Jayne Montgomery
2012-11-12 10:52 (unknown), Jayne Montgomery
2012-04-12 11:21 (unknown), monicaaluke01@gmail.com
2012-02-25 14:29 (unknown), Grieger, Anne
2011-11-18  4:54 (unknown), Robbin Setzer
2011-10-09 20:56 (unknown), MONEY GRAM CUSTOMER CARE
2011-04-14  7:15 (unknown) pradeep Annavarapu
2011-03-03  5:39 (unknown) pradeep Annavarapu
2011-03-01 23:48 (unknown), Mr. henry
2011-03-01 23:47 (unknown), Mr. henry
2010-11-19  4:38 (unknown) Mayank Rana
2007-11-25  2:10 (unknown) Thomas Bogendoerfer
2007-04-30 22:06 (unknown) Corey Minyard
     [not found] <000601c7708e$f36a37c0$0200a8c0@7950gx2>
2007-03-27 16:42 ` (unknown), Chris Mawer
2006-10-15 14:20 (unknown) upcajxhkb
2006-08-07  2:46 (unknown), colet aeneas
2006-06-16 17:54 (unknown) kueth
2006-05-01  7:56 (unknown) bec
2006-04-30 23:40 (unknown) jungjackson
2006-03-11 21:02 (unknown) lwvxfb
2005-11-17 18:48 (unknown) Stuart MacDonald
2005-07-27 16:19 (unknown) drlim
2005-07-23  4:50 (unknown) Mr.Derrick Tanner.
2005-06-21 11:48 (unknown) pliskie
2005-06-16 12:14 (unknown) LeslieGolden
2005-06-11  2:00 (unknown) dtasman
2005-06-10  2:30 (unknown) bewails
2005-05-16  8:11 (unknown) ucmjfspdc
2005-05-08  3:52 (unknown) xiytw
2005-04-22  2:00 (unknown) vyidqsw
2004-10-09 22:23 (unknown) zzz
2004-09-02 14:27 (unknown), Larry
2004-08-24  6:05 (unknown) Francisco M. Marzoa Alonso
2004-08-14  6:38 (unknown) sky
2004-08-11  1:10 (unknown) sky
2004-08-07  4:32 (unknown) sky
2004-08-07  1:05 (unknown) kkkkkkk
2004-08-06  1:02 (unknown) lowinterrest
2004-08-01 10:30 (unknown) sky
2004-03-16 22:48 (unknown), Kumar Gala
2004-03-15 22:13 (unknown), Brice Blount
2003-12-21 13:39 (unknown) "Grigorii Rubtsov" 
2003-12-18  7:37 (unknown) achen1
2003-11-18 13:26 (unknown), Michael Kohne
2002-08-27  1:48 (unknown) Alex Pavloff

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).