From patchwork Tue Aug 21 17:02:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 144773 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp5569884ljj; Tue, 21 Aug 2018 10:54:45 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbOtNOZfn9LP1kHlIopPsl9H2o4gyfn2VnyuHtUiEy5O/Tt471HCcE4Dg49kxUtTt2pSvJM X-Received: by 2002:ac8:179c:: with SMTP id o28-v6mr1353913qtj.98.1534874085386; Tue, 21 Aug 2018 10:54:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534874085; cv=none; d=google.com; s=arc-20160816; b=D3ybC3ah6ZmCS8WT4yO3QYnbUBJYSHFJltCsA+eBrw1aAijTRlEqGX8CZPNCX6F1K0 6Dt9AG/coWOoko42M+YAVkAo/udhtoFknsZR1SlCFsQOXkKnytogSZoAs8qODA4lI81w Ro5wZCYihbDamgu1pWi6EUEAWlLk+X8zSBMQcxPpBJezRhLjvujQpAoxkIs1r35Aj82B t2zMAO4hZw4z6tXj8Mj6uxtsI95edN6DflRS3R+lHsQAM7HsJ1Ezjg/LS3XGP1jZ5rDn /+2iV5Eh7SOjxRkqqOVQGB0shDbzVV+b+vkygawvPUDs2jV2nYH/2xBQpbKYPg9LjDm/ xxPw== 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:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=ADFFXom5iNIFTwymwNdZAOMCVy/8n3vmNA6fvWLZ6qY=; b=j8Ky1YlAqjXoqPZWbf+937ueYl++0eZWdGH6CsttHkgi5K8EbEUqHARPJvWJl9ayU6 YfgUPwFNnF5EJzohoLWslOwvOkcchrIhoHLMaoZZNhZfOjboyXQBAUXUcukuN9fLaeee zbKEcCWYnPCJgYANm3qT+TEE9yOGxSm4Bolm1Q1DhnF3eJePDpU0ZIeRATGDHh91aILG P3pFI37kUdFTPE2J11BjCYTaf5wI90Iw5WiFNf1+4K/crpCadBdyX2/IXj7PaqbZZ503 eW1OMYhZinizBSIEiBIvx6DsbLW2ydKFmYVa2jiBdiFIglMuMvhKPcZ2egufvqbNSl7n m+Fg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=HjMIk1RE; 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"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id v188-v6si6102272qkb.323.2018.08.21.10.54.45 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 21 Aug 2018 10:54:45 -0700 (PDT) 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=HjMIk1RE; 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"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from localhost ([::1]:55211 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fsArb-000320-Da for patch@linaro.org; Tue, 21 Aug 2018 13:54:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34040) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fsA53-0002Vl-4b for qemu-devel@nongnu.org; Tue, 21 Aug 2018 13:04:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fsA4o-0007Ci-Ci for qemu-devel@nongnu.org; Tue, 21 Aug 2018 13:04:27 -0400 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]:38391) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fsA4n-00077J-HN for qemu-devel@nongnu.org; Tue, 21 Aug 2018 13:04:18 -0400 Received: by mail-wr1-x441.google.com with SMTP id w11-v6so13897592wrc.5 for ; Tue, 21 Aug 2018 10:04:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ADFFXom5iNIFTwymwNdZAOMCVy/8n3vmNA6fvWLZ6qY=; b=HjMIk1RE2ErqgFDRbdWJs4Krm+H9dFmQBl++9PIvajX6VNd5DuAb9K24ulHgXjWPw6 TG0OUwvUpmg9WCbnBaS6zskbCfYITGR3V4PdtJSIH5997V2kmouHuCK511zWH9WSi7dy ndPPASmFSPpaau2USrNUVF5IxUkGc2HxWp4L1551KBoLbIbW+gelsaEJNhFyph6D9Dga LTUMu6m/sbNmq2+LMM8sRL103UN1TJ9W/6bqztugfxwBlwRbsgAHweMRESI+lZONo55X CAUMCllw+8Bhr9yoSQ/4qwwwP3NnE2ALuLk44SV8Lu07EIwwb/K+p6+/XecjoipD5KTo RpWQ== 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 :in-reply-to:references:mime-version:content-transfer-encoding; bh=ADFFXom5iNIFTwymwNdZAOMCVy/8n3vmNA6fvWLZ6qY=; b=io3Kp3h8sJ4VXf4xV1KSRwHnr0gic6TQ+pr5rfCPuRyB9litowz9F+jr9eySwZJTJB wMaeCSs5tKMtodOUUdxqyorC+q7aSMaQOnCyl9pRXYl0u/F6RuKdbVpeFNj0eS9qrGaY udjbca45ijK1tIT/9vy6ixY5ehZqKRdR8F3Si90p9qXbH0vMye52gE3dbnVr6kBvPIZd PAAxoVxj8k6OY+4wtirkvetAW+SdLxlNQDCM+v1+kUIcgs99ZzqncgLouQ2yNSnP4Nvu IqZbwoVsxHrGtPDu3BZmENJRjtjNnao0yzFwqkrhmHofAJqNI8zqMIlOxi4j4O9Q8FHB ZQlQ== X-Gm-Message-State: AOUpUlHOirOu1EBz/zPeDrAuVw8bXSo4hRsJRzn6y8jOwuir98qNx8iS tRPwUnOAm3OtzjwwbLTn8YANxI/1 X-Received: by 2002:adf:8161:: with SMTP id 88-v6mr32055453wrm.22.1534871054300; Tue, 21 Aug 2018 10:04:14 -0700 (PDT) Received: from 640k.lan (dynamic-adsl-78-12-184-244.clienti.tiscali.it. [78.12.184.244]) by smtp.gmail.com with ESMTPSA id v6-v6sm2608955wmc.43.2018.08.21.10.04.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 21 Aug 2018 10:04:13 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Tue, 21 Aug 2018 19:02:39 +0200 Message-Id: <1534870966-9287-68-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1534870966-9287-1-git-send-email-pbonzini@redhat.com> References: <1534870966-9287-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::441 Subject: [Qemu-devel] [PULL 67/74] i2c: pm_smbus: Don't delay host status register busy bit when interrupts are enabled 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 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 Cc: Hervé Poussineau Cc: Philippe Mathieu-Daudé Message-Id: <1534796770-10295-8-git-send-email-minyard@acm.org> Signed-off-by: Paolo Bonzini --- hw/i2c/pm_smbus.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) -- 1.8.3.1 diff --git a/hw/i2c/pm_smbus.c b/hw/i2c/pm_smbus.c index 6322f07..91ee444 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;