From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH 2/2] dma: add dma_sync nop stubs for PBL
Date: Tue, 14 Jun 2022 11:15:56 +0200 [thread overview]
Message-ID: <20220614091556.1018102-2-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20220614091556.1018102-1-a.fatoum@pengutronix.de>
We can implement dma_sync functions as compiler barriers when we are
certain that the buffers are in coherent/uncached memory, e.g. because
MMU is only enabled in barebox_arm_entry which hasn't run yet.
This will come in handy when doing mailbox communication in PBL on the
Raspberry Pi.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
Please replace equally-named patch in next with this.
Should fix breakage for !MMU SoCFPGA
---
include/dma.h | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/include/dma.h b/include/dma.h
index 2a271044f61c..2c4bdfc98fb5 100644
--- a/include/dma.h
+++ b/include/dma.h
@@ -56,6 +56,7 @@ static inline int dma_mapping_error(struct device_d *dev, dma_addr_t dma_addr)
(dev->dma_mask && dma_addr > dev->dma_mask);
}
+#ifndef __PBL__
/* streaming DMA - implement the below calls to support HAS_DMA */
#ifndef dma_sync_single_for_cpu
void dma_sync_single_for_cpu(dma_addr_t address, size_t size,
@@ -66,6 +67,27 @@ void dma_sync_single_for_cpu(dma_addr_t address, size_t size,
void dma_sync_single_for_device(dma_addr_t address, size_t size,
enum dma_data_direction dir);
#endif
+#else
+#ifndef dma_sync_single_for_cpu
+/*
+ * assumes buffers are in coherent/uncached memory, e.g. because
+ * MMU is only enabled in barebox_arm_entry which hasn't run yet.
+ */
+static inline void dma_sync_single_for_cpu(dma_addr_t address, size_t size,
+ enum dma_data_direction dir)
+{
+ barrier_data((void *)address);
+}
+#endif
+
+#ifndef dma_sync_single_for_device
+static inline void dma_sync_single_for_device(dma_addr_t address, size_t size,
+ enum dma_data_direction dir)
+{
+ barrier_data((void *)address);
+}
+#endif
+#endif
#ifndef dma_alloc_coherent
void *dma_alloc_coherent(size_t size, dma_addr_t *dma_handle);
--
2.30.2
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2022-06-14 9:24 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-14 9:15 [PATCH master 1/2] dma: avoid clash between static inline and extern dma_alloc declarations Ahmad Fatoum
2022-06-14 9:15 ` Ahmad Fatoum [this message]
2022-06-17 6:43 ` Sascha Hauer
2022-06-17 6:48 ` Ahmad Fatoum
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=20220614091556.1018102-2-a.fatoum@pengutronix.de \
--to=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.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