Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2070384imj; Sun, 17 Feb 2019 22:36:29 -0800 (PST) X-Google-Smtp-Source: AHgI3Ibi7rled/TEoAST2baxI2uOjJxduMUebHFQmb+LK7iuDI5d9z34mjs66EE7/u9Ufti5O4B6 X-Received: by 2002:a63:516:: with SMTP id 22mr16890905pgf.353.1550471789005; Sun, 17 Feb 2019 22:36:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550471788; cv=none; d=google.com; s=arc-20160816; b=ysCsVLhMLuWpScABV86CsF24HdPF54n3YAF9EBoH/2cCAkuwTY6OYKmHABuGNvFniw +HfYEyokHcMxH4ZcCDIU28x1I02DxVPkqQRSnVM7F6OluJUlfdGl5FvzCRlUXKsfg04S DkCqFVWDwDkG7OvUOKaxWzTNdhCcY+exQpLdea7t3AdJRbjCEfvwHfhltL/Jmf98rfVa w9SQ69YRetMKLk5dkx/Ycoqn6B/bTcVSllDjKz21+GP8QBILNfCbnOJhAHZ5/RDcGp60 Cu1hYN4ahEXSZC2kuy2Aqu2xWeIrLenloZYRzee+IjTFogORcxfUifU7lTtu5QXpAdmI bnRQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=vHCudiFBm/jzc4dvlgpQ6a7QXYNqY+987pMivWSoyZk=; b=PAvlQmyXsRoBaYldNxAnx15ispPgxo307out5TJK0FC4+j5+HwRX7jRK/oLvgLDzZM tKzL9LZkCCWABjff8wS17COTON9ijMU2f3U24kLtwl1oC4DFUD3/Cqaitx8eJmQgrKcL BJsDbAmTusIgWHvFOzcSGIXtzWc8P9IJcMvceMWxB648MlxOMhOnalmc4z9b0pEIY/hE SDVQJSalfxA7aHB+yC0yWW0reyNH6lTbDszSR4gfASy0IGCuzfRDNzsfTYpoHbjkuWO/ dacBQauaQWSxNI/pv14iQXqwmUirojZYORqg9uAMz4WXHz7ma03tPJwWh6IRfd8TGjWj BmmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=MsuBJSSI; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i68si13385536plb.325.2019.02.17.22.36.12; Sun, 17 Feb 2019 22:36:28 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=MsuBJSSI; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728349AbfBRGdb (ORCPT + 99 others); Mon, 18 Feb 2019 01:33:31 -0500 Received: from mail-wr1-f68.google.com ([209.85.221.68]:39566 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726221AbfBRGdb (ORCPT ); Mon, 18 Feb 2019 01:33:31 -0500 Received: by mail-wr1-f68.google.com with SMTP id l5so15901784wrw.6; Sun, 17 Feb 2019 22:33:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=vHCudiFBm/jzc4dvlgpQ6a7QXYNqY+987pMivWSoyZk=; b=MsuBJSSIeGgjQ4zYmV+EZjNnmbGHHojlgGczNswkGXwu0B4rIDZPxsA/6sw8qgKGGf cl4UfWzzTI6FuCdus+pjdvyCvxRCBy0piyk4m2aLS3397+CFimVmpr5SZY35RMkLnZOR +h4xvo2/wVfLE/slwcsV1/l/P8a3C5btMH9vojNYTxKRno7Vdrtbzd76TD9488etd4QG clA+74fnpq0udhTPc6J2HuFx6cpthej1G+53oSbXt90fLUAKlfpOgQc+uYXbSZfUiYkP YA5GLZT2YKm4+nNjBVJbgd1jokCfFKqSd4MSUjQTughbcKQAtPKZ7DBSfw7ffEEjStu/ 3yeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=vHCudiFBm/jzc4dvlgpQ6a7QXYNqY+987pMivWSoyZk=; b=We7Rnk8aPZ2tmvRs7vgoj6AoZISnjk0hK2+qPRkWp4Q5dg9FfHl+YWNFUdav8NhVqf FdOlvSyfNHqgJ7x42wvk58xt/sQ+b1oVspho51XlIJCzfeWnW9TSd1CUzgZR1MDkNhwj wwrDs2EaeaLWM8lxTdhtyO54Mk9pHboFq0QzPdxBRCx6Te5QblMVY0KMaqlrsfkdw16r biMJiMu3bfB/94fGMoCBnFIC5md4kEi2NRbl5b/DpeAHqGPh4bgMmpaaTJUY/QVKUJ/b mNXo1PJeH5PFZ40aqgwvXAf2xCNHlVsEJD2q0q4LOVzgrNvWemN9cFL0JClv1mcv67U7 UxQw== X-Gm-Message-State: AHQUAubG8OZgrin+I02q1yhm3QE1wEulSSFpLNJ6s+Uoh7UcgbEX6Nxd 7Ap/GYTNeU0Re3Lj9KusgGEQGB93ND/6oOQwPkY= X-Received: by 2002:adf:cd87:: with SMTP id q7mr16476213wrj.92.1550471609085; Sun, 17 Feb 2019 22:33:29 -0800 (PST) MIME-Version: 1.0 References: <20190129195214.30272-1-sxauwsk@163.com> <2019021615501780626817@163.com> In-Reply-To: <2019021615501780626817@163.com> From: Shubhrajyoti Datta Date: Mon, 18 Feb 2019 12:03:18 +0530 Message-ID: Subject: Re: [PATCH] i2c: cadence: try reset when master receive error interrupts To: "sxauwsk@163.com" Cc: "michal.simek" , linux-arm-kernel , linux-i2c , linux-kernel , Shubhrajyoti Datta Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi , On Sat, Feb 16, 2019 at 1:21 PM sxauwsk@163.com wrote: > > >Hi Sxauwsk, > > > >On Wed, Jan 30, 2019 at 3:13 PM sxauwsk wrote: > >> > >> When the adapter receive error interrupts, such as NACK, arbitration lost, > >> cdns_i2c_master_xfer return to the caller directly instead of resuming > >> the adapter which resulted in the adapter being out of control. > >> > >> So when driver detect err_status then try to repair and fix it. > >> > >> Signed-off-by: sxauwsk > >> --- > >> drivers/i2c/busses/i2c-cadence.c | 12 +++++++----- > >> 1 file changed, 7 insertions(+), 5 deletions(-) > >> > >> diff --git a/drivers/i2c/busses/i2c-cadence.c b/drivers/i2c/busses/i2c-cadence.c > >> index b13605718291..e10048d7524a 100644 > >> --- a/drivers/i2c/busses/i2c-cadence.c > >> +++ b/drivers/i2c/busses/i2c-cadence.c > >> @@ -548,10 +548,6 @@ static int cdns_i2c_process_msg(struct cdns_i2c *id, struct i2c_msg *msg, > >> cdns_i2c_writereg(CDNS_I2C_IXR_ALL_INTR_MASK, > >> CDNS_I2C_IDR_OFFSET); > >> > >> - /* If it is bus arbitration error, try again */ > >> - if (id->err_status & CDNS_I2C_IXR_ARB_LOST) > >> - return -EAGAIN; > >> - > >> return 0; > >> } > >> > >> @@ -617,13 +613,19 @@ static int cdns_i2c_master_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, > >> id->bus_hold_flag = 0; > >> > >> ret = cdns_i2c_process_msg(id, msgs, adap); > >> - if (ret) > >> + if (!ret) > >> goto out; > >> > >In case the Arbitration error happend the cdns_i2c_process_msg would return 0 > >and we will miss the check below. > > > >Am I missing something ? > > > >> /* Report the other error interrupts to application */ > >> if (id->err_status) { > >> cdns_i2c_master_reset(adap); > >> > >> + /* If it is bus arbitration error, try again */ > >> + if (id->err_status & CDNS_I2C_IXR_ARB_LOST) { > >> + ret = -EAGAIN; > >> + goto out; > >> + } > >> + > >> if (id->err_status & CDNS_I2C_IXR_NACK) { > >> ret = -ENXIO; > >> goto out; > >> -- > >> 2.19.2 > >> > >> > > In cdns_i2c_process_msg process, when detect arbitration lost error return -EAGAIN to cdns_i2c_master_xfer, not return 0 > that mean cdns_i2c_process_msg just go out ignore error check and problem occur, So we should do something when arbitration error detect. Arbitration lost is fine how about other errors like NACK.