From: Dave Stevenson <dave.stevenson@raspberrypi.com> To: Vinod Koul <vkoul@kernel.org>, Florian Fainelli <florian.fainelli@broadcom.com>, Ray Jui <rjui@broadcom.com>, Scott Branden <sbranden@broadcom.com>, Broadcom internal kernel review list <bcm-kernel-feedback-list@broadcom.com>, dmaengine@vger.kernel.org, Robin Murphy <robin.murphy@arm.com>, Christoph Hellwig <hch@lst.de>, Marek Szyprowski <m.szyprowski@samsung.com>, linux-rpi-kernel@lists.infradead.org, Linux ARM <linux-arm-kernel@lists.infradead.org> Cc: Maxime Ripard <mripard@kernel.org>, Mark Brown <broonie@kernel.org>, Ulf Hansson <ulf.hansson@linaro.org>, Stefan Wahren <wahrenst@gmx.net>, Nicolas Saenz Julienne <nsaenzjulienne@suse.de>, Jim Quinlan <jim2101024@gmail.com>, Phil Elwell <phil@raspberrypi.com> Subject: DMA range support on BCM283x Date: Fri, 8 Mar 2024 15:06:01 +0000 [thread overview] Message-ID: <CAPY8ntByJYzSv0kTAc1kY0Dp=vwrzcA0oWiPpyg7x7_BQwGSnA@mail.gmail.com> (raw) 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
WARNING: multiple messages have this Message-ID (diff)
From: Dave Stevenson <dave.stevenson@raspberrypi.com> To: Vinod Koul <vkoul@kernel.org>, Florian Fainelli <florian.fainelli@broadcom.com>, Ray Jui <rjui@broadcom.com>, Scott Branden <sbranden@broadcom.com>, Broadcom internal kernel review list <bcm-kernel-feedback-list@broadcom.com>, dmaengine@vger.kernel.org, Robin Murphy <robin.murphy@arm.com>, Christoph Hellwig <hch@lst.de>, Marek Szyprowski <m.szyprowski@samsung.com>, linux-rpi-kernel@lists.infradead.org, Linux ARM <linux-arm-kernel@lists.infradead.org> Cc: Maxime Ripard <mripard@kernel.org>, Mark Brown <broonie@kernel.org>, Ulf Hansson <ulf.hansson@linaro.org>, Stefan Wahren <wahrenst@gmx.net>, Nicolas Saenz Julienne <nsaenzjulienne@suse.de>, Jim Quinlan <jim2101024@gmail.com>, Phil Elwell <phil@raspberrypi.com> Subject: DMA range support on BCM283x Date: Fri, 8 Mar 2024 15:06:01 +0000 [thread overview] Message-ID: <CAPY8ntByJYzSv0kTAc1kY0Dp=vwrzcA0oWiPpyg7x7_BQwGSnA@mail.gmail.com> (raw) 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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next reply other threads:[~2024-03-08 15:06 UTC|newest] Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top 2024-03-08 15:06 Dave Stevenson [this message] 2024-03-08 15:06 ` DMA range support on BCM283x Dave Stevenson 2024-03-14 13:47 ` Mark Brown 2024-03-14 13:47 ` Mark Brown 2024-03-15 16:27 ` Dave Stevenson 2024-03-15 16:27 ` Dave Stevenson
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='CAPY8ntByJYzSv0kTAc1kY0Dp=vwrzcA0oWiPpyg7x7_BQwGSnA@mail.gmail.com' \ --to=dave.stevenson@raspberrypi.com \ --cc=bcm-kernel-feedback-list@broadcom.com \ --cc=broonie@kernel.org \ --cc=dmaengine@vger.kernel.org \ --cc=florian.fainelli@broadcom.com \ --cc=hch@lst.de \ --cc=jim2101024@gmail.com \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-rpi-kernel@lists.infradead.org \ --cc=m.szyprowski@samsung.com \ --cc=mripard@kernel.org \ --cc=nsaenzjulienne@suse.de \ --cc=phil@raspberrypi.com \ --cc=rjui@broadcom.com \ --cc=robin.murphy@arm.com \ --cc=sbranden@broadcom.com \ --cc=ulf.hansson@linaro.org \ --cc=vkoul@kernel.org \ --cc=wahrenst@gmx.net \ /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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.