From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1L9lJT-0002SV-Fw for qemu-devel@nongnu.org; Mon, 08 Dec 2008 13:58:35 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1L9lJR-0002RT-Qg for qemu-devel@nongnu.org; Mon, 08 Dec 2008 13:58:34 -0500 Received: from [199.232.76.173] (port=33171 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1L9lJQ-0002RI-PX for qemu-devel@nongnu.org; Mon, 08 Dec 2008 13:58:32 -0500 Received: from e38.co.us.ibm.com ([32.97.110.159]:51021) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1L9lJQ-0008So-72 for qemu-devel@nongnu.org; Mon, 08 Dec 2008 13:58:32 -0500 Received: from d03relay04.boulder.ibm.com (d03relay04.boulder.ibm.com [9.17.195.106]) by e38.co.us.ibm.com (8.13.1/8.13.1) with ESMTP id mB8IvM2Q014647 for ; Mon, 8 Dec 2008 11:57:22 -0700 Received: from d03av01.boulder.ibm.com (d03av01.boulder.ibm.com [9.17.195.167]) by d03relay04.boulder.ibm.com (8.13.8/8.13.8/NCO v9.1) with ESMTP id mB8IwS5K207466 for ; Mon, 8 Dec 2008 11:58:28 -0700 Received: from d03av01.boulder.ibm.com (loopback [127.0.0.1]) by d03av01.boulder.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id mB8IwSoA025586 for ; Mon, 8 Dec 2008 11:58:28 -0700 Date: Mon, 8 Dec 2008 12:58:27 -0600 From: Ryan Harper Subject: Re: [Qemu-devel] [PATCH 3/4] LSI53C895A: Implement TARGET RESET message Message-ID: <20081208185827.GL13481@us.ibm.com> References: <1228759670-31113-1-git-send-email-ryanh@us.ibm.com> <1228759670-31113-4-git-send-email-ryanh@us.ibm.com> <200812081838.23464.paul@codesourcery.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200812081838.23464.paul@codesourcery.com> 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: Ryan Harper , qemu-devel@nongnu.org, kvm@vger.kernel.org * Paul Brook [2008-12-08 12:39]: > On Monday 08 December 2008, Ryan Harper wrote: > > Linux and Windows send a TARGET RESET message to the device when it fails > > to respond as it expects. For example, when it tries to select LUN1, which > > we don't support. This patch is needed to support the Linux sym53c8xx_2 > > driver when configured with SYM_CONF_DMA_ADDRESSING_MODE=2 > > > > Signed-off-by: Ryan Harper > > > > diff --git a/hw/lsi53c895a.c b/hw/lsi53c895a.c > > index b36c08c..ac8c5a5 100644 > > --- a/hw/lsi53c895a.c > > +++ b/hw/lsi53c895a.c > > @@ -804,6 +804,10 @@ static void lsi_do_msgout(LSIState *s) > > goto bad; > > } > > break; > > + case 0x0c: /* TARGET RESET */ > > + DPRINTF("MSG: Target Reset\n"); > > + lsi_soft_reset(s); > > + break; > > case 0x20: /* SIMPLE queue */ > > s->current_tag |= lsi_get_msgbyte(s) | LSI_TAG_VALID; > > DPRINTF("SIMPLE queue tag=0x%x\n", s->current_tag & 0xff); > > This looks wrong. The clue is in the name. This should reset the *target* > device (i.e. the disk) not the host adapter. > > Probably also explains why you need the bogus 4th patch. The target reset can go away, but we still need the 4th patch. The linux driver does bus resets after failing to probe LUNs we don't support. I first noticed that we fail with a Reselect with pending DMA: [ 49.438690] sd 2:0:0:0: Attached scsi generic sg1 type 0 [ 49.444504] sym0: SCSI BUS reset detected. [ 49.459818] sym0: SCSI BUS has been reset. [ 52.850722] sym0: SCSI BUS reset detected. [ 52.866301] sym0: SCSI BUS has been reset. [ 56.358587] sym0: SCSI BUS reset detected. [ 56.374131] sym0: SCSI BUS has been reset. [ 59.858698] sym0: SCSI BUS reset detected. [ 59.875703] sym0: SCSI BUS has been reset. [ 63.362570] sym0: SCSI BUS reset detected. lsi_scsi: error: Reselect with pending DMA [ 63.378562] sym0: SCSI BUS has been reset. [ 63.381405] BUG: unable to handle kernel NULL pointer dereference at 0000000000000358 [ 63.385283] IP: [] sym_int_sir+0x679/0x1500 [sym53c8xx] Which I figured was because lsi_soft_reset doesn't initialize current_dma_len. I added current_dma_len to soft_reset and now we can probe with out failing, and existing partitions on the device show up, but any further use of the device results in broken behavior. root@vm1:~# cat /proc/partitions major minor #blocks name 254 0 10485760 vda 254 1 9992398 vda1 254 2 1 vda2 254 5 489951 vda5 8 0 52449280 sda 8 1 10241406 sda1 root@vm1:~# fdisk -l /dev/sda Disk /dev/sda: 53.7 GB, 53708062720 bytes 64 heads, 32 sectors/track, 51220 cylinders Units = cylinders of 2048 * 512 = 1048576 bytes Disk identifier: 0x00000000 Disk /dev/sda doesn't contain a valid partition table Because the driver is issueing bus resets, we're clobbering the scratch registers. So, to summarize, I'll drop the TARGET RESET patch since it is completely wrong, but we still need the quirk patch. -- Ryan Harper Software Engineer; Linux Technology Center IBM Corp., Austin, Tx ryanh@us.ibm.com