Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2132994imj; Mon, 18 Feb 2019 00:09:11 -0800 (PST) X-Google-Smtp-Source: AHgI3Ib9jZO+h/wzhZjchF6PzuiLOepv76q8kEH1OhFQRnbqE0SdDDMX1jhfYo9wUMxQ7sdDrai4 X-Received: by 2002:a17:902:8641:: with SMTP id y1mr23930770plt.159.1550477351466; Mon, 18 Feb 2019 00:09:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550477351; cv=none; d=google.com; s=arc-20160816; b=mXJ/G6Hjxk1VHHuu9G5DPBI43IN+9ALMoLrC8ZiUn9+T9fmWIXahA4ztb5VgsOCs3c UD2g2FRlnvERIuVROFRqoR16sc4HcBCF+6+zPOjUXxgZHgjplv7Dt0ktv4vv2QONl0Kk lMbLrvR6BHfBM+PaiUk0bltsEgsUX69Wm2UrKnBatR7FydwthvmPgTGdiGNnM6QCN9Kz IHhwXkzzxbEeC7uXbsJ4z+OC6mfUdvemCBVO/mqCFmLg/sWa61CstigABGOx2qdsQ5cH B4tSJGAN4hkLrlBMbr7gGqW8YYC5gwlCiqWBZm64fCs3SKAwjz2utC8m8EbqmgiCJyI0 nSfw== 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=UFe9jHX1HoWKU6FMk5WMii4IqtK2zof/9fuLaWJERV4=; b=jwwqhW9VyL43RphX4hsnoaTdZrc9Fgt+998ypKHvYFS+AM/Vk4f7ZgzzPK0LElImel VZtpKydUXJioHwdjMUqpXSL3SMSbBm2IaKWxxIwuOX1X0ec2moZPjDEotJxRgKyT+FyY xvWTSyxhp50irtvYxK3Lji2s25YsuBJcNkmWgVnG+Yhn1Rlu/kTIZWj7D8KoCcjNJ/2O pN7wTKmgXRl4Zs3KrkxG2RoKgi1Kv/7PuAt7VKGepmCsREsUuVw8sagbTix3Xdp3C8du NfSF9RltlQ9XgMQakYdXaYQ4LR+R3GDoAX/C5FguzDXA3zFW4NQJlaemUvzmNW1nanjE D3pQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=HWBZCA5p; 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 u2si11959082pgp.592.2019.02.18.00.08.56; Mon, 18 Feb 2019 00:09:11 -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=HWBZCA5p; 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 S1728980AbfBRH70 (ORCPT + 99 others); Mon, 18 Feb 2019 02:59:26 -0500 Received: from mail-wr1-f65.google.com ([209.85.221.65]:46785 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727114AbfBRH7Y (ORCPT ); Mon, 18 Feb 2019 02:59:24 -0500 Received: by mail-wr1-f65.google.com with SMTP id i16so8957860wrs.13; Sun, 17 Feb 2019 23:59:22 -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=UFe9jHX1HoWKU6FMk5WMii4IqtK2zof/9fuLaWJERV4=; b=HWBZCA5pfGGENevoLmdMKxYCCXasF0r78JIHjqLOuLTtdQdw/g6i5Pg8FV0MSjfFnU SCUuacO6uSw1lzOqn4P+LQYDgf5ppcFBYO0ZACKVSI5PIsnVFVniQlWKhGTavSbbNmqn 02ag7wchNxBw7bxIhetlvvb1Em5PW55J0/v2obfTi/+Y6qozA9VIm9ktvPiLUcve7Ai+ 438saAYNPgr1ocPhyLhs5R6RpiwxTv5vUmvGOeWPi1E8S5psHCsf+JQbQ7bc17+8R02Q 1CfUgzXcsR2VGsIsqfdccUis9xU7PZc3g9V1HCTOc5p27JUva1f/85vUmBRExQ8apvS0 xsag== 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=UFe9jHX1HoWKU6FMk5WMii4IqtK2zof/9fuLaWJERV4=; b=cdi/F8Ov9n0CPRRUeqknP7MtKFGDUo+fy1P6JsfKbTaX5kTkIMoSAYWjKeNFve8hd5 YczYcpd3krcSaT7IqiOfp4C3P9vDr3+6aPsJiGNweSlI5rZANLOtVheQ50CCy1tMA5Lx f9OCfCqJ8MCGMpO8BGQXrdy13/M8I65H4vzSqk9mSjhL+/cIy5eciD3FnllZAqGPu/F8 brJf/jJCsjVbjDItXm7ZoCtTE8WmIBP/KuI7UTTdlSQEVZFTDjkSE7B7EqXDz4H0Zog/ RP7F2zxzjTqXNC9J2saysGLsVDSRJ/rxS5BOmDJhlDcvqBAgr8BgJriiKeh6+8NUfOrj Z2MQ== X-Gm-Message-State: AHQUAuYOzsnJ1CB3wd3K3l19U44HpHtUs/LDEh+huWDEwonE2wYovfh4 PLr5wrdOnIEjRu4pgHUoSI8zH+9XfsJD1s5Or19uqg== X-Received: by 2002:a5d:4147:: with SMTP id c7mr16597764wrq.235.1550476761629; Sun, 17 Feb 2019 23:59:21 -0800 (PST) MIME-Version: 1.0 References: <20190129195214.30272-1-sxauwsk@163.com> <2019021615501780626817@163.com> <2019021815163582329937@163.com> In-Reply-To: <2019021815163582329937@163.com> From: Shubhrajyoti Datta Date: Mon, 18 Feb 2019 13:29:10 +0530 Message-ID: Subject: Re: 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 On Mon, Feb 18, 2019 at 12:48 PM sxauwsk@163.com wrote: > > Hi , Shubhrajyoti > > >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. > > >> >> ret = cdns_i2c_process_msg(id, msgs, adap); > >> >> - if (ret) > >> >> + if (!ret) > >> >> goto out; > > Yes, you're right, This place I should't make any change, perfect solution! > > >> >> > >> >> - /* If it is bus arbitration error, try again */ > >> >> - if (id->err_status & CDNS_I2C_IXR_ARB_LOST) > >> >> - return -EAGAIN; > >> >> - > >> >> return 0; > >> >> } > > > >> >> /* 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; > >> >> + } > >> >> + > > Maybe Just remove Arbitration lost Detect part from cdns_i2c_process_msg function, then add to cdns_i2c_master_xfer, Do you think? I agree. > > > >