@@ -27,6 +27,7 @@
#include <linux/vmalloc.h>
#include <linux/swiotlb.h>
#include <linux/amba/bus.h>
+#include <linux/acpi.h>
#include <asm/cacheflush.h>
@@ -319,6 +320,21 @@ static int dma_bus_notifier(struct notifier_block *nb,
if (of_property_read_bool(dev->of_node, "dma-coherent"))
set_dma_ops(dev, &coherent_swiotlb_dma_ops);
+#ifdef CONFIG_ACPI
+ if (ACPI_HANDLE(dev)) {
+ acpi_status status;
+ int coherent;
+
+ /*
+ * Kernel defaults to noncoherent ops but ACPI 5.1 spec says arm64
+ * defaults to coherent. Set coherent ops if _CCA not found or _CCA
+ * found and non-zero.
+ */
+ status = acpi_check_coherency(ACPI_HANDLE(dev), &coherent);
+ if (ACPI_FAILURE(status) || coherent)
+ set_dma_ops(dev, &coherent_swiotlb_dma_ops);
+ }
+#endif
return NOTIFY_OK;
}