linux-serial.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] serial: 8250: Fix THRE flag usage for CAP_MINI
@ 2017-06-28  9:41 Phil Elwell
       [not found] ` <1498642885-8063-1-git-send-email-phil-FnsA7b+Nu9XbIbC87yuRow@public.gmane.org>
  0 siblings, 1 reply; 6+ messages in thread
From: Phil Elwell @ 2017-06-28  9:41 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Andy Shevchenko, Peter Hurley, Yegor Yefremov,
	Jan Kiszka, linux-serial-u79uwXL29TY76Z2rM5mHXA,
	linux-rpi-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r

The BCM2835 MINI UART has non-standard THRE semantics. Conventionally
the bit means that the FIFO is empty (although there may still be a
byte in the transmit register), but on 2835 it indicates that the FIFO
is not full. This causes interrupts after every byte is transmitted,
with the FIFO providing some interrupt latency tolerance.

A consequence of this difference is that the usual strategy of writing
multiple bytes into the TX FIFO after checking THRE once is unsafe.
In the worst case of 7 bytes in the FIFO, writing 8 bytes loses all
but the first since by then the FIFO is full.

There is an HFIFO ("Hidden FIFO") capability that causes the transmit
loop to terminate when both THRE and TEMT are set, i.e. when the TX
block is completely idle. This is unnecessarily cautious, potentially
causing gaps in transmission.

Add a new conditional to the transmit loop, predicated on CAP_MINI,
that exits when THRE is no longer set (the FIFO is full). This allows
the FIFO to fill quickly but subsequent writes are paced by the
transmission rate.

Signed-off-by: Phil Elwell <phil-FnsA7b+Nu9XbIbC87yuRow@public.gmane.org>
Acked-by: Eric Anholt <eric-WhKQ6XTQaPysTnJN9+BGXg@public.gmane.org>
Acked-by: Andy Shevchenko <andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
---
Changes in v2:
 Add review tags.

 drivers/tty/serial/8250/8250_port.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c
index 4c620be..a5fe0e6 100644
--- a/drivers/tty/serial/8250/8250_port.c
+++ b/drivers/tty/serial/8250/8250_port.c
@@ -1764,6 +1764,10 @@ void serial8250_tx_chars(struct uart_8250_port *up)
 		if ((up->capabilities & UART_CAP_HFIFO) &&
 		    (serial_in(up, UART_LSR) & BOTH_EMPTY) != BOTH_EMPTY)
 			break;
+		/* The BCM2835 MINI UART THRE bit is really a not-full bit. */
+		if ((up->capabilities & UART_CAP_MINI) &&
+		    !(serial_in(up, UART_LSR) & UART_LSR_THRE))
+			break;
 	} while (--count > 0);
 
 	if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
-- 
1.9.1

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

* Re: [PATCH v2] serial: 8250: Fix THRE flag usage for CAP_MINI
       [not found] ` <1498642885-8063-1-git-send-email-phil-FnsA7b+Nu9XbIbC87yuRow@public.gmane.org>
@ 2017-06-28 10:57   ` Uwe Kleine-König
       [not found]     ` <20170628105744.42bchlftl6khvsxd-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
  0 siblings, 1 reply; 6+ messages in thread
From: Uwe Kleine-König @ 2017-06-28 10:57 UTC (permalink / raw)
  To: Phil Elwell
  Cc: Peter Hurley, Greg Kroah-Hartman, Yegor Yefremov,
	linux-rpi-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	linux-serial-u79uwXL29TY76Z2rM5mHXA, Jan Kiszka, Andy Shevchenko

Hello,

On Wed, Jun 28, 2017 at 10:41:25AM +0100, Phil Elwell wrote:
> Signed-off-by: Phil Elwell <phil-FnsA7b+Nu9XbIbC87yuRow@public.gmane.org>
> Acked-by: Eric Anholt <eric-WhKQ6XTQaPysTnJN9+BGXg@public.gmane.org>
> Acked-by: Andy Shevchenko <andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
> ---
> Changes in v2:
>  Add review tags.

nitpick: The order of lines in the Sob area matter and you should add
your Sob at the end. So as it was you adding the ack by Eric and Andy,
it should look as follows:

	Acked-by: Eric Anholt <eric-WhKQ6XTQaPysTnJN9+BGXg@public.gmane.org>
	Acked-by: Andy Shevchenko <andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
	Signed-off-by: Phil Elwell <phil-FnsA7b+Nu9XbIbC87yuRow@public.gmane.org>

. Note that this comment is very picky, quite some people don't get it
right and I never saw a maintainer refuse a patch because of this. So
this probably doesn't warrant a v3 :-)

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

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

* Re: [PATCH v2] serial: 8250: Fix THRE flag usage for CAP_MINI
       [not found]     ` <20170628105744.42bchlftl6khvsxd-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
@ 2017-06-28 11:52       ` Phil Elwell
       [not found]         ` <95a13280-e9f6-50f5-bb0c-8bcdefd0bf12-FnsA7b+Nu9XbIbC87yuRow@public.gmane.org>
  2017-06-28 12:01       ` Andy Shevchenko
  1 sibling, 1 reply; 6+ messages in thread
From: Phil Elwell @ 2017-06-28 11:52 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: Peter Hurley, Greg Kroah-Hartman, Yegor Yefremov,
	linux-rpi-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	linux-serial-u79uwXL29TY76Z2rM5mHXA, Jan Kiszka, Andy Shevchenko

On 28/06/2017 11:57, Uwe Kleine-König wrote:
> Hello,
> 
> On Wed, Jun 28, 2017 at 10:41:25AM +0100, Phil Elwell wrote:
>> Signed-off-by: Phil Elwell <phil@raspberrypi.org>
>> Acked-by: Eric Anholt <eric@anholt.net>
>> Acked-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
>> ---
>> Changes in v2:
>>  Add review tags.
> 
> nitpick: The order of lines in the Sob area matter and you should add
> your Sob at the end. So as it was you adding the ack by Eric and Andy,
> it should look as follows:
> 
> 	Acked-by: Eric Anholt <eric@anholt.net>
> 	Acked-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> 	Signed-off-by: Phil Elwell <phil@raspberrypi.org>

Really? I thought the submitter went first and the final merger went
last, with other reviewers in-between, like this:

    commit 6df765dca378bddf994cfd2044acafa501bd800f
    Author: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
    Date:   Wed May 24 21:38:46 2017 +0200

        serial: imx: ensure UCR3 and UFCR are setup correctly

        [...]

        Fixes: e61c38d85b73 ("serial: imx: setup DCEDTE early and ensure DCD and RI irqs to be off")
        Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
        Acked-by: Mika Penttilä <mika.penttila@nextfour.com>
        Tested-by: Mika Penttilä <mika.penttila@nextfour.com>
        Acked-by: Steve Twiss <stwiss.opensource@diasemi.com>
        Tested-by: Steve Twiss <stwiss.opensource@diasemi.com>
        Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

> . Note that this comment is very picky, quite some people don't get it
> right and I never saw a maintainer refuse a patch because of this. So
> this probably doesn't warrant a v3 :-)
> 
> Best regards
> Uwe
> 

_______________________________________________
linux-rpi-kernel mailing list
linux-rpi-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rpi-kernel

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

* Re: [PATCH v2] serial: 8250: Fix THRE flag usage for CAP_MINI
       [not found]         ` <95a13280-e9f6-50f5-bb0c-8bcdefd0bf12-FnsA7b+Nu9XbIbC87yuRow@public.gmane.org>
@ 2017-06-28 12:00           ` Andy Shevchenko
  2017-06-28 13:04           ` Uwe Kleine-König
  1 sibling, 0 replies; 6+ messages in thread
From: Andy Shevchenko @ 2017-06-28 12:00 UTC (permalink / raw)
  To: Phil Elwell, Uwe Kleine-König
  Cc: Peter Hurley, Greg Kroah-Hartman, Yegor Yefremov,
	linux-rpi-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	linux-serial-u79uwXL29TY76Z2rM5mHXA, Jan Kiszka

On Wed, 2017-06-28 at 12:52 +0100, Phil Elwell wrote:
> On 28/06/2017 11:57, Uwe Kleine-König wrote:
> > Hello,
> > 
> > On Wed, Jun 28, 2017 at 10:41:25AM +0100, Phil Elwell wrote:
> > > Signed-off-by: Phil Elwell <phil@raspberrypi.org>
> > > Acked-by: Eric Anholt <eric@anholt.net>
> > > Acked-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> > > ---
> > > Changes in v2:
> > >  Add review tags.
> > 
> > nitpick: The order of lines in the Sob area matter and you should
> > add
> > your Sob at the end. So as it was you adding the ack by Eric and
> > Andy,
> > it should look as follows:
> > 
> > 	Acked-by: Eric Anholt <eric@anholt.net>
> > 	Acked-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> > 	Signed-off-by: Phil Elwell <phil@raspberrypi.org>
> 
> Really? I thought the submitter went first and the final merger went
> last, with other reviewers in-between, like this:

There is a difference between two, i.e. who has added tags in your case
and below one? I guess whoever adds them, adds before their own SoB tag.

> 
>     commit 6df765dca378bddf994cfd2044acafa501bd800f
>     Author: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
>     Date:   Wed May 24 21:38:46 2017 +0200
> 
>         serial: imx: ensure UCR3 and UFCR are setup correctly
> 
>         [...]
> 
>         Fixes: e61c38d85b73 ("serial: imx: setup DCEDTE early and
> ensure DCD and RI irqs to be off")
>         Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.d
> e>
>         Acked-by: Mika Penttilä <mika.penttila@nextfour.com>
>         Tested-by: Mika Penttilä <mika.penttila@nextfour.com>
>         Acked-by: Steve Twiss <stwiss.opensource@diasemi.com>
>         Tested-by: Steve Twiss <stwiss.opensource@diasemi.com>
>         Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> 
> > . Note that this comment is very picky, quite some people don't get
> > it
> > right and I never saw a maintainer refuse a patch because of this.
> > So
> > this probably doesn't warrant a v3 :-)
> > 
> > Best regards
> > Uwe
> > 

-- 
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy

_______________________________________________
linux-rpi-kernel mailing list
linux-rpi-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rpi-kernel

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

* Re: [PATCH v2] serial: 8250: Fix THRE flag usage for CAP_MINI
       [not found]     ` <20170628105744.42bchlftl6khvsxd-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
  2017-06-28 11:52       ` Phil Elwell
@ 2017-06-28 12:01       ` Andy Shevchenko
  1 sibling, 0 replies; 6+ messages in thread
From: Andy Shevchenko @ 2017-06-28 12:01 UTC (permalink / raw)
  To: Uwe Kleine-König, Phil Elwell
  Cc: Peter Hurley, Greg Kroah-Hartman, Yegor Yefremov,
	linux-rpi-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	linux-serial-u79uwXL29TY76Z2rM5mHXA, Jan Kiszka

On Wed, 2017-06-28 at 12:57 +0200, Uwe Kleine-König wrote:
> Hello,
> 
> On Wed, Jun 28, 2017 at 10:41:25AM +0100, Phil Elwell wrote:
> > Signed-off-by: Phil Elwell <phil@raspberrypi.org>
> > Acked-by: Eric Anholt <eric@anholt.net>
> > Acked-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> > ---
> > Changes in v2:
> >  Add review tags.
> 
> nitpick: The order of lines in the Sob area matter and you should add
> your Sob at the end. So as it was you adding the ack by Eric and Andy,
> it should look as follows:
> 
> 	Acked-by: Eric Anholt <eric@anholt.net>
> 	Acked-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> 	Signed-off-by: Phil Elwell <phil@raspberrypi.org>
> 
> . Note that this comment is very picky, quite some people don't get it
> right and I never saw a maintainer refuse a patch because of this. So
> this probably doesn't warrant a v3 :-)

Yeah, it's easily learned when one is using

% git commit -s [--amend]

-- 
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy

_______________________________________________
linux-rpi-kernel mailing list
linux-rpi-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rpi-kernel

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

* Re: [PATCH v2] serial: 8250: Fix THRE flag usage for CAP_MINI
       [not found]         ` <95a13280-e9f6-50f5-bb0c-8bcdefd0bf12-FnsA7b+Nu9XbIbC87yuRow@public.gmane.org>
  2017-06-28 12:00           ` Andy Shevchenko
@ 2017-06-28 13:04           ` Uwe Kleine-König
  1 sibling, 0 replies; 6+ messages in thread
From: Uwe Kleine-König @ 2017-06-28 13:04 UTC (permalink / raw)
  To: Phil Elwell
  Cc: Peter Hurley, Greg Kroah-Hartman, Yegor Yefremov,
	linux-rpi-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	linux-serial-u79uwXL29TY76Z2rM5mHXA, Jan Kiszka, Andy Shevchenko

Hello,

On Wed, Jun 28, 2017 at 12:52:46PM +0100, Phil Elwell wrote:
> On 28/06/2017 11:57, Uwe Kleine-König wrote:
> > nitpick: The order of lines in the Sob area matter and you should add
> > your Sob at the end. So as it was you adding the ack by Eric and Andy,
> > it should look as follows:
> > 
> > 	Acked-by: Eric Anholt <eric-WhKQ6XTQaPysTnJN9+BGXg@public.gmane.org>
> > 	Acked-by: Andy Shevchenko <andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
> > 	Signed-off-by: Phil Elwell <phil-FnsA7b+Nu9XbIbC87yuRow@public.gmane.org>
> 
> Really? I thought the submitter went first and the final merger went
> last, with other reviewers in-between, like this:
> 
>     commit 6df765dca378bddf994cfd2044acafa501bd800f
>     Author: Uwe Kleine-König <u.kleine-koenig-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
>     Date:   Wed May 24 21:38:46 2017 +0200
> 
>         serial: imx: ensure UCR3 and UFCR are setup correctly
> 
>         [...]
> 
>         Fixes: e61c38d85b73 ("serial: imx: setup DCEDTE early and ensure DCD and RI irqs to be off")
>         Signed-off-by: Uwe Kleine-König <u.kleine-koenig-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
>         Acked-by: Mika Penttilä <mika.penttila-MRsr7dthA9VWk0Htik3J/w@public.gmane.org>
>         Tested-by: Mika Penttilä <mika.penttila-MRsr7dthA9VWk0Htik3J/w@public.gmane.org>
>         Acked-by: Steve Twiss <stwiss.opensource-WBD+wuPFNBhBDgjK7y7TUQ@public.gmane.org>
>         Tested-by: Steve Twiss <stwiss.opensource-WBD+wuPFNBhBDgjK7y7TUQ@public.gmane.org>
>         Signed-off-by: Greg Kroah-Hartman <gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org>

Right, I would expect that it was Greg who added the Acked and Tested-by
tags when reading this.

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

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

end of thread, other threads:[~2017-06-28 13:04 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-06-28  9:41 [PATCH v2] serial: 8250: Fix THRE flag usage for CAP_MINI Phil Elwell
     [not found] ` <1498642885-8063-1-git-send-email-phil-FnsA7b+Nu9XbIbC87yuRow@public.gmane.org>
2017-06-28 10:57   ` Uwe Kleine-König
     [not found]     ` <20170628105744.42bchlftl6khvsxd-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2017-06-28 11:52       ` Phil Elwell
     [not found]         ` <95a13280-e9f6-50f5-bb0c-8bcdefd0bf12-FnsA7b+Nu9XbIbC87yuRow@public.gmane.org>
2017-06-28 12:00           ` Andy Shevchenko
2017-06-28 13:04           ` Uwe Kleine-König
2017-06-28 12:01       ` Andy Shevchenko

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).