Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp8222830ybi; Thu, 6 Jun 2019 08:36:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqzMqdNMveiCFLU4FsomYslgHqOHjjZdWTjOD4jMd0cAEuSa34FXviV7UQtxMj5xiXA1ybS0 X-Received: by 2002:a62:5487:: with SMTP id i129mr51145382pfb.68.1559835385598; Thu, 06 Jun 2019 08:36:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559835385; cv=none; d=google.com; s=arc-20160816; b=Li/mFT/ByZdO4Al8E6NjpOUMYhMjrLlsrcd5zbM5MXapbyPlBvkxY4cC3CtJ0lf1hF kxXD7KuQce3uV3iqWt4yKDRXEOwicT9tqSL6v4vcJEgbL9idFr8Lm+WHOVWEB8CoEiwq /Gh64GBJ8M02cj+bsbLsk8wmZw7ofpDv2zEtAZ6ReoAK54E3t3CyZiAaqL1aXlJ4aLNn QWCXYdzwnWlBub/wIxAspxowiAe9XlkyHtwekJKnhtYbORNeE5sltshG+cs00eoZ22v5 nC9PjCBIX0ipd1yJt6WO9dWGpTYAVLs88MOLWwJNbtn9RUrV5wZtMKbxNa8+SFRBqMzp SzBA== 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=CNzuT4B+gj0fca3L+CBElR5BCGQz7D37R5CsfOS0R5U=; b=VV3TZ0neJXregYThSMsO71kYTiY9v9bQ5r7Y5TSJ3z0odjJOWKu3fuG1aWdu8oNrx0 tEJUxFApQSi5V5Q445WabpBuXXSpUf1HoJNBWvFhclzHCxyv0XUsQsHyPFB2HxZ4hGB4 a0yNftQnyxJlaUi5Otbjdk0EUaRjpm5S2Fm31Pwx27Xzms9tj5CqQ6drWu/DfxS20x2n rWPOfr6a5vDukWTunvF/FKS9OEwcpsWafRnj2uPydCMRHm6Dmw+3TycNqruYWvVwz4mh TPxHxuZ4z/mTIqTq6e32DeNIhzM7itIaKb1OnadTKYFSqLurS0ndvXYlVBGB9yUGhRXU lqzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=VWscwD+f; 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 i4si2134618pfc.26.2019.06.06.08.36.08; Thu, 06 Jun 2019 08:36:25 -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=VWscwD+f; 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 S1729365AbfFFPe7 (ORCPT + 99 others); Thu, 6 Jun 2019 11:34:59 -0400 Received: from mail-lj1-f195.google.com ([209.85.208.195]:37097 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729185AbfFFPe7 (ORCPT ); Thu, 6 Jun 2019 11:34:59 -0400 Received: by mail-lj1-f195.google.com with SMTP id 131so2485052ljf.4; Thu, 06 Jun 2019 08:34:57 -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=CNzuT4B+gj0fca3L+CBElR5BCGQz7D37R5CsfOS0R5U=; b=VWscwD+f7KttjezbVWzpZtP1ZvHaxYlbphCgYRA7iz58igJeZyW24ly4jyIogAH0Uw SHrCD9VcA1bnc0g4lDBUhiArGjnOKqINogD2cGRbqydhHmnbOt/9FOVwptsK9Ts/EDtM vDeCBMXacEKgoIZrgg06bMgL6XwQiMlNa6OYNbARX2UOEv9qlrzo91Z0ocO6b9jNToYz bk9kivBv6638oKvzKIlHqdQFNM0fpg9+4i4hwoRfSp3YM5699DWdG248k1ySlPOe+zy8 uVede+6ARmkEQwT4pDGyhUevnkhKW36zKI80lgtHM1ZzG3Repouf0aKJO1Ff4gS7RXBF mv6w== 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=CNzuT4B+gj0fca3L+CBElR5BCGQz7D37R5CsfOS0R5U=; b=Gh74JyOWZ7yCfR8bCvvK+yG8e4qIhyBMqG2WYcE0NascSTzLcWy5BpPO0K/jROuPVH GEOfWVbU17mVAiDCKQs/4sVNDkCczWAGIyuBjfrTDuJ1ngGELMBmd7w7xG+3cjKIGbgT lnE7pJN24qH0wssvvCqun93wPmlF4yjWeg6Id/kVJmdiPcHB+l3dazF/stuXWzEDtxx8 241Hwid/grhqPPrUeSgTWXQgsMNvrwA0sVN5R1cFvOaJgNKqD0c9cGnvIMiUTpNwM0Ru jL98ob5bW70YgT8jHtlwiilss+TWQaFp1GQ3M7XLxE6WEe2zEeuvHYQ3DFWuEB/LdVyD 6/Aw== X-Gm-Message-State: APjAAAXikuLb3n0lOH5R9D2Ap9GCWNGP1H6gER4K3cPSfroFivw3P0DH 2za24uaqeQUKhcr9CwAbS0s= X-Received: by 2002:a2e:988b:: with SMTP id b11mr10513015ljj.85.1559835296660; Thu, 06 Jun 2019 08:34:56 -0700 (PDT) Received: from [192.168.2.145] ([94.29.35.141]) by smtp.googlemail.com with ESMTPSA id z12sm343409lfe.2.2019.06.06.08.34.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 06 Jun 2019 08:34:55 -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> <5871f51b-11d4-8bc9-6f40-4a91f2aab8f8@nvidia.com> From: Dmitry Osipenko Message-ID: <3d4ea007-e289-6b52-5321-68a7399e62d7@gmail.com> Date: Thu, 6 Jun 2019 18:34:55 +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: <5871f51b-11d4-8bc9-6f40-4a91f2aab8f8@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 16:58, Bitan Biswas пишет: > > > On 6/6/19 5:06 AM, Dmitry Osipenko wrote: >> 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. > Agreed. > >> >>> + >>> +    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. >> > OK. > >>> +    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) >>>   }; >>> > I shall send updated patch with suggested changes. Yes, please.