Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2434783imj; Mon, 18 Feb 2019 06:03:06 -0800 (PST) X-Google-Smtp-Source: AHgI3IY9YxDA0zL5wWo/jA0esX04YocfG/Cj2Iwm+HbW8BXF3zQmMe9ZTRhkEOXu91dHpDwJhBDR X-Received: by 2002:a62:221a:: with SMTP id i26mr24113735pfi.174.1550498586041; Mon, 18 Feb 2019 06:03:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550498586; cv=none; d=google.com; s=arc-20160816; b=OuWAemBojL33fu1LbDAodDEBHaVhcn0tF5ziPgpLgFChcWv8T715xBv7+a8hMj0a4D iK0Vg8uN1bavSrrC2i0pL9SYnf4lkkC+pIfKiJ6mm7qracM4mzpcRr4YrWVjI4rI8p7G AG03uIJCy9FD0YKtqcuLhj9eiMHAXk+Imxfih2TPgaQThTRSNydv6JCiwjrOkLzm9PeO xfxlCefcnIbdNhWtrf71ubOVwBTeMobqx45rNUtx4LV2jYPXbTEQZqgGMbdzsn5AbDAF 1HobqGlrW8aeghwiODrAdSvvEVfsktJA4rtqaxL7VbFQ1Nij8ST7f5WbRQKR7cEmosVq bGTA== 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=Rdx/w8tcyP5TNlJhZgVA0RNg5w1nzddkPakWgJIpA7Y=; b=WheGXg0xq4BV7dRN2m6UsrFIaAsauStewJpLvxUtVNLVQfwUiDNHBJWfrUYzHOsE8K /rtJFk7fuSK3a/fmNkw0VneXDV+PIuUJPr0j1F2mZz/e9dC8z/9FevlEmdkxkYK4zURd sFNYoxoX8SIBZUjpr/J4BqsdmST7tVzNaFxYZ+OOqq1E7S0qMcJQUXVSDHOmuabFy1rv Q/+hKCvgkTACp6pHp0ApNyEsujtrEZTnuYZ/CA9qyeJYLsBJ1Gu1qolbDljw72SxhMYg dCea857DoxQWXXQORFvunU5PelQDglCZXdL3+LTzWyRrlt/nNACCJ0nDw+LPYAsO6Gw1 WLLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=QeZdYMJ9; 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 x16si12828356pgf.112.2019.02.18.06.02.49; Mon, 18 Feb 2019 06:03:06 -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=QeZdYMJ9; 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 S2388716AbfBROB7 (ORCPT + 99 others); Mon, 18 Feb 2019 09:01:59 -0500 Received: from mail.kernel.org ([198.145.29.99]:43502 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389209AbfBROB4 (ORCPT ); Mon, 18 Feb 2019 09:01:56 -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 170732070D; Mon, 18 Feb 2019 14:01:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1550498515; bh=fCBdobyvBHCq4jVjs7xcAC2o0V88TcUeaorbvya3q+c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QeZdYMJ9GKF3FiDxRefUOXl25wwTkA9Rlqg7k9gNbuc5D4zXA91xcsnzgW1gwZ2xS qNPwbOgZDr60Cxi4YDXpTGysA/c1s9yzsLwdzFH8QHtdLtK3paLGztYcSE4mWUX7SY BvC7pn0oGymY9nebWMXPSX22Q7RNt3CElxmP7QzE= 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.4 034/143] i2c-axxia: check for error conditions first Date: Mon, 18 Feb 2019 14:42:42 +0100 Message-Id: <20190218133530.381031191@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190218133529.099444112@linuxfoundation.org> References: <20190218133529.099444112@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.4-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 9c9fd2e87a4b..1c68b05c8649 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