Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2670064imj; Mon, 11 Feb 2019 06:47:13 -0800 (PST) X-Google-Smtp-Source: AHgI3IanR4kVN+uKcSLEd7Reh9b/zVAqvbB9qfN/kR4syKocs9otri8n9InnYxCzz4Usm6gul9dq X-Received: by 2002:a63:5717:: with SMTP id l23mr19053321pgb.62.1549896433072; Mon, 11 Feb 2019 06:47:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549896433; cv=none; d=google.com; s=arc-20160816; b=t7c1/OhqQJekw4JTfAIsaDBosDlqkIU8Hpd96eYQ/bVeekKKGihLc73rpMFFPeKxy9 vAvtDAcNbJerlu8S2/5SVWVMOEowjoahHdOEn/3ZYWt37xQIQa3gZupZARU7BFXAxr36 NsY3vzLF6S4tIl7P782vLsHcDczhdbq0KcW9GLy5b7m2vbQdjtRbW2nWzfXmDnidBZbH i+89e4iAbUTluL70Kf5fKD4wazpKOswxIcAKdU5Zm1pOAox5PcBGzvlERtWAo06+8/Tm wBWzTY/6j53OkZLkALPJovf5/fsMdQEITloGNhrQTeu0gkMdzYHJXtey16lDwhkAWbuM nOSA== 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=x2pw//zhhzxS/S9yUhcHkJ+oGhenr1BwlinN4DxyndU=; b=p5ravcF4GSUCKdenm16LdawZbTZBeATrdcnppWOKK2eSgimdEyFVMA+du923zpQcYQ LPuFvBXJtuXYHAR6hMm9gZQcrAjHcsaYDYBg1Iyg9k/s2GpRZwrmHSuz5TnAlnCSEmI4 C6mzoz1l9sURr3x8/42LFnjNiIy1P6MnbkfFytyMWa4pezxCsFhdkV6MxpryQYm0FVLv QN9WxFSPXkkfaQyaNDfP2lhxU0gqLftK+pZm6t8rHKH3eiDrZ8W+dYrKhqnzPp4QWrjT Gkg9l4v73iLieNQAoeketeL3FMQEX7L5MJHS8QxUcQ6WuBXrybHVNXDRF76cm6gW4Kkw OvMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=MIq+lIMg; 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 n3si10242058plk.328.2019.02.11.06.46.56; Mon, 11 Feb 2019 06:47:13 -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=MIq+lIMg; 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 S1732900AbfBKOop (ORCPT + 99 others); Mon, 11 Feb 2019 09:44:45 -0500 Received: from mail.kernel.org ([198.145.29.99]:57554 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729322AbfBKOom (ORCPT ); Mon, 11 Feb 2019 09:44:42 -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 9EC32206BA; Mon, 11 Feb 2019 14:44:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549896282; bh=0TIwNSfn+p0YsXml0HoJefodb+QEn2wHXHq/YxwFRLg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MIq+lIMgHseprzjpo+Hch1lMC90DpP6nIaoCFgiNex+yZFh+yxHLy8C9qC0EcIixg lQM+KGQLxDqG28nKcR5twAmj2CSUJMpZNGv65B7BunN+hMfOegc3Lq8JOsuBg6Y2CR rgvBYdW2BJ1xks2qOabtcBt+GjdIxK1qJ9RZpS9o= 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.19 133/313] i2c-axxia: check for error conditions first Date: Mon, 11 Feb 2019 15:16:53 +0100 Message-Id: <20190211141902.593321900@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190211141852.749630980@linuxfoundation.org> References: <20190211141852.749630980@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.19-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