Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2162668imj; Mon, 18 Feb 2019 00:51:09 -0800 (PST) X-Google-Smtp-Source: AHgI3IY8hwezg2snRZD1akOnuoXnRiRyNnClboKN/j1+nbZ44rHzs5yJ6tj07y1yKPSKrb/fQMWJ X-Received: by 2002:a63:374e:: with SMTP id g14mr18228222pgn.59.1550479869048; Mon, 18 Feb 2019 00:51:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550479869; cv=none; d=google.com; s=arc-20160816; b=anLukNJonvQ4m1tRfTFtRy6ARiJR3m4OUZtiMraSOg/gHRBS29hPDxFPGgZArFkI0m JpclfbVnlEcQZPIXUPiNZ12YFHMCTZIyQ/PTvDC4r3yf2LCMdUF3VsN8cFE6lvjW4wnm 1SuKYpw+sJETqRTY0oqAspRHZvog0exazxighOsyPbjBRseDNOeqL1GW6bFrQ6xC4pvS ta27n0VI4FtDEjR8tIbBAX0QIo9x5jp/vQ3o9+uhSth5U8PJhIEM/9GY6EpXpf4vP73c Dp8SRsvOVb3CERBxa2ZmwNdWiT8M0BpOQhmxIzRMOx1ZfqT1n3m6lit+OvtLCZ25kaPS Xi8w== 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=Dw9Pej+fnj+RHCbvYGdm4LntG421zy/HfA2jQFdBX1s=; b=Hyr13KNAmOMsd4bRHhAXc2icl7UCTfvcwEm4zmaamSf5OuWSlqq48Nd/a6+5UhF3Gv rKYDUpIoZ2IdMGGC2XH6y+yMatLpWuNGY40yi28Yi6BxnXSmhA1/DOxGqOSwnyBHJd4w mMkd1TzeYsJgB4FDiEwWIu4pThAbKRbGmnRRO09YQ+V8k9zW+9b1tLn+6ToBrpikPi/N z07hONMaR8W8rYoUUgsLxJiZWp7fCn5ysQoe3nWKFPKpZsgPyaVPZxbQE44b47iG8lZ8 Fghg+0UztXrRETL+PMLkXD46LuYe2+wy10yfleoTWlJoCX2zWnonmIaJRM6rg7DKAo2j RcPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b=R0lXaQnr; 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 l123si9672493pfc.187.2019.02.18.00.50.53; Mon, 18 Feb 2019 00:51:09 -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=R0lXaQnr; 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 S1729317AbfBRIpD (ORCPT + 99 others); Mon, 18 Feb 2019 03:45:03 -0500 Received: from m12-16.163.com ([220.181.12.16]:59705 "EHLO m12-16.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727423AbfBRIpD (ORCPT ); Mon, 18 Feb 2019 03:45:03 -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=Dw9Pe j+fnj+RHCbvYGdm4LntG421zy/HfA2jQFdBX1s=; b=R0lXaQnrUEhAqmUIPHD0R x5tVj7Fc81ch6i5iVScP9KwekP0BZk4ttB8N6GayMAA5z1FLMcesVvdORB9FGnga E8NVDPSnrtgRsGCZvMbSFaJDeSEgh7JOCgOueHg0o3qp3Bi5nNvCr3gEuV9l1lpu uWJjg/tsnKrHFFtpdENr+c= Received: from localhost.localdomain (unknown [202.100.35.16]) by smtp12 (Coremail) with SMTP id EMCowADXYgVvcGpc0qeTGA--.53770S3; Mon, 18 Feb 2019 16:44:33 +0800 (CST) From: sxauwsk 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 16:35:22 +0800 Message-Id: <20190218083522.4681-1-sxauwsk@163.com> X-Mailer: git-send-email 2.19.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: EMCowADXYgVvcGpc0qeTGA--.53770S3 X-Coremail-Antispam: 1Uf129KBjvJXoW7tr1xGw4UZr1DCr45ZF1fZwb_yoW8GFWkpa 1DGrZIkrW0qr1IqFs7Ar17ZF98uwsYga4jkr4Fk34DuF15Cr4DtFy3tF98XF4xCryrXrya qrZ8t39rG3W2vFJanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07j2xRDUUUUU= X-Originating-IP: [202.100.35.16] X-CM-SenderInfo: 5v0d34lvn6il2tof0z/xtbBZxFfJlettFNQqwAAsp 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: sxauwsk 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