Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JU8hX-0007TZ-Ie for qemu-devel@nongnu.org; Tue, 26 Feb 2008 17:55:07 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JU8hW-0007T5-RA for qemu-devel@nongnu.org; Tue, 26 Feb 2008 17:55:07 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JU8hW-0007T0-Ja for qemu-devel@nongnu.org; Tue, 26 Feb 2008 17:55:06 -0500 Received: from main.gmane.org ([80.91.229.2] helo=ciao.gmane.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1JU8hW-0005pi-4P for qemu-devel@nongnu.org; Tue, 26 Feb 2008 17:55:06 -0500 Received: from root by ciao.gmane.org with local (Exim 4.43) id 1JU8hS-0005A4-UV for qemu-devel@nongnu.org; Tue, 26 Feb 2008 22:55:02 +0000 Received: from 79-76-70-181.dynamic.dsl.as9105.com ([79.76.70.181]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 26 Feb 2008 22:55:02 +0000 Received: from bacam by 79-76-70-181.dynamic.dsl.as9105.com with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 26 Feb 2008 22:55:02 +0000 From: Brian Campbell Date: Tue, 26 Feb 2008 22:36:25 +0000 Message-ID: <87mypn73bq.fsf@misnomer.z273.org.uk> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Sender: news Subject: [Qemu-devel] Hanging when using hw/lsi53c895a.c Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org --=-=-= When using qemu-system-arm from CVS or 0.9.1 I've noticed that the emulator locks up occasionally on heavy disk access. Forcing a fsck on start up is normally enough to trigger it. The root cause is that scsi_read_data can be reentered before updating sector and sector_count: lsi_do_dma calls scsi_read_data, which calls scsi_read_complete, lsi_command_complete, lsi_do_dma, scsi_read_data without updating sector and sector_count, and so on... This results in an unending series of reads: scsi-disk: Command: lun=0 tag=0x10049 data=0x28 0x00 0x00 0x24 0x24 0x97 0x00 0x00 0x90 0x00 scsi-disk: Read (sector 2368663, count 144) scsi-disk: Read tag=0x10049 sector_count=144 scsi-disk: Data ready tag=0x10049 len=65536 scsi-disk: Read tag=0x10049 sector_count=16 scsi-disk: Data ready tag=0x10049 len=8192 scsi-disk: Read tag=0x10049 sector_count=16 scsi-disk: Data ready tag=0x10049 len=8192 scsi-disk: Read tag=0x10049 sector_count=-16 scsi-disk: Data ready tag=0x10049 len=65536 scsi-disk: Read tag=0x10049 sector_count=-144 scsi-disk: Data ready tag=0x10049 len=65536 scsi-disk: Read tag=0x10049 sector_count=-272 scsi-disk: Data ready tag=0x10049 len=65536 The attached patch ensures that the scsi_read_complete call occurs at the end on scsi_read_data. I'm not sure if this is how it was intended to work -- an alternative would be to prevent lsi_command_complete calling lsi_do_dma. But the patch does prevent the hanging. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=qemu-hang.patch Content-Description: Prevent lsi emulation hanging Index: hw/scsi-disk.c =================================================================== RCS file: /sources/qemu/qemu/hw/scsi-disk.c,v retrieving revision 1.20 diff -u -r1.20 scsi-disk.c --- hw/scsi-disk.c 3 Feb 2008 04:05:50 -0000 1.20 +++ hw/scsi-disk.c 26 Feb 2008 22:31:03 -0000 @@ -171,6 +171,7 @@ SCSIDeviceState *s = d->state; SCSIRequest *r; uint32_t n; + int sector; r = scsi_find_request(s, tag); if (!r) { @@ -191,17 +192,19 @@ return; } + sector = r->sector; + n = r->sector_count; if (n > SCSI_DMA_BUF_SIZE / 512) n = SCSI_DMA_BUF_SIZE / 512; + r->sector += n; + r->sector_count -= n; r->buf_len = n * 512; - r->aiocb = bdrv_aio_read(s->bdrv, r->sector, r->dma_buf, n, + r->aiocb = bdrv_aio_read(s->bdrv, sector, r->dma_buf, n, scsi_read_complete, r); if (r->aiocb == NULL) scsi_command_complete(r, SENSE_HARDWARE_ERROR); - r->sector += n; - r->sector_count -= n; } static void scsi_write_complete(void * opaque, int ret) --=-=-= Brian --=-=-=--