Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2212276imj; Mon, 18 Feb 2019 01:54:43 -0800 (PST) X-Google-Smtp-Source: AHgI3IYC08AMW4f+WP1VLpPkRb9uWxCNj16CZNmXUvY6Di9AIc+2J3RcE+I3lBGjDdYpqUYcYQuE X-Received: by 2002:a63:2bd5:: with SMTP id r204mr18381714pgr.48.1550483683370; Mon, 18 Feb 2019 01:54:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550483683; cv=none; d=google.com; s=arc-20160816; b=WV1HUPSjq2rXTxZSd4XoqcESFa5vsuW7iL8GieGRLmoVba0ygsCWbNySW9eT0KIcDb aLk5ufF0U9AuSmNvXKpW7OEt2eYf0iMcWBzQmB7GnSOdKk+QNWvSWjbVLGtefIJ5Atjs tAUZYoizpidqzJ+DWhhRub7J/TZAZDdjsntnMRmHHuye46wp0GBP/ReZjmDWKZUBCjD2 yAWc1/yfHTEcyloWL+EtFu6LfQ/GL9wAeAW9i3QUhMO1uum6+vUJLq69Re6q1B+bq7Wi f0HHl6zEns0kE6qKctAou6zGgq4e5++7dlJTu7kAjV1cKz53Ij6ei/yQSd43422Ggl+u coEw== 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=P2vcV6f8loVaf/ZIiX2dpDXisvZU04xacdx/G8A6NQo=; b=wuzeCqBq7NU0YKfmj9tVXaSYKXfdUypGcmnFDyK7uJpunFK5ixVXWOTNIUZMl6aJUJ a+OsKiwBJ001lqyh1AcMqWbw2Og3uMDP7NREXxykGK07Z9IgjBcVRBH5yx89wiRBeZ67 3WzyjzwlsgseSaddP6JCNR5l0PBMYASS+hpfwJBaXqJ6mc82TGTjfnntZFWmCzWjJxRs PTUqszxXAVquK0OuyznSmCKKgAfHntr5yf6Kl/Guyj4Igj39pNHv7VsUV8YpdWk1KNQn 9UiKglKT11opu92ZpjyQwA7c63chwD52aqy+8YnhfXuLKgKWOO51jZiVIcIQu6xxJNdz EKCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b=HoXJ+lXF; 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 f10si13400905plo.53.2019.02.18.01.54.27; Mon, 18 Feb 2019 01:54:43 -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=HoXJ+lXF; 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 S1729467AbfBRJur (ORCPT + 99 others); Mon, 18 Feb 2019 04:50:47 -0500 Received: from m12-14.163.com ([220.181.12.14]:57787 "EHLO m12-14.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727423AbfBRJur (ORCPT ); Mon, 18 Feb 2019 04:50:47 -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=P2vcV 6f8loVaf/ZIiX2dpDXisvZU04xacdx/G8A6NQo=; b=HoXJ+lXF3jE+cgyInkc8G GC/NTw6YVxqDMdPLEt3vzoSAaMvSL04q8gBvDZ0n8qR4wzS3wJzmrvM19VLqs+4H GhU0Iq0xiklmAImmaw+LTX0YNVMAZ0t+C3HWRoz4dXHqEqj6pFNqIrf00kx0Nusk Q2u2yl4bJtbviuES75Iu9I= Received: from localhost.localdomain (unknown [202.100.35.16]) by smtp10 (Coremail) with SMTP id DsCowADnYA_vf2pcFKt1GQ--.1550S3; Mon, 18 Feb 2019 17:50:40 +0800 (CST) From: Shikai Wang To: Shubhrajyoti Datta Cc: Michal Simek , 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 arbitration lost Date: Mon, 18 Feb 2019 17:41:32 +0800 Message-Id: <20190218094132.5226-1-sxauwsk@163.com> X-Mailer: git-send-email 2.19.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: DsCowADnYA_vf2pcFKt1GQ--.1550S3 X-Coremail-Antispam: 1Uf129KBjvJXoW7tr1xGw4UZr1DAr4rKFy7trb_yoW8Gw15pa 1DGrZIkrW0qr4IqFs7Ar17ZF98uwsYga4jkF4Fk34q9F15CrWDtFy3tF98XF4xCryrX34a qrZ0y39rG3W2vFJanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07jc_-PUUUUU= X-Originating-IP: [202.100.35.16] X-CM-SenderInfo: 5v0d34lvn6il2tof0z/xtbBzxBfJlaD1XcVlAAAsQ Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When the adapter receive arbitration lost error interrupts, cdns_i2c_master_xfer return to the caller directly instead of resetting the adapter which resulted in the adapter being out of control. So when driver detect err_status such as arbitration lost, then try to repair and fix it. Signed-off-by: Shikai Wang Signed-off-by: Shubhrajyoti Datta --- drivers/i2c/busses/i2c-cadence.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/i2c/busses/i2c-cadence.c b/drivers/i2c/busses/i2c-cadence.c index b13605718291..595b0d56ff1a 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; } @@ -624,6 +620,12 @@ static int cdns_i2c_master_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, 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