From: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
To: "Jan Kundrát" <jan.kundrat@cesnet.cz>
Cc: <linux-spi@vger.kernel.org>, Mark Brown <broonie@kernel.org>
Subject: Re: High CPU load when using MAX14830 SPI UART controller
Date: Tue, 21 Jul 2020 15:51:39 +0200 [thread overview]
Message-ID: <20200721155139.40fdb835@windsurf.home> (raw)
In-Reply-To: <4c5c972b-c8b8-4326-a1f9-438d88217a4a@cesnet.cz>
Hello Jan,
On Wed, 20 May 2020 12:44:43 +0200
Jan Kundrát <jan.kundrat@cesnet.cz> wrote:
> I was getting something similar when I first wrote that patch. The TL;DR
> version is that even though this UART has 128 byte FIFO per each direction
> of each UART, I wanted my patch to stay conservative and only batch reads
> in an opportunistic manner -- I wanted not to risk a possible RX FIFO
> overflow. That's why the IRQ handler is eager to trigger as soon as there
> are some data in the RX FIFO. Our setup has no HW flow control (no RTS/CTS,
> no software flow control), so one has to hope that the IRQ latency is low
> enough...
>
> The MAX14830 supports also another mode of operation where the interrupt
> fires only when the RX buffer gets filled over a configurable minimal
> threshold. This can be combined with yet another interrupt which fires
> whenever there's some data in the RX FIFO for "too long". Unfortunately,
> this timer starts over again upon reception of any additional data, so it's
> the *youngest* byte in the RX FIFO that controls triggering of this delayed
> interrupt.
Do you have some more details about this mode of operation? I looked a
bit at the MAX14830 datasheet and code, but couldn't spot what allows
an interrupt to be triggered after X bytes have been received *OR* if
data has been sitting in the FIFO for too long.
> I am not sure how to balance the latency ("how soon is userspace notified
> about this byte") with CPU utilization ("don't read data byte-by-byte from
> this 128 byte buffer"). If there's some cross-driver support for "something
> like that" in the TTY layer, I'm sure that max310x.c could be adopted to
> make use of that. Otherwise, we could always add a pair of DT properties
> for controling:
>
> a) the "start reading from RX FIFO" timeout,
> b) "allow up to X bytes in the RX FIFO, I know that my platform has enough
> CPU and SPI bandwidth to finish reading that before the RX FIFO overflows"
>
> BTW, there are also real SPI bus throughput limitations, see
> 2258761213cb239e5e6c11b4ec9b1700fcb4fdcd for some numbers from my platform.
> The chip supports up to 26 MHz (but not all bus masters have clock
> granularities fine enough to use this), that's 3.25 MBps of raw throughput
> divided among four UARTs. Reading each register takes at least two bytes,
> one has to check the top-level IRQ status register (to decide which UART to
> check), then read per-UART IRQ registers, and only then start reading the
> data. Also, batched reading can only happen if userspace explicitly ignores
> framing errors, parity errors, etc, otherwise the driver will have to read
> byte-by-byte, and check the line status register, etc.
Yes, there is definitely some significant overhead with all those SPI
transactions. But here I'm mostly concerned about CPU usage rather than
actual bandwidth on the UART.
Thomas
--
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
next prev parent reply other threads:[~2020-07-21 13:51 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-19 14:33 High CPU load when using MAX14830 SPI UART controller Thomas Petazzoni
2020-05-19 15:24 ` Mark Brown
2020-05-20 10:18 ` Thomas Petazzoni
2020-05-20 11:26 ` Mark Brown
2020-07-21 13:39 ` Thomas Petazzoni
2020-07-21 22:30 ` Mark Brown
2020-05-20 10:44 ` Jan Kundrát
2020-07-21 13:51 ` Thomas Petazzoni [this message]
2020-07-21 14:20 ` Jan Kundrát
2020-07-21 21:49 ` Andy Shevchenko
2020-07-28 8:22 ` Thomas Petazzoni
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=20200721155139.40fdb835@windsurf.home \
--to=thomas.petazzoni@bootlin.com \
--cc=broonie@kernel.org \
--cc=jan.kundrat@cesnet.cz \
--cc=linux-spi@vger.kernel.org \
/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).