-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Pull upstream dma backport into rpi 4.4.y #1524
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
Pull upstream dma backport into rpi 4.4.y #1524
Conversation
This reverts commit ec2e48f.
This reverts commit 052c200.
This reverts commit 6f56fff.
This reverts commit 8a34930.
The original patch contained 3 dma channels that were masked out. These - as far as research and discussions show - are a artefacts remaining from the downstream legacy dma-api. Right now down-stream still includes a legacy api used only in a single (downstream only) driver (bcm2708_fb) that requires 2D DMA for speedup (DMA-channel 0). Formerly the sd-card support driver also was using this legacy api (DMA-channel 2), but since has been moved over to use dmaengine directly. The DMA-channel 3 is already masked out in the devicetree in the default property "brcm,dma-channel-mask = <0x7f35>;" So we can remove the whole masking of DMA channels. Signed-off-by: Martin Sperl <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Signed-off-by: Eric Anholt <[email protected]> Signed-off-by: Vinod Koul <[email protected]>
Add additional defines describing the DMA registers as well as adding some more documentation to those registers. Signed-off-by: Martin Sperl <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Signed-off-by: Eric Anholt <[email protected]> Signed-off-by: Vinod Koul <[email protected]>
…_desc In preparation to consolidating code we move the cyclic member into the bcm_2835_desc structure. Signed-off-by: Martin Sperl <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Signed-off-by: Eric Anholt <[email protected]> Signed-off-by: Vinod Koul <[email protected]>
…method In preparation of adding slave_sg functionality this patch moves the generation/allocation of bcm2835_desc and the building of the corresponding DMA-control-block chain from bcm2835_dma_prep_dma_cyclic into the newly created method bcm2835_dma_create_cb_chain. Signed-off-by: Martin Sperl <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Signed-off-by: Eric Anholt <[email protected]> Signed-off-by: Vinod Koul <[email protected]>
The bcm2835 dma system has 2 basic types of dma-channels: * "normal" channels * "light" channels Lite channels are limited in several aspects: * internal data-structure is 128 bit (not 256) * does not support BCM2835_DMA_TDMODE (2D) * DMA length register is limited to 16 bit. so 0-65535 (not 0-65536 as mentioned in the official datasheet) * BCM2835_DMA_S/D_IGNORE are not supported The detection of the type of mode is implemented by looking at the LITE bit in the DEBUG register for each channel. This allows automatic detection. Based on this the maximum block size is set to (64K - 4) or to 1G and this limit is honored during generation of control block chains. The effect is that when a LITE channel is used more control blocks are used to do the same transfer (compared to a normal channel). As there are several sources/target DREQS that are 32 bit wide we need to have the transfer to be a multiple of 4 as this would break the transfer otherwise. This is why the limit of (64K - 4) was chosen over the alternative of (64K - 4K). Signed-off-by: Martin Sperl <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Signed-off-by: Eric Anholt <[email protected]> Signed-off-by: Vinod Koul <[email protected]>
Add slave_sg support to bcm2835-dma using shared allocation code for bcm2835_desc and DMA-control blocks already used by dma_cyclic. Note that bcm2835_dma_callback had to get modified to support both modes of operation (cyclic and non-cyclic). Tested using: * Hifiberry I2S card (using cyclic DMA) * fb_st7735r SPI-framebuffer (using slave_sg DMA via spi-bcm2835) playing BigBuckBunny for audio and video. Signed-off-by: Martin Sperl <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Signed-off-by: Eric Anholt <[email protected]> Signed-off-by: Vinod Koul <[email protected]>
Also added check for an error condition in bcm2835_dma_create_cb_chain that showed up during development of this patch. Tested using dmatest for all enabled channels. Signed-off-by: Martin Sperl <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Signed-off-by: Eric Anholt <[email protected]> Signed-off-by: Vinod Koul <[email protected]>
Use platform_get_irq_byname to allow for correct mapping of interrupts to dma channels. The currently implemented device tree is unfortunately implemented with the wrong assumption, that each dma-channel has its own dma channel, but dma-irq 11 is handling dma-channel 11-14 and dma-irq 12 is actually a "catch all" interrupt. So here we use the byname variant and require that interrupts are explicitly named via the interrupts-name property in the device tree. The use of shared interrupts is also implemented. As a side-effect this means we can now use dma channels 12, 13 and 14 in a correct manner - also testing shows that onl using channels 11 to 14 for spi and i2s works perfectly (when playing some video) Signed-off-by: Martin Sperl <[email protected]> Acked-by: Eric Anholt <[email protected]> Acked-by: Mark Rutland <[email protected]> Signed-off-by: Vinod Koul <[email protected]>
Load driver early since at least bcm2708_fb doesn't support deferred probing and even if it did, we don't want the video driver deferred. Support the legacy DMA API which is needed by bcm2708_fb (but only using the dedicated dma channel 0). Signed-off-by: Noralf Trønnes <[email protected]> Signed-off-by: Martin Sperl <[email protected]>
Dma channel0 is used by the legacy api - to avoid confilcts this needs to get masked out in the device-tree instead of hardcoding it in the driver. Signed-off-by: Martin Sperl <[email protected]>
Add interrupt-names properties to dt and apply the correct mapping between irq and dma channels. Signed-off-by: Martin Sperl <[email protected]>
Enable the use of dma-channel 0 when using the vc4-kms-v3d overlay. Signed-off-by: Martin Sperl <[email protected]>
The code responsible for splitting periods into chunks that can be handled by the DMA controller missed to update total_len, the number of bytes processed in the current period, when there are more chunks to follow. Therefore total_len was stuck at 0 and the code didn't work at all. This resulted in a wrong control block layout and audio issues because the cyclic DMA callback wasn't executing on period boundaries. Fix this by adding the missing total_len update. Signed-off-by: Matthias Reichl <[email protected]> Signed-off-by: Martin Sperl <[email protected]> Tested-by: Clive Messer <[email protected]>
The current cyclic DMA period splitting implementation can generate very small chunks at the end of each period. For example a 65536 byte period will be split into a 65532 byte chunk and a 4 byte chunk on the "lite" DMA channels. This increases pressure on the RAM controller as the DMA controller needs to fetch two control blocks from RAM in quick succession and could potentially cause latency issues if the RAM is tied up by other devices. We can easily avoid these situations by distributing the remaining length evenly between the last-but-one and the last chunk, making sure that split chunks will be at least half the maximum length the DMA controller can handle. This patch checks if the last chunk would be less than half of the maximum DMA length and if yes distributes the max len+4...max_len*1.5 bytes evenly between the last 2 chunks. This results in chunk sizes between max_len/2 and max_len*0.75 bytes. Signed-off-by: Matthias Reichl <[email protected]> Signed-off-by: Martin Sperl <[email protected]> Tested-by: Clive Messer <[email protected]>
… masked. The tx_status hook is supposed to be safe to call from interrupt context, but it wouldn't ever return completion for the last transfer, meaning you couldn't poll for DMA completion with interrupts masked. This fixes IRQ handling for bcm2835's DSI1, which requires using the DMA engine to write its registers due to a bug in the AXI bridge. Signed-off-by: Eric Anholt <[email protected]>
Added 19th patch to this dma set, from Eric Anholt, "dmaengine: bcm2835: Fix polling for completion of DMA with interrupts masked". See #1522 (comment) |
I've cherry-picked Eric's patch to 4.6 for further testing. |
Cool. I won't be submitting a new PR for rpi-4.6.y branch then....... |
See: raspberrypi/linux#1524 kernel: 8192cu: Enable cfg80211 and various fixes See: raspberrypi/linux#1489 See: raspberrypi/linux#1488 firmware: dt-blob: Don't statically set i2c0 function on pins firmware: image_fx: Mask off unwanted flags from generated frames firmware: raspivid: Add option -lev/--level to raspvid to select H264 Level
See: raspberrypi/linux#1524 kernel: 8192cu: Enable cfg80211 and various fixes See: raspberrypi/linux#1489 See: raspberrypi/linux#1488 firmware: dt-blob: Don't statically set i2c0 function on pins firmware: image_fx: Mask off unwanted flags from generated frames firmware: raspivid: Add option -lev/--level to raspvid to select H264 Level
@samaaron or any other testers, this PR is in latest rpi-update kernel/firmware. |
Yes! Updating the kernel using rpi-update did the trick. Clear audio
through HiFiBerry DAC+, no stuttering.
Many thanks!
Stuart
|
Thanks for the feedback. And if in real life you ever happen to cross paths with a man called Martin Sperl, buy him a beer. He's the person to thank. |
See: raspberrypi/linux#1524 kernel: 8192cu: Enable cfg80211 and various fixes See: raspberrypi/linux#1489 See: raspberrypi/linux#1488 firmware: dt-blob: Don't statically set i2c0 function on pins firmware: image_fx: Mask off unwanted flags from generated frames firmware: raspivid: Add option -lev/--level to raspvid to select H264 Level
This is an 18 patch series, consisting of 16 patches from @msperl (the upstream dma backport) and 2 "fix" patches from @HiassofT