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 1984821CEB139 for ; Fri, 27 Oct 2017 09:28:53 -0700 (PDT) Received: by mail-lf0-x243.google.com with SMTP id a132so8025073lfa.7 for ; Fri, 27 Oct 2017 09:32:40 -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=O1+9zvhjkdUvwVF3jphPpPsJHcyQ6rPYswsrTRmYs+3q0z4Kh/dscOstMR0RhKAQ23 8CdcxwQO7PPRc5yPW1XU9tG4tvcp4q8zZHJ7P6+PaIlrBckVjqnVs4LLJlSKPINUqs5I ODn1TQ3NKqzj66nwgXsEXe9D8g7kYD3ny/o5F8baSbBftX9Kilivqeo0uRCBGV/ochp2 wpc1Cb8LPrW4hT3rUaZKE23pGscqLKDo8mjPY6La22tj5KLpSZaOCp62rxXvCVEVks97 PoIOmaWu6ut5lkl7xIOY9gMksgPVLrHZMqCN7M3DNP0XVuwKwdoHI54yQ6vqfD7tYs1Y bSiw== 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=BzrKcob3tzqIKNc2MO/+voXTikFa8KHAidpIs4nbGbktpSOF1eZ/fcxUc02DZ5oB5Y 6u8LGllGQ2Fo8WRwBOoIGOrBQw6pk3MkSL73h65kdECiEjaC8J4uEmeB0O0TryQEwecF j2tJXal8mDGv0BBS+1/snueHDHjce/uV2Y+xOqpEyOmX93XjpnsjC0JYoa7jWGgyQI+j Q8Jl1kA/FGlS8j/n/cIgGTbUyagbYcGCI4iPdO5dRQiWAnKU4Ta1ighs6wSMu7eBVaOR HZDBxaahaBvmutJnXNZKG37GSW6o7ndNh2bEcUSz+lszCUhYkEnSO1KccG68/bRYixyF h25w== X-Gm-Message-State: AMCzsaXW1uhpS6NI2yQZB0EvluOhfBpNYO4nZ0nLBtRKVOxWLpcUOPZN WsnKz/rME3xJtfdnJiABFSo5MAslgHU= X-Google-Smtp-Source: ABhQp+T3oSV/GdGxn/I4KXHuSETZPcuujALvHDq2Ec4tHUkQbu6URgEmKM/0koOpGvU7+/4vvA0lDg== X-Received: by 10.25.76.212 with SMTP id z203mr306346lfa.39.1509121958514; Fri, 27 Oct 2017 09:32:38 -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 h3sm1569222lfj.26.2017.10.27.09.32.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 27 Oct 2017 09:32:37 -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 18:31:46 +0200 Message-Id: <1509121913-12937-4-git-send-email-mw@semihalf.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1509121913-12937-1-git-send-email-mw@semihalf.com> References: <1509121913-12937-1-git-send-email-mw@semihalf.com> Subject: [platforms: PATCH v3 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 16:28:53 -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