From patchwork Fri Sep 23 13:34:41 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 76867 Delivered-To: patch@linaro.org Received: by 10.140.106.72 with SMTP id d66csp572656qgf; Fri, 23 Sep 2016 06:33:28 -0700 (PDT) X-Received: by 10.66.159.1 with SMTP id wy1mr12544702pab.20.1474637608665; Fri, 23 Sep 2016 06:33:28 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a6si7710081pag.64.2016.09.23.06.33.28; Fri, 23 Sep 2016 06:33:28 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-i2c-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@nifty.com; spf=pass (google.com: best guess record for domain of linux-i2c-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-i2c-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757894AbcIWNd1 (ORCPT + 1 other); Fri, 23 Sep 2016 09:33:27 -0400 Received: from conuserg-07.nifty.com ([210.131.2.74]:49397 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754692AbcIWNd0 (ORCPT ); Fri, 23 Sep 2016 09:33:26 -0400 X-Greylist: delayed 5447 seconds by postgrey-1.27 at vger.kernel.org; Fri, 23 Sep 2016 09:33:25 EDT Received: from beagle.diag.org (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-07.nifty.com with ESMTP id u8NDWWWb024877; Fri, 23 Sep 2016 22:32:33 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com u8NDWWWb024877 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1474637553; bh=Y3gaUmOH7JzhRvNkpIzjsnDu0nwDkOUKVTvVgF48QGk=; h=From:To:Cc:Subject:Date:From; b=g9BNRCbgIbOaDz6NzSwzrtTfhq2ont9TNE2iCWt+9eqhiG7BYlA1aVCkO9mTbDeVv sU/XcQgbxKRy3baaz4xv8gmE4enxfSdYLRZoDFsGech2xwiLaDoLflzO6lzrRbfFaC FP+2BHms/Q8dEdxrOAHkK4exW8/fjqTZy7m2HnvYQrOeOVtWGBqgf1PjKCreD6K7jk eF0Wy+tcrt2+9Sb2lZHag+OARTNF5uPjijw9VrT3ZFuiWJdYRn9zN2hFQTAah+KfuZ FcP6MSzUiXevU5MNQeHwhV2bhnEfquFwsM1SQCEt9M4RFgr9tJulsTApbJjBfFNl9q N1RKWpzwtjq7Q== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-i2c@vger.kernel.org Cc: Masahiro Yamada , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Wolfram Sang Subject: [PATCH v2] i2c: uniphier-f: fix misdetection of incomplete STOP condition Date: Fri, 23 Sep 2016 22:34:41 +0900 Message-Id: <1474637681-9589-1-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 1.9.1 Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org Currently, the status register FI2C_SR is checked immediately after a STOP condition is issued in case of the deferred STOP condition. It takes typically 5-10 usec until the corresponding bits in the register are set, so the error check for "stop condition was not completed" is very likely to be false positive. Add wait code to relax the status register check. Signed-off-by: Masahiro Yamada --- Changes in v2: - use readl_poll_timeout() drivers/i2c/busses/i2c-uniphier-f.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-i2c" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/i2c/busses/i2c-uniphier-f.c b/drivers/i2c/busses/i2c-uniphier-f.c index 829df91..db9105e 100644 --- a/drivers/i2c/busses/i2c-uniphier-f.c +++ b/drivers/i2c/busses/i2c-uniphier-f.c @@ -14,6 +14,7 @@ #include #include +#include #include #include #include @@ -348,14 +349,19 @@ static int uniphier_fi2c_master_xfer_one(struct i2c_adapter *adap, dev_dbg(&adap->dev, "complete\n"); if (unlikely(priv->flags & UNIPHIER_FI2C_DEFER_STOP_COMP)) { - u32 status = readl(priv->membase + UNIPHIER_FI2C_SR); - - if (!(status & UNIPHIER_FI2C_SR_STS) || - status & UNIPHIER_FI2C_SR_BB) { + u32 status; + int ret; + + ret = readl_poll_timeout(priv->membase + UNIPHIER_FI2C_SR, + status, + (status & UNIPHIER_FI2C_SR_STS) && + !(status & UNIPHIER_FI2C_SR_BB), + 1, 20); + if (ret) { dev_err(&adap->dev, "stop condition was not completed.\n"); uniphier_fi2c_recover(priv); - return -EBUSY; + return ret; } }