esp.c fast SCSI-bus reset
PATCH 1/1 esp.c fast SCSI-bus reset
It seems to make a little sense to raise an interrupt still having "bus reset" status, since it makes the host think the bus is busy. The proper way would be to tell all the scsi devices to reset before the interrupt.
The patch makes scsi probe to come a little further when using OBP under sparc32.
esp.c 2009-07-24 12:08:48.585546871 +0200 renamed from esp.c.master 2009-07-24 00:28:30.146422134 +0200 +1 -1
@@ -505,7 +505,7 @@ break; case CMD_BUSRESET: DPRINTF("Bus reset (%2.2x)\n", val); - s->rregs[ESP_RINTR] = INTR_RST; + s->rregs[ESP_RINTR] = 0; if (!(s->wregs[ESP_CFG1] & CFG1_RESREPT)) { esp_raise_irq(s); }
Quoted 6 lines · Artyom Tarasenko
It seems to make a little sense to raise an interrupt still having "bus reset" status, since it makes the host think the bus is busy. The proper way would be to tell all the scsi devices to reset before the interrupt.
The patch makes scsi probe to come a little further when using OBP under sparc32.
Unfortunately it also makes BSDs think that the bus reset hasn't happened:
OpenBSD 4.3 (RAMDISK) #415: Tue Mar 11 18:31:57 MDT 2008
[email protected]:/usr/src/sys/arch/sparc/compile/RAMDISK
[clip]
esp0 at dma0 offset 0x8800000 pri 4: ESP200, 40MHz, SCSI ID 7 scsibus0 at esp0: 8 targets
esp0: waiting for SCSI Bus Reset to happen
probe(esp0:0:0): esp0: timed out [ecb 0xf9c2d000 (flags 0x3, dleft 24, stat 0)], <state 9, nexus 0x0, phase(l 0, c 0, p 101), resid 0, msg(q 0,o 0) >
probe(esp0:0:0): esp0: timed out [ecb 0xf9c2d000 (flags 0x43, dleft 24, stat 0)], <state 9, nexus 0x0, phase(l 0, c 0, p 101), resid 0, msg(q 0,o 0) > AGAIN
esp0: waiting for SCSI Bus Reset to happen
NetBSD just hangs:
NetBSD 4.0 (INSTALL) #0: Sun Dec 16 02:32:37 PST 2007
builds@wb29:/home/builds/ab/netbsd-4-0-RELEASE/sparc/200712160005Z-obj/home/builds/ab/netbsd-4-0-RELEASE/src/sys/arch/sparc/compile/INSTALL
[clip]
esp0 at dma0 slot 5 offset 0x8800000 level 4: ESP200, 40MHz, SCSI ID 7 scsibus0 at esp0: 8 targets, 8 luns per target
ledma0 at sbus0 slot 5 offset 0x8400010: DMA rev 2
le0 at ledma0 slot 5 offset 0x8c00000 level 6: address 52:54:00:12:34:56
le0: 8 receive buffers, 2 transmit buffers
SUNW,CS4231 at sbus0 slot 4 offset 0xc000000 level 5 (ipl 9) not configured power-management at sbus0 slot 4 offset 0xa000000 not configured
esp0: waiting for SCSI Bus Reset to happen
timecounter: Timecounter "clockinterrupt" frequency 100 Hz quality 0
md0: internal 688 KB image area
scsibus0: waiting 2 seconds for devices to settle...
Linux is not affected.
Quoted 1 line
Unfortunately it also makes BSDs think that the bus reset hasn't happened:
How about this one? Seems to be fine with NetBSD. Not "fast" though, emulates more precisely what would happen on a real hw.
hw/esp.c 2009-07-28 20:08:15.683543101 +0200 renamed from hw/esp.c.master 2009-07-28 19:42:24.161417594 +0200 +5 -0
@@ -448,6 +448,11 @@ // Clear interrupt/error status bits s->rregs[ESP_RSTAT] &= ~(STAT_GE | STAT_PE); esp_lower_irq(s); + // Clear bus reset + if(INTR_RST==s->rregs[ESP_RINTR]) { + s->rregs[ESP_RINTR] = 0; + return INTR_RST; + } break;
default:
break;Quoted 5 lines · Artyom Tarasenko
Quoted 1 line
Unfortunately it also makes BSDs think that the bus reset hasn't happened:
How about this one? Seems to be fine with NetBSD. Not "fast" though, emulates more precisely what would happen on a real hw.
Thanks, but I read the interrupt register part of the data sheet again, and it looks like the current implementation was not correct at all.
This patch clears interrupt, sequence and status registers like the data sheet specifies and also passes my tests, does it help with yours?
In the future, please add a Signed-off-by line. The coding style (indentation, spaces between tokens) did not match rest of QEMU and expression order should be like x == 1, not 1 == x.
From 2814df28efc184dd327e15a2bb75119c1ef19564 Mon Sep 17 00:00:00 2001
From: Blue Swirl <[email protected]>
Date: Fri, 31 Jul 2009 07:26:44 +0000
Subject: [PATCH] esp: fix interrupt register read
Read of interrupt register should clear it and also sequence step and status.
--- hw/esp.c | 13 +++++++++---- 1 files changed, 9 insertions(+), 4 deletions(-)
hw/esp.c +9 -4
@@ -422,7 +422,7 @@ static void parent_esp_reset(void *opaque, int irq, int level)static uint32_t esp_mem_readb (void *opaque,target_phys_addr_t addr) {ESPState *s = opaque; -uint32_t saddr; +uint32_t saddr, old_val; saddr = addr >> s->it_shift;DPRINTF ("read reg[%d]: 0x%2.2x\n" , saddr, s->rregs[saddr]);
@@ -445,10 +445,15 @@ static uint32_t esp_mem_readb(void *opaque, target_phys_addr_t addr) }break ;case ESP_RINTR : -// Clear interrupt/error status bits - s->rregs[ESP_RSTAT ] &= ~(STAT_GE |STAT_PE ); +/* Clear sequence step, interrupt register and all status bits +except TC */ + old_val = s->rregs[ESP_RINTR ]; + s->rregs[ESP_RINTR ] =0 ; + s->rregs[ESP_RSTAT ] &= ~STAT_TC ; + s->rregs[ESP_RSEQ ] =SEQ_CD ;esp_lower_irq (s); -break ; + +return old_val;default :break ; }
Signature · 1 line
1.5.6.5
Quoted 3 lines
This patch clears interrupt, sequence and status registers like the data sheet specifies and also passes my tests, does it help with yours?
Looks good, thanks.