From patchwork Tue May 29 10:58:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wolfram Sang X-Patchwork-Id: 921969 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-i2c-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=sang-engineering.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 40w9hV3wBvz9s0y for ; Tue, 29 May 2018 20:59:06 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933190AbeE2K7E (ORCPT ); Tue, 29 May 2018 06:59:04 -0400 Received: from sauhun.de ([88.99.104.3]:54014 "EHLO pokefinder.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932847AbeE2K7D (ORCPT ); Tue, 29 May 2018 06:59:03 -0400 Received: from localhost (p54B3340F.dip0.t-ipconnect.de [84.179.52.15]) by pokefinder.org (Postfix) with ESMTPSA id 88C1544B250; Tue, 29 May 2018 12:59:01 +0200 (CEST) From: Wolfram Sang To: linux-i2c@vger.kernel.org Cc: linux-renesas-soc@vger.kernel.org, Yoshihiro Shimoda , Hiromitsu Yamasaki , Wolfram Sang Subject: [RFC PATCH 0/1] i2c: rcar: handle RXDMA HW bug on Gen3 Date: Tue, 29 May 2018 12:58:46 +0200 Message-Id: <20180529105847.15663-1-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.11.0 Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org As mentioned in the patch description, this patch works around a HW bug on Renesas R-Car Gen3 SoCs. It had not been discovered yet because it only happens when clearing DMA enable bits is too late because of latency. To reproduce the problem reliably, the below patch was used [1]. To the best of my knowledge, all Gen3 SoCs are affected, so I didn't add any soc_device_match kind of matching for now. If the situation changes, we can add it. For now, priv->devtype is good. The improvement can be shown by using the following command. Before the patch, executed on a Salvator-X / R-Car M3-W ES1.0: # i2ctransfer -y 2 w1@0x10 0 r16 w1 0 r16 0x0f 0x07 0x3f 0x20 0x20 0x55 0x05 0x07 0x0f 0x07 0x3f 0x00 0x00 0x00 0x00 0x00 0xfe 0x0f 0x07 0x3f 0x20 0x20 0x55 0x05 0x07 0x0f 0x07 0x3f 0x00 0x00 0x00 0x00 # i2ctransfer -y 2 w1@0x10 0 r16 w1 0 r16 0xfe 0x0f 0x07 0x3f 0x20 0x20 0x55 0x05 0x07 0x0f 0x07 0x3f 0x00 0x00 0x00 0x00 0xfe 0x0f 0x07 0x3f 0x20 0x20 0x55 0x05 0x07 0x0f 0x07 0x3f 0x00 0x00 0x00 0x00 Note the broken first byte (0xfe) after the first successful RXDMA transfer. After the patch (tested with and without CONFIG_RESET_CONTROLLER): # i2ctransfer -y 2 w1@0x10 0 r16 w1 0 r16 0x0f 0x07 0x3f 0x20 0x20 0x55 0x05 0x07 0x0f 0x07 0x3f 0x00 0x00 0x00 0x00 0x00 0x0f 0x07 0x3f 0x20 0x20 0x55 0x05 0x07 0x0f 0x07 0x3f 0x00 0x00 0x00 0x00 0x00 # i2ctransfer -y 2 w1@0x10 0 r16 w1 0 r16 0x0f 0x07 0x3f 0x20 0x20 0x55 0x05 0x07 0x0f 0x07 0x3f 0x00 0x00 0x00 0x00 0x00 0x0f 0x07 0x3f 0x20 0x20 0x55 0x05 0x07 0x0f 0x07 0x3f 0x00 0x00 0x00 0x00 0x00 Looks way better! Patch was tested with current renesas-drivers/master, but should also apply cleanly on i2c/for-next or v4.17-rc7. Please test and comment. Kind regards, Wolfram Wolfram Sang (1): i2c: rcar: handle RXDMA HW bug on Gen3 drivers/i2c/busses/i2c-rcar.c | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) [1] Testcase patch: diff --git a/drivers/i2c/busses/i2c-rcar.c b/drivers/i2c/busses/i2c-rcar.c index d445b5891280..e42cd0121862 100644 --- a/drivers/i2c/busses/i2c-rcar.c +++ b/drivers/i2c/busses/i2c-rcar.c @@ -353,6 +353,7 @@ static void rcar_i2c_dma_unmap(struct rcar_i2c_priv *priv) struct dma_chan *chan = priv->dma_direction == DMA_FROM_DEVICE ? priv->dma_rx : priv->dma_tx; + mdelay(10); /* Disable DMA Master Received/Transmitted */ rcar_i2c_write(priv, ICDMAER, 0);