From patchwork Mon Aug 20 20:26:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Corey Minyard X-Patchwork-Id: 144668 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp4423096ljj; Mon, 20 Aug 2018 13:46:34 -0700 (PDT) X-Google-Smtp-Source: AA+uWPy5OzxjLC3BIcKsBv91+SgE8zubatQqAGHg/RPYzBU2hSw4VqgkiOwcMymZ/cIDDSr1mjBM X-Received: by 2002:a37:6b84:: with SMTP id g126-v6mr42544625qkc.231.1534797994083; Mon, 20 Aug 2018 13:46:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534797994; cv=none; d=google.com; s=arc-20160816; b=DU/oJVeT7Phmz2eufuTMXEVObwol7eTE9pH7XzDJQ5/g0iOBExfeifIph1gtfLiP3C 2+LIokibfce0RGi1Uc7ZwU/0TDcO/Ncp6joUs17ATCCXkznIxAUON3uG5r9QYScdyVNU Ur2NMPRB0ODz06Ep3JeZLMNx9AISIqSDxr7rmMbgD2kMwqd9YJXA+J0tYB7GY6dkwoHi 0mzIC1W5M9gkDihh1O5KrMhfr8YdHbYoNwJQF4k3R6YkCCthzQ1zZSHu9uQfAiqp0chI jnH2TPLlW5HzLBaqYLOGLtC7dlUhjfz2ap3U3N5C/JDwEFCtWV6tHhMGi7J8tE8I+6YJ 46kQ== 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=vhtOYdHcEbT9TflkxyUlcUwo0tSCvGmf5NTsWpvpQak=; b=OvRXspf7Td4eHz5DeuqfM8P5JLTWjOViWLOmhLjAQDSvpesMqP5i/KFVoIWqq1R0DS Q/n+mJcPiQFOQnE3q4/O2tZiA9x9eUs0gDpLEwUo9Gju5o3dBR6PuZ7h24hTyy+CRjJ2 bIEcCvkwpwvFUahBn5ZZaPU1DLOfxiG2LZyScy7b7V+1H0TEedCk8246B+apO76j8N+K gOolBhsTU5e+F+lsyEAX7TDzv0D5wgNG7R9vF4JE8wBtM9x8RRo4o9wsM1dbKn0qYEsC Dk1iw3LZioqWDs19Tz+k2WPdj1PTixEaa5rsX8pfm3x5gLWzmZ9TRCwvr5Or1/toMwOs pJoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b="kdik/S5f"; 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 r19-v6si680854qta.244.2018.08.20.13.46.33 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 20 Aug 2018 13:46:34 -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="kdik/S5f"; 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]:49250 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1frr4L-0002qi-KE for patch@linaro.org; Mon, 20 Aug 2018 16:46:33 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52122) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1frqlq-0003L3-2N for qemu-devel@nongnu.org; Mon, 20 Aug 2018 16:27:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1frqll-0004BK-G9 for qemu-devel@nongnu.org; Mon, 20 Aug 2018 16:27:25 -0400 Received: from mail-oi0-x231.google.com ([2607:f8b0:4003:c06::231]:33756) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1frqlb-0003PT-JP for qemu-devel@nongnu.org; Mon, 20 Aug 2018 16:27:14 -0400 Received: by mail-oi0-x231.google.com with SMTP id 8-v6so28223526oip.0 for ; Mon, 20 Aug 2018 13:26:58 -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=vhtOYdHcEbT9TflkxyUlcUwo0tSCvGmf5NTsWpvpQak=; b=kdik/S5fOJ3d3/rr6zdUXf9BOFTHIy0ofz2hHaz407850xlG6V2MPgrHajOhOw6myg zSlJ7LQYOMnL/kdnlId29HUoY9Rksmc25DpsK1U6M4dsPOdbX9bzObXO+dLrOk4m6Ygs OF2CQP3ZqLTTcO8qDVe7CZQ0ECBVAloebBnV0FTyyBgmomDz+VI9xdjUjZ4HimR4V376 sJUSap0KczFpDiSwR/KuxZyz73VRu69dhw/dceUD0TjqHdDB65Bkn36t6J5aYjTIm7Qe C7kxF2ND9uHdhHJiFtcGJuE/MUW1ndHa1KoSVLTjTnUF5lHO9NrSKzhiNm//FKGQWM4H dZug== 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=vhtOYdHcEbT9TflkxyUlcUwo0tSCvGmf5NTsWpvpQak=; b=Nug6ci8UysCnmEZxqTSHiRrhrrs5/tszczLZGPDS9FYRXqdT04UFLXkP0LKseboNpC 4meeaxWo4vcs/PJql7G2CJPSEWInmVt9q6OPd7oxBtVB0oRImVOO0KFyX1/JWK8fCdhi NzIMKJDFRrKqLo1/ZeF4KHUXQQwolkBxA9lnzJWU54P9q2N3CoUg1/LJlqzn8ANtvnQL aNWkJKmW9eNW3+Q3fcPoPx/AZWqaVOne1xvMD4ayiZYm/NZ0IXwDOJwVL6XX2gKaBcsz 0Yz3Y3ggjoXI2KPX7AP9FOEa3RzZ9N3uqOba2PsaHS7ubkc2RadgEN/xD65KOQBwSN19 5PUA== X-Gm-Message-State: AOUpUlFVDvbsC+DtjUMojbv549i8TnjaRj6owzem+gxF9MTa+/HyCjt8 v80kdsSO8p+1UO2IozhLyQ== X-Received: by 2002:aca:5885:: with SMTP id m127-v6mr14444739oib.162.1534796817868; Mon, 20 Aug 2018 13:26:57 -0700 (PDT) Received: from serve.minyard.net ([47.184.170.128]) by smtp.gmail.com with ESMTPSA id q18-v6sm11585777oic.18.2018.08.20.13.26.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Aug 2018 13:26:57 -0700 (PDT) Received: from t430.minyard.net (unknown [IPv6:2001:470:b8f6:1b:7d98:76b7:e7fd:495f]) by serve.minyard.net (Postfix) with ESMTPA id B148D1307; Mon, 20 Aug 2018 15:26:24 -0500 (CDT) Received: by t430.minyard.net (Postfix, from userid 1000) id BE8AD30010A; Mon, 20 Aug 2018 15:26:21 -0500 (CDT) From: minyard@acm.org To: Paolo Bonzini , qemu-devel@nongnu.org Date: Mon, 20 Aug 2018 15:26:07 -0500 Message-Id: <1534796770-10295-8-git-send-email-minyard@acm.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1534796770-10295-1-git-send-email-minyard@acm.org> References: <1534796770-10295-1-git-send-email-minyard@acm.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::231 Subject: [Qemu-devel] [PATCH v2 07/10] 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?= , "Michael S . Tsirkin" 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é --- hw/i2c/pm_smbus.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) -- 2.7.4 Reviewed-by: Philippe Mathieu-Daudé 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;