qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: minyard@acm.org
To: Paolo Bonzini <pbonzini@redhat.com>, qemu-devel@nongnu.org
Cc: "Michael S . Tsirkin" <mst@redhat.com>,
	"Corey Minyard" <cminyard@mvista.com>,
	"Hervé Poussineau" <hpoussin@reactos.org>,
	"Philippe Mathieu-Daudé" <f4bug@amsat.org>
Subject: [Qemu-devel] [PATCH v2 07/10] Don't delay host status register busy bit when interrupts are enabled
Date: Mon, 20 Aug 2018 15:26:07 -0500	[thread overview]
Message-ID: <1534796770-10295-8-git-send-email-minyard@acm.org> (raw)
In-Reply-To: <1534796770-10295-1-git-send-email-minyard@acm.org>

From: Corey Minyard <cminyard@mvista.com>

Change 880b1ffe6ec2f0ae "smbus: do not immediately complete commands"
changed pm_smbus to delay setting the host busy bit until the status
register was read, to work around a bug in AMIBIOS.  Unfortunately,
when interrupts are enabled, the status register will never get read
and the processing will never happen.

Modify the code to only delay setting the host busy bit if interrupts
are not enabled.

Signed-off-by: Corey Minyard <cminyard@mvista.com>
Cc: Hervé Poussineau <hpoussin@reactos.org>
Cc: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/i2c/pm_smbus.c | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/hw/i2c/pm_smbus.c b/hw/i2c/pm_smbus.c
index 664a6b1..10ba208 100644
--- a/hw/i2c/pm_smbus.c
+++ b/hw/i2c/pm_smbus.c
@@ -80,9 +80,6 @@ static void smb_transaction(PMSMBus *s)
     I2CBus *bus = s->smbus;
     int ret;
 
-    assert(s->smb_stat & STS_HOST_BUSY);
-    s->smb_stat &= ~STS_HOST_BUSY;
-
     SMBUS_DPRINTF("SMBus trans addr=0x%02x prot=0x%02x\n", addr, prot);
     /* Transaction isn't exec if STS_DEV_ERR bit set */
     if ((s->smb_stat & STS_DEV_ERR) != 0)  {
@@ -209,9 +206,18 @@ error:
 
 static void smb_transaction_start(PMSMBus *s)
 {
-    /* Do not execute immediately the command ; it will be
-     * executed when guest will read SMB_STAT register */
-    s->smb_stat |= STS_HOST_BUSY;
+    if (s->smb_ctl & CTL_INTREN) {
+        smb_transaction(s);
+    } else {
+        /* Do not execute immediately the command; it will be
+         * executed when guest will read SMB_STAT register.  This
+         * is to work around a bug in AMIBIOS (that is working
+         * around another bug in some specific hardware) where
+         * it waits for STS_HOST_BUSY to be set before waiting
+         * checking for status.  If STS_HOST_BUSY doesn't get
+         * set, it gets stuck. */
+        s->smb_stat |= STS_HOST_BUSY;
+    }
 }
 
 static bool
@@ -330,6 +336,7 @@ static uint64_t smb_ioport_readb(void *opaque, hwaddr addr, unsigned width)
         val = s->smb_stat;
         if (s->smb_stat & STS_HOST_BUSY) {
             /* execute command now */
+            s->smb_stat &= ~STS_HOST_BUSY;
             smb_transaction(s);
         }
         break;
-- 
2.7.4

  parent reply	other threads:[~2018-08-20 20:27 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-20 20:26 [Qemu-devel] [PATCH v2 0/8] Make the pm_smbus code more correct minyard
2018-08-20 20:26 ` [Qemu-devel] [PATCH v2 01/10] i2c:pm_smbus: Clean up some style issues minyard
2018-08-21  6:22   ` Philippe Mathieu-Daudé
2018-08-20 20:26 ` [Qemu-devel] [PATCH v2 02/10] i2c:pm_smbus: Fix the semantics of block I2C transfers minyard
2018-08-20 20:26 ` [Qemu-devel] [PATCH v2 03/10] i2c:pm_smbus: Make the I2C block read command read-only minyard
2018-08-20 20:26 ` [Qemu-devel] [PATCH v2 04/10] i2c:pm_smbus: Add block transfer capability minyard
2018-08-20 20:26 ` [Qemu-devel] [PATCH v2 05/10] i2c:pm_smbus: Fix state transfer minyard
2018-08-21 12:41   ` Paolo Bonzini
2018-08-29 12:05     ` Dr. David Alan Gilbert
2018-08-20 20:26 ` [Qemu-devel] [PATCH v2 06/10] i2c:pm_smbus: Add interrupt handling minyard
2018-08-20 20:26 ` minyard [this message]
2018-08-21  6:26   ` [Qemu-devel] [PATCH v2 07/10] Don't delay host status register busy bit when interrupts are enabled Philippe Mathieu-Daudé
2018-08-20 20:26 ` [Qemu-devel] [PATCH v2 08/10] i2c:pm_smbus: Add the ability to force block transfer enable minyard
2018-08-21  6:27   ` Philippe Mathieu-Daudé
2018-08-20 20:26 ` [Qemu-devel] [PATCH v2 09/10] i2c: Add an SMBus vmstate structure minyard
2018-08-29 11:59   ` Dr. David Alan Gilbert
2018-08-20 20:26 ` [Qemu-devel] [PATCH v2 10/10] i2c: Add vmstate handling to the smbus eeprom minyard
2018-08-29 11:44   ` Dr. David Alan Gilbert
2018-08-29 12:01     ` Dr. David Alan Gilbert
2018-08-21 12:02 ` [Qemu-devel] [PATCH v2 0/8] Make the pm_smbus code more correct Paolo Bonzini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1534796770-10295-8-git-send-email-minyard@acm.org \
    --to=minyard@acm.org \
    --cc=cminyard@mvista.com \
    --cc=f4bug@amsat.org \
    --cc=hpoussin@reactos.org \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).