From: Thierry Reding <thierry.reding@gmail.com>
To: mirq-test@rere.qmqm.pl
Cc: Wolfram Sang <wsa@the-dreams.de>,
Dmitry Osipenko <digetx@gmail.com>,
Jon Hunter <jonathanh@nvidia.com>,
linux-i2c@vger.kernel.org, linux-tegra@vger.kernel.org
Subject: Re: [PATCH 2/5] i2c: tegra: Restore pinmux on system resume
Date: Thu, 7 May 2020 12:03:15 +0200 [thread overview]
Message-ID: <20200507100315.GA2890327@ulmo> (raw)
In-Reply-To: <20200506224336.GA23423@qmqm.qmqm.pl>
[-- Attachment #1: Type: text/plain, Size: 2432 bytes --]
On Thu, May 07, 2020 at 12:43:36AM +0200, mirq-test@rere.qmqm.pl wrote:
> On Wed, May 06, 2020 at 09:33:55PM +0200, Thierry Reding wrote:
> [...]
> > --- a/drivers/i2c/busses/i2c-tegra.c
> > +++ b/drivers/i2c/busses/i2c-tegra.c
> > @@ -1769,10 +1769,14 @@ static int tegra_i2c_remove(struct platform_device *pdev)
> > static int __maybe_unused tegra_i2c_suspend(struct device *dev)
> > {
> > struct tegra_i2c_dev *i2c_dev = dev_get_drvdata(dev);
> > + int err = 0;
> >
> > i2c_mark_adapter_suspended(&i2c_dev->adapter);
> >
> > - return 0;
> > + if (!pm_runtime_status_suspended(dev))
> > + err = tegra_i2c_runtime_suspend(dev);
> > +
> > + return err;
> > }
> >
> > static int __maybe_unused tegra_i2c_resume(struct device *dev)
> > @@ -1788,9 +1792,11 @@ static int __maybe_unused tegra_i2c_resume(struct device *dev)
> > if (err)
> > return err;
> >
> > - err = tegra_i2c_runtime_suspend(dev);
> > - if (err)
> > - return err;
> > + if (pm_runtime_status_suspended(dev)) {
> [...]
> Shouldn't this be negated as in suspend? I would assume that inbetween
> suspend and resume nothing changes the stored state.
I know this is confusing because I have now twice had the same doubts
after looking at the patch after I sent it out and thought I had sent
out a wrong version.
However, I think it starts to make more sense when you look at the
resulting code, which I'll reproduce below:
static int __maybe_unused tegra_i2c_resume(struct device *dev)
{
struct tegra_i2c_dev *i2c_dev = dev_get_drvdata(dev);
int err;
err = tegra_i2c_runtime_resume(dev);
if (err)
return err;
err = tegra_i2c_init(i2c_dev, false);
if (err)
return err;
if (pm_runtime_status_suspended(dev)) {
err = tegra_i2c_runtime_suspend(dev);
if (err)
return err;
}
i2c_mark_adapter_resumed(&i2c_dev->adapter);
return 0;
}
So the purpose here is to runtime resume the I2C controller temporarily
so that the register context can be reprogrammed because it was lost
during suspend. Now, if the controller was runtime suspended prior to
system suspend, we want to put it back into suspend after the context
was loaded again. Conversely, if it was not runtime suspended, then we
want to keep it on.
If it helps I can sprinkle some comments throughout this function to try
and explain why exactly this is being done.
Thierry
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2020-05-07 10:03 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-06 19:33 [PATCH 0/5] i2c: tegra: Various fixes and improvements Thierry Reding
2020-05-06 19:33 ` [PATCH 1/5] Revert "i2c: tegra: Fix suspending in active runtime PM state" Thierry Reding
2020-05-06 19:33 ` [PATCH 2/5] i2c: tegra: Restore pinmux on system resume Thierry Reding
2020-05-06 22:43 ` mirq-test
2020-05-07 10:03 ` Thierry Reding [this message]
2020-05-07 12:20 ` Michał Mirosław
2020-05-07 21:50 ` Dmitry Osipenko
2020-05-08 10:31 ` Thierry Reding
2020-05-08 15:00 ` Dmitry Osipenko
2020-05-09 15:35 ` Dmitry Osipenko
2020-05-19 16:07 ` Thierry Reding
2020-05-19 15:57 ` Thierry Reding
2020-05-08 15:05 ` Dmitry Osipenko
2020-05-06 19:33 ` [PATCH 3/5] i2c: tegra: Keep IRQs enabled during suspend/resume Thierry Reding
2020-05-06 19:33 ` [PATCH 4/5] i2c: tegra: Better handle case where CPU0 is busy for a long time Thierry Reding
2020-05-06 19:33 ` [PATCH 5/5] i2c: tegra: Synchronize DMA before termination Thierry Reding
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200507100315.GA2890327@ulmo \
--to=thierry.reding@gmail.com \
--cc=digetx@gmail.com \
--cc=jonathanh@nvidia.com \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-tegra@vger.kernel.org \
--cc=mirq-test@rere.qmqm.pl \
--cc=wsa@the-dreams.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).