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::243; helo=mail-lf0-x243.google.com; envelope-from=mw@semihalf.com; receiver=edk2-devel@lists.01.org Received: from mail-lf0-x243.google.com (mail-lf0-x243.google.com [IPv6:2a00:1450:4010:c07::243]) (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 551EB2034CF8D for ; Wed, 25 Oct 2017 18:16:17 -0700 (PDT) Received: by mail-lf0-x243.google.com with SMTP id a2so1904462lfh.11 for ; Wed, 25 Oct 2017 18:20:02 -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=4Y4ZOSBmbKvqIxtzHc0XgQzM7/ggPK172m5cmX9ogj4=; b=xfxaJmVSQS9caPIKM3ZZKrhNCZzUqhywnoia8nKLNSgD8cPnHlPPR+Fi8QgLbHjmdm I/Ota6OjBl3Bf0D9OMCVQb0c1kqiIxrqxKeiwL3gDJNy3M0Qjk0U+4XzuvbmsXubT2rj O5WZWE+8rDJ8j/jZuL++7jL6I5YZ+LT3M2R+tz4dRAny4jJFUr4EHMhE/yTBhugbP/J4 2geITv48oQlVJHBniabKnQhGxrD4YjvSsZGTR2A++nMKU1xsZZMlkt5pZ7wAo1VSlFHR ypFQFmA13CgJdkGkE0vL1HdEzKw8ZTRmmhG2GX8pG/idTKKW2uLz+1MQaoOS0ElJcy2n 5CJA== 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=4Y4ZOSBmbKvqIxtzHc0XgQzM7/ggPK172m5cmX9ogj4=; b=daE8Js5lvJULxUjN6yvO5TDMSMRgWjtSBCy1XAfSQv2pMCu5xguUzwSpI59rwlvxpV WttDPPNxi9agqeS4eoQ2PumRJZrH1Ar7JBlnSGkUuqdtWtKxRftBYfDsQjL6TYkAbtjg m0RJi5nGLaCnhCO84Vs/WlD0SFXvezBVNLlRnaiDI0KeZU7bn60vHOhrlOCGPo/aTY3q fdnwDk6I75Z4JlggNmugjAjjLPIKDbgfPyuf0rMsr5kDxiOTVaOs3Kfx9+GoQtXIT601 9VeowG8SQp1VHFgx8wX4i17o1swzAqsMl92mcUrZ9ua4ihxf0UWvhJz73x1LbtGUFv+o 8f7w== X-Gm-Message-State: AMCzsaXFmb1YNeScp7r9/iAK792TFphSZOhDh8AXDJMbywYWXc0Sjmi3 0fiby1gxwWZ2ougk7pvd6RjfSSOCmiI= X-Google-Smtp-Source: ABhQp+TPuOs11sx/7gfXR0e3ameK7WB0W/Kbns/Y8k99MPwmlDyCwhmKk8e9PfvhKeXj/InzeaM9Ww== X-Received: by 10.25.160.211 with SMTP id j202mr6323177lfe.218.1508980801013; Wed, 25 Oct 2017 18:20:01 -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 h26sm1053428lja.69.2017.10.25.18.19.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 25 Oct 2017 18:20:00 -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: Thu, 26 Oct 2017 03:19:30 +0200 Message-Id: <1508980777-29006-4-git-send-email-mw@semihalf.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1508980777-29006-1-git-send-email-mw@semihalf.com> References: <1508980777-29006-1-git-send-email-mw@semihalf.com> Subject: [platforms: PATCH 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: Thu, 26 Oct 2017 01:16:17 -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 --- 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 8ed96f0..3c26d18 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