From nobody Mon May 6 03:13:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1516327034158325.5103794007051; Thu, 18 Jan 2018 17:57:14 -0800 (PST) Received: from localhost ([::1]:43200 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ecLvV-0005Ce-Kn for importer@patchew.org; Thu, 18 Jan 2018 20:57:05 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56965) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ecLuW-0004oI-9P for qemu-devel@nongnu.org; Thu, 18 Jan 2018 20:56:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ecLuV-0000Xd-5b for qemu-devel@nongnu.org; Thu, 18 Jan 2018 20:56:04 -0500 Received: from mail-pf0-x244.google.com ([2607:f8b0:400e:c00::244]:37794) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ecLuU-0000XJ-Ut for qemu-devel@nongnu.org; Thu, 18 Jan 2018 20:56:03 -0500 Received: by mail-pf0-x244.google.com with SMTP id p1so202984pfh.4 for ; Thu, 18 Jan 2018 17:56:02 -0800 (PST) Received: from serve.minyard.net (serve.minyard.net. [2001:470:b8f6:1b::1]) by smtp.gmail.com with ESMTPSA id c72sm15023124pfe.26.2018.01.18.17.55.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 18 Jan 2018 17:56:00 -0800 (PST) Received: from t430.minyard.net (t430m.minyard.net [192.168.27.3]) by serve.minyard.net (Postfix) with ESMTPA id 49CAF30B; Thu, 18 Jan 2018 19:55:58 -0600 (CST) Received: by t430.minyard.net (Postfix, from userid 1000) id 7E7053000AC; Thu, 18 Jan 2018 19:55:57 -0600 (CST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=D1Y0fwMo+DHvbklquAB+iEPsMmfn56MO+pKTErYnw3c=; b=AJzabVbLIu8VzHXB64tRAgd3f4qKwQTcoclhk1lfa9XgMSlgyIhMkncGARQ5tdYNIQ n8HyUfJp72YxpiLMaYXrYjd/gD/1aztwosjFrcIZlsypLZzjZ2B3EWDENQvddMoc4LZ6 IBlJcCaj0q5Cz1EpGTykRtLGPHQ5ExzTsm4cuuTZs8x8uF30Ht2DJv0ngi+42j5ryuSl ZQS2qMVy4rUIz6NjZagDHaRH+qeouv/Ocyci/4mmEV0uwsp8dVmYW96e9yw+9NNX2DqA UI2v6/isJ+9945yX5Mg2QnswJfNcHKduy2X1pcXt0Y+1hxnyrBnnfX8mbw58zFVRcC5X V0fw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :mime-version:content-transfer-encoding; bh=D1Y0fwMo+DHvbklquAB+iEPsMmfn56MO+pKTErYnw3c=; b=sdqVJ4RlLuJ0DkkqKNYT0LSAUqViQh90G/z2/pIbmawREicpX12QAoi5ikDEB67PRu dlDyfdHFBXTcNKb7y1r/rybqPIqmvQYuLFaCylG9X72M4RJbEIuUOjAShiRNO+Im/64S XCZuwQ3wtJPwZ3rFW/CGR/dLEDD5h1B//9FdVFYnbVwbYgK+8ERIbtFj88+VYehndngv kjJK2HLbeOA0sez2RPwF/pZRfa3NOfeG+3oDzNMzmpD6h2Mvw2wCCBt2S8bXPFFxFd0w GhouzL29KN4up/7uJ1QUjLsUNGjLCVn6hU2xx2XwN1RHldaeB5Ss23qKygEuBcVDncEQ 4OUQ== X-Gm-Message-State: AKwxytc86470eCVIWbX9tQjU0ueZokWL+Wgiff7e1luyWDg1Ys2pGSpI A4mzx9XYA5o2TefwSaApHQ== X-Google-Smtp-Source: ACJfBouYVaX2gYQJkbHXJHSsY9tn9scJN6okkNnGB9JbdXFRg5DgutDikyKSIeNVu3omNQT/LPzDNw== X-Received: by 10.99.110.205 with SMTP id j196mr12363143pgc.54.1516326961242; Thu, 18 Jan 2018 17:56:01 -0800 (PST) From: minyard@acm.org To: qemu-devel@nongnu.org, "Michael S . Tsirkin" Date: Thu, 18 Jan 2018 19:55:41 -0600 Message-Id: <1516326941-11832-1-git-send-email-minyard@acm.org> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::244 Subject: [Qemu-devel] [PATCH] Revert "smbus: do not immediately complete commands" X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Corey Minyard , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 From: Corey Minyard This reverts commit 880b1ffe6ec2f0ae25cc4175716227ad275e8b8a. The commit being reverted says: PIIX4 errata says that "immediate polling of the Host Status Register B= USY bit may indicate that the SMBus is NOT busy." Due to this, some code does the following steps: (a) set parameters (b) start command (c) check for smbus busy bit set (to know that command started) (d) check for smbus busy bit not set (to know that command finished) Let (c) happen, by immediately setting the busy bit, and really executi= ng the command when status register has been read once. This fixes a problem with AMIBIOS, which can now properly initialize the PIIX4. Emulating bad hardware so badly written software will work doesn't sound like a good idea to me. I have patches that add interrupt capability to pm_smbus, but this change breaks that because the Linux driver starts the transaction then waits for interrupts before reading the status register. That obviously won't work with these changes. The right way to fix this in AMIBIOS is to ignore the host busy bit and use the other bits in the host status register to tell if the transaction has completed. Using host busy is racy, anyway, if you get interrupted or something while processing, you may miss step (c) in your algorithm and fail. Cc: Herv=C3=A9 Poussineau Cc: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Corey Minyard --- hw/i2c/pm_smbus.c | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/hw/i2c/pm_smbus.c b/hw/i2c/pm_smbus.c index 0d26e0f..a044dd1 100644 --- a/hw/i2c/pm_smbus.c +++ b/hw/i2c/pm_smbus.c @@ -62,9 +62,6 @@ static void smb_transaction(PMSMBus *s) I2CBus *bus =3D s->smbus; int ret; =20 - assert(s->smb_stat & STS_HOST_BUSY); - s->smb_stat &=3D ~STS_HOST_BUSY; - SMBUS_DPRINTF("SMBus trans addr=3D0x%02x prot=3D0x%02x\n", addr, prot); /* Transaction isn't exec if STS_DEV_ERR bit set */ if ((s->smb_stat & STS_DEV_ERR) !=3D 0) { @@ -137,13 +134,6 @@ error: =20 } =20 -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 |=3D STS_HOST_BUSY; -} - static void smb_ioport_writeb(void *opaque, hwaddr addr, uint64_t val, unsigned width) { @@ -159,7 +149,7 @@ static void smb_ioport_writeb(void *opaque, hwaddr addr= , uint64_t val, case SMBHSTCNT: s->smb_ctl =3D val; if (val & 0x40) - smb_transaction_start(s); + smb_transaction(s); break; case SMBHSTCMD: s->smb_cmd =3D val; @@ -191,10 +181,6 @@ static uint64_t smb_ioport_readb(void *opaque, hwaddr = addr, unsigned width) switch(addr) { case SMBHSTSTS: val =3D s->smb_stat; - if (s->smb_stat & STS_HOST_BUSY) { - /* execute command now */ - smb_transaction(s); - } break; case SMBHSTCNT: s->smb_index =3D 0; --=20 2.7.4