From: Andrew Davis <afd@ti.com>
To: Simon Glass <sjg@chromium.org>, Tom Rini <trini@konsulko.com>,
Vignesh Raghavendra <vigneshr@ti.com>, <u-boot@lists.denx.de>
Cc: Andrew Davis <afd@ti.com>
Subject: [PATCH 3/3] dma: Transfer dma_ops should use DMA address types
Date: Fri, 7 Oct 2022 12:11:13 -0500 [thread overview]
Message-ID: <20221007171113.31577-3-afd@ti.com> (raw)
In-Reply-To: <20221007171113.31577-1-afd@ti.com>
DMA operations should function on DMA addresses, not virtual addresses.
Although these are usually the same in U-Boot, it is more correct
to be explicit with our types here.
Signed-off-by: Andrew Davis <afd@ti.com>
---
drivers/dma/dma-uclass.c | 2 +-
drivers/dma/sandbox-dma-test.c | 4 ++--
drivers/dma/ti-edma3.c | 14 +++++++-------
drivers/dma/ti/k3-udma.c | 4 ++--
include/dma-uclass.h | 4 ++--
5 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/drivers/dma/dma-uclass.c b/drivers/dma/dma-uclass.c
index 70f06f1f09..81dbb4da10 100644
--- a/drivers/dma/dma-uclass.c
+++ b/drivers/dma/dma-uclass.c
@@ -252,7 +252,7 @@ int dma_memcpy(void *dst, void *src, size_t len)
destination = dma_map_single(dst, len, DMA_FROM_DEVICE);
source = dma_map_single(src, len, DMA_TO_DEVICE);
- ret = ops->transfer(dev, DMA_MEM_TO_MEM, dst, src, len);
+ ret = ops->transfer(dev, DMA_MEM_TO_MEM, destination, source, len);
/* Clean+Invalidate the areas after, so we can see DMA'd data */
dma_unmap_single(destination, len, DMA_FROM_DEVICE);
diff --git a/drivers/dma/sandbox-dma-test.c b/drivers/dma/sandbox-dma-test.c
index aebf3eef96..2b8259a35b 100644
--- a/drivers/dma/sandbox-dma-test.c
+++ b/drivers/dma/sandbox-dma-test.c
@@ -39,9 +39,9 @@ struct sandbox_dma_dev {
};
static int sandbox_dma_transfer(struct udevice *dev, int direction,
- void *dst, void *src, size_t len)
+ dma_addr_t dst, dma_addr_t src, size_t len)
{
- memcpy(dst, src, len);
+ memcpy((void *)dst, (void *)src, len);
return 0;
}
diff --git a/drivers/dma/ti-edma3.c b/drivers/dma/ti-edma3.c
index 53dc4e8ce5..1ad3b92dbf 100644
--- a/drivers/dma/ti-edma3.c
+++ b/drivers/dma/ti-edma3.c
@@ -396,7 +396,7 @@ void qedma3_stop(u32 base, struct edma3_channel_config *cfg)
}
void __edma3_transfer(unsigned long edma3_base_addr, unsigned int edma_slot_num,
- void *dst, void *src, size_t len, size_t s_len)
+ dma_addr_t dst, dma_addr_t src, size_t len, size_t s_len)
{
struct edma3_slot_config slot;
struct edma3_channel_config edma_channel;
@@ -484,7 +484,7 @@ void __edma3_transfer(unsigned long edma3_base_addr, unsigned int edma_slot_num,
}
void __edma3_fill(unsigned long edma3_base_addr, unsigned int edma_slot_num,
- void *dst, u8 val, size_t len)
+ dma_addr_t dst, u8 val, size_t len)
{
int xfer_len;
int max_xfer = EDMA_FILL_BUFFER_SIZE * 65535;
@@ -499,7 +499,7 @@ void __edma3_fill(unsigned long edma3_base_addr, unsigned int edma_slot_num,
xfer_len = max_xfer;
__edma3_transfer(edma3_base_addr, edma_slot_num, dst,
- edma_fill_buffer, xfer_len,
+ source, xfer_len,
EDMA_FILL_BUFFER_SIZE);
len -= xfer_len;
dst += xfer_len;
@@ -517,7 +517,7 @@ void edma3_transfer(unsigned long edma3_base_addr, unsigned int edma_slot_num,
dma_addr_t destination = dma_map_single(dst, len, DMA_FROM_DEVICE);
dma_addr_t source = dma_map_single(src, len, DMA_TO_DEVICE);
- __edma3_transfer(edma3_base_addr, edma_slot_num, dst, src, len, len);
+ __edma3_transfer(edma3_base_addr, edma_slot_num, destination, source, len, len);
/* Clean+Invalidate the areas after, so we can see DMA'd data */
dma_unmap_single(destination, len, DMA_FROM_DEVICE);
@@ -530,7 +530,7 @@ void edma3_fill(unsigned long edma3_base_addr, unsigned int edma_slot_num,
/* Clean the area, so no writeback into the RAM races with DMA */
dma_addr_t destination = dma_map_single(dst, len, DMA_FROM_DEVICE);
- __edma3_fill(edma3_base_addr, edma_slot_num, dst, val, len);
+ __edma3_fill(edma3_base_addr, edma_slot_num, destination, val, len);
/* Clean+Invalidate the area after, so we can see DMA'd data */
dma_unmap_single(destination, len, DMA_FROM_DEVICE);
@@ -538,8 +538,8 @@ void edma3_fill(unsigned long edma3_base_addr, unsigned int edma_slot_num,
#else
-static int ti_edma3_transfer(struct udevice *dev, int direction, void *dst,
- void *src, size_t len)
+static int ti_edma3_transfer(struct udevice *dev, int direction,
+ dma_addr_t dst, dma_addr_t src, size_t len)
{
struct ti_edma3_priv *priv = dev_get_priv(dev);
diff --git a/drivers/dma/ti/k3-udma.c b/drivers/dma/ti/k3-udma.c
index 86603d43f1..ab6639b4a1 100644
--- a/drivers/dma/ti/k3-udma.c
+++ b/drivers/dma/ti/k3-udma.c
@@ -2304,7 +2304,7 @@ err_res_free:
}
static int udma_transfer(struct udevice *dev, int direction,
- void *dst, void *src, size_t len)
+ dma_addr_t dst, dma_addr_t src, size_t len)
{
struct udma_dev *ud = dev_get_priv(dev);
/* Channel0 is reserved for memcpy */
@@ -2325,7 +2325,7 @@ static int udma_transfer(struct udevice *dev, int direction,
if (ret)
return ret;
- udma_prep_dma_memcpy(uc, (dma_addr_t)dst, (dma_addr_t)src, len);
+ udma_prep_dma_memcpy(uc, dst, src, len);
udma_start(uc);
udma_poll_completion(uc, &paddr);
udma_stop(uc);
diff --git a/include/dma-uclass.h b/include/dma-uclass.h
index 340437acc1..ea721baae6 100644
--- a/include/dma-uclass.h
+++ b/include/dma-uclass.h
@@ -132,8 +132,8 @@ struct dma_ops {
* @len: Length of the data to be copied (number of bytes).
* @return zero on success, or -ve error code.
*/
- int (*transfer)(struct udevice *dev, int direction, void *dst,
- void *src, size_t len);
+ int (*transfer)(struct udevice *dev, int direction, dma_addr_t dst,
+ dma_addr_t src, size_t len);
};
#endif /* _DMA_UCLASS_H */
--
2.37.3
next prev parent reply other threads:[~2022-10-07 17:11 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-07 17:11 [PATCH 1/3] dma: Use dma-mapping for cache ops and sync after write Andrew Davis
2022-10-07 17:11 ` [PATCH 2/3] dma: ti-edma3: Add DMA map operations before and after transfers Andrew Davis
2022-10-18 22:15 ` Tom Rini
2022-10-07 17:11 ` Andrew Davis [this message]
2022-10-18 22:15 ` [PATCH 3/3] dma: Transfer dma_ops should use DMA address types Tom Rini
2022-10-18 22:15 ` [PATCH 1/3] dma: Use dma-mapping for cache ops and sync after write Tom Rini
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=20221007171113.31577-3-afd@ti.com \
--to=afd@ti.com \
--cc=sjg@chromium.org \
--cc=trini@konsulko.com \
--cc=u-boot@lists.denx.de \
--cc=vigneshr@ti.com \
/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