From: Robin Murphy <robin.murphy@arm.com>
To: Andrea della Porta <andrea.porta@suse.com>,
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, linux-rpi-kernel@lists.infradead.org,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org,
"iommu@lists.linux.dev" <iommu@lists.linux.dev>
Cc: Maxime Ripard <maxime@cerno.tech>,
Dom Cobley <popcornmix@gmail.com>,
Phil Elwell <phil@raspberrypi.com>
Subject: Re: [PATCH 05/12] bcm2835-dma: Derive slave DMA addresses correctly
Date: Mon, 5 Feb 2024 18:03:53 +0000 [thread overview]
Message-ID: <ee19a95d-fe1e-4f3f-bc81-bdef38475469@arm.com> (raw)
In-Reply-To: <30da53ebdf43b712da790fd2ae0f0040f71762b8.1706948717.git.andrea.porta@suse.com>
On 2024-02-04 6:59 am, Andrea della Porta wrote:
> From: Phil Elwell <phil@raspberrypi.com>
>
> Slave addresses for DMA are meant to be supplied as physical addresses
> (contrary to what struct snd_dmaengine_dai_dma_data does). It is up to
> the DMA controller driver to perform the translation based on its own
> view of the world, as described in Device Tree.
>
> Now that the Pi Device Trees have the correct peripheral mappings,
> replace the hacky address munging with phys_to_dma().
>
> Signed-off-by: Phil Elwell <phil@raspberrypi.com>
> ---
> drivers/dma/bcm2835-dma.c | 23 +++++------------------
> 1 file changed, 5 insertions(+), 18 deletions(-)
>
> diff --git a/drivers/dma/bcm2835-dma.c b/drivers/dma/bcm2835-dma.c
> index 237dcdb8d726..077812eda609 100644
> --- a/drivers/dma/bcm2835-dma.c
> +++ b/drivers/dma/bcm2835-dma.c
> @@ -18,6 +18,7 @@
> * Copyright 2012 Marvell International Ltd.
> */
> #include <linux/dmaengine.h>
> +#include <linux/dma-direct.h>
Please read the comment at the top of that file; this driver is
definitely not a DMA API implementation, and should not be including it.
> #include <linux/dma-mapping.h>
> #include <linux/dmapool.h>
> #include <linux/err.h>
> @@ -980,22 +981,12 @@ static struct dma_async_tx_descriptor *bcm2835_dma_prep_slave_sg(
> if (direction == DMA_DEV_TO_MEM) {
> if (c->cfg.src_addr_width != DMA_SLAVE_BUSWIDTH_4_BYTES)
> return NULL;
> - src = c->cfg.src_addr;
> - /*
> - * One would think it ought to be possible to get the physical
> - * to dma address mapping information from the dma-ranges DT
> - * property, but I've not found a way yet that doesn't involve
> - * open-coding the whole thing.
> - */
> - if (c->is_40bit_channel)
> - src |= 0x400000000ull;
> + src = phys_to_dma(chan->device->dev, c->cfg.src_addr);
FWIW I'd argue that abusing DMA API internals like this is even more
hacky than bypassing it entirely. The appropriate public API for setting
up the device end of a transfer is dma_map_resource(). Now, it *is* the
case currently that the dma-direct implementation of that does not take
dma_range_map into account, but that's already an open question:
https://lore.kernel.org/linux-iommu/20220610080802.11147-1-Sergey.Semin@baikalelectronics.ru/
Thanks,
Robin.
> info |= BCM2835_DMA_S_DREQ | BCM2835_DMA_D_INC;
> } else {
> if (c->cfg.dst_addr_width != DMA_SLAVE_BUSWIDTH_4_BYTES)
> return NULL;
> - dst = c->cfg.dst_addr;
> - if (c->is_40bit_channel)
> - dst |= 0x400000000ull;
> + dst = phys_to_dma(chan->device->dev, c->cfg.dst_addr);
> info |= BCM2835_DMA_D_DREQ | BCM2835_DMA_S_INC;
> }
>
> @@ -1064,17 +1055,13 @@ static struct dma_async_tx_descriptor *bcm2835_dma_prep_dma_cyclic(
> if (direction == DMA_DEV_TO_MEM) {
> if (c->cfg.src_addr_width != DMA_SLAVE_BUSWIDTH_4_BYTES)
> return NULL;
> - src = c->cfg.src_addr;
> - if (c->is_40bit_channel)
> - src |= 0x400000000ull;
> + src = phys_to_dma(chan->device->dev, c->cfg.src_addr);
> dst = buf_addr;
> info |= BCM2835_DMA_S_DREQ | BCM2835_DMA_D_INC;
> } else {
> if (c->cfg.dst_addr_width != DMA_SLAVE_BUSWIDTH_4_BYTES)
> return NULL;
> - dst = c->cfg.dst_addr;
> - if (c->is_40bit_channel)
> - dst |= 0x400000000ull;
> + dst = phys_to_dma(chan->device->dev, c->cfg.dst_addr);
> src = buf_addr;
> info |= BCM2835_DMA_D_DREQ | BCM2835_DMA_S_INC;
>
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2024-02-05 18:04 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-04 6:59 [PATCH 00/12] Add support for BCM2712 DMA engine Andrea della Porta
2024-02-04 6:59 ` [PATCH 01/12] bcm2835-dma: Add support for per-channel flags Andrea della Porta
2024-02-04 6:59 ` [PATCH 02/12] bcm2835-dma: Add proper 40-bit DMA support Andrea della Porta
2024-02-05 18:50 ` Stefan Wahren
2024-02-06 16:31 ` Dave Stevenson
2024-02-06 18:08 ` Stefan Wahren
2024-02-06 18:11 ` Stefan Wahren
2024-02-04 6:59 ` [PATCH 03/12] bcm2835-dma: Add NO_WAIT_RESP, DMA_WIDE_SOURCE and DMA_WIDE_DEST flag Andrea della Porta
2024-02-04 6:59 ` [PATCH 04/12] bcm2835-dma: Advertise the full DMA range Andrea della Porta
2024-02-05 17:55 ` Robin Murphy
2024-03-01 13:55 ` Andrea della Porta
2024-02-05 18:25 ` Stefan Wahren
2024-02-04 6:59 ` [PATCH 05/12] bcm2835-dma: Derive slave DMA addresses correctly Andrea della Porta
2024-02-05 18:03 ` Robin Murphy [this message]
2024-02-04 6:59 ` [PATCH 06/12] dmaengine: bcm2835: Use to_bcm2711_cbaddr where relevant Andrea della Porta
2024-02-04 17:04 ` Florian Fainelli
2024-02-05 10:25 ` Andrea della Porta
2024-02-04 6:59 ` [PATCH 07/12] bcm2835-dma: Support dma flags for multi-beat burst Andrea della Porta
2024-02-07 8:22 ` Vinod Koul
2024-02-04 6:59 ` [PATCH 08/12] bcm2835-dma: Need to keep PROT bits set in CS on 40bit controller Andrea della Porta
2024-02-04 6:59 ` [PATCH 09/12] dmaengine: bcm2835: Add BCM2712 support Andrea della Porta
2024-02-04 6:59 ` [PATCH 10/12] dmaengine: bcm2835: Support DMA-Lite channels Andrea della Porta
2024-02-07 8:26 ` Vinod Koul
2024-02-04 6:59 ` [PATCH 11/12] dmaengine: bcm2835: Rename to_bcm2711_cbaddr to to_40bit_cbaddr Andrea della Porta
2024-02-04 6:59 ` [PATCH 12/12] bcm2835-dma: Fixes for dma_abort Andrea della Porta
2024-02-05 19:06 ` [PATCH 00/12] Add support for BCM2712 DMA engine Stefan Wahren
2024-02-07 8:19 ` Vinod Koul
2024-02-07 10:24 ` Andrea della Porta
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=ee19a95d-fe1e-4f3f-bc81-bdef38475469@arm.com \
--to=robin.murphy@arm.com \
--cc=andrea.porta@suse.com \
--cc=bcm-kernel-feedback-list@broadcom.com \
--cc=dmaengine@vger.kernel.org \
--cc=florian.fainelli@broadcom.com \
--cc=iommu@lists.linux.dev \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rpi-kernel@lists.infradead.org \
--cc=maxime@cerno.tech \
--cc=phil@raspberrypi.com \
--cc=popcornmix@gmail.com \
--cc=rjui@broadcom.com \
--cc=sbranden@broadcom.com \
--cc=vkoul@kernel.org \
/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: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).