From patchwork Fri Jan 19 01:55:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Corey Minyard X-Patchwork-Id: 125065 Delivered-To: patch@linaro.org Received: by 10.46.66.141 with SMTP id h13csp82241ljf; Thu, 18 Jan 2018 17:57:32 -0800 (PST) X-Google-Smtp-Source: ACJfBovD+4SqOcR5ZeHlMVA9LxQVd18tm1YTdot7CidKk9hPFLA0kpbfcSJ/i6taaK7lReYoHZ/k X-Received: by 10.129.60.9 with SMTP id j9mr7827946ywa.315.1516327052018; Thu, 18 Jan 2018 17:57:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516327052; cv=none; d=google.com; s=arc-20160816; b=DTr272Zwme9CQtE4qvF8TEPHqgZ2YodjcWcD7GxMYKUWoSm13XpQ2Mobqi38HDMQAw Kt0qxJMWrLmUOULIlc66gJFbbW6ZXU9eCarhui7PS0uGHSqIzfuFBJNC3sCNZmUyyVzg sO/SfrpeqQARYyA+GLItIETP0Z4k5QCDsBRK0OO2vRVTNJ4mVtkSfnyqi8jYofvZPQlE 0uCVJrwj1tXY2hDbuWBNNZ3Qr44C/vCyF59bzi201fG+qlarE99uCNSE58Mp7cpbLRot P6Lipgr1i8yXPFA6e7li5yRFLUKT0CSas4J9Z2083NHCqzkIdtOBFxXkXcHhlCImdDta X7eA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:message-id:date:to:from :dkim-signature:arc-authentication-results; bh=D1Y0fwMo+DHvbklquAB+iEPsMmfn56MO+pKTErYnw3c=; b=K0h71xc5uZqDchSYm7oeF0dGpRY7NvVQ+wO1zET4BdDeoFmVpQHDQNpTTXAIFPmd0J Z3Wq6PLtdDHyyqxw0Z6h2TN3sLTS2T4ibUh9mqcq/DqZy/ydGod5Xgrn3Ur4fQrB4HuW ul4R6OPdDCYt+zXwcUNjYamZqPyH5PTa9MhVuNkkvw/DnektDT/e8M4glwdAsilKMx6d fdUejcK+5o+gFDeNdjgzsDQEgYSRkTI93yxfx44K/7iPNfiDMf6/yhVsWW6X9T7hz9VL UIp1q3/MwPYMruYHetJhZpjL6T+onE/tCWn316sJZUrEFEvmPbz2fgokLg+m5Bm5QI9E RQCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=AJzabVbL; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id b132si397171ybc.28.2018.01.18.17.57.31 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 18 Jan 2018 17:57:32 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=AJzabVbL; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org Received: from localhost ([::1]:43200 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ecLvv-0005Ce-ED for patch@linaro.org; Thu, 18 Jan 2018 20:57:31 -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) 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-Received: by 10.99.110.205 with SMTP id j196mr12363143pgc.54.1516326961242; Thu, 18 Jan 2018 17:56:01 -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) 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 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_Poussineau?= , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Corey Minyard This reverts commit 880b1ffe6ec2f0ae25cc4175716227ad275e8b8a. The commit being reverted says: PIIX4 errata says that "immediate polling of the Host Status Register BUSY 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 executing 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é Poussineau Cc: Philippe Mathieu-Daudé Signed-off-by: Corey Minyard --- hw/i2c/pm_smbus.c | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) -- 2.7.4 Signed-off-by: Hervé Poussineau 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 = 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) { @@ -137,13 +134,6 @@ 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; -} - 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 = val; if (val & 0x40) - smb_transaction_start(s); + smb_transaction(s); break; case SMBHSTCMD: s->smb_cmd = val; @@ -191,10 +181,6 @@ static uint64_t smb_ioport_readb(void *opaque, hwaddr addr, unsigned width) switch(addr) { case SMBHSTSTS: val = s->smb_stat; - if (s->smb_stat & STS_HOST_BUSY) { - /* execute command now */ - smb_transaction(s); - } break; case SMBHSTCNT: s->smb_index = 0;