Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2762291imj; Mon, 11 Feb 2019 08:06:27 -0800 (PST) X-Google-Smtp-Source: AHgI3IbgtLZPv1g02k5RNQMP/3wYXdmAXfBgzs56O0V2Kx8H+/egYk0INaKDMdYVXA3rAxv5WpHl X-Received: by 2002:a62:12d5:: with SMTP id 82mr11576897pfs.255.1549901186939; Mon, 11 Feb 2019 08:06:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549901186; cv=none; d=google.com; s=arc-20160816; b=YWRJZCpbh4Bwrgz7Iudgm3ZxYjHFDjxHrRqclsR6aQZmTTzIzZTG2Pd+DA14oZIylq Nl57ognXhrXGjO1IlVN6XpXZyk8eEjfCrcVDeQ4enkFT1C+Nl1LjB7yCOt6UwcHF5+hM mQ/ltaw9P7wYqqiYW+jFG8euMqJJ/RX3zxlUhX9ZnTml2D18MkORRDVpZzHSxtmCQpvk JdauEdu30Vrrmk2DvGmtYwmx6nKwAI9eHvoFwG9JqvCrIY3IDRr1+XyjEvB82KLi2JL/ qpwM/WKs7ZFMFFivZ9zgJQgqm7e8Twm6dapAGYh94E37V7bX7vtJ1TTeyGrs3eLAs4Na qm/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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=fcVXFxusJsaBctvkZz3djeTTi3xM25u3LriHRvyeHsI=; b=uMDRBanKUJzr3zLM/SbRmrraKAGmdABCxXPbSOa0EtfebhSS2ZLl1afCCpAJY0Hwqa +i0mzeFA5isUTn1OoT2+BuUIL8qL65pyiGjpKNkySaEA/2ohM5VZ3xhPmo3KFpm0SwG7 R0Gdg6fvarsXtludyyqpqOWhLpTILUjGzVOvc7myDKH271woPRlasxiO9Wpxb0N2i/Gj 9jekalP0KUjq79Uj65PNmYhO4RxUn/DuJqF2Ts+/I//ROpWaDbMnQOSN6JYnLc/lDquv Y9wP9uavsiY/M5iW1XaDMuzeWQbnlNqP8VUyRkvba+A6bHt4ehHcSF6ndY3yxBmj9/9g eHGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=DdaGbrcT; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u129si10336772pfu.117.2019.02.11.08.05.56; Mon, 11 Feb 2019 08:06:26 -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=DdaGbrcT; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729822AbfBKO2P (ORCPT + 99 others); Mon, 11 Feb 2019 09:28:15 -0500 Received: from mail.kernel.org ([198.145.29.99]:33992 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729799AbfBKO2F (ORCPT ); Mon, 11 Feb 2019 09:28:05 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 200AF20821; Mon, 11 Feb 2019 14:28:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549895284; bh=QqYLDnFkKbCcIisn7oG1nwxHsQvJUaMh11YeTUREB9s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DdaGbrcT6dC29tecDhqSAQOTQ1cwXQgRfdaUepbXhYH65L4+jpqTtLWlryYjdjSqi bDpPArsx/9yInwq7Z4zKzFc2EgsjMYXRsxpjuk6OJ3PH3frlVdx479a1BwwhN0GIJX ag3Rk0Gxg/eTaO6HLGYJo6zjn0WFNWJbocIwWRVc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Krzysztof Adamski , Alexander Sverdlin , Wolfram Sang , Sasha Levin Subject: [PATCH 4.20 155/352] i2c-axxia: check for error conditions first Date: Mon, 11 Feb 2019 15:16:22 +0100 Message-Id: <20190211141856.610062789@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190211141846.543045703@linuxfoundation.org> References: <20190211141846.543045703@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.20-stable review patch. If anyone has any objections, please let me know. ------------------ [ 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