From: Quentin Schulz <quentin.schulz@cherry.de>
To: Cole Munz <Munzzyy1@proton.me>
Cc: u-boot@lists.u-boot-project.org, Tom Rini <trini@konsulko.com>,
Kever Yang <kever.yang@rock-chips.com>,
Simon Glass <sjg@chromium.org>,
Dario Binacchi <dario.binacchi@amarulasolutions.com>,
Boon Khai Ng <boon.khai.ng@altera.com>,
Alexey Charkov <alchark@flipper.net>
Subject: Re: [PATCH v2 2/2] spi: rockchip: skip the unused FIFO direction on a one-wire device
Date: Fri, 21 Aug 2026 12:12:18 +0200 [thread overview]
Message-ID: <9ce1174c-fabe-4618-bcaa-7edfd0b09d56@cherry.de> (raw)
In-Reply-To: <20260820170026.117260-1-Munzzyy1@proton.me>
Hi Cole,
On 8/20/26 7:00 PM, Cole Munz wrote:
> Hi Quentin,
>
> On 8/20/26 5:57 PM, Quentin Schulz wrote:
>> I got confused by the wording here. Can I suggest:
>>
>> /* When RX wire is not routed, the RX FIFO can never fill, so waiting on
>> it would hang. */
>>
>> I don't understand the context for the second sentence though, we are
>> always waiting until not busy, if there's something to transmit, it
>> doesn't have anything to do with the RX path does it? What am I missing
>> here?
>
> The RX drain was doing double duty in TMOD_TR. Byte N only shows up in
> the RX FIFO after byte N has gone out on the wire. Draining toread
Are you sure? The controller needs to tell the peripheral which data
it's interested in. Therefore, the peripheral cannot send data to the
controller until it knows what it wants? c.f.
https://learn.sparkfun.com/tutorials/serial-peripheral-interface-spi/all
in the Receiving data section. Concurrent TX and RX may happen but it's
not a given (and in any case, you'd have a first PICO transfer to
specify what to read next on the POCI line).
At a logic level, the current while loop may very well write all of
towrite without a single toread being read (due to the RX FIFO being
empty in the controller) and then go through all toread, or it could
write 8b and read 8b at a time (or a mixed number of 8b write/read,
though I don't think this is necessarily possible).
> bytes is therefore also what made the loop wait for the transfer
> itself. With toread forced to zero the loop exits as soon as the last
> byte lands in the TX FIFO, which says nothing about the wire. From
> there the wait_till_not_busy() below is the only wait left. That is
> what the sentence tried to point at.
>
> You're right that it explained none of that. v3 takes your first
> sentence and adds the pacing part:
>
> When the RX wire is not routed, the RX FIFO never fills,
> so waiting on it would hang. Draining it was also what
> paced this loop against the wire, so the transmit-only
The controller has 64x 16b-wide RX and TX FIFOs, so my reading of the
TRM means that you can have up to 64 16b data pending in RX and/or TX
FIFOs. So I'm not sure "pacing" is the correct term here. If we're doing
full-duplex (which depends on the device and how we write the driver
since we need to write once in the TX FIFO before doing full-duplex and
both reading and writing at the same time), then I think it's pretty
much guaranteed we're sending and reading bits on PICO/POCI at the same
clock edge. If we aren't doing full-duplex, then we may have to wait to
read from the RX FIFO after we've actually sent stuff on the wire from
the TX FIFO. In conclusion, the wait_till_not_busy() is actually only
useful if we're doing a tx-only transfer as writing to the TX FIFO
doesn't mean it's sent over the wire. If we agree on this, then I think
it's more appropriate to reword the comment just before
rkspi_wait_till_not_busy() to specify we wait till the TX FIFO has been
sent over the wire before starting a new transfer as disabling the
controller will clear all FIFOs.
Cheers,
Quentin
next prev parent reply other threads:[~2026-08-21 10:12 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-20 15:26 [PATCH v2 0/2] spi: support devices with no wire in one direction Cole Munz
2026-08-20 15:26 ` [PATCH v2 1/2] spi: Handle spi-{tx, rx}-bus-width 0 as SPI_NO_TX/SPI_NO_RX Cole Munz
2026-08-20 15:49 ` [PATCH v2 1/2] spi: Handle spi-{tx,rx}-bus-width " Quentin Schulz
2026-08-20 15:26 ` [PATCH v2 2/2] spi: rockchip: skip the unused FIFO direction on a one-wire device Cole Munz
2026-08-20 15:57 ` Quentin Schulz
2026-08-20 17:00 ` Cole Munz
2026-08-21 10:12 ` Quentin Schulz [this message]
2026-08-21 10:55 ` Cole Munz
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=9ce1174c-fabe-4618-bcaa-7edfd0b09d56@cherry.de \
--to=quentin.schulz@cherry.de \
--cc=Munzzyy1@proton.me \
--cc=alchark@flipper.net \
--cc=boon.khai.ng@altera.com \
--cc=dario.binacchi@amarulasolutions.com \
--cc=kever.yang@rock-chips.com \
--cc=sjg@chromium.org \
--cc=trini@konsulko.com \
--cc=u-boot@lists.u-boot-project.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.