From: Russell King <rmk+lkml@arm.linux.org.uk>
To: Wen Xiong <wendyx@us.ibm.com>
Cc: Greg KH <greg@kroah.com>, linux-kernel@vger.kernel.org
Subject: Re: [ patch 2/5] drivers/serial/jsm: new serial device driver
Date: Wed, 30 Mar 2005 15:55:35 +0100 [thread overview]
Message-ID: <20050330155535.A13781@flint.arm.linux.org.uk> (raw)
In-Reply-To: <4231B9F9.2080401@us.ltcfwd.linux.ibm.com>; from wendyx@us.ibm.com on Fri, Mar 11, 2005 at 10:32:09AM -0500
Here's some belated comments. I won't even pretend to understand
any of your (imo overcomplex) driver - which is the reason I haven't
bothered commenting before now.
However, it seems that there may be some duplication between what
you're doing and what the rest of the kernel is doing for you.
This may not be desirable, and may actually cause subtle problems,
especially if you and the rest of the kernel decides to send, eg,
an XOFF character (so the remote end sees two XOFF characters).
On Fri, Mar 11, 2005 at 10:32:09AM -0500, Wen Xiong wrote:
> diff -Nuar linux-2.6.11.org/drivers/serial/jsm/jsm_tty.c linux-2.6.11.new/drivers/serial/jsm/jsm_tty.c
> --- linux-2.6.11.org/drivers/serial/jsm/jsm_tty.c 1969-12-31 18:00:00.000000000 -0600
> +++ linux-2.6.11.new/drivers/serial/jsm/jsm_tty.c 2005-03-10 16:34:37.342965976 -0600
> +static void jsm_tty_close(struct uart_port *port)
> +{
> + struct jsm_board *bd;
> + struct termios *ts;
> + struct jsm_channel *channel = (struct jsm_channel *)port;
> +
> + jsm_printk(CLOSE, INFO, &channel->ch_bd->pci_dev, "start\n");
> +
> + bd = channel->ch_bd;
> + ts = channel->uart_port.info->tty->termios;
> +
> + channel->ch_flags &= ~(CH_STOPI);
> +
> + channel->ch_open_count--;
> +
> + /*
> + * If we have HUPCL set, lower DTR and RTS
> + */
> + if (channel->ch_c_cflag & HUPCL) {
> + jsm_printk(CLOSE, INFO, &channel->ch_bd->pci_dev,
> + "Close. HUPCL set, dropping DTR/RTS\n");
> +
> + /* Drop RTS/DTR */
> + channel->ch_mostat &= ~(UART_MCR_DTR | UART_MCR_RTS);
> + bd->bd_ops->assert_modem_signals(channel);
> + }
This is not necessary. Since you're using the serial core, if you
look at what it's already doing for you, you'll see that uart_shutdown()
already takes care of this.
> +void jsm_check_queue_flow_control(struct jsm_channel *ch)
> +{
> + int qleft = 0;
> +
> + /* Store how much space we have left in the queue */
> + if ((qleft = ch->ch_r_tail - ch->ch_r_head - 1) < 0)
> + qleft += RQUEUEMASK + 1;
> +
> + /*
> + * Check to see if we should enforce flow control on our queue because
> + * the ld (or user) isn't reading data out of our queue fast enuf.
> + *
> + * NOTE: This is done based on what the current flow control of the
> + * port is set for.
> + *
> + * 1) HWFLOW (RTS) - Turn off the UART's Receive interrupt.
> + * This will cause the UART's FIFO to back up, and force
> + * the RTS signal to be dropped.
> + * 2) SWFLOW (IXOFF) - Keep trying to send a stop character to
> + * the other side, in hopes it will stop sending data to us.
> + * 3) NONE - Nothing we can do. We will simply drop any extra data
> + * that gets sent into us when the queue fills up.
> + */
> + if (qleft < 256) {
> + /* HWFLOW */
> + if (ch->ch_c_cflag & CRTSCTS) {
> + if(!(ch->ch_flags & CH_RECEIVER_OFF)) {
> + ch->ch_bd->bd_ops->disable_receiver(ch);
> + ch->ch_flags |= (CH_RECEIVER_OFF);
> + jsm_printk(READ, INFO, &ch->ch_bd->pci_dev,
> + "Internal queue hit hilevel mark (%d)! Turning off interrupts.\n",
> + qleft);
> + }
> + }
> + /* SWFLOW */
> + else if (ch->ch_c_iflag & IXOFF) {
> + if (ch->ch_stops_sent <= MAX_STOPS_SENT) {
> + ch->ch_bd->bd_ops->send_stop_character(ch);
> + ch->ch_stops_sent++;
> + jsm_printk(READ, INFO, &ch->ch_bd->pci_dev,
> + "Sending stop char! Times sent: %x\n", ch->ch_stops_sent);
> + }
> + }
> + }
> +
> + /*
> + * Check to see if we should unenforce flow control because
> + * ld (or user) finally read enuf data out of our queue.
> + *
> + * NOTE: This is done based on what the current flow control of the
> + * port is set for.
> + *
> + * 1) HWFLOW (RTS) - Turn back on the UART's Receive interrupt.
> + * This will cause the UART's FIFO to raise RTS back up,
> + * which will allow the other side to start sending data again.
> + * 2) SWFLOW (IXOFF) - Send a start character to
> + * the other side, so it will start sending data to us again.
> + * 3) NONE - Do nothing. Since we didn't do anything to turn off the
> + * other side, we don't need to do anything now.
> + */
> + if (qleft > (RQUEUESIZE / 2)) {
> + /* HWFLOW */
> + if (ch->ch_c_cflag & CRTSCTS) {
> + if (ch->ch_flags & CH_RECEIVER_OFF) {
> + ch->ch_bd->bd_ops->enable_receiver(ch);
> + ch->ch_flags &= ~(CH_RECEIVER_OFF);
> + jsm_printk(READ, INFO, &ch->ch_bd->pci_dev,
> + "Internal queue hit lowlevel mark (%d)! Turning on interrupts.\n",
> + qleft);
> + }
> + }
> + /* SWFLOW */
> + else if (ch->ch_c_iflag & IXOFF && ch->ch_stops_sent) {
> + ch->ch_stops_sent = 0;
> + ch->ch_bd->bd_ops->send_start_character(ch);
> + jsm_printk(READ, INFO, &ch->ch_bd->pci_dev, "Sending start char!\n");
> + }
> + }
> +}
Wouldn't you think the kernel already takers are of flow control, given
that it already handles the sending of the X* characters?
--
Russell King
Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/
maintainer of: 2.6 Serial core
next prev parent reply other threads:[~2005-03-30 14:56 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-02-27 23:39 [ patch 4/7] drivers/serial/jsm: new serial device driver Wen Xiong
2005-02-28 3:21 ` Christoph Hellwig
2005-02-28 6:39 ` Greg KH
2005-03-04 21:08 ` Wen Xiong
2005-03-04 22:01 ` Greg KH
2005-03-07 22:46 ` Wen Xiong
2005-03-08 6:44 ` Greg KH
2005-03-08 18:55 ` Wen Xiong
2005-03-08 23:58 ` Greg KH
2005-03-09 15:47 ` Wen Xiong
2005-03-09 16:35 ` Greg KH
2005-03-09 17:18 ` Wen Xiong
2005-03-09 18:58 ` Greg KH
2005-03-11 15:29 ` [ patch 1/5] " Wen Xiong
2005-03-12 13:06 ` Domen Puncer
2005-03-14 17:35 ` Wen Xiong
2005-03-14 20:24 ` Domen Puncer
2005-03-14 21:24 ` Wen Xiong
2005-03-11 15:32 ` [ patch 2/5] " Wen Xiong
2005-03-30 14:55 ` Russell King [this message]
2005-03-11 15:38 ` [ patch 3/5] " Wen Xiong
2005-03-11 15:53 ` Arjan van de Ven
2005-03-11 16:39 ` Wen Xiong
2005-03-11 16:46 ` Arjan van de Ven
2005-03-11 22:34 ` Wen Xiong
2005-03-30 15:01 ` Russell King
2005-03-11 15:38 ` [ patch 4/5] " Wen Xiong
2005-03-11 15:38 ` [ patch 5/5] " Wen Xiong
2005-03-09 16:11 ` [ patch 4/7] " Russell King
-- strict thread matches above, loose matches on Subject: below --
2005-03-30 15:41 [ patch 2/5] " Kilau, Scott
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20050330155535.A13781@flint.arm.linux.org.uk \
--to=rmk+lkml@arm.linux.org.uk \
--cc=greg@kroah.com \
--cc=linux-kernel@vger.kernel.org \
--cc=wendyx@us.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox