From 0bcf55800fb3d3baf41c9681c067153a4b3742ce Mon Sep 17 00:00:00 2001 From: Norman Feske Date: Mon, 26 Nov 2012 09:36:57 +0100 Subject: [PATCH] Eagerly map DMA buffers This patch is a work-around for issue #452. --- os/include/os/attached_ram_dataspace.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/os/include/os/attached_ram_dataspace.h b/os/include/os/attached_ram_dataspace.h index 9ac439e919..f93db613d0 100644 --- a/os/include/os/attached_ram_dataspace.h +++ b/os/include/os/attached_ram_dataspace.h @@ -22,6 +22,7 @@ #define _INCLUDE__OS__ATTACHED_RAM_DATASPACE_H_ #include +#include #include namespace Genode { @@ -61,6 +62,23 @@ namespace Genode { _ram_session->free(_ds); throw; } + + /* + * Eagerly map dataspace if used for DMA + * + * On some platforms, namely Fiasco.OC on ARMv7, the handling + * of page faults interferes with the caching attributes used + * for uncached DMA memory. See issue #452 for more details + * (https://github.com/genodelabs/genode/issues/452). As a + * work-around for this issues, we eagerly map the whole + * dataspace before writing actual content to it. + */ + if (!_cached) { + enum { PAGE_SIZE = 4096 }; + unsigned char volatile *base = (unsigned char volatile *)_local_addr; + for (size_t i = 0; i < _size; i += PAGE_SIZE) + touch_read_write(base + i); + } } public: