From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39998) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XntlR-0004Hb-Sv for qemu-devel@nongnu.org; Mon, 10 Nov 2014 13:32:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XntlM-0004xE-8W for qemu-devel@nongnu.org; Mon, 10 Nov 2014 13:32:33 -0500 Received: from mail-wg0-x22b.google.com ([2a00:1450:400c:c00::22b]:59891) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XntlM-0004wv-2C for qemu-devel@nongnu.org; Mon, 10 Nov 2014 13:32:28 -0500 Received: by mail-wg0-f43.google.com with SMTP id y10so9760689wgg.16 for ; Mon, 10 Nov 2014 10:32:24 -0800 (PST) Sender: Paolo Bonzini Message-ID: <546104B3.6020707@redhat.com> Date: Mon, 10 Nov 2014 19:32:19 +0100 From: Paolo Bonzini MIME-Version: 1.0 References: <1415634775-4288-1-git-send-email-hare@suse.de> In-Reply-To: <1415634775-4288-1-git-send-email-hare@suse.de> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCHv2] esp: Do not overwrite ESP_TCHI after reset List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Hannes Reinecke Cc: qemu-devel@nongnu.org On 10/11/2014 16:52, Hannes Reinecke wrote: > After a reset ESP_TCHI should contain the unique ID > of the chip. This value will be overwritten with the > current tranfer count if the transfer count has > previously been set. > So we should always return the chip id if ESP_TCHI > has never been written to. What if ESP_TCHI was written 0? Why should it return the chip id? Can you explain exactly what sequence of register reads/writes leads to the bug? Paolo > Signed-off-by: Hannes Reinecke > --- > hw/scsi/esp.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c > index 5ab44d8..2caac1c 100644 > --- a/hw/scsi/esp.c > +++ b/hw/scsi/esp.c > @@ -364,7 +364,6 @@ void esp_hard_reset(ESPState *s) > { > memset(s->rregs, 0, ESP_REGS); > memset(s->wregs, 0, ESP_REGS); > - s->rregs[ESP_TCHI] = s->chip_id; > s->ti_size = 0; > s->ti_rptr = 0; > s->ti_wptr = 0; > @@ -422,6 +421,11 @@ uint64_t esp_reg_read(ESPState *s, uint32_t saddr) > esp_lower_irq(s); > > return old_val; > + case ESP_TCHI: > + /* Return the unique id if the value has never been written */ > + if (!s->wregs[ESP_TCHI]) { > + return s->chip_id; > + } > default: > break; > } >