Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2046997imm; Mon, 16 Jul 2018 00:51:54 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfrCmhBdrwA4UDmPR8vfOIhbevRPUb9hlLmvosAZiRGwETD0za58Nqu5AR3Pz9H1t/y5z8M X-Received: by 2002:a63:ba10:: with SMTP id k16-v6mr14769693pgf.145.1531727514123; Mon, 16 Jul 2018 00:51:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531727514; cv=none; d=google.com; s=arc-20160816; b=GT0OG54GxBa4DcPBPj78UAwdfLhCRXSOLpJvkLYahvIBQgWlPUEMAmIUtAa8onilnC 4aXyHtZ6T+tPhPISqtzXpUrowCOO3S6Cc+UcRJS0BzB6Tz15YSUBY+WXQy/pw0IFRKGa wFN88a3ecEqY8kDU5nsGOihu5dQpO6XxX6q7d9g0+zwirU0zawCwpDMj7sMrFDmfDKAF KVYuMIjrexrKiefHNg7fMxtos4BBDBi1uDxtgKK3fGoEaHzN0LioQ7BwXh8u0AGVySiP tfgcrr1O7SVrJixJeuQdA0CVfYuyMMvJpogx5qZ9vqNvVEn4ea19psU8F/NsY2PxpmBb E3OQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=6s4OUXDZgX6fQ3CiYsdAewV97NHaq+SVFin4yzurJng=; b=YYS3Mmepfjwn8eab1ThSULcRjaNZnNYQY9zuBRrsFlsRlDiAYGDsy2HXrI8HxHOox7 oyfl89o8YGSDMtXWVdv3Z1cyVVVNUV5VsCLTdiydEMAd5c1YDIBIpr0w1JdQ2GeXj5cP lHjzjaDKOhEYhRhbYLqOqSNaDJ7govVn2dERdW/Oc86QBMSaFfvGQmtvS9HdfMBRZLn7 tPy3sqJ1448sYi5z8xo8pH+4Z1pSYqyWbwHVaIz4L0/JeybzjX9kSO0oZuncfoAHrtD0 amDiUT7923FSVXS1QspotUyZKo4oarOqmD6qKsDXnrpZlzwkaFhMKfTtqRm4vlzKUGyX bz6Q== ARC-Authentication-Results: i=1; mx.google.com; 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 v129-v6si8184038pgv.610.2018.07.16.00.51.39; Mon, 16 Jul 2018 00:51:54 -0700 (PDT) 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; 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 S2388924AbeGPIJG (ORCPT + 99 others); Mon, 16 Jul 2018 04:09:06 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:47916 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730161AbeGPIJF (ORCPT ); Mon, 16 Jul 2018 04:09:05 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 930CBCA4; Mon, 16 Jul 2018 07:43:02 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jon Hunter , Thierry Reding , Wolfram Sang Subject: [PATCH 4.9 23/32] i2c: tegra: Fix NACK error handling Date: Mon, 16 Jul 2018 09:36:31 +0200 Message-Id: <20180716073507.436974213@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180716073504.433996952@linuxfoundation.org> References: <20180716073504.433996952@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jon Hunter commit 54836e2d03e76d80aec3399368ffaf5b7caadd1b upstream. On Tegra30 Cardhu the PCA9546 I2C mux is not ACK'ing I2C commands on resume from suspend (which is caused by the reset signal for the I2C mux not being configured correctl). However, this NACK is causing the Tegra30 to hang on resuming from suspend which is not expected as we detect NACKs and handle them. The hang observed appears to occur when resetting the I2C controller to recover from the NACK. Commit 77821b4678f9 ("i2c: tegra: proper handling of error cases") added additional error handling for some error cases including NACK, however, it appears that this change conflicts with an early fix by commit f70893d08338 ("i2c: tegra: Add delay before resetting the controller after NACK"). After commit 77821b4678f9 was made we now disable 'packet mode' before the delay from commit f70893d08338 happens. Testing shows that moving the delay to before disabling 'packet mode' fixes the hang observed on Tegra30. The delay was added to give the I2C controller chance to send a stop condition and so it makes sense to move this to before we disable packet mode. Please note that packet mode is always enabled for Tegra. Fixes: 77821b4678f9 ("i2c: tegra: proper handling of error cases") Signed-off-by: Jon Hunter Acked-by: Thierry Reding Signed-off-by: Wolfram Sang Cc: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman --- drivers/i2c/busses/i2c-tegra.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) --- a/drivers/i2c/busses/i2c-tegra.c +++ b/drivers/i2c/busses/i2c-tegra.c @@ -547,6 +547,14 @@ static int tegra_i2c_disable_packet_mode { u32 cnfg; + /* + * NACK interrupt is generated before the I2C controller generates + * the STOP condition on the bus. So wait for 2 clock periods + * before disabling the controller so that the STOP condition has + * been delivered properly. + */ + udelay(DIV_ROUND_UP(2 * 1000000, i2c_dev->bus_clk_rate)); + cnfg = i2c_readl(i2c_dev, I2C_CNFG); if (cnfg & I2C_CNFG_PACKET_MODE_EN) i2c_writel(i2c_dev, cnfg & ~I2C_CNFG_PACKET_MODE_EN, I2C_CNFG); @@ -708,15 +716,6 @@ static int tegra_i2c_xfer_msg(struct teg if (likely(i2c_dev->msg_err == I2C_ERR_NONE)) return 0; - /* - * NACK interrupt is generated before the I2C controller generates - * the STOP condition on the bus. So wait for 2 clock periods - * before resetting the controller so that the STOP condition has - * been delivered properly. - */ - if (i2c_dev->msg_err == I2C_ERR_NO_ACK) - udelay(DIV_ROUND_UP(2 * 1000000, i2c_dev->bus_clk_rate)); - tegra_i2c_init(i2c_dev); if (i2c_dev->msg_err == I2C_ERR_NO_ACK) { if (msg->flags & I2C_M_IGNORE_NAK)