From: Michael Walle <michael-QKn5cuLxLXY@public.gmane.org>
To: Vladimir Oltean <olteanv-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: Mark Brown <broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
lkml <linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
Shawn Guo <shawnguo-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
Rob Herring <robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
Mark Rutland <mark.rutland-5wv7dgnIgG8@public.gmane.org>,
devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Esben Haabendal <eha-/iRVSOupHO4@public.gmane.org>,
angelo-BIYBQhTR83Y@public.gmane.org,
andrew.smirnov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
"Gustavo A. R. Silva"
<gustavo-L1vi/lXTdts+Va1GwOuvDg@public.gmane.org>,
Wei Chen <weic-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>,
Mohamed Hosny <mhosny-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>,
peng.ma-3arQi8VN3Tc@public.gmane.org
Subject: Re: [PATCH v3 06/12] spi: spi-fsl-dspi: Replace interruptible wait queue with a simple completion
Date: Tue, 17 Mar 2020 12:24:49 +0100 [thread overview]
Message-ID: <52ce52ed4f045c4276dfb885ed29e835@walle.cc> (raw)
In-Reply-To: <8c22cb70b7c0acb6769e0c68540ab523-QKn5cuLxLXY@public.gmane.org>
Am 2020-03-16 18:15, schrieb Michael Walle:
>>> dd: /dev/mtd0: Input/output error
>>
>> I don't really have a SPI flash connected to DSPI on any LS1028A
>> board.
>
> I'm already debugging it again.
Ok now maybe a more experienced kernel developer could have a look at
this.
(1) the error is EIO because the actual_length doesn't match the
expected
length
(2) I've put trace_printk() where the actual_length is modified:
in dspi_fifo_write()
/* Update total number of bytes that were transferred */
bytes_sent = dspi->words_in_flight * dspi->oper_word_size;
msg->actual_length += bytes_sent;
trace_printk("msg=%px actual_length=%d bytes_sent=%d
word_in_flight=%d oper_word_size=%d\n",
msg, msg->actual_length,
bytes_sent, dspi->words_in_flight,
dspi->oper_word_size);
dspi->progress += bytes_sent / DIV_ROUND_UP(xfer->bits_per_word,
8);
At the start of the foreach transfer loop in
dspi_transfer_one_message():
list_for_each_entry(transfer, &message->transfers,
transfer_list) {
trace_printk("%d transfer->length=%d\n", i++,
transfer->len);
dspi->cur_transfer = transfer;
And at the end of this function:
}
trace_printk("returning actual_length=%d\n",
message->actual_length);
message->status = status;
spi_finalize_current_message(ctlr);
return status;
(3) The trace is attached at the end of this mail. There is a good case
and the
bad one. What I've noticed (besides returning the wrong count, eg
13, which
seems to be the first one) is the preempt-depth which is always none
in the
bad case. In all transfers before, the preempt-depth is 1. The flags
are
usually "d.h1", sometimes "d.H1" and in case of the error "d.H.".
I also don't know why the fifo_write() with actual_length=13 is
traced after
all the ones printed inside the interrupt handler. Also something
seems to
be off with the words_in_flight and oper_word_size in the bad case.
So besides the flags.. I still think there is a race between the
dspi_fifo_write() call in transfer_one_message and the interrupt
handler
for the shared data like words_in_flight and oper_word_size.
good one:
dd-1259 [000] .... 3383.499863:
dspi_transfer_one_message: 0 transfer->length=1
dd-1259 [000] .... 3383.499886: dspi_fifo_write:
msg=ffff800011973840 actual_length=1 bytes_sent=1 word_in_flight=1
oper_word_size=1
dd-1259 [000] .... 3383.499891:
dspi_transfer_one_message: 1 transfer->length=3
dd-1259 [000] .... 3383.499915: dspi_fifo_write:
msg=ffff800011973840 actual_length=4 bytes_sent=3 word_in_flight=3
oper_word_size=1
dd-1259 [000] .... 3383.499920:
dspi_transfer_one_message: 2 transfer->length=1
dd-1259 [000] .... 3383.499940: dspi_fifo_write:
msg=ffff800011973840 actual_length=5 bytes_sent=1 word_in_flight=1
oper_word_size=1
dd-1259 [000] .... 3383.499946:
dspi_transfer_one_message: 3 transfer->length=64
dd-1259 [000] d.h1 3383.499973: dspi_fifo_write:
msg=ffff800011973840 actual_length=21 bytes_sent=8 word_in_flight=2
oper_word_size=4
dd-1259 [000] d.h1 3383.499993: dspi_fifo_write:
msg=ffff800011973840 actual_length=29 bytes_sent=8 word_in_flight=2
oper_word_size=4
dd-1259 [000] d.h1 3383.500013: dspi_fifo_write:
msg=ffff800011973840 actual_length=37 bytes_sent=8 word_in_flight=2
oper_word_size=4
dd-1259 [000] d.h1 3383.500032: dspi_fifo_write:
msg=ffff800011973840 actual_length=45 bytes_sent=8 word_in_flight=2
oper_word_size=4
dd-1259 [000] d.h1 3383.500051: dspi_fifo_write:
msg=ffff800011973840 actual_length=53 bytes_sent=8 word_in_flight=2
oper_word_size=4
dd-1259 [000] d.h1 3383.500070: dspi_fifo_write:
msg=ffff800011973840 actual_length=61 bytes_sent=8 word_in_flight=2
oper_word_size=4
dd-1259 [000] d.h1 3383.500089: dspi_fifo_write:
msg=ffff800011973840 actual_length=69 bytes_sent=8 word_in_flight=4
oper_word_size=2
dd-1259 [000] .... 3383.500107: dspi_fifo_write:
msg=ffff800011973840 actual_length=13 bytes_sent=8 word_in_flight=2
oper_word_size=4
dd-1259 [000] .... 3383.500111:
dspi_transfer_one_message: returning actual_length=69
bad one:
dd-1259 [000] .... 3383.500149:
dspi_transfer_one_message: 0 transfer->length=1
dd-1259 [000] .... 3383.500172: dspi_fifo_write:
msg=ffff800011973840 actual_length=1 bytes_sent=1 word_in_flight=1
oper_word_size=1
dd-1259 [000] .... 3383.500178:
dspi_transfer_one_message: 1 transfer->length=3
dd-1259 [000] .... 3383.500202: dspi_fifo_write:
msg=ffff800011973840 actual_length=4 bytes_sent=3 word_in_flight=3
oper_word_size=1
dd-1259 [000] .... 3383.500207:
dspi_transfer_one_message: 2 transfer->length=1
dd-1259 [000] .... 3383.500227: dspi_fifo_write:
msg=ffff800011973840 actual_length=5 bytes_sent=1 word_in_flight=1
oper_word_size=1
dd-1259 [000] .... 3383.500232:
dspi_transfer_one_message: 3 transfer->length=64
dd-1259 [000] d.H. 3383.500286: dspi_fifo_write:
msg=ffff800011973840 actual_length=13 bytes_sent=8 word_in_flight=2
oper_word_size=4
dd-1259 [000] d.H. 3383.500307: dspi_fifo_write:
msg=ffff800011973840 actual_length=21 bytes_sent=8 word_in_flight=2
oper_word_size=4
dd-1259 [000] d.H. 3383.500327: dspi_fifo_write:
msg=ffff800011973840 actual_length=29 bytes_sent=8 word_in_flight=2
oper_word_size=4
dd-1259 [000] d.H. 3383.500347: dspi_fifo_write:
msg=ffff800011973840 actual_length=37 bytes_sent=8 word_in_flight=2
oper_word_size=4
dd-1259 [000] d.H. 3383.500366: dspi_fifo_write:
msg=ffff800011973840 actual_length=45 bytes_sent=8 word_in_flight=2
oper_word_size=4
dd-1259 [000] d.H. 3383.500385: dspi_fifo_write:
msg=ffff800011973840 actual_length=53 bytes_sent=8 word_in_flight=2
oper_word_size=4
dd-1259 [000] d.H. 3383.500404: dspi_fifo_write:
msg=ffff800011973840 actual_length=61 bytes_sent=8 word_in_flight=4
oper_word_size=2
dd-1259 [000] .... 3383.500436: dspi_fifo_write:
msg=ffff800011973840 actual_length=13 bytes_sent=8 word_in_flight=4
oper_word_size=2
dd-1259 [000] .... 3383.500441:
dspi_transfer_one_message: returning actual_length=13
-michael
next prev parent reply other threads:[~2020-03-17 11:24 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-14 22:43 [PATCH v3 00/12] NXP DSPI bugfixes and support for LS1028A Vladimir Oltean
2020-03-14 22:43 ` [PATCH v3 01/12] spi: spi-fsl-dspi: Don't access reserved fields in SPI_MCR Vladimir Oltean
[not found] ` <20200314224340.1544-1-olteanv-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2020-03-14 22:43 ` [PATCH v3 02/12] spi: spi-fsl-dspi: Fix little endian access to PUSHR CMD and TXDATA Vladimir Oltean
2020-03-14 22:43 ` [PATCH v3 03/12] spi: spi-fsl-dspi: Fix bits-per-word acceleration in DMA mode Vladimir Oltean
2020-03-14 22:43 ` [PATCH v3 04/12] spi: spi-fsl-dspi: Avoid reading more data than written in EOQ mode Vladimir Oltean
2020-03-14 22:43 ` [PATCH v3 05/12] spi: spi-fsl-dspi: Protect against races on dspi->words_in_flight Vladimir Oltean
[not found] ` <20200314224340.1544-6-olteanv-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2020-03-16 12:35 ` Vladimir Oltean
2020-03-14 22:43 ` [PATCH v3 08/12] spi: spi-fsl-dspi: Fix interrupt-less DMA mode taking an XSPI code path Vladimir Oltean
2020-03-14 22:43 ` [PATCH v3 09/12] spi: spi-fsl-dspi: Move invariant configs out of dspi_transfer_one_message Vladimir Oltean
2020-03-14 22:43 ` [PATCH v3 10/12] spi: spi-fsl-dspi: Add support for LS1028A Vladimir Oltean
2020-03-14 22:43 ` [PATCH v3 11/12] arm64: dts: ls1028a: Specify the DMA channels for the DSPI controllers Vladimir Oltean
2020-03-14 22:43 ` [PATCH v3 12/12] arm64: dts: ls1028a-rdb: Add a spidev node for the mikroBUS Vladimir Oltean
2020-03-14 22:43 ` [PATCH v3 06/12] spi: spi-fsl-dspi: Replace interruptible wait queue with a simple completion Vladimir Oltean
2020-03-16 12:26 ` Mark Brown
[not found] ` <20200316122613.GE5010-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2020-03-16 12:29 ` Vladimir Oltean
[not found] ` <CA+h21hqRV+HmAz4QGyH9ZtcFWzeCKczitcn+mfTdwAC7ZobdDw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2020-03-16 12:49 ` Mark Brown
2020-03-16 13:00 ` Vladimir Oltean
[not found] ` <CA+h21hpoHGuDwpOqtWJFO7+0mQVUrmcBLW7nnGq6dt3QU5axfw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2020-03-16 13:25 ` Michael Walle
2020-03-16 16:23 ` Vladimir Oltean
[not found] ` <CA+h21hqt7Xe1LrSDsCVS8zqunQp2tKGhmHDraMirxL595go4nA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2020-03-16 17:15 ` Michael Walle
[not found] ` <8c22cb70b7c0acb6769e0c68540ab523-QKn5cuLxLXY@public.gmane.org>
2020-03-17 11:24 ` Michael Walle [this message]
2020-03-14 22:43 ` [PATCH v3 07/12] spi: spi-fsl-dspi: Avoid NULL pointer in dspi_slave_abort for non-DMA mode Vladimir Oltean
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=52ce52ed4f045c4276dfb885ed29e835@walle.cc \
--to=michael-qkn5culxlxy@public.gmane.org \
--cc=andrew.smirnov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=angelo-BIYBQhTR83Y@public.gmane.org \
--cc=broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=eha-/iRVSOupHO4@public.gmane.org \
--cc=gustavo-L1vi/lXTdts+Va1GwOuvDg@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=mark.rutland-5wv7dgnIgG8@public.gmane.org \
--cc=mhosny-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org \
--cc=olteanv-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=peng.ma-3arQi8VN3Tc@public.gmane.org \
--cc=robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=shawnguo-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=weic-DDmLM1+adcrQT0dZR+AlfA@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).