From: Matt Kline <matt@bitbashing.io>
To: Wolfgang Grandegger <wg@grandegger.com>,
Marc Kleine-Budde <mkl@pengutronix.de>
Cc: Matt Kline <matt@bitbashing.io>, linux-can@vger.kernel.org
Subject: [PATCH v2 0/2] can: m_can: Merge FIFO ops to increase throughput
Date: Mon, 26 Jul 2021 18:58:53 -0700 [thread overview]
Message-ID: <20210727015855.17482-1-matt@bitbashing.io> (raw)
While debugging low throughput on a tcan4x5x chip using a logic
analyzer, I found that the SPI bus is silent for the *vast* majority of
time spent sending or receiving a CAN frame.
Each SPI transfer takes ~5 microseconds, but there's an order of
magnitude more time (50-60 microseconds) between them. This doesn't seem
to be caused by any sort of contention - it happens on a SPI bus with a
single chip select and no other drivers accessing it. Presumably there's
a (relatively) large fixed cost to request a transfer from the SPI
controller on the hardware I'm using (an NVIDIA Jetson platform).
Let's improve throughput by combining FIFO reads and writes into larger
transfers - one for ID & DLC, one for the frame data - instead of
handling single words at a time. We could reduce the number of transfers
further by batching certain control register reads, but this is an easy
place to start, since FIFO registers are contiguous.
Since TX and RX time is dominated by the fixed, per-transfer delays
mentioned above, this nets substantial performance improvements - about
20% faster for small CAN frames and nearly 5x faster for max size
(64 byte) CAN FD frames.
This is a resend of a previous patch set, updated to use FIELD_PREP()
and friends - I fear the first one got eaten by a spam filter due to
some SMTP flub on my end.
Matt Kline (2):
can: m_can: Batch FIFO reads during CAN receive
can: m_can: Batch FIFO writes during CAN transmit
drivers/net/can/m_can/m_can.c | 80 +++++++++++++-------------
drivers/net/can/m_can/m_can.h | 4 +-
drivers/net/can/m_can/m_can_pci.c | 11 ++--
drivers/net/can/m_can/m_can_platform.c | 11 ++--
drivers/net/can/m_can/tcan4x5x-core.c | 12 ++--
5 files changed, 61 insertions(+), 57 deletions(-)
--
2.32.0
next reply other threads:[~2021-07-27 1:59 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-27 1:58 Matt Kline [this message]
2021-07-27 1:58 ` [PATCH v2 1/2] can: m_can: Batch FIFO reads during CAN receive Matt Kline
2021-07-27 1:58 ` [PATCH v2 2/2] can: m_can: Batch FIFO writes during CAN transmit Matt Kline
2021-08-04 9:18 ` Marc Kleine-Budde
2021-08-10 20:47 ` Matt Kline
2021-08-11 6:35 ` Marc Kleine-Budde
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=20210727015855.17482-1-matt@bitbashing.io \
--to=matt@bitbashing.io \
--cc=linux-can@vger.kernel.org \
--cc=mkl@pengutronix.de \
--cc=wg@grandegger.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).