Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp8285273ybi; Thu, 6 Jun 2019 09:35:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqySheMB1iiK/SyUL64NuPX1MC6Rk4kQCVjWYcOHMM2fVgkz78tto9/VZIiqbYme0+e+xJj+ X-Received: by 2002:a63:1c10:: with SMTP id c16mr4317867pgc.442.1559838951114; Thu, 06 Jun 2019 09:35:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559838951; cv=none; d=google.com; s=arc-20160816; b=CWm1PX0tKizoxyEIf/CpwFGpMeIuGI/K7qfSN/7G6IFjDv//hLreU366VKxZ6FXOr5 JPvWrouaMMsU/N7u1VS+DzaTmTGa6BydWAB5OMeWpzoKGQgSXhJyDV42KWjXUKt0jN5f hNpcAwQ6GA+oLEKKHf+/ZBzFSIazEcmqWPEhMtmTZitqpl+tit/y3AE11h3Ue04O1ZIo rBIudiS8fqAZXDF24ZpohatM1mYUqfZRjNoYV0mySrT8JoqpAf5KIJPcerrxP6BPbLa4 K2W0ui+lPdKFTj+io1yUcM6w3GcIGu3YpGNahZ0jxJcft5B/vc7NmvIXYp0Wk/HEzb4q /3cw== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=R7ZNJlaqp8GSpG9iatV9CsosxNubuXEWB8hYZg3ZABo=; b=vPjwBQPqoKLJHQNfB4qmmp9tzQwp/op5jM/uSiEMD28XtdzQmZeayUy1JEmzXoWbbQ hIMjek0oyKT9fIKyujb3yBmsldy+lr9VYHmTWQ3Pjgldc3K1jMORpb7Paux3FntF7sJr cjvpAg5jVwdmFN7P0B9tjXGBWZXBr9ngtihBxI2ogfwIxMdG1Dh13IxSPLRUY59uyqYu I6J/pk7p2awsQG5pOSn8+DRCMGnxcCMhn3xnzu7pAVzLTgZA3akHNdHllYlhFLJu0ULL IjWqssl+jO9eAO7YR4B+F48JKAXXeXLYn1R/wmzwumVFTSfsIiCSVW+gg+WkyyVMJcje pglA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=KSyEVJWQ; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k8si2030390pll.213.2019.06.06.09.35.35; Thu, 06 Jun 2019 09:35:51 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=KSyEVJWQ; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727909AbfFFMGx (ORCPT + 99 others); Thu, 6 Jun 2019 08:06:53 -0400 Received: from mail-lf1-f65.google.com ([209.85.167.65]:36439 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726922AbfFFMGx (ORCPT ); Thu, 6 Jun 2019 08:06:53 -0400 Received: by mail-lf1-f65.google.com with SMTP id q26so1355174lfc.3; Thu, 06 Jun 2019 05:06:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=R7ZNJlaqp8GSpG9iatV9CsosxNubuXEWB8hYZg3ZABo=; b=KSyEVJWQEAGeNjkM0M25ea194Kr78Z0HoM1QpSkVGhD2e7pB9J2vbVJ/G4sCHXMCFn DDmW8pFDKIQugaRdyOHf3C+AvfcyKJyHELE4j/JzZUxBBidg1v5uB6kYRRzO88wHQbrK oa6eUu57sSpximL+edAi8vlcsrWLz/728il0PtWj1d+HOUf31d81lt0VSIwQKK+yzEOk dPefFCB+ZTLKVs73eGPukGyf6l0nCxpDp0rsDY28b+7aDcuFWi/GUsgLzCSh7hEwzjfi sbXOMaGbm6pviz3ab4z34mJmcvZhzu6fsMOCsEns9VmA3u6oHQCO3rf5YvSqN80zELZ8 PoDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=R7ZNJlaqp8GSpG9iatV9CsosxNubuXEWB8hYZg3ZABo=; b=e5EA9v6fkEaTqYFIjYyqByCquWiYwXiCKYh4jL0LcdHmrKjof8iL8i4ePjY9WUbQPU jTEiNvEHc3XOafVBmVWHkYJXhNKLwv3gYl50uv4P1SG5xTUwPNzgXk0Sv0V6215TR2iL 2HI9L0Y2CzSvOKT9o//sdkxpeZVAd/3dQJ3XH0kNXuVJ1ZWZAEGquRzg5+UZ5I56gJbY VzQf7Wem9A4npHpdGkLJi6ktBi3lXMkFjLy/KqMsp2/oj+ab4LRwJCTt60VDnZjNL77z 4lTcmWIS6JNuWM3IGDGqPftDK2kzj4LbhCcVp6YpGF3DBXYoo/RRGrSsZissMrTdl2Ma uZ/g== X-Gm-Message-State: APjAAAVG2zUCZkg1kEKbawZFdulmP0lLUw0ArRMJ/osuWkhTbjBhkd0/ VciDAFcPlrPsVS8+c5rM075u7HAr X-Received: by 2002:ac2:5446:: with SMTP id d6mr23084965lfn.138.1559822810432; Thu, 06 Jun 2019 05:06:50 -0700 (PDT) Received: from [192.168.2.145] ([94.29.35.141]) by smtp.googlemail.com with ESMTPSA id 1sm304424ljt.78.2019.06.06.05.06.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 06 Jun 2019 05:06:49 -0700 (PDT) Subject: Re: [PATCH V2] i2c: busses: tegra: Add suspend-resume support To: Bitan Biswas , Laxman Dewangan , Thierry Reding , Jonathan Hunter , linux-i2c@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Shardar Mohammed , Sowjanya Komatineni , Mantravadi Karthik References: <1559800475-5446-1-git-send-email-bbiswas@nvidia.com> From: Dmitry Osipenko Message-ID: Date: Thu, 6 Jun 2019 15:06:48 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <1559800475-5446-1-git-send-email-bbiswas@nvidia.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 06.06.2019 8:54, Bitan Biswas пишет: > Post suspend I2C registers have power on reset values. Before any > transfer initialize I2C registers to prevent I2C transfer timeout > and implement suspend and resume callbacks needed. Fix below errors > post suspend: > > 1) Tegra I2C transfer timeout during jetson tx2 resume: > > [ 27.520613] pca953x 1-0074: calling pca953x_resume+0x0/0x1b0 @ 2939, parent: i2c-1 > [ 27.633623] tegra-i2c 3160000.i2c: i2c transfer timed out > [ 27.639162] pca953x 1-0074: Unable to sync registers 0x3-0x5. -110 > [ 27.645336] pca953x 1-0074: Failed to sync GPIO dir registers: -110 > [ 27.651596] PM: dpm_run_callback(): pca953x_resume+0x0/0x1b0 returns -110 > [ 27.658375] pca953x 1-0074: pca953x_resume+0x0/0x1b0 returned -110 after 127152 usecs > [ 27.666194] PM: Device 1-0074 failed to resume: error -110 > > 2) Tegra I2C transfer timeout error on jetson Xavier post resume. > > Remove i2c bus lock-unlock calls in resume callback as i2c_mark_adapter_* > (suspended-resumed) help ensure i2c core calls from client are not > executed before i2c-tegra resume. > > Signed-off-by: Bitan Biswas > --- > drivers/i2c/busses/i2c-tegra.c | 23 +++++++++++++++++++++++ > 1 file changed, 23 insertions(+) > > diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c > index ebaa78d..76b7926 100644 > --- a/drivers/i2c/busses/i2c-tegra.c > +++ b/drivers/i2c/busses/i2c-tegra.c > @@ -1687,7 +1687,30 @@ static int tegra_i2c_remove(struct platform_device *pdev) > } > > #ifdef CONFIG_PM_SLEEP > +static int tegra_i2c_suspend(struct device *dev) > +{ > + struct tegra_i2c_dev *i2c_dev = dev_get_drvdata(dev); > + > + i2c_mark_adapter_suspended(&i2c_dev->adapter); > + > + return 0; > +} > + > +static int tegra_i2c_resume(struct device *dev) > +{ > + struct tegra_i2c_dev *i2c_dev = dev_get_drvdata(dev); > + int ret; > + > + ret = tegra_i2c_init(i2c_dev, false); > + if (ret) > + return ret; We're expecting that tegra_i2c_init returns a error code on a failure and nothing else, hence it will be a bit more expressive to name the returned variable as "err". There is nothing wrong with yours variant, this is just a very minor recommendation from me. Please note that a bit more wise choice of the names makes easier to follow the code for other people and hence results in a cleaner code. > + > + i2c_mark_adapter_resumed(&i2c_dev->adapter); Please add a blank line here for a better readability and to make the patch consistent. You added the blank line in a similar case of tegra_i2c_suspend() and this makes it inconsistent. > + return 0; > +} > + > static const struct dev_pm_ops tegra_i2c_pm = { > + SET_SYSTEM_SLEEP_PM_OPS(tegra_i2c_suspend, tegra_i2c_resume) > SET_RUNTIME_PM_OPS(tegra_i2c_runtime_suspend, tegra_i2c_runtime_resume, > NULL) > }; >