Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp3059818imj; Mon, 18 Feb 2019 18:48:18 -0800 (PST) X-Google-Smtp-Source: AHgI3IY7nqCV6Lo2POV0IyCHNKxYscAEAqBA7GQIlbjmRFwGJ6tSiOJtOOcWhsRSDWcyzg8z4YOl X-Received: by 2002:a17:902:2bc9:: with SMTP id l67mr28777869plb.241.1550544497996; Mon, 18 Feb 2019 18:48:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550544497; cv=none; d=google.com; s=arc-20160816; b=ySoQCiOXujouVyrkA91tLJoGIuduriZF3KXcLt4js+bDY+Mhm7vgXs1j0rtllqemSA RIuCivE7jbRcSldWF8V7iOp3Tl3AtiHOWeJePNcZrQ3J6fxplc+7hfY4x7AwoYKoPDSS ++VMZbLv7IQUHLISLBETtuGa64DD8Uh+5dGBx6xyPumByJXhR6VmpgXVkRTykAHK5jJ0 dZ4ll32FenRLr4PVWc2ByssYaBIO0roleEFymBe45EOb4GnWNIguLu+DkoamuK+mW0/e xsTRj0yVwyU42szWNZjJ9d190eSrvM7C4TCNllHm0UIyQJeQhKtLjuXKZuWTYFemnjh/ 9Q5w== 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=vJOxliD3ylQNF+bK3c+e1E/IPoF2RmPsUHSYa4f68G4=; b=zQWNKgRvjDKQyVC+hcrv7lXpHmvtg46dpIPQKz907nAgs3rOdOBdvypYwW9GW86aXq fxHb2nRRk+60cycjHpY2oYLrm49fMBt2yNqPxYJ8YgrQCkp2VHS/3bIZ1WpvxUQ0mA4/ v6XOZt6hQfIILNVaWWS3bOEjnWtdQV1MSdTvxyMo0sUOP7FtY36jdObcNyQ0r6xvgjHC Kynh9wtBkIBkzqJ15ruGrLQVSSyfJbNRr6HQrg0VIkCfkOqkGFnL6d2Howq2YjBWdImk SYH1+LPoo4Vf5M4uSYxkIrjX0OFN+1OlFpp2laRJMrcWXFrLrWg8KqaDaKuSavZRUI9Z vQyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b=MRTuwdl5; 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 p7si14641210pgp.284.2019.02.18.18.48.02; Mon, 18 Feb 2019 18:48:17 -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=MRTuwdl5; 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 S1732766AbfBSBeS (ORCPT + 99 others); Mon, 18 Feb 2019 20:34:18 -0500 Received: from m12-12.163.com ([220.181.12.12]:38987 "EHLO m12-12.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730247AbfBSBeS (ORCPT ); Mon, 18 Feb 2019 20:34:18 -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=vJOxl iD3ylQNF+bK3c+e1E/IPoF2RmPsUHSYa4f68G4=; b=MRTuwdl5hca/5724t3b7h Dr4LnqeBtUejGLE3FLMPjrnSDFE6WlxYKdmkKEBXyDrzZ9jcRIA4oPda3nQqtHIk QxTdlSzkMwEIxZtXJ7j0abGg+7jzZXdI7OshAkJaP6+Lzssht9u8AcVH1ngs3FoR ggyP35j3nDDxE0Prw/iT4w= Received: from localhost.localdomain (unknown [117.36.119.220]) by smtp8 (Coremail) with SMTP id DMCowAC3NM4CXWtcMmt4GQ--.10745S3; Tue, 19 Feb 2019 09:33:55 +0800 (CST) From: Shikai Wang To: Michal Simek Cc: Shubhrajyoti Datta , Wolfram Sang , linux-arm-kernel@lists.infradead.org, linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, Shikai Wang Subject: [PATCH v2] i2c: cadence: try reset when master receive arbitration lost Date: Tue, 19 Feb 2019 09:24:47 +0800 Message-Id: <20190219012447.5900-1-sxauwsk@163.com> X-Mailer: git-send-email 2.19.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: DMCowAC3NM4CXWtcMmt4GQ--.10745S3 X-Coremail-Antispam: 1Uf129KBjvJXoW7tr1xGw4UZr1DAw17CryUKFg_yoW8Gw1Upa 1DG39IkrW0qr4IqFs7Ar17ZF98uwsYga4UKF4Fk34q9F15CrWDtFy3tF95XF4xCry5Xw1a qrZ0y39rG3W2vFJanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07UgTmDUUUUU= X-Originating-IP: [117.36.119.220] X-CM-SenderInfo: 5v0d34lvn6il2tof0z/1tbiQBRgJlSIZQ4tnwABsW 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. Reviewed-by: Shubhrajyoti Datta Signed-off-by: Shikai Wang --- 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