Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2719461imj; Mon, 11 Feb 2019 07:28:25 -0800 (PST) X-Google-Smtp-Source: AHgI3IZxa2peME2LioNP0F6Q+v73e62PAcXaA6jjtpB0ZGWjrktax/ONGoYN0Ii3I1qg/X364nZV X-Received: by 2002:a63:5b65:: with SMTP id l37mr23394126pgm.395.1549898905171; Mon, 11 Feb 2019 07:28:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549898905; cv=none; d=google.com; s=arc-20160816; b=bGbktvGp280KVq11ghR9gGFioqLfFQcssVVe85GBXzdj2RWGixtNCOJ+LTi2MZjD2H LvR7ajv4Z7xE4IkA+syx7OY83yeY21ZGQo0dwrpjjwYrABu1HH/YkZpbS7u91JsP2+TN XC2g8+13DFB1EzQcdfyj7NgKGHaRNS0OhvLNYhryMNvVfyoCzlYYdSd2ZDiXiIMJcehK kWhRpNMf4qJbRd6u+9zbjveBLxi1tU3nxauLYBXoDqnciy8d5J2t+MzuX70nynAuvwg6 E/tYmsB3h5opqz/2N8UKX6gz2H+S8Pgw84yZk+PTSQ0e7xB8Xu0ZkEBrN+rq4Misv2An nlCQ== 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=hdCY6CMpbBfSYcKuL6Ok45RfgBw69PmnlItTdokZf9k=; b=qG91rzrTp0UykLNIDRYbT/wcu7Ul/g8USW+dkNYbaP5CMziTGdfie7Ci2Og+vmFwNe wzrWYhLUu8pL4uo524EYKQIJDHrVo4b1ms9q/J042saRbnKT9HuFFskRE6XL5mRsIb76 +JD2K54OaG4eeba/7rhY9xg32v6rjgCbZxDhnj1zG8AyFaM5/hVTpVdFt4CKmJmyBHgX s7mXdDjmz91cr+95sHRfXWKz+h5tqvaJUjMD3WRjju71Zlhas0IaNh5pN2wYnodmib9E bZDLIPW2N7LWQsKrKa1iFvfckPevObx5cDlBZSzPLgCpEeG617pI50yOOYsF8Rr2nP0Q mDmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=jt8l7RYt; 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 3si10993900pla.240.2019.02.11.07.28.07; Mon, 11 Feb 2019 07:28:25 -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=jt8l7RYt; 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 S2389813AbfBKO7c (ORCPT + 99 others); Mon, 11 Feb 2019 09:59:32 -0500 Received: from mail.kernel.org ([198.145.29.99]:47240 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389316AbfBKO73 (ORCPT ); Mon, 11 Feb 2019 09:59:29 -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 8912D21773; Mon, 11 Feb 2019 14:59:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549897169; bh=Tg/87bGqKQaaFjxFFDSi9lvKMTnuVxgCGghixjlTSco=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jt8l7RYtcKaZoFeLC5x5JfjZ9WIiT8xWiCy21fZiesmfc5O77yUH60XDbBWuZxY/F zkFiG0VFNg8nhlRowIM0NJGckYKsi7qvEB2OHgjDsBj4wLFqv3AfDxVYjNTMOfuJUl UMbbbEJyETejGp0B4lsdQFxI0dMCmCL4GpZaQldM= 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.14 086/205] i2c-axxia: check for error conditions first Date: Mon, 11 Feb 2019 15:18:04 +0100 Message-Id: <20190211141834.296081903@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190211141827.214852402@linuxfoundation.org> References: <20190211141827.214852402@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.14-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 deea13838648..30d80ce0bde3 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