From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: None (no SPF record) identity=mailfrom; client-ip=2a00:1450:4010:c07::244; helo=mail-lf0-x244.google.com; envelope-from=mw@semihalf.com; receiver=edk2-devel@lists.01.org Received: from mail-lf0-x244.google.com (mail-lf0-x244.google.com [IPv6:2a00:1450:4010:c07::244]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 1514D2034A87A for ; Thu, 26 Oct 2017 18:10:47 -0700 (PDT) Received: by mail-lf0-x244.google.com with SMTP id a69so5682191lfe.5 for ; Thu, 26 Oct 2017 18:14:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=XOFO9TtAZ3RTSamL64u3tOj918MQw0Favl3owH37cuk=; b=WFJeS/XUgjzkisIevf/sqAHZ/1kf4xhs4hhpOvlYChz8SsmJ0woDu4VrUP0i4c2fzD K+qs7hnzuH9X8kIdZkcEFfbJFGINzJ4VSaWpQi8qwaEMyvWd1IzA/30UFKUBu0t2ZWZp KawlCzovTNHrPPrQZrcJMQDiRIogf0NjvyWiDLVYLBpqyGj+bKQs2epJgGDaNvmLWKBh 7HXHwZvw65k9Gyf4TYRHCNVrfyfVn6JyJIcPi1d4EKMy7/rlIxON4rKnOeHj3U4x+wpj orwX8hPZOsH3zxlrwC3E0OvjaRP/nz9nofC4kHTF0GJz4Xf1TSHaVAD7JLj96Ta2846A miOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=XOFO9TtAZ3RTSamL64u3tOj918MQw0Favl3owH37cuk=; b=mq3tqPLer6gc1RdYH73pGwsJ5qv+bXF8CoCRUJSCYL/TWHz/UXbaXt3G/FNhGw6FPr SxGE/T4uAwIU+D6But/m0uTX/Td1gmR2rP4lfiLX6X3MAWlfVh6XHwcm2wS92IGoCOyj I4cpN+o5wE42AhhwJHDqopJb4jd0YmWmIrw54krLoIPMAR+ThCcEcvnB0BnYSuazM0Z6 C6X4iDYmswtpwtf/LXyaPwZTSWpkPxbe3ecPMDDLoYhJZ0vSVYqVOIBzeSlfr0k/8QGD 9trWk4CLJ8N97hrKG2hTB9a6NbKnVFipd+35uPZUDxV47y9TxEXgcbpFj5xWADmgPp7P ElGQ== X-Gm-Message-State: AMCzsaVYsZeQqY0Tmv+/EjpJHRZQeKDv0t3AKppCQdC1h22mx4nRlcjU tKeM67JIKnema/hDV91ZDjs1Myk56R8= X-Google-Smtp-Source: ABhQp+QGuqdnEpugSV2RBrcmQJEXPs2SmYhEfX6+4B91HrFdUt8odBlnSMAvL7HY4Ae2ldUler0ttg== X-Received: by 10.46.82.14 with SMTP id g14mr10082183ljb.118.1509066871761; Thu, 26 Oct 2017 18:14:31 -0700 (PDT) Received: from gilgamesh.semihalf.com (31-172-191-173.noc.fibertech.net.pl. [31.172.191.173]) by smtp.gmail.com with ESMTPSA id m9sm1675702ljb.61.2017.10.26.18.14.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 26 Oct 2017 18:14:31 -0700 (PDT) From: Marcin Wojtas To: edk2-devel@lists.01.org Cc: leif.lindholm@linaro.org, ard.biesheuvel@linaro.org, nadavh@marvell.com, neta@marvell.com, kostap@marvell.com, jinghua@marvell.com, mw@semihalf.com, jsd@semihalf.com, David Greeson Date: Fri, 27 Oct 2017 03:13:45 +0200 Message-Id: <1509066832-5285-4-git-send-email-mw@semihalf.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1509066832-5285-1-git-send-email-mw@semihalf.com> References: <1509066832-5285-1-git-send-email-mw@semihalf.com> Subject: [platforms: PATCH v2 03/10] Marvell/Drivers: MvI2cDxe: Reduce bus occupation time X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Oct 2017 01:10:47 -0000 From: David Greeson During each transaction start, clearing the I2C_CONTROL_FLAG was surrounded by 3 uncoditional stalls. This was not necessary, so replace them with one busy-wait loop, whose polling count could be also safely reduced. Above improvements result in faster transfer initialization and allow to reduce the I2C bus occupation. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: David Greeson Signed-off-by: Marcin Wojtas Reviewed-by: Leif Lindholm --- Platform/Marvell/Drivers/I2c/MvI2cDxe/MvI2cDxe.c | 6 +----- Platform/Marvell/Drivers/I2c/MvI2cDxe/MvI2cDxe.h | 2 +- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/Platform/Marvell/Drivers/I2c/MvI2cDxe/MvI2cDxe.c b/Platform/Marvell/Drivers/I2c/MvI2cDxe/MvI2cDxe.c index a62383f..d6f590d 100755 --- a/Platform/Marvell/Drivers/I2c/MvI2cDxe/MvI2cDxe.c +++ b/Platform/Marvell/Drivers/I2c/MvI2cDxe/MvI2cDxe.c @@ -243,9 +243,8 @@ MvI2cClearIflg ( IN I2C_MASTER_CONTEXT *I2cMasterContext ) { - gBS->Stall(I2C_OPERATION_TIMEOUT); + MvI2cPollCtrl (I2cMasterContext, I2C_OPERATION_TIMEOUT, I2C_CONTROL_IFLG); MvI2cControlClear(I2cMasterContext, I2C_CONTROL_IFLG); - gBS->Stall(I2C_OPERATION_TIMEOUT); } /* Timeout is given in us */ @@ -295,9 +294,6 @@ MvI2cLockedStart ( MvI2cClearIflg(I2cMasterContext); } - /* Without this delay we Timeout checking IFLG if the Timeout is 0 */ - gBS->Stall(I2C_OPERATION_TIMEOUT); - if (MvI2cPollCtrl(I2cMasterContext, Timeout, I2C_CONTROL_IFLG)) { DEBUG((DEBUG_ERROR, "MvI2cDxe: Timeout sending %sSTART condition\n", Mask == I2C_STATUS_START ? "" : "repeated ")); diff --git a/Platform/Marvell/Drivers/I2c/MvI2cDxe/MvI2cDxe.h b/Platform/Marvell/Drivers/I2c/MvI2cDxe/MvI2cDxe.h index 028fd54..3c9beaf 100644 --- a/Platform/Marvell/Drivers/I2c/MvI2cDxe/MvI2cDxe.h +++ b/Platform/Marvell/Drivers/I2c/MvI2cDxe/MvI2cDxe.h @@ -68,7 +68,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define I2C_SOFT_RESET 0x1c #define I2C_TRANSFER_TIMEOUT 10000 -#define I2C_OPERATION_TIMEOUT 1000 +#define I2C_OPERATION_TIMEOUT 100 #define I2C_UNKNOWN 0x0 #define I2C_SLOW 0x1 -- 2.7.4