[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 4/4] Reallocate dma buffers in read/write path if ne
From: |
Ryan Harper |
Subject: |
[Qemu-devel] [PATCH 4/4] Reallocate dma buffers in read/write path if needed |
Date: |
Fri, 3 Oct 2008 17:05:31 -0500 |
The default buffer size breaks up larger read/write requests unnecessarily.
When we encounter requests larger than the default dma buffer, reallocate the
buffer to support the request.
Signed-off-by: Ryan Harper <address@hidden>
diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c
index f2b4814..a94f10a 100644
--- a/hw/scsi-disk.c
+++ b/hw/scsi-disk.c
@@ -192,10 +192,14 @@ static void scsi_read_data(SCSIDevice *d, uint32_t tag)
}
n = r->sector_count;
- if (n > SCSI_DMA_BUF_SIZE / 512)
- n = SCSI_DMA_BUF_SIZE / 512;
-
r->buf_len = n * 512;
+
+ /* if the request is larger than the default, allocate a larger buffer */
+ if (r->buf_len > SCSI_DMA_BUF_SIZE) {
+ qemu_free(r->dma_buf);
+ r->dma_buf = qemu_memalign(512, r->buf_len);
+ }
+
r->aiocb = bdrv_aio_read(s->bdrv, r->sector, r->dma_buf, n,
scsi_read_complete, r);
if (r->aiocb == NULL)
@@ -224,7 +228,7 @@ static int scsi_write_data(SCSIDevice *d, uint32_t tag)
{
SCSIDeviceState *s = d->state;
SCSIRequest *r;
- uint32_t n, len;
+ uint32_t n;
DPRINTF("Write data tag=0x%x\n", tag);
r = scsi_find_request(s, tag);
@@ -243,10 +247,13 @@ static int scsi_write_data(SCSIDevice *d, uint32_t tag)
/* we know the len of the request and with the max size of the scsi buffer,
* we can calculate buf_len needed */
- len = r->sector_count * 512;
- if (len > SCSI_DMA_BUF_SIZE)
- len = SCSI_DMA_BUF_SIZE;
- r->buf_len = len;
+ r->buf_len = r->sector_count * 512;
+
+ /* if the request is larger than the default, allocate a larger buffer */
+ if (r->buf_len > SCSI_DMA_BUF_SIZE) {
+ qemu_free(r->dma_buf);
+ r->dma_buf = qemu_memalign(512, r->buf_len);
+ }
/* number of sectors to submit */
n = r->buf_len / 512;
- [Qemu-devel] [PATCH 0/4] Improve emulated scsi write performance, Ryan Harper, 2008/10/03
- [Qemu-devel] [PATCH 1/4] lsi_queue_command: add dma direction parameter, Ryan Harper, 2008/10/03
- [Qemu-devel] [PATCH 2/4] Refactor lsi_do_command to queue read and write ops, Ryan Harper, 2008/10/03
- [Qemu-devel] [PATCH 3/4] Refactor scsi-disk layer for queue'ing writes, Ryan Harper, 2008/10/03
- [Qemu-devel] [PATCH 4/4] Reallocate dma buffers in read/write path if needed,
Ryan Harper <=
- Re: [Qemu-devel] [PATCH 4/4] Reallocate dma buffers in read/write path if needed, Paul Brook, 2008/10/03
- Re: [Qemu-devel] [PATCH 4/4] Reallocate dma buffers in read/write path if needed, Anthony Liguori, 2008/10/03
- Re: [Qemu-devel] [PATCH 4/4] Reallocate dma buffers in read/write path if needed, Paul Brook, 2008/10/03
- Re: [Qemu-devel] [PATCH 4/4] Reallocate dma buffers in read/write path if needed, Avi Kivity, 2008/10/04
- Message not available
- Re: [Qemu-devel] [PATCH 4/4] Reallocate dma buffers in read/write path if needed, Ryan Harper, 2008/10/04
- Re: [Qemu-devel] [PATCH 4/4] Reallocate dma buffers in read/write path if needed, Anthony Liguori, 2008/10/04
- Re: [Qemu-devel] [PATCH 4/4] Reallocate dma buffers in read/write path if needed, Avi Kivity, 2008/10/05
- Re: [Qemu-devel] [PATCH 4/4] Reallocate dma buffers in read/write path if needed, Ryan Harper, 2008/10/05
- Re: [Qemu-devel] [PATCH 4/4] Reallocate dma buffers in read/write path if needed, Avi Kivity, 2008/10/06
- Re: [Qemu-devel] [PATCH 4/4] Reallocate dma buffers in read/write path if needed, Paul Brook, 2008/10/04