Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp5686067imu; Wed, 30 Jan 2019 01:43:10 -0800 (PST) X-Google-Smtp-Source: ALg8bN4VCyRYHL1S0Is1rDOW6M7M4NHgJR+8FIkOrDaRUsFxy9COoMbhubSVY9znfvdKYERcfDKP X-Received: by 2002:a17:902:a5ca:: with SMTP id t10mr29524443plq.139.1548841390730; Wed, 30 Jan 2019 01:43:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548841390; cv=none; d=google.com; s=arc-20160816; b=AgJhr3rReJyzgBTMdVHh6L/yNfoUq1tp5BvRW+q0cFDeXwyeVeQHcxQ9XakQ/TylAm /7nx6DTUnrfwLtGuZSXuovkXcYc6PAqXczTt3HkSy8WTij+jSn8c01kXGW9ydjuczbLh gDYGMNQUu9Acg/WM2Kz0q3BUc4Nf6TbLIyVMntLw9MmhzhiNmXnY7DzVer2BhCh49EZR C7wZmcKVAxnZgsMpVSt9GEVjsIbkK/iLvAVkB821RuS8FG8xLwT5Bw2r+nzwHV83CyMs 7RRfRpV6P+HENJNRyQcyQXZfgxpa0S7qOhzGzBcEWxavdTJ+LgFiCGzGw4+ELm82OBxF pFBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=hBdMeYqWOgwoCMrt5lUW7Gyey2VQfeeIjvvw5BlxhRw=; b=b7fBJrrzFqA2RE9H7is0MQ0wXRyjbv6HPPnW2E3/VO3zQuLdulpTHBl9yBq5cBjr6l OT2HR9iPqXn2LMkRyxWLiZs5Pyq4hiyHyZgn8Jt2vm0vlzvfaWmpRDrQPKqyW59ZECPV OmfsnWbl4XeLGLBoJjlDzfdbK8OcTUnFI+xBavZj9rOsVmXQuyAvOB6iAUMWIoNt0vm/ NcG6oSYWYBiF0k+pqej7D5ftPlcrKVTHnr76vUnzxSPRlDwrhMIzJlbJ6fOvqMx+TWSI 8HZYChrV4RJ/bVAXz8hnjoytdg4KVF+Wuvvb8ErGthhwNDxT+OPu5YuDsq80K17zI6qL m9OA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b=Wf9CoRoA; 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=NONE dis=NONE) header.from=163.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b24si962264pgi.308.2019.01.30.01.42.55; Wed, 30 Jan 2019 01:43:10 -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=@163.com header.s=s110527 header.b=Wf9CoRoA; 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=NONE dis=NONE) header.from=163.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730279AbfA3Jmw (ORCPT + 99 others); Wed, 30 Jan 2019 04:42:52 -0500 Received: from m12-11.163.com ([220.181.12.11]:54395 "EHLO m12-11.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726406AbfA3Jmv (ORCPT ); Wed, 30 Jan 2019 04:42:51 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id:MIME-Version; bh=hBdMe YqWOgwoCMrt5lUW7Gyey2VQfeeIjvvw5BlxhRw=; b=Wf9CoRoADJFNPfxz+Gar+ wodcD1wPp40pjrZLquHUpiBzxSE23+KeuMu5dq06AFG90KZfkZC0MiRHPyhw62SB FYWmh66kuDbeYdhhbUL0d0LLq6sURGQJh+Bg+ie5Toy6E9pZ5J0lGnvWiCObW94J t3N6jCgFfbkKNSEhfHgBxk= Received: from localhost.localdomain (unknown [117.36.119.152]) by smtp7 (Coremail) with SMTP id C8CowACnVnuOcVFc23h4Dg--.63966S3; Wed, 30 Jan 2019 17:42:39 +0800 (CST) From: sxauwsk To: Michal Simek Cc: linux-arm-kernel@lists.infradead.org, linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, sxauwsk@163.com Subject: [PATCH] i2c: cadence: try reset when master receive error interrupts Date: Wed, 30 Jan 2019 03:52:14 +0800 Message-Id: <20190129195214.30272-1-sxauwsk@163.com> X-Mailer: git-send-email 2.19.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: C8CowACnVnuOcVFc23h4Dg--.63966S3 X-Coremail-Antispam: 1Uf129KBjvJXoW7Ww1rXrW5AFy5Jr1UZryfXrb_yoW8XrWkpa 1UG39IkrWIqF4IvFs7Zr17ZFy5uwsYga4jkr4Fk3sruF15Crn8Ka43tF98WF4xCry5X342 qrZ8t39rG3W2vF7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07Uoc_hUUUUU= X-Originating-IP: [117.36.119.152] X-CM-SenderInfo: 5v0d34lvn6il2tof0z/xtbBZA9MJlQHDeqMrgAAsX Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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; /* 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