From b328324d193489665fecc90a7425fa921d98bd12 Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Fri, 8 Aug 2008 23:15:21 +0000 Subject: [PATCH] DMAResource::TranslateNext(), in case of given physical vecs: * segmentCount was potentially set incorrectly. It could be too big, since we considered all vecs, not only those remaining. * The main loop condition was incorrect. This would lead to too few DMABuffer vecs (or none at all) for any but the first IOOperation of a request. Should fix #2586. * Correctly offset by vecIndex in debug output. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26881 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/system/kernel/device_manager/dma_resources.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/system/kernel/device_manager/dma_resources.cpp b/src/system/kernel/device_manager/dma_resources.cpp index 32fa7842ff..2526210b67 100644 --- a/src/system/kernel/device_manager/dma_resources.cpp +++ b/src/system/kernel/device_manager/dma_resources.cpp @@ -444,14 +444,15 @@ DMAResource::TranslateNext(IORequest* request, IOOperation* operation) // We do already have physical addresses. locker.Unlock(); vecs = buffer->Vecs(); - segmentCount = min_c(buffer->VecCount(), + segmentCount = min_c(buffer->VecCount() - vecIndex, fRestrictions.max_segment_count); } #ifdef TRACE_DMA_RESOURCE TRACE(" physical count %lu\n", segmentCount); for (uint32 i = 0; i < segmentCount; i++) { - TRACE(" [%lu] %p, %lu\n", i, vecs[i].iov_base, vecs[i].iov_len); + TRACE(" [%lu] %p, %lu\n", i, vecs[vecIndex + i].iov_base, + vecs[vecIndex + i].iov_len); } #endif @@ -488,7 +489,7 @@ DMAResource::TranslateNext(IORequest* request, IOOperation* operation) "%lu\n", offset, length); } - for (uint32 i = vecIndex; i < segmentCount;) { + for (uint32 i = vecIndex; i < vecIndex + segmentCount;) { if (dmaBuffer->VecCount() >= fRestrictions.max_segment_count) break;