From ff7cf84b895ee1f54fca47e1b9325b563a36174c Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Thu, 22 Nov 2007 00:40:40 +0000 Subject: [PATCH] In case of writing a partial block, the complete block is first read into a buffer. The size of the S/G list for that buffer is now temporarily set to the block size for the read request. This works around the problem that the IDE bus manager would erroneously request DMA for the complete buffer (32 KB), but issue a read request only for one block, thus, after a few timeouts and bus resets, needing to resort to PIO mode. Fixes bugs #985 and #1176. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22975 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/add-ons/kernel/generic/block_io/io.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/add-ons/kernel/generic/block_io/io.c b/src/add-ons/kernel/generic/block_io/io.c index 749a76b800..b53e77efeb 100644 --- a/src/add-ons/kernel/generic/block_io/io.c +++ b/src/add-ons/kernel/generic/block_io/io.c @@ -383,9 +383,18 @@ retry: cur_blocks = 1; SHOW_FLOW0(3, "partial write at beginning: reading content of first block"); + + // temporarily restrict the buffer's S/G list size to how much + // we actually want to read + block_io_buffer_phys_vec.total_len = block_size; + block_io_buffer_phys_vec.vec[0].size = block_size; + res = device->interface->read(handle->cookie, &block_io_buffer_phys_vec, block_pos, cur_blocks, block_size, &bytes_transferred); + + block_io_buffer_phys_vec.total_len = block_io_buffer_size; + block_io_buffer_phys_vec.vec[0].size = block_io_buffer_size; } else { // alignment problem or partial block read - find out how many // blocks are spanned by this transfer