From: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
To: "qemu-devel@nongnu.org" <qemu-devel@nongnu.org>
Subject: [Qemu-devel] [PATCH] honor IDE_DMA_BUF_SECTORS
Date: Wed, 25 Mar 2009 13:45:53 +0000 [thread overview]
Message-ID: <49CA3591.1010309@eu.citrix.com> (raw)
Hi all,
after the recent introduction of dma_buf_prepare we stopped honoring
IDE_DMA_BUF_SECTORS (the guest can issue dma requests with a greater
total length than IDE_DMA_BUF_SECTORS).
This patch adds the IDE_DMA_BUF_SECTORS limit back in place.
Comments are welcome.
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
---
diff --git a/hw/ide.c b/hw/ide.c
index 96bc176..ef1356d 100644
--- a/hw/ide.c
+++ b/hw/ide.c
@@ -207,6 +207,7 @@
#define MAX_MULT_SECTORS 16
#define IDE_DMA_BUF_SECTORS 256
+#define IDE_DMA_BUF_BYTES (IDE_DMA_BUF_SECTORS * 512)
#if (IDE_DMA_BUF_SECTORS < MAX_MULT_SECTORS)
#error "IDE_DMA_BUF_SECTORS must be bigger or equal to MAX_MULT_SECTORS"
@@ -877,9 +878,10 @@ static int dma_buf_prepare(BMDMAState *bm, int is_write)
uint32_t addr;
uint32_t size;
} prd;
- int l, len;
+ int l, len, n;
- qemu_sglist_init(&s->sg, s->nsector / (TARGET_PAGE_SIZE/512) + 1);
+ n = s->nsector <= IDE_DMA_BUF_SECTORS ? s->nsector : IDE_DMA_BUF_SECTORS;
+ qemu_sglist_init(&s->sg, n / (TARGET_PAGE_SIZE/512) + 1);
s->io_buffer_size = 0;
for(;;) {
if (bm->cur_prd_len == 0) {
@@ -900,6 +902,13 @@ static int dma_buf_prepare(BMDMAState *bm, int is_write)
}
l = bm->cur_prd_len;
if (l > 0) {
+ if (l > IDE_DMA_BUF_BYTES)
+ l = IDE_DMA_BUF_BYTES;
+ if (s->io_buffer_size + l > IDE_DMA_BUF_BYTES) {
+ l = IDE_DMA_BUF_BYTES - s->io_buffer_size;
+ if (!l)
+ return s->io_buffer_size != 0;
+ }
qemu_sglist_add(&s->sg, bm->cur_prd_addr, l);
bm->cur_prd_addr += l;
bm->cur_prd_len -= l;
next reply other threads:[~2009-03-25 13:52 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-25 13:45 Stefano Stabellini [this message]
2009-03-25 15:22 ` [Qemu-devel] [PATCH] honor IDE_DMA_BUF_SECTORS Avi Kivity
2009-03-25 16:19 ` Stefano Stabellini
2009-03-25 16:45 ` Avi Kivity
2009-03-25 16:50 ` Stefano Stabellini
2009-03-25 17:47 ` Stefano Stabellini
2009-03-26 10:23 ` Avi Kivity
2009-03-26 10:31 ` Stefano Stabellini
2009-03-26 10:57 ` Avi Kivity
2009-03-26 11:45 ` Stefano Stabellini
2009-03-26 12:10 ` Avi Kivity
2009-03-26 12:28 ` Stefano Stabellini
2009-03-26 12:47 ` Samuel Thibault
2009-03-26 12:58 ` Avi Kivity
2009-03-26 15:30 ` Samuel Thibault
2009-03-26 18:32 ` Avi Kivity
2009-03-26 18:48 ` Samuel Thibault
2009-03-26 19:40 ` Avi Kivity
2009-03-26 23:18 ` Samuel Thibault
2009-03-27 9:52 ` Avi Kivity
2009-03-27 10:32 ` Samuel Thibault
2009-03-27 10:53 ` Avi Kivity
2009-03-27 13:45 ` Samuel Thibault
2009-03-26 22:42 ` Christoph Hellwig
2009-03-26 23:22 ` Samuel Thibault
2009-03-27 10:02 ` Avi Kivity
2009-03-27 10:36 ` Samuel Thibault
2009-03-27 10:58 ` Avi Kivity
2009-03-25 16:46 ` Samuel Thibault
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=49CA3591.1010309@eu.citrix.com \
--to=stefano.stabellini@eu.citrix.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.