From f3bd145c0942c6971e5fd89bb17a75541366f62a Mon Sep 17 00:00:00 2001 From: Michael Lotz Date: Sat, 10 Oct 2009 19:55:13 +0000 Subject: [PATCH] When the need for physical to virtual mapping arises because of emulating IO reads or writes for old style drivers, map the physical memory at once. Since USB is pretty much the only one affected and there small reads/writes are exponentially slower, the performance gain of the burst transfer far outweighs the additional overhead of the mapping. Still this could be further optimized and will eventually be superseeded by also providing a physical memory API in USB. For now it should bring back USB reads to an acceptable level. Writes are still page wise though because of how writing back memory works in general. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33503 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/system/kernel/fs/vfs_request_io.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/system/kernel/fs/vfs_request_io.cpp b/src/system/kernel/fs/vfs_request_io.cpp index 616e835b6d..0bf0609b69 100644 --- a/src/system/kernel/fs/vfs_request_io.cpp +++ b/src/system/kernel/fs/vfs_request_io.cpp @@ -89,6 +89,24 @@ public: addr_t buffer = (addr_t)_buffer; size_t length = *_length; + if (length > B_PAGE_SIZE) { + // try to not split up the request if possible + // TODO: map with less overhead! pre-reserved address space + // could be used as a scratch space for example, directly mapping + // pages into that instead of creating new areas for each request + void* virtualAddress; + area_id mapArea = map_physical_memory("physical io request map", + (void*)buffer, length, B_ANY_ADDRESS, B_KERNEL_READ_AREA + | B_KERNEL_WRITE_AREA, &virtualAddress); + if (mapArea >= 0) { + status_t result = InternalIO(offset, virtualAddress, _length); + delete_area(mapArea); + return result; + } + + // otherwise we fall back to page wise mapping + } + while (length > 0) { addr_t pageOffset = buffer % B_PAGE_SIZE; addr_t virtualAddress;