Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3704070imu; Mon, 28 Jan 2019 09:19:14 -0800 (PST) X-Google-Smtp-Source: AHgI3IYl/RgMpLesEENRqqDDIRaeEd6BiwLA3HZH9SZuyIYVJEMSUBLDXB2Osz+BqZC+MIRv4E6B X-Received: by 2002:a62:4618:: with SMTP id t24mr5385880pfa.139.1548695954374; Mon, 28 Jan 2019 09:19:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548695954; cv=none; d=google.com; s=arc-20160816; b=wIHSP2A4vGHUShpsmkEO6+UMwjhoHDWDokZW+QD5pX+cuoTe98o3JJwECOShEKrwS6 /X7u01DtoJjqf/2f8k4ZyFHcN9t/kmjjy8GptzKSNhO/hmp62yPsHQYAw693gmxPYulY yiwu4AM5AUUpxfpLDH92x+3KZgYCLg8xYhEvUSZMj7ZTqM3tv8KzdOlT5IwBb3YOkbHo J79/tKRdQF6unG4uIYOGl2ucRdwBkA3Za8sgd4aVwvpgikLi2jzYGXRD/rGVkX/qJjQU pObAO43u7O+38dAqPHlVz+12PeACnnq9+5zGj4ETUbVrDVc1qGjQ/S/AQkzwO6ywalv6 Di/g== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=iuCluL3BbExkcZwIKnPtTw03Mkm0nZFM4zPIrRVQGjs=; b=pAGAgdpUTM0x1Sum2WgFDC87wWN6XK7/iW8sE1ok8o1q8ThMCrPXzXZsPodK2AmOx1 COH1JBPTmMTA530C6bO02wy/dEzFjh1h2rKwXxbVlDILPJXd0lsh5H568AeeBCHg1GhI hLJXC39IRC60ixX1ztyE+N25BXzlNGOaxo33z3qkEpEiWQsbYh/2kXbbaQ3nZLWVvJrj aipJK7fyfCO/W210DXX538IucvqVoZkGoucwX/icgKSHBYsTdItxz0pfEn43xXAMmfcL 8/Sny4xeCMvOInNTEc+KgcI9iNUYKofU//V0ZhvrlHu1kbK3e9b712eKbpoXZQ+gb8Sf CgGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=C27JsvK+; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a5si4782457pgg.120.2019.01.28.09.18.58; Mon, 28 Jan 2019 09:19:14 -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=@kernel.org header.s=default header.b=C27JsvK+; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732250AbfA1RRI (ORCPT + 99 others); Mon, 28 Jan 2019 12:17:08 -0500 Received: from mail.kernel.org ([198.145.29.99]:53848 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731440AbfA1QF7 (ORCPT ); Mon, 28 Jan 2019 11:05:59 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 985A42171F; Mon, 28 Jan 2019 16:05:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548691558; bh=IYFWtsPiA/H/kYCsgZU763bveExVKt/n42NU/WHNgd8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=C27JsvK+ugijmZtoghB9fl4SlO/qsmsxwphjsGPM/FtjMSDIgXLWp7d8uOYH9iByK hNVTtNbeX4kTZfZvIV0kE+EcGrAW2VzL1Sk3Vra8OIhyx6tW0oHJFiAsNgb7DhKdvA HrHkbdIKhG3OwiVse4g1gDOShwIniSACoYPrQM1w= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: "Adamski, Krzysztof (Nokia - PL/Wroclaw)" , Wolfram Sang , Sasha Levin , linux-i2c@vger.kernel.org Subject: [PATCH AUTOSEL 4.19 141/258] i2c-axxia: check for error conditions first Date: Mon, 28 Jan 2019 10:57:27 -0500 Message-Id: <20190128155924.51521-141-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190128155924.51521-1-sashal@kernel.org> References: <20190128155924.51521-1-sashal@kernel.org> MIME-Version: 1.0 X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: "Adamski, Krzysztof (Nokia - PL/Wroclaw)" [ Upstream commit 4f5c85fe3a60ace555d09898166af372547f97fc ] It was observed that when using seqentional mode contrary to the documentation, the SS bit (which is supposed to only be set if automatic/sequence command completed normally), is sometimes set together with NA (NAK in address phase) causing transfer to falsely be considered successful. My assumption is that this does not happen during manual mode since the controller is stopping its work the moment it sets NA/ND bit in status register. This is not the case in Automatic/Sequentional mode where it is still working to send STOP condition and the actual status we get depends on the time when the ISR is run. This patch changes the order of checking status bits in ISR - error conditions are checked first and only if none of them occurred, the transfer may be considered successful. This is required to introduce using of sequentional mode in next patch. Signed-off-by: Krzysztof Adamski Reviewed-by: Alexander Sverdlin Signed-off-by: Wolfram Sang Signed-off-by: Sasha Levin --- drivers/i2c/busses/i2c-axxia.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/drivers/i2c/busses/i2c-axxia.c b/drivers/i2c/busses/i2c-axxia.c index 51d34959709b..fb5bac079e83 100644 --- a/drivers/i2c/busses/i2c-axxia.c +++ b/drivers/i2c/busses/i2c-axxia.c @@ -296,22 +296,7 @@ static irqreturn_t axxia_i2c_isr(int irq, void *_dev) i2c_int_disable(idev, MST_STATUS_TFL); } - if (status & MST_STATUS_SCC) { - /* Stop completed */ - i2c_int_disable(idev, ~MST_STATUS_TSS); - complete(&idev->msg_complete); - } else if (status & MST_STATUS_SNS) { - /* Transfer done */ - i2c_int_disable(idev, ~MST_STATUS_TSS); - if (i2c_m_rd(idev->msg) && idev->msg_xfrd < idev->msg->len) - axxia_i2c_empty_rx_fifo(idev); - complete(&idev->msg_complete); - } else if (status & MST_STATUS_TSS) { - /* Transfer timeout */ - idev->msg_err = -ETIMEDOUT; - i2c_int_disable(idev, ~MST_STATUS_TSS); - complete(&idev->msg_complete); - } else if (unlikely(status & MST_STATUS_ERR)) { + if (unlikely(status & MST_STATUS_ERR)) { /* Transfer error */ i2c_int_disable(idev, ~0); if (status & MST_STATUS_AL) @@ -328,6 +313,21 @@ static irqreturn_t axxia_i2c_isr(int irq, void *_dev) readl(idev->base + MST_TX_BYTES_XFRD), readl(idev->base + MST_TX_XFER)); complete(&idev->msg_complete); + } else if (status & MST_STATUS_SCC) { + /* Stop completed */ + i2c_int_disable(idev, ~MST_STATUS_TSS); + complete(&idev->msg_complete); + } else if (status & MST_STATUS_SNS) { + /* Transfer done */ + i2c_int_disable(idev, ~MST_STATUS_TSS); + if (i2c_m_rd(idev->msg) && idev->msg_xfrd < idev->msg->len) + axxia_i2c_empty_rx_fifo(idev); + complete(&idev->msg_complete); + } else if (status & MST_STATUS_TSS) { + /* Transfer timeout */ + idev->msg_err = -ETIMEDOUT; + i2c_int_disable(idev, ~MST_STATUS_TSS); + complete(&idev->msg_complete); } out: -- 2.19.1