DMA range support on BCM283x

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi All

I'm looking at the DMA configuration on BCM283x as part of upstreaming
the 40 bit controller for BCM2711.

It looks like we have a historical misconfiguration, and I'm not sure
how we resolve it.

On BCM283x, dma address != CPU physical address, particularly for the
peripheral registers.

The DMA users have been passing in the DMA address extracted from DT,
eg HDMI audio [1], SPI [2], and MMC [3]. Certainly for HDMI audio this
is implied as correct by struct snd_dmaengine_dai_dma_data taking a
dma_addr_t, except snd_dmaengine_pcm_set_config_from_dai_data() then
assigns that dma_addr_t to a phys_addr_t[4].

Our understanding now is that this is incorrect, and they should be
passed the CPU physical address. "dma-ranges" should then reflect the
mapping, and the dma driver should be using dma_map_resource() to map
between the two (although it currently doesn't consider dma-ranges as
raised in [5]).

BCM283x DT currently doesn't cover the peripheral registers in
"dma-ranges", although it is present in "ranges". AIUI it's considered
ABI so we can't now mandate that mapping be present.

Assuming I'm correct with the above, the question is how to implement
a solution that corrects the behaviour whilst still supporting the old
DT, and preferably isn't spread far and wide through the code.
Worst case is to require all DMA users and the DMA controller to look
for the dma-ranges property, observe the range isn't present, and drop
back to the current behaviour.
Slightly nicer is to use the knowledge that "ranges" and "dma-ranges"
in this case should be identical, so have the DMA controller driver
attempt a lookup with "ranges" if "dma-ranges" fails.

It's an awkward situation that we find ourselves in, but any advice on
routes forward would be appreciated.

Many thanks
  Dave

[1] https://github.com/torvalds/linux/blob/master/drivers/gpu/drm/vc4/vc4_hdmi.c#L2729-L2743
dates back to bb7d78568814 ("drm/vc4: Add HDMI audio support") in 2017
[2] https://github.com/torvalds/linux/blob/master/drivers/spi/spi-bcm2835.c#L898-L905
dates back to 3ecd37edaa2a ("spi: bcm2835: enable dma modes for
transfers meeting certain conditions") in 2015
[3] https://github.com/torvalds/linux/blob/master/drivers/mmc/host/bcm2835.c#L1370-L1380
[4] https://github.com/torvalds/linux/blob/master/sound/core/pcm_dmaengine.c#L112
and line 120.
[5] https://lkml.org/lkml/2024/2/5/1161




[Index of Archives]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux PCI]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux