From patchwork Mon Jun 14 16:41:29 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 55566 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 73324B7D8B for ; Tue, 15 Jun 2010 02:44:14 +1000 (EST) Received: from localhost ([127.0.0.1]:42529 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OOClf-0006mC-7M for incoming@patchwork.ozlabs.org; Mon, 14 Jun 2010 12:44:11 -0400 Received: from [140.186.70.92] (port=37957 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OOCjF-0005yJ-Md for qemu-devel@nongnu.org; Mon, 14 Jun 2010 12:41:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OOCjD-000581-E6 for qemu-devel@nongnu.org; Mon, 14 Jun 2010 12:41:41 -0400 Received: from mail-wy0-f173.google.com ([74.125.82.173]:42340) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OOCjD-00057p-AE for qemu-devel@nongnu.org; Mon, 14 Jun 2010 12:41:39 -0400 Received: by wyb36 with SMTP id 36so4413397wyb.4 for ; Mon, 14 Jun 2010 09:41:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:sender:from:to:subject:date :message-id:x-mailer; bh=67n2ybEoQibJzWHHZ9S3jC/nVDlYwpChIAe9dfTU05k=; b=TRoTwxJOyRAjyuZREietxZdD4DhpTBDLndfUp3scg7VInAtscj57FUxReNEZNvuPwo C0Q25DMirRBxpkaIynbdSVGvgw9vQ7ZhA8V6oca1CZHXTCiLDrFBQucMCkRtQDIf5+Nb Z4OoKsSloDr3m1Ivxth0RQ0w4CJXDPNoaAdZQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:from:to:subject:date:message-id:x-mailer; b=w75cdHO00Kc0CNcd5nhHs+qbq08ndn+T2U+qpzB4oTu/B77g0+NaNTDXrpnKFPRgqV YuXGAIG3ZDaMASTFa57+a7t3Of9pRPGeN047oqopxUrBgNgQ3HCfIzjM70HAl1alEVv0 8bxxcAYia+/WuDf9crSf5IJgou0M1n/lyqTSU= Received: by 10.227.142.210 with SMTP id r18mr5933881wbu.81.1276533698434; Mon, 14 Jun 2010 09:41:38 -0700 (PDT) Received: from localhost.localdomain (nat-pool-brq-t.redhat.com [209.132.186.34]) by mx.google.com with ESMTPS id n31sm9614834wba.9.2010.06.14.09.41.34 (version=TLSv1/SSLv3 cipher=RC4-MD5); Mon, 14 Jun 2010 09:41:35 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 14 Jun 2010 18:41:29 +0200 Message-Id: <1276533689-16293-1-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.7.0.1 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) Subject: [Qemu-devel] [PATCH] lsi53c895a: fix Phase Mismatch Jump X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org lsi_bad_phase has a bug in the choice of pmjad1/pmjad2. This does not matter with Linux guests because it uses just one routine for both, but it breaks Windows 64-bit guests. This is the text from the spec: "[The PMJCTL] bit controls which decision mechanism is used when jumping on phase mismatch. When this bit is cleared the LSI53C895A will use Phase Mismatch Jump Address 1 (PMJAD1) when the WSR bit is cleared and Phase Mismatch Jump Address 2 (PMJAD2) when the WSR bit is set. When this bit is set the LSI53C895A will use jump address one (PMJAD1) on data out (data out, command, message out) transfers and jump address two (PMJAD2) on data in (data in, status, message in) transfers." Which means: CCNTL0.PMJCTL 0 SCNTL2.WSR = 0 PMJAD1 0 SCNTL2.WSR = 1 PMJAD2 1 out PMJAD1 1 in PMJAD2 In qemu, what you get instead is: CCNTL0.PMJCTL 0 out PMJAD1 0 in PMJAD2 <<<<< 1 out PMJAD1 1 in PMJAD1 <<<<< Considering that qemu always has SCNTL2.WSR cleared, the two marked cases (corresponding to phase mismatch on input) are always jumping to the wrong PMJAD register. The patch implements the correct semantics. Signed-off-by: Paolo Bonzini --- hw/lsi53c895a.c | 12 +++++++++--- 1 files changed, 9 insertions(+), 3 deletions(-) diff --git a/hw/lsi53c895a.c b/hw/lsi53c895a.c index f5a91ba..00df2bd 100644 --- a/hw/lsi53c895a.c +++ b/hw/lsi53c895a.c @@ -490,11 +490,14 @@ static void lsi_bad_phase(LSIState *s, int out, int new_phase) { /* Trigger a phase mismatch. */ if (s->ccntl0 & LSI_CCNTL0_ENPMJ) { - if ((s->ccntl0 & LSI_CCNTL0_PMJCTL) || out) { - s->dsp = s->pmjad1; + int dest; + if ((s->ccntl0 & LSI_CCNTL0_PMJCTL)) { + dest = out ? 1 : 2; } else { - s->dsp = s->pmjad2; + dest = (s->scntl2 & LSI_SCNTL2_WSR ? 2 : 1); } + + s->dsp = (dest == 1) ? s->pmjad1 : s->pmjad2; DPRINTF("Data phase mismatch jump to %08x\n", s->dsp); } else { DPRINTF("Phase mismatch interrupt\n");