From: Marcelo Tosatti <mtosatti@redhat.com>
To: Paul Brook <paul@codesourcery.com>
Cc: "Alberto Treviño" <alberto@byu.edu>, qemu-devel@nongnu.org
Subject: [Qemu-devel] LSI: avoid infinite loops
Date: Wed, 7 May 2008 20:02:06 -0300 [thread overview]
Message-ID: <20080507230206.GB28197@dmt> (raw)
The Windows driver has SCRIPTS code which busy loops on main memory. So
give the CPU's a chance to run if that happens.
Fixes
http://sourceforge.net/tracker/index.php?func=detail&aid=1895893&group_id=180599&atid=893831
Paul, I'm not conviced that a smarter algorithm to determine this
conditions is necessary... perhaps it would be wise to increase the
"200" magic number.
The scsi-disk.c patch in the bugzilla entry has been submitted but ignored.
diff --git a/qemu/hw/lsi53c895a.c b/qemu/hw/lsi53c895a.c
index 72ed5c3..2691418 100644
--- a/qemu/hw/lsi53c895a.c
+++ b/qemu/hw/lsi53c895a.c
@@ -840,9 +840,11 @@ static void lsi_execute_script(LSIState *s)
uint32_t insn;
uint32_t addr;
int opcode;
+ int insns_processed = 0;
s->istat1 |= LSI_ISTAT1_SRUN;
again:
+ insns_processed++;
insn = read_dword(s, s->dsp);
addr = read_dword(s, s->dsp + 4);
DPRINTF("SCRIPTS dsp=%08x opcode %08x arg %08x\n", s->dsp, insn, addr);
@@ -1197,8 +1199,13 @@ again:
}
}
}
- /* ??? Need to avoid infinite loops. */
- if (s->istat1 & LSI_ISTAT1_SRUN && !s->waiting) {
+ /*
+ * The Windows driver downloads SCRIPT code which busy loops
+ * on main memory, so give the CPU's a chance to run if that
+ * happens.
+ */
+ if (insns_processed < 200 && s->istat1 & LSI_ISTAT1_SRUN &&
+ !s->waiting) {
if (s->dcntl & LSI_DCNTL_SSM) {
lsi_script_dma_interrupt(s, LSI_DSTAT_SSI);
} else {
next reply other threads:[~2008-05-07 23:03 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-05-07 23:02 Marcelo Tosatti [this message]
2008-05-07 23:21 ` [Qemu-devel] Re: LSI: avoid infinite loops Paul Brook
2008-05-07 23:42 ` Marcelo Tosatti
2008-05-08 0:39 ` Paul Brook
2008-05-08 0:52 ` Paul Brook
2008-05-08 3:13 ` Marcelo Tosatti
2008-06-19 21:53 ` Marcelo Tosatti
2008-06-19 22:33 ` Paul Brook
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=20080507230206.GB28197@dmt \
--to=mtosatti@redhat.com \
--cc=alberto@byu.edu \
--cc=paul@codesourcery.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).