linux-serial.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: One Thousand Gnomes <gnomes@lxorguk.ukuu.org.uk>
To: Yoshihiro YUNOMAE <yoshihiro.yunomae.ez@hitachi.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Heikki Krogerus <heikki.krogerus@linux.intel.com>,
	Stephen Warren <swarren@nvidia.com>,
	Jingoo Han <jg1.han@samsung.com>,
	linux-kernel@vger.kernel.org,
	Hidehiro Kawai <hidehiro.kawai.ez@hitachi.com>,
	linux-serial@vger.kernel.org, yrl.pp-manager.tt@hitachi.com,
	Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>,
	Aaron Sierra <asierra@xes-inc.com>, Jiri Slaby <jslaby@suse.cz>
Subject: Re: [PATCH V3] serial/uart/8250: Add tunable RX interrupt trigger I/F of FIFO buffers
Date: Fri, 14 Mar 2014 12:04:00 +0000	[thread overview]
Message-ID: <20140314120400.4e17c47a@alan.etchedpixels.co.uk> (raw)
In-Reply-To: <20140314022154.4345.23024.stgit@yunodevel>

> @@ -2325,10 +2323,19 @@ serial8250_do_set_termios(struct uart_port *port, struct ktermios *termios,
>  		if ((baud < 2400 && !up->dma) || fifo_bug) {
>  			fcr &= ~UART_FCR_TRIGGER_MASK;
>  			fcr |= UART_FCR_TRIGGER_1;
> +			/* Don't use user setting RX trigger */
> +			up->fcr = 0;

This breaks

	set fcr via sysfs
	set baud rate below 2400
	set baud rate higher

If baud < 2400 and the user has set a value then probably we should honour
it. If fifo_bug is set then we should never honour it (and should perhaps
eventually error it in the sysfs set).


> +static unsigned char convert_fcr2val(struct uart_8250_port *up,
> +				     unsigned char fcr)
> +{
> +	unsigned char val = 0, trig_raw = fcr & UART_FCR_TRIGGER_MASK;
> +
> +	switch (up->port.type) {
> +	case PORT_16550A:
> +		if (trig_raw == UART_FCR_R_TRIG_00)
> +			val = 1;
> +		else if (trig_raw == UART_FCR_R_TRIG_01)
> +			val = 4;
> +		else if (trig_raw == UART_FCR_R_TRIG_10)
> +			val = 8;
> +		else if (trig_raw == UART_FCR_R_TRIG_11)
> +			val = 14;
> +		break;

Surely the default case should be returning 1 not 0 ?


> +static int convert_val2rxtrig(struct uart_8250_port *up, unsigned char val)
> +{
> +	switch (up->port.type) {
> +	case PORT_16550A:
> +		if (val == 1)
> +			return UART_FCR_R_TRIG_00;
> +		else if (val == 4)
> +			return UART_FCR_R_TRIG_01;
> +		else if (val == 8)
> +			return UART_FCR_R_TRIG_10;
> +		else if (val == 14)
> +			return UART_FCR_R_TRIG_11;

What happens if you specify a meaningless value. Doing exact matching
means that you have to know the hardware exactly. How about

	if (val < 4)
		return UART_FCR_R_TRIG_00;
	else if (val < 8)
		return UART_FCR_R_TRIG_01;
	else if (val < 14)
		return UART_FCR_R_TRIG_10;
	else
		return UART_FCR_R_TRIG_11;

so you get the nearest lower value that the hardware can provide ?

> +		break;
> +	default:
> +		pr_info("Not support RX-trigger setting for this serial %u\n",
> +			up->port.type);

That lets users spew into the logs. I think actually you just want

	default:
		return -EOPNOTSUPP;

or similar



Otherwise this looks good to me. The interface is sensible, it can be
expanded easily to other devices and device types, and the logic looks
right.

Alan

  reply	other threads:[~2014-03-14 12:04 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-14  2:21 [PATCH V3] serial/uart/8250: Add tunable RX interrupt trigger I/F of FIFO buffers Yoshihiro YUNOMAE
2014-03-14 12:04 ` One Thousand Gnomes [this message]
2014-03-14 14:38   ` Heikki Krogerus
2014-03-17  6:04   ` Yoshihiro YUNOMAE
2014-03-14 14:16 ` Heikki Krogerus
2014-03-17  3:03   ` Yoshihiro YUNOMAE

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=20140314120400.4e17c47a@alan.etchedpixels.co.uk \
    --to=gnomes@lxorguk.ukuu.org.uk \
    --cc=asierra@xes-inc.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=heikki.krogerus@linux.intel.com \
    --cc=hidehiro.kawai.ez@hitachi.com \
    --cc=jg1.han@samsung.com \
    --cc=jslaby@suse.cz \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=masami.hiramatsu.pt@hitachi.com \
    --cc=swarren@nvidia.com \
    --cc=yoshihiro.yunomae.ez@hitachi.com \
    --cc=yrl.pp-manager.tt@hitachi.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;
as well as URLs for NNTP newsgroup(s).