-
Notifications
You must be signed in to change notification settings - Fork 5k
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
Use bcm2835-dma #1153
Use bcm2835-dma #1153
Conversation
bcm2708_fb uses the legacy DMA API, so in order to start using bcm2835-dma, bcm2835-dma has to support the legacy API. Make this possible by exporting bcm_dmaman_probe() and bcm_dmaman_remove(). Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
Add slave transfer capability to BCM2835 dmaengine driver. This patch is pulled from the bcm2708-dmaengine driver in the Raspberry Pi repo. The work was done by Gellert Weisz. Tested using the bcm2835-mmc driver from the same repo. Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
bcm2835-dma supports residue reporting at burst level but didn't report this via the residue_granularity field. Without this field set properly we get playback issues with I2S cards. [by HiassofT, taken from bcm2708-dmaengine] Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
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. Don't mask out channel 2. Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
[by popcornmix, taken from bcm2708-dmaengine] Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
Start to use bcm2835-dma when booting with Device Tree. bcm2708-dmaengine will be used with non-DT boot. Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
Both bcm2835-dma and bcm2708-dmaengine have the same compatible string. So change compatible to "brcm,bcm2708-dma". Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
Looks reasonable to me. We could probably drop the debug wait states commit as so far it hasn't fixed any problematic sdcards (although it's self contained and could be dropped later). Also I think non-DT support is just waiting for an excuse to drop it. I don't think you'd have any objections if you stopped supporting it (on 4.2 or later trees). |
Actually I'm working on patches that will remove non-DT support where ever I can find it. Primarly just to see how much I can remove. I can make it into a PR so we can discuss it. |
Yes. I'm sure non-DT will be removed, it's just when. |
With the latest changes, bcm2835-dma.c and bcm2708-dmaengine,c are so similar that it is easier to compare the two files than it is to review the changes. If it weren't for a large number of mainly pointless cosmetic differences then bcm2835-dma.c would almost be a large subset of the downstream driver. No objections. |
Thanks. Seemed to work fine in a run time test. |
I've noticed 2 differences compared to bcm2708-dmaengine: bcm2835_dma_slave_config doesn't set c->dreq to cfg->slave_id if c->dreq is 0. This causes I2S soundcards to break. You can reproduce it with the rpi-dac overlay (no hardware needed), then run aplay or speaker-test and you'll get a lot of underruns instead of sound output. Adding the missing code fixes this issue
Second issue: with MAX_LITE_TRANSFER set to SZ_64K-4 (instead of 32k as in the bcm2708 code) I get repeating clicks as soon as period_len is greater than 32k. i.e. with the default alsa settings aplay with a 48kHz/16bit file plays fine, but for example 48kHz/32bit or 96kHz/16bit files click. Setting MAX_LITE_TRANSFER to SZ_32K fixes this issue. Not sure though if alsa or the DMA controller is to blame for that. Other than that: great job, with these 2 fixes everything seems to be working really fine! |
Yes, the driver expects the channel to come from Device Tree which sets dreq.
I just tested spi-bcm2835 with a 65532 byte buffer on a SPI display and it worked fine. Mainline bcm2835-dma doesn't check the transfer size at all and it is used with bcm2835-i2s. But I don't know how well it is tested with regards to buffer sizes. And I don't know if it was tested with normal or lite channels. The easy fix is to just set it to 32k for cyclic dma, unless @popcornmix or @pelwell has objections or insight into why this happens. I2S is one a the few areas where we haven't switched to the mainline driver, hopefully someone will look into this. |
Until someone does have time to look into making the mainline dma driver work properly with I2S, can we please revert this commit from the 4.2.y tree? I would suggest that the 4.3.y tree would be a better "playground" for this sort of change. |
This PR patches up bcm2835-dma to match bcm2708-dmaengine and uses it when booting with Device Tree. Non-DT booting continues to use bcm2708-dmaengine.
bcm2835-dma exposes the legacy DMA API by using bcm2708-dmaengine.
Tested on Pi1 and Pi2 with and without Device Tree + ARCH_BCM2835.
7 DMA channels:
Relevant boot log entries with Device Tree:
Without DT (the channel 13 error also occurs without this PR):