From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JtsfA-00035d-HX for qemu-devel@nongnu.org; Wed, 07 May 2008 19:03:04 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Jtsf8-00035R-0N for qemu-devel@nongnu.org; Wed, 07 May 2008 19:03:03 -0400 Received: from [199.232.76.173] (port=36501 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Jtsf7-00035O-Qi for qemu-devel@nongnu.org; Wed, 07 May 2008 19:03:01 -0400 Received: from mx1.redhat.com ([66.187.233.31]:40998) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Jtsf7-0003hj-9m for qemu-devel@nongnu.org; Wed, 07 May 2008 19:03:01 -0400 Date: Wed, 7 May 2008 20:02:06 -0300 From: Marcelo Tosatti Message-ID: <20080507230206.GB28197@dmt> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Subject: [Qemu-devel] LSI: avoid infinite loops Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paul Brook Cc: Alberto =?iso-8859-1?Q?Trevi=F1o?= , qemu-devel@nongnu.org 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 {