From: "Péter Ujfalusi" <peter.ujfalusi@gmail.com>
To: Jean-Michel Hautbois <jeanmichel.hautbois@yoseli.org>,
linux-spi@vger.kernel.org
Cc: broonie@kernel.org, vkoul@kernel.org, dmaengine@vger.kernel.org,
vigneshr@ti.com
Subject: Re: [RFC] omap2-mcspi: periodic zero TX in target mode - debugging help needed
Date: Tue, 17 Feb 2026 08:12:18 +0200 [thread overview]
Message-ID: <d1ba23bc-d8cc-4109-985f-76bb454c6d4a@gmail.com> (raw)
In-Reply-To: <941806a6-0deb-415d-8af3-e78d6104da1c@yoseli.org>
Hi,
On 12/02/2026 17:53, Jean-Michel Hautbois wrote:
> Hi,
>
> I'm seeing a puzzling issue with omap2-mcspi in target mode on AM64x
> and could use some help understanding what might be happening.
>
> Here is my setup:
> - AM64x as SPI target, external controller at ~1 MHz, 1 Hz frame rate
> - Target mode, DMA enabled (k3-udma, not legacy EDMA)
> - Fixed 64-byte transfers (matches MCSPI FIFO depth)
> - Full-duplex, using spi_async() for continuous operation
> - Kernel 6.12.y (also tried mainline, same behaviour) + PREEMPT_RT
>
> Periodically, MISO outputs all zeros instead of the prepared TX buffer.
> The pattern is surprisingly regular: every 42 or 43 transfers.
> If transfer #10 fails, then #52 or #53, #94 or #95, etc.
>
> This number (~42) doesn't obviously match any power of 2 or buffer
> size I'm using, which makes it more puzzling.
Curiously matches with the answer to the ultimate question (THGG) ;)
> I have verified a few things:
> - TX buffer is correctly filled before spi_async() returns
> - Added debug check: buffer is NOT zeros at submit time when failure occurs
> - RX works fine (master data received correctly)
> - System is mostly idle (basic Yocto, systemd, no heavy load)
> - Logic analyser confirms: zeros on MISO, correct clock/CS from master
> - Forcing single CPU (maxcpus=1) does not change behaviour
>
> This suggests the data is correctly prepared but doesn't make it to
> the FIFO in time. The issue seems to be in omap2-mcspi or k3-udma,
> not in my slave protocol driver.
>
> DMA configuration:
> - Using k3-udma (AM64x UDMA subsystem)
> - Single DMA descriptor per transfer (not cyclic)
> - DMA-coherent buffers allocated with dma_alloc_coherent()
>
> Questions:
> 1. Are there known timing constraints for target mode DMA that
> could explain this periodic behaviour?
> 2. Could this be related to k3-udma descriptor recycling or
> ring management around ~42 iterations?
> 3. Is there recommended tracing/debug I should enable to
> investigate the DMA/FIFO timing?
> 4. Has anyone seen similar periodic failures in target mode?
>
> I can provide more details, traces, or test patches if helpful.
I would enable all interrupts (channel 0 is the relevant for
non-provider mode) FULL/UNDERFLOW/EMPTY and see if McSPI itself reports
any starvation.
Iteration is number of one-shot transfers (of equal size or variable size?)
I cannot recall anything which would result such an issue, but the
consistency is more than interesting. Re-reading the TRM for SPI + PDMA
and BCDMA (or PKTDMA is servicing McSPI?) might give some clues.
>
> Thanks for any pointers!
> Jean-Michel
--
Péter
prev parent reply other threads:[~2026-02-17 6:10 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-12 15:53 [RFC] omap2-mcspi: periodic zero TX in target mode - debugging help needed Jean-Michel Hautbois
2026-02-17 6:12 ` Péter Ujfalusi [this message]
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=d1ba23bc-d8cc-4109-985f-76bb454c6d4a@gmail.com \
--to=peter.ujfalusi@gmail.com \
--cc=broonie@kernel.org \
--cc=dmaengine@vger.kernel.org \
--cc=jeanmichel.hautbois@yoseli.org \
--cc=linux-spi@vger.kernel.org \
--cc=vigneshr@ti.com \
--cc=vkoul@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