Skip to content

Align AXI DMAC configuration and peripheral client use #6280

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Jul 25, 2024

Conversation

P33M
Copy link
Contributor

@P33M P33M commented Jul 23, 2024

This is a bit of an omni-PR, but it solves two important issues:

  • TV hat unreliability on Pi 5
  • Hardware limitations of the DMAC causing mismatches between client expectations of bytes transferred vs descriptor lengths

In the first case, the limitations of the DMAC severely restrict SPI throughput so operating a) in a unidirectional mode b) with corrected burst lengths are both required. Doing b) means that other peripheral drivers using the DMAC need to set burst thresholds (particularly RX) correctly.

if (dws->dma_mapped) {
dw_spi_mask_intr(dws, 0xff);
dw_readl(dws, DW_SPI_ICR);
} else
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, but the kernel coding style is to use braces in both paths or neither.

pelwell and others added 10 commits July 25, 2024 14:49
TMOD_TO is the transmit-only mode that doesn't put data into the receive
FIFO. Using TMOD_TO when the user doesn't want the received data saves
CPU time and memory bandwidth.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
TMOD_RO is the receive-only mode that doesn't require data in the
transmit FIFO in order to generate clock cycles. Using TMOD_RO when the
device doesn't care about the data sent to it saves CPU time and memory
bandwidth.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
Disabling the peripheral resets controller state which has a dangerous
side-effect of disabling the DMA handshake interface while it is active.
This can cause DMA channels to hang.

The error recovery pathway will wait for DMA to stop and reset the chip
anyway, so mask further FIFO interrupts and let the transfer finish
gracefully.

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>
Channels 1-2 have a statically configured maximum MSIZE of 8, and
channels 3-8 have MSIZE set to 4. The DMAC "helpfully" silently
truncates bursts to the hardware supported maximum, so any FIFO read
operation with an oversized burst threshold will leave a residue of
threshold minus MSIZE rows.

As channel allocation is dynamic, this means every client needs to use a
maximum of 4 for burst length.

AXI AWLEN/ARLEN constraints aren't strictly related to MSIZE, except
that bursts won't be issued that are longer than MSIZE beats. Therefore,
it's a useful proxy to tell clients of the DMAC the hardware
limitations.

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>
There's no real need to constrain MEM access widths to 32-bit (or
narrower), as the DMAC is intelligent enough to size memory accesses
appropriately. Wider accesses are more efficient.

Similarly, MEM burst lengths don't need to be a function of DEV burst
lengths - the DMAC packs/unpacks data into/from its internal channel
FIFOs appropriately. Longer accesses are more efficient.

However, the DMAC doesn't have complete support for unaligned accesses,
and blocks are always defined in integer multiples of SRC_WIDTH, so odd
source lengths or buffer alignments will prevent wide accesses being
used, as before.

There is an implicit requirement to limit requested DEV read burst
lengths to less than the hardware's maximum configured MSIZE - otherwise
RX data will be left over at the end of a block. There is no config
register that reports this value, so the AXI burst length parameter is
used to produce a facsimile of it. Warn if such a request arrives that
doesn't respect this.

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>
This issue was due to a misconfiguration of the RP1 DMAC due to hardware
limitations, not the SPI driver (which was using the incorrect reported
maximum burst size to set the FIFO threshold).

This reverts commit 6aab06f.

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>
If the associated DMA controller has lower burst length support than the
level the FIFO is set to, then bytes will be left in the RX FIFO at the
end of a DMA block - requiring a round-trip through the timeout interrupt
handler rather than an end-of-block DMA interrupt.

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>
Do an end-run around ASoC in lieu of not being able to easily find the
associated DMA controller capabilities.

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>
…ints

Valid ranges for the I2S peripheral's FIFO configuration include a depth
of 16 - unconditionally setting the burst length to 16 with a fifo
threshold of size/2 will cause under/overflows.

For DMA engines with restricted capabilities the requested burst length
and FIFO thresholds need to be adjusted downward accordingly.

Both the RX and TX FIFOs operate on "less-than" thresholds. Setting the
TX threshold to fifo_size minus burst means the FIFO is kept nearly-full.

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>
The associated DMAC has channels that do not support longer bursts.

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>
@P33M P33M marked this pull request as ready for review July 25, 2024 13:49
@pelwell pelwell merged commit 062434a into raspberrypi:rpi-6.6.y Jul 25, 2024
11 of 12 checks passed
popcornmix added a commit to raspberrypi/firmware that referenced this pull request Jul 25, 2024
See: raspberrypi/linux#6283

kernel: Align AXI DMAC configuration and peripheral client use
See: raspberrypi/linux#6280

kernel: drm/vc4: Disable the 2pixel/clock odd timings workaround for interlaced
See: raspberrypi/linux#6282
popcornmix added a commit to raspberrypi/rpi-firmware that referenced this pull request Jul 25, 2024
See: raspberrypi/linux#6283

kernel: Align AXI DMAC configuration and peripheral client use
See: raspberrypi/linux#6280

kernel: drm/vc4: Disable the 2pixel/clock odd timings workaround for interlaced
See: raspberrypi/linux#6282
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants