[PATCH v2 03/11] dma: introduce CONFIG_OF_DMA_COHERENCY
Ahmad Fatoum
a.fatoum at pengutronix.de
Wed Jan 10 08:01:05 PST 2024
Some architectures are either exclusively cache-coherent or not, but
some others can have only some devices that snoop the bus, while the
rest doesn't. This information can be encoded in the device tree, but
we don't want to look this up in the device tree for the vast majority
of platforms that are either completely coherent or aren't.
Therefore provide a new CONFIG_OF_DMA_COHERENCY symbol for selections
by platforms that require this functionality.
Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
v1 -> v2:
- make of_dma_is_coherent DT walking dependent on
CONFIG_OF_DMA_COHERENCY
---
drivers/dma/Kconfig | 10 ++++++++++
drivers/of/platform.c | 14 ++++++++------
2 files changed, 18 insertions(+), 6 deletions(-)
diff --git a/drivers/dma/Kconfig b/drivers/dma/Kconfig
index 46b9b90d8231..635b11c7af7d 100644
--- a/drivers/dma/Kconfig
+++ b/drivers/dma/Kconfig
@@ -7,4 +7,14 @@ config MXS_APBH_DMA
select STMP_DEVICE
help
Experimental!
+
+config OF_DMA_COHERENCY
+ bool "Respect device tree DMA coherency settings" if COMPILE_TEST
+ depends on HAS_DMA && OFDEVICE
+ help
+ For most platforms supported, either all DMA is coherent or it isn't.
+ Platforms that have DMA masters of mixed coherency or that differ
+ from the architecture default will select this option to parse
+ DMA coherency out of the DT.
+
endmenu
diff --git a/drivers/of/platform.c b/drivers/of/platform.c
index dc6c53b7163b..edfeb192d434 100644
--- a/drivers/of/platform.c
+++ b/drivers/of/platform.c
@@ -101,12 +101,14 @@ static struct device_node *of_get_next_dma_parent(const struct device_node *np)
*/
bool of_dma_is_coherent(struct device_node *node)
{
- while (node) {
- if (of_property_read_bool(node, "dma-coherent"))
- return true;
- if (of_property_read_bool(node, "dma-noncoherent"))
- return false;
- node = of_get_next_dma_parent(node);
+ if (IS_ENABLED(CONFIG_OF_DMA_COHERENCY)) {
+ while (node) {
+ if (of_property_read_bool(node, "dma-coherent"))
+ return true;
+ if (of_property_read_bool(node, "dma-noncoherent"))
+ return false;
+ node = of_get_next_dma_parent(node);
+ }
}
return IS_ENABLED(CONFIG_ARCH_DMA_DEFAULT_COHERENT);
--
2.39.2
More information about the barebox
mailing list