From: Mark Brown <broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
To: Heiner Kallweit <hkallweit1-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: Mark Brown <broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
Mark Brown <broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
"linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
<linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Applied "spi: fsl-espi: fix and improve reading from RX FIFO" to the spi tree
Date: Fri, 28 Oct 2016 19:51:33 +0100 [thread overview]
Message-ID: <E1c0CFZ-00065f-IM@finisterre> (raw)
In-Reply-To: <6ae20ab9-4068-9be7-654d-12424de35716-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
The patch
spi: fsl-espi: fix and improve reading from RX FIFO
has been applied to the spi tree at
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git
All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying
to this mail.
Thanks,
Mark
>From f05689a662d47896da742f5338eab183ed692c1c Mon Sep 17 00:00:00 2001
From: Heiner Kallweit <hkallweit1-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Date: Thu, 27 Oct 2016 21:27:35 +0200
Subject: [PATCH] spi: fsl-espi: fix and improve reading from RX FIFO
Currently the driver polls in the ISR for enough bytes in the RX FIFO.
An ISR should never do this.
Change it to read as much as possible whenever the ISR is called.
This also allows to significantly simplify the code.
Signed-off-by: Heiner Kallweit <hkallweit1-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Signed-off-by: Mark Brown <broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
---
drivers/spi/spi-fsl-espi.c | 67 ++++++++++++++--------------------------------
1 file changed, 20 insertions(+), 47 deletions(-)
diff --git a/drivers/spi/spi-fsl-espi.c b/drivers/spi/spi-fsl-espi.c
index 239f0362df61..2f95b19e67f7 100644
--- a/drivers/spi/spi-fsl-espi.c
+++ b/drivers/spi/spi-fsl-espi.c
@@ -224,6 +224,24 @@ static void fsl_espi_fill_tx_fifo(struct mpc8xxx_spi *mspi, u32 events)
}
}
+static void fsl_espi_read_rx_fifo(struct mpc8xxx_spi *mspi, u32 events)
+{
+ u32 rx_fifo_avail = SPIE_RXCNT(events);
+
+ while (rx_fifo_avail >= min(4U, mspi->rx_len) && mspi->rx_len)
+ if (mspi->rx_len >= 4) {
+ *(u32 *)mspi->rx = fsl_espi_read_reg(mspi, ESPI_SPIRF);
+ mspi->rx += 4;
+ mspi->rx_len -= 4;
+ rx_fifo_avail -= 4;
+ } else {
+ *(u8 *)mspi->rx = fsl_espi_read_reg8(mspi, ESPI_SPIRF);
+ mspi->rx += 1;
+ mspi->rx_len -= 1;
+ rx_fifo_avail -= 1;
+ }
+}
+
static void fsl_espi_setup_transfer(struct spi_device *spi,
struct spi_transfer *t)
{
@@ -423,53 +441,8 @@ static void fsl_espi_cleanup(struct spi_device *spi)
static void fsl_espi_cpu_irq(struct mpc8xxx_spi *mspi, u32 events)
{
- /* We need handle RX first */
- if (events & SPIE_RNE) {
- u32 rx_data, tmp;
- u8 rx_data_8;
- int rx_nr_bytes = 4;
- int ret;
-
- /* Spin until RX is done */
- if (SPIE_RXCNT(events) < min(4U, mspi->rx_len)) {
- ret = spin_event_timeout(
- !(SPIE_RXCNT(events =
- fsl_espi_read_reg(mspi, ESPI_SPIE)) <
- min(4U, mspi->rx_len)),
- 10000, 0); /* 10 msec */
- if (!ret)
- dev_err(mspi->dev,
- "tired waiting for SPIE_RXCNT\n");
- }
-
- if (mspi->rx_len >= 4) {
- rx_data = fsl_espi_read_reg(mspi, ESPI_SPIRF);
- } else if (!mspi->rx_len) {
- dev_err(mspi->dev,
- "unexpected RX(SPIE_RNE) interrupt occurred,\n"
- "(local rxlen %d bytes, reg rxlen %d bytes)\n",
- min(4U, mspi->rx_len), SPIE_RXCNT(events));
- rx_nr_bytes = 0;
- } else {
- rx_nr_bytes = mspi->rx_len;
- tmp = mspi->rx_len;
- rx_data = 0;
- while (tmp--) {
- rx_data_8 = fsl_espi_read_reg8(mspi,
- ESPI_SPIRF);
- rx_data |= (rx_data_8 << (tmp * 8));
- }
-
- rx_data <<= (4 - mspi->rx_len) * 8;
- }
-
- mspi->rx_len -= rx_nr_bytes;
-
- if (rx_nr_bytes && mspi->rx) {
- *(u32 *)mspi->rx = rx_data;
- mspi->rx += 4;
- }
- }
+ if (mspi->rx_len)
+ fsl_espi_read_rx_fifo(mspi, events);
if (mspi->tx_len)
fsl_espi_fill_tx_fifo(mspi, events);
--
2.10.1
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2016-10-28 18:51 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <5b98be38-17a2-79a2-14da-fb2bb6f8820f@gmail.com>
[not found] ` <5b98be38-17a2-79a2-14da-fb2bb6f8820f-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-10-02 12:22 ` [PATCH 02/11] spi: fsl-espi: remove unneeded check for SPI_QE_CPU_MODE Heiner Kallweit
[not found] ` <20608368-44e6-21f8-d970-5ade9990ce59-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-10-06 15:45 ` Mark Brown
[not found] ` <20161006154543.rxlrc3sumejozpcg-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2016-10-06 18:36 ` Heiner Kallweit
[not found] ` <bbe77580-1ac2-4071-5d7d-f786c54ad177-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-10-26 17:07 ` Mark Brown
2016-10-02 12:22 ` [PATCH 03/11] spi: fsl-espi: fix handling of word sizes other than 8 bit Heiner Kallweit
2016-10-02 12:23 ` [PATCH 04/11] spi: fsl-espi: fix and improve writing to TX FIFO Heiner Kallweit
[not found] ` <c246dbf2-c59e-f029-afa1-8a5c6f6dd24b-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-10-28 18:53 ` Applied "spi: fsl-espi: fix and improve writing to TX FIFO" to the spi tree Mark Brown
2016-10-02 12:23 ` [PATCH 05/11] spi: fsl-espi: Rename len in struct mpc8xxx_spi to rx_len and make it unsigned Heiner Kallweit
2016-10-02 12:23 ` [PATCH 06/11] spi: fsl-espi: simplify and inline function fsl_espi_change_mode Heiner Kallweit
[not found] ` <0aeb49f0-dbfb-7acb-3829-cabafe4e7291-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-10-28 18:52 ` Applied "spi: fsl-espi: simplify and inline function fsl_espi_change_mode" to the spi tree Mark Brown
2016-10-02 12:23 ` [PATCH 07/11] spi: fsl-espi: fix and improve reading from RX FIFO Heiner Kallweit
2016-10-02 12:23 ` [PATCH 08/11] spi: fsl-espi: make better use of the " Heiner Kallweit
[not found] ` <144b73b1-dff2-a5b6-9df1-837238f20008-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-10-28 18:51 ` Applied "spi: fsl-espi: make better use of the RX FIFO" to the spi tree Mark Brown
2016-10-02 12:23 ` [PATCH 09/11] spi: fsl-espi: extend and improve transfer error handling Heiner Kallweit
[not found] ` <4ba19a7f-9f66-54c4-9119-e85671d608fb-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-10-28 18:52 ` Applied "spi: fsl-espi: extend and improve transfer error handling" to the spi tree Mark Brown
2016-10-02 12:23 ` [PATCH 10/11] spi: fsl-espi: add support for RXSKIP mode Heiner Kallweit
2016-10-02 12:23 ` [PATCH 11/11] spi: fsl-espi: add support for dual read mode Heiner Kallweit
2016-10-27 19:24 ` [PATCH v2 01/09] spi: fsl-espi: improve check for SPI_QE_CPU_MODE Heiner Kallweit
[not found] ` <0b5e7849-88d6-2af5-a428-eeb0de0f2af2-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-10-28 18:34 ` Mark Brown
2016-10-28 18:53 ` Applied "spi: fsl-espi: improve check for SPI_QE_CPU_MODE" to the spi tree Mark Brown
2016-10-27 19:25 ` [PATCH v2 02/09] spi: fsl-espi: fix and improve writing to TX FIFO Heiner Kallweit
2016-10-27 19:26 ` [PATCH v2 03/09] spi: fsl-espi: Rename len in struct mpc8xxx_spi to rx_len and make it unsigned Heiner Kallweit
[not found] ` <611500a3-d254-f04c-ce20-6905a649bcda-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-10-28 18:53 ` Applied "spi: fsl-espi: Rename len in struct mpc8xxx_spi to rx_len and make it unsigned" to the spi tree Mark Brown
2016-10-27 19:26 ` [PATCH v2 04/09] spi: fsl-espi: simplify and inline function fsl_espi_change_mode Heiner Kallweit
2016-10-27 19:27 ` [PATCH v2 05/09] spi: fsl-espi: fix and improve reading from RX FIFO Heiner Kallweit
[not found] ` <6ae20ab9-4068-9be7-654d-12424de35716-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-10-28 18:51 ` Mark Brown [this message]
2016-10-27 19:27 ` [PATCH v2 06/09] spi: fsl-espi: make better use of the " Heiner Kallweit
2016-10-27 19:28 ` [PATCH v2 07/09] spi: fsl-espi: extend and improve transfer error handling Heiner Kallweit
2016-10-27 19:28 ` [PATCH v2 08/09] spi: fsl-espi: add support for RXSKIP mode Heiner Kallweit
2016-10-27 19:29 ` [PATCH v2 09/09] spi: fsl-espi: add support for dual read mode Heiner Kallweit
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=E1c0CFZ-00065f-IM@finisterre \
--to=broonie-dgejt+ai2ygdnm+yrofe0a@public.gmane.org \
--cc=hkallweit1-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.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).